; GDC TESTPROGRAMM          GDC.ASM   COLOR FUER MIXED MODE
;=====================      LAST CHANGE    3.3.83
; 
;  GDC INIT. CONSTANTS 
; 
VC       EQU  0016H      ;GRAPHIC NON-INTERLACED 
AW       EQU  0028H      ;ACT. DISPLAY WORD/LINE
HS       EQU  000BH      ;HORZ. SYNC WIDTH 
VSL      EQU  0040H      ;VERT. SYNC WIDTH LOW 
VSH      EQU  0001H      ;VERT. SYNC WIDTH HIGH 
HFP      EQU  0004H      ;HOR. FRONT PORCH WIDTH 
HBP      EQU  0001H      ;HOR. BACK PORCH WIDTH 
VFP      EQU  000EH      ;VER. FRONT PORCH WIDTH 
ALL      EQU  0090H      ;ACTIV DISPLAY LINES LOW 
ALH      EQU  0001H      ;ACTIV DISPLAY LINES HIGH 
VBP      EQU  0034H      ;VER. BACK PORCH WIDTH 
; 
; GRAPHIC ADAPTER ADDRESSES 
; 
BSA      EQU  0FD00H     ;BOARD SELECT ADDRESS 
WPA      EQU  00A0H      ;WRITE PARAMETER 
RSTA     EQU  00A0H      ;READ STATUS 
WCO      EQU  00A1H      ;WRITE COMMANDS 
RFIF     EQU  00A1H      ;READ FIFO 
; 
;  GDC COMMAND TABLE 
; 
LPRD     EQU  00C0H      ;LIGHT PEN 
GDRE     EQU  0000H 
VSYNC    EQU  006FH 
CCHR     EQU  004BH 
STAG     EQU  006BH 
ZOOM     EQU  0046H 
CURS     EQU  0049H 
PRAM     EQU  0070H 
PITCH    EQU  0047H 
WDAT     EQU  0020H 
MASK     EQU  004AH 
FIGS     EQU  004CH 
FIGD     EQU  006CH 
GCHD     EQU  0068H 
RDAT     EQU  00A0H 
CURD     EQU  00E0H 
WSET     EQU  0003H 
WCLR     EQU  0002H 
WCOM     EQU  0001H 
WREP     EQU  0000H 
PADA     EQU  0008H 
; 
; BEGIN OF PROGRAM 
; 
START:   ORG  0B000H
         JMP  STOD1
         JMP  KURS
         JMP Z00M
         JMP  KREIS
         JMP  LIN
         JMP  BOX
         JMP  REC
         JMP  CH
         JMP  RMW
         JMP  GRCD
         JMP  EOD
         JMP  COSEL
         RET
GDCCOLOR: DB '81.01.00'
STOD1:   NOP
         MVI A,0CH
         CALL COOP
         LXI H,PART1
         MVI A,ZOOM
         CALL COOP
         MVI C,01H
         CALL PAOP
         MVI A,CCHR
         CALL COOP
         MVI C,01H
         CALL PAOP
         MVI A,PRAM
         CALL COOP
         MVI C,10H
         CALL PAOP
         XRA A
         STA PART3+1
         MVI B,03H
STOD2:   MVI A,CURS
         CALL COOP
         MVI C,03H
         CALL PAOP
         MVI A,MASK
         CALL COOP
         MVI C,02H
         CALL PAOP
         MVI A,FIGS
         CALL COOP
         MVI C,0BH
         CALL PAOP
         MVI A,WDAT+WSET
         CALL COOP
         MVI C,02H
         CALL PAOP
         LXI H,PART3+1
         MOV A,M
         ADI 40H
         MOV M,A
         DCX H
         DCR B
         JNZ STOD2
         MVI A,WDAT+WCOM
         CALL COOP
         LXI H,COLDA
         MVI M,02H
         INX H
         MVI M,0FFH
         INX H
         MVI M,08H
         MVI A,0DH
         CALL COOP
         RET
 PART1:  DW 0
         DW 0
         DB 0
         DW 0059H
         DW 0000H
         DB 59H
         DW 0FFFFH,0FFFFH,0FFFFH,0FFFFH
 PART3:  DB 0
         DW 0 ;CURS
         DW 0FFFFH ;MASK
         DB 02H    ;FIGS
         DW 7FFFH,0008H,0008H,3FFFH,3FFFH,0FFFFH
 EOD:    NOP
         LXI  H,PART2
         MVI  A,CCHR
         CALL COOP
         MVI  C,01H
         CALL PAOP
         MVI  A,ZOOM
         CALL COOP
         MVI  C,01
         CALL PAOP
         MVI  A,PRAM
         CALL COOP
         MVI  C,10H
         CALL PAOP
         MVI  E,1AH
         MVI  C,02H
         CALL 0005H
         RET
