There have been at least several posts about how to get music from CD-i games (either because it's awesome, nostalgic, or just because).
I know there's a tool or two that can do exactly that, but I've found them lacking the ability to rip ALL audio.
In many cases the sound effects are not found.
So... time to take matters into my own hands!
With the availability of the Green Book, there's plenty of information to start from.
I'll be referencing this book a lot, for those who want to help out, want detailed info, or just check if I've correctly interpreted the info.
The format will be [chapter].[sections] or [chapter].[sections].F[figure number].
The example I'm using is shown using a hex editor with character set 'DOS/IBM-ASCII' as it has the most diverse char set (compared to 'ANSI', 'Macintosh', 'EBCDIC') and is purely for visual aid.
Reading a single (audio) sector
Data is stored in sectors on the disc, each can be used for various purposes, but they're generally in the following format:
General sector format as detailed in II.4.1.1
With the header as:
II.4.4.F11
Mode=2 must be used for CD-i tracks
And the subheader as:
II.4.5.1.F12. The coding information is described in IV.3.2.4)
The values between '[]' are when the bit or bits have the value [0,1] or [00,01,10,11] respectively.
So 'Bits/sample [4/8/R/R]' makes:
Code: Select all
00 -> 4
01 -> 8
10 -> Reserved
11 -> Reserved
The subheader is present twice for data-integrity reasons.
II.4.5.2 describes in detail the definition of values in the subheader.
The submode has a requirement for audio sectors (defined in IV.3.2.3.F3]).
With the combined information in IV.3.1 and IV.3.3, the data block can be formatted as follows:
Audio block format
Each sound groups is formatted as follows as described in IV.3.4.F6:
Sound group format
From here on out, things get too small to show in figures.
A sound parameter block (16 bytes) holds 16 sound parameters of 1 byte each.
A single sound parameter consists of a Range and Filter value of 4 bits each in the following format:
Code: Select all
msb FFFFRRRR lsb
Code: Select all
Sound parameter: 01011100
F: 0101
R: 1100
Code: Select all
0 .. 11 : sync
12 : header -> Minutes
13 : header -> Seconds
14 : header -> Sectors
15 : header -> Mode
16 : subheader -> fileNr
17 : subheader -> channelNr
18.0 : subheader -> submode -> End of File
18.1 : subheader -> submode -> Real-Time
18.2 : subheader -> submode -> Form
18.3 : subheader -> submode -> Trigger
18.4 : subheader -> submode -> Data
18.5 : subheader -> submode -> Audio
18.6 : subheader -> submode -> Video
18.7 : subheader -> submode -> End of Record
19.0 : subheader -> codingData -> zero
19.1 : subheader -> codingData -> emphasis
19.2 .. 19.3 : subheader -> codingData -> bitsPerSample
19.4 .. 19.5 : subheader -> codingData -> sampleFrequency
19.6 .. 19.7 : subheader -> codingData -> monoStereo
20 .. 23 : subheader repeated
24.0 .. 24.3 : dataBlock -> Sound group 0 -> Sound parameter 0 -> F
24.4 .. 24.7 : dataBlock -> Sound group 0 -> Sound parameter 0 -> R
25 .. 39 : dataBlock -> Sound group 0 -> Sound parameter 1..15
40 .. 151 : dataBlock -> Sound group 0 -> Sample audio
152 .. 2327 : dataBlock -> Sound group 1..17
2328 .. 2347 : dataBlock -> Padding
2348 .. 2351 : dataBlock -> Quality control
More to come as I work through my code to write more documentation (if one can call it that).