Well it mostly works now. But did we ever have the biggest fun with the sound and SVGA.
So [HCI]Mara’akate integrated all the Q1 sound code, got it to compile, but nothing not a peep from the sound card. While I was busy trashing the video code, he spent way too much time on the audio, and then for the heck of it I thought I’d look at the code, although I’m really stabbing in the dark when it comes to audio. Imagine my surprise when I compiled the code, and ran it and got the sound blasting at full volume! It turns out that I had my audio set to ‘high quality’ in the client, while he had his set to ‘low quality’. What it does is govern the frequency between 11Khz and 22Khz. And if you get this wrong you get *NO* audio. OOPS. At least it was one of those feeling vindicated moments that his efforts for sound really did work.
Now with audio, it was my time to hurry up and get the video going. I had basic VGA working so I figured I didn’t want to spend a lot of time on this, so I was going to go with the VESA 2.0 linear frame buffer. Well this once more again proved to be a bit more involved as the only way I really have to test is emulation via DOSBox and Qemu. And naturally both of them worked fine, but when [HCI]Mara’akate ran it on his real DOS Box (with GUS of course) it crashed wonderfully.
Now I had taken the VESA init code from Quake 1 to build a table of what 8bit modes are supported, and used the VESA code to switch, along with drawing to the buffer with a simple memcpy. And we got nothing but crashes.
After looking more around, I found that you had to add 0x4000 to the VESA mode you want if you wanted to access it’s LFB. Did that work? No still crashed.
Later in the adventure we noticed to get proper access you had enable ‘near pointer acess’ with a call to :
So naturally I would disable it when I’m done, making the call look like this:
WRONG. Oh so WRONG. Well OK technically it did work, but if sound is enabled (and why wouldn’t it be?) it would immediately crash with an error in the DMA code. We ended up wasting over a day trying to figure this one out until I just said screw it, let’s never dsiable the nearpointer, leave it unprotected. Naturally that actually worked. The hint is in map_in_conventional_memory, where __djgpp_nearptr_enable(); is called, but of course there is no calls to __djgpp_nearptr_disable(); I’ve thought about going back through the source to ‘clean’ it up to make it lock and unlock memory as needed, but this is 2015 not 1997 so good enough is well, good enough.
So now with VESA and Sound, I thought this would be a great time to tackle the dynamic loading of gamex86. We will have to re-compile whatever gamex86 DLLs are out there as of course DOS is DOS. The HX DOS guy Japheth seems to have died, as his site and all the info on that extender seems to have mostly vanished. I have an old copy, but I never could make it call DOS stuff if you had WIN32 stuff going on. And if he’s really dead it’s too late to ask him.
Ages ago I remembered this DLL support for DJGPP called DLM, so I thought I’d give that a try. I was able to take our ‘null’ version of Quake II, and get it to where it can load and unload the gamex86.dlm at will. So I figured this was going to be an easy win, right?
Wrong again. Once I started to put in the MS-DOS specific code I got this fun crash:
DLM -> Exiting due to signal SIGSEGV at
0x0014f59d SYM: _dos_lockmem+0x9 DLM: q2.exe [0xf5000]
possibly because of undefined reference to symbol ‘___djgpp_base_address’
DLM call frame traceback :
0x0014dcaf SYM: _Sys_PageInProgram+0x37 DLM: q2.exe [0xf5000]
0x0014e1c4 SYM: _main+0x18 DLM: q2.exe [0xf5000]
So apparently it doesn’t export (or import) djgpp stuff like the base address calculations so we can’t do direct memory access, which means no video and no sound. Ouch. I’ll have to hit the lists to see about support. I don’t like the DXE’s because they cannot be unloaded, so that isn’t much good. And of course things like the JVM inside of gamex86.dll is right out as JAVA inside of MS-DOS? in 64MB of RAM? Dream on.
So for now, the gamex86.dll is statically linked into the executable. You are restricted to vanilla gameplay for now.
As an added bonus, I used Rufus 2.2, to setup a bootable MS-DOS USB stick, slapped everything onto there, and booted up on my Xeon, and it works!
Now as a super bonus, [HCI]Mara’akate went above and beyond by adding in a bunch of fixes, and updates from 3.24 and varous stuff from Knightmare. And then the best part is integrating libogg, so it can now play the ogg sound track! Really, just place the ogg files in the baseq2\music directory and away you go!
For anyone who is interested, I’ve updated the binaries, to include the latest version with built in quakespy technology! Run an /slist2 and get a list of servers!
At this point the ‘alpha 2’ version contains:
- SoundBlaster and Gravis UltraSound Family
- CD-ROM music
- OGG music
- Networking (You need a packet driver)
I’ve also compiled a ‘server’ for Linux based on the code, and put it online @ 188.8.131.52:27910