PART2:   DB 8FH
         DB 0
         DW 0
         DB 0
         DW 0019H
         DW 0000H
         DB 19H
         DW 0FFFFH,0FFFFH,0FFFFH,0FFFFH
ADSP:    SHLD XADR
         XCHG
         SHLD YADR
         RET
PATR:    MOV  E,M
         INX  H
         MOV D,M
         XCHG
         RET
XADR:    DW 0
YADR:    DW 0
ZADR:    DW 0
; MAIN ROUTINES 
; 
COSEL:   CALL ADSP
         LHLD XADR
         CALL PATR
         SHLD COLDA 
         LXI  H,COLDB 
         MVI  M,0FFH 
         INX  H 
         MVI  M,08H 
         RET
KURS:    CALL ADSP
         LHLD XADR
         CALL PATR
         SHLD XCUB
         LHLD YADR
         CALL PATR
         SHLD YCUB
         CALL CUR0 
         LXI  H,MCUR 
         CALL COCU       ;OUT CURSOR TO GDC 
         RET
Z00M:    CALL ADSP
         LHLD XADR
         CALL PATR
         XCHG
         LXI H,ZFA
         MOV M,E
         MVI A,ZOOM
         CALL COOP
         MVI C,01H
         CALL PAOP
         RET
KREIS:   CALL ADSP
         LHLD XADR
         CALL PATR
         SHLD BIRA
         CALL RACU       ;CALCU.CIRC. CURS.POINTS 
         CALL DCRO 
KREI2:   MVI  B,08H 
         XRA  A
         STA  DMPAR
         LXI  H,NPO1 
KREI0:   CALL COCU       ;CUR FOR CIRCL 
         PUSH H 
         MVI  A,FIGS 
         CALL COOP 
         CALL MIX
         LXI  H,PAR1     ;CIRCLE PARAM 
         INR  M 
         MVI  A,0F7H 
         ANA  M 
         MOV  M,A        ;DIR LIMIT 
         MVI  C,0BH 
         CALL PAOP 
         MVI  A,FIGD 
         CALL COOP 
         MVI  A,05H 
         CMP  B 
         JNZ  KREI1 
         LXI  H,DMPAR 
         MVI  M,01H 
KREI1:   DCR  B 
         POP  H 
         JNZ  KREI0 
         CALL CORO       ;COLOR CONTROL 
         JMP  KREI2 
         RET
LIN:     CALL ADSP
         LHLD XADR
         CALL PATR
         SHLD EXCB
         LHLD YADR
         CALL PATR
         SHLD EYCB
         CALL LIPA 
LIN2:    MVI  A,FIGS 
         CALL COOP 
         LXI  H,PAR1 
         CALL MIX
         MVI  C,0BH      ;PARAM TO GDC 
         CALL PAOP 
         MVI  A,FIGD 
         CALL COOP 
         CALL CORO       ;COLOR CONTROL 
         JMP  LIN1 
         JMP  LIN3 
LIN1:    LXI  H,MCUR     ;SET CURS IN STARTPOS. 
         CALL COCU 
         JMP  LIN2 
LIN3:    CALL CUR5 
         RET
CUR5:    PUSH H 
         PUSH B 
         PUSH D 
         PUSH PSW 
         JMP  CUR3 
BOX:     MVI  A,01H
         STA  DIR+1
         JMP RANG
REC:     MVI  A,00H
         STA  DIR+1
RANG:    CALL ADSP
         MOV L,C
         MOV H,B
         SHLD ZADR
         MOV A,M
         STA DIR
         LHLD XADR
         CALL PATR
         SHLD XDB
         LHLD YADR
         CALL PATR
         SHLD YDB
         LHLD DIR        ;TEST IF BOX 
         MOV  A,H 
         ANI  01H       ;TEST RECT OR BOX 
         JNZ  RAN1       ;IF BOX 
         CALL RECT 
