necro-bump
I used this thread to get nsf's running in a compiled rom. I know it is an old thread, and that the OP probably figured it out already, but I'll post what I did in case it can help other people.
#1. Changed from nesasm to dasm. Got rid of .bank problems (was more trouble than it's worth).
#2. "Padded" the NSF I wanted to use. I found no other way to align data properly in the rom. This is the area where advice would be welcome.
For example, I wanted to include Zelda.nsf in my program.
The size of the music data, when the header is taken off is $12C4 bytes.
It's load adress is $8D60, init is $A003 and play is $A000. For the rom to be the correct size (32 784 bytes?), I had to pad $0D60 worth of zeroes before the music data, and $1FDC worth after.
This was to make the $12C4 bytes file weight $4000 bytes, for the load offset to align properly(and fill an entire prg-rom bank).
Is it common practice to do this? Is it assumed that nsf data within a nes rom weights exactly 16kb?
#3. Cleared the ram from $0000 to $07FF ... It would NOT work at all without doing that. Nintendulator would just spew out some unorganized beeps! This is what happens when you don't follow chris's example closely enough...
Anyways, for other newbies having problems with this, I ended up with this code:
Code:
INIT EQU #$A003
PLAY EQU #$A000
PROCESSOR 6502
ORG $C000
.reset
sei
cld
.waitv
bit $2002
bpl .waitv
lda #$0
tax
.clearRam
sta $0000,X
sta $0100,X
sta $0200,X
sta $0300,X
sta $0400,X
sta $0500,X
sta $0600,X
sta $0700,X
inx
bne .clearRam ;clear RAM
lda #$0
ldx #$0
jsr INIT
lda #%10000000
sta $2000 ; <- enable play after init
.loop
jmp .loop
.nmi
jsr PLAY
.irq
rti
ORG $FFFA,0
dc.w .nmi
dc.w .reset
dc.w .irq
You can compile it with dasm using this syntax:
Code:
dasm asmfile.asm -f3
and then assemble the rom this way:
Code:
copy /b header.bin+music.bin+a.out rom.nes
where:
header.bin is the iNes header (2 prg banks, 0 chr-bank, mapper0)
music.bin is the padded music data (16kb)
a.out is the 16kb prg-rom outputted by dasm
Of course this code will only run the "First track" of the nsf.
If anyone can answer my interrogations it would be most appreciated!