Category Archives: General

Rant From The Past: Linux on PowerPC

I dug up this old rant on my hard drive. The way it is formatted I obviously intended to publish it. The file is dated April 28, 2001. Some of you may find it interesting or amusing. More data on this episode is archived at the Yellowdog Linux mailing list. In the end, I solved the problem and got Linux onto a PowerPC machine but it took me 9 days from the start of my journey until the end.

Trying to Install Linux on a PowerPC

All I want to do is run Linux on a PowerPC machine…it’s a good thing I appreciate a challenge…

Continue reading

Parsing GRAF Scripts

I missed out on any kind of compiler theory course during my time in academia. Add that to the list of topics I would like to study and comprehend someday (along with 3D graphics and artificial intelligence).

The MultiEx Commander program uses a simple, custom scripting language to interpret game resource archive formats (a.k.a. GRAFs). Why do I care? Because these GRAF files often carry lots of FMV files that I want to separate and study invidually. This is a script that takes apart the BIFF (.bif) GRAF files from Baldur’s Gate:

IDString 0 BIFFV1 ;
Get DUMMYL Int 0 ;
SavePos FILESTART 0 ;
Get FILECNTL Long 0 ;
Math FILESTART += 16 ;
Do ;
GoTo FILESTART 0 ;
Get FILEOFF Long 0 ;
Get FILESIZE Long 0 ;
Math FILESTART += 16 ;
Log FILENAME FILEOFF FILESIZE 0 0 ;
Math EXTRCNT += 1 ;
While EXTRCNT <> FILECNTL ;

That script was taken from the XentaxWiki entry for BIF. Plenty more sample scripts are available on that Wiki.

Who can tell me the best approach to writing a program that can interpret scripts like the one shown above? Something tells me that full-fledged compiler theory is overkill for this type of application. It looks like the language was designed to be parsed in a fairly braindead virtual machine. But that’s just my best, uneducated guess.

Update: I am working on a BMS language spec in the XentaxWiki.

Sound Blaster Frequency Redux

After hashing it out with Trixter in the comments of the previous post, I have seen the light regarding the Sound Blaster frequency divisor. This should be the correct formula:

  frequency = 1000000 / (256 - sample_rate_divisor)

sample_rate_divisor should be treated as an unsigned quantity (0..255). Thus, as the divisor runs from 0 -> 255, the total divisor will get smaller and the output frequency will be higher. The low end is 3921 Hz and the high end is 1000000 Hz, though frequencies above 45454 Hz (divisor 234/0xEA) are unsupported by the original Sound Blaster DAC hardware.

The reason the other formula appeared to work along with the signed sample rate is that key divisors yielded similar numbers. For example, for actual sample .VOC files I have collected from various games:

Signed divisor formula:

  divisor = -47 (0xD1), frequency = 21532
  divisor = -45 (0xD3), frequency = 22478

Unsigned divisor formula:

  divisor = 209 (0xD1), frequency = 21276
  divisor = 211 (0xD3), frequency = 22222

Pretty close. The unsigned divisor formula yields the trademark “weird” SB frequencies like 22222 Hz. Plus, the unsigned formula is able to accommodate much lower frequencies.

One last point of closure: I always thought the certain weird frequencies common in the early days of PC multimedia such as 11127 Hz and 22254 Hz were artifacts of the original Sound Blaster hardware. It turns out that they were the result of Apple Macintosh hardware. Thanks to Trixter for pointing me to this page on the subject.

Sound Blaster Frequencies

Remember when the original Creative Labs Sound Blaster was released? It was quite revolutionary for PC audio at the time since it was basically a stock AdLib FM synthesizer card and but with an 8-bit, monophonic digital to audio converter (DAC) that could output raw PCM data.


Classic Sound Blaster box

One of the more curious artifacts of the original Sound Blaster is the frequency divisor used to initialize the DAC for PCM playback.

Continue reading