199

From C64-Wiki
Jump to: navigation, search

The zeropage address of 199 ($C7 in hexadecimal) is a system flag used to indicate whether the text output to the screen has been set to print in reverse on mode: This address contains the value 18/$12 when the reverse video mode is on, and a zero byte if reverse video is off.

From BASIC or machine language code, this address can be used both to "read" whether reverse video on the text screen is on or not, and "written" into to select or de-select reverse video mode.

Here's an example of reading the reverse video state of the text screen:

print "r";peek(199);"R";peek(199)

(note that r and R are the control characters for turning reverse video on and off, respectively: From the keyboard they are entered as CTRL + 9 and CTRL + 0. The above example would yield the following output:

 18  0
ready.

The following example demonstrates that reverse video mode can be controlled throgh address 199:

poke 199,18:print "Commodore 64"
Commodore 64
ready.

In reality the content of this register does not have to be 18/$12 to attain reverse mode; any non-zero value will do, as this example demonstrates:

poke 199,19:print "Commodore 64"
Commodore 64
ready.

ROM details[edit]

When printing visible chars (i.e. non-control characters) to the screen, the check for reverse video mode is performed by ROM code at 59027%ndash;59032/$E698: At this point the screen code for the character to be printed is held in the processor's accumulator, and the X register is loaded with the content of zeropage address 199/$C7: If this value is zero, a BEQ instruction skips an ORA operation to set the most significant bit in the screen character code, thus obtaining the code for the corresponding "reversed" character image.

Printing the reverse on control character (PETSCII code 18/$12) to the text screen is handled in the code at 59269–59274/$E785; if this character comes up, it's PETSCII code is stuck right into address 199/$C7.

Handling the reverse off character (PETSCII code 146/$92) is dealt with at 59468–59475/$E84C–E853; when this character is sent to the text screen, a zerobyte is written into address 199/$C7.