  	TITLE 'GRAPHIC COLOR  DRIVER FOR GSS'	
;=========================================
;
;	     29.6.83 12:35   WF
;	28/Maerz/1984 08:00  wf soft character generator implemented 
;	11/Juli /1984 07.15  wf ladbarer character generator
;	3 /OKTOBER/1984 12:00 WF CHARACTER CORRECTION FAKTOR IMPEMENTED
;
;            COLOR VERSION
;

PUBLIC	KURS,ZOOMA,KREIS,LIN,BOX,REC,CH,RMW,GRCD,GCLSCR,RDCURS
PUBLIC	DRAWM,GRAPON,GRAPOF,BIOFUN,POSCUR,OUTCAT,REVID,ICCPO
PUBLIC  REMCOM,KEYIN,CHOICE,SCOLIN,GETCOL,INLOC,CURMRK,font,ZEILE
;
;	GDC INIT. CONSTANTS
;
;
AW	EQU	28H	;ACT. DISPLAY WORD/LINE
ALL	EQU	90H	;ACTIVE DISPLAY LINES LOW
ALH	EQU	1	;ACTIVE DISPLAY LINES HIGH
;
;
;	GRAPHIC ADAPTER ADDRESSES
;
WPA      EQU  00A0H      ;WRITE PARAMETER
RSTA     EQU  00A0H      ;READ STATUS
WCO      EQU  00A1H      ;WRITE COMMANDS
RFIF     EQU  00A1H      ;READ FIFO
; 
; 
PAGE
;  GDC COMMAND TABLE 
; 
LPRD     EQU  00C0H      ;LIGHT PEN 
GDRE     EQU  0000H 
VSYNC    EQU  006FH 
CCHR     EQU  004BH 
STAG     EQU  006BH 
Z00M     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 
PAGE
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*****
;
;
;              		*SET CURSOR AT POSITION*
;
;            ENTRY REGISTER: (H,L) = ADDRESS OF X-COORDINATE
;                            (D,E) = ADDRESS OF Y-COORDINATE
;
;
;
;
KURS:
  	CALL 	ADSP
KURSA:
        LHLD 	XADR
        CALL 	PATR
	INX	H
        SHLD 	XCUB
        LHLD 	YADR
        CALL 	PATR
	INX	H
        SHLD 	YCUB
SETCU:
        CALL 	CUR0 
        RET
;
;
PAGE
;
;	         	*SET ZOOM FACTOR*
;
;		ENTRY REGISTER: (H,L) = ADDRESS OF ZOOM FACTOR
;
;
ZOOMA:   
	MOV 	E,M
        LXI  	H,ZFA
        MOV  	M,E
        MVI  	A,Z00M
        CALL 	COOP
        MVI  	C,01H
        CALL 	PAOP
        RET
;
;
PAGE
;
;			*DRAW CIRCLE OF SPECIFIED RADIUS*
;
;		ENTRY REGISTER: (H,L) = ADDRESS OF RADIUS
;
;
KREIS:
        RET

DRAWPRF:
	PUSH	B
	MVI	A,FIGS
	CALL	COOP	;FIGS COMMAND
	LXI	H,PAR1	;FIGS PARAMETER
	MVI	C,11	;NUMBER OF PARAMETERS
	CALL	PAOP	;OUTPUT PARAMETER
	MVI	A,FIGD
	CALL	COOP	;START DRAWING
	POP	B
	RET

;
PAGE
;			*DRAW A LINE*
;
;		ENTRY REGISTER:(H,L) = ADDRESS OF X-COORDINATE
;			       (D,E) = ADDRESS OF Y-COORDINATE
;
;
LIN:	
	CALL 	ADSP       ;STORE BASIC DATA
        LHLD 	XADR
        CALL 	PATR
	INX	H
        SHLD 	EXCB
        LHLD 	YADR
        CALL 	PATR
	INX	H
        SHLD 	EYCB
        CALL 	LIPA 
	LDA	CLRL	;GET LINE COLOR INDEX
	MOV	C,A
	MVI	D,3	;NUMBER OF COLOR PAGES
LIN2:
	CALL	DRAWXXX ;WRITEMODE AND COLOR INDEX
	JNC	LIN1	;JUMP IF DRAWING NOT NECESSARY
	CALL	DRAWPRF	;DRAW LINE IN ONE COLOR
LIN1:
	DCR	D	;NEXT COLOR
	JNZ	LIN2
	RET
	 
;
PAGE
;
;			*DRAW A FILLED AREA*
;
;		
BOX: 
	MVI  	A,01H
        STA  	DIR+1
        JMP  	RANG
;
;
;			*DRAW A RECTANGLE*
;
;		ENTRY REGISTER:(H,L) = ADDRESS OF DELTA X
;			       (D,E) = ADDRESS OF DELTA Y
;			       (B,C) = ADDRESS OF DIRECTION
;
;
REC:	 	
	MVI  	A,00H
        STA  	DIR+1
RANG:
	CALL 	ADSP
        MOV  	L,C        ;store 3.param.
        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  	0FH        ;TEST RECT OR BOX
        JNZ  	RAN1       ;IF BOX 
REC3:
        CALL 	RECT 
	LDA	CLRF	;GET LINE COLOR INDEX
	MOV	C,A
	MVI	D,3	;NUMBER OF COLOR PAGES
REC2:
	CALL	DRAWXXX ;SET DRAWMODE AND COLOR INDEX
	JNC	REC1	;JUMP IF DRAWING NOT NECESSARY
	CALL	DRAWPRF	;DRAW RECTANGLE IN ONE COLOR PAGE
REC1:
	DCR	D
	JNZ	REC2	;NEXT COLOR
	RET
;
;
;
 RAN1:  CALL RARF       ;CALCULAT BOX PARAM. 
	LDA	CLRF	;GET FILL COLOR INDEX
	MOV	C,A
	MVI	D,3	;NUMBER OF COLOR PAGES
BOX2:
	CALL	DRAWXXX ;SET DRAWMODE AND COLOR INDEX
	JNC	BOX1	;JUMP IF DRAWING NOT NECESSARY
	CALL	DRAWPRG ;DRAW BOX IN ONE COLOR
BOX1:
	DCR	D
	JNZ	BOX2	;NEXT COLOR PAGE
	LDA	PATTREG
	ORA	A
	RZ		;RETURN IF FULL FILL 
	MVI	A,0
	STA	PATTREG	;SET PATTERN --> 0FFH
	JMP 	REC3	;DRAW RECTANGEL 
;
;
	
 DRAWPRG:
	PUSH	B
 	MVI  	A,FIGS 
        CALL 	COOP
 	LXI  	H,PAR1 
 	LDA	GCHRFLG
	ORA	A
	JZ	DRAWPR1	;JUMP IF NO GRAFIC CHARACTER
	LXI	H,FIPAR	;CHARACTER PARAMETER
DRAWPR1:
	MVI  	C,0BH 
        CALL 	PAOP
        MVI  	A,GCHD     ;START AREA FILL 
        CALL 	COOP 
	POP	B
        RET
;
PAGE
;
;			*SET LINE TYPE*
;
;		ENTRY REGISTER:(H,L) = ADDRESS OF LINE TYPE (0-15)
;
;
CH:
	MOV	A,M
	STA	PATTREG	;SAVE LINE TYPE IN PATTERN REGISTER
	RET
CH1:
	LDA	GCHRFLG	;GET CHARACTER OR LINR TYPE
	ORA	A
	JNZ	CH2	;JUMP IF GRAFIC CHARACTER
	LDA	PATTREG
CH4:
        MVI	H,00H
        ANI 	1FH
        MOV 	L,A
        DAD 	H
        DAD	H
        DAD  	H
        LXI  	D,TAB6
        DAD  	D
CH3:
        MVI  	A,PRAM+PADA
        CALL 	COOP
        MVI  	C,08H
        CALL 	PAOPS
        RET
