Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /storage/content/49/145849/famitracker.com/public_html/forum/classes/dbHandler.php on line 29 FamiTracker
Login:
Menu:
Post: Author:
FamiTracker > General > Source and development > Famitracker and memory use Owner: Sivak New post
Page 1 of 3 Sort: Goto Page: [1] [2] [3] Next >>
Famitracker and memory use Posted: 2008-01-22 05:07 Reply | Quote
Sivak

Avatar

Member for: 5263 days
Status: Offline

#1089
I've made an NSF that I want to use in my homebrew game with the help of Famitracker and I've gotten some fairly favorable results.

One big problem I have involves playing music while holding the BG in place is done. Basically the screen flickers and restores itself.

The issue is explained in detail here: http://nesdev.parodius.com/bbs/viewtopic.php?t=3848

Interestingly, I have used another game's NSF (Clu Clu Land's) and these bugs are all gone.

I had talked to JSR about guesses and have talked to some other people and have come up with the conclusion that some part of memory is being accessed that shouldn't be. So I'm wondering, are there any specifics on what memory Famitracker-generated NSFs use and can they be modified?

I've figured out that it uses a small part of zero page and $0200 (so my sprites can't be there), but I'm guessing something else must also be being used.

I've been looking through the NSF driver source, though I'm not seeing what this may be.

Anyone have any thoughts? Thanks.

Posted: 2008-01-23 00:00 Reply | Quote
Dafydd

Avatar

Member for: 5304 days
Location: Uppsala, Sweden
Status: Offline

#1093
It's really cool to see some people are actually making NES games. I'd love to learn how. Unfortunately I can't help you, but maybe someone else can.

Posted: 2008-01-24 00:34 Reply | Quote
jsr
Administrator

Avatar

Member for: 5924 days
Location: Sweden
Status: Offline

#1097
I'm the only developer right now so I guess I should have some answers. =)

Memory usage is, zero page: $00-$0F, above zero page: $200-$2DC. Stack depth are only a few levels. CPU usage is about 5-8%, which is around 20 scanlines. (Can probably be more in worst case)

I still think there's some unintentional PPU access being made outside of vblank as I can't really think of anything else. I haven't had problems using music in my ROMs (nothing fancy though).

If you get really stuck then I can take a look at the code, if that's alright for you. Or a ROM with the problem for checking in a debugger.

Posted: 2008-01-24 05:13  (Last Edited: 2008-01-24 05:15) Reply | Quote
Sivak

Avatar

Member for: 5263 days
Status: Offline

#1100
I don't really know how to use the debugger. People say to use it, but I don't know what half the stuff even means or what it's even telling me.

Here's a link to the rom:

http://www.nintendoage.com/media/_usermedia/attachments/Geminim-Glitched1%2Ezip

I left in the glitches. The first place you can notice them will be on the title where you move the cursor around with the d-pad.

Posted: 2008-01-26 05:20 Reply | Quote
Sivak

Avatar

Member for: 5263 days
Status: Offline

#1108
Hey, I think I've figured all this out.

Apparently, I need my init of the NSF routine at the end of things. I had it midway in the code, and that was causing the glitches.

I made some special code with a variable and then an if statement.

So all in all, that's that. Now all we need is to find a way to have two tracks playing at the same time (i.e. music and sound effects) just like Clu Clu Land's NSF can...

Posted: 2008-01-29 00:41 Reply | Quote
jsr
Administrator

Avatar

Member for: 5924 days
Location: Sweden
Status: Offline

#1112
Great that you found it! (I never had time to debug it)

There's no easy way to play two tracks at the same time, unfortunately. But you can add a flag that disables register updates for some channels and try doing sound effects on your own. (Sorry, but it's the only way right now)
Unless you feel to hack the source rather heavily.

Posted: 2008-10-02 08:19 Reply | Quote
banshaku

Avatar

Member for: 5010 days
Location: Japan
Status: Offline

