Joined: 19 Mar 2006
|Posted: Wed Aug 01, 2007 11:49 am Post subject: PCE System Card PSG driver and... PC-FX?
|I was browsing through the data track of Ginga Ojousama Densetsu Yuna FX and recognized some familiar looking music data. It appears that its PSG data is somewhat compatible with the PCE-CD System Card PSG driver (I'm guessing the PC-FX bios contains a PSG driver). Besides the obvious difference (32-bit pointers vs 16-bit), it appears that the envelope data is in a different format. Percussion (track mode 1) I am unsure about as well.
So, obviously, I attempted an HES of it (just one track, for fun). I didn't know how to handle the envelope data at all, so I just converted all envelope selects to envelopes internal to the System Card (this will obviously make things sound different). Percussion came out very strange as well (the track I looked at uses mode 1 - percussion of the non-noise variety). Channel 6 stays silent for a long time, and then finally begins playing, sounding way off from the actual game.
Here's a link to the HES: http://h1.ripway.com/kingshriek/yunafx_test.zip
Anyone know anything about the PSG data formats (envelope and percussion data specifically) used by the PC-FX version of the system card PSG driver? It would be really cool to do PC-FX PSG rips in HES format (if it's even possible).
A few PC-FX envelope samples:
|@1: 00 03 00 7C 01 00 00 00 01 00 00 E7 00 00 00 F6
@2: 00 03 00 7C 01 00 00 00 05 00 00 FA 00 00 00 FD
@3: 00 02 00 FA 00 03 00 00 00 03 00 00 00 03 00 68
29 00 80 00 FA 00 00 00 00 00 C0 FF 00 01
@4: 00 02 00 FA 07 04 00 03 00 7C 02 00 00 FF 1C 04
00 03 00 7C 02 00 00 F8 1F 04 00 03 00 78 1E 00
B0 FE 00 00 40 FF 00 01
Not sure what to make of these.
Hmm, looking at the envelope data a bit more (while comparing to PCE envelope data), it would appear the format used is:
nn mm [ll hh]
nn - duration (byte)
mm - mode (byte) (have only seen values between 00 and 04 used)
ll hh - rate (word) (used in modes 0,2,3)
educated guesses on the modes (not really sure on these):
00 decay? (duration varies)
01 end data (always found at end of envelope data; only have seen $00 as duration value; does not take a rate parameter)
02 release? (either appears once or not at all in envelope data; when it does appear, it's found at the beginning; only have seen $00 as duration value)
03 attack? (commonly used rate is $7C00; only have seen $00 as duration value)
04 sustain? (duration varies; does not take a rate parameter)
Well, envelope mode 04 is not a sustain as I originally guessed, it appears to actually modify the channel waveform to the wave data indexed by the value in the 'duration' byte. That is, the PC-FX driver supports mid-envelope timbre changes. I succeeded in hacking the PCE system card to support this.
Also, turns out the bytecodes for the music data are not entirely identical between the two. F6 and F7 behave differently on the PC-FX (on the PCE, these set up rates of change for the volume of the right and left stereo components of the sound respectively). I haven't quite figured out what these do exactly, but F7 is quite interesting. When there are two F7 instructions in a row with the last of these taking 80 as a parameter, it causes the sound to pan back and forth at the rate specified by the first F7. Hacking this into the PCE system card driver may pose quite a challenge.
I went ahead and created another HES, this time adding in the rest of the tracks as well as the envelope hack. I use the following envelope conversions:
PCFX ---> PCE
nn 00 ll hh ---> nn ll hh
nn 01 ---> FF
nn 02 ll hh ---> FB ll hh
nn 03 ll hh ---> FC ll hh
nn 04 ---> FD nn (required some hacking to support)
As for the F6-F7 issue, I just NOP'd out the F7 80 instructions (as this would kill the left stereo channel) and left the others as is, thus the panning is incorrect.
Track $01 gets out of sync very early.
Track $06 stops abruptly.
Anyway, here's the updated HES: http://h1.ripway.com/kingshriek/GingaOjousamaDensetsuYunaFX_experimental.zip