Help with playing .nsf music in a homebrew project.

Discuss NSF files, FamiTracker, MML tools, or anything else related to NES music.

Moderator: Moderators

User avatar
dougeff
Posts: 2741
Joined: Fri May 08, 2015 7:17 pm
Location: DIGDUG
Contact:

Re: Help with playing .nsf music in a homebrew project.

Post by dougeff » Thu Jun 09, 2016 3:49 pm

First, I want to make sure you get this bit right...
The reason this is suspicious...

Code: Select all

.inesprg 1   ; 1x 16KB PRG code

  .bank 0
  .org $A0E6
Is because you're clearly using 2 banks of PRG, and it should start at $8000...

Something like this...

Code: Select all

.inesprg 2   ; 2 x 16KB PRG code

  .bank 0
  .org $8000
And maybe some more 'bank' directives, since nesasm complains when you put more than $2000 bytes in a single 'bank'.

Code: Select all


 .bank 0

  .org $8000

 .bank 1

  .org $a000

  .bank 2

  .org $c000


 .bank 3

  .org $e000

 .bank 4

 ;inc graphics file here

I can't remember, it's been a while since I used nesasm.
Last edited by dougeff on Thu Jun 09, 2016 5:18 pm, edited 1 time in total.
nesdoug.com -- blog/tutorial on programming for the NES

User avatar
darryl.revok
Posts: 520
Joined: Sat Jul 25, 2015 1:22 pm

Re: Help with playing .nsf music in a homebrew project.

Post by darryl.revok » Thu Jun 09, 2016 3:56 pm

Mind if I suggest a quick change to ASM6? I don't think you'd have to modify anything other than your headers and we can help you set those up. (It looks like they need to be modified anyway)

NESASM has a lot of bizarre quirks and it's not really preferred around here. It's a bit easier to get help with a more familiar assembler.

User avatar
Memblers
Site Admin
Posts: 3881
Joined: Mon Sep 20, 2004 6:04 am
Location: Indianapolis
Contact:

Re: Help with playing .nsf music in a homebrew project.

Post by Memblers » Thu Jun 09, 2016 7:17 pm

dougeff wrote: And maybe some more 'bank' directives, since nesasm complains when you put more than $2000 bytes in a single 'bank'.
Actually it's even worse, when you overflow a bank, NESASM will build the ROM without giving any error or warning about it. I was dealing with that kind of fun stuff recently, helping someone with their project. When it comes to error messages (or lack of), working with NESASM can be a real nightmare. With NESASM 3 (one of them anyways*) you actually can put more than $2000 bytes in a bank, but if you don't do it right, you're screwed (no error or warning, just a hosed ROM).

*And to make things even more fun, there are 2 different branches of NESASM with different extensions people have added, and I think they have the same version number.. good luck. :P

User avatar
rainwarrior
Posts: 7841
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Help with playing .nsf music in a homebrew project.

Post by rainwarrior » Thu Jun 09, 2016 7:36 pm

mariogamemaster wrote:1. Write $00 to all RAM at $0000-$07FF and $6000-$7FFF.
...
7. Call the music INIT routine.
The code that clears RAM is at the location clrmem: in your code. This has to be done before you call INIT. If you clear RAM after INIT, you're erasing all the work the INIT routine just did and it's like you didn't call it at all.

Also note that the "clrmem" section is filling the region at $0200 with $FE instead of $00. This was for the OAM region at $200 which you have moved to $700, so you've got to swap what you're doing to these two locations. (i.e.: change the line that says STA $0700, x to STA $0200,x and vice versa.)

Memblers wrote:...when you overflow a bank, NESASM will build the ROM without giving any error or warning about it.
This specifically is why I called it the "worst assembler I have ever used" in another thread. ;)

For mariogamemaster, though, this problem means that when you .incbin your NSF, it's likely that NESASM will silently cut off part of the file, ruining it.

Another piece of advice, instead of trying to remove 128 bytes from the beginning by hand, you might just put -128 on the end of your .org statement at the LOAD address, and include the original NSF file. (You don't need to save that 128 bytes of space.) By shifting the starting address back 128 bytes, you'll put the start of the data where it needs to be.

Post Reply