CH2:
	LHLD	CHARACTER	;GET CHARACTER ADDRESS
	JMP	CH3

GCHRFLG:	DB	0	;1=GRAFIC CHARACTER
PATTREG:	DB	0	;HOLD LINESTYLE
CHARACTER:	DW	0	;START ADDRESS OF CHARACTER PATTERN
;
RMW:
	CALL 	ADSP
        LHLD 	XADR
	CALL 	PATR
	MOV  	A,L
	ANI  	03H          ;SET READ M WRITE
        ORI  	20H
	CALL 	COOP
	RET
 	PAGE
;
 ;
 TAB6:
	  DB   0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
  	  DB   0FFH,000H,0FFH,000H,0FFH,000H,0FFH,000H	;STYLE 2 DASHED
          DB   011H,011H,011H,011H,011H,011H,011H,011H	;STYLE 3 DOTTED
          DB   0FFH,018H,0FFH,018H,0FFH,018H,0FFH,018H	;STYLE 4 DASHDOT
	  DB   0FFH,024H,0FFH,024H,0FFH,024H,0FFH,024H
          DB   033H,033H,033H,033H,033H,033H,033H,033H
          DB   055H,055H,055H,055H,055H,055H,055H,055H
          DB   003H,003H,003H,003H,003H,003H,003H,003H

				;HATCH

	DB	049H,0A4H,052H,029H,094H,04AH,025H,092H	; NARROW 45' CROSSHATCH
	DB	088H,044H,022H,011H,088H,044H,022H,011H	; MEDIUM 45' CROSSHATCH
	DB	080H,040H,020H,010H,008H,004H,002H,001H	; WIDE   45' CROSSHATCH
	DB	0AAH,055H,0AAH,055H,0AAH,055H,0AAH,055H	; NARROW 45' DOUBLE
	DB	0AAH,044H,0AAH,011H,0AAH,044H,0AAH,011H	; MEDIUM 45'   CROSS-
	DB	081H,042H,024H,018H,018H,024H,042H,081H	; WIDE   45'   HATCH
	DB	011H,022H,044H,088H,011H,022H,044H,088H	; NARROW-45' CROSSHATCH
	DB	010H,020H,040H,080H,001H,002H,004H,008H	; MEDIUM-45' CROSSHATCH
							;
				;PATTERN
	 
	DB	010H,054H,038H,0FEH,038H,054H,010H,000H	; STAR
	DB	000H,066H,066H,000H,000H,066H,066H,000H	; DOTS
	DB	038H,07CH,0FEH,0FFH,0FEH,07CH,038H,010H	; ROUTE
	DB	0F0H,0F0H,0F0H,0F0H,00FH,00FH,00FH,00FH	; CHESS
	DB	000H,044H,0EEH,0FEH,07CH,038H,010H,000H	;
	DB	000H,000H,010H,038H,07CH,038H,010H,000H	;
	DB	000H,018H,018H,07EH,07EH,018H,018H,000H	;
	DB	000H,010H,038H,07CH,0FEH,0EEH,044H,000H	;

CHARGEN1:	DB      0		;FONT
CHARTYP:	DB      0		;CHARACTER TYPE = OFFSET TO NEXT CHARACTER
CHARCOUN:	DB 	0		;CHAR CORRECTIN counT
CHAROFFS:	DB 	0		;CHAR CORRECTION OFFSET	
CHARHT:		DB      0		;CHARACTER HOEHE
CHARWID:	DB      0		;CHARACTER BREITE
CHARGEN:	DS	32*65H		;CHARACTER BUFFER     
;CHARACTER BIT TABLE IN ASCII SEQUENCE STARTING AT SPACE 20H
;				       ENDING   AT DEL   7FH

RAFE:   DW   	0 
BIWE:   DW   	0 
XCUR:   DW   	0 
XCUB:   DW   	0 
YCUR:   DW   	0 
YCUB:   DW   	0 
YRAD:   DW   	0 
XRAD:	DW 	0
;
;
PAGE
;
;			*OUT COMMAND*
;
;		ENTRY REGISTER:(A) = COMMAND
;
;	 
COOP:  
	PUSH 	PSW 
COST:
	IN  	RSTA        ;LOAD GDC STATUS
        ANI  	0AH        ;TEST STATUS 
        JNZ  	COST 
        POP  	PSW 
        OUT  	WCO        ;COMMAND TO GDC
        RET
;
;
;				*OUT PARAMETER*
;			
;			ENTRY REGISTER:(H,L) = ADDRESS OF PARAMETERS
;				       (C)   = NUMBER OF PARAMETERS
;
;
;
PAOPS:
	IN  	RSTA        ;LOAD GDC STATUS
        ANI  	0AH 
        JNZ  	PAOPS 
	MOV	A,M
PAOPS1:
        OUT  	WPA
        INX  	H 
        DCR  	C 
        JNZ  	PAOPS 
	RET
;
PAGE
PAOP:
	IN  	RSTA        ;LOAD GDC STATUS
        ANI  	0AH 
        JNZ  	PAOP 
	MOV	A,M
        OUT  	WPA
        INX  	H 
        DCR  	C 
        JNZ  	PAOP 
	RET

;				*OUT PARAMETER*
;
;			ENTRY REGISTER:(A) = PARAMETER
;				       (C) = NUMBER OF OUTS
;		
;
PSAO:
	MVI	C,1
PFAO:
 	PUSH	PSW
	IN	RSTA
	ANI	0AH
	JNZ	PFAO
	POP	PSW
	OUT	WPA
	DCR	C
	JNZ	PFAO
	RET
;
PAGE
;
;	 
 ; 
 ; 			*COMPUTE CURSOR POSITION*
;
;		ENTRY CONDITIONS: (XCUB) = X COORDINATE
;				  (YCUB) = Y COORDINATE
;
;
CUR0: 
	PUSH 	H 
        PUSH 	B 
        PUSH 	D 
        PUSH 	PSW 
        LHLD 	YCUB
	SHLD	YCUB1
        CALL 	YSPI 
        SHLD 	YCUB       ;STORE BIN YCUR 
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       ;PITCH
        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 
	INX	H
        XCHG 
        MVI  	H,ALH 
        MVI  	L,ALL 
        DAD  	D 
        RET
;
;
PAGE
;
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 
	PAGE
; 
;
;			*CALCULATE RADIUS FOR CIRCL DRAWING*
;
;		ENTRY CONDITION: (BIRA) = RADIUS
;
;
;
RACU: 
	PUSH 	H 
	PUSH 	B 
	PUSH 	D 
	PUSH 	PSW 
	MVI  	A,20H 
	STA  	PAR1 
	LHLD 	BIRA       ;RADUIS IN H+L
	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
;
PAGE
; 
;			*CALCULATE FIGS PARAMETER*
;
;		ENTRY CONDITION: (BIRA) = RADIUS
;
;
;
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 
        MVI	A,40H
	ORA	B	;SET GRAFIC DRAW FLAG
	MOV  	M,A        ;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
;
PAGE
; 
;			*CALCULATE LINE PARAMETER*
; 
 ; 		ENTRY CONDITIONS:(EXCB) = X COORDINATE
;				 (EYCB) = Y COORDINATE
;
;
			
TAB2:	DB	0DH
          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 
          DB   0EH 
          DB   0CH
          DB   08H
          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        ;Y END POINT IN H+L
	CALL	YSPI 
	SHLD	EYCB       ;STORE END POINT Y 
	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 X-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 
	MVI	A,40H
	ORA	H	;SET GRAFIC DRAW FLAG
	MOV	H,A
	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
