
	!to "chesszoomer.prg"

	* = $0801
	!byte $0c, $08, $00, $00, $9e, $32, $30, $35, $39, $00, $a2, $00

;
; Definitons
;

;
; Code Starts Here
;

	* = $080d

;
; [BEGIN] Generate Chess Datas From $4000 to $7FFF
;
!ZONE DataGen
DataGen
	stx $f0
	stx $f2
	stx $f4
	lda #$40
	sta $f1
	lsr
	sta $f5
	lda #$18
	sta $d016
	sta $f8
	asl
	sta $f3
.lbl1
	lda $f8
	sta ($f0),y
	dec $ff
	bpl .lbl2
	stx $ff
	eor #$02
	sta $f8
.lbl2
	iny
	bne .lbl1
	lda #$18
	sta $f8
	inc $f1
	inx
;	inx
	stx $ff
	bpl .lbl1
	
;
; [END] Generate Chess Datas From $4000 to $7FFF
;

;
; [BEGIN] Clear And Prepare $3000-$37FF Char Datas
;
	txa
	lsr
	sta $f1

.lbl4	lda #$00
	sta ($f4),y
	iny
	bne .lbl4
	inc $f5
	lda $f5
	asl
	bpl .lbl4

.lbl5	tya
	and #$07
	tax
	ora #$18
	sta $0f00,y
	lda ($f0),y
	cmp #$1a
	bne .goon1
	tax
.goon1
	tya
	pha
	lsr
	lsr
	lsr
	tay

	lda #$80
	cpx #$00
	beq .goon2
.lbl7	
	lsr
	dex
	bne .lbl7
.goon2
	ora ($f2),y
	ora #$55
	sta ($f2),y
	pla
	tay
	iny
	bne .lbl5

	lda $f2
	adc #$20
	sta $f2
	bcc .goon3
	inc $f3
.goon3
	inc $f1
	bpl .lbl5

;
; [END] Prepare $3000-$37FF Char Datas
;

;
; [BEGIN] Effect
;
	sei
.lbl6	tya
	sta $042c,y
	lda #$08
	sta $d82c,y
	iny
	bpl .lbl6
int
	lda $d012
	cmp #$3c
	bne *-5

.int1	lda $0f00,y
	sta $d011
.int2	lda $4000,y
	sta $d018
	iny
	bne .int1

.trn1	lda $3000,x
	sta $2000,y
	eor #$aa
	sta $2800,y
	inx
	tya
	clc
	adc #$08
	tay
	bne .trn1

	tax

.dir	lda .trn1+1
.dir1	adc #$1f
	sta .trn1+1
.dir2	bcc .dir4
.dir3	inc .trn1+2
.dir4	inc .int2+2
	lda .int2+2
	and #$3f
	bne int
	lda .dir1
	eor #$80
	sta .dir1
	lda .dir1+1
	eor #$3f
	sta .dir1+1
	lda .dir2
	eor #$20
	sta .dir2
	lda .dir3
	eor #$20
	sta .dir3
	sta .dir4
	bne .dir
;
; [END] Effect
;
