6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun Nov 10, 2024 4:14 pm

All times are UTC




Post new topic Reply to topic  [ 24 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: Sat Jun 18, 2011 2:46 pm 
Offline

Joined: Tue Jul 05, 2005 7:08 pm
Posts: 1042
Location: near Heidelberg, Germany
paul_nicholls wrote:
Speaking of which, does any here know how to set the c64 text mode to upper-case only, or both lower/upper case?


I think there are some key combinations on the C64 you can use, but you can also use
Code:
         print chr$(14)

resp.
Code:
         print chr$(142)

to switch between upper/lower and graphics/uppercase characters

André


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Jun 18, 2011 10:56 pm 
Offline

Joined: Wed Jan 19, 2011 10:20 pm
Posts: 42
Thanks André :)

After doing some googling I found this:

http://en.wikipedia.org/wiki/PETSCII

Quote:
PETSCII provides for shifting between the power-on default (unshifted) uppercase+graphics character set and the alternative (shifted) lower+uppercase set (where the shifted set contains a subset of the block graphic characters of the unshifted set). The shift between modes is done by POKEing location 59468 with the value 14 to select the alternative set or 12 to revert to standard. On C64 the sets are alternated by flipping bit 2 of the byte 53272.


I am going to try the bit flipping (or just set/clear) to see if this works for me :)

cheers,
Paul

_________________
"The plastic veneer of civilization is easily melted in the heat of the moment" - Paul Nicholls


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Jun 19, 2011 4:42 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8479
Location: Midwestern USA
paul_nicholls wrote:
I might look up the PETSCII codes and see if I can maybe convert upper-case chars to PETSCII shifted versions, and lowercase characters to normal upper-case characters as I am doing now :)

I can give you some simple code that can map between PETSCII and ASCII. Use it all the time to drive standard printers from C= hardware.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Jun 19, 2011 4:45 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8479
Location: Midwestern USA
paul_nicholls wrote:
Thanks André :)

After doing some googling I found this:

http://en.wikipedia.org/wiki/PETSCII

Quote:
PETSCII provides for shifting between the power-on default (unshifted) uppercase+graphics character set and the alternative (shifted) lower+uppercase set (where the shifted set contains a subset of the block graphic characters of the unshifted set). The shift between modes is done by POKEing location 59468 with the value 14 to select the alternative set or 12 to revert to standard. On C64 the sets are alternated by flipping bit 2 of the byte 53272.


I am going to try the bit flipping (or just set/clear) to see if this works for me :)

cheers,
Paul

Printing the characters that André mentioned is less work than twiddling bits. Don't forget that the entire screen will change state when you switch character sets. The C-64, unlike the C-128 in 80 column mode, cannot display from both char sets at the same time.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Jun 19, 2011 7:28 am 
Offline

Joined: Wed Jan 19, 2011 10:20 pm
Posts: 42
BigDumbDinosaur wrote:
paul_nicholls wrote:
I might look up the PETSCII codes and see if I can maybe convert upper-case chars to PETSCII shifted versions, and lowercase characters to normal upper-case characters as I am doing now :)

I can give you some simple code that can map between PETSCII and ASCII. Use it all the time to drive standard printers from C= hardware.


Cool! Thanks mate, that would be very handy :)

cheers,
Paul

_________________
"The plastic veneer of civilization is easily melted in the heat of the moment" - Paul Nicholls


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Jun 20, 2011 9:52 am 
Offline

Joined: Wed Jan 19, 2011 10:20 pm
Posts: 42
@BigDumbDinosaur, I found online some lookup tables that can be used to convert ASCII <--> PETSCII

