	ORG	#C000
PG7_BEGIN ;-------------------------
	INCBIN "bin/tiratok-screen.bin"

	ORG	#FA00
OUTBG

	LD	A,0
BG_DX	EQU	$-1
	INC	A
	AND	7
	LD	(BG_DX),A
	LD	E,A
	LD	D,0

	LD	HL,BUFF
	ADD	HL,DE

	LD	BC,8

	DUP	22
	LD	D,ORTBL/256
	LD	E,(HL)	;7
	LD	A,(DE)	;7
	LD	(HL),A	;7
	ADD	HL,BC
	LD	E,(HL)	;7
	LD	A,(DE)	;7
	LD	(HL),A	;7
	ADD	HL,BC
	LD	E,(HL)	;7
	LD	A,(DE)	;7
	LD	(HL),A	;7
	ADD	HL,BC
	LD	E,(HL)	;7
	LD	A,(DE)	;7
	LD	(HL),A	;7
	ADD	HL,BC
	LD	E,(HL)	;7
	LD	A,(DE)	;7
	LD	(HL),A	;7
	ADD	HL,BC
	LD	E,(HL)	;7
	LD	A,(DE)	;7
	LD	(HL),A	;7
	LD	DE,64+64-8-8-8-8-8
	ADD	HL,DE
	EDUP
	
	LD	A,0
BG_DY	EQU	$-1
	ADD	A,2
	AND	15
	LD	(BG_DY),A
	LD	LX,3
	CP	12
	JR	C,BGY3
	DEC	LX
BGY3
	LD	L,A
	LD	H,0
	ADD	HL,HL
	ADD	HL,HL
	ADD	HL,HL
	ADD	HL,HL
	ADD	HL,HL
	ADD	HL,HL
	LD	DE,BUFF+2
	ADD	HL,DE
	
	LD	BC,64*16-32
	LD	D,ORTBL/256
BGL1	DUP	32
	LD	E,(HL)	;7
	LD	A,(DE)	;7
	LD	(HL),A	;7
	INC L
	EDUP
	ADD	HL,BC
	DEC	LX
	JP	NZ,BGL1
	RET
	
	
	DISPLAY "OUTBG_END ", /A, $
	SAVEBIN "compile/addstarbg.bin", OUTBG, $-OUTBG