RAN3:    MVI  A,FIGS 
         CALL COOP 
         LXI  H,PAR1 
         CALL MIX
         MVI  C,0BH 
         CALL PAOP 
         MVI  A,FIGD     ;START REC. DRAWING 
         CALL COOP 
         CALL CORO 
         JMP  RAN4 
         RET 
RAN4:    LXI  H,MCUR     ;SET CURS IN START 
         CALL COCU 
         JMP  RAN3 
RAN1:    CALL RARF       ;CALCULAT BOX PARAM. 
RAN2:    MVI  A,FIGS 
         CALL COOP 
         LXI  H,PAR1 
         CALL MIX
         MVI  C,0BH 
         CALL PAOP 
         MVI  A,GCHD     ;START AREA FILL 
         CALL COOP 
         CALL CORO 
         JMP  RAN5 
         RET 
RAN5:    LXI  H,MCUR 
         CALL COCU 
         JMP  RAN2 
TAB6:    DW   0FFFFH,0FFFFH,0FFFFH,0FFFFH 
         DW   055AAH,055AAH,055AAH,055AAH
         DW   4488H,1122H,4488H,1122H
         DW   2211H,8844H,2211H,8844H
         DW   0AA00H,0AA00H,0AA00H,0AA00H
         DW   0FF00H,0FF00H,0FF00H,0FF00H
         DW   0AAAAH,0AAAAH,0AAAAH,0AAAAH
         DW   4281H,1824H,2418H,8142H
         DW   0FF0H,0FF0H,0FF0H,0FF0H
         DW   5555H,5555H,0AAAAH,0AAAAH
         DW   0CC33H,0CC33H,0CC33H,0CC33H
         DW   5555H,0AAAAH,5555H,0AAAAH
         DW   0A552H,944AH,5229H,4AA5H
         DW   0A54AH,2952H,4A94H,52A5H
         DW   0E773H,9CCEH,7339H,0CEE7H
         DW   0F0FH,0F0FH,0F0F0H,0F0F0H
XCUB:    DW   0 
YCUB:    DW   0 
CH:      CALL ADSP
         LHLD XADR
         CALL PATR
         MVI H,00H
         MOV A,L
         ANI 0FH
         MOV L,A
         DAD H
         DAD H
         DAD H
         LXI D,TAB6
         DAD D
         MVI A,PRAM+PADA
         CALL COOP
         MVI C,08H
         CALL PAOP
         RET
RMW:     CALL ADSP
         LHLD XADR
         CALL PATR
         MOV  A,L
         ANI 03H
         ORI 20H
         CALL COOP
         RET
COCU:    PUSH PSW 
         PUSH D 
         PUSH B 
         CALL CORE
         MVI  A,CURS 
         CALL COOP 
COCV:    MVI  C,01H 
         CALL PAOP       ;OUT FIRST 2-BYTES 
         MOV  B,M 
         LDA  COLDB      ;COLDA + 1 
         ANI  03H 
         RRC
         RRC
         ORA  B          ; ADD. COLOR BITES 
         OUT  WPA    ;OUT COLOR ADDR. 
         INX  H 
         MVI C,01H
         CALL PAOP
         POP  B 
         POP  D 
         POP  PSW 
         RET 
COOP:    PUSH H 
         PUSH PSW 
COST:    IN  RSTA   ;LOAD GDC STATUS 
         ANI  0AH        ;TEST STATUS 
         JNZ  COST 
         POP  PSW 
         OUT  WCO    ;COMMAND TO GDC 
         POP  H 
         RET 
PAOP:    IN  RSTA   ;LOAD GDC STATUS 
         ANI  0AH 
         JNZ  PAOP 
PACO:    MOV  A,M        ;PARAMETER TO ACCU 
         OUT  WPA 
         INX  H 
         DCR  C 
         JNZ  PAOP 
         RET 
; 
;  COLOR CONTROL 
; 
CORO:    POP  D 
         PUSH D 
         PUSH PSW 
         PUSH H 
         PUSH B 
         LXI  H,COLDA 
         MOV  B,M        ;GET COLOR CODE 
         INX  H 
         MOV  C,M        ;GET COLOR ADDR. 
         INR  C 
         INX  H 
COLRP:   MOV  A,M 
         RAR 
         MOV  M,A 
         JC   COLEN 
         ANA  B 
         JNZ  COLRR 
         INR  C 
         JMP  COLRP 