Code:
const
  cASCIIToPETSCIITable: array[0..256 - 1] of Byte = (
    $00,$01,$02,$03,$04,$05,$06,$07,$14,$20,$0d,$11,$93,$0a,$0e,$0f,
    $10,$0b,$12,$13,$08,$15,$16,$17,$18,$19,$1a,$1b,$1c,$1d,$1e,$1f,
    $20,$21,$22,$23,$24,$25,$26,$27,$28,$29,$2a,$2b,$2c,$2d,$2e,$2f,
    $30,$31,$32,$33,$34,$35,$36,$37,$38,$39,$3a,$3b,$3c,$3d,$3e,$3f,
    $40,$c1,$c2,$c3,$c4,$c5,$c6,$c7,$c8,$c9,$ca,$cb,$cc,$cd,$ce,$cf,
    $d0,$d1,$d2,$d3,$d4,$d5,$d6,$d7,$d8,$d9,$da,$5b,$5c,$5d,$5e,$5f,
    $c0,$41,$42,$43,$44,$45,$46,$47,$48,$49,$4a,$4b,$4c,$4d,$4e,$4f,
    $50,$51,$52,$53,$54,$55,$56,$57,$58,$59,$5a,$db,$dc,$dd,$de,$df,
    $80,$81,$82,$83,$84,$85,$86,$87,$88,$89,$8a,$8b,$8c,$8d,$8e,$8f,
    $90,$91,$92,$0c,$94,$95,$96,$97,$98,$99,$9a,$9b,$9c,$9d,$9e,$9f,
    $a0,$a1,$a2,$a3,$a4,$a5,$a6,$a7,$a8,$a9,$aa,$ab,$ac,$ad,$ae,$af,
    $b0,$b1,$b2,$b3,$b4,$b5,$b6,$b7,$b8,$b9,$ba,$bb,$bc,$bd,$be,$bf,
    $60,$61,$62,$63,$64,$65,$66,$67,$68,$69,$6a,$6b,$6c,$6d,$6e,$6f,
    $70,$71,$72,$73,$74,$75,$76,$77,$78,$79,$7a,$7b,$7c,$7d,$7e,$7f,
    $e0,$e1,$e2,$e3,$e4,$e5,$e6,$e7,$e8,$e9,$ea,$eb,$ec,$ed,$ee,$ef,
    $f0,$f1,$f2,$f3,$f4,$f5,$f6,$f7,$f8,$f9,$fa,$fb,$fc,$fd,$fe,$ff
  );

  cPETSCIIToASCIITable: array[0..256 - 1] of Byte = (
    $00,$01,$02,$03,$04,$05,$06,$07,$14,$09,$0d,$11,$93,$0a,$0e,$0f,
    $10,$0b,$12,$13,$08,$15,$16,$17,$18,$19,$1a,$1b,$1c,$1d,$1e,$1f,
    $20,$21,$22,$23,$24,$25,$26,$27,$28,$29,$2a,$2b,$2c,$2d,$2e,$2f,
    $30,$31,$32,$33,$34,$35,$36,$37,$38,$39,$3a,$3b,$3c,$3d,$3e,$3f,
    $40,$61,$62,$63,$64,$65,$66,$67,$68,$69,$6a,$6b,$6c,$6d,$6e,$6f,
    $70,$71,$72,$73,$74,$75,$76,$77,$78,$79,$7a,$5b,$5c,$5d,$5e,$5f,
    $c0,$c1,$c2,$c3,$c4,$c5,$c6,$c7,$c8,$c9,$ca,$cb,$cc,$cd,$ce,$cf,
    $d0,$d1,$d2,$d3,$d4,$d5,$d6,$d7,$d8,$d9,$da,$db,$dc,$dd,$de,$df,
    $80,$81,$82,$83,$84,$85,$86,$87,$88,$89,$8a,$8b,$8c,$8d,$8e,$8f,
    $90,$91,$92,$0c,$94,$95,$96,$97,$98,$99,$9a,$9b,$9c,$9d,$9e,$9f,
    $a0,$a1,$a2,$a3,$a4,$a5,$a6,$a7,$a8,$a9,$aa,$ab,$ac,$ad,$ae,$af,
    $b0,$b1,$b2,$b3,$b4,$b5,$b6,$b7,$b8,$b9,$ba,$bb,$bc,$bd,$be,$bf,
    $60,$41,$42,$43,$44,$45,$46,$47,$48,$49,$4a,$4b,$4c,$4d,$4e,$4f,
    $50,$51,$52,$53,$54,$55,$56,$57,$58,$59,$5a,$7b,$7c,$7d,$7e,$7f,
    $a0,$a1,$a2,$a3,$a4,$a5,$a6,$a7,$a8,$a9,$aa,$ab,$ac,$ad,$ae,$af,
    $b0,$b1,$b2,$b3,$b4,$b5,$b6,$b7,$b8,$b9,$ba,$bb,$bc,$bd,$be,$bf
  );


I have converted it from C to Pascal, but it should be easily converted to other languages, or even Assembly :)

I got them from here:
http://codebase64.org/doku.php?id=source_conversion

See Petcom (petcom.c)

cheers,
Paul

_________________
"The plastic veneer of civilization is easily melted in the heat of the moment" - Paul Nicholls


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Jun 20, 2011 5:32 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8479
Location: Midwestern USA
paul_nicholls wrote:
BigDumbDinosaur wrote:
paul_nicholls wrote:
I might look up the PETSCII codes and see if I can maybe convert upper-case chars to PETSCII shifted versions, and lowercase characters to normal upper-case characters as I am doing now :)

I can give you some simple code that can map between PETSCII and ASCII. Use it all the time to drive standard printers from C= hardware.


Cool! Thanks mate, that would be very handy :)

cheers,
Paul

I couldn't seem to find the file in which I have PETSCII to ASCII conversion. It may be off-line on an archive tape (which I don't store here), so I'll have to do some digging.

Meanwhile, here's code that takes a PETSCII character and converts it to a CBM screen code.

