657

From C64-Wiki
Jump to navigationJump to search

The address 657 ($291) holds a system flag that controls whether the user can change character set through the SHIFT  + C=  combination from the keyboard: If the most significant bit is set ("1"), changing character set is disabled. The default setting is that this bit is clear ("0"), thus allowing character set changes. Note that this flag only affects the user's ability to change character sets from the keyboard – regardless of the state of address 657, the software may change character sets "at will", either by printing the control characters n (PETSCII code 14/$0E; select upper/lower case) and N (code 142/$8E; select uppercase/graphics), or directly through address 53272/$D018 and the VIC bank conficuration.

ROM system usage[edit | edit source]

The system modifies address 657 when either of the control characters h (code 8/$08; disable charactert set change) and i (code 9/$09; enable character set change); this is handled in KERNAL ROM at 60510–60535/$EC5E–EC77. Furthermore, address 657 is initialized during cold start (i.e. power-on or reset) to allow changing character sets by default; this takes place in ROM at 58651–58657/$E51B–E51F.

At 60232–60256/$Eb48–EB60, KERNAL checks if the SHIFT  + C=  key combination is present, and, if "allowed" by address 657, performs the character set change.

Example[edit | edit source]

First, make sure the system is set up to allow chacater set changes using SHIFT  + C= }}; if this is not the case, press CTRL  + <I>  to allow this. Then check the contents of address 657 by typing:

print peek(657)
 0
ready.

This shows that the flag bit is off, indicating character changes are allowed. To "dissalow" it, you may either

  • press CTRL  + H ,
  • type print chr$(8) or print "h" (h is obtained by pressing CTRL  + H )

After this, PEEK'ing into 657 now reveals that the "locking" bit has been set:

print peek(657)
 128
ready.

User programs may disable or enable the character set changes either by PRINTing the appropriate control characters, but accessing address 657 directly is much faster, whether the program is written i BASIC or machine language: Putting any integer from 0 through 127 in address 657 renders the most significant bit clear, thus allowing character set changes, whereas any byte value above 127 sets the bit in question, disabling changes.