COLRR:   DCX  H 
         MOV  M,C        ;COLOR ADDR. IN COLDA+1 
COLRS:   POP  B 
         POP  H 
         POP  PSW 
         XCHG 
         XTHL 
         XCHG 
         RET 
COLEN:   MVI  M,08H 
         DCX  H 
         MVI  M,0FFH 
         INX  D 
         INX  D 
         INX  D 
         JMP  COLRS 
COLDA:   DB   0 
COLDB:   DB   0 
         DB   0 
CORE:    MVI  B,03H
         LDA  COLDB
         ANI  03H
         CMP  B
         CZ   CORO
         RET
MIX:     LDA DCPAR+1
         ORI 40H
         STA DCPAR+1
         RET
; 
; X - Y CURSOR IN MEM ADDRESS 
CUR0:    PUSH H 
         PUSH B 
         PUSH D 
         PUSH PSW 
         LHLD YCUB
         CALL YSPI
         SHLD YCUB
CUR3:    LXI  B,0000H    ;CLEAR B+C 
         LHLD XCUB       ;BIN CURS IN H+L 
         DCX  H 
         MOV  A,L 
         ANI  0FH        ;CUT LOWER BITS 
         STA  ZCUR 
         RLC 
         RLC 
         RLC 
         RLC 
         STA  DCUR       ;STORE DOT CURSOR 
         MOV  A,L 
         ANI  0F0H       ;CUT DOT BITS 
         MOV  L,A 
         LXI  D,0FFF0H   ;-16 IN D+E 
CURS2:   CALL RWOR 
         MOV  A,C        ;X ADDRESS IN ACCU 
         STA  WCUR 
         LHLD YCUB       ;Y BIN CURS IN H+L 
         DCX  H 
         XCHG 
         LXI  H,0000H 
         LXI  B,AW
         CALL ADRE 
         XCHG           ;LINE START ADDR. IN D+E 
         LDA  WCUR 
         MOV  L,A 
         DAD  D 
         SHLD MCUR       ;STORE MEM ADDRESS 
         POP  PSW 
         POP  D 
         POP  B 
         POP  H 
         RET 
YSPI:    CALL COMH       ;Y-POINT EXCHANGE 
         XCHG 
         MVI  H,ALH 
         MVI  L,ALL 
         INX  H 
         DAD  D 
         RET 
ADRE:    MVI  A,00H 
         CMP  E 
         JZ   ADR1 
         DAD  B          ;ADD. AW 
         DCR  E 
         JMP  ADRE 
ADR1:    CMP  D 
         RZ 
         DAD  B 
         DCR  E 
         DCR  D 
         JMP  ADRE 
MCUR:    DW   0 
DCUR:    DB   0 
WCUR:    DW   0 
ZCUR:    DW   0 
; 
; CALCUL RADIUS FOR CIRCL DRAWING 
RACU:    PUSH H 
         PUSH B 
         PUSH D 
         PUSH PSW 
         MVI  A,20H 
         STA  PAR1 
         LHLD BIRA       ;STORE BIN RADIUS 
         XCHG 
RAC1:    LHLD MCUR       ;CIRC. CENTER 
         LXI  B,AW 
         CALL COMP       ;GEN 2-COMP FROM AW 
         CALL ADRE 
         SHLD NPO1 
         SHLD NPO2 
         LHLD BIRA       ;BIN RAD IN H+L 
         XCHG 
         LHLD MCUR       ;CIRC. CENT IN H+L 
         LXI  B,AW    ;PITCH FOR CURS. CALC. 
         CALL ADRE 
         SHLD SPO1       ;CIRC. SOUTH POINT 
         SHLD SPO2 
         LDA  DCUR       ;GET DOT CURSOR 
         STA  NPU1       ;NORTH DOT CURSOR 
         STA  NPU2 
         STA  SPU1 
         STA  SPU2 
         LHLD BIRA 
         MOV  A,L 
         STA  ZWDO 
         ANI  0F0H       ;CUT UPPER BITS 
         MOV  L,A 
         LXI  D,0FFF0H   ;-16 IN D+E 
         LXI  B,0000H 
         CALL RWOR       ;RAD IN MEM-WORD 
         PUSH B          ;SAVE RAD.WORD ADDR. 
         LDA  ZWDO       ;ZWI.BUFFER 
         ANI  0FH        ;CUT UPPER BITS 
         CALL RADO 
         STA  WPU1 
         STA  WPU2 
         LHLD MCUR       ;MEM ADDRESS 
         DAD  B 
         SHLD WPO1 
         SHLD WPO2 
         POP  B 
         LDA  ZWDO 
         ANI  0FH 
         CMA 
         INR  A 
         CALL RADO       ;CALCU. DOT FOR EASTPOINT 
