Commodore 64 Hi-Res Quick Clear
Paul W. Downing
Here's a machine language routine that clears the Commodore 64's high-resolution screen in less than a second.
If you've ever used high-resolution graphics on the Commodore 64, you probably know how long it takes to clear the hires screen in BASIC. You need to POKE 8,000 memory locations with zeros, usually with a line like this:
FOR J = 8192 TO 16192 : POKE J,0 : NEXT
This takes about 30 seconds— not a very long time, but it can seem almost endless if you're staring at a PLEASE WAIT message on the screen, waiting for the program to set up.
"Quick Clear" is a short machine language routine that clears the hires screen in less than one second. It can be inserted in any program that uses high-resolution graphics. You don't need to understand machine language to use it— just type it in and enter RUN. This installs the ML in the cassette buffer, starting at location 828. Once the routine is in place, use SYS 828 whenever you want to clear the hires screen.
Fill With Any Value
If you've never used hires graphics before, try this experiment. Run Quick Clear, then enter the following line to put your 64 in bitmap mode:
POKE 53265, PEEK(53265) OR 32: POKE 53272, PEEK(53272) OR 8
The screen will be full of garbage. Now press SHIFT-CLR/ HOME and enter SYS 828. The screen will clear in a heartbeat.
Ordinarily, you'll want to clear the screen with zeros. But you can also use this routine to fill the hires screen with any value from 0 to 255. Just change the second number in the third DATA statement from 0 to the desired number.
The ML routine is relocatable, so you don't need to put it in the cassette buffer. To change its location, change the variable SA in line 10 from 828 to another safe address (49152, for example).
The variable HS in line 10 is the starting address of the hires screen. If you locate the screen at some address other than 8192, be sure to change HS to match.
Please refer to "COMPUTE!'s Guide to Typing In Programs" before entering this listing.
10 SA=828:HS=8192:POKE2,HS-256*INT(HS/256):POKK3,INT(HS/256) :rem 30 20 FOR A=SATOSA+31:READB:POKEA, B:NEXT :rem 74 30 DATA 165,2,133,4,165,3 :rem 193 40 DATA 133,5,162,30,160,0 :rem 233 50 DATA 169,0,145,4,136,208 :rem 45 60 DATA 251,230,5,202,16,242 :rem 81 70 DATA 160,64,145,4,136,16 :rem 45 80 DATA 251,96 :rem 181