SCREENCODES to PETSCII

Started by MIRKOSOFT, August 16, 2010, 11:49 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

MIRKOSOFT

Hi!


My Q is 'think too stupid, but also:


If I look at screencodes in LCASE, 0-26 are letters, 64-90 are capitals.
If I look at PETSCII, 0-31 are cotntrol codes, 128-159 too.


But I want to display full charset of SCREENCODES (which I know) and transfer it to PETSCII to display.
It seems that's not problem, but one Q is here: where are the "lost" 64 codes which are in PETSCII control codes?
No problem with decode, but I'm like dumb - can PETSCII display full 256 screencodes? It seems like 256 + 64 control codes and that's what I don't understand...
I created my Slovak font and want to use BSOUT to display codes, but it needs decoding to PETSCII from screencodes... and there are missing 64 codes, so where are the lost?
Or easier solution: exists routine which is similar to BSOUT except displays SCREENCODES instead PETSCII?


Thanks for every reply.


Miro
MIRKOSOFT of megabytes

Commodore 64 was great, Commodore 128 is bigger, better, faster and more!!!

http://www.mirkosoft.sk

Hydrophilic

This is a difficult topic to discuss...

You could say there are two PETSCII codes.  One PETSCII code for Upper/Lower - Case characters and a second PETSCII code for Upper/Graphic - characters.

OR

You could say there is one PETSCII code which is displayed with two possible character sets.

This is the complicated view of C64, C16, and Plus/4 (and original C128).

It gets MORE complicated with nationalized versions of C128 which have ASCII/DIN key instead of CAPS LOCK; these machines have yet another character set!

...

To keep things simple, let's assume Upper / Lower - Case character set and PETSCII codes (and no national character set).

Here, like you say, are special PETSCII codes from $00 to $1F (0 to 31) and also from $80 to $9F (128 to 159).  Lower-case letters are ONLY from $41 to $5A; Upper-case letters are repeated ($61 to $7A and $C1 to $DA); limited graphics are also repeated ($A0 to $BF and $E0 to $FF).

You ask which 64 characters are missing?  A better question would be: which characters are not repeated?  The Lower-Case values (letters and a few punctuations) from $40 to $5F are not repeated (that is 32 "missing" characters), and numbers/punction ($20 to $3F) are not repeated (the other "missing" 32 characters).

Another way to say this is, Upper-Case character are repeated at $C0-$DF (because they are repeated, you loose 32 characters), and the limited graphic characters are repeated at $E0-$FF (so you loose another 32 characters).

Simplest answer: 64 characters (PETSCII $C0 to $FF) are duplicates of other characters so they are "missing".

There is no KERNAL routine to print screen codes.  The old way is to simply POKE or STA the screen-code directly into RAM (no KERNAL needed) but on the C128 it is not that simple when using VDC / 80-Columns.  In 80-columns, you have to write your own subroutine to emulate POKE/STA into video-RAM... and you need to store twice!  Once for "screen code" and second for "attribute".
I'm kupo for kupo nuts!

MIRKOSOFT

Hi!


Yes, sure, using STA XX at address or VDC-access by STA is possible.
But it's too complicated if I compare routine BSOUT. Really doesn't exists routine which prints screencodes like BSOUT (instead PETSCII)?


Thanks.


Miro
MIRKOSOFT of megabytes

Commodore 64 was great, Commodore 128 is bigger, better, faster and more!!!

http://www.mirkosoft.sk

BigDumbDinosaur

Quote from: Hydrophilic on August 17, 2010, 12:32 AMIn 80-columns, you have to write your own subroutine to emulate POKE/STA into video-RAM...
No you  don't.  Use the screen kernel ROM subs at $CDCC and $CDDA.

Quote...and you need to store twice!  Once for "screen code" and second for "attribute".
The same applies to writing directly to VIC video.  One store to video RAM and another to color RAM.
x86?  We ain't got no x86.  We don't need no stinking x86!

Hydrophilic

BDD: when I said there is no ROM code, I was referring to the current topic: no ROM code for printing raw screen codes.  It would be nice if there were some ROM code that works like BSOUT but uses screen codes instead of PETSCII... and I think I found it, see below!

Yes, two stores (one for character and one for color) are needed for either VIC or VDC.  I just wanted to point out that if you write your own "print" routine, that two parts of memory need to be updated, and while this is easy with direct memory access of VIC, it requires more work for VDC.  For example, the VIC code may be

$CC44 STA ($E0),Y
$CC46 TXA
$CC47 STA ($E2),Y

but for the VDC, the code may be

$CC4A PHA
$CC4B TXA
$CC4C PHA
$CC4D JSR $CDF9
$CC50 PLA
$CC51 JSR $CDCA
$CC54 JSR $CDE6
$CC57 PLA
$CC58 JMP $CDCA


Anyway, I think I found a ROM routine for printing screen codes.  Editor ROM entry $C003: DISPLAY.  This is the second entry in the Editor Jump Table.  It is not directly referenced by any other ROM routine, and I've never seen anybody use it, but I think it should solve the issue at hand.  It does JMP $CC34 which writes screen code (A register) and color/attribute code (X register) to the cursor position of the active display.

So you can use BSOUT to clear the screen, move the cursor, and/or swap 40/80 mode.  Then call DISPLAY ($C003) to print screen/color code pairs.  Just remember for VDC you also need to "upload" your custom character set, and that "color" codes of VDC control more than color.

Also, color codes for VDC are different than VIC.  There is a table in ROM at $CE5C that has VDC color codes.  For example, White (VIC color 1) can be found at $CE5C+1.  The value in ROM is $0F which is the VDC code for White.  Or Red (VIC color 2) at $CE5C+2 has $08 in ROM, the VDC code for Red.

Another important thing to note is that the cursor position is not updated after calling DISPLAY.  You should consider calling $C33E after calling DISPLAY to advance the cursor.

I hope that helps!
I'm kupo for kupo nuts!

BigDumbDinosaur

Quote from: Hydrophilic on August 19, 2010, 06:40 PMAnyway, I think I found a ROM routine for printing screen codes.  Editor ROM entry $C003: DISPLAY.
That's correct.  Here's a brief description of the DISPLAY call at $C003:

49155 $C003 JDISPLY
Entry point for the routine at 52276/SCC34, which deposits a
screen code and attribute value at the current cursor position.
Call this entry with the accumulator holding the screen code
(not the character code) for the desired character and the X
register holding the attribute value for the character.


As Hydro noted, the above routine doesn't advance the cursor.  Take a look at the JCRSR80 in the screen kernel at $C01B:

49179 $C01B JCRSR80
Entry point for the routine at 52567/$CD57, which moves the
cursor on the 80-column display to the row and column specified
in 235/$EB and 236/$EC, respectively. The 40-column
display's cursor is maintained by software, so it follows these
pointers automatically, but the position of the 80-column
cursor must be set explicitly.


You can also use JPLOT ($C018) to explicitly set the cursor position, as well as read it.
x86?  We ain't got no x86.  We don't need no stinking x86!