Thursday 8 May 2008

Development update

Well, BETA 4 is out and includes saving - games and configurations. It also has a couple of tweaks and a bugfix for a quite serious bug.

The bug was related to dragging objects off the top or left of the screen. For some reason, the game midend functions just die when you do this (even though they have "int" as the type for the variable) and the program would crash. I hadn't noticed it and it's been about for a while. It's been in the program for at least the last two beta's, for instance. It only affects the left/top edges of the screen. I fixed it by making sure that the mouse couldn't be moved "off screen", by setting the drawing clipping region properly (it was happening because SDL was being told to "blit" the cursor to a negative x/y value, but it was the game midend that was telling it to do so, even when the mouse was quite some distance from the edge!). So I added proper clipping and a few extra checks and seem to have caught it. At least, I couldn't trigger it with either mouse (no matter how fast I "threw" the cursor against the top or left ) or the GP2X controls.

Mines is still proving an enigma. SDL versions using identical code work fine on PC and crash on GP2X. I'm trying to set up a QEMU ARM environment and see if the same happens there. If so, I'll be able to send a complete "demo" image to Simon Tatham. The GCC options for signed/unsigned bitfields/chars don't seem to fix the problem but the symptoms point at it inserting negative numbers where they should be positive (so, for example, wherever there would be a "1" on the gamefield, a "flagged mine" appears on the screen, before the user has even done anything - flagged mines are represented by -1 inside the game state). These numbers are not generated or used by the SDL frontend at all, they are internal game variables that store the state of the minefield.

Short of running the whole game through GDB or printf()'ing the thing to buggery, it's hard to track down where/why it's doing this. It always asserts at the same point (line 599 of mines.c) but that is part of a recursive function that gets called lots during the course of a game. However, the crash only triggers when you click a box and the game shows problems right from the very start with the initial draw of the gamefield.

I'm also looking more closely at F200 touchscreen and have an emulation set up so that I can test the way it would work on an F200. A few people have reported problems but I had little or no information to go on to resolve them.

No comments: