Mike wrote:I'll have a go at the listing 12-39 in the next days.
For completeness, here we go (
download):
Code: Select all
20 PRINT "BACKGROUND?";: GOSUB 50000: BA=G-1
22 PRINT "{4 SPACE}BORDER?";: GOSUB 50000: BO=G-1
24 PRINT " AUXILIARY?";: GOSUB 50000: AU=G-1
26 PRINT " CHARACTER?";: GOSUB 50000: CE=G-1
30 POKE 36879,8+BO+16*BA: REM SET BORDER, BACKGND
32 POKE 36878,16*AU: REM AUXILIARY COLOR
34 POKE 36869,204: POKE 648,16: REM SCREEN & CHARS AT $1000
36 POKE 36866,20: REM 20 COLUMNS
38 POKE 36867,25: REM 12 DOUBLE-SIZE ROWS
40 FOR J=320 TO 343: READ G:POKE J,G: NEXT:SYS 320
42 FOR J=0 TO 239:POKE 4096+J,J+16: REM SCREEN CHARS 16 & UP
44 POKE 37888+J,CE+8: REM DEFAULT CELL COLOR
46 NEXT
100 GET G$: G=ASC(G$+CHR$(0))
200 IF G>48 AND G<57 THEN G=G-49: GOSUB 40000: GOTO 500
210 IF G>32 AND G<41 THEN G=G-25: GOSUB 40000: GOTO 500
220 IF G$=" " THEN MOVE = 1-MOVE:REM SPACE TOGGLES PLOT ON/OFF
230 IF G$="{RIGHT}" THEN X=X+2: IF X>158 THEN X=158: REM RIGHT
240 IF G$="{LEFT}" THEN X=X-2: IF X<0 THEN X=0: REM LEFT
250 IF G$="{UP}" THEN Y=Y-1: IF Y<0 THEN Y=0: REM UP
260 IF G$="{DOWN}" THEN Y=Y+1: IF Y>191 THEN Y=191: REM DOWN
500 SCREENCHR = 20*INT(Y/16) + INT(X/8)
510 ROW = Y AND 15: BIT=6-(X AND 7)
520 CHAR=4352 + 16 * SCR + ROW: PE=PEEK(CH)
530 POKE CH,(PE AND (255-3*2^BIT)) AND NOT B*2^BIT: REM FLASH...
540 POKE CH,(PE AND (255-3*2^BIT)) OR B*2^BIT: REM AND PLOT
550 IF MOVE=1 THEN POKE CH,PE: REM REPLACE UNCHANGED
560 GOTO 100
1000 DATA 169,16,170,133,252,169,0,168,133: REM CLEAR CHAR DEFNS
1010 DATA 251,145,251,153,0,148,200,208
1020 DATA 248,230,252,202,208,243,96
40000 IF G=BACKGD THEN B=0: RETURN: REM SEARCH FOR COLOR
40010 IF G=BODER THEN B=1: RETURN
40020 IF G=CELL THEN B=2: RETURN
40030 IF G=AUX THEN B=3: RETURN
40040 CE=(G AND 7) + 8: B=2: REM NEW DEFAULT COLOR
40050 POKE 37888+20*INT(Y/16)+INT(X/8),CE: REM PUT INTO COLOR RAM
40060 RETURN
50000 GET G$:IF G$="" GOTO 50000: REM CONVERT COLOR KEY
50005 G=VAL(G$)
50010 IF G=0 THEN G=ASC(G$)-24
50015 PRINTG:RETURN
As given in the book, the original listing contains two errors and two misfeatures:
- In line 230, the range for X should be limited by 158, not 159 (has been corrected). Otherwise, as soon as the cursor is tried to move outside the right border, the bit patterns in line 510..530 are wrongly calculated. These formulae expect even X-coordinates.
- much more severe: the last number 33 in the DATA line 1000 should be 133 instead. This typo doesn't directly kill the machine code, as the ZP-address 251 contains a 0 after reset, but needn't so anymore after it has been used be another program. Also corrected.
- if the foreground colour is changed by selecting an "unknown" colour, only the current attribute cell is affected.
- using any other keys than given in the manual can make the program stop with an ?ILLEGAL QUANTITY error.
...
For use with a +3K RAM expansion, use "boot3k.prg"; with +8K or more, use "boot8k.prg".
The version with MINIGRAFIK will follow shortly.