COMPUTER BRAIN SURGERY
Feel like giving your 64 a frontal lobotomy? Try this: POKE 1,PEEK(1) AND 253. You've just removed your computer's intelligence. Hit RUN/STOP-RESTORE to return your 64 to a more productive state.
Experienced programmers will recognize the above command as the one that switches out the computer's ROM (Read Only Memory). Every time your computer prints READY, flashes the cursor, or complains about your syntax, it's because the instructions located in ROM told it to do so. Without its ROM, your computer is functionally brain dead.
Two ROMs. The 64 has two types of ROM: 8K of BASIC ROM, which is responsible for interpreting and executing BASIC instructions, and 8K of Kernal ROM, which handles the computer's more specialized functions, such as reading characters from the keyboard and moving the cursor. Together they form the 64's operating system.
BASIC ROM is located at 40960-49151 ($A000-$BFFF), and Kernal ROM is located at the top of the 64's memory map at 57344-65535 ($E000-$FFFF). As you might expect, reading one of these locations returns the value that's stored in ROM. After all, that's what the computer sees here. However, when you switch out ROM as we did above, RAM takes its place. At this point, reading one of these locations returns the value that's stored in RAM. Interestingly, values written to these locations are always stored in the RAM that resides here, no matter what the in-out status of the ROM is.
The reason your computer hangs when you switch out ROM from BASIC is because the underlying RAM doesn't contain any coherent machine language routines for the computer to execute. That is, not unless you put them there.
Customizing ROM. Because the underlying RAM can be written to at any time, it's easy to move the contents of ROM to the corresponding RAM addresses. Once that's accomplished, switching out ROM has no ill effects. Best of all, you can now modify the ROM code to your liking, thus changing the way the computer behaves.
To copy ROM to RAM and then switch out ROM, type in and run the following program. Be patient; this takes more than a minute to run.
10 FOR I = 40960 TO 49151 : POKE I, PEEK(I) : NEXT 20 FOR I = 7344 TO 65535 : POKE I, PEEK(I) : NEXT 30 POKE 1, PEEK(1) AND 253
Line 10 copies BASIC ROM, and line 20 copies Kernal ROM. Line 30 switches out ROM by clearing bit 1 of memory location 1 (the computer's R6510 register). Bit 0 of this register controls BASIC ROM, while bit 1 controls Kernal ROM. You should note that we simply clear bit 1 in line 30 because BASIC ROM is automatically switched out whenever Kernal ROM is. Only BASIC ROM can be switched independently.
READY? Now that the dirty work is done and ROM has been moved into RAM, it's time to have some fun. To begin with, let's change the READY prompt. Enter POKE 41849,65:POKE 41850,78 after running the program above. A familiar name should appear in place of the computer's normal greeting. If you like, you can add these POKEs to the end of the program above.
On the more practical side, disk drive owners can force their computers to default to loading from and saving to device 8, the disk drive, instead of device 1, the datasette. Enter POKE 57818,8 and you won't have to type a ,8 after every load and save command.
In an old issue of COMPUTE! magazine, Jim Butterfield lists a POKE that stops BASIC from shouting ILLEGAL QUANTITY ERROR every time you try to get the ASCII value of a null string. Enter POKE 46991,5 and the computer will return a value of 0 when you PRINT ASC(" ").
Sheldon Leemon mentions changing INPUT's prompt character from a question mark to a colon in his book Mapping the Commodore 64. Enter POKE 53846,58 to make this change. Actually, you could POKE the ASCII value of any character here such as a 32 for a space.
Enter POKE 61765,252 and BASIC's GET statement will wait until it receives a valid keypress before continuing on (no more GET K$:IF K$=" " THEN... commands).
Adventuresome machine language programmers might go even further and replace the 64's ROM code entirely. BASIC could be replaced with a Pascal interpreter, or the whole computer could be converted into a dedicated word processor or database system.
Of course, switching out ROM does make your computer more vulnerable to stray POKE commands. If you accidentally destroy a sensitive ROM location, your computer could easily lock up. You can switch back to the normal ROM by entering POKE 1,PEEK(1) OR 3 (assuming the computer is still responding to your commands), hitting RUN/STOP-RESTORE, or turning your computer off and on. Any mistakes (or improvements) that you make while modifying your 64's ROM code are quickly forgotten when the power goes out.