; This file is part of the snescom-asm demo - a demo of how to build a SNES program.
; See http://bisqwit.iki.fi/source/snescom.html for details.

; Begin assembling to this address.
*= $C0FF00

RESET:
        sei: clc: xce
        jmp @GAME_MAIN

IRQ_16bit:
        php
         rep #$30
         pha: phx: phy: phd: phb
          jsl @IRQ_ROUTINE
          rep #$30
         plb: pld: ply: plx: pla
        plp
        rti

NMI_16bit:
        php
         rep #$30
         pha: phx: phy: phd: phb
          jsl @NMI_ROUTINE
          rep #$30
         plb: pld: ply: plx: pla
        plp
        rti


;error vectors
ABT_8bit: ABT_16bit:
BRK_8bit: BRK_16bit:
COP_8bit: COP_16bit:
IRQ_8bit:
NMI_8bit:
        - wai: lda $ABCDEF : bra -

*= $C0FFB0
        ; Zero the area from $FFB0 - $FFFF
        ; to ensure that the linker won't get clever
        ; and fill it with small pieces of code.
        .word 0,0,0,0, 0,0,0,0
        .word 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0
        .word 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0

*= $C0FFB0

.byt "MR"         ;2 bytes - company id
.byt "BOOT"       ;4 bytes - rom id

*= $C0FFC0
.byt "SD2SNES BOOT         "
     ;123456789012345678901; - max 21 chars

*= $C0FFD5     .byt $31  ;rom speed
*= $C0FFD6     .byt $02  ;rom type
*= $C0FFD7     .byt $06  ;rom size   64 kByte
*= $C0FFD8     .byt $03  ;sram size  8 kBit
*= $C0FFD9     .byt $09  ;rom region 4 = Finland
*= $C0FFDA     .byt $33  ;company id flag

*= $C0FFDC     .word 0,0 ;checksums

*= $C0FFE4     .word COP_16bit
*= $C0FFE6     .word BRK_16bit
*= $C0FFE8     .word ABT_16bit
*= $C0FFEA     .word NMI_16bit
*= $C0FFEE     .word IRQ_16bit
*= $C0FFF4     .word COP_8bit
*= $C0FFF8     .word ABT_8bit
*= $C0FFFA     .word NMI_8bit
*= $C0FFFC     .word RESET
*= $C0FFFE     .word BRK_8bit
*= $C0FFFE     .word IRQ_8bit
