VOGONS


First post, by moog

User metadata
Rank Member
Rank
Member

Mandatory reading: Re: Runtime error R6003 integer divide by 0 - real Fixes for fast CPUs, no slowdown workaround..
In short, that message is misleading, we're not dividing by zero, we're experiencing a divide overflow.

I found something out.

Stargunner CAN be played on fast CPUs without issue! But here's the catch - disable VBE 2.0 detection. How? Here's how from the game's own synopsis:

Option:          Description:              Default:
---------------- -------------------------- -----
/vesa{+,-} Vesa 2.0 Detection. On
/lfb{+,-} Vesa Linear Frame Buffer. On
/tseng{+,-} Use Tseng ET4000. OFF
/fade{+,-} Palette Fading. On
/sound{+,-} All Sound. On
/music{+,-} Music. On
/soundfx{+,-} Sound Effects. On
/logo{+,-} Display Apogee Logo. On
/intro{+,-} Display Intro Animation. On
---------------- -------------------------- -----
/nomouse Disable mouse detection & use no mouse.
/lpt{1,2,3} Set printer port for SEGA/SNES joystick.
/cd:{dir} Use {dir} for configuration files. (When running from CD)

Command Line Example: stargun /logo- /fade-
OR Environment Variable: set stargun=/logo- /fade-

Disables Apogee's logo on startup, and palette fading. Command line options
override the environment variable. {+,-} means use either + or - to enable or
disable the option. A option without + or - will toggle the default value.

So when I start the game with

STARGUN.EXE /vesa-

the game works! Flawlessly, and without any performance impact - not that a Pentium III-S running at 700MHz would make me notice.

The problem appears to be entirely concentrated in broken VBE 2.0 support in newer graphic card BIOSes, such as my Voodoo 5500. There are other people backing up this as a reason: https://www.3dfxzone.it/enboard/index.php?topic=1120

But that still leaves us with a broken SETUP.EXE. I'll try and cook something up. Since Stargunner is using binary config files that contain literally all game settings, our only way to live without a SETUP.EXE is to start the game with known good settings. But that can be tricky if we don't know the layout. Here's what I'm gonna do.

Short term: I'll write something that can generate Stargunner configs, but doesn't force us to go into VBE 2.0 modes.
Long term: I'll make a patch for both STARGUN.EXE and SETUP.EXE - in the first one's case, it will turn VBE 2.0 detection off by default so people with compatible cards will have to run with /vesa+, and for SETUP.EXE I will outright disable any attempt to detect VBE 2.0.

Also while looking through the disassembly I found a motherlode of other commandline switches that /? does not reveal. The first one is /status, which gives us this prompt:

- Tseng Labs Mode      : Disabled
- Vesa Detection : Enabled
- Raster Display : Disabled
- Profiler : Disabled
- Redirection : Disabled
- Slow Mode : Disabled
- Fading : Enabled
- Hidden Icons : Enabled
- Debugging Keys : Disabled
- Supervisor Mode : Disabled
- Logging : Enabled
- Mouse : Disabled
- Detect Mouse : Disabled
- Sound : Enabled
- Sound Effects : Enabled
- Music : Enabled

Ready?

The array that contains recognized switches is as such:

000DEE7C off_DEE7C       dd offset asc_B820A     ; DATA XREF: sub_38010+3Bo
000DEE7C ; sub_38710+3Bo
000DEE7C ; "?"
000DEE80 dd offset aDbuf ; "dbuf"
000DEE84 dd offset aLogo_0 ; "logo"
000DEE88 dd offset aIntro ; "intro"
000DEE8C dd offset aJoystick ; "joystick"
000DEE90 dd offset aNomouse ; "nomouse"
000DEE94 dd offset aBuffers ; "buffers"
000DEE98 dd offset aStatus ; "status"
000DEE9C dd offset aSoundfx ; "soundfx"
000DEEA0 dd offset aSound_0 ; "sound"
000DEEA4 dd offset aMusic_0 ; "music"
000DEEA8 dd offset aMouse_3 ; "mouse"
000DEEAC dd offset aMoney ; "money"
000DEEB0 dd offset aProfile ; "profile"
000DEEB4 dd offset aRaster ; "raster"
000DEEB8 dd offset aH1dden ; "h1dden"
000DEEBC dd offset aDm0de ; "dm0de"
000DEEC0 dd offset aRedir ; "redir"
000DEEC4 dd offset aTseng ; "tseng"
000DEEC8 dd offset aSuper ; "super"
000DEECC dd offset aDebug ; "debug"
000DEED0 dd offset aPfopt ; "pfopt"
000DEED4 dd offset aLoad ; "load"
000DEED8 dd offset aMono_0 ; "mono"
000DEEDC dd offset aSlow ; "slow"
000DEEE0 dd offset aVesa ; "vesa"
000DEEE4 dd offset aFade ; "fade"
000DEEE8 dd offset aFlow ; "flow"
000DEEEC dd offset aSega ; "sega"
000DEEF0 dd offset aSnes ; "snes"
000DEEF4 dd offset aKeyb ; "keyb"
000DEEF8 dd offset aVero ; "vero"
000DEEFC dd offset aTest ; "test"
000DEF00 dd offset aDemo ; "demo"
000DEF04 dd offset aLpt ; "lpt"
000DEF08 dd offset aVrs ; "vrs"
000DEF0C dd offset aLfb ; "lfb"
000DEF10 dd offset aLog ; "log"
000DEF14 dd offset aRec ; "rec"
000DEF18 dd offset aCd ; "cd"
000DEF1C dd offset aCf ; "cf"
000DEF20 dd offset aP ; "p"
000DEF24 dd offset aT ; "t"
000DEF28 dd offset aZ ; "z"
000DEF2C dd offset aS_5 ; "s"
000DEF30 dd offset aM ; "m"
000DEF34 dd offset asc_B82F6 ; "l"
000DEF38 dd offset aE ; "e"

