Aladdin in Nasira's Revenge (PC) - .ASF by Nicknine at 8:56 PM EDT on June 2, 2018
The game stores music in ASF files which appear to have unknown encoding although they do have a header. I assume the audio is 22050 Hz mono like in PS1 version. There's also a codec module called asfcodec.adl in the executable directory if it's any help.

Sample:
agra_1.asf

Codec file:
asfcodec.adl

edited 9:05 PM EDT June 2, 2018
by Nicknine at 9:27 PM EDT on June 2, 2018
Found this old thread. kode54 commented that it seems like modified Microsoft ADPCM. Must be a custom codec made by Argonaut Games. Some guy posted a decoder but without the source code.

edited 10:54 AM EDT June 3, 2018
by Nicknine at 6:11 PM EDT on June 3, 2018
The decoder produces PCM audio that is heavily distorted. Either I'm doing something wrong or the format has been changed since Croc 2.
by Nicknine at 2:47 AM EDT on June 25, 2018
Bump. Has anybody looked into this? I've decompiled the codec module and it doesn't look complicated so I think it's possible to reverse it.

edited 2:47 AM EDT June 25, 2018
by bnnm at 5:10 PM EDT on June 25, 2018
I tried before but assembly is not my thing. I saw a bunch of functions doing (seemingly) ADPCM nibble decoding, but I wasn't familiar with the algorithm (some stuff looked vaguely inpired by PS-ADPCM?).

If somebody properly describes it I could implement.
by bnnm at 7:03 PM EDT on July 17, 2018
I added this, output is roughly the same as croc2asf2raw, but I don't think decoding is 100% correct.

Here what I thought were the decoding functions in asfcodec.adl: https://pastebin.com/ni9H0j8y

Trying to decode like that didn't work, but I'm not sure about the meaning of some parts.
by Nicknine at 8:16 PM EDT on July 18, 2018
IDA Pro can produce pseudo-code from assembly, perhaps that can help?
by bnnm at 2:30 PM EDT on July 21, 2018
Hmmm, somehow can't find the option. I'm using "IDA Pro Free" (7.0?). I'll see if I can procure something better, or could you post the pseudo-code?
(decoding functions are the 4 long-ish subroutines just before the entry point/DLL main, I think).
by Nisto at 2:37 PM EDT on July 21, 2018
@bnnm: Pretty sure the free version doesn't ship with any decompilers, so look for a copy of IDA Pro.
by Nicknine at 12:43 AM EDT on July 22, 2018
@bnnm - Here you go:

Decompiled asfcodec.adl

edited 12:43 AM EDT July 22, 2018
by bnnm at 1:58 PM EDT on July 23, 2018
Thanks, still can't get it right. I think I'm misunderstanding something about signed/unsignedness and carry stuff (add vs adc).
Oh well, if I level up I'll try again.
by kode54 at 9:51 PM EDT on July 23, 2018
Never mind, I found that the full set is already uploaded to joshw.info. I'll grab that and investigate.

edited 9:52 PM EDT July 23, 2018

Okay, try that change I made to the ASF decoder.

edited 10:28 PM EDT July 23, 2018
by Nicknine at 10:04 PM EDT on July 23, 2018
Funny that someone uploaded the files like a year ago even though no decoder was available at the time.
by bnnm at 2:28 PM EDT on July 24, 2018
@kode54 - thanks, I think it's correct. My test files give byte-identical results though, I was expecting rounding diffs and stuff. I guess the math is basically equivalent. Not sure why I was getting it wrong (thought I tried what you wrote).
Also you added "carry" but didn't get used?

Games in joswh using this codec: Croc 2, The Emperor's New Groove, Aladdin in Nasira's Revenge (Croc 1 isn't)
Other Argonaut PC games that could use it: Bionicle: The Game, I-Ninja, Catwoman: The Game.

***

Gave another try and I think I understand it properly now and what we have is indeed byte-accurate: https://pastebin.com/eC1qwNTj
(I'll do a minor tweak later)

The only thing I wonder is about the carry flag (add then adc) but I don't think it's needed with C int32? (since max values are limited)
by Nicknine at 3:15 PM EDT on July 24, 2018
I'm still getting slight crackling in the sound which is not heard in the original PS1 music files. Do these ASF files sound like that in-game as well?

EDIT:
I ran the game and all the music plays with clicking, must be a bug on modern systems... How do you determine decoding is byte accurate?

edited 3:31 PM EDT July 24, 2018
by bnnm at 4:20 PM EDT on July 24, 2018
I've never played the games but I can tell you the codec is worse than the PS1 one, so I wouldn't be surprised. Dunno why didn't just reuse the same, it's basically very similar but simplified in dumb ways.

It's byte accurate in that frames decode like asfcodec does (IOW the pastebin I posted). It's possible they apply a filter after decoding, but I don't think I saw anything like that in asfcodec.adl. You sure it should sound cleaner?

***

BTW, one detail not sure people get is that after decoding, games may upsample and/or filter the output.
For example PS1 XA is saved in 37khz but is upsampled+filtered to 44khz (which may not even properly emulated elsewhere), or in PC games the sound card may do internal resampling who knows how.

vgmstream doesn't/can't simulate those behaviours and just outputs the raw sample rate, so it's less accurate than the real thing.
by Nicknine at 4:36 PM EDT on July 24, 2018
Yeah, I remember that games might re-sample the sound, this might be the case here.
Like I said, I can't check if it sounds like this in-game or not ATM cause the music seems to be screwed up on modern systems. I'll check it on my Win98 box when I get the chance.
I wish I could remember how it sounded from experience but the last time I played the PC version was way back in 2006. %)

By the way, it's even more baffling that they used a custom codec for music considering that all the sound effects and speech are still in PS-ADCPM in PC version.

edited 4:43 PM EDT July 24, 2018
by Infomaniac95 at 7:04 PM EDT on July 24, 2018
Im glad some work on the ASF format is being done, cause other games by argonaut, like emperor's new groove also use the same sound format.
by Nicknine at 4:39 PM EDT on July 25, 2018
Well, I ran the game on an authentic Win98 machine and the music sounds about the same as when decoded with vgmstream. I guess this ASF codec really is worse than PS-ADPCM.

edited 4:39 PM EDT July 25, 2018
by kode54 at 8:40 PM EDT on July 26, 2018
More likely their encoder sucks. Also notice how the frequencies that are crackling are high frequencies, but the audio is 22050Hz. Maybe they clipped in downsampling?
by bnnm at 11:59 AM EDT on July 27, 2018
Now that I'm getting the hang of IDA here is another crappy codec I added: Konami XMD (Xbox)

This also seems inspired by XA/PS-ADPCM, only one filter but resets ADPCM output every few samples (potentially better sound?). Guess somebody was bored, since Xbox had a bunch of standard codecs.

I didn't have IDA Pro at hand to decompile the .xbe so it's based on xmddecode.dll from some russian Silent Hill tools.


Go to Page 0

Search this thread

Show all threads

Reply to this thread:

User Name Tags:

bold: [b]bold[/b]
italics: [i]italics[/i]
emphasis: [em]emphasis[/em]
underline: [u]underline[/u]
small: [small]small[/small]
Link: [url=http://www.google.com]Link[/url]

[img=https://www.hcs64.com/images/mm1.png]
Password
Subject
Message

HCS Forum Index
Halley's Comet Software
forum source