• establish a few frequently-used variables, then do general init 10 X = Y = Z = BACK = CHAR: GOSUB 20000 100 ONERR GOTO 32000 • do screen init 150 GOSUB 11000 MAIN LOOP • gosub 2000 to reading paddles and check for key input; Z will be < 0 if key is pending • paddle values are clamped *before* reading the keyboard, so IJKM can push it out one more pixel • if key was hit, gosub 12000 to handle it 200 GOSUB 2000: IF Z < 0 THEN GOSUB 12000 • Z now positive, so Z=2 means button hit 590 IF MICRO THEN 700 600 IF Z < > 2 THEN 200 • read the screen color at (X,Y+1) 610 POKE 0,0: POKE 1,X: POKE 2,Y + 1: POKE 3,128: CALL PLT:BACK = PEEK (3) • if not black or white (0 or 5), not eligible for flood fill 620 IF BACK AND BACK < > 5 THEN 200 • in SAFE mode, must be a white pixel 650 IF SAFE AND NOT BACK THEN 200 • read the screen color at (X,Y) and see if it matches (dither check) 660 POKE 2,Y: POKE 3,128: CALL PLT: IF PEEK (3) < > BACK THEN 200 • if screen color is white, and we're drawing white/white, don't fill (dangerous no-op) 670 IF BACK AND EVEN = 5 AND ODD = 5 THEN 200 • fill! 690 POKE 4,EVEN: POKE 5,ODD: CALL FILL: GOTO 200 • Update position in MICRO mode. If button hit, plot a point in the current colors. 700 POKE 0,X: POKE 1,Y: CALL SCOPE: IF Z < > 2 THEN 200 730 POKE 0,0: POKE 1,X: POKE 2,Y: POKE 4,EVEN: POKE 5,ODD: CALL DITHER: GOTO 200 get name of file to read, and read it 1000 TEXT : CALL - 936 1010 VTAB 12: PRINT "READ PICTURE:";: GOSUB 21000 1020 IF LEN (A$) THEN PRINT D$;"BLOAD ";A$;", A$2000" 1050 GOTO 11070 read paddles unless FROZEN X value mapped from [0,255] to [-58,197] and clamped to [1,138] Y value mapped from [0,255] to [-32,223] and clamped to [1,190] (leaves a 1-pixel boundary on our 140x192 screen) if not in MICRO mode, draw crosshair cursor on exit: X/Y hold paddle values Z indicates key/button status: 0: nothing hit -3: key hit 2: button hit -2: key and button hit 2000 IF NOT FROZEN THEN X = PDL (0) - 58 2010 IF X < 1 THEN X = 1 2020 IF X > 138 THEN X = 138 • if key hit, set Z to -3 2050 Z = 0: IF PEEK ( - 16384) > 127 THEN Z = - 3 • if button hit, update Z; note SGN(0)==0 2060 IF PEEK ( - 16287) > 127 OR PEEK ( - 16286) > 127 THEN Z = 2 + 4 * SGN (Z) 2100 IF NOT FROZEN THEN Y = PDL (1) - 32 2110 IF Y < 1 THEN Y = 1 2120 IF Y > 190 THEN Y = 190 2150 IF MICRO THEN RETURN 2200 POKE 0,0: POKE 1,X: POKE 2,Y: CALL CROSS 2500 RETURN init screen mode 11000 REM SET PROPER SCREEN MODE • full screen mode, graphics on 11070 POKE - 16302,0: POKE - 16304,0 • in MICRO mode call INIT, which enables lo-res graphics 11080 IF MICRO THEN CALL INIT • otherwise, enable hi-res 11090 IF NOT MICRO THEN POKE - 16297,0 11100 RETURN handle keyboard input Z will be negative on entry. This negates it before returning. 12000 REM KEY WAS HIT 12300 CHAR = PEEK ( - 16384) - 128: POKE - 16368,0 12400 POKE 0,0:Z = - Z 12500 IF CHAR < > ASC ("Z") THEN 12600 12550 FROZEN = 1 - FROZEN: RETURN 12600 IF CHAR < > ASC ("I") THEN 12700 12650 Y = Y - 1: RETURN 12700 IF CHAR < > ASC ("J") AND CHAR < > 8 THEN 12800 12750 X = X - 1: RETURN 12800 IF CHAR < > ASC ("K") AND CHAR < > 21 THEN 12900 12850 X = X + 1: RETURN 12900 IF CHAR < > ASC ("M") THEN 13000 12950 Y = Y + 1: RETURN 13000 C = - 1 13010 IF CHAR = ASC ("D") THEN C = 0 13020 IF CHAR = ASC ("V") THEN C = 1 13025 IF CHAR = ASC ("P") THEN C = 1 13030 IF CHAR = ASC ("G") THEN C = 2 13040 IF CHAR = ASC ("B") THEN C = 3 13050 IF CHAR = ASC ("O") THEN C = 4 13060 IF CHAR = ASC ("L") THEN C = 5 13070 IF CHAR = ASC ("W") THEN C = 5 13100 IF C < 0 THEN 13200 13150 EVEN = ODD:ODD = C: RETURN 13200 IF CHAR < > ASC ("N") THEN 13400 13300 CALL NEG: RETURN 13400 IF CHAR < > ASC ("X") - 64 THEN 13600 13500 CALL CLEAN: RETURN 13600 IF CHAR < > ASC (" ") THEN 14000 13650 MICRO = 1 - MICRO: IF MICRO THEN 13800 13700 POKE - 16297,0: RETURN 13800 CALL INIT: RETURN 14000 IF CHAR < > ASC ("R") - 64 THEN 15000 14500 GOSUB 1000 14900 GOTO 11070 15000 IF CHAR < > ASC ("W") - 64 THEN 16000 15200 TEXT : CALL - 936 15300 VTAB 12: PRINT "WRITE PICTURE:";: GOSUB 21000 15400 IF LEN (A$) THEN PRINT D$;"BSAVE ";A$;", A$2000, L$1FF8" 15900 GOTO 11070 16000 IF CHAR < > ASC ("N") - 64 THEN 16500 16100 SAFE = 1: RETURN 16500 IF CHAR < > ASC ("F") - 64 THEN 17000 16600 SAFE = 0: RETURN 17000 IF CHAR < > ASC (D$) THEN 18000 17150 TEXT : CALL - 936: VTAB 10 17200 PRINT : PRINT : PRINT "DOS:";: GOSUB 21000 17250 IF LEN (A$) = 0 THEN 11070 17300 PRINT D$;A$ 17400 GOTO 17200 18000 REM MORE KEYS CAN BE ADDED HERE 19000 IF CHAR < > 27 THEN RETURN 19100 TEXT : CALL - 936 19510 VTAB 11: HTAB 7: PRINT "HIT 'RETURN' TO TERMINATE" 19520 VTAB 13: HTAB 6: PRINT "HIT ANY OTHER KEY TO RESUME␇" 19530 IF PEEK ( - 16384) < 128 THEN 19530 19540 POKE - 16368,0 19600 IF PEEK ( - 16384) < > 13 THEN 11070 19700 CALL - 936: VTAB 12: HTAB 4: PRINT "THANK YOU FOR USING MICRO-PAINTER" 19900 VTAB 23: POP : POKE 216,0: POKE 118,255: END general program initialization 20000 DIM A$(40):D$ = "␄" 20030 EVEN = 0:ODD = 0:MICRO = 0:SAFE = 1:FROZEN = 0 • subroutine addresses: FILL=$6800, CROSS=$6700, DITHER=$6900, PLT=$6903, SCOPE=$6A00, INIT=$6A03, CLEAN=$6CC0, NEG=$6DC0 20035 FILL = 6 * 4096 + 2048:CROSS = FILL - 256 20040 DITHER = FILL + 256:PLT = DITHER + 3 20045 SCOPE = DITHER + 256:INIT = SCOPE + 3 20050 CLEAN = SCOPE + 512 + 192:NEG = CLEAN + 256 20060 TEXT : CALL - 936: VTAB 10 20065 HTAB 11: PRINT "*** MICRO-PAINTER ***" 20070 PRINT : HTAB 18: PRINT "- BY -" 20075 PRINT : HTAB 16: PRINT "BOB BISHOP" 20100 PRINT D$;"BLOAD PAINT" 20150 PRINT D$;"BLOAD CURSOR" • check button status to see if paddles are attached 20200 IF PEEK ( - 16287) < 128 AND PEEK ( - 16286) < 128 THEN 20300 20210 CALL - 936: VTAB 12: HTAB 4 20220 PRINT "PLEASE CONNECT YOUR GAME PADDLES␇" 20230 IF PEEK ( - 16287) > 127 OR PEEK ( - 16286) > 127 THEN 20230 20250 CALL - 936: VTAB 12: HTAB 15 20260 PRINT "THANK YOU!␇" 20270 FOR K = 1 TO 1000: NEXT K 20300 ONERR GOTO 32000 • clear keyboard strobe and jump to file load 20310 POKE - 16368,0: GOTO 1000 • replacement for INPUT (why?); sets prompt and calls $FD6A (GETLN) 21000 POKE 51,160: CALL 64874 • assemble typed line from input buffer at $200 21020 Q = 512:A$ = "" 21030 CH = PEEK (Q): IF CH < > 141 THEN A$ = A$ + CHR$ (CH):Q = Q + 1: GOTO 21030 21050 RETURN • ONERR function 32000 PRINT "␇": GOTO 100 32767 REM ␊␊␊␊␊␊␊␊␊␊␊WRITTEN BY: BOB BISHOP␊␊␊␊␊␊␊␊␊␊␊