8BitChip Forum

Atari => Software => Topic started by: Petari on 22-02-2017, 19:10:15

Title: Prince of Persia with improved sound
Post by: Petari on 22-02-2017, 19:10:15
http://atari.8bitchip.info/SCRSH/princofps.html
Floppy v. :   http://atari.8bitchip.info/ASTGA/P/princofp.php

Some people may be interested about how to replace sound playback in Atari ST games to STE DMA system, like in this case, or in Dungeon Master.
It was pretty much different, although playback code self is almost 100%. First thing is to get quality samples somewhere, somehow. In case of DM there is lot of it available, so quality effect samples too. Also SW for extracting all elementary files - with what I could extract all samples of ST version with descriptive file names. ST version uses 21 samples for effects, while PC version 35. So, needed to listen all it and take proper 21. Then convert them to STE DMAA compatible format. Original ST samples are very compact, all together 17KB. Converted ones 112KB - at relative low samplerate of 12500 Hz. That means of course that RAM requirement is min 1MB - no space for extra 90KB in 512KB. But that is certainly not problem - most of STEs have so much at least. Finding playback code and replacing with DMA one was not hard in case of DM. Then needed to find proper RAM area for samples, code, tables, and that was basically all what I needed to do.  Chaos Strikes Back uses same samples as DM, so it was really not big work to solve it too.
Prince of Persia was harder, mostly because there was music playback too, + I needed to fix some bugs in it's code, which I encountered during tests.
But I dealt already with it some years ago, when disassembled it completely and made some fixes for working on higher TOS versions, Falcon.  That was big help for audio mod. Much less sources for POP than DM online. I just did not see enough good music files. Samples were not separated, so I would need lot of time to extract all from unknown structures.  Fortunately, what was in ST version was good enough quality for STE playback - samplerate was 7680 Hz - pretty high for YM sample playback (that's why game slows a lot during sound effects). So, I only converted them to 12517 Hz STE format, recalculated some tables, replaced playback code, and effects worked like charm. With music was harder, because it was mixed sample and YM generated playback, and there is lot of it - 18 tunes, some with longer duration of some 30 secs. Replacing all it with DMA samples would need lot of RAM or direct hard disk read by playback. Later may be done one day - if I find some really good music. I ripped 4 shorter tunes only from Android v. POP Classic - and that takes some 110KB. So, there is much less music than in ST original, but what matters is gameplay. And all that fits in 1MB. 
I don't think that there is some rule how to do it. Each game is different coded, samples have diverse formats, sources are different ... So all it is: examine, think, look around, acquire, convert, trace, test ....
Title: Re: Prince of Persia with improved sound
Post by: ataricrypt on 23-02-2017, 00:27:38
Absolutely. Amazing. Great work mate. Thank you :-)