Difference between revisions of "Andlabs/Time Trax"
From Sega Retro
Line 22: | Line 22: | ||
Though the sample buffer is $80 bytes long, the game has two consecutive buffers, switching after one has been played through. Why he doesn't just use one $100-byte-long buffer is beyond me; maybe he wanted it to load to the second buffer while playing back from the first? | Though the sample buffer is $80 bytes long, the game has two consecutive buffers, switching after one has been played through. Why he doesn't just use one $100-byte-long buffer is beyond me; maybe he wanted it to load to the second buffer while playing back from the first? | ||
+ | |||
+ | Unless I am confused, and it is actually using a giant $100-byte buffer, but only loading the upper half...? | ||
===pcm-bug=== | ===pcm-bug=== |
Revision as of 02:12, 14 July 2013
There are only two sound banks.
- $F0000 - PCM samples
- $F8000 - music and SFX
everything fits neatly into its bank
PCM Sample Bank
The top of this bank contains pointer-length pairs for PCM samples. Pointers are relative to the Z80 memory map (so they are bank pointers). Pointers and lengths are big endian (this is NOT how things usually are done!)
Or in other words
- $0 word - first sample pointer BIG ENDIAN
- $2 word - first sample length BIG ENDIAN
- $4 word - second sample pointer BIG ENDIAN
- $6 word - second sample length BIG ENDIAN
- $8 word - third sample pointer BIG ENDIAN
- $A word - third sample length BIG ENDIAN
and so on until the first PCM data byte
PCM Sample Playback
PCM samples are played back through a buffer: the game reads $80 bytes of sample data, then plays back one byte of ample data every so often. Buffer filling is done all at once and in groups of 8 bytes, with another PCM data write after each group of 8 bytes.
Though the sample buffer is $80 bytes long, the game has two consecutive buffers, switching after one has been played through. Why he doesn't just use one $100-byte-long buffer is beyond me; maybe he wanted it to load to the second buffer while playing back from the first?
Unless I am confused, and it is actually using a giant $100-byte buffer, but only loading the upper half...?
pcm-bug
There appears to be a bug in the buffer loading code:
ROM:0B18 ld hl, (PCMSampleLength) ROM:0B1B ld bc, 80h ; 'Ç' ROM:0B1E sbc hl, bc ROM:0B20 jp m, loc_C67 ; stops sample playback ROM:0B23 ld (PCMSampleLength), hl
if I am reading this correctly, the game will stop playing samples if it cannot fill a buffer completely, leaving the tail end of samples unplayed:
00f0000: 8024 166e 9692 048d 9b1f 0a70 a58f 0869 .$.n.......p...i 00f0010: adf8 156f c367 0975 ccdc 0579 d255 2080 ...o.g.u...y.U . 00f0020: f2d5 093b ____ ____ ____ ____ ____ ____ ...;____________
notice how none of those lengths (except one) are aligned