Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .-----------------------------------.
- ( A P P E N D I X B . P E T S C I I )
- `-----------------------------------ยด
- general contents: https://pastebin.com/hmpJmurr
- o==========o
- | Contents |
- o==========o
- A. Character ROM, Character Sets
- B. PETSCII, control characters and screen codes
- 1. PETSCII and control characters
- 2. Screen codes and character sets
- X. References
- -<>-<>-<>-<>-<>-<>-
- o=====================================o
- | A. Character ROM and Character Sets |
- o=====================================o
- Character ROM: a 4 kB chip that holds the default character's bitmaps.
- The character ROM chip contains *two* Character Sets of 2 kB each. The first contains only upper case letters (used per default), the second also has lower case letters (and less graphical characters).
- Only one is in use a time (you must choose between 'm). A Character Set holds 128 regular characters (letters and graphics) and 128 reversed chars (256 total = 2^8 = 8 bit; screen RAM can only hold 8 bit numbers). See [3] or appendix G in [5] for the two char. sets. One Character Set is 2 kB in size. Do the math:
- One Character Set:
- 256 chars (regular and reversed) x (8 x 8 bits/character) =
- 256 x 64 bits =
- 256 x 8 Bytes =
- 2048 B = 2 kB
- The second Character Set can be activated with Shift + C= (which changes case), via register D018_hex, or with PETSCII control character 0E_hex (see chapter 'PETSCII'). After switching Character Set (Shift C=) all characters on screen change.
- The reverse characters in a Character Set can be activated with Ctrl + 9 (RVS ON), by setting register C7_hex or by PETSCII control character 12_hex (see chapter 'Petscii'). This probably sets an offset in the Character Set.
- Realize that in Character ROM there are only 128 unique characters in a Chracter Set, the rest are the reverse ones. If one uses a custom character set in RAM (to make a game level) the screen codes from 128 to 255 are not reversed.
- o=================================================o
- | B. PETSCII, control characters and screen codes |
- o=================================================o
- PETSCII is also called CBM ASCII. What is the difference between PETSCII, Control Characters, Screen Codes and a Character Set?
- 1. PETSCII and control characters
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- To print characters on screen (hexadecimal) numbers are used by the kernal routine CHROUT (FFD2_hex) and by the BASIC command CHR$. Those numbers are called PETSCII code. See [1], [2] or appendix F in [5]. Some codes refer to a character (i.e. they print a letter or graphic character from character ROM on screen), some are "Control Characters" (i.e. they code for the carriage return, home, del, colors, etc.). An example is PETSCII code 0E_hex (14_dec): it changes case. The Character Set in use is changed then. Also notice that Screen RAM is not written to then since no character is printed on screen.
- Try the following to print the letter A (PETSCII code 65_dec/41_hex) on screen:
- PRINT CHR$(65)
- PRINT CHR$(14) lower case
- PRINT CHR$(142) upper case
- There are 256 PETSCII codes (8 bit), 128 of which correspond to an actual printable non-reversed character. If you want to print the reversed characters one must set, for instance, register 00C7_hex in assembly. The control characters and 128 screen (character) codes in PETSCII do not add up to 256. Therefore some codes are duplicated [2]:
- Codes 192-223 are as codes 96-127
- Codes 224-254 are as codes 160-190
- Code 255 are as code 126
- A handy list of Control Characters and what they do can be found in [4].
- 2. Screen codes and character sets
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- The so called Screen Code of a character is its place in a Character Set from character ROM/RAM (see [3] and appendix G in [5]). This is something different from it's (hexadecimal) PETSCII code. The Screen Code for the letter A, for instance, is nr. 1 (nr. 0 is the @ sign) and in PETSCII it's nr. 65_dec (41_hex). This is why in some programming routines the number 64 is added to the Screen Code of a letter. The Screen Code of a char is used in the BASIC command POKE and in screen RAM.
- Try the following to print letter A (Screen Code 1, i.e. character 1 in Char. Set) in the upper left corner (1024_dec/400_hex is the start of screen RAM):
- POKE 1024,1
- POKE 1024,129 :REM reverse A
- One can print (reversed) characters 128 to 256 by loading 128_dec to 255_dec in screen memory (you don't have to change to reverse mode via register C7_hex).
- o===============o
- | X. References |
- o===============o
- [1] Complete Petscii table (for Assembly and CHR$):
- https://sta.c64.org/cbm64pet.html
- [2] Condensed Petscii table (for Assembly and CHR$):
- https://www.c64-wiki.com/wiki/PETSCII
- [3] Character set/screen codes for POKE):
- https://www.c64-wiki.com/wiki/Character_set
- [4] Control characters (for Assembly and CHR$):
- https://www.c64-wiki.com/wiki/control_character
- [5] "Mapping the C64", Sheldon Leemon, Compute! Publications Inc., ISBN 0-942386-23-X (1984).
Add Comment
Please, Sign In to add comment