The other day on Shmups Forum, BPzeBanshee bumped a thread requesting information on G-Stream G2020. So after playing a bit, I thought maybe it’d be a good idea to fix the sound. Later BPzeBanshee popped up in the #shmups IRC and asked if I was going to fix the sound. I was hesitant, but the fairly decent amount of sound errors made me want to go in and fix it. I spent a couple hours reverse-engineering the code that generated the banking data, but that didn’t really get me anywhere. So then I tried to modify the old code that was being used to bank. This also didn’t get me much of anywhere.
Then I wrote up a small program that converts raw OKI sound data to PCM data (for analysis in another tool, such as Audacity). Once I converted all the ROMs to PCM, I could actually figure out what banks had what data in them. From here I added some debug prints that would show the value being written to the banking register. After a bit of analysis, I came to the conclusion that the values weren’t meant to be interpreted at much larger than single bits. It was about here that I moved the latter two sound ROMs from the first OKI to the second (thus separating the two). I did this because in my analysis, I noticed that the sound-effect bank was duplicated in the first ROM and the 3rd ROM. After that, I decided to deconstruct the banking value into binary, and I started to notice a pattern. Soon I figured out how the values corresponded to the banks.
In the end, the final algorithm I came up with was:
OKI1_bank = ((BIT(data, 6) & !BIT(data, 7)) << 1) | (BIT(data, 2) & BIT(data, 3)); OKI2_bank = ((BIT(data, 4) & !BIT(data, 5)) << 1) | (BIT(data, 0) & BIT(data, 1));
A bit messy, yes, but it has worked for every banking value that the game has thrown at it. If I ever get access to a PCB, I may try to test this algorithm with other values and refine it further.
Download link for the patch (should apply to any recent MAME version, but 146u5 does not work): http://daifukkat.su/files/gstream.diff