Todd Replogle Extractor by Frenkel Smeijers, 2001.

This program extracts files from Todd Replogle game files. It works for
the following files: cosmo1.vol \
                     cosmo2.vol  \
                     cosmo3.vol   \
                     cosmo1.stn   /   Cosmo's Cosmic Adventure
                     cosmo2.stn  /
                     cosmo3.stn /
                     nukem2.cmp       Duke Nukem II
                     volume1a.ms1 \
                     volume1b.ms1  \
                     volume2a.ms2   \
                     volume2b.ms2   / Major Stryker
                     volume3a.ms3  /
                     volume3b.ms3 /

I know the format of the Sounds.mni, Sounds2.mni and Sounds3.mni
files of Cosmo and the Drsound.snd and Drsound2.snd from Major Stryker.
The format is very similar to the format of the sound file of Commander
Keen 1, Duke Nukum, The Catacomb, Dangerous Dave, Hovertank, Paragon, 
Rescue Rover and Slordax. I found the following information on the
Commander Keen 1-3 for Unix Port/Clone Project Page which you can find
on http://durdin.net/andy/keen/Gavare


Sound file format
This is probably not 100% correct, it was found by trial-and-error kind
of research. In Keen 1, the sound data is stored in SOUNDS.CK1, but in
Keen 2 and 3 the data is stored directly in the main executable. 

Offset: Len: Description: 
 0x00    3   "SND" 
 0x03    1   0x00 
 0x04    2   total file length 
 0x06    2   nr_of_sounds (0x3f in Keen 1) 
 0x08    2   (unknown) 
 0x0a    6   0x00 0x00 0x00 0x00 0x00 0x00 
 0x10   16   header for sound #1 
 0x20   16   header for sound #2 
 ..      2   .. 
 0x400   2   data for sound #1 begins here... (Keen 1) 

There is one "header" for each sound (#1, #2, ..) which has the
following format: 

Offset: Len: Description: 
+ 0x00   2   file offset to sound data 
+ 0x02   1   priority, 0xff means guaranteed foreground play 
+ 0x03   1   (unknown, 8 if sound exists, 1 if non-existant???) 
+ 0x04  12   name, padded with zeroes if neccessary 

Sound data is given as a number of 2-byte Intel words. A word of 0xffff
ends the sound. A 0x0000 means quiet. All other values are inverted
frequency data. A simple test shows that approx 1000000/value sounds 
almost like the sounds in the game. The 1000000 could be 1193180 (the 
PC's timer base value) or something else. I'm not sure. The duration of
each sound data sample is probably around 1/128 of a second. 

Whenever the sound playing function is called, the priority of the new
sample is compared to the sample which is currently playing (if any).
If the priority of the new sample is higher than or equal to the 
priority of the currently playing sample, then we switch to playing the
new one, otherwise we do nothing (which means that the old sample 
continues). 

Here's a quick hack which extracts the audio and saves it as 16-bit PCM
samples: 

File:         Description: 
sounds2raw.c  C source code to extract sounds from SOUNDS.CK1 

http://durdin.net/andy/keen/Gavare/files/sounds2raw.c

I wrote a program that displays Title1.mni from Cosmo and other files 
that are 32 kb, but that program isn't ready for distribution.
I also wrote a program that plays the PC speaker sound fx files
(Sound.mni, Sound2.mni ...) but that program is also not ready for 
distribution.
Cosmo1.mni, Nomemory.mni from Cosmo and other files that are 4000 
bytes are the end screens. These files can be edited using a end 
screen editor like TED DOOM ENDOOM Data Editor (No, that is not TED5,
Tile Editor from Id software which is used on games like Commander
Keen, Catacomb 3-D, Dangerous Dave, Hovertank, Paragon, Rescue Rover,
Slordax, Wolfenstein 3-D and Rise of the Triad) by Peter Monks
pmonks@socs.uts.edu.au (I don't know if this e-mailadress still works,
the textfile that came with TED said May 1994.)

Thanks go to:
Apogee and     for creating great games. http://www.apogee1.com
Todd Replogle  

Lon Matero     for his great Apogee page, 
               http://members.home.net/lmatero 
               He gave me the idea for creating a extractor for Cosmo's
               Cosmic Adventure. After finishing that program, I found
               out it worked for other games too.

unknown        someone mailed Lon Matero and gave him the real format
               for the Cosmo files.

The format of the grouped files is
Offset: Len: Description: 
 0x00   12   Filename
 0x0C    4   offset to the file
 0x10    4   length of the file

Frenkel Smeijers
frenkel_smeijers@hotmail.com
http://www.student.tue.nl/u/a.f.smeijers/sfp