; Verifies that reset doesn't alter any RAM.

.include "testing.s"

zp_res COUNT

reset:
	sei
	cld
	ldx #$FF
	txs

	; Init PPU
	bit PPUSTATUS
vwait1:
	bit PPUSTATUS
	bpl vwait1
vwait2:
	bit PPUSTATUS
	bpl vwait2

	lda #$00
	sta PPUCTRL ; NMI off, PPU slave, Small sprites, 0 addresses
	lda #$3F
	sta PPUADDR
	lda #$03
	sta PPUADDR ; Load $3F03
	lda #$16
	sta PPUDATA ; Load $16 into palette 0, color 3
	lda #$01
	sta PPUDATA ; Load $01 into palette 1
	sta PPUDATA ; Load $01 into palette 1
	sta PPUDATA ; Load $01 into palette 1
	sta PPUDATA ; Load $01 into palette 1

	lda #$23
	sta PPUADDR
	lda #$C0
	sta PPUADDR ; Load $23C0
	lda #$41
	ldx #$40
fill_loop:
	sta PPUDATA ; Load $16 into palette 0, color 0
	dex
	bne fill_loop

	lda #$0A
	sta PPUMASK; No EM, only background rendering, normal color

	lda #$00
	sta PPUSCROLL
	sta PPUSCROLL
	lda #$80
	sta PPUCTRL ; NMI on, PPU slave, Small sprites, 0 addresses
loop:
	jmp loop

nmi:
	lda COUNT
	bne exit
	inc COUNT
	rti
exit:
	stp

irq:
	stp