RAC3:    STA  OPU1 
         STA  OPU2 
         CALL COMP       ;SUBT. RADIUS 
         LHLD MCUR       ;MEM ADDRESS 
         DAD  B 
RAC5:    SHLD OPO1 
         SHLD OPO2 
         POP  PSW 
         POP  D 
         POP  B 
         POP  H 
         RET 
RADO:    MOV  E,A 
         LDA  ZCUR 
         ADD  E 
         MOV  E,A 
         ANI  0F0H 
         JZ   RAC2 
         INX  B 
RAC2:    MOV  A,E 
         RLC 
         RLC 
         RLC 
         RLC 
         ANI  0F0H 
         RET 
COMP:    MOV  A,C 
         CMA 
         MOV  C,A 
         MOV  A,B 
         CMA 
         MOV  B,A 
         INX  B 
         RET 
RWOR:    DAD  D 
         INR  C 
         JC   RWOR 
         DCR  C 
         RET 
BIRA:    DW   0 
NPO1:    DW   0 
NPU1:    DB   0 
SPO1:    DW   0 
SPU1:    DB   0 
OPO1:    DW   0 
OPU1:    DB   0 
WPO1:    DW   0 
WPU1:    DB   0 
SPO2:    DW   0 
SPU2:    DB   0 
NPO2:    DW   0 
NPU2:    DB   0 
WPO2:    DW   0 
WPU2:    DB   0 
OPO2:    DW   0 
OPU2:    DB   0 
ZWDO:    DB   0 
; CALCUL. FIGS PARAM. 
DCRO:    PUSH H 
         PUSH D 
         PUSH B 
         PUSH PSW 
         LHLD BIRA 
         SHLD RAD2 
         MVI  A,00H 
         STA  RAD1 
         LXI  B,0000H 
DCR1:    LXI  H,SINKO 
         LXI  D,RAD1 
         LDAX D 
         ADD  M 
         STAX D 
         INX  H 
         INX  D 
         LDAX D 
         ADC  M 
         STAX D 
         INX  H 
         INX  D 
         LDAX D 
         ADC  M 
         STAX D 
         INX  B 
         JC   DCR1 
         LDA  RAD2 
         ANI  01H 
         JNZ   DCR2 
         LDA  RAD1 
         ADI  0B5H 
         JNC  DCR2 
         DCX  B 
DCR2:    LXI  H,DCPAR    ;START ADDR CIRC PARAM 
         MOV  M,C 
         INX  H 
         MOV  M,B        ;STORE DC PARAM 
         LHLD BIRA 
         DCX  H 
         SHLD DPAR 
         DAD  H          ;2TIMES RAD-1 
         SHLD D2PAR 
         LXI  H,3FFFH    ;D1 =-1 
         SHLD D1PAR      ;STORE D1 PARAM 
         LXI  H,0000H    ;DM PARAM 
         SHLD DMPAR 
         POP  PSW 
         POP  B 
         POP  D 
         POP  H 
         RET 
SINKO:   DW   0FE95H     ;2-COMP. SIN 45 
         DB   0FFH 
RAD1:    DB   0 
RAD2:    DB   0 
RAD3:    DB   0 
; CALCULATE LINE PARAMETER 
; 
;        LIST 
TAB2:    DB   0DH        ;DIR=5 QU=2 
         DB   0EH        ; 6 - 3 
         DB   0AH        ; 2 - 1 
         DB   09H        ; 1 - 4 
         DB   0CH        ; 4 - 2 
         DB   0FH        ; 7 - 3 
         DB   0BH        ; 3 - 1 
         DB   08H        ; 0 - 4 
         DB   0AH        ; 2 - 1 
         DB   0EH        ; 6 - 3 
         DB   0CH        ; 4 - 2 
         DB   08H        ; 0 - 4 
         DB   0DH        ; 5 - 2 
         DB   0FH        ; 7 - 3 
         DB   0BH        ; 3 - 1 
         DB   09H        ; 1 - 4 
