Hello,
I'm currently trying to integrate the FamiStudio Engine to a Castlevania 3 (US) ROM, with the goal of replacing the sound engine completely. It uses the MMC5 variant, 4 original channels, plus 2 extras, with a few options like tempo control, arpeggios, DPCM, etc. The engine itself weights AF7 bytes. Right now, I have the entire engine copied to SRAM to make bank switching easier.
Because song data is so massive, we have to use multiple banks to store everything. The problem that came up is, how is it possible to juggle between different banks for songs, SFX and DPCM, with a single update routine? If a SFX needs to fetch more data, then a specific bank must be loaded into $8000-BFFF at that specific moment in code, but if it's about a song playing, then it's another bank.
Did I paint myself in a corner? Is there any way to solve that puzzle, short of modifying the engine code itself?
Any insight is appreciated...
FamiStudio Engine Integration to CV3
Moderator: Moderators
Re: FamiStudio Engine Integration to CV3
I took a look at the source (at least the copy I have locally, possibly outdated). You do need to modify the engine, but not but by much, I think. There's a part of the code that does 'jsr famistudio_sfx_update' 4 times. If you select the sfx bank before that point, then return to the music bank after (if needed, I didn't fully trace it out), hopefully that would be enough.
Then you probably need to select the SFX bank before calling famistudio_sfx_play, famistudio_sfx_init. That doesn't need to be an engine modification, but could be.
However, I'm not totally certain that somewhere in the code it doesn't assume the sfx and music is in the same bank, which could need further bank changes. edit: It kind of looks like the main pointer for sfx and music data is the same pointer? Though it seems to refer to them as being separate streams. I dunno.
DPCM on the other hand, is a whole other issue I didn't look at. DPCM bankswitching opportunities are somewhat limited in the best circumstances, probably moreso when modifying an existing game. The bank with the current DPCM sample just has to remain swapped in any time the sample is playing - no exceptions. This effectively turns this whole bank address space into being 100% dedicated to DPCM. Going beyond the DPCM memory that the game already has reserved for it is probably going to be difficult.
Then you probably need to select the SFX bank before calling famistudio_sfx_play, famistudio_sfx_init. That doesn't need to be an engine modification, but could be.
However, I'm not totally certain that somewhere in the code it doesn't assume the sfx and music is in the same bank, which could need further bank changes. edit: It kind of looks like the main pointer for sfx and music data is the same pointer? Though it seems to refer to them as being separate streams. I dunno.
DPCM on the other hand, is a whole other issue I didn't look at. DPCM bankswitching opportunities are somewhat limited in the best circumstances, probably moreso when modifying an existing game. The bank with the current DPCM sample just has to remain swapped in any time the sample is playing - no exceptions. This effectively turns this whole bank address space into being 100% dedicated to DPCM. Going beyond the DPCM memory that the game already has reserved for it is probably going to be difficult.
Re: FamiStudio Engine Integration to CV3
Alright, thanks for the reply. That sounds logical, switch bank before music data is being processed as needed, then switch, if needed, to another bank for SFX. As for DPCM, the engine already has a callback function included, so I'll use that.