;Screen X,Y --> X:$7369  Y:$70BE

func_screen_r1: ;$7369

CP 9
JP C,$5F
LD HL,$FFFA
LD B,(HL)
LD C,B
SET 3,B
RES 4,B
CP $C
JR Z,func_screen_r1_3 ;073AEH
SET 4,B
LD HL,$FAFC
CP $B
SET 5,(HL)
JR Z,func_screen_r1_2 ;07388H
RES 5,(HL)
func_screen_r1_2:
BIT 3,C
JR Z,func_screen_r1_6 ;073B2H
BIT 4,C
RET NZ
PUSH BC
LD A,$F7
LD B,1
LD DE,0
LD L,E
LD H,D
LD IX,$FF
LD IY,$FF
CALL func_screen_r1_7 ;$6E36
LD A,(6)
LD C,A
INC C
CALL func_screen_r1_8 ;$708A
JR func_screen_r1_4 ;073B8H
func_screen_r1_3:
BIT 3,C
JR NZ,func_screen_r1_5 ;073B9H
func_screen_r1_6:
PUSH BC
LD A,8
CALL $5F
func_screen_r1_4:
POP BC
func_screen_r1_5:
LD C,$19
JP $47

func_screen_r2: ;$70BE
AND 3
LD HL,$F3E0
RES 0,(HL)
RES 1,(HL)
OR (HL)
LD (HL),A
JP $69

func_screen_r1_7: ;$6E36
PUSH AF
CALL func_screen_r1_9 ;$7441
CALL func_screen_r1_10 ;$742D
POP AF
PUSH AF
PUSH HL
PUSH IX
POP HL
AND A
PUSH HL
SBC HL,DE
POP HL
JR NC,func_screen_r1_17 ;06E4CH
EX DE,HL
AND A

func_screen_r1_17:
EX (SP),HL
PUSH DE
PUSH IY
POP DE
PUSH HL
SBC HL,DE
POP HL
JR C,func_screen_r1_18 ;06E58H
EX DE,HL

func_screen_r1_18:
PUSH DE
POP IY
POP DE
POP IX
CALL func_screen_r1_16 ;$7079
INC C
INC C
OUT (C),E
OUT (C),D
OUT (C),L
LD A,($FAF6)
OR H
OUT (C),A
PUSH HL
PUSH IX
POP HL
AND A
SBC HL,DE
INC HL
OUT (C),L
OUT (C),H
LD A,L
OR E
PUSH IY
POP HL
POP DE
SBC HL,DE
INC HL
OUT (C),L
OUT (C),H
LD E,A
POP HL
INC B
DJNZ func_screen_r1_19 ;06EA7H
LD A,($FCAF)
CP 8
JR Z,func_screen_r1_20 ;06EBEH
CP 7
JR Z,func_screen_r1_21 ;06E9CH
CP 6
JR Z,func_screen_r1_22 ;06EA2H

func_screen_r1_21:
LD A,E
RRCA
JR NC,func_screen_r1_23 ;06EB7H
JR func_screen_r1_19 ;06EA7H

func_screen_r1_22:
LD A,E
AND 3
JR Z,func_screen_r1_24 ;06EB2H

func_screen_r1_19:
OUT (C),H
XOR A
OUT (C),A
LD A,B
OR $80
OUT (C),A
RET

func_screen_r1_24:
LD A,H
ADD A,A
ADD A,A
OR H
LD H,A

func_screen_r1_23:
LD A,H
ADD A,A
ADD A,A
ADD A,A
ADD A,A
OR H
LD H,A

func_screen_r1_20:
OUT (C),H
XOR A
OUT (C),A
LD A,$C0
OUT (C),A
RET

func_screen_r1_16:
LD A,$24
func_copy_new_1: ;707B
PUSH AF
LD A,(6)
LD C,A
INC C
POP AF
DI
OUT (C),A
LD A,$91
EI
OUT (C),A

func_screen_r1_8: ;$708A
LD A,2
DI
CALL func_screen_r1_11 ;$709C
IN A,(C)
RRA
LD A,0
CALL func_screen_r1_11 ;$709C
EI
JR C,func_screen_r1_8 ;0708AH
RET

func_screen_r1_11:
OUT (C),A
LD A,$8F
OUT (C),A
RET

func_screen_r1_10:
PUSH HL
PUSH DE
PUSH IX
POP DE
PUSH IY
POP HL
CALL func_screen_r1_9 ;$7441
PUSH HL
POP IY
PUSH DE
POP IX
POP DE
POP HL
RET

func_screen_r1_9:
LD A,($FAFC)
AND $10
RET NZ
LD A,D
ADD A,A
JR NC,func_screen_r1_12 ;07450H
LD DE,0
JR func_screen_r1_13 ;0745CH

