Ok, first off, I'm new to this forum, after about a week of searching for answers, I've finally decided to register to ask my questions
I know this have been discussed a couple of times now, but I'm having real hard time including NSF files in my code.
I'm using NESASM, and from what I've read, that might be the problem, even thou I don't get errors
Even if I copy some/most of the code posted here, I still can't get it to work.
I have stripped the header from the NSF (Made with FamiTracker),and the load address is $B05D, I believe.
The init address is $B200, and play is $B203.
I've done everything I can possibly imagine, but no matter if I'm trying to include it at an existing project, or new one, I just can't get it to work.
Any suggestions?
If it it crosses bank boundaries, I don't know if nesasm deals with that or not (or doesn't when it assembes code). $B05D seems really weird as a load address. Have you had it generate a listing and looked at it? Also what's it do, if you can step into it with a debugger?
Best bet might be to reassemble the NSF and have it start at $8000.
I'm still a newbie, so I don't know what you mean with "generate a listing", or anything with debugging yet
(Try 'n fail, read 'n learn)
But I might have failed when it comes to getting those addresses?
Load address is at 08-09 with a hex editor, init is 0A-0B, and play is 0C-0D?
The NSF does play fine in NESten's NSF player, however.(With header, ofcourse.)
I've seen a couple of ways to include NSF songs, and I don't know what to use, and concentrate on using yet. So perhaps I'm just doing all wrong there?
What way is the most common/easiest?
What I do for a quick debugger check, is put something like this right before where I want to check:
stop: jmp stop
Then in a debugger, usually FCEU you can hit the step button, then you can step through it from there.
Usually the NSF is assembled separately (with whatever assembler), though you could include the driver source (it usually wouldn't matter).
It's most common to put the music starting at $8000, and you'll have to place any DPCM samples separately (at $C000 or above).
But, with the NSF loaded at $8000, will the addresses from the header still work?
From what I understand, I have to jsr to the addresses I got form the header.
So, if I
Code:
.org $8000
.incbin "Song.nsf"
To init, I probably can't just do
Code:
lda #$01
ldx #$00
jsr $B200
I'm more newbie then I thought
No, you should make a new NSF. For Famitracker what you'll need to do is get the driver source code, and in the tracker export your music as a .dat file. The driver source includes everything you'll need. You can change the addresses in there pretty easily (linker config, the nes.cfg or nsf.cfg file). I also recently made a modification for it so it can play music from multiple .dat files, if you ever need to.
In my older games, I used Famitracker NSFs, although I'd discourage it for anything other than just to get some music in there.
Anyway, the NSF load address will change whenever you add something new to it. In my old Geminim game, I had this:
Code:
NSFloadAddr = $A682 ;Gets $80 subtracted from it when used down below
NSFinitAddr = $B200
NSFplayAddr = $B203
....
.bank 1
.org NSFloadAddr - $80
.incbin "Geminim.nsf"
The only reason I do that - $80 is because I was lazy and didn't bother stripping out the NSF header. If you did do that, then disregard the -$80.
Then, whenever a new sound needed to be loaded, I'd have some checks to see if a new sound was called and eventually would: JSR NSFinitAddr
...And every single frame there would be a JSR NSFplayAddr called towards the end of NMI.
You also need to be sure the first $18 or so bytes of zero page are NOT used by anything and that most, if not all of $0200-$02FF is NOT used by anything.
Sivak wrote:
In my older games, I used Famitracker NSFs, although I'd discourage it for anything other than just to get some music in there.
Except for the size of the driver which I now is easily 3/4k, why do you discourage it? Too much CPU usage? Hard to modify? I think it could be relevant to this thread.
I was able to modify like Membler so I can locate my music data where I want, disable some channels and play some sound fx (not perfect for fx, I stopped to work on that part to focus on other tools).
Banshaku wrote:
Except for the size of the driver which I now is easily 3/4k, why do you discourage it? Too much CPU usage? Hard to modify? I think it could be relevant to this thread.
I guess hard to modify to allow for sound effects would be my main complaint. But that's just me. The engine I have needs no modification by me, so I'm fine with it.
Sivak wrote:
I guess hard to modify to allow for sound effects would be my main complaint. But that's just me. The engine I have needs no modification by me, so I'm fine with it.
ok, I see. The way I'm doing it at the moment is that I inserted 2 variables: 1 for the music data address so you can point to your music anywhere in the rom and one for which channels I want to disable.
Before I play the music in my frame (ft_music_play) I check if I need to do any sound fx. If any, I set in my variable which channel must be disabled. In the music routine (apu module), when the player decide to play the next frame, I check if the channel is disabled or not. If it is, I don't play the music on that channel. Then, after the music routine is over, I play my sound fx. This way, the music player and soundfx player don't have to know about each other.
Once I start to use it more seriously in my game I will see how easy is it to use that way or not. If it's doesn't work so well, worst case I'll just make my own but I still think that we could do something interesting if we modify it properly.
I could try someday to to play another track as sound fx but I guess this one could be quite complicated to do depending how "flexible" you want it to be.
I decided to post a new message since this one is specific to the original poster. Sorry for the 2 post in a row.
Wkter wrote:
I know this have been discussed a couple of times now, but I'm having real hard time including NSF files in my code.
I'm using NESASM, and from what I've read, that might be the problem, even thou I don't get errors
Regarding your issue, are you making your own music or using an already existing NSF? If by any chance you are making your music and doing it with Famitracker 2.7, I converted the sound driver for Nesasm. I made a sample on how to use it too.
So if this is the case, I can provide the code anytime.
Banshaku wrote:
I decided to post a new message since this one is specific to the original poster. Sorry for the 2 post in a row.
Wkter wrote:
I know this have been discussed a couple of times now, but I'm having real hard time including NSF files in my code.
I'm using NESASM, and from what I've read, that might be the problem, even thou I don't get errors
Regarding your issue, are you making your own music or using an already existing NSF? If by any chance you are making your music and doing it with Famitracker 2.7, I converted the sound driver for Nesasm. I made a sample on how to use it too.
So if this is the case, I can provide the code anytime.
I'd be interested in seeing that sound driver!
MetalSlime wrote:
I'd be interested in seeing that sound driver!
Here's the link
(FTSoundDriver_RC3)
This is the last update I did before I put that project on hold. There is a sample for CA65 and nesasm. It play some music and some simple sound fx. The sound fx part is not designed properly: it just for testing purpose and didn't have time to make an engine for it. You need to use FT2.7 to use it, not the latest one.
I will port the new driver later once I get back on the music part of my game project since I want to use VRC6 at some point. This file is already useful for nesasm users since the FT website only provide a CA65 version.
I will do my best to provide some answers on the usage of the samples if any question arise.
Thank you for your help!
It seems like I didn't strip the header correctly, so I used your code, and left the header on..
Works quite good
But it seems I must make some edits to the music, so it sounds etter.
Banshaku wrote:
Regarding your issue, are you making your own music or using an already existing NSF? If by any chance you are making your music and doing it with Famitracker 2.7, I converted the sound driver for Nesasm. I made a sample on how to use it too.
I'm making my own, simple music
I don't know what version I'm using, Ill check when I get back from school.
Banshaku wrote:
MetalSlime wrote:
I'd be interested in seeing that sound driver!
Here's the link
(FTSoundDriver_RC3)This is the last update I did before I put that project on hold. There is a sample for CA65 and nesasm. It play some music and some simple sound fx. The sound fx part is not designed properly: it just for testing purpose and didn't have time to make an engine for it. You need to use FT2.7 to use it, not the latest one.
I will port the new driver later once I get back on the music part of my game project since I want to use VRC6 at some point. This file is already useful for nesasm users since the FT website only provide a CA65 version.
I will do my best to provide some answers on the usage of the samples if any question arise.
Thanks a lot!
HI,Sorry,about reviving this thread,but i need some help.
Actualy i just want to ask Banshaku if he will update driver to famitracker 3.0?
And maybe make it more easy to understand?
I did a little game,but i have HUGE problems with music..;[
Also, since we're on topic, I noticed that FamiTracker can also export 32kb .prg file. Do I just need to use incbin to include it? And is there any way to reduce it to 16kb instead?
Look at the NES file it generates with a hex editor, look at where the player code and data is in the ROM. As long as you make a new rom with the player code in the same address as the old player code, you can just call the player's init routine and play routine.
So I'm looking at a generated NES file. Looks like the player occupies the first 0D20 bytes, then the music data immediately follows it. When you see a bunch of zeroes or FF's or whatever, you know that data ends. The rest of the NES file doesn't matter, it's just some stub code to call the player, and the vectors. If you use DMC samples. there may be a hole in the file before the DMC data.
Play code is at $8000, init code is at $8003.
Player uses the first 0x10 bytes of zeropage, 0x200-0x2DF, and up to 10 bytes of stack.
As long as you don't step on the player's RAM, and have the memory all mapped correctly there should be no problems. Just call init once, then call Play once per frame.
So yes, you can incbin the player code at $8000 if you're making a NES rom.
It depends what you means by update to 3.0. Do you mean converting it to nesasm or adding the features for playing sound fx?
If this is the sound fx part, I'm still not implemented yet in my mm9 proof of concept so it may take a while before I start coding it. I'm quite busy these days with my personal life so I don't know when I will be able to work on it. These days, I don't even have time at all to work on my hobby.
Version 3.0 of the driver allow to disable the sound channels, it's already implemented (albeit a little bit differently than my approach) if this is the only thing you need to do.
edit:
People answered this post while I was writing. I will add to this post then.
WJYkK wrote:
Also, since we're on topic, I noticed that FamiTracker can also export 32kb .prg file. Do I just need to use incbin to include it? And is there any way to reduce it to 16kb instead?
I would not do that for a game, that is not practical. Instead export the sound data to binary only (i.e. no driver included), include the source code for the sound driver in the segment you want and just change the address were the sound data point to the location where you incbin your custom song data.
Uh...sorry.I meant support for Famitracker 3.0(VRC music).
I have a music file and a nes game in NESASM what i have to do to make my game play music with sound driver(easiest way,please
).
For now I didn't convert yet the code for FT3.0 for nesasm since the interest was not really there. It's not such a big job so I could see if I can do it if I can find the time soon.
Playing the song inside your game shouldn't be that difficult. Once you include the driver + bin, you just need to set the address of the song, select which song you want to play, init and play. Maybe I can find some time this weekend and do a quick VRC-6 sample at the same time.
Thanks,I'd be looking forward to it!
And if you wish to play my game (it's still in "prototype" state)
Then you can download it here:
http://dl.dropbox.com/u/1309313/NES%20P ... totype.NES
Controls in menu:
Select and A button.
In game:
Right and left arrow.
Denine wrote:
Thanks,I'd be looking forward to it!
And if you wish to play my game (it's still in "prototype" state)
Then you can download it here:
http://dl.dropbox.com/u/1309313/NES%20P ... totype.NESControls in menu:
Select and A button.
In game:
Right and left arrow.
Not bad. Couple of things I noticed. It's cool that you can walk behind the tree, but if they coins fall on the other side how is the egg catching them? Also, if you press a button while moving it stops the character from moving. A little bit of catchy music will add a lot to this project.
SOo...umm..i don't hurry you up,but how's work is going?(Sorry for bad vocabulary)
Quite a coincidence, I was just going to post something on the subject. Sorry, I couldn't work on it this weekend since I had a few other things to take care of (I worked on updating the software of the wiki amongst other things).
The work is already started but in the new version, there is a lot of flags for enabling/disabling specific chips (VCR6, MMC5 etc) with if condition that doesn't work the same as CA65. So it will take a little bit more time before it can be converted and tested. I'm not sure yet how to convert those flag, thus the reason of delay. I will see what I can do this week but I cannot promise anything.
Nah,don't worry,i have time,I just asked,but...I have 1 question:
Applying music code will be easy?
There are three hang-ups:
- Stay out of the way of whatever RAM the music player uses.
- Make sure your sound effects engine cooperates with the music engine: share the address used for avoiding unnecessary writes to $4003 and $4007.
- Make sure your sound effects engine cooperates with the music engine: the music engine either shouldn't update a channel in use by sound effects or should provide an interface to play sound effects as "notes" on an "instrument".
Then it's a matter of calling start_music() at the start of a new screen and update_music() every frame.
I guess what Tepples said mention many of the points you have to be careful. As for being easy, it's all depends on how comfortable you feel about nes programming. The first thing that will be an issue is how to initialize properly the VRC6 mapper. Not hard but a pain when you don't know how it work.
Like I mentioned, once I figure out how to convert this version properly for nesasm I will try to make the sample VRC6 compatible. It just that I don't have that much time these days.
Edit:
I finished to convert yesterday but the first tests resulted in the rom to fail which means I made a mistake and it will take more time before I can have a stable release.
Status update:
the nesasm driver is now working. There is a bug in the driver that cause volumes to go haywire if the ram is not reset properly. In the past (if I remember well) there was some code in the init function that was doing a clean-up and it's not there anymore. I need to fix this.
I should be able to make a quick VRC6 sample this weekend. Don't lose hope, it's coming
Edit:
Both drivers are working. What is left is to make a VRC6 sample in nesasm, like I promised. Maybe I can do it this weekend.
Here a release that you can play with it:
Famitracker Soundriver (FT3.0) for ca65 and nesasm
Nothing new in this driver (from me) except that I fixed a bug that occur when you use multiple binary file. The memory was not reset anymore, causing all kind of issues.
I started to make a quick sample for VRC6. The sample is not finish yet: the rom size and mapper setting are probably wrong but will work with emulators (nintendulator and nestopia). Once I have time, I will try to make a sample that work on the real hardware. For now, it should be enough to insert music in your game.
Have fun
OK,It's working nicely with my music,but I still have some problem..How can I apply Drvier to my game?
Basically, what you have to do is:
- copy the soundrv folder in your project
- include the driver.asm in a bank that have enough space and that will be selected when the game is running
Code:
; The code for the player
.include "./soundDrv/driver.asm"
- Set the flag for VRC6
Code:
USE_VRC6 = 1 ; Enable this to include VRC6 code
- Check in the reset vector how the music is init and the mapper and use that code
Code:
; Init VRC6 mapper
lda #$00
sta $8000 ; Bank 0 at $8000
sta $8010
lda #$02 ; Bank 2 at $C000
sta $C000
lda #$00000000
sta $E000 ; Mirroring
; Init CHR banks
ldx #$00
stx $D000 ; 1K at CHR 0
inx
stx $D001 ; 1K at CHR 1
inx
stx $D002 ; 1K at CHR 2
inx
stx $D003 ; 1K at CHR 3
inx
stx $E000 ; 1K at CHR 4
inx
stx $E001 ; 1K at CHR 5
inx
stx $E002 ; 1K at CHR 6
inx
stx $E003 ; 1K at CHR 7
; Then store the address of the intented music data, if any.
lda #LOW(songData1)
sta ft_music_addr
lda #HIGH(songData1)
sta ft_music_addr + 1
; Finally select the song inside the music data
lda #$0 ; track 0
ldx #$0 ; NTSC
jsr ft_music_init
- Call the play method on every nmi
Code:
; Play the music
jsr ft_music_play
- Change the mapper to 24
Code:
.inesmap 24
That should do it. Like I mentioned, the code for setting banks (PRG ones, chr should be fine) is not 100% accurate so it may still not work on the real hardware but if you code is not that big and uses almost the same setup as the sample (.inesprg 1), it should work fine in emulator even thought it's not ok (emulators are still not too strict about some bank settings for those exotics mappers).
But before you include the music, did you fix your issues with Nintendulator/nestopia? That should be your top priority
Including the sound driver will not be an issue at a later stage.
I tried to include sound driver,but i was unsuccesful...I tried many,many times,but most common eror is:
Code:
#[1] 1.asm
17 00:8F9F USE_VRC6 = 1
Unknown instruction!
And...uhm...compability with nestopia and nintendulator isn't solved yet unfortunelly
Denine wrote:
Code:
#[1] 1.asm
17 00:8F9F USE_VRC6 = 1
Unknown instruction!
That's odd, is USE_VRC6 = 1 the first thing on that line? With some assemblers it seemed like you weren't allowed to put a space/tab before a label or assembler directive, which is pretty lame. I've used a lot of them so I'm not sure which one was like that.
in file it goes like this:
Code:
.bank 0
.org $8000
.include "./soundDrv/driver.asm"
USE_VRC6 = 1
I see 2 possibility.
Order it's defined:
- USE_VRC6 should be before the driver include and nesasm complaint about that (doesn't seems like that from the error message)
Or:
- The define doesn't start as the first character on the line and nesasm complaint.
Try it and see what it does. By the error, it seems more to be error #2. Check how the sample was created, that should already give you an idea.
Ok,I was able to compile it without errors,but...
Name Table is messed up,except for main menu.
Sound is played in "credits" screen only.
Here's a video:
http://www.youtube.com/watch?v=AFAKJLWsKU4
How code is going:
Header(mapper 24),
Bank1 with interupt table
Bank0:
first is vrc6.bin included
second is VRC6 flag set
third is sound driver included
fourth is code to init VRC6 mapper
last is regular code of game.
NMI label contain:
Code:
jsr ft_music_play
rti
Maybe I should give whole code to Banshaku so he can setup game propely...I don't know..
What registers is your NMI routine saving and restoring?
It's a bad idea for an interrupt service routine to change the CPU's registers behind the main program's back.
There are six architectural registers in the 6502: A, X, Y, P (flags), S (stack pointer), and the program counter. /NMI saves P and the program counter on the stack; RTI restores them. Your NMI handler has to either save A, X, and Y on the stack or not use them. If you're playing music in your ISR, the music player is probably using all registers. So save them on the stack and restore them afterward:
Code:
.proc nmiHandler
pha
txa
pha
tya
pha
jsr ft_music_play
pla
tay
pla
tax
pla
rti
.endproc
So i need to replace NMI code with yours?
hmm...It's still not working.Maybe i made other mistakes...I'll look for them.
What RAM addresses is your music player using?
A messed-up nametable may mean you are taking more than the 2270 cycles of vertical blanking time to update VRAM. Either move music playback out of the NMI handler, or move nametable updating into it and before the music playback.
For now unless I can see some code there is not much I can do. You're already aware that your game already have issues with Nintendulator/nestopia. Now trying to put the sound engine code inside code with issues is "not a good thing" (tm). I would focus on fixing the original issue. Inserting the music shouldn't be such a problem after since for now your game shouldn't be quite timing intensive from what I saw.
YES!
I DID IT!
I mean...game is now working with NEstopia and nintendulator,don't ask about problem,it's a shame that I didn't noticed it earlier...
SO...as i can understand...i Needed NTSC to run to use VRC Music driver(I heard it's not supporting PAL)
Now,i'll try to attach music driver...
Good to see that your project is moving forward. As for VRC6, if was only released in Japan, which is only NTSC. They never released a version in europe.
Remember bug from video?
It's removed!
Ok,i was able to apply Music Driver to my game,however...i just get empty screen with music playing!
Later,i was able to make my game play,but...music was gone(Except for "BEEEEPP" sound...) any ideas how i should put games code to make it working with game?
(Later,when BBEEP sound appeared I noticed that NMI is executed only ONCE,no idea WHY...)
I'm just guessing but you must have more than one bank. The VRC6 require the setting of the banks to be done properly. In the sample I gave, there is good chance the settings for the mapper are wrong for PRG ones since only one bank is set and emulators didn't complain about it.
From what I understand of your message, once you move code around either the music work or the game. This mean while the game is running, there is good chances that the wrong bank was selected in the region were the code doesn't work.
I did one sample in the past for VRC6 and tested on hardware but I don't think it was for nesasm. I can't find it anymore. So for now I don't know how to set properly the banks in nesasm then set VRC6 mapper settings. This is probably the only issue.
I plan to start adding music driver again from start,but:
-You have some kind of list of used RAM adresses?
-Sound effects can be added?(I tried,but failed...)
-What about VRC6 bank setting?
Hey,Banshaku...I got it working with my game!
But...only if it is in last (fixed)bank...so..let's say i want to store music in different bank(bank 3 for example)How in the world i can switch from bank0(main game code) to bank 3,read music data,and hop back into bank 0 without screwing antyhing?I know how to switch banks,but i don't know how to load code from different bank than0(bank 0 have main loop...)
This is a good question. I don't know enough about VRC6 at the moment. I'm checking the wiki to see the bank configuration. Maybe by that time someone may be able to answer you.
But how is your program set? All code is in the fixed bank, driver included? I just want to have a better understanding of location of data/code and maybe I could (or someone else) figure out what is better to do in that case.
Code:
.include "./common/NES.inc"
Is in start of bank 0,just before VRC6 flag,and Zero page variables.
Everything else is in fixed bank($E000)except for music data-It's in $C000.
Also to make driver work you need to put this code after "player init"
Code:
; init default value for ppu_crtl flags + activate NMI
lda #PPU_CTRL_NMI
sta zpPpuCtrlFlags
sta PPU_CTRL
Banshaku wrote:
Here a release that you can play with it:
Famitracker Soundriver (FT3.0) for ca65 and nesasmNothing new in this driver (from me) except that I fixed a bug that occur when you use multiple binary file. The memory was not reset anymore, causing all kind of issues.
I started to make a quick sample for VRC6. The sample is not finish yet: the rom size and mapper setting are probably wrong but will work with emulators (nintendulator and nestopia). Once I have time, I will try to make a sample that work on the real hardware. For now, it should be enough to insert music in your game.
Have fun
What did you use to make bin files? I used FamiTracker 0.27 to export as bin, and not worked.
Kunio wrote:
What did you use to make bin files? I used FamiTracker 0.27 to export as bin, and not worked.
Since the driver is for Famitracker 3.0, version 0.27 will not work. The binary format of previous version is not compatible with the latest driver.
Banshaku wrote:
Kunio wrote:
What did you use to make bin files? I used FamiTracker 0.27 to export as bin, and not worked.
Since the driver is for Famitracker 3.0, version 0.27 will not work. The binary format of previous version is not compatible with the latest driver.
I also tried the 0.3.5. Ok, then let's see with the 0.3.
One more question: How did you import the whole Ninja Gaiden soundtrack, even with DPCM?
Kunio wrote:
One more question: How did you import the whole Ninja Gaiden soundtrack, even with DPCM?
For the song, I didn't import it: I did a cover of the song only. I found the DPCM drum that someone extracted (Maybe it was Bucky if my memory is good) and tried to make it as faithful as the original.
HI!
I was about 7 month since I was doing anything in DRD(Dizzy Rainy Day).
The problem was that I'm bad at grafic making,and game development was halted...
But miracle happend-About week ago one guy responded to my request and said that he will make some grafics.
I'm back with development.(Actually I returned with it today,after seeing first grafic..)
But there's another reason for me to write a post here:
Of course,I have a roblem.
And yes,It's music driver.
Last time music was playing really good,now it's playing same,however,back then I wasn't doing anything serious about music.
Now I have really nice remix of Yolkfolk village.
The problem?
Sound driver plays VRC6 channels incorrectly.
It plays fine in Banshaku sample,but not in mine game...
Maybe I shouldn't post it-There's a little chance of finding why it happens without source code,however...ONLY VRC6 channels are glitched,other "normal" channels plays fine.
I was trying to solve it by myself,but I miserably failed.
Maybe there's some kind of glitch that is known by community?
And,I was using Famitracker 3.0 to build bin files,not latest one.
Can anyone help?
Maybe there is a memory collision somewhere. If you're using Famitracker to create the NSF, I don't recall anything right off hand that tells you the RAM usage unless maybe you look at the driver source code. Could be any number of things, possibly.
I don't collide RAM...
Maybe Banshaku can help.
The strange thing-just after RESET interrupt I init music and then make infinte loop...and music is still messed...
This mean that code of my game is not colliding with music driver(right?)
And I don't use IRQ...
hmm..NMI also don't mess it up...so why..?
(Maybe I should provide whole source code?...but it may be a lot of work with checking it..)
EDIT:
ARGHHH!!
I fixed it...
Just don't laugh at me,ok...?
I never seen it in Famitracker documentation,but i gave it a try-
Music driver is NOT compatible with mapper 26(I'm using mapper 26...)ONLY with 24.
I changed mapper number and it started to work,magic?
Yeah,it's a little funny-i lost whole day,but at least learned something:)