Conversation

Replying to
also, this isn't a DOS game. it's a PC booter game. You insert the disk and boot your PC, and it boots right into this game, no DOS needed. This one has been converted into a DOS version by some pirate.
5
92
So if we look at the wikipedia for CGA we can see the palettes for CGA. It seems it's using palette 1, high intensity, and should be palette 0, low intensity.
Image
2
46
as for why it's wrong... two possibilities: 1. dosbox is starting up in CGA palette 1-high and the game expects 0-low. I'm not sure what an actual IBM PC does here? 2. when it got converted to a .COM file, someone added explicit palette-setting
5
45
so for #2, let's look. I plugged it into ghidra and checked for calls to int 10h, the interrupt for BIOS video functions. There's a call to AH=0x0E, which prints text to the screen, a call to AH=0x01 (to set the text mode cursor shape?), and a call to AH=0x00.
2
29
that last one is Set Video Mode. AL is 0x04, which gives us the 320x200 4 color mode. So... no palette calls.
1
31
So it must be a problem with DOSBox starting up in the wrong palette mode. I seem to remember that can happen because of CGA emulation in VGA mode? So... let's fix it.
3
34
So here's the function that sets the video mode. You'll notice it has a suspicious amount of NOPs in it. That's good: it means we can easily fix this.
Image
4
51
I've moved the video mode call up, then I call AH=0x0B to set the palette, and use option BX,0100 to set it to palette 0. Then, I call it AH=0x0B again but with BX set to 0, so that it sets the background color to 0 (black)
1
31
finally I empty out AX just to make sure it doesn't break any later code which might be depending on AH being 0.
1
34
WHELP now the internet archive won't let me upload it because it thinks it's spam. That's not fun.
2
64
okay, archive emailed at the "if this isn't really spam, send email here" address. Kinda takes out the momentum from this thread, but I'll update with the working URL when done.
2
52
for now, take your own copy of digger .com, open it in a hex editor, then go to offset 0x32C and change the next 18 bytes to: B8 04 00 CD 10 B4 0B BB 00 01 CD 10 31 DB CD 10 31 C0
4
60
okay in the meantime, gave me a copy that seems an even earlier version... and all those NOPs? they're actually code in this one!
Image
1
36
So what's this code doing? Well, it's bypassing the BIOS completely. It's directly programming the CRTC chip on the CGA card!
2
34
And I think that explains what happened here: 1. Digger was written (in 1983). The EGA and VGA cards did not exist yet, and this code probably didn't work there.
1
24
2. At some later point, someone patched it to still run on EGA/VGA systems, but they either didn't fix the palette or were using a video card that defaulted back to the same palette as Digger set anyway
1
26
So let's see how these three versions work in DOSBox. If we set machinetype=cga, they all work the same. the version, the archive .org version, and my patched version.
Image
2
30
setting it to machinetype=vgaonly means they all do different things. My patched version works the same as on machinetype=cga. The archive .org version? wrong palette!
Image
1
26
So yeah. The original game directly programmed the CGA card's CRTC registers, which broke later when VGA cards came around. Someone hacked it to fix that, but potentially caused an issue with VGA cards not using the right default CGA palette
2
36
the funniest part? I'm just assuming that's what the original version did. I now have three versions here, and I know NONE of them are the original version.
2
32
the bad news, though? this is completely different code. It's initializing the video mode using the BIOS... so possibly this is later code that was updated to work on more systems
Image
3
33
Show replies