func_screen_r1_12:
LD A,($FCAF)
RRCA
AND 1
CP D
JR NC,func_screen_r1_13 ;0745CH
LD E,$FF
LD D,A

func_screen_r1_13:
LD A,H
ADD A,A
JR NC,func_screen_r1_14 ;07464H
LD HL,0
RET

func_screen_r1_14:
JR NZ,func_screen_r1_15 ;0746AH
LD A,L
CP $D4
RET C

func_screen_r1_15:
LD HL,$D3
RET

func_copy_new: ;06EC8H
CALL func_screen_r1_9 ;$7441
CALL func_screen_r1_10 ;$742D
PUSH HL
PUSH DE
LD DE,($FCB7)
LD HL,($FCB9)
CALL func_screen_r1_9 ;$7441
LD ($FCB7),DE
LD ($FCB9),HL
POP DE
POP HL
PUSH DE
PUSH BC
LD A,$20
CALL func_copy_new_1 ;$707B
INC C
INC C
OUT (C),E
OUT (C),D
OUT (C),L
LD A,($FC18)
OR H
OUT (C),A
PUSH HL
LD HL,($FCB7)
OUT (C),L
OUT (C),H
LD HL,($FCB9)
OUT (C),L
LD A,($FC19)
OR H
OUT (C),A
LD B,0
LD A,($FCB7)
OR E
PUSH IX
POP HL
SBC HL,DE
JR NC,func_copy_new_2 ;06F28H
LD A,($FCB7)
CPL
LD D,A
LD A,E
CPL
OR D
EX DE,HL
LD HL,0
SBC HL,DE
SET 2,B

func_copy_new_2:
INC HL
OUT (C),L
OUT (C),H
OR L
POP DE
PUSH IY
POP HL
SBC HL,DE
JR NC,func_copy_new_3 ;06F3EH
EX DE,HL
LD HL,1
SBC HL,DE
SET 3,B

func_copy_new_3:
INC HL
OUT (C),L
OUT (C),H
OUT (C),A
OUT (C),B
LD B,A
POP HL
POP DE
LD A,H
AND A
JR NZ,func_copy_new_4 ;06F68H
LD A,($FCAF)
CP 8
JR Z,func_copy_new_5 ;06F6EH
CP 7
JR Z,func_copy_new_6 ;06F5DH
CP 6
JR Z,func_copy_new_7 ;06F63H

func_copy_new_6:
LD A,B
RRCA
JR NC,func_copy_new_5 ;06F6EH
JR func_copy_new_4 ;06F68H

func_copy_new_7:
LD A,B
AND 3
JR Z,func_copy_new_5 ;06F6EH

func_copy_new_4:
LD A,H
OR $90
OUT (C),A
RET

func_copy_new_5:
LD A,$D0
OUT (C),A
RET

func_line_new_b: ;06D4BH
PUSH AF
LD A,($FCAF)
CP 5
JP C,func_line_new_b_2 ;$747B
POP AF
PUSH HL
PUSH IX
POP HL
AND A
PUSH HL
SBC HL,DE
POP HL
JR NC,func_line_new_b_5 ;06D62H
EX DE,HL
AND A

func_line_new_b_5:
EX (SP),HL
PUSH DE
PUSH IY
POP DE
PUSH HL
SBC HL,DE
POP HL
JR C,func_line_new_b_6 ;06D6EH
EX DE,HL

func_line_new_b_6:
PUSH DE
POP IY
POP DE
POP IX
PUSH IY
PUSH HL
POP IY
DEC IX
PUSH AF
PUSH BC
CALL func_line_new ;$6DA9
POP BC
POP AF
INC IX
POP HL
DEC HL
PUSH IY
PUSH DE
PUSH IX
POP DE
PUSH AF
PUSH BC
CALL func_line_new ;$6DA9
POP BC
POP AF
INC HL
POP IX
INC IX
PUSH HL
POP IY
PUSH AF
PUSH BC
CALL func_line_new ;$6DA9
POP BC
POP AF
DEC IX
POP HL
INC HL
PUSH IX
POP DE

func_line_new: ;06DA9H
PUSH AF
LD A,($FCAF)
CP 5
JP C,func_line_new_b_7 ;$7476
POP AF
CALL func_line_new_2 ;$73D3
PUSH AF
CALL func_screen_r1_9 ;$7441
CALL func_screen_r1_10 ;$742D
POP AF
PUSH DE
PUSH HL
PUSH IX
PUSH IY
PUSH AF
PUSH AF
PUSH HL
CALL func_screen_r1_16 ;$7079
INC C
INC C
PUSH IX
POP HL
OUT (C),L
OUT (C),H
PUSH IY
POP HL
OUT (C),L
LD A,($FAF6)
OR H
OUT (C),A
LD A,$C
PUSH IX
POP HL
SBC HL,DE
JR NC,func_line_new_b_8 ;06DEFH
EX DE,HL
LD HL,1
SBC HL,DE
AND $FB

