Oldskool demo fixing

While I was doing the oldskool PC stuff, the demo Crystal Dream by Triton was one of my inspirations:

It’s one of the first demos ever to have smooth polygons on PC, and great mod-based music.
It uses the same EGA trickery that I developed.

However, when I tried to run it on my 486DX2-80, I couldn’t get the Sound Blaster to work. I have an original Sound Blaster Pro 2, and neither SB nor SB Pro worked properly. Only internal speaker worked, which sounds horrible.
That’s odd, because I recall the music well. But I had a 386SX-16 at the time (with the same SB Pro card). So I turned off the turbo on my 486, and found that the SB gets detected properly in that case. You just can’t fully enjoy the demo, because the system is too slow that way.

So I figured there must be some kind of timing bug or such in the SB code. So I put it on my todo-list to find and fix the bug.
I made a start with it a while ago, but it turned out to be more difficult than just putting a bigger value in a loop counter somewhere. And I did not know anything about programming the SB anyway. I didn’t have the time, so I left it for now, but kept it on the todo-list for later.

Yesterday and today, I had some more time to look into it, and I finally managed to pinpoint the issue, and patch up the actual code.
It now works flawlessly on my 486DX2-80 in both SB and SB Pro mode: https://www.dropbox.com/s/df1h2w2zapo2kpv/crystfix.zip?dl=0

It still does not work properly in Dosbox though, but I think that is related to the way it uses DMA. It also won’t run properly under Windows 95, only from pure DOS. It might be because it does not reset the PIC timer rate to the default value… But I don’t know if and when I’ll ever look into that.

Oh, and no, obviously I don’t have the source code for this demo. I just did it the oldskool way: unpack the executables, disassemble, find the offending code, and patch the fixed code in there. Open Source? Pah, the open source community is a bunch of quiche eaters. You don’t need the source code to fix things. You think I had the source code for Endless City too?

This entry was posted in Oldskool/retro programming, Software development and tagged , , , , , , , , , , , , , , , , , , , . Bookmark the permalink.

6 Responses to Oldskool demo fixing

  1. Pingback: Triton’s Crystal Dream restored and preserved for posterity | Scali's blog

  2. Pingback: Random thoughts on programming, culture and such | Scali's OpenBlog™

  3. Pingback: Triton’s Crystal Dream – the final chapter | Scali's OpenBlog™

  4. Vallenrod says:

    Good effort, on my PIII 500 with SB AWE32 CT3900 demo starts and plays sound for a second and then cuts off. Interestingly it does that at each section so it suggests that the playback routine is faulty.
    Previously it wouldn’t even run unless I used moslo /5 crystal.exe.
    However that does not fix the audio issue because the actual demo is in dream.dat which is then executed by crystal.exe after audio setup.
    Rename dream.dat to dream.exe and run it with parameter:
    “dream.exe 00003E8000040220” it should start at the last section just before end scroll.


    • Scali says:

      The demo is written for the original Sound Blaster.
      Only the SB 1.0, 1.5, 2.0 and SB Pro 1.0 and 2.0 are fully compatible.
      The SB16 and newer cards have issues in the implementation of the legacy commands. See also here: http://nerdlypleasures.blogspot.nl/2015/05/16-bit-sound-blaster-8-bit-playback.html

      Given the trickery that Crystal Dream uses (restarting the DSP playback before the interrupt fires, and never handling an interrupt, even if it would fire), I wouldn’t be surprised if SB16/AWE cards don’t work.
      Modifying the code to use a newer DSP command for continuous playback may make it work. Some cards may still require the interrupts to be acknowledged though, in which case an interrupt handler would need to be added to the code as well.
      It would also break compatibility with anything older than a Sound Blaster 2.0.
      See this blog for more background info on the limitations of early SB cards: https://scalibq.wordpress.com/2017/03/12/dma-activation/

      • Vallenrod says:

        It makes sense, and I will have a read with pleasure. Btw I love the blog, I’m surprised I have coma across it so late.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s