#1876
I don't know if this thread is appropriate but if not, we will have to make a new one.

In this thread Sivak had an issue with the replay code. I have an issue with it. There is good chance that it's because I don't know how to use it properly since I'm still quite new to 6502 programming.

I included your driver as a module in it's own segment (changed code to sound_drv). Then I exported the real init and play function so I can use it in my main code.

I moved the music segment so it could be in my own code and removed the linking flags. I removed the init and play label to call the original method directly, to remove one jump. That is how far I modified it.

Then in my code I included the binary data from Famitracker at the music segment location.

I put the init method after the display setting (NMI + nametable) were set then in the NMI procedure, after the refresh of the OAM, I call the play function.

When I init, the emulator say that I have some illegal opcode. I guess something must have went wrong in my tests.

I will try to test it again without modifying the code and see how it goes. If you have any pointers on how to use the driver well, I will be more than happy to hear them

Thanks for that nice tracker, really like it. And thanks again for the pointers you gave me on how to use it on nesdev.


Posted: 2008-10-02 09:09  (Last Edited: 2008-10-02 13:30) Reply | Quote
banshaku

Avatar

Member for: 5010 days
Location: Japan
Status: Offline

#1877
I fixed my issue. I was too tired when I tried to incorporate the code. I copy pasted the call to the init/play function. So instead of jsr, It was jmp... So this is where the illegal opcode cames from.

Sorry to have bothered you about this. Once it worked, the sprites were going wild so I checked this post and my OAM data was at $200, so it was conflicting with FT's data. I will try to study the code more.

So the way I was using with segments what not an issue, just a stupid mistake of mine. This mean your driver can be used in a segment and works fine (there was a comment regarding this in your code).

Posted: 2008-10-03 02:30 Reply | Quote
jsr
Administrator

Avatar

Member for: 5924 days
Location: Sweden
Status: Offline

#1879
banshaku: Hi and thanks!

Great that you managed to fix it on your own. I believe good documentation can help avoid problems like these (or at least make debugging easier), and it's kind of lacking right now but I have intentions of improving it in future releases.

I hope it'll work fine with your code now, but just ask if you run into more troubles or have questions about the player in general.

_______________________
Programmer and developer
Posted: 2008-10-03 03:24 Reply | Quote
banshaku

Avatar

Member for: 5010 days
Location: Japan
Status: Offline

#1880
[quote=jsr]Great that you managed to fix it on your own. I believe good documentation can help avoid problems like these (or at least make debugging easier), and it's kind of lacking right now but I have intentions of improving it in future releases.[/quote]

I guess that your main goal right now it to make a tracker that works well and we are grateful for this So it's normal that your focus is not on the driver because you have enough job with that part already. Maybe someday you could delegate the driver part to someone that could document it, that could help you. Is the driver code used to generate NSF file?

[quote=jsr]I hope it'll work fine with your code now, but just ask if you run into more troubles or have questions about the player in general.[/quote]

Step my step, my nes project is starting to move. I started from nothing and now I can play music, so I'm already happy. Once I know how I can handle the hardware properly I will be able to focus on the game itself.

I have a few questions thought. I didn't have time to analyze the code completely, just a quick glance. One thing I saw is if the DPCM is not at $C000, it doesn't work. Is it hard coded somewhere or there is another reason behind it?

