PN PLOTTER ; PFL: EQU 052H PPL: EQU 054H ; ORG 08000H BEGIN: LD SP,0B0H CALL INIT JR ELDE-# DEMO: LD HL,0 LD (AKPX),HL LD (AKPY),HL LD (LYA),HL LOOP: LD HL,00900H LD (LXA),HL LD HL,00300H LD (LYA),HL CALL PSET LD HL,0 LD (LXA),HL LD (LYA),HL CALL PSET JRZ LOOP-# RST 038H ELDE: LD HL,0 LD (AKPX),HL LD (AKPY),HL LD HL,00300H LD (LXA),HL LD (LYA),HL LD HL,00130H LD (LXE),HL LD HL,00100H LD (LYE),HL CALL ELLY CALL HOME RST 038H ; STEP: IN PFL BIT 1,A PUSH AF JRZ RDY-# RST 020H DB 2 DB 'ERROR: Plotter' DB ' not present.' DB 08DH LD BC,06024H CALL 0FFDCH POP AF RET RDY: IN PPL OR C OUT PPL LD B,10 KPAU: DJNZ KPAU-# AND 0FAH OUT PPL CALL PAU AND 0F0H OUT PPL POP AF RET SPEN: LD A,010H JR PEN-# RPEN: XOR A PEN: OUT PPL LD B,40 WAIT: CALL PAU DJNZ WAIT-# RET PAU: PUSH HL PUSH AF LD HL,160 NPAU: DEC HL LD A,H OR L JRNZ NPAU-# POP AF POP HL RET RREG: LD HL,LXA LD DE,LXA2 REG2: LD BC,8 LDIR RET LREG: LD HL,LXA2 LD DE,LXA JR REG2-# INIT: LD A,0FFH OUT PPL+1 XOR A OUT PPL LD A,0E0H OUT PPL+1 RET HOME: PUSH HL LD HL,0 LD (LXA),HL LD (LYA),HL POP HL PSET: PUSH HL PUSH DE PUSH BC CALL RREG LD HL,(LXA) LD (LXE),HL LD HL,(LYA) LD (LYE),HL LD HL,(AKPX) LD (LXA),HL LD HL,(AKPY) LD (LYA),HL CALL LIN2 PUSH AF CALL LREG POP AF POP BC POP DE POP HL RET LINE: CALL PSET RNZ LIN2: CALL 0F533H XOR A LD HL,(LYA) LD DE,(LYE) PUSH HL SBC HL,DE POP HL JRC YPL-# JRZ YPL-# OR 2 YPL: EXX LD HL,(LXA) LD DE,(LXE) OR A PUSH HL SBC HL,DE POP HL JRC XMI-# JRZ XMI-# OR 8 XMI: LD (MRT),A LCHP: XOR A SBC HL,DE JRNC LMA1-# ADD HL,DE EX DE,HL EXX EX DE,HL EXX JR LCHP-# LMA1: EXX PUSH DE LRTG: SBC HL,DE JRNC LMA3-# ADD HL,DE EX DE,HL OR 1 JR LRTG-# LMA3: PUSH HL EXX POP BC PUSH HL SBC HL,BC POP HL PUSH BC JRNC LMA5-# EX (SP),HL OR 2 LMA5: PUSH HL LD B,H LD C,L EXX POP BC POP DE LD H,B LD L,C SRL H RR L EXX POP HL LD (AKY2),HL EX DE,HL LD (AKX2),HL PLAK: PUSH AF CALL DRAW JRNZ STOP-# POP AF EXX AND A SBC HL,DE JRNC LMA6-# ADD HL,BC LMA6: EXX BIT 1,A JRNZ LMA7-# INC HL JRNC LMA8-# AND A LMA7: BIT 0,A INC DE JRZ LMA9-# DEC DE DEC DE LMA9: JRNC LMA8-# INC HL LMA8: EXAF LD A,B OR C JRZ LRET-# DEC BC EXAF JR PLAK-# STOP: POP HL LRET: LD HL,(LXE) LD (AKPX),HL LD HL,(LYE) LD (AKPY),HL CALL 0F54AH IN PFL BIT 1,A RET DRAW: PUSH HL PUSH DE PUSH BC XOR A LD BC,(AKX2) LD (AKX2),HL SBC HL,BC EX DE,HL XOR A LD BC,(AKY2) LD (AKY2),HL SBC HL,BC EX DE,HL LD A,E AND 1 LD E,A LD A,L AND 1 RLCA RLCA LD L,A LD A,(MRT) OR E OR L LD C,A AND 5 JRZ NDR-# CALL STEP NDR: POP BC POP DE POP HL RET RECK: PUSH HL PUSH DE PUSH BC XOR A LD HL,(LYE) LD DE,(LYA) SBC HL,DE EX DE,HL XOR A LD HL,(LXE) LD BC,(LXA) SBC HL,BC LD B,H LD C,L LD HL,(LXA) LD (LXE),HL CALL LINE JRNZ REND-# CALL NPOS LD HL,(LXA) ADD HL,BC LD (LXE),HL CALL LIN2 JRNZ REND-# CALL NPOS XOR A LD HL,(LYA) SBC HL,DE LD (LYE),HL CALL LIN2 JRNZ REND-# CALL NPOS XOR A LD HL,(LXA) SBC HL,BC LD (LXE),HL CALL LIN2 REND: POP BC POP DE POP HL RET NPOS: LD HL,(LXE) LD (LXA),HL LD HL,(LYE) LD (LYA),HL RET ELLY: PUSH HL PUSH DE PUSH BC LD HL,(LYA) LD (YNRM),HL LD HL,(LXA) LD DE,(LXE) OR A SBC HL,DE LD (LXA),HL CALL PSET JPNZ EEND CALL SPEN LD HL,(LXE) LD B,1 ANOR: LD A,H OR A JRZ AEQ-# INC B SRL H RR L JR ANOR-# AEQ: LD DE,(LYE) LD C,1 BNOR: LD A,D OR A JRZ BEQ-# INC C SRL D RR E JR BNOR-# BEQ: LD A,L EXX LD B,1 LD C,A DEC C ZUG: LD A,C CALL QUAD EX DE,HL EXX LD A,L EXX CALL QUAD OR A SBC HL,DE CALL SQR LD H,0 LD L,A EXX LD A,E EXX LD D,H LD E,A CALL MULT EXX LD A,L EXX LD D,0 LD E,A CALL DIV LD E,L PUSH BC LD A,B LD HL,(LXA) EXX PUSH BC EXX POP BC CMP 3 JRNC VGXS-# VGXA: INC HL DJNZ VGXA-# JR XSET-# VGXS: DEC HL DJNZ VGXS-# XSET: LD (LXE),HL LD HL,(YNRM) LD B,C CMP 3 JRC VGYA-# VGYS: OR A SBC HL,DE DJNZ VGYS-# JR YPK-# VGYA: ADD HL,DE DJNZ VGYA-# YPK: POP BC LD (LYE),HL CALL LIN2 JRNZ EEND-# CALL NPOS LD A,B AND 1 JRZ ST24-# ST13: DEC C STZ: JRNZ GOZ-# NST: INC B LD A,B CMP 5 JRZ EEND-# GOZ: JMP ZUG ST24: LD A,C INC C EXX CMP L EXX JRNZ GOZ-# DEC C DEC C JR NST-# EEND: CALL RPEN POP BC POP DE POP HL RET MULT: PUSH DE PUSH BC PUSH AF LD B,H LD C,L LD HL,0 MADD: LD A,D OR E JRZ MEX-# ADD HL,BC DEC DE JR MADD-# MEX: POP AF POP BC POP DE RET DIV: PUSH BC LD BC,0 DSUB: OR A SBC HL,DE JRC DEX-# INC BC JR DSUB-# DEX: ADD HL,DE SLA L RL H SBC HL,DE JRC DEX2-# INC BC DEX2: LD H,B LD L,C POP BC RET QUAD: PUSH DE PUSH BC LD B,A LD DE,1 LD HL,0 QADD: ADD HL,DE INC DE INC DE DJNZ QADD-# POP BC POP DE RET SQR: PUSH HL PUSH DE PUSH BC LD DE,1 LD C,0FFH SQS: INC C XOR A SBC HL,DE INC DE INC DE JRNC SQS-# ADD HL,DE DEC HL SLA L RL H SBC HL,DE JRC SQ2-# INC C SQ2: LD A,C POP BC POP DE POP HL RET AKPX: DA 0 AKPY: DA 0 LXA: DA 0 LYA: DA 0 LXE: DA 0 LYE: DA 0 AKX2: DA 0 AKY2: DA 0 LXA2: DA 0 LYA2: DA 0 LXE2: DA 0 LYE2: DA 0 YNRM: DA 0 MRT: DB 0 END ; END