Many people start out using NESASM, probably because of the tutorials that use it. And sometimes we suggest they use a better assembler, ASM6 being a good candidate because it's very simple to use. So I decided to put together these basic NROM and UNROM templates, so that there is no excuse for people not to try it.
Note that all of these shuld be assembld in the simplest possible way: asm6 game.asm game.nes
UPDATE: Included a CNROM template.
NROM template:
UNROM template:
CNROM Template:
Note that all of these shuld be assembld in the simplest possible way: asm6 game.asm game.nes
UPDATE: Included a CNROM template.
NROM template:
Code:
;----------------------------------------------------------------
; constants
;----------------------------------------------------------------
PRG_COUNT = 1 ;1 = 16KB, 2 = 32KB
MIRRORING = %0001 ;%0000 = horizontal, %0001 = vertical, %1000 = four-screen
;----------------------------------------------------------------
; variables
;----------------------------------------------------------------
.enum $0000
;NOTE: declare variables using the DSB and DSW directives, like this:
;MyVariable0 .dsb 1
;MyVariable1 .dsb 3
.ende
;NOTE: you can also split the variable declarations into individual pages, like this:
;.enum $0100
;.ende
;.enum $0200
;.ende
;----------------------------------------------------------------
; iNES header
;----------------------------------------------------------------
.db "NES", $1a ;identification of the iNES header
.db PRG_COUNT ;number of 16KB PRG-ROM pages
.db $01 ;number of 8KB CHR-ROM pages
.db $00|MIRRORING ;mapper 0 and mirroring
.dsb 9, $00 ;clear the remaining bytes
;----------------------------------------------------------------
; program bank(s)
;----------------------------------------------------------------
.base $10000-(PRG_COUNT*$4000)
Reset:
;NOTE: initialization code goes here
NMI:
;NOTE: NMI code goes here
IRQ:
;NOTE: IRQ code goes here
;----------------------------------------------------------------
; interrupt vectors
;----------------------------------------------------------------
.org $fffa
.dw NMI
.dw Reset
.dw IRQ
;----------------------------------------------------------------
; CHR-ROM bank
;----------------------------------------------------------------
.incbin "tiles.chr"
; constants
;----------------------------------------------------------------
PRG_COUNT = 1 ;1 = 16KB, 2 = 32KB
MIRRORING = %0001 ;%0000 = horizontal, %0001 = vertical, %1000 = four-screen
;----------------------------------------------------------------
; variables
;----------------------------------------------------------------
.enum $0000
;NOTE: declare variables using the DSB and DSW directives, like this:
;MyVariable0 .dsb 1
;MyVariable1 .dsb 3
.ende
;NOTE: you can also split the variable declarations into individual pages, like this:
;.enum $0100
;.ende
;.enum $0200
;.ende
;----------------------------------------------------------------
; iNES header
;----------------------------------------------------------------
.db "NES", $1a ;identification of the iNES header
.db PRG_COUNT ;number of 16KB PRG-ROM pages
.db $01 ;number of 8KB CHR-ROM pages
.db $00|MIRRORING ;mapper 0 and mirroring
.dsb 9, $00 ;clear the remaining bytes
;----------------------------------------------------------------
; program bank(s)
;----------------------------------------------------------------
.base $10000-(PRG_COUNT*$4000)
Reset:
;NOTE: initialization code goes here
NMI:
;NOTE: NMI code goes here
IRQ:
;NOTE: IRQ code goes here
;----------------------------------------------------------------
; interrupt vectors
;----------------------------------------------------------------
.org $fffa
.dw NMI
.dw Reset
.dw IRQ
;----------------------------------------------------------------
; CHR-ROM bank
;----------------------------------------------------------------
.incbin "tiles.chr"
UNROM template:
Code:
;----------------------------------------------------------------
; constants
;----------------------------------------------------------------
MIRRORING = %0001 ;%0000 = horizontal, %0001 = vertical, %1000 = four-screen
;----------------------------------------------------------------
; variables
;----------------------------------------------------------------
.enum $0000
;NOTE: declare variables using the DSB and DSW directives, like this:
;MyVariable0 .dsb 1
;MyVariable1 .dsb 3
.ende
;NOTE: you can also split the variable declarations into individual pages, like this:
;.enum $0100
;.ende
;.enum $0200
;.ende
;----------------------------------------------------------------
; iNES header
;----------------------------------------------------------------
.db "NES", $1a ;identification of the iNES header
.db $08 ;number of 16KB PRG-ROM pages
.db $00 ;number of 8KB CHR-ROM pages
.db $20|MIRRORING ;mapper 2 and mirroring
.dsb 9, $00 ;clear the remaining bytes
;----------------------------------------------------------------
; program bank 0
;----------------------------------------------------------------
.base $8000
;NOTE: contents of program bank 0 go here
.org $c000
;----------------------------------------------------------------
; program bank 1
;----------------------------------------------------------------
.base $8000
;NOTE: contents of program bank 1 go here
.org $c000
;----------------------------------------------------------------
; program bank 2
;----------------------------------------------------------------
.base $8000
;NOTE: contents of program bank 2 go here
.org $c000
;----------------------------------------------------------------
; program bank 3
;----------------------------------------------------------------
.base $8000
;NOTE: contents of program bank 3 go here
.org $c000
;----------------------------------------------------------------
; program bank 4
;----------------------------------------------------------------
.base $8000
;NOTE: contents of program bank 4 go here
.org $c000
;----------------------------------------------------------------
; program bank 5
;----------------------------------------------------------------
.base $8000
;NOTE: contents of program bank 5 go here
.org $c000
;----------------------------------------------------------------
; program bank 6
;----------------------------------------------------------------
.base $8000
;NOTE: contents of program bank 6 go here
.org $c000
;----------------------------------------------------------------
; fixed program bank (7)
;----------------------------------------------------------------
.base $c000
Reset:
;NOTE: initialization code goes here
NMI:
;NOTE: NMI code goes here
IRQ:
;NOTE: IRQ code goes here
;----------------------------------------------------------------
; interrupt vectors
;----------------------------------------------------------------
.org $fffa
.dw NMI
.dw Reset
.dw IRQ
; constants
;----------------------------------------------------------------
MIRRORING = %0001 ;%0000 = horizontal, %0001 = vertical, %1000 = four-screen
;----------------------------------------------------------------
; variables
;----------------------------------------------------------------
.enum $0000
;NOTE: declare variables using the DSB and DSW directives, like this:
;MyVariable0 .dsb 1
;MyVariable1 .dsb 3
.ende
;NOTE: you can also split the variable declarations into individual pages, like this:
;.enum $0100
;.ende
;.enum $0200
;.ende
;----------------------------------------------------------------
; iNES header
;----------------------------------------------------------------
.db "NES", $1a ;identification of the iNES header
.db $08 ;number of 16KB PRG-ROM pages
.db $00 ;number of 8KB CHR-ROM pages
.db $20|MIRRORING ;mapper 2 and mirroring
.dsb 9, $00 ;clear the remaining bytes
;----------------------------------------------------------------
; program bank 0
;----------------------------------------------------------------
.base $8000
;NOTE: contents of program bank 0 go here
.org $c000
;----------------------------------------------------------------
; program bank 1
;----------------------------------------------------------------
.base $8000
;NOTE: contents of program bank 1 go here
.org $c000
;----------------------------------------------------------------
; program bank 2
;----------------------------------------------------------------
.base $8000
;NOTE: contents of program bank 2 go here
.org $c000
;----------------------------------------------------------------
; program bank 3
;----------------------------------------------------------------
.base $8000
;NOTE: contents of program bank 3 go here
.org $c000
;----------------------------------------------------------------
; program bank 4
;----------------------------------------------------------------
.base $8000
;NOTE: contents of program bank 4 go here
.org $c000
;----------------------------------------------------------------
; program bank 5
;----------------------------------------------------------------
.base $8000
;NOTE: contents of program bank 5 go here
.org $c000
;----------------------------------------------------------------
; program bank 6
;----------------------------------------------------------------
.base $8000
;NOTE: contents of program bank 6 go here
.org $c000
;----------------------------------------------------------------
; fixed program bank (7)
;----------------------------------------------------------------
.base $c000
Reset:
;NOTE: initialization code goes here
NMI:
;NOTE: NMI code goes here
IRQ:
;NOTE: IRQ code goes here
;----------------------------------------------------------------
; interrupt vectors
;----------------------------------------------------------------
.org $fffa
.dw NMI
.dw Reset
.dw IRQ
CNROM Template:
Code:
;----------------------------------------------------------------
; constants
;----------------------------------------------------------------
PRG_COUNT = 2 ;1 = 16KB, 2 = 32KB
CHR_COUNT = 4 ;1 = 8KB, 2 = 16KB, 4 = 32KB
MIRRORING = %0001 ;%0000 = horizontal, %0001 = vertical, %1000 = four-screen
;----------------------------------------------------------------
; variables
;----------------------------------------------------------------
.enum $0000
;NOTE: declare variables using the DSB and DSW directives, like this:
;MyVariable0 .dsb 1
;MyVariable1 .dsb 3
.ende
;NOTE: you can also split the variable declarations into individual pages, like this:
;.enum $0100
;.ende
;.enum $0200
;.ende
;----------------------------------------------------------------
; iNES header
;----------------------------------------------------------------
.db "NES", $1a ;identification of the iNES header
.db PRG_COUNT ;number of 16KB PRG-ROM pages
.db CHR_COUNT ;number of 8KB CHR-ROM pages
.db $30|MIRRORING ;mapper 3 and mirroring
.dsb 9, $00 ;clear the remaining bytes
;----------------------------------------------------------------
; program bank(s)
;----------------------------------------------------------------
.base $10000-(PRG_COUNT*$4000)
Reset:
;NOTE: initialization code goes here
NMI:
;NOTE: NMI code goes here
IRQ:
;NOTE: IRQ code goes here
;----------------------------------------------------------------
; interrupt vectors
;----------------------------------------------------------------
.org $fffa
.dw NMI
.dw Reset
.dw IRQ
;----------------------------------------------------------------
; CHR-ROM banks
;----------------------------------------------------------------
.incbin "tiles0.chr"
.incbin "tiles1.chr"
.incbin "tiles2.chr"
.incbin "tiles3.chr"
; constants
;----------------------------------------------------------------
PRG_COUNT = 2 ;1 = 16KB, 2 = 32KB
CHR_COUNT = 4 ;1 = 8KB, 2 = 16KB, 4 = 32KB
MIRRORING = %0001 ;%0000 = horizontal, %0001 = vertical, %1000 = four-screen
;----------------------------------------------------------------
; variables
;----------------------------------------------------------------
.enum $0000
;NOTE: declare variables using the DSB and DSW directives, like this:
;MyVariable0 .dsb 1
;MyVariable1 .dsb 3
.ende
;NOTE: you can also split the variable declarations into individual pages, like this:
;.enum $0100
;.ende
;.enum $0200
;.ende
;----------------------------------------------------------------
; iNES header
;----------------------------------------------------------------
.db "NES", $1a ;identification of the iNES header
.db PRG_COUNT ;number of 16KB PRG-ROM pages
.db CHR_COUNT ;number of 8KB CHR-ROM pages
.db $30|MIRRORING ;mapper 3 and mirroring
.dsb 9, $00 ;clear the remaining bytes
;----------------------------------------------------------------
; program bank(s)
;----------------------------------------------------------------
.base $10000-(PRG_COUNT*$4000)
Reset:
;NOTE: initialization code goes here
NMI:
;NOTE: NMI code goes here
IRQ:
;NOTE: IRQ code goes here
;----------------------------------------------------------------
; interrupt vectors
;----------------------------------------------------------------
.org $fffa
.dw NMI
.dw Reset
.dw IRQ
;----------------------------------------------------------------
; CHR-ROM banks
;----------------------------------------------------------------
.incbin "tiles0.chr"
.incbin "tiles1.chr"
.incbin "tiles2.chr"
.incbin "tiles3.chr"