LIPA:    PUSH H 
         PUSH D 
         PUSH B 
         PUSH PSW 
         XRA  A 
         STA  CBY 
         LHLD EXCB       ;X END POINT IN MEM. 
         XCHG 
         LHLD XCUB       ;X-START POINT 
         MOV  C,L        ;COMP START POINT 
         MOV  B,H 
         CALL COMP 
         XCHG           ;END POINT IN H+L 
         DAD  B 
         CNC  COMH 
         SHLD DEX        ;STORE DELTA X 
         MVI  A,02H      ;IF X-POS STORE 1 
         CC   LIPB       ;IF POSITIV 
         LHLD EYCB       ;STORE END POINT Y 
         CALL YSPI
         SHLD EYCB
         XCHG           ;Y-END IN D+E 
         LHLD YCUB       ;Y-START POINT 
         MOV  C,L 
         MOV  B,H 
         CALL COMP       ;CALCU. DELTA Y 
         XCHG           ;END POINT IN H+L 
         DAD  B 
         CNC  COMH 
         SHLD DEY        ;STORE DELTA Y 
         MVI  A,01H      ;IF Y-POS STORE 1 
         CC   LIPB 
         XCHG           ;DELTA Y IN D+E 
         LHLD DEX        ;GET DELTA X 
         MOV  C,L 
         MOV  B,H 
         CALL COMP 
         XCHG           ;DEY IN H+L - DEX IN D+E 
         DAD  B          ;SUB X FROM Y 
         MVI  A,04H      ;IF Y > X STORE 1 
         CC   LIPB 
         MOV  A,L        ;TEST Y = X 
         ORA  H 
         MVI  A,08H      ;SET 1 IF X=Y 
         CZ   LIPB 
         LHLD DEY        ;DEY IN H+L - DEX IN D+E 
         MOV  A,L 
         ORA  H 
         CZ   LIPC 
         MOV  A,E 
         ORA  D 
         CZ   LIPF       ;TEST DEX=0 
         LDA  CBY 
         ANI  04H        ;IF 1 INDEPEN.=DEY 
         CZ   LIPD 
         SHLD DCPAR 
         MOV  C,L        ;INDEP IN B+C 
         MOV  B,H 
         CALL COMP 
         MOV  L,E        ;DEPENT. IN H+L 
         MOV  H,D 
         DAD  H 
         SHLD D1PAR      ;2X DEPENT 
         DAD  B 
         SHLD DPAR       ;2X DEP -INDEP 
         XCHG           ;DEPEN IN H+L 
         DAD  B 
         DAD  H 
         SHLD D2PAR 
         LXI  H,3FFFH 
         SHLD DMPAR 
CALE:    LXI  H,TAB2 
         LXI  D,0000H 
         LDA  CBY 
         MOV  C,A 
         ANI  10H        ;TEST X OR Y =0 
         CNZ  LIPE 
         MOV  E,C 
         DAD  D 
         MOV  A,M        ;GET DIR PARAMETER 
         STA  PAR1 
         LHLD EXCB       ;STORE NEW START POINT 
         SHLD XCUB 
         LHLD EYCB 
         SHLD YCUB 
         POP  PSW 
         POP  B 
         POP  D 
         POP  H 
         RET 
LIPC:    MVI  A,10H      ;X OR Y = 0 
         CALL LIPB 
         LDA  CBY 
         ANI  02H 
         RZ 
         LDA  CBY 
         ANI  0FCH       ;SET DIR 
         STA  CBY 
         RET 
LIPF:    MVI  A,14H      ;IF DEX = 0 
         CALL LIPB 
         RET 
LIPD:    XCHG 
         RET 
LIPE:    LDA  CBY        ;IF X OR Y = 0 
         ANI  03H 
         ORI  08H 
         MOV  C,A 
         RET 
COMH:    PUSH PSW        ;SAVE CARRY 
         MOV  A,L 
         CMA 
         MOV  L,A 
         MOV  A,H 
         CMA 
         MOV  H,A 
         INX  H 
         POP  PSW 
         RET 
LIPB:    PUSH H 
         LXI  H,CBY 
         ORA  M 
         MOV  M,A 
         POP  H 
         RET 
