Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Emulating DS4QB2
#1
You might need to be a certain age to appreciate this, but I made a "driver" for emulating old QB games that use DS4QB2 for sound in the V86 PC emulator. Behold, no one has heard these sounds in 20 years!

Some tests: Some that almost work but not quite
  • Super Sumo Wrestling - gets to the menu screen and plays music, but hangs
  • Zeta (B2) - (game from the library author. Gets to the production logo and hangs before playing anything)

Long story: 
DS4QB was a family of audio libraries for QB. Instead of using a sound blaster driver, they used an I/O port to signal a Win32 host application that played sounds using LibBASS. This ended up being a cursed solution - when Windows XP rolled around with its Hardware Abstraction Layer, both DOS and Win32 applications lost direct access to I/O and the games stopped working. And since it used this hacky mechanism, DOS emulators never supported it, unless you make a VM and install Windows 9x on it.

How I got this working:
V86 is a lovely, very hackable javascript X86 emulator. So I wanted to see if I could run DOS in the emulator and talk to games using one of the DS4QB protocol, but from Javascript code. I picked DS4QB2 because it had a lot of games using it, and it's easier to emulate than the original.

DS4QB2 communicated with its host (a Visual Basic program) like this:
  • Client writes parameters to a file called DS4QB2.DAT
  • Client sets I/O port 0 (DMA) to a value to indicate the function
  • Host polls port 0 and responds when the value is non-zero
  • Host reads parameters from DS4QB2.DAT and calls an audio function
  • Host clears port 0
  • Guest polls port 0 and resume executing

V86 has an API to read I/O ports, so I polled it every 50ms and did a little dance when I saw port 0 flip from 0 to 3 ("Load SFX").

But V86 doesn't have any APIs to share files with DOS guests. Luckily though, If you put the contents of your FAT image into an ArrayBuffer and provide that instead of a URL to V86 for the hard disk, it will read and write blocks directly to that ArrayBuffer. So, using a FAT library I ported to webassembly, I mounted, read DS4QB2.DAT, and unmounted the ArrayBuffer right after the port when high.

With the decoded signal and parameters, I used howler.js to play sounds and MP3s. MOD/IT/S3M/XM don't have browser support, so I used a library called chiptune3.js to play those.

I also added a few other nice-to-haves:
  • Automatically extract ZIP files into a FAT image
  • Code to open AUTOEXEC.BAT and add a game's EXE, the mouse driver, or EMS Magic.

What's Left:
DS4QB++ shouldn't be too bad to support since it had a Win9X mode that worked similarly to DS4QB2

The original DS4QB, however, used a clipboard interrupt that Windows 3.1 and 9x added for transferring parameters. Supporting this will require writing a TSR to mimic the original interrupts and write memory addresses to I/O ports instead of whatever black magic Windows used to access the clipboard.

I need to package the source code and make it available. In the meantime, if anyone has any old hard drives with forgotten DS4QB2 games, let me know!
Reply
#2
Hi @jofers!   Now there’s a name I know from the QB glory days.  Really good to see you’re still around.

I recall that project, and it’s possible I saved some of those games on a hard drive somewhere.  Plasma is still around, perhaps he may have them somewhere. I’ll dig through my QB code hard drives….

- Dav

Find my programs here in Dav's QB64 Corner
Reply
#3
Wow! @jofers Is is a third way to run QB64 code over the browser? (I am thinking BAM and QBJS as 2, maybe there was another through ports?)

Welcome
b = b + ...
Reply
#4
@Dav - I knew I'd find some familiar faces here! How have you been?

@bplus -  I wish it were, but this project is merely to emulate audio for DOS EXEs made with the original QuickBASIC and a specific audio library. DOS emulators that run QBasic have been around for awhile though!
Reply
#5
I remember you from the QBasic Forum.

Wow, you're still living in the past. Next trip back, take me with you!!!! Big Grin 

Pete

- Wondering if fallen angles also have that Democrat mantra. "We won't go back!"?
Reply




Users browsing this thread: 1 Guest(s)