Code:
;================================================================================
;
;CONVERT CBM PETSCII to SCREEN CODE
;
;   ----------------------
;   .A = PETSCII character
;   ----------------------
;   .A = screen code
;   .X = entry value
;   .Y = entry value
;   ----------------------
;
;   Conversion rules:
;
;   PETSCII Range      Input          Output      Mask
;   ----------------------------------------------------
;   Low Control      $00 - $1F ---> $00 - $1F
;   Punc & Numerals  $20 - $3F ---> $20 - $3F   00111111
;   Alpha LC         $40 - $5F ---> $00 - $1F   00111111
;   Alt Alpha LC     $60 - $7F ---> $40 - $5F   01011111
;   High Control     $80 - $9F ---> $80 - $9F
;   Alpha UC         $C0 - $FE ---> $40 - $FE   01111111
;   Pi               $FF ---------> $5E
;   ----------------------------------------------------
;
petcodcl =$1f                  ;low PETSCII control range end
petcodch =$9f                  ;high PETSCII control range end
petcodl  =$60                  ;regular LC PETSCII range end
petcodm  =$80                  ;alternate LC PETSCII range end
petcodp  =$7f                  ;pi PETSCII test value
petcodps =$5e                  ;pi screen code
pschmask =%01111111            ;PETSCII to screen code high-range
psclmask =%10111111            ;PETSCII to screen code mid-range
pscmmask =%11011111            ;PETSCII to screen code low-range
scblank  =$20                  ;blank char screen code
;
petscode cmp #petcodcl+1       ;low control code end
         bcc petcod03          ;skip conversion
;           
         cmp #petcodl          ;regular LC range end
         bcs petcod01          ;try next
;
         and #psclmask         ;change to LC screen code
         rts                   ;done
;
petcod01 cmp #petcodm          ;alternate LC range
         bcs petcod02          ;UC range or pi
;
         and #pscmmask
         rts
;
petcod02 cmp #petcodch+1       ;high control code end
         bcc petcod03          ;no conversion
;
         and #pschmask
         cmp #petcodp          ;is it pi?
         bne petcod03          ;no, so return it unchanged
;
         lda #petcodps         ;pi screen code
;
petcod03 rts
;

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Jun 20, 2011 8:44 pm 
Offline

Joined: Wed Jan 19, 2011 10:20 pm
Posts: 42
Thanks mate, that should come in really handy for when I want to do a TextOut(x,y,text) function in my compiler :)

cheers,
Paul

_________________
"The plastic veneer of civilization is easily melted in the heat of the moment" - Paul Nicholls


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Jun 21, 2011 6:51 am 
Offline

Joined: Wed Jan 19, 2011 10:20 pm
Posts: 42
I haven't tested it, but I have now made a look up table for PETSCII -> CBM Screen Codes similar to the other ones I did:

Code:
  cPETSCIIToCBMScreenCode: array [0..256 - 1] of Byte = (
    $80,$81,$82,$83,$84,$85,$86,$87,$88,$89,$8a,$8b,$8c,$8d,$8e,$8f,
    $90,$91,$92,$93,$94,$95,$96,$97,$98,$99,$9a,$9b,$9c,$9d,$9e,$9f,
    $20,$21,$22,$23,$24,$25,$26,$27,$28,$29,$2a,$2b,$2c,$2d,$2e,$2f,
    $30,$31,$32,$33,$34,$35,$36,$37,$38,$39,$3a,$3b,$3c,$3d,$3e,$3f,
    $00,$01,$02,$03,$04,$05,$06,$07,$08,$09,$0a,$0b,$0c,$0d,$0e,$0f,
    $10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$1a,$1b,$1c,$1d,$1e,$1f,
    $40,$41,$42,$43,$44,$45,$46,$47,$48,$49,$4a,$4b,$4c,$4d,$4e,$4f,
    $50,$51,$52,$53,$54,$55,$56,$57,$58,$59,$5a,$5b,$5c,$5d,$5e,$5f,
    $c0,$c1,$c2,$c3,$c4,$c5,$c6,$c7,$c8,$c9,$ca,$cb,$cc,$cd,$ce,$cf,
    $d0,$d1,$d2,$d3,$d4,$d5,$d6,$d7,$d8,$d9,$da,$db,$dc,$dd,$de,$df,
    $60,$61,$62,$63,$64,$65,$66,$67,$68,$69,$6a,$6b,$6c,$6d,$6e,$6f,
    $70,$71,$72,$73,$74,$75,$76,$77,$78,$79,$7a,$7b,$7c,$7d,$7e,$7f,
    $40,$41,$42,$43,$44,$45,$46,$47,$48,$49,$4a,$4b,$4c,$4d,$4e,$4f,
    $50,$51,$52,$53,$54,$55,$56,$57,$58,$59,$5a,$5b,$5c,$5d,$5e,$5f,
    $60,$61,$62,$63,$64,$65,$66,$67,$68,$69,$6a,$6b,$6c,$6d,$6e,$6f,
    $70,$71,$72,$73,$74,$75,$76,$77,$78,$79,$7a,$7b,$7c,$7d,$7e,$5e
  );


I used this info here:
http://sta.c64.org/cbm64pettoscr.html

Maybe someone will find this useful.

cheers,
Paul

_________________
"The plastic veneer of civilization is easily melted in the heat of the moment" - Paul Nicholls


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 24 posts ]  Go to page Previous  1, 2

All times are UTC


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: