Saturday, January 9, 2010

C-evo on netbook bug fixed

There's a bug in C-evo (the largest game I put on my 50 megabyte "desert island" disc) where it doesn't fully work on a netbook. In more detail, the diplomacy screen is nay-to-impossible to use on a screen only 600 pixels high because its top is cut off.

Since one rule I have for all software on my desert island disk is that it must work on a netbook [1], I have fixed this bug. Look at c-evo-netbook-fix.c and c-evo.netbook-fix.exe at samiam.org/cevo. This program, which is run in the same directory as cevo.exe, creates a cevo-netbook.exe with this bug fixed.

In more detail, the offending code is this line in Term.pas:

NatStatDlg.UserTop:=Screen.Height-PanelHeight-NatStatDlg.Height-8;

These are the variables used:

NatStatDlg: The window that pops up when you hit F9 (the nations window)

UserTop: Its default starting position, whose top is off the screen on a netbook unless we fix the above line.

Screen.Height: How high our screen is

PanelHeight: How high the "panel" on the bottom of the screen is

NetStatDlg.Height: How big the nations window is.

8: An eight pixel cushion so it looks a little nicer.

Since I don't have Delphi 4, I had to find the resulting compiled code the hard way. The offending -8 above is byte number 723333 in the code (as a positive 8, since the compiled code subtracts 8, instead of adding -8). Since C-evo is using the "subtract this 8-bit signed value with a value of 8" opcode here, we can make the number in question a negative number, resulting in the window being moved down instead of being moved up.

[1] The target netbook is a Intel N450-based netbook with a 1024x600 display.