Star Wars Galactic Battlegrounds is an RTS game (based on the Age of Empires II engine) set in the Star Wars universe.
Unfortunately, I've found my version (the 'Saga' edition containing the expansion) to crash after around ~20 minutes of play, both in single player and multiplayer. This comes down to a null pointer access somewhere in the renderer.
You can fix this by nopping out (replacing with 0x90
) 25 bytes at
0x24DC8D
. This removes the code for the render instruction that's
causing the problem. I haven't seen any side effects, and the game now runs
pretty well both in windows and under wine. Note that the original executable I
had was battlegrounds_x1.exe
with md5sum
6fc2fcdf1586db6667e996c88e610c64
. The patches are also compatible with
the GOG.com
version with md5sum 974f4d4404bb94451a9c27ae5c673243
.
The bytes you're patching should start 8B 47 FD
.
Another issue with the original game (and, indeed, all games based on the Age of Empires "Genie" engine) is that sometimes the up and left arrow keys get "stuck", causing the game to keep scrolling up and to the left. This happens espescially often when Alt+Tabbing under wine, though it's known to happen in other circumstances as well.
That issue is caused by the game misinterpreting the results from the windows
GetKeyboardState()
function. As the above MSDN link states, it returns
— for each key — a byte whose least significant bit signifies that
the key is "toggled", and whose most significant bit signifies that the key is
pressed. SWGB checks if the key is pressed by checking if the byte has a value
greater than 1. This works when the undefined bits are all zero, but this is
not always the case. We can fix the issue by instead ANDing the byte with
0x80
and checking if the result is nonzero.
To do this with SWGB, we need to patch 9 of the checks to replace a CMP
instruction with an AND
instruction, and the JBE
branch with
a JZ
. To do this, we need to replace 80 7C
04 24 01 76
with 80
64 04 24
80 74
. These are found at
offsets:
0x1FD4FA
0x1FD533
0x1FD56D
0x1FD5A7
0x1FD5E0
0x1FD61A
0x1FD654
0x1FD68D
With these changes, I've been unable to reproduce the stuck scrolling issue.
Note that this only fixes the in-game keyboard code: things like the tech tree
call the GetKeyboardState()
function independently, and may still suffer
from similar bugs.
Here's an executable with these issues
fixed (and the CD check at 0x27F90
removed).
Here is a version which links
against WIN32.dll
instead of WINMM.dll
to be compatible with the GOG version's
CD audio emulation. If you have the GOG version, you should download this.