It is currently Tue Oct 17, 2017 3:39 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: Thu May 30, 2013 1:22 am 
Offline

Joined: Thu May 30, 2013 1:16 am
Posts: 1
So I'm trying to figure out how to add Famitracker binary music to my prg code but it's not really working even when loading to the load address it specifies.

Any ideas on how to incbin binary Famitracker tunes into prg code?

I attached an NSF I'd like to include in my prg, but I can't figure it out.
\
Thanks!


Attachments:
File comment: going into prg code when I can figure out how to includ it.
smb4star.nsf [8.16 KiB]
Downloaded 78 times
File comment: music track going into prg somehow when I can figure it out.
smb4star.nsf [8.16 KiB]
Downloaded 63 times
Top
 Profile  
 
PostPosted: Thu May 30, 2013 4:27 am 
Offline

Joined: Wed Feb 17, 2010 5:42 pm
Posts: 359
Location: Denine's Devil Mansion
Well, I think, it would be better to attach said binary file, instead of NSF.
From what I understand, you want to use a Famitracker music engine in your NES game, right?

Try to compile NSF driver source.

BTW: Which assembler do you use?


Top
 Profile  
 
PostPosted: Thu May 30, 2013 12:24 pm 
Offline

Joined: Thu May 30, 2013 11:29 am
Posts: 3
Hello,

I'm trying to do exactly the same thing as iexpress. I wrote small NES ROM in assembly, composed some music in Famitracker, and now I want to play that music within my ROM.

I tries to follow the instructions I found here viewtopic.php?t=2026 and here viewtopic.php?f=10&t=6282 but I could not make it work. Here's what I did:

1) I located the three addresses specified in the NSF header (Load: $A896; Init: $AA55; Play: $AA58).
2) I removed the first 128 bytes of the NSF file.
3) I included the NSF file as follows in my PRG code (I use the Ophis assembler):

Code:
.text nsf
.org $A916
.incbin "no-header.nsf"

.text
.org $C000

reset:
  ; ...RAM initialization...
  jsr $A916 + $0A
loop:
  jmp loop

vblank:
  jsr $AA58
irq:
  rti

.advance $FFFA
.word vblank, reset, irq


No music plays. When I look at the memory using the FCEUX debugger, it looks like the content of no-header.nsf is stored at $C000 and not $A916... I have two questions:

1) Is this a mapper issue? I'm using Mapper #0. I have to admit those things still confuse me a lot. What mapper should I use to play an NSF file?
2) How can I tell which parts of RAM are used by the NSF music engine, and which parts are free for me to use for the rest of my program?

Thanks in advance!


Top
 Profile  
 
PostPosted: Thu May 30, 2013 1:02 pm 
Offline

Joined: Wed Feb 17, 2010 5:42 pm
Posts: 359
Location: Denine's Devil Mansion
pmlt wrote:
reset:
; ...RAM initialization...
jsr $A916 + $0A

Why call beginning of file, when you know that you need to call Init?($AA55)

Quote:
No music plays. When I look at the memory using the FCEUX debugger, it looks like the content of no-header.nsf is stored at $C000 and not $A916...

How many PRG banks do you have in header, and are they 16kb or 8 kb banks?
NROM(Mapper #0) comes in 2 variants-16 kb and 32kb. If you use 16kb variant, then $8000-$BFFF gets mirrored to $C000-$FFFF

Quote:
1) Is this a mapper issue? I'm using Mapper #0. I have to admit those things still confuse me a lot. What mapper should I use to play an NSF file?

Any mapper can play music. Unless you use a extra channels. If you do, you have to change mapper.

Quote:
2) How can I tell which parts of RAM are used by the NSF music engine, and which parts are free for me to use for the rest of my program?

Look at RAM. You can also try to set breakcodes at one(or several) APU registers

Since I'm using it too, I'll just tell you:
It seems to be using 16 bytes of ZP,starting at $00 and whole page of $200.


Top
 Profile  
 
PostPosted: Fri May 31, 2013 8:02 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5710
Location: Canada
If LOAD is $A896 why do you have ".org $A916"? And what is "jsr $A916 + $0A"? Also, doesn't .org only set the program counter? You need to place the data at that location, not just set the program counter.

Also, your vblank NMI will never be called unless you turn it on. You want to jsr to INIT and then turn it on by writing to $2000 (see PPU registers).


Top
 Profile  
 
PostPosted: Fri May 31, 2013 9:14 am 
Offline
User avatar

Joined: Mon Jan 03, 2005 10:36 am
Posts: 2961
Location: Tampere, Finland
Denine wrote:
Quote:
1) Is this a mapper issue? I'm using Mapper #0. I have to admit those things still confuse me a lot. What mapper should I use to play an NSF file?

Any mapper can play music. Unless you use a extra channels. If you do, you have to change mapper

Let's clarify: If it's a non-banked NSF (most commercial ones are), you can use any mapper. If it's a banked NSF, in fact you can't use any mapper directly (I don't think an iNES mapper number has been allocated for the NSF mapper?)

_________________
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: kkfos.aspekt.fi


Top
 Profile  
 
PostPosted: Fri May 31, 2013 10:28 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5710
Location: Canada
Also, if you're using Famitracker, a while ago I wrote a guide for using its .bin/asm export: http://famitracker.com/forum/posts.php?id=3681


Top
 Profile  
 
PostPosted: Sat Jun 01, 2013 7:08 am 
Offline

Joined: Thu May 30, 2013 11:29 am
Posts: 3
Quote:
Why call beginning of file, when you know that you need to call Init?($AA55)

I'm sorry, that was a copy-paste mistake on my part. I do execute "jsr $AA55" for the init phase, and I do enable vblank afterward, but still no music plays.

Quote:
How many PRG banks do you have in header, and are they 16kb or 8 kb banks?
NROM(Mapper #0) comes in 2 variants-16 kb and 32kb. If you use 16kb variant, then $8000-$BFFF gets mirrored to $C000-$FFFF


I use the value $01 as the fifth byte of my iNES header. Does that means I use 16kb variant? What should I put in to use the full range of PRG-ROM?


Top
 Profile  
 
PostPosted: Sun Jun 02, 2013 3:23 pm 
Offline

Joined: Thu May 30, 2013 11:29 am
Posts: 3
Got it working! Here's what worked for me, in case anybody else had the same problem:

First, I had to change the fifth byte of the iNES header to $02 instead of $01 (thanks Denine!)

Second, I had to change my PRG code to the following (so that 0's get forcibly written from $8000 to my load address):
Code:
.org $8000

.advance $A916 ; Write 0's until we reach $A916
.incbin "no-header.nsf"

.advance $C000 ; Write 0's until we reach $C000

reset: 
; Init code...
        ; Disable all graphics.
        lda #$00
        sta $2000
        sta $2001
        ; Init registers for loading the tune
        lda #$00
        ldx #$00
       
        ; Call music init
        jsr $AA55

        ; Enable all graphics
        lda #%10001000
        sta $2000
        lda #%00011110
        sta $2001

        ; Transfer control to the VBLANK routines.
loop:   jmp loop

vblank: jsr $AA58
irq:    rti

.advance $FFFA
.word vblank, reset, irq


Thank you all for your help!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group