EXCB:    DW   0 
EYCB:    DW   0 
DEX:     DW   0 
DEY:     DW   0 
CBY:     DB   0 
PAR1:    DB   0          ;P1 PARAM 
DCPAR:   DW   0 
DPAR:    DW   0 
D2PAR:   DW   0 
D1PAR:   DW   0 
DMPAR:   DW   0 
; GRAPHIC CHARACTER IN/OUT 
; 
CGEST    EQU  0B700H     ;CHARCTER GEN STARTADDR.=4000H 
; 
GRCD:    CALL ADSP
         LHLD YADR
         CALL PATR
         MOV  A,L
         ANI  07H
         ORI  10H
         STA  FIPAR
GRC2:    LHLD XADR
         MOV  C,M
         INX  H
         CALL PATR
GRC1:    MOV  B,M
         INX  H
         PUSH H
         PUSH B
         MVI  H,00H
         MOV  L,B
         LXI  D,CGEST 
         DAD  H 
         DAD  H 
         DAD  H 
         DAD  D 
         MVI  A,PRAM+PADA          ;LOAD GR.CHRA. IN GDC 
         CALL COOP 
         MVI  C,08H 
         CALL PAOP 
         LXI  H,FIPAR    ;FIGS PARAM 
         MVI  A,FIGS 
         CALL COOP 
         MVI  C,0BH 
         CALL PAOP 
         MVI  A,GCHD 
         CALL COOP 
         POP  B
         POP  H
         DCR  C
         JNZ  GRC1 
         CALL CORO
         JMP GRC3
         RET
GRC3:    LXI H,MCUR
         CALL COCU
         JMP GRC2
         CALL CORO
         JMP GRC2
         RET
FIPAR:   DB   10H 
         DW   4007H,0008H,0008H,3FFFH,3FFFH
ZFA:     DW   0H 
; RECTANGLE ROUTINES 
; 
RECT:    PUSH H 
         PUSH D 
         PUSH B 
         PUSH PSW 
         CALL XYDB       ;XY IN BINARY 
         DCX  H
         DCX  D
         ANI  02H
         JNZ   REC1 
         SHLD DPAR       ;A=X 
         SHLD DMPAR 
         XCHG 
         SHLD D2PAR      ;B=Y 
         JMP  REC2 
REC1:    SHLD D2PAR 
         XCHG 
         SHLD DPAR 
         SHLD DMPAR 
REC2:    LXI  H,0003H    ;SET RECTAN PARAM 
         SHLD DCPAR 
         LXI  H,3FFFH 
         SHLD D1PAR 
         LDA  DIR 
         ADI  02H
         ANI  07H 
         ORI  40H 
         STA  PAR1 
         POP  PSW 
         POP  B 
         POP  D 
         POP  H 
         RET 
XYDB:    LHLD YDB 
         XCHG 
         LHLD XDB        ;X IN H+L   Y IN D+E 
         LDA  DIR 
         ANI  07H 
         ADI  04H 
         RET 
RARF:    PUSH H 
         PUSH D 
         PUSH B 
         PUSH PSW 
         CALL XYDB 
         ANI  02H 
         JNZ   RAF1 
         XCHG 
         MOV  A,H 
         ANI  3FH        ;CUT UPPER 2BITS 
         MOV  H,A 
         DCX  H
         SHLD DCPAR      ;Y=B 
         XCHG           ;X=A 
         JMP  RAF2 
RAF1:    MOV  A,H 
         ANI  3FH 
         MOV  H,A 
         SHLD DCPAR      ;X=B 
         XCHG 
RAF2:    SHLD DPAR       ;Y=A 
         SHLD D2PAR 
         LXI  H,3FFFH 
         SHLD D1PAR 
         SHLD DMPAR 
         LDA  DIR        ;DIRECTION 
         ADI  02H
         ANI  07H 
         ORI  10H 
         STA  PAR1 
         POP  PSW 
         POP  B 
         POP  D 
         POP  H 
         RET 
DIR:     DW   0 
XDB:     DW   0 
YDB:     DW   0 
;
; GRAPHIC CHARACTER GENERATOR
;
         ORG 0B800H
; 20H SPACE
         DW   0000H,0000H,0000H,0000H
; 21H !
         DW   0000H,0000H,005FH,0000H
; 22H "
         DW   0000H,0007H,0007H,0000H
; 23H #
         DW   0000H,1F0AH,1F0AH,000AH
