Sunday, November 2, 2014

FMod - Song Success

After finding and crushing some silly off-by-one bugs, Abiathar's Music Mappings dialog loads successfully. I finished coding the buttons that actually do the work of importing IMFs and fixed a bug in the song deletion routine that caused it to sometimes not clean up all the unused ephemeral slots.



There were some problems with saving the imported song name (mojibake), but I fixed that by switching to a UTF-8 encoding and prepending the actual header byte instead of putting it inside the GetBytes call.

I also made the Audio Resources dialog a persistent configuration dialog instead of a set-up wizard. (It can load the existing configuration instead of just wiping it out.) There is now an option to dissociate the audio files from the dependency file.


With those in place, it was time to actually test the mappings. I threw random songs into Keen 4 levels, exported the patches, and it worked! I could successfully choose which song goes into which level. Then I tried adding new songs (exported by KeenWave from Keen 6). That didn't go so well - the patch file seemed to be generated correctly, but I just got silence. I got the same effect when I overwrote existing chunks with the imported songs.

It turns out that KeenWave exports Type 1 IMF files; Abiathar by default expects Type 0. So, it had been importing the files shifted by two bytes, writing (usually) zero to various undefined OPL registers. I changed the default to expect Type 1 files after doing research and determining that the commonly used MIDI to IMF converter also produces Type 1 files.

With that change made, I tested the addition of new songs again. It worked! This makes Abiathar the first program (not just level editor) to automate the process of adding new songs. v2.2 will hopefully be out in a week or so.

No comments:

Post a Comment