.inesprg 2  ; 2 banks
.ineschr 1  ; 
.inesmap 0  ; mapper 0 = NROM
.inesmir 0  ; background mirroring, horizontal

; .org $0000 ; "ZEROPAGE"
ppu_emphasis = $0000
color        = $0001
temp         = $0002
gamepad      = $0003
gamepad_last = $0004

; .org $0200 ; "OAM"
; .assert ((* & $FF) = 0),error,"oam not aligned to page"
oam = $0200

.org $8000
RESET:
        sei ; Ignore IRQs while starting up
        cld ; disabled decimal mode (iirc it doesn't work properly on NES anyway)
        ldx #$40
        stx $4017 ; Disable APU frame IRQ
        ldx #$ff
        txs ; Set stack pointer to 0x1ff
        inx ; Set x to zero
        stx $2000 ; Disable NMI (by writing zero)
        stx $4010 ; Disable DMC IRQs
        ldx #$08
        stx $2001 ; Disable rendering

        bit $2002 ; Clear vblank flag by reading ppu status
VBLANKWAIT1:
        bit $2002
        bpl VBLANKWAIT1
VBLANKWAIT2:
        bit $2002
        bpl VBLANKWAIT2
        hlt
        hlt

ERROR_:
        hlt

IGNORE:
        rti


.org $FFFA	; Interrupt vectors go here:
.word nmi; NMI
.word reset ; Reset
.word irq; IRQ

;;;; NESASM COMPILER STUFF, ADDING THE PATTERN DATA ;;;;

.incbin "Sprites.pcx"
.incbin "Tiles.pcx"
