Sega Master System / Mark III / Game Gear|
SG-1000 / SC-3000 / SF-7000 / OMV
Home - Forums - Games - Scans - Maps - Cheats - Credits
Music - Videos - Development - Hacks - Translations - Homebrew
Playing Sound SamplesPosted: Mon Apr 14, 2014 12:52 am
Below is the code used to play the "Let's Go" sound sample at the start of each level in the Game Gear version of Lemmings 2. I've attached the output table (1024 bytes) and the sound sample as a RAR file. The code was written for KASM (written by Krysalis Software, in 1992!) so you may need to edit it to work in the assembler of your choice.
SMPRTE DB 0
INSREG: LD C,#80 ;Initialise sound registers
ISR10: LD A,C
LD HL,LETSGO ;Sample data
LD BC,6346 ;Length
LD A,16 ;Rate
PSGS10: LD A,(HL)
PSGS20: DEC E
SAMPTB: INCBIN L2SGSMTB.BIN ; 1024
LETSGO: INCBIN L2LETSGO.SMP ; 6346
Code from twenty years ago, so no guarantees, your mileage may vary, etc. :-)
||Posted: Mon Apr 14, 2014 1:12 am|
|Interesting, it seems somewhat different from how many games do it, possibly for cross platform reasons. The sample data seems to be raw signed 8 bit data, and the lookup table is trying to get some extra resolution out of the 16 volume levels of the PSG by mixing the three channels. This comes at the cost of ROM space, but by the early 90s this was much less of an issue than in the early years of the Master System.|
||Posted: Mon Apr 14, 2014 8:13 am|
That's an interesting approach and sounds quite decent :)
I experimented with sample playback on the PSG a while ago and went to a different route :
I took the logarithmic curve of the PSG volume register into account and with some DC offset shifting I could create 4bit streams that sound pretty naiss.
||Posted: Mon Apr 14, 2014 8:32 am|
The lookup table was reverse engineered by hooking up a voltmeter to the headphone output and measuring the DC level for each combination of channel outputs. While this gave the highest resolution, my lack of sample processing software meant that I couldn't take advantage of it.
Cutting back this back to two channels (with two channels combined at the same level) would have yielded results that saved ROM space and might have been good enough for an 8-bit sample - but that required more time that I had.
||Posted: Mon Apr 14, 2014 8:52 am|
Do you remember if there were any non-linearities like say highest peaks being flattened ?
From my tests that happened in SMS2 and only because of "wrong" choice of a resistor on the audio out pin. MD1/2 and SMS1 has no such issues, GG I have not touched.
||Posted: Mon Apr 14, 2014 12:55 pm|
The lookup table seems a bit odd when I graph it. I guess the voltmeter approach may have taken into account real-system effects which you don't get with pure emulation. It is broadly dealing with the non-linearity, but has resolution issues at the high end.
||Posted: Mon Apr 14, 2014 4:31 pm|
Interesting to see it graphed. :-) Certainly the sample playback sounded much better through the speaker and headphones than in an emulator such as Fusion, but it seems at least comparable with the playback on something like Ecco the Dolphin.