Audigy 2 ZS in FreeDOS
LinLin adapter documentation
+ various capacitor list threads

Reply 1 of 6, by ripsaw8080

User metadata
Rank DOSBox Author
Rank
DOSBox Author

I think it's more about a bugged VBE implementation in the video card's BIOS than a fast CPU. Stargunner wants to set a 320 x 240 x 256 mode with VESA 2.0 by default, and it calls INT 10/4F06 to change the logical scan line length to 336 (150h) pixels; i.e., 16 pixels beyond the horizontal display end. The mentioned function is likely where the divide overflow occurs, possibly because the BIOS programmer(s) didn't test such "small" horizontal resolutions in the year 2000. 😉

Knowing that the issue relates to VBE, have you tried loading an alternate, such as UniVBE (aka SciTech Display Doctor)?

Reply 2 of 6, by LSS10999

User metadata
Rank Oldbie
Rank
Oldbie

IIRC Stargunner's SETUP can toggle VESA 2.0 functionality. I'm using the freeware release.

On modern GPUs VESA 2.0 doesn't work correctly with this game, and must be turned off. With VESA 2.0 turned on, intro video plays fine but the screen turns complete garbage once entered menu. Fortunately I can just ESC then ENTER to exit the game.

Though I never encountered any divide by zero error message with this game.

Reply 3 of 6, by mkarcher

User metadata
Rank l33t
Rank
l33t
ripsaw8080 wrote on 2025-11-26, 04:35:

I think it's more about a bugged VBE implementation in the video card's BIOS than a fast CPU. Stargunner wants to set a 320 x 240 x 256 mode with VESA 2.0 by default, and it calls INT 10/4F06 to change the logical scan line length to 336 (150h) pixels; i.e., 16 pixels beyond the horizontal display end.

Oh, sounds a lot like Commander Keen's scrolling ported to VESA and 256 colors. It would make sense for the BIOS to calculate the number of rows available at a width of 336 pixels. The overflow can happen at 32768 rows (signed divide) or 65536 rows (unsigned divide). 336*32768 is around 11 Megapixels, which would require 11 Megabytes. This might indicate that the issue is likely to happen on cards with 16MB or more memory that can be used for the frame buffer.

Reply 4 of 6, by moog

User metadata
Rank Member
Rank
Member
ripsaw8080 wrote on 2025-11-26, 04:35:

I think it's more about a bugged VBE implementation in the video card's BIOS than a fast CPU. Stargunner wants to set a 320 x 240 x 256 mode with VESA 2.0 by default, and it calls INT 10/4F06 to change the logical scan line length to 336 (150h) pixels; i.e., 16 pixels beyond the horizontal display end. The mentioned function is likely where the divide overflow occurs, possibly because the BIOS programmer(s) didn't test such "small" horizontal resolutions in the year 2000. 😉

Knowing that the issue relates to VBE, have you tried loading an alternate, such as UniVBE (aka SciTech Display Doctor)?

UniVBE does not support Voodoo 5500, to the point where it refuses to load because it does not detect a supported card. I have SciTech Display Doctor 6 for DOS and it's the same story - no support. What's interesting is that the provided VBETEST.EXE can set this resolution, and so can Quake. Maybe they don't do it with VBE 2.0. Or maybe it's because I haven't tested all refresh rates with VBETEST.

LSS10999 wrote on 2025-11-26, 06:50:

IIRC Stargunner's SETUP can toggle VESA 2.0 functionality. I'm using the freeware release.

On modern GPUs VESA 2.0 doesn't work correctly with this game, and must be turned off. With VESA 2.0 turned on, intro video plays fine but the screen turns complete garbage once entered menu. Fortunately I can just ESC then ENTER to exit the game.

Though I never encountered any divide by zero error message with this game.

I'm also using the freeware release. As far as I can tell from disassembly, SETUP.EXE can detect 4 different video modes and comments on them as a state of VBE 2.0 capacity:
1. Disabled
2. No 320x240 - I can get this on QEMU with VGA
3. Not present
4. Enabled - I can get this on DOSBox and DOSBox-X

Audigy 2 ZS in FreeDOS
LinLin adapter documentation
+ various capacitor list threads

Reply 5 of 6, by ripsaw8080

User metadata
Rank DOSBox Author
Rank
DOSBox Author
moog wrote on 2025-11-26, 08:45:

What's interesting is that the provided VBETEST.EXE can set this resolution, and so can Quake. Maybe they don't do it with VBE 2.0. Or maybe it's because I haven't tested all refresh rates with VBETEST.

I think Stargunner can set the 320 x 240 x 256 VESA mode as well. Adding 16 logical pixels to the scan line length via INT 10/4F06, which Stargunner does but the cases you mention presumably do not, is proposed to be where the divide error happens with the 5500 BIOS.

Anyway, I agree that disabling VESA is probably the easiest solution, but I couldn't readily find a tool for doing that, so I made one. The attached simple TSR program will make VESA appear unavailable, perhaps useful in other cases as well for systems with VBE included in the video card BIOS.

Reply 6 of 6, by mbsystem

User metadata
Rank Newbie
Rank
Newbie

Couldn't VESALIE.COM in vgadoc4b have done the job, while also adding vbe 2.0 and vbe 3.0 detection? The source code is included.