;
; 
EXCR:	DW   0 
EYCR:	DW   0 
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
;
PAGE
; 
;			*DRAW GRAPHIC CHARACTER*
; 
; 		ENTRY REGISTERS:(H,L) = ADDRESS OF NUMBER OF CHARACTERS
;				(D,E) = ADDRESS OF CHARACTER STRING
;				(B,C) = ADDRESS OF DIRECTION
BSFLAG	DB	0
LINEST	DB	0
FIRSTS	DB	0
;	
ZEILE:
	CALL	ADSP
	LHLD	XADR
	MOV	A,M		;GET PARAMETER
	STA	LINEST		;SET LINE STATUS
	ORA	A
	RNZ
	STA	FIRSTS		;CLEAR FIRST CHARACTER FLAG
	RET

; 
GRCD:
	LDA	LINEST		;GET STATUS
	ORA	A
	JZ	GRCD00		;JUMP IF NO SPEZIAL CHARACTER SEQUENCE
	LDA	FIRSTS
	ORA	A
	JNZ	GRCD1		;JUMP IF NOR FIRST CHARACTER IN SPEZIAL SEQUENZE
	MVI	A,1
	STA	FIRSTS		;SET FLAG TO INDICATE NO FIRST RUN
GRCD00:
	LDA	CHARCOUN	;GET CHAR CORRECTION COUNT
	ORA	A
	JZ	GRCD0		;NO CORRECTION NECESSARY
	MVI	A,1
GRCD0:
	STA	CHRCNT1		;SET CORRECTION COUNT
GRCD1:
	CALL 	ADSP
	MOV	H,B
	MOV	L,C
	SHLD	ZADR		;SAVE ADDRESS OF DIRECTION
	MOV	A,M		;GET DIRECTION
	ANI	07H
	STA	DIR1
	ADI	2
	ANI  	07H
	ORI  	10H
	STA  	FIPAR
	LHLD 	XADR
	MOV  	C,M		;GET NUMBER OF CHARACTERS
	LHLD	YADR		;HL = ADDRESS OF CHARACTER
GRC1:
	MOV  	B,M          ;CHARECTER IN REG B
        INX  	H
	INX	H		;POINTER TO NEXT CHARACTER
	PUSH 	H
	PUSH 	B
	MOV  	A,B
	CPI	8
	JNZ	GRC11		;JUMP IF NO BS
	STA	BSFLAG
	MVI	A,20H
GRC11:
	CALL	GETCHR
	MVI	A,1
	STA	GCHRFLG	;SET GRAFIC CHARACTER FLAG
	LDA	BSFLAG
	ORA	A
	JZ	GRC20		;JUMP IF NO BS
	LDA	DIR1		;SAVE DIRECTION
	PUSH	PSW
	ADI	4		;NEGATE DIRECTION
	ANI	7
	STA	DIR1		;SAVE NEW DIRECTION
	CALL	CALPOS
	CALL	SETCU		;SET POSITION BACK
	POP	PSW
	STA	DIR1		;RESTORE DIRECTION
GRC20:
	LDA	CLRT	;GET TEXT COLOR INDEX
	MOV	C,A
	MVI	D,3	;NUMBER OF COLOR PAGES
GRC2:
	LDA	BSFLAG
	ORA	A
	JNZ	GRC201
	LDA	CHARHT		;TEST CHARACTER HIGHT
	CPI	9
	JNC	GRC21		;JUMP IF > 8
GRC201:
	LXI	H,CHRRAM
	SHLD	CHARACTER
	CALL	DRAWXXX
	JNC	GRC3
	CALL	DRAWPRG
GRC3:
	DCR	D
	JNZ	GRC2	;NEXT COLOR
	XRA	A
	STA	GCHRFLG	;CLEAR CHARACTER FLAG
	LDA	BSFLAG
	ORA	A
	JNZ	GRC31		;NO NEW POSITION IF BS
	CALL	CALPOS		;CALCULAT NEXT CHR POSITION
	CALL	SETCU		;SET CURSOR
GRC31:
	XRA	A
	STA	BSFLAG		;CLEAR BS FLAG
	POP  	B
	POP  	H
	DCR  	C
	JNZ  	GRC1
	RET
GRC21:
	LDA	CHARTYP
	CPI	9		;JUMP IF > 8
	JNC	GRC22		;JUMP IF WIDE CHARACTER
	LXI	H,CHRRAM+8
	SHLD	CHARACTER
	CALL	DRAWXXX
	JNC	GRC3
	CALL	DRAWPRG
	LXI	H,CHRRAM
	SHLD	CHARACTER
	PUSH	D
	PUSH	B
	CALL	CH1
	POP	B
	POP	D
	CALL	DRAWPRG		;DRAW UPPER HALF OF CHARACTER
	JMP	GRC3
GRC22:
	LXI	H,CHRRAM+8
	SHLD	CHARACTER
	CALL	DRAWXXX
	JNC	GRC3
	CALL	DRAWPRG
	LXI	H,CHRRAM
	SHLD	CHARACTER
	PUSH	D
	PUSH	B
	CALL	CH1
	CALL	DRAWPRG		;DRAW UPPER HALF OF CHARACTER
	LDA	CHARTYP
	PUSH	PSW
	MVI	A,8
	STA	CHARTYP		;SET FONT TO 0 FOR POSITION +8
	CALL	CALPOSS
	CALL	SETCU
	POP	PSW
	STA	CHARTYP		;RESTORE FONT
	LXI	H,CHRRAM+24
	SHLD	CHARACTER
	POP	B
	POP	D
	PUSH	D
	PUSH	B
	MOV	A,C
	RLC
	MOV	C,A
	CALL	DRAWXXX		;SET PHYSICAL CURSOR
	CALL	DRAWPRG		;DRAW UPPER HALF OF CHARACTER
	LXI	H,CHRRAM+16
	SHLD	CHARACTER
	CALL	CH1
	POP	B
	POP	D
	CALL	DRAWPRG		;DRAW UPPER HALF OF CHARACTER
	JMP	GRC3
;
;
FIPAR:	DB   	10H
	DW   	4007H,0008H,0008H,3FFFH,3FFFH 
ZFA:	DW   	0H
;
PAGE
;
;			*RECTANGLE ROUTINE*
;
;		ENTRY CONDITIONS: (XDB) = DELTA X
;				  (YDB) = DELTA Y
;
;
		
RECT: 
	PUSH	H 
        PUSH	D 
        PUSH	B 
        PUSH	PSW 
        CALL	XYDB       ;XY IN BINARY 
        DCX	H
        DCX	D
	MOV	A,H
	ORA	L
	JNZ	RECT3		;TEST FOR ZERO
	INX	H
RECT3:
	MOV	A,D
	ORA	E
	JNZ	RECT4		;TEST FOR ZERO
	INX	D
RECT4:
        SHLD	DPAR       ;A=X 
        SHLD	DMPAR 
        XCHG 
        SHLD	D2PAR      ;B=Y 
RECT2:
	LXI  	H,4003H    ;SET RECTAN PARAM 
	SHLD	DCPAR 	  ; AND GRAFIC DRAW FLAG
	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
;
PAGE
;
;			*AREA FILL ROUTINE*
;
;		ENTRY CONDITIONS:(XDB) = DELTA X
;				 (YDB) = DELTA Y
;
; 
RARF: 
	PUSH	H 
	PUSH	D 
	PUSH	B 
	PUSH	PSW 
	CALL	XYDB 
	XCHG 
	MOV	A,H 
	ANI	3FH        ;CUT UPPER 2BITS 
	MOV	H,A 
	DCX	H
	MOV	A,H
	ORA	L
	JNZ	RARF3
	INX	H
RARF3:
	MVI	A,40H	;SET GRAFIC DRAW FLAG
	ORA	H
	MOV	H,A
	SHLD 	DCPAR      ;Y=B 
	XCHG           ;X=A 
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 
XDI:	DW	0 
XDB:	DW	0 
YDI:	DW	0 
YDB:	DW	0 
; 
;
PAGE
;
;
;     			*CLEAR SCREEN*                		
;
GCLSCR:
	MVI 	A,CURS
	CALL	COOP
	XRA	A
	MVI	C,3	;CURSOR HOME
	CALL	PFAO
	MVI	A,MASK
	CALL	COOP
	MVI	A,-1
	MVI	C,2	;SET MASK
	CALL	PFAO
	MVI	B,3
GCLSC1:
	MVI	A,FIGS
	CALL	COOP	;SET DIR AND NUMBER OF WORDS
	MVI	A,2
	STA	PAR1	;DIR=2
	LXI	H,7FFFH
	SHLD	DCPAR	;LENGTH=16K WORDS
	MVI	C,3
	LXI	H,PAR1
	CALL 	PAOP
	MVI	A,WDAT+2
	CALL	COOP
	MVI	A,-1	;SET RESET MODE
	MVI	C,2
	CALL	PFAO
	DCR	B
	JNZ	GCLSC1
	RET
;
PAGE
;
;			*READ CURSOR POSITION*
;
; 
RDCURS:
	RET
;
;
;			*SET DRAWING MODE*
;
;
;
DRAWM:
	MOV	A,M
	STA	DRAWFLG
	RET
DRAWFLG	DB	0
DRAWFLG1 DB	0
;
PAGE
;			*SET DRAWMODE AND COLOR INDEX*
;
;
;				B= COLOR INDEX
;
WRITMOD:
	LDA	DRAWFLG	;GET DRAWMODE
	CPI	20H
	JNZ	WRITM10	;JUMP IF NOT REPLACE
	LDA	GCHRFLG	;IF GRAPHIC CHARACTER AND REPLACE MODE
	ORA	A	;                     AND COLOR INDEX = 1
	MVI	A,23H	;	THEN SET  "SET MODE"
	JNZ	WRITM02
	MVI	A,20H	;SET REPLACE MODE
WRITM02:
	CALL	COOP	;
	DCR	B
	JZ	WRITM01	;JUMP IF COLOR INDEX = 1
	MVI	A,22H	;SET RESET MODE
	CALL	COOP
WRITM01:
	STC		;SET DRAW FLAG
	RET
WRITM10:
	CPI	23H
	JNZ	WRITM20	;JUMP IF NOT SET MODE
	CALL	COOP	;SET "SET MODE"
	DCR	B	;
	JNZ	WRITM11	;JUMP IF COLOR INDEX = 0
	STC
	RET		;SET DRAW FLAG
WRITM11:
	STC
	CMC		;RESET DRAW FLAG
	RET
WRITM20:
	CPI	21H	;COMPLEMENT
	JNZ	WRITM30	;JUMP IF NOT COMPLEMENT
	CALL	COOP	;SET "COMPLEMENT MODE"
	DCR	B
	JNZ	WRITM11	;JUMP IF COLOR INDEX = 0
	STC		;SET DRAW FLAG
	RET
WRITM30:
	CALL	COOP	;SET "RESET MODE"
	DCR	B
	JZ	WRITM31	;JUMP IF COLOR INDEX = 1
	JMP	WRITM11
WRITM31:
	STC		;SET DRAW FLAG
	RET
PAGE
;			
;			*SET DRAWMODE AND COLOR INDEX*
;
;
;				C= COLOR INDEX
;				D= NUMBER OF COLOR PAGES
;
;
DRAWXXX:
	MOV	A,C
	RRC
	MOV	C,A
	MVI	B,0
	JNC	DRAWXX1	;JUMP IF COLOR INDEX OF ONE COLOR = 0
	MVI	B,1
DRAWXX1:
	CALL	WRITMOD	;SET WRITEMODE DEPENDING ON COLOR INDEX
	RNC		;RETURN IF NO DRAWING
	PUSH	B
	PUSH	D
	CALL	CH1	;SET PATTERN
	POP	D
	LHLD	MCUR	;CALCULATE OFFSET FOR 
	LXI	B,4000H
	MOV	A,D	;COLOR CURSOR
	CPI	1
	JZ	DRAWXX2	;JUMP IF COLOR = GREEN
	CPI	2
	JZ	DRAWXX3	;JUMP IF COLOR = RED
	DAD	B
DRAWXX3:
	DAD	B
	LDA	COLFLG
	ORA	A
	POP	B
	RZ		;RETURN IF MONOCHROME NO DRAWING NECCESSARY
	PUSH	B
DRAWXX2:
	SHLD	CMCUR	;SAVE IT IN COLOR CURSOR
	LDA	DCUR
	STA	CDCUR
	MVI	A,CURS
	CALL	COOP	;SET COLOR CURSOR
	MVI	C,3	;NUMBER OF PARAMETERS
	LXI	H,CMCUR
	CALL	PAOP	;SEND PARAMETER TO GDC
	POP	B
	STC		;INDICATE DRAWING
	RET
;
;
CMCUR	DW	0
CDCUR	DB	0
	PAGE
;
;
;
;			*SET COLOR INDEX*
;
;
;				HL= ADDRESS OF COLOR INDEX
;				DE= ADDRESS OF COLOR TYPE
;					0=LINE
;					1=POLYMAKER
;					2=TEXT
;					3=FILL
;
;
SCOLIN:
	MOV	C,M	;GET COLOR INDEX
	MVI	B,0
	LDA	COLFLG	;GET COLOR CAPABILITY FLAG
	ORA	A
	JZ	SCOLI2	;JUMP IF MONOCHROME
	LXI	H,COLTAB
SCOLI1:
	DAD	B	;OFFSET INTO COLOR CONVERSION TABLE
	MOV	A,M	;GET CONVERTED COLOR
	XCHG
	MOV	C,M	;GET COLOR TYPE
	LXI	H,CLRL
	DAD	B	;OFFSET TO COLOR TYPE FLAG
	MOV	M,A	;SAVE CONVERTED COLOR INDEX 
	RET		;INTO COLOR TYPE FLAG
;
SCOLI2:
	LXI	H,BLKWIT
	JMP	SCOLI1
;
;
CLRL	DB	4   	;DEFAULT FOR NON COLOR
CLRM	DB	4
CLRT	DB	4
CLRF	DB	4
;
;
;			COLOR INDEX CONVERSION TABLE
COLTAB	DB	0,2,4,1,5,6,3,7
;			MONOCHROME INDEX CONVERSION TABLE
BLKWIT	DB	0,4,4,4,4,4,4,4
COLFLG	DB	0	;0 = MONOCHROME, 1 = COLOR
	PAGE
;			*GET COLOR INDEX FROM THE HARDWARE*
;
;
;			HL = ADDRESS OF COLOR CAPABILITY FLAG
;			DE = ADDRESS OF NUMBER OF PRE DEFINED COLORS
;			BC = ADDRESS OF NUMBER OF AVAILABLE COLORS
;
;
GETCOL:
;	OUT	11H	;ROMSELECT
;	LDA	0FF9H	;GET COLOR INDICATOR FROM FIRMWARE
;	OUT	10H	;RAMSELECT
;	CPI	'C'
;	JNZ	GETCO1	;JUMP IF MONOCHROME
;	MVI	A,1
;	STA	COLFLG	;SET COLOR INDICATOR IN GRAFIC DRIVER
;	MVI	M,1	;SET COLOR CAPABILITY FLAG --> 1
;	XCHG
;	MVI	M,8	;SET NUMBER OF PRE DEFINED COLORS --> 8
;	MOV	H,B
;	MOV	L,C
;	MVI	M,8	;SET NUMBER OF AVAILABLE COLORS --> 8
;	RET
;
GETCO1:
	XRA	A
	STA	COLFLG	;RESET COLOR INDICATOR IN GRAFIC DRIVER
	MVI	M,0	;RESET COLOR CAPABILITY FLAG --> 0
	XCHG
	MVI	M,2	;SET NUMBER OF PRE DEFINED COLORS --> 2
	MOV	H,B
	MOV	L,C
	MVI	M,2	;SET NUMBER OF AVAILABLE COLORS --> 2
	RET
				
;			*GET CHARACTER FROM CHARACTER ROM*
;
;
GETCHR:
	PUSH	B
	PUSH	D
	PUSH	H		;SAVE REGISTERS
	CPI	20H
	JNC	GETCHRX
	MVI	A,20H
GETCHRX:
	ANI	07FH		;ONLY ASCII CHR ALOWED
	SUI	20H
	MOV	L,A
	MVI	H,0
	DAD	H
	DAD	H
	DAD	H		;*8
	LDA	CHARHT
	CPI	9
	JC	GETCHR2		;JUMP IF 8*8 CHARACTER
	DAD	H		;*16
	LDA	CHARWID
	CPI	9
	JC	GETCHR2
	DAD	H		;*32
GETCHR2:
	LXI	D,CHARGEN	;START OF CHARACTER ROM
	DAD	D
	LXI	D,CHRRAM	;MOVE CHR FROM SOFT-CHARACTER GENERATOR TO RAM
	LDA	CHARHT
	CPI	8
	MVI	b,8
	JZ	GETCHR1		;JUMP IF 8*8 CHARACTER
	MVI	B,16
	LDA	CHARTYP
	CPI	9
	JC	GETCHR1		;JUMP IF 8*16 CHARACTER
	PUSH	H
	INX	H
GETCHR4:
	MOV	A,M
	DB 	1FH
	DB 	0CBH,011H
	DB 	1FH
	DB 	0CBH,011H
	DB 	1FH
	DB 	0CBH,011H
	DB 	1FH
	DB 	0CBH,011H
	DB 	1FH
	DB 	0CBH,011H
	DB 	1FH
	DB 	0CBH,011H
	DB 	1FH
	DB 	0CBH,011H
	DB 	1FH
	DB 	0CBH,011H
	MOV	A,C
	STAX	D
	INX	H
	INX	H
	INX	D
	DCR	B
	JNZ	GETCHR4
	POP	H
	MVI	B,16
GETCHR5:
	MOV	A,M
	DB 	1FH
	DB 	0CBH,011H
	DB 	1FH
	DB 	0CBH,011H
	DB 	1FH
	DB 	0CBH,011H
	DB 	1FH
	DB 	0CBH,011H
	DB 	1FH
	DB 	0CBH,011H
	DB 	1FH
	DB 	0CBH,011H
	DB 	1FH
	DB 	0CBH,011H
	DB 	1FH
	DB 	0CBH,011H
	MOV	A,C
	STAX	D
	INX	H
	INX	H
	INX	D
	DCR	B
	JNZ	GETCHR5
	POP	H
	POP	D
	POP	B
	RET
		
GETCHR1:
	LDA	CHARGEN1
	CPI	5
	JZ	GETCHR11
	ORA	A
	JNZ	GETCHR3
GETCHR11:
	MOV	A,M
	STAX	D
	INX	H
	INX	D
	DCR	B
	JNZ	GETCHR11		;LOOP TIL DONE
	POP	H
	POP	D
	POP	B
	RET
GETCHR3:
	MOV	A,M
	DB 	1FH
	DB 	0CBH,011H
	DB 	1FH
	DB 	0CBH,011H
	DB 	1FH
	DB 	0CBH,011H
	DB 	1FH
	DB 	0CBH,011H
	DB 	1FH
	DB 	0CBH,011H
	DB 	1FH
	DB 	0CBH,011H
	DB 	1FH
	DB 	0CBH,011H
	DB 	1FH
	DB 	0CBH,011H
	MOV	A,C
	STAX	D
	INX	H
	INX	D
	DCR	B
	JNZ	GETCHR3
	POP	H
	POP	D
	POP	B
	RET
	;
PAGE
;
;			*CALCULATE NEXT CURSOR POSITION*
;
;		ENTRY CONDITIONS:(ZFA) = ZOOMFACTOR
;				 (XCUB)= X COORDINATE
;				 (YCUB1)= Y COORDINATE
;

CALPOSS:
	LDA 	CHARTYP
	STA	CHRBRT
	JMP	CALPOS4	
CALPOS:
	LDA	CHARTYP
	STA	CHRBRT		;SET ABSTAND ZUM NACHSTEN CHAR
	LDA	BSFLAG		;TEST IF BACK SPACE
	ORA	A
	JZ	CALPOS6		;JUMP IF NO BS
	LDA	CHRCNT1		;GET CORR COUNT
	CPI	0
	JZ	CALPOS4		;JUMP IF NO CORR NECESSARY
	CPI	1
	JNZ	CALPOS5		;JUMP IF NO CORR AT THIS POINT
	LDA	CHAROFFS	;GET CORR FAKTOR
	MOV	B,A		;SAVE IT
	LDA	CHARTYP		;CALCULATE NEW ABSTAND
	ADD	B
	STA	CHRBRT		;SAVE NEW ABSTAND
	LDA	CHARCOUN	;UPDATE CORR COUNT
	INR	A
CALPOS5:
	DCR	A
	STA	CHRCNT1
CALPOS4:		
	LDA	CHARTYP
	CPI	9
	JC	CALPOS2		;JUMP IF < 9
	LDA	BSFLAG
	ORA	A
	LDA	CHRBRT
	JNZ	CALPOS1
	SUI	8
	JMP	CALPOS1
CALPOS6:
	LDA	CHRCNT1		;GET CORR COUNT
	CPI	0
	JZ	CALPOS4		;JUMP IF NO CORR NECESSARY
	MOV	B,A		;SAVE COUNTER
	LDA 	CHARCOUN	;GET CORR COUNTER
	MOV	C,A		;SAVE IT
	MOV	A,B
	CMP	C
	JNZ	CALPOS7		;JUMP IF NO CORR AT THIS POINT
	LDA	CHAROFFS	;GET CORR FAKTOR
	MOV	B,A		;SAVE IT
	LDA	CHARTYP		;GET ABSTAND
	ADD	B		;UPDATE ABSTAND
	STA	CHRBRT
	MVI	A,0
CALPOS7:
	INR	A
	STA	CHRCNT1
	JMP	CALPOS4
CALPOS2:
	LDA	ZFA		;GET ZOOMFACTOR
	INR	A
	MOV	B,A
	LDA	CHRBRT
	MOV	C,A
CALPOS3:
	DCR	B
	JZ	CALPOS1
	ADD	C
	JMP	CALPOS3
CALPOS1:
	MOV	L,A
	MVI	H,0
	SHLD	ZFA7		;SAVE ZOOMFACTOR * 8
	CALL	COMH		;NEGATE ZOOMFACTOR * 8
	SHLD	ZFA7M		;SAVE IT
	LHLD	YCUB1
	SHLD	YCUB
	LDA	DIR1		;GET DIRECTION
	CPI	0
	JZ	XPZ		;X=X+ZF*8
				;Y=Y
	CPI	1
	CZ	XPZ		;X=X+ZF*8
	JZ	YPZ		;Z=Z+ZF*8
	CPI	2
	JZ	YPZ		;X=X
				;Y=Y+ZF*8
	CPI	3
	CZ	XMZ		;X=X-ZF*8
	JZ	YPZ		;Y=Y+ZF*8
	CPI	4
	JZ	XMZ		;X=X-ZF*8
				;Y=Y
	CPI	5
	CZ	XMZ		;X=X-ZF*8
	JZ	YMZ		;Y=Y-ZF*8
	CPI	6
	JZ	YMZ		;X=X
				;Y=Y-ZF*8
	CALL	XPZ		;X=X+ZF*8
	JMP	YMZ		;Y=Y-ZF*8
XPZ:
	LHLD	XCUB		;X+ZF*8
	XCHG
	LHLD	ZFA7
	DAD	D
	SHLD	XCUB
	RET
XMZ:
	LHLD	XCUB		;X-ZF*8
	XCHG
	LHLD	ZFA7M
	DAD	D
	SHLD	XCUB
	RET
YPZ:
	LHLD	YCUB1		;Y+ZF*8
	XCHG
	LHLD	ZFA7
	DAD	D
	SHLD	YCUB
	RET
YMZ:
	LHLD	YCUB1		;Y-ZF*8
	XCHG
	LHLD	ZFA7M
	DAD	D
	SHLD	YCUB
	RET



CHRCNT1:	DB	0	;CORR COUNT
CHRBRT:		DB	0	;ABSTAND
;
PAGE
;			*ENTER GRAPHIC MODE*
;
;
;
GRAPON:
	LXI	D,WBOOTE	;CHANGE ADDRESS OF WARM BOOT
	LXI	B,3		;OFFSET OF WARM BOOT IN BIOS
	CALL	GETPUT
	SHLD	WBOOTEO		;SAVE BIOS WARM BOOT ADDRESS
	LXI	D,DISPERR	;CHANGE ADDRESS OF DISPLAY ERROR ROUTINE
	LXI	B,39H		;OFFSET OF ERROR ROUTINE IN BIOS
	CALL	GETPUT
	SHLD	DISPERRO	;SAVE BIOS ERROR ROUTINE ADDRESS
	LXI	D,CLRLIN	;CANGE CLEAR LINE ROUTINE ADDRESS IN BIOS
	LXI	B,3CH		;OFFSET OF CLEAR LINE ROUTINE IN BIOS
	CALL	GETPUT
	SHLD	CLRLINO		;SAVE CLEAR LINE ROUTINE ADDRESS
	LXI	D,CONOUT	;CHANGE ADDRESS OF CONOUT ROUTINE
	LXI	B,0CH		;OFFSET TO BIOS CONOUT ROUTINE
	CALL	GETPUT
	SHLD	CONOUTO		;SAVE BIOS CONOUT ROUTINE ADDRESS
	MVI     A,0CH		;DISABLE DISPLAY
	CALL	COOP
	LXI	H,0
        SHLD 	CHRRAM	;START OF PATITION 1
	LXI	H,5900H	;
	SHLD	CHRRAM+2 ;LENGTH OF PATITION 1
	LXI	H,0
	SHLD	CHRRAM+4 ;START OF PATITION 2
	LXI	H,0000H
	SHLD	CHRRAM+6 ;LENGTH OF PATITION 2
	MVI	A,PRAM+0
	CALL	COOP	;OUT PRAM COMMAND
	LXI	H,CHRRAM
	MVI	C,8
	CALL	PAOP	;OUT PARAMETER
	CALL 	GCLSCR	;CLEAR ALL THREE COLOR PAGES
	CALL	DELAY	;
GRAPO1:
	IN	RSTA
	ANI	20H
	JZ	GRAPO1	
	MVI	A,0DH	;ENABLE DISPLAY
	CALL	COOP
	MVI	A,0FFH
	STA	CHARGEN1
	RET               
;
;
;
WBOOTE:
	CALL	GRAPOF		;CLOSE 
	JMP	0		;BIOS WARM BOOTE
;
;
PAGE
;
;			*EXIT GRAPHIC MODE*
;
;
;
GRAPOF:
	LHLD	WBOOTEO		;RESTORE ORIGINAL WARM BOOT ADDRESS
	XCHG
	LXI	B,3		;OFFSET OF BIOS WARM BOOT ADDRESS
	CALL	GETPUT
	LHLD	DISPERRO	;RESTORE ORIGINAL ERROR ROUTIN ADDRESS
	XCHG
	LXI	B,39H		;OFFSET OF ERROR ROUTIN ADDRESS IN BIOS
	CALL	GETPUT
	LHLD	CLRLINO		;RESTORE ORIGINAL CLEAR LINE ROUTINE ADDRESS
	XCHG
	LXI	B,3CH		;OFFSET OF BIOS CLEAR LINE ROUTINE ADDRESS
	CALL	GETPUT
	LHLD	CONOUTO		;RESTORE ORIGINAL BIOS ROUTIN ADDRESS
	XCHG
	LXI	B,0CH		;OFFSET OF CONOUT ROUTINE ADDRESS IN BIOS
	CALL	GETPUT
 	LXI	H,0
	SHLD	CHRRAM
	SHLD	CHRRAM+4
	SHLD	CHRRAM+6
	LXI	H,1900H
	SHLD	CHRRAM+2
	MVI	A,0CH		;DISABLE DISPLAY
	CALL	COOP
	MVI	A,PRAM+0
	CALL	COOP
	LXI	H,CHRRAM
	MVI	C,8
	CALL	PAOP
	MVI	C,1AH
	CALL	CLEARS	;CLEAR SCREEN
	CALL	DELAY
GRAPOF1:
	IN	RSTA
	ANI	20H
	JZ	GRAPOF1
 	MVI	A,0DH
	CALL	COOP		;ENABLE DISPLAY
	MVI	A,1
	STA	CURCOL
	STA	CURROW		;CURSOR HOME
	RET
;
DELAY:
	MVI	B,4
DELAY1:
	IN	RSTA
	ANI	20H
	JZ	DELAY1
DELAY2:
	IN	RSTA
	ANI	20H
	JNZ	DELAY2
	DCR	B
	RZ
	JMP	DELAY1

;
;
;
;
CLEARS:
	LHLD	1	;(HL)= BIOS START ADDRESS +3
	LXI	D,9
	DAD	D
	PCHL		;JUMP TO BIOS ROUTINE VCONOUT
;
;
;
;		ENTRY REG: B/C = OFFSET INTO BIOS JUMPTABLE
;			   D/E = NEW ROUTINE ADDRESS
;		EXIT REG:  H/L = ADDRESS OF OLD ROUTINE ADDRESS
;
;			   IF ROUTINE ADDRESS = 0 NO CHANGES DONE !!!!
;
;
;

GETPUT:
	LHLD	1		;GET ADDRESS OF BIOS START + 3
	DAD	B
	LXI	B,-2
	DAD	B		;POINTER TO ROUTINE ADDRESS
	MOV	C,M		;GET ROUTINE ADDRESS --> B/C
	INX	H
	MOV	B,M
	MOV	A,E		;TEST IF CHANGED ADDRESS = 0
	ORA	D
	JZ	GETPUT1		;JUMP IF ADDRESS = 0
	MOV	M,D		;STORE NEW ROUTINE ADDRESS INTO
	DCX	H		;   BIOS JUMP TABLE
	MOV	M,E
GETPUT1:
	MOV	H,B		;ADDRESS OF ROUTINE --> H/L
	MOV	L,C
	RET
;
;
;
DISPERR:
	PUSH	H
	MVI	A,25-1 OR 40H
	STA	LP12		;CUTT LENGTH OF PAGE
	LXI	H,400*40	;
	SHLD	SP2		;START OF PAGE 2
	MVI	A,PRAM+0
	CALL	COOP		;INITIALIZE PAGE 1 AND PAGE 2
	LXI	H,SP1
	MVI	C,8
	CALL	PAOP		;SEND PARAMETER
	MVI	C,1EH
	CALL	CLEARS		;CALL BDOS
	MVI	A,CURS		;SET CURSOR TO START OF ERROR LINE
	CALL	COOP
	MVI	C,3
	LXI	H,CUR1
	CALL	PAOP		;SEND PARAMETER
	LXI	D,80-1		;LENGTH TO CLEAR
	MVI	A,MASK		;SET MASK TO 0FFFFH
	CALL	COOP
	MVI	A,-1
	MVI	C,2
	CALL	PFAO		;SEND PARAMETER
	MVI	A,FIGS
	CALL	COOP		;FIGS COMMAND
	MVI	A,2
	CALL	PSAO		;DIRECTION = 2
	MOV	A,E
	CALL	PSAO		;LENGTH TO CLEAR
	MOV	A,D
	CALL	PSAO
	MVI	A,WDAT
	CALL	COOP		;WDAT COMMAND
	MVI	A,20H		;SPACE
	CALL	PSAO
	MVI	A,0		;ATTRIBUTE = 0
	CALL	PSAO
	MVI	A,CURS		;SET CURSOR TO START OF ERROR LINE
	CALL	COOP
	MVI	C,3
	LXI	H,CUR1
	CALL	PAOP		;SEND PARAMETER
	MVI	A,MASK
	CALL	COOP		;SET MASK TO FFFF
	MVI	A,-1
	MVI	C,2
	CALL	PFAO
	LHLD	DISPERRO	;GET ADDRESS OF BIOS DISP ERROR ROUTINE
	LXI	D,3
	DAD	D
	SHLD	DISPERR1+1	;SAVE IT INTO JUMP VECTOR

	POP	H
DISPERR1:
	JMP	0
;
;
;
;
CLRLIN:
	MVI	A,PRAM+0
	CALL	COOP		;INITIALIZE  PAGE 1 
	MVI	A,25 OR 40H
	STA	LP12		;GRAFIC PAGE = FULL LENGTH
	LXI	H,SP1
	MVI	C,4
	CALL	PAOP		;INITIALIZE OLD PAGE
	RET
;
;
;
SP1:	DW	0		;START OF PAGE 1
LP11:	DB	0
LP12:	DB	0		;LENGTH OF PAGE 1
SP2:	DW	0		;START OF PAGE 2
LP21:	DB	0
LP22:	DB	1		;LENGHT OF PAGE 2
;
;
CUR1:	DB	080H,03EH,0	;START OF ERROR LINE
;
;
DISPERRO: DW	0		;ORIGIN DISP ERROR ROUTINE ADDRESS
CLRLINO:  DW	0		;ORIGIN CLEAR LINE ROUTINE ADDRESS
WBOOTEO:  DW	0		;ORIGIN WARM BOOTE ADDRESS
CONOUTO:  DW	0		;ORIGIN BIOS CONOUT ROUTINE ADDRESS
;
;
;
;
CONOUT:
	RET
;

PAGE
FONT:
	CALL	ADSP
	LHLD	XADR
	LDA	CHARGEN1	;TEST IF RIGHT FON IN THERE
	CMP	M
	JNZ	FONT1
	RET
FONT1:
	MOV	A,M		;GET FONT TYPE
	ORI	30H
	STA	FCBFONT+5	;SAVE NAME IN FCB	
	LXI	D,FCBFONT	;GET FCB ADDRESS 
	MVI	C,0FH
	CALL	5		;GO To BDOS
	INR	A
	JNZ	FONT1READY
	RET
FONT1READY:
	LXI	D,CHARGEN1	;BUFFER START ADDRESS
FONT1R1:
	PUSH	D
	MVI	C,1AH
	CALL	5		;GOTO BDOS
	LXI	D,FCBFONT
	MVI	C,14H
	CALL	5		;READ BLOCK
	CPI	1
	JZ	FONT1END
	POP	D
	LXI	H,128
	DAD	D
	XCHG
	JMP	FONT1R1	;NEXT BLOCK
FONT1END:
	POP	D
	LXI	D,FCBFONT
	MVI	C,10H
	CALL	5		;CLOSE FILE
	XRA	A
	STA	FCBFONT+15
	STA	FCBFONT+32
	RET
FCBFONT:
	DB	0
	DB	'FONT0   '
	DB	'DAT'
	DB	0,0,0,0
	DS	16
	DB	0
	DB	0,0,0	
PAGE
;
;			*CURSOR AND ERASE FUNCTIONS*
;
;		ENTRY REGISTER:(H,L) = ADDRESS OF FUNCTION CODE
;
;
BIOFUN:
	RET
;
;
;       		* POSITION CURSOR*
;
;		ENTRY REGISTERS:(H,L) = ADDRESS OF ROW VALUE 
;				(D,E) = ADDRESS OF COLUMN VALUE
;
;	
;				
POSCUR:
	CALL	ADSP
	LHLD	XADR
	CALL	PATR
	MOV	A,L
	CPI	0
	JZ	P2	;JUMP IF X-POSITION OUT OF RANGE
	CPI	25
	JNC	P2	;JUMP IF X-POSITION OUT OF RANGE
	STA	CURROW
	LXI	D,20H	;OFFSET
	DAD	D	;+ X-POSITION
	MOV	A,L
	DCR	A	
	STA	YP
P2:
	LHLD	YADR
	CALL	PATR
	MOV	A,L
	CPI	0
	JZ	P3	;JUMP IF Y-POSITION OUT OF RANGE
	CPI	81
	JNC	P3	;JUMP IF Y-POSITION OUT OF RANGE
	STA	CURCOL
	LXI	D,20H
	DAD	D
	MOV	A,L	;OFFSET + Y-POSITION
	DCR	A
	STA	XP
P3:
	MVI	A,4
	LXI	H,POSCUT
P1:
	MOV	E,M
	PUSH	H
	PUSH	PSW
	MVI	C,2
	CALL	5
	POP	PSW
	POP	H
	INX	H
	DCR	A
	JNZ	P1
	RET
;
;
POSCUT:
	DB	1BH
	DB	3DH
YP:	DB	20
XP:	DB	20
CURCOL:	DB	1 	;CURRENT COLUMN
CURROW:	DB	1	;CURRENT ROW
	PAGE
;
;
;       	 	*OUT CURSOR ADDRESSABLE TEXT*
;
;		ENTRY REGISTERS:(H,L) = ADDRESS OF NUMBERS OF CHARACTER
;				(D,E) = ADDRESS OF CHARACTER STRING
;
;
OUTCAT:
	MOV	A,M	;NUMBER OF CHARACTERS
	XCHG     
O1:
	MVI	C,2	;CONSOLE OUTPUT
	MOV	E,M	;ASCII CHARACTER
	PUSH	H
	PUSH	PSW
	CALL	5	;CALL BIOS
	LDA	CURCOL
	CPI	80
	JZ	O2	;JUMP IF LAST POSITION IN ROW
	INR	A
	STA	CURCOL
	POP	PSW
	POP	H
	INX	H
	INX 	H
	DCR	A
	JNZ	O1	;JUMP IF FURTHER CHARACTERS
	RET
O2:
	MVI	C,2
	MVI	E,08
	CALL	5	;CURSOR LEFT
	POP	PSW
	POP	H
	RET
	PAGE
;
;
;			*REVERSE VIDEO ON /OFF*
;			*BLINKING ON/OFF*		
;		ENTRY REGISTER:(H,L) = ADDRESS OF FUNCTION CODE
;  
;
;
REVID:
	CALL	ADSP
	MVI	C,2	;CONSOLE OUTPUT
	MVI	E,1BH	;ESCAPE
	CALL	5	;CALL BIOS
	MVI	C,2
	MVI	E,'G'
	CALL	5	;CALL BIOS
	LHLD	XADR
	MOV	A,M
	CPI	53
	MVI	E,15
	JZ	RE1	;JUMP IF BLINKING ON
	CPI	54
	MVI	E,14
	JZ	RE1	;JUMP IF BLINKING OFF
	MOV	E,M
RE1:
	MVI	D,0
	LXI	H,REVVT-13
	DAD	D
	MVI	C,2	;CONSOLE OUTPUT
	MOV	E,M	;REVERSE VIDEO ON OR OFF
	CALL	5	;CALL BIOS
	RET
;
;
REVVT:
	DB	'4'	;REVERSE VIDEO ON
	DB	'0'	;REVERSE VIDEO OFF
	DB	'2'	;BLINKING ON
	PAGE
;
;
;
;			*INQUIRE CURRENT CURSOR POSITION*
;
;		ENTRY REGISTERS:(H,L) = ADDRESS OF X POSITION 
;				(D,E) = ADDRESS OF Y POSITION
;
;
;
ICCPO:
	RET
;
;
CURAD:
EADL:	DB	0
EADM:	DB	0
EADH:	DB	0
DADL:	DB	0
DADH:	DB	0	
	PAGE
