;SETSCROLL a,b,c,d

func_scroll_new:

PUSH AF
LD A,E
AND D
INC A
JR Z,func_scroll_new_1 ;07023H
LD C,E
DEC DE
RR D
RR E
SRL E
SRL E
INC E
LD A,E
AND $3F
LD E,A
LD A,C
NEG
AND 7
LD D,A
LD ($FFFB),DE

func_scroll_new_1:
LD A,L
AND H
INC A
JR Z,func_scroll_new_2 ;0702CH
LD A,L
LD ($FFF6),A

func_scroll_new_2:
LD HL,$FFFA
INC B
JR Z,func_scroll_new_3 ;07038H
SET 1,(HL)
DJNZ func_scroll_new_3 ;07038H
RES 1,(HL)

func_scroll_new_3:
POP BC
INC B
JR Z,func_scroll_new_4 ;07042H
SET 0,(HL)
DJNZ func_scroll_new_4 ;07042H
RES 0,(HL)

func_scroll_new_4:
LD A,(6)
LD C,A
INC C
LD A,2
DI
CALL func_scroll_new_5 ;$709C

func_scroll_new_6:
IN A,(C)
ADD A,A
JP M,func_scroll_new_6 ;$704D

func_scroll_new_7:
IN A,(C)
ADD A,A
JP P,func_scroll_new_7 ;$7053
XOR A
CALL func_scroll_new_5 ;$709C
LD A,($FFF6)
OUT (C),A
LD A,$97
OUT (C),A
LD A,$19
OUT (C),A
LD A,$91
OUT (C),A
INC C
INC C
LD B,3
LD HL,$FFFA
OTIR
EI
RET

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