; 24H $
         DW   1200H,7F2AH,242AH,0000H
; 25H %
         DW   6200H,0864H,2313H,0000H
; 26H &
         DW   5000H,5522H,3649H,0000H
; 27H '
         DW   0000H,0000H,070BH,0000H
; 28H (
         DW   0000H,2241H,001CH,0000H
; 29H
         DW   0000H,221CH,0041H,0000H
; 2AH *
         DW   0000H,1C2AH,2A1CH,002AH
; 2BH +
         DW   0000H,0808H,083EH,0008H
; 2CH ,
         DW   0000H,0B070H,0000H,0000H
; 2DH -
         DW   0000H,0404H,0404H,0004H
; 2EH .
         DW   0000H,6000H,0060H,0000H
; 2FH /
         DW   0000H,1020H,0408H,0002H
; 30H 0
         DW   0000H,413EH,3E41H,0000H
; 31H 1
         DW   0000H,7F00H,0002H,0000H
; 32H 2
         DW   4600H,4949H,6251H,0000H
; 33H 3
         DW   3300H,494DH,4141H,0000H
; 34H 4
         DW   0800H,087FH,0F08H,0000H
; 35H 5
         DW   3900H,4545H,4745H,0000H
; 36H 6
         DW   3000H,4949H,3C4AH,0000H
; 37H 7
         DW   0300H,0905H,6111H,0000H
; 38H 8
         DW   3600H,4949H,3649H,0000H
; 39H 9
         DW   1E00H,4929H,0649H,0000H
; 3AH :
         DW   0000H,3600H,0036H,0000H
; 3BH ;
         DW   0000H,7600H,00B6H,0000H
; 3CH <
         DW   0000H,1408H,4122H,0000H
; 3DH =
         DW   0000H,1414H,1414H,0014H
; 3EH >
         DW   0000H,4100H,1422H,0008H
; 3FH ?
         DW   0600H,5109H,0201H,0000H
; 40H 
         DW   5E00H,5D55H,3E41H,0000H
; 41H A
         DW   0000H,097EH,0909H,007EH
; 42H B
         DW   3600H,4949H,7F49H,0000H
; 43H C
         DW   2200H,4141H,3E41H,0000H
; 44H D
         DW   3E00H,4141H,7F41H,0000H
; 45H E
         DW   4100H,4949H,7F49H,0000H
; 46H F
         DW   0100H,0909H,7F09H,0000H
; 47H G
         DW   7200H,5151H,3E41H,0000H
; 48H H
         DW   7F00H,0808H,7F08H,0000H
; 49H I
         DW   0000H,4100H,417FH,0000H
; 4AH J
         DW   3F00H,4040H,2040H,0000H
; 4BH K
         DW   4100H,1422H,7F08H,0000H
; 4CH L
         DW   4000H,4040H,7F40H,0000H
; 4DH M
         DW   7F00H,0C02H,7F02H,0000H
; 4EH N
         DW   7F00H,0408H,7F02H,0000H
; 4FH O
         DW   0000H,413EH,4141H,003EH
; 50H P
         DW   0600H,0909H,7F09H,0000H
; 51H Q
         DW   5E00H,5141H,3E41H,0000H
; 52H R
         DW   4600H,1929H,7F09H,0000H
; 53H S
         DW   3200H,4949H,2649H,0000H
; 54H T
         DW   0000H,0101H,017FH,0001H
; 55H U
         DW   0000H,403FH,4040H,003FH
; 56H V
         DW   0000H,201FH,2040H,001FH
; 57H W
         DW   0000H,207FH,2018H,007FH
; 58H X
         DW   0000H,1463H,1408H,0063H
; 59H Y
         DW   0000H,0807H,0870H,0007H
; 5AH Z
         DW   4300H,4945H,6151H,0000H
; 5BH [
         DW   0000H,7F00H,4141H,0000H
; 5CH
         DW   0000H,0402H,1008H,0020H
; 5DH ]
         DW   0000H,4100H,7F41H,0000H
; 5EH 
         DW   0400H,7F02H,0402H,0000H
; 5FH -
         DW   0000H,1C08H,082AH,0008H
; 60H '
         DW   0000H,0700H,000BH,0000H
; 61H a
         DW   4000H,5478H,7054H,0000H
; 62H b
         DW   3C00H,4444H,407FH,0000H
;
; END