Second one, my guess is the driver focus is mostly to play the FT data, which is normal. If someone would like to add some sound effects, as in a game, my guess is the only way to do that would be to modify the driver. Conceptually, (I don't know how nes fx are done yet), it could receive some kind of queue of sound to play. Once it receive that, it would have to stop that specific channel for the current song and play that sound effects. I don't know yet if it would have to play 1 frame the song channel, the other frame the sound effect. That I have to figure out with the nesdev community.

Thanks in advance for your comments!

Posted: 2008-10-04 02:17 Reply | Quote
jsr
Administrator

Avatar

Member for: 5924 days
Location: Sweden
Status: Offline

#1883
[quote=banshaku]Is the driver code used to generate NSF file?[/quote]
Yes it's used for that. There are two precompiled versions in the tracker, one located near $C000 and one located at $8000 to enable efficient use of memory depending on if DPCM samples are used or not.

[quote=banshaku]I have a few questions thought. I didn't have time to analyze the code completely, just a quick glance. One thing I saw is if the DPCM is not at $C000, it doesn't work. Is it hard coded somewhere or there is another reason behind it?[/quote]
This is because the NES can only read samples from the area located at $C000 to $FFFF (it is a limitation in the hardware), so the samples can be located anywhere there between. The absolute address location for each sample are stored by the tracker when the music data is exported (starting from $C000 usually), but if you want to change that then a quick way is to add an offset when the DPCM sample address register is written (register $4012, in apu.s).

[quote=banshaku]Second one, my guess is the driver focus is mostly to play the FT data, which is normal. If someone would like to add some sound effects, as in a game, my guess is the only way to do that would be to modify the driver. Conceptually, (I don't know how nes fx are done yet), it could receive some kind of queue of sound to play. Once it receive that, it would have to stop that specific channel for the current song and play that sound effects. I don't know yet if it would have to play 1 frame the song channel, the other frame the sound effect. That I have to figure out with the nesdev community.[/quote]
That is correct, playing sound effects requires some of the channels to stop and then start again when the effect is done. There is no automatic way to stop channels right now, but I am going to add functions for that in the upcoming version. You just tell which channels to disable, play the effects (by writing your own data to the sound registers) and enable again. I've had request about giving the player ability to play sound effects and do the whole thing automatically (basically just starting another song with the sound effect on top of the playing music) but this was easier said than done so I'll start by just making it easer just to disable certain channels, and then later try to implement playing multiple songs.

_______________________
Programmer and developer
Posted: 2008-10-04 18:13 Reply | Quote
banshaku

Avatar

Member for: 5010 days
Location: Japan
Status: Offline

#1884
[quote=jsr]This is because the NES can only read samples from the area located at $C000 to $FFFF (it is a limitation in the hardware)[/quote]

Great, thanks to pointing that out! These days I'm learning new things about the nes everyday.

[quote=jsr]but if you want to change that then a quick way is to add an offset when the DPCM sample address register is written (register $4012, in apu.s).[/quote]

This will come in handy. Thanks again.

About playing sound fx, I will try to change the current code and see how it goes. If you do make a new version soon, please let us know on nesdev, we will be happy about this new development. I think some people are actually waiting for this, me included


Posted: 2008-10-05 03:06 Reply | Quote
Kizul

Avatar

Member for: 5780 days
Status: Offline

#1887
Out of curiosity, would it be possible to use the code for the NSF player for something other than a NES game? Like, an actual PC game, perhaps? :o

Posted: 2008-10-05 09:16 Reply | Quote
furrykef

Avatar

Member for: 5189 days
Status: Offline

#1888
An NSF is just a bunch of NES program code. So all you need to play an NSF in a PC game would be to use a 6502 CPU emulator that emulates the NES's sound hardware. There's probably a ton of different NSF players and NES emulators whose code can be recycled for this purpose, and it shouldn't even be too hard to write your own (although 100% accuracy may not be the easiest thing in that case).

- Kef


Posted: 2008-10-05 20:05  (Last Edited: 2008-10-05 20:06) Reply | Quote
Dafydd

Avatar

Member for: 5304 days
Location: Uppsala, Sweden
Status: Offline

#1890
The easiest thing would probably be taking an existing nsf player and rid it of its visual user interface, making the only way to control it be program code. An nsf plugin for winamp, for example - I'm pretty sure those come as dll files...

Page 1 of 3 Sort: Goto Page: [1] [2] [3] Next >>