10 MODE7
20 PROCassem:END
30 DEFPROCpl(X%,Y%):A%=0:CALLplot:ENDPROC
40 DEFPROCset:FOR A=0 TO 24:VDU31,0,A,145:NEXT:VDU30:ENDPROC
50 DEFPROCplot(X,Y)
60 IF X<0 OR X>77 OR Y<0 OR Y>75 ENDPROC
70 LOCAL addr,byte
80 addr=X DIV 2+40*(24-(Y DIV 3))+&7C01
90 byte=160+VALMID$("166404080102",2*((X AND 1)+2*(Y MOD 3))+1,2)
100 ?addr=?addr OR byte:ENDPROC
110 :
120 :
130 :
140 :
150 DEFPROCassem
160 Xstore=&A8:Ystore=&A9
170 addr=&AA:remainder=&AC
180 sc_start=&350
190 FOR P=0 TO 1
200 P%=&900
210 [OPT P*3
220 .plot
230 CPX #78:BCS plot_exit
240 CPY #76:BCS plot_exit
250 PHA
260 STX Xstore:STY Ystore
270 LDA #75:SEC:SBC Ystore
280 LDY #0:STY addr+1
290 .div3
300 INY:SEC:SBC #3:BPL div3
310 DEY:STA remainder:TYA
320 STA addr
330 ASL A:ASL A
340 CLC:ADC addr
350 ASL A
360 ASL A:ROL addr+1
370 ASL A:ROL addr+1
380 STA addr
390 LDA Xstore:LSR A
400 CLC:ADC addr:STA addr
410 LDA addr+1:ADC #0:STA addr+1
420 CLC
430 LDA sc_start:ADC addr:STA addr
440 LDA sc_start+1:ADC addr+1
450 CMP #&80:BCC plot2
460 SEC:SBC #&04
470 .plot2
480 STA addr+1
490 LDY #0:LDA (addr),Y
500 AND #&20:BEQ plot_exit
510 ASL remainder
520 LDA Xstore:AND #1
530 ORA remainder
540 CLC:ADC #6:TAX
550 LDA plot_bytes,X:TAX
560 PLA:PHA
570 CMP #3:BCC plot_or
580 BEQ plot_inv
590 CMP #4:BEQ plot_eor:BCS plot_exit
600 .plot_or
610 TXA:ORA (addr),Y
620 .plot_go
630 STA (addr),Y
640 .plot_exit
650 LDX Xstore:LDY Ystore
660 PLA
670 RTS
680 .plot_eor
690 TXA:EOR (addr),Y:JMP plot_go
700 .plot_inv
710 TXA:EOR #255:AND (addr),Y
720 JMP plot_go
730 .plot_bytes
740 EQUB 1:EQUB 2:EQUB 4:EQUB 8
750 EQUB 16:EQUB 64
760 ]NEXT
770 ENDPROC