func_line_new_b_8:
PUSH HL
POP IX
POP DE
PUSH IY
POP HL
SBC HL,DE
JR NC,func_line_new_b_9 ;06E02H
EX DE,HL
LD HL,1
SBC HL,DE
AND $F7

func_line_new_b_9:
PUSH IX
POP DE
PUSH HL
SBC HL,DE
POP HL
JR C,func_line_new_b_10 ;06E0EH
EX DE,HL
OR 1

func_line_new_b_10:
OUT (C),E
OUT (C),D
OUT (C),L
OUT (C),H
LD E,A
POP AF
OUT (C),A
OUT (C),E
LD A,B
OR $70
OUT (C),A
POP AF
POP IY
POP IX
POP HL
POP DE
RET


func_line_new_bf: ;06E29H
PUSH AF
LD A,($FCAF)
CP 5
JP C,func_line_new_1 ;$7480
POP AF
CALL func_line_new_2 ;$73D3
jp func_screen_r1_7

func_line_new_b_7:
LD BC,$58FC
JR func_line_new_b_3 ;07483H

func_line_new_b_2:
LD BC,$5912
JR func_line_new_b_3 ;07483H
LD BC,$58C1

func_line_new_b_3:
POP AF
LD ($F3F2),A
PUSH BC
LD ($FCB3),DE
LD ($FCB5),HL
PUSH IX
POP BC
PUSH IY
POP DE
POP IX
JP func_line_new_b_4 ;$74EE

func_line_new_1:
LD BC,$58C1
POP AF
LD ($F3F2),A
PUSH BC
LD ($FCB3),DE
LD ($FCB5),HL
PUSH IX
POP BC
PUSH IY
POP DE
POP IX
;JP $74EE 

func_line_new_b_4:
CALL $159 ;$74EE 
EI
RET

func_line_new_3:
LD A,($2D)
CP 2
SBC A,A
RET NZ
LD A,($FFFA)
AND $18
CP $18
RET NZ
LD A,($FAFC)
AND $20
RET

func_line_new_2:
LD C,A
CALL func_line_new_3 ;$73BE
LD A,C
RET NZ
EX (SP),HL
LD ($F7C0),HL
POP HL
INC B
DJNZ func_line_new_4 ;073F9H
PUSH AF
PUSH DE
PUSH HL
PUSH IX
PUSH IY
LD A,$F
LD B,1
CALL func_line_new_5 ;$73FD
POP IY
POP IX
POP HL
POP DE
POP AF
LD B,2
SCF

func_line_new_4:
RLA
RLA
RLA
RLA

func_line_new_5:
PUSH HL
LD HL,($F7C0)
EX (SP),HL
RET


func_pset_new: ;06F73H
PUSH AF
LD A,($FCAF)
CP 5
JP C,func_pset_new_1 ;$749A
POP AF
CALL func_line_new_2 ;$73D3
PUSH AF
CALL func_screen_r1_9 ;$7441
CALL func_screen_r1_16 ;$7079
INC C
INC C
OUT (C),E
OUT (C),D
OUT (C),L
LD A,($FAF6)
OR H
OUT (C),A
OUT (C),A
OUT (C),A
OUT (C),A
OUT (C),A
POP AF
OUT (C),A
XOR A
OUT (C),A
LD A,B
OR $50
OUT (C),A
RET

func_pset_new_1:
POP AF
LD ($F3F2),A
LD C,E
LD B,D
EX DE,HL
LD IX,$57F5
JP func_line_new_b_4

func_point_new: ;06FA9H
LD A,($FCAF)
CP 5
JP C,func_point_new_1 ;$74A8
CALL func_screen_r1_9 ;$7441
LD A,$20
CALL func_copy_new_1 ;$707B
INC C
INC C
OUT (C),E
OUT (C),D
OUT (C),L
LD A,($FAF6)
OR H
OUT (C),A
OUT (C),A
OUT (C),A
OUT (C),A
OUT (C),A
OUT (C),A
OUT (C),A
OUT (C),A
OUT (C),A
OUT (C),A
XOR A
OUT (C),A
LD A,$40
OUT (C),A
DEC C
DEC C
LD H,0
CALL func_screen_r1_8 ;$708A
LD A,7
DI
CALL func_screen_r1_11 ;$709C
IN L,(C)
XOR A
CALL func_screen_r1_11 ;$709C
EI
CALL func_line_new_3 ;$73BE
RET NZ
LD A,L
AND $F8
RRA
RRA
RRA
RRA
LD L,A
RET C
LD L,$FF
RET

func_point_new_1:
LD C,E
LD B,D
EX DE,HL
CALL $10E
LD HL,$FFFF
RET NC
CALL $111
CALL $11D
LD L,A
LD H,0
RET

