It is currently Wed Oct 17, 2018 5:37 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Fri Aug 24, 2018 10:57 pm 
Offline
User avatar

Joined: Tue Jun 24, 2008 8:38 pm
Posts: 2001
Location: Fukuoka, Japan
For my current tests in C, I ported the code back to neslib examples and I'm using, I think, NROM (128/256). For now the code and data fits in 32k and I have no issue but once I switch back to my target mapper I need to decide how to manage it.

For my test, since I was not able to convert the song to famitome (for this project is not big deal), I decided to try the example by Shiru that uses famitracker for music and a trimmed down version of famitone for sound fx and it's working quite well. My old ft3.0 data converted to 4.6 got trimmed by at least 1k so there was some good things out of it.

As you can imagine, those 2 engines put together will take a lot of space. From my map file, both combined seems to takes around 177E bytes, which is almost a bank on mmc3.

How would you manage such a big engine and the music data on an MMC3? Would you keep the engine in the locked banks or switch them when necessary?

For testing code only, everything is the same bank is more than enough but it will become an issue to fix so I should start to migrate the code as soon as possible.


Top
 Profile  
 
PostPosted: Fri Aug 24, 2018 11:12 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 6881
Location: Canada
The only thing that needs to always be present is DPCM samples.

I like to store the music code with the music data, and bank it in only temporarily when I'm calling the player function.

If you have a lot of music data, though, it might help to put the player in its own bank, or fixed bank, I guess. On MMC3 you could put data at $8000-BFFF and player in $C000-DFFF if you weren't using DPCM. (Not using DPCM opens up a lot of possibilities, in general.)


Top
 Profile  
 
PostPosted: Sat Aug 25, 2018 2:27 am 
Offline
User avatar

Joined: Tue Jun 24, 2008 8:38 pm
Posts: 2001
Location: Fukuoka, Japan
I see. For my current project I do not need DPCM so it should be fine. Since the combined drivers are almost 8k, I cannot put the music in the same bank since 1 song is easily 1~2k. This means I would need a bank for the driver and bank(s) for the songs.

The only thing that I may need to check is how the famitone fx driver do for playing fx. It should be done during at the same time as music but what happens when you request an fx. I may need to adapt the code for setting up fx to be in a static bank since the request will be done outside the nmi.


Top
 Profile  
 
PostPosted: Sat Aug 25, 2018 2:44 am 
Offline
Formerly WheelInventor

Joined: Thu Apr 14, 2016 2:55 am
Posts: 1782
Location: Gothenburg, Sweden
I'd consider this a last resort, but some games place a copy of the driver in several banks to avoid bank switching. Metroid keeps a couple of songs and a copy of its driver in each level bank*. With a big driver, this is less attractive of course.

*(the "world map" itself is actually commonly shared for all levels, but the structures each room in that world map points to are stored in the level bank, along with other level specific data)

_________________
http://www.frankengraphics.com - personal NES blog


Top
 Profile  
 
PostPosted: Sat Aug 25, 2018 6:36 am 
Online

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20661
Location: NE Indiana, USA (NTSC)
The Curse of Possum Hollow uses MMC3 and a FamiTone-derived driver. It has the engine and SFX data at $8000-$9FFF and music sequence data in three different banks swapped into $A000-$BFFF. When the driver isn't executing, something else is swapped into those banks.

Nova the Squirrel uses MMC1 (or, with a compile time switch, UNROM + SRAM) and Pently 5. The vast majority of the soundtrack fits in one 16K bank that gets switched into $8000-$BFFF. I seem to remember that a couple tunes in cutscenes or wherever use a different driver, and one of the hidden minigames (DABG) uses a copy of Pently 3.


Top
 Profile  
 
PostPosted: Sat Aug 25, 2018 8:19 am 
Offline
User avatar

Joined: Tue Jun 24, 2008 8:38 pm
Posts: 2001
Location: Fukuoka, Japan
From the comments, if the fx are not too big, since there will be some remaining space in the driver bank, maybe I should but them there at the same time.


Top
 Profile  
 
PostPosted: Sat Aug 25, 2018 8:46 am 
Offline
Formerly WheelInventor

Joined: Thu Apr 14, 2016 2:55 am
Posts: 1782
Location: Gothenburg, Sweden
Sounds like a good plan. I suppose you're planning to use a lot of the same sfx across multiple portions of the game? It makes sense.

_________________
http://www.frankengraphics.com - personal NES blog


Top
 Profile  
 
PostPosted: Sat Aug 25, 2018 7:29 pm 
Offline
User avatar

Joined: Tue Jun 24, 2008 8:38 pm
Posts: 2001
Location: Fukuoka, Japan
It will depends of the game made. For now, my engine is based on my old files which was a mega man based game and it should mostly be using the same fx in all stages. So hopefully the fx content will not be too big (didn't check yet ^^;;;).

Using an existing game to build the foundation of my engine is really saving me a lot of time that I don't have. I'm grateful too of using tools from the community to converting assets without having to work too much on the UI part. If I had to focus on fleshing out a new game and building an engine when you can sometime work only a few minutes on it, it would go nowhere. Hopefully, the resulting engine will be flexible enough but once I have an engine working it should be possible to adapt to the game I had in mind since I wanted to make an action platformer game anyway.


Top
 Profile  
 
PostPosted: Sat Aug 25, 2018 11:40 pm 
Offline
User avatar

Joined: Fri Feb 27, 2009 2:35 pm
Posts: 294
Location: Fort Wayne, Indiana
FrankenGraphics wrote:
I'd consider this a last resort, but some games place a copy of the driver in several banks to avoid bank switching. Metroid keeps a couple of songs and a copy of its driver in each level bank

I feel like that's more an artifact of being an FDS port than anything else, just making a "snapshot" of the driver combined with each level's song and picking one of the snapshots, since it can't combine them in realtime.

tepples wrote:
Nova the Squirrel uses MMC1 (or, with a compile time switch, UNROM + SRAM) and Pently 5. The vast majority of the soundtrack fits in one 16K bank that gets switched into $8000-$BFFF. I seem to remember that a couple tunes in cutscenes or wherever use a different driver, and one of the hidden minigames (DABG) uses a copy of Pently 3.

Yeah, the entire game's soundtrack (8 songs and 5 level select loops, plus all the sound effects) fits into that bank alongside Pently (sans the period tables). True to its purpose, Pently seems to be really good at keeping the music size small too, and it might be feasible to keep even a large game's soundtrack in 16KB.

The other engine was only used in the sound test for bonus songs, and was just because Famitone 2 was built for noise instruments played at different pitches, which Pently isn't good at.


Top
 Profile  
 
PostPosted: Sun Aug 26, 2018 1:16 am 
Offline

Joined: Mon May 27, 2013 9:40 am
Posts: 494
In my UNROM template for neslib+famitone2, famitone itself resides on the fixed bank but is able to play music from a different bank via a very simple modification, in case you want to check.

_________________
http://www.mojontwins.com


Top
 Profile  
 
PostPosted: Sun Aug 26, 2018 2:41 am 
Online
User avatar

Joined: Sat Aug 15, 2015 3:42 pm
Posts: 147
Location: France
In Twin Dragons I'm using famitracker driver + famitone sfx driver. I have 3 16k banks of music data, and the drivers are in each bank.

The ideal solution would be what rainwarrior said, having the engines in an 8k bank at $C000-DFFF and switch 16k banks of data at $8000-BFFF. I tried that when I was playing with VRC6 mapper, it worked well.

_________________
My first game : Twin Dragons available at Broke Studio.


Top
 Profile  
 
PostPosted: Sun Aug 26, 2018 4:57 am 
Offline
Formerly WheelInventor

Joined: Thu Apr 14, 2016 2:55 am
Posts: 1782
Location: Gothenburg, Sweden
NovaSquirrel wrote:
I feel like that's more an artifact of being an FDS port than anything else


Oh, that makes a lot of sense. I completely forgot about some games being originally written for the FDS. Also, the "riddle music" is instanced across every level bank (except tourian, which iirc has the escape music there instead).

_________________
http://www.frankengraphics.com - personal NES blog


Top
 Profile  
 
PostPosted: Sun Aug 26, 2018 5:37 am 
Offline
User avatar

Joined: Tue Jun 24, 2008 8:38 pm
Posts: 2001
Location: Fukuoka, Japan
glutock wrote:
In Twin Dragons I'm using famitracker driver + famitone sfx driver. I have 3 16k banks of music data, and the drivers are in each bank.

The ideal solution would be what rainwarrior said, having the engines in an 8k bank at $C000-DFFF and switch 16k banks of data at $8000-BFFF. I tried that when I was playing with VRC6 mapper, it worked well.


After reading everyone comments my idea would be to put the engine in 1 bank with fx and the songs in another 8k bank. I usually save the songs one by one so it's quite easy to limit to a few in 1 bank. I didn't check how much I would save if I put many together but the latest famitracker seems to optimize when instruments are not used (it just drop them).

For now space is not my main priority. I may try to optimize later, once the game engine actually works ^^;; I ported my code back to mmc3 and it loaded the bank at the location I expected.

Thanks everyone for the comment, I have many ideas to try.


Top
 Profile  
 
PostPosted: Sun Aug 26, 2018 1:29 pm 
Offline
User avatar

Joined: Sat Sep 07, 2013 2:59 pm
Posts: 1708
Here is my suggestion:

FamiTone into the fixed bank. Music and sound effects into other banks.

As long as music and sound effects are all in the same bank, it's no problem: Just switch to the corresponding bank before you call any FamiTone function that accesses a song or sound effect.

As soon as you need more than one bank for music and sound effects, you need to alter the FamiTone library itself in one single place.

In the function FamiToneUpdate, find this code:
Code:
.if(FT_SFX_ENABLE)

   ;process all sound effect streams

   .if FT_SFX_STREAMS>0
   ldx #FT_SFX_CH0
   jsr _FT2SfxUpdate
   .endif
   .if FT_SFX_STREAMS>1
   ldx #FT_SFX_CH1
   jsr _FT2SfxUpdate
   .endif
   .if FT_SFX_STREAMS>2
   ldx #FT_SFX_CH2
   jsr _FT2SfxUpdate
   .endif
   .if FT_SFX_STREAMS>3
   ldx #FT_SFX_CH3
   jsr _FT2SfxUpdate
   .endif

Before the comment, include code to switch to the sound effects bank. (Assuming that all your sound effects fit into one bank.)

This way, it works as intended:
Before you call FamiToneMusicPlay or FamiToneUpdate, you set the corresponding music bank.
Before you call FamiToneSfxPlay, you set the sound effects bank.

And switching from music bank to effects bank in FamiToneUpdate is done due to the lib's code change.

_________________
Available now: My game "City Trouble".
Website: https://megacatstudios.com/products/city-trouble
Trailer: https://youtu.be/IYXpP59qSxA
Gameplay: https://youtu.be/Eee0yurkIW4
German Retro Gamer article: http://i67.tinypic.com/345o108.jpg


Top
 Profile  
 
PostPosted: Mon Aug 27, 2018 12:34 pm 
Offline
User avatar

Joined: Sun Nov 09, 2008 9:18 pm
Posts: 1107
Location: Pennsylvania, USA
I'm using MMC3 right now and it quite frankly feels like I died and went to heaven. 8kb bankswitching makes it easy to keep the sound engine, envelopes and sfx in one 8kb bank and then swap out music in the other 8kb bank. Don't know how I managed previously, haha. I had a smaller soundtrack before, everything fit in one 16kb bank including the music engine.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 2 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:  
cron
Powered by phpBB® Forum Software © phpBB Group