;
;
;
;	 		*REMOVE CURSOR*
;
;
REMCOM:
	RET
	PAGE
;
;			*GET CHARACTER FROM KEYBOARD*
;
;
KEYIN:
	PUSH	H	;SAVE PARAMETER ADDRESS
KEYIN1:
	CALL	GETKST	;GET KEYBOARD STATUS
	ORA	A
	JZ	KEYIN1	;WAIT FOR KEY
	CALL	GETKEY	;GET KEY FROM KEYBOARD
	POP	H
	MOV	M,A	;SAVE KEY INTO PARAMETER 
	INX	H
	MVI	M,0
	DCX	H
	RET
GETKST:
	LHLD	1	;GET START ADDRESS OF BIOS
	LXI	D,3
	DAD	D
	PCHL		;GOTO BIOS KEYBORD STATUS ROUTINE
;
GETKEY:
	LHLD	1	;GET START ADDRESS OF BIOS+3
	LXI	D,6
	DAD	D
	PCHL		;GOTO BIOS GET KEY ROUTINE
;
CHOICE:
	PUSH	H
	LHLD	1 	;SET CONFIG FLAG 
	LXI	D,-3+512+0
	DAD	D	;    TO USE KEY VALUE OF
	MOV	A,M	;    FUNCTION KEY
	INX	H
	MOV	H,M
	MOV	L,A
	LXI	B,5
	DAD	B
	MVI	M,1     ; SET FLAG
CHOICE1:
	CALL	KEYIN	;GET KEY
	MVI	M,0	;RESET CONFIG FLAG
	POP	H
	MOV	M,A	;STORE FUNCTION KEY INTO PARAMETER 
	RET

	PAGE
;			*INPUT LOCATOR*
;		
;		ENTRY REGISTERS:
;				HL = ADDRESS OF Y
;				DE = ADDRESS OF X POSITION
;				BC = ADDRESS OF Y POSITION


INLOC:
	PUSH	D
	PUSH	B
	CALL	KEYIN		;GET CHARACTER
	POP	B
	POP	D
	CPI	17H		;CURSOR KEY HOME
	JZ	HISPED		;JUMP IF CURSOR HOME TOGGLE HIGH SPEED CURSOR
	CPI	13H
	JZ	CLEFT		;JUMP IF CURSOR LEFT
	CPI	18H
	JZ	CDOWN		;JUMP IF CURSOR DOWN
	CPI	05H		
	JZ	CDOWN		;JUMP IF CURSOR UP
	CPI	04
	JZ	CLEFT		;JUMP IF CURSOR RIGHT
	CPI	0DH
	RZ			;IF CR RETURN TO MAIN PROGRAM
	CPI	20H
	JC	INLOC		;JUMP IF INVALID KEY
	CPI	80H
	JNC	INLOC		;JUMP IF INVALID KEY
	RET			;RETURN TO MAIN PROGRAM
HISPED:
	PUSH	PSW
	LDA	FACTOR		;TOGGLE HIGH SPEED CURSOR ON/OFF
	CPI	10
	MVI	A,1
	JZ	HISPE1
	MVI	A,10
HISPE1:
	STA	FACTOR
	POP	PSW
	JMP	INLOC
FACTOR:	DW	1		;CURSOR MOVE FACTOR
;
;
;
CLEFT:
	MVI	M,0		;INDICATOR FOR MAIN ROUTINE
	XCHG			;GET ADDRESS OF X-POSITION
	PUSH	H		; AND SAVE IT
	MOV	E,M
	INX	H
	MOV	D,M		;GET VALUE OF X-COORDINATE
	LHLD	FACTOR
	CPI	04H
	JZ	CRIGHT		;JUMP IF CURSOR RIGHT
CLEF3:
	CALL	COMH		;COMPLEMENT FACTOR
	DAD	D		;CURSOR POSITION - FACTOR
	MOV	A,H
	CPI	0FFH
	JNZ	CLEF1		;JUMP IF IN RANGE
	LXI	H,0		;MINIMAL X-CURSOR POSITION
CLEF1:
	XCHG
CLEF2:
	POP	H		;RESTORE ADDRESS OF X-POSITION
	MOV	M,E
	INX	H
	MOV	M,D		;STORE NEW VALUE TO MAIN ROUTINE
	RET
;
;
CRIGHT:
	DAD	D		;XPOSITION + FACTOR
	LXI	D,640		;TEST RANGE
CRIGH1:
	CALL	WZDCMP
	DCX	D
	JNC	CLEF2		;JUMP IF HL >= 640/400
	JMP	CLEF1
;
;
CDOWN:
	MVI	M,0		;INDICATOR FOR MAIN ROUTINE
	MOV	H,B
	MOV	L,C		;GET ADDRESS OF Y-POSITION
	PUSH	H		; AND SAVE IT
	MOV	E,M
	INX	H
	MOV	D,M		;GET VALUE OF Y-COORDINATE
	LHLD	FACTOR
	CPI	05H
	JZ	CUP		;JUMP IF CURSOR UP
	JMP	CLEF3		;TEST LOWER BOUND
CUP:
	DAD	D
	LXI	D,400
	JMP	CRIGH1		;TEST UPPER BOUND
;
;			*DRAW GRAFIC CURSOR*
;
;
;		ENTRY REGISTER:
;				HL = X-POSITION
;				DE = Y-POSITION
;
CURMRK:
	CALL	KURS1		;SET CURSOR
	PUSH	D		;SAVE X VALUE
	PUSH	B		;SAVE Y VALUE
	LXI	H,12
	DAD	D
	SHLD	XPOSCUR		;
	LXI	H,-1
	DAD	B
	SHLD	YPOSCUR
	CALL	KURS2		;SET CURSOR
	LXI	H,CURMX1
	LXI	D,CURMY1
	LXI	B,CURMD
	CALL	BOX
	POP	B
	POP	D
	LXI	H,1
	DAD	D
	SHLD	XPOSCUR
	LXI	H,-12
	DAD	B
	SHLD	YPOSCUR
	CALL	KURS2
	LXI	H,CURMX2
	LXI	D,CURMY2
	LXI	B,CURMD
	CALL	BOX
	RET
;
KURS1:
	MOV	C,M		;GET X POSITION VALUE
	INX	H
	MOV	B,M		; --> DE
	XCHG			;PIONTER TO Y POSITION 
	MOV	E,C
	MOV	D,B
	MOV	C,M		;GET Y POSITION VALUE
	INX	H
	MOV	B,M		; --> BC
	RET
KURS2:
	LXI	H,XPOSCUR
	LXI	D,YPOSCUR
	CALL	KURS
	RET
;
;
XPOSCUR:DW	0
YPOSCUR:DW	0
CURMX1:	DW	3
CURMX2:	DW	25
CURMY1:	DW	25
CURMY2:	DW	3
CURMD:	DW	2
	PAGE
;
;
;*****
;***** DOUBLE BYTE COMPARE
;*****
;
;ENTRY POINT:	  WZDCMP
;ENTRY VIA:	  CALL
;ENTRY REGISTERS: A  = XX
;		  BC = XXXX
;		  DE = FIRST VALUE TO BE COMPARED
;		  HL = SECOND VALUE TO BE COMPARED
;
;EXIT VIA:	  RETURN
;EXIT REGISTERS:  A  = XX
;		  BC = PRESERVED
;		  DE = PRESERVED
;		  HL = PRESERVED
;
;	STATUS RETURNS IN FLAGS:
;					CARRY     ZERO
;		(DE) < (HL)               0         0
;		(DE) = (HL)		  0         1
;		(DE) > (HL)		  1         0
;
WZDCMP:
	MOV	A,H
	CMP	D
	RC
	RNZ
	MOV	A,L
	CMP	E
	RET
 	 


CHRRAM:	DS	32
YCUB1:	DW	0
DIR1:	DB	0
ZFA7:	DW	0
ZFA7M:	DW	0
END
