Tuesday 11 November 2008

STPPC2x v1.1 News

Just to reassure everyone, I'm still working on STPPC2x after my "version 1.0" release.

At the moment, I have the following in progress for "version 1.1":

Menus - Added indicators on the main menu to tell whether a game requires numeric digit input (e.g. filling, solo, unequal), supports "cursor key" control (e.g. sokoban, maze3d, etc.) or has its own solver.

Mosco - Various memory cleanups, a working "end-of-game" detector with "flash" ( so that you know you've won) - I left a bug in the version released for v1.0 that lets you complete the game even if some of the conditions aren't met.

Solo (Sudoku) - Perfect display with all the intermediate lines but in a "normal" resolution now. 4x4 sudoku is also playable because I've adjusted the "digit" input code (e.g. Press L/R to increase digit and X to enter it into a square) so that you can use the letters too... 4x4 sudoku needs 1-9, A-G, for instance.

Unequal - Because of the above, you can now play much larger unequal games too, and smaller games now only let you select numbers that are "in range" (e.g. 1 - 4 on a 4x4 unequal, 0-9 on a 10x10 unequal, 0-G on a 16x16 unequal etc.)

Loopy - New SVN updates provide better puzzle generation when using "Great Hexagonal" layouts etc.

I'm also working on a Kakuro puzzle, because it's nice to have a new puzzle each time I put out a big update.

Wednesday 8 October 2008

STPPC2x Version 1.0

(Hopefully) The definitive version of my efforts to port Simon Tatham's Portable Puzzle Collection to the GP2X. This is now a set of 31 addictive logic and puzzle games (1 new to this release - Mosco). Some are old favourites (like sudoku, sliding puzzles and minesweeper) and others you may not have seen before. An awful lot has changed in this release, so make sure you read this whole thing!



You can download STPPC2x immediately from the main website or from the GP2X archive.

PLEASE NOTE: This release is a bit of a leap in how the collection operates. It is recommended that you create a new folder for this version - the directory structure has changed significantly. INI's and SAV's from previous versions are, of course, still compatible but may need a little renaming (same_game.ini to samegame.ini or rect0.sav to rectangles0.sav, etc.)

So, what's new?

- Mines now works 100%.

- New game - Mosco - written by myself, based on a puzzle I found in an old book I found lying around. There isn't a "proper" solver yet (by Simon Tatham's definition), but it will give a valid answer and determine when you have won.

- Perfect display of all games (no more mismatching lines etc.)

- Save / Load / Delete Savegame with multiple saveslots for each game.

- "Autosave" option to save whenever you come out of a game (so it gives the appearance of persistence - come out of one game, or quit the collection, and when you come back it's exactly how you left it). Off by default to prevent unnecessary writing to your SD card (hold L or R when starting a game to ignore any autosave).

- Game presets are now fully working - you can play the "difficulty levels" of games that have them, as well as create your own defaults for each individual game. (Hold L or R when starting a game from the main menu to skip your defaults, or hold L + R on the main menu to delete the config file for that game entirely).

- Music by Mr Lou is available in a (optional and seperate) "music pack" from http://www.ledow.org.uk/gp2x/ (Turned off by default - check the tracks you want to play in the Music Tracks menu and it will loop through them. Press to the left of a track name to sample it. Make sure Play Music is on and save the config on the relevant pages to get music all the time). Many thanks to Mr Lou for allowing me to use the track.

- Integrated game menu.

- Map now has an option to show "unmoveable" colours.

- New SVN version of Loopy which is much more complex and configurable. Old savegames may not be compatible (not my fault!).

- Fixed display of Solo to show up better on the GP2X.

- Screenshot feature on stick-click.

- Cursor key emulation mode (so that the D-pad/joystick) to let you play games like Sokoban easily - joystick will act like a joystick when this is turned on (indicated by a keyboard icon in the menu). Net, Light-up, Maze3D and Sokoban also support this option.

- Fix to Blackbox to allow the player to set minimum and maximum number of balls on the GP2X.

- Use the Y button in more games to support additional functions (hints, clearing digits etc.)

- A million and one other features and fixes.

Feedback is appreciated (especially from F-200 and USB mouse users) and full source code is available from:

http://www.ledow.org.uk/gp2x/

Note that this is an unofficial port - so please don't bother Simon Tatham with any problems, although he is aware of the project's existence.

Saturday 20 September 2008

Monday 15 September 2008

More version 1.0 news

Version 1.0 Checklist - Current Status

30 fully-working games (including Mines) - Check
Perfect display of the games - Check
Loading of built-in game presets (Easy, Medium, Hard etc.) - Check
Presets menu can cope with any number of presets - Check
Saving your own custom preset for each game, with automatic loading of the preset for that game ("I like net to start on a 10x10" mode) - Check
Ability to bypass the above if you want when starting a game - Check
Blackbox fix (so you can enter, e.g. 4-10 balls instead of a fixed number) - Check
Map fix (so you can see which "countries" were given to you at the start and are therefore locked) - Check
Loopy fix (so that you can still use the "old" presets which are much more playable than the enormous presets in the new code) - Check
Up to ten save slots can be loaded, saved and safely deleted from within the game - Check
Auto-save option so that whenever you quit a puzzle it is saved in a special slot and the same puzzle in the same state greets you next time you run that game - Check
Ability to bypass the above if you want when starting a game - Check
Cursor-key emulation available for certain games (sokoban etc.)
Latest SVN (including a more complex version of Loopy) - Check
Background Music - Check
Volume control - Check
Track list (up to ten music tracks, only turn on the ones you want to play, if any) - Check
Music can be replaced by any OGG file - check
Tweaked floating-point (decimal numbers) support in some games configuration options - Check
Screenshot feature on stick click (with options to snap whole screen or just puzzle area and settings in a global settings menu to hide certain elements) - Check
Game menu can cope with any number of games - Check

Hourglass cursors, credits screens, SVN version number in the title screen, updated text throughout, general help for keys, nicer menu system, smaller executable, smaller distribution (you can even remove the music, which doesn't need to be there), and a million and one tiny tweaks - Check

Basically the only things that remain on my list for v1.0 are "Interruptible generation", a new verson of malloc() and some random code-style, duplicated variables etc. that I can prune but which don't affect the games at all.

Interruptible generation for the games which are "slow" by default (which seems to be Filling and Slide) shouldn't be too hard at all. Moving it to every game will take a bit longer as they all have different generation strategies and it'll take a while to understand the code and find the bottlenecks.

It's also a little tricky to "recover" from a interrupted generation cleanly, but it shouldn't happen too often, so that shouldn't be an issue. Mainly, it's where the game allocated a ton of memory to generate the puzzle and I missed that it should be cleaned up.

The new "malloc" (which allocates memory for the games to use) may well be implemented for v1.0 depending on how easy it is to do. The games already use a "safe malloc" within the puzzle collection for all memory allocations, which leaves the opportunity to extend it to be able to use some of the Video RAM on the GP2X too. Basically, when a "normal" memory allocation fails, it'll be able to carry on and provide a bit of Video RAM to use instead and the games won't even know the difference.

The whole procedure would be transparent to the games, but provide them with up to 32Mb of RAM extra if they need it. I can't see many current games needing it will provide a safety barrier should they touch on the 32Mb mark. I'm looking at a new game (which probably will come after v1.0 if at all) that might well come close to that mark on it's larger settings. Once you add multiple fonts, PNG's loaded into RAM, OGG files, etc. it's better to be safe for the sake of fifty lines of code.

Anyway, version 1.0 is iminent and in a more-than-releaseable state as it is. I just want to playtest some more (the wife is very good at finding bugs accidentally), get those two more bits of code in and then it'll be released.

Thursday 11 September 2008

Feature-creep

Okay, so version 1.0 is slowly taking shape. Here's a few snippets of the smaller parts that are being worked on in between a lot of the "big stuff".

Firstly, there's a couple of things that I've put in there for my own use. For instance, there's screenshot code now, although probably the only person that will use that is myself. It's BMP-only (converting to PNG using libpng just looks way too complex to bother with) and I use it to verify the drawing is correct, to build the new animated GIF's for advertising the game and things like that. Unfortunately, because it needs to be able to activate at any time, this is one of those features that can't be slowly moved into the menus like almost every other new feature and requires a dedicated key. I've put it on Stick-Click for now because most people never press it (and it doesn't even exist on later versions of the GP2X), so it won't get in people's way.

It highlights a big problem that I have - the GP2X doesn't have enough keys! Unbelievable, I know! Excluding the basic up-down-left-right (whether as a "mouse" or "cursor keys") that are common to all the games, and the key-combinations I have for "safety" (e.g. L+R to quit back to the menu etc.) the "keys" required after moving almost everything into the Pause menu are:

Left-click (required in every game)
Right-click (required in a lot of games and sometimes essential to completion / player comfort)
Middle-click (only used in a handful of the games, and not essential to puzzle completion, but convenient)
Pause / Enter Menu
Decrease Digit
Increase Digit (the only way I could make unequal, solo, filling, etc. playable without a keyboard, but still not perfect).
Enter Digit
Undo
Redo

And the buttons I have are: A, B, X, Y, L, R, Select, Start. 8 buttons for 9 functions. So before release I'll be re-jigging all the keys. I don't want to move Undo/Redo into the menus but it's an option. I also don't want to shift a common key into a "combination" (e.g. at the moment I have L+VolDown for Undo and L+VolUp for Redo). I'd also like a key to switch between input systems eventually, so that for some games where it makes more sense to use a "cursor-control" system instead of a mouse-emulation one (such as fifteen and sokoban), the user can change between them at the press of a button.

Some "hidden" combinations need to be present to. Because the user can save their favourite configuration for each game as a preset, and that preset loads by default whenever they start that game, there needs to be a way to cope with two scenarios: The config save file gets corrupted, the config describes a game which takes an inordinately long time to generate. Imagine accidentally saving a config for Net, for example, that takes an hour to generate a game. You'd have to leave your GP2X on for all that time before you'd be able to change the options and play Net normally again. In fact, the easy solution is a little hidden feature - press L or R when loading a game from the main menu and it will completely ignore your preset. You can then get into the game ultra-quickly, change the options and re-save your preset if you need to.

At the moment, the options in the Pause menu are so numerous that they are now sub-categorised:

New Game
Restart Game
Solve Game
Configure Game
- View Presets
- Load "My Preset"
- {Load Preset X}
- {Configuration Option X}
- Save As "My Preset"
Help
- General help (Keys, etc.)
- {Game X} Instructions
- {Game X} Tips and Tricks
Global Options
- Music
- Track List
- Volume (including On/Off)
- Auto-Save Game on Exit
- Screenshots
- Include cursor in screenshot.
- Include status text in screenshot.
Credits & Licenses
- Puzzle Collection
- Third-party Games
- GP2X Port
- Music
Quit to Main Menu (the list of games).

I have decided on the background music I want and got permission of the artist - by strange coincidence, they own a GP2X so they'll be able to play the game with their own music. I've gone for some plinky-plonky ambient music - gentle, relaxing, simple. I'll also retain the ability for the users to replace or remove the music if they so wish - it'll just be 10 OGG files in a music folder. If they aren't there, nothing plays. If they are, they appear on a track list that the user can edit - so even if they don't like my choices, they can choose their favourite tracks to play while they puzzle. And, of course, there's the all important "Music Off" option.

General Updates:

The main menu shows the revision of STPPC that they are based on. This is so that people can see how old the collection is and whether it needs updating to support feature X of a certain game, or indeed any new games that come about. (There's a new, much more configurable, version of Loopy in SVN and it's already in my private version of 1.0 and working perfectly.)

The main menu is now complete and allows loading any of the 30 fully-working games (yes, 30, because Mines works now). It lets you go into and come out of the games as many time as you like without quitting back to the menu and is super-fast. I tried it on my GP2X for a laugh and after 200 entries and exits from particular games without quitting back to the main menu, I was suitably satisifed that I wasn't leaking too much RAM or risking a crash by playing that many games - this test included music, games with saved presets, full games, partial games, games with timers, loading/saving games, etc. A fairly accurate measurement of memory usage says that (with music off) the games rarely go about 5Mb of allocated RAM in their default configurations, although obviously most of them can be allowed to grow to silly sizes if you play with their config options. Without going too mad, I was able to generate "virtually impossible to solve within the GP2X's battery life" puzzles in all the games and didn't once get an out-of-memory error or crash. Although some of them nearly took forever to generate puzzles of that size!

Music works but may stutter on very difficult puzzle generation. There's not much I can do about this without increasing the size of the sound buffer - at the moment puzzle generation is an inherently single-threaded process and it tends to swamp the CPU and all other threads running. When interruptible generation is implemented (a BIG task), then it will hopefully solve itself because in the same place that I put code to check if the user wants to stop, I can refresh the music buffer.

I also know that Blackbox has a configuration option that can take values of the form "4-10" meaning "anything from 4 to 10". That's totally impossible to enter in the options menu in the current state (although you can happily use a Preset or hand-edited config file to play it!), but I may well hack on the Blackbox code to convert this to two configuration options: Min and Max. If you set them to the same number N, it's the same as just "N" in the config box, and if you set them to, say, X and Y respectively, it's the same as entering "X-Y" in the config box. I'll also be on the lookout for other similar options that allow such things.

Config-options are one of those things that are really finicky to convert to a non-keyboard device because they are expecting textual input all the time - the current GP2X code has always had a special "Kludge" switch that allows entry of floating-point numbers in, for example, "Barrier Probability" in net because otherwise you'd only have barriers everywhere or none at all. At the moment, such options are hard-coded in the GP2X code but I'm trying to find a nice way for the puzzles to support telling the so-called "frontend" whether a configuration option should be floating-point or not. It looks like I might have Simon Tatham's ear on that particular issue, however.

There's been a massive reorganisation of the files that the program uses. The folder structure is currently similar to:

Configurations/ (holds the game-specific INI files)
Documentation/ (holds various information about the collection such as licenses etc.)
Help/ (holds the various help textfiles)
Images/ (holds splashscreens and "game previews" that show in the menu)
Images/Screenshots/ (holds any generated .BMP screenshots)
Music/ (hold, erm, the music?)
Saves/ (holds all the savegames)
STPPC2x.gpe

So hopefully, there will be no more hundreds-of-files-in-one-folder and even the above folders should be as empty as they can be.

Finally (for this update at least), I'm looking at making a new game to go into the collection. It won't make it into the official collection, I'm sure, but I'm looking at the possibility of a simple overhead 2D maze game - I have some code that I can use for various "types" of mazes and solvers for them and I'm hoping they'll translate well to the small screen of the GP2X. That will be probably be a post-1.0 thing, though, because believe it or not, programming for that side of the collection is new to me!

Monday 8 September 2008

STPPC2X - "Mines" is now working!

Ah-ha!

Right, FINALLY. I got you, you mines-bast**d. FIXED. FIXED. FIXED. Version 1.0 will have working "mines"! Guaranteed.



Okay, for some reason, the particular version of gcc on ARM that the Open2x development environment uses does not treat an relatively-undocumented (and technically "broken") use of memset on the ARM platform the same as it does on x86. I think it's the alignment of ARM but I can't be bothered to check the exact technical details know that I have found it.

void * memset ( void * ptr, int value, size_t num);
Sets the first num bytes of the block of memory pointed by ptr to the specified value (interpreted as an unsigned char).


Notice the "unsigned char" bit. So when you do what mines.c was doing: memset(a pointer, -2, a number) it works perfectly on x86 (and all the other supported platforms, including MacOS, Palm, etc.) but does this on ARM:

"-1 -2 -2 -2 -1 -2 -2 -2 -1 -2 -2 -2"


Which buggers up mines! The fix is not to use memset but to fill the array manually - you get the proper result and mines no longer crashes but "just works". There were three places, only in mines.c, that do similar things. It seems to work fine for the other uses which are mostly -1's.

This fix was found by the following method:

1) Write original author of mines.c a long begging letter with lots of technical details on the problem
2) Recieve reply with basically says "No idea, can you print out the contents of X at line Y for me to look at?"
3) Edit code to print out contents of X at line Y on both PC and GP2X.
4) Gather debug logs from both platforms and compare.
5) Draft another long begging letter which says "This is what I got".
6) Just before hitting Send with large debug logs attached, notice that there is a pattern to the what-should-be-empty array.
7) On a hunch, gradually keep shifting the debug check higher and higher in the code, eventually placing it immediately after a memset.
8) Spot the problem (memset arrays aren't actually uniformly memset)
9) Google the definition of memset which includes the "unsigned char" line.
10) BELLS RING.
11) Search for all memsets with negative parameters and replace with for() loops.
12) Test on PC and GP2X.
13) Rewrite email to Simon Tatham, including a patch and problem description and press Send.
14) Kick self repeatedly and hard.

Anyway... it's fixed. Mines works. Finally. Can't believe it was something so stupid. Multiple human error, because obviously nobody who's touched the mines code had ever noticed the error before and only a compile on an ARM-based device showed it up. Patch winging its way to Simon Tatham for inclusion in the main code. Sigh of relief. Celebration game of mines.

Now, who's got the champagne?

Saturday 6 September 2008

More work on STPPC2x

I've fixed some quite important bugs in STPPC2x today.

First, I've been doing Valgrind runs on the code, which has picked up on quite a few little bugs here and there - I didn't free this memory, I lost the thing a pointer was pointing too, I extended outside the boundaries of this allocated memory etc. It's only a game for a handheld, so it's not security-critical but it's always nice to fix something that shouldn't happen, even if it only happens rarely, or it has zero actual impact on the code.

At least one of those bugs left a few hundred thousands bytes of bitmap or fonts in RAM. Not a big deal, because the libc clears up enough after the game is quit, but (in theory) if you were to run enough games inside STPPC2x one after the other, you'd run out of RAM. That's still possible but extremely unlikely now because the only memory leaks left are in SDL libraries and the like and so will affect all GP2X software. They are on the order of 20-30 bytes of lost memory each time, so it'd take months of constant playing without quitting, batteries running out, power going off, etc. to make a difference.

I also fixed two long-standing display bugs. Many people noticed that Solo (the Sudoku puzzle in the collection) wasn't drawing properly. And, if you look carefully, you might notice that several puzzles were drawing a bit awry. There was an off-by-one in the drawing of any rectangles (which are used is virtually all games, even if they are just the "background" for a circular or triangular object) which meant that everything looked slightly off and the Solo's cells "overlapped". That's now fixed. I must have misread or miscontrued the documentation for the puzzles and SDL_gfx because I was sure that I had looked at this several times and it was coded as it was supposed to be.

The other bug was a bug in drawing circles for which the puzzle only wanted the outline (i.e. no "fill" colour). This showed itself most in "Inertia" where the stop-points were dark-red pie-slices when they should have been mere one-pixels arcs. By sheer stupidity, the fill colour for a "empty" circle used colours plucked out of a random location of memory because of a signed overflow in the function. A short, one-line check and I fixed it.

In previous versions, none of the GP2X puzzles looked like their screenshots, if people looked carefully. That's because the screenshots were taken from GTK versions. Now, they are pixel-perfect (I hope) and the same as the GTK screenshots or, indeed, the screenshots of any other version of STPPC.

I also fixed a possible palette-crash that I think I may have introduced myself quite recently. Always check your array boundaries! This was caught by Valgrind, again, and I'm quickly finding Valgrind an invaluable tool when debugging. GDB can get you to the line where a problem occurs, with a small backtrace. Valgrind tells you why the thing crashed and where the relevant parts of the code are - only for memory, overrun and similar errors but it's damn helpful. Valgrind has also found multi-threaded locking problems in the latest version and numerous other bugs.

I also did a quick Valgrind "Heapcheck" run on the code. This checks how much memory it *actually* allocates, rather than trying to guess from what's left over in memory. STPPC2x uses very little memory, a lot less than I supposed. A single session that played over 50 games of various types never went much past 5Mb heap usage with the default config options. Although I consider that quite a large amount of memory for a basic game to use, I was quite impressed - that means that on default settings it uses less than 1/7th of the standard memory available on the GP2X.

I played with a few bits to enable background music. Unfortunately, the GP2X is a little underpowered and stutters on the difficult game generations, or if a move is particularly graphically-intensive. I'm sure there are ways around it with larger buffers, seperate threads etc. but for now I've put it on a backburner - it works, but it's not good enough yet.

The code loading game presets (i.e. difficulty levels) is working really well now - I haven't had a big problem in that code yet. As part of that, I've added a "special" preset which is an extension of the "save config" functionality of the older versions. Basically, you can save *your* favourite difficulty as a preset and have it load up every time you run that game by default. This did present a small logical problem though - what if you accidentally set it to a difficulty so hard that it takes the computer forever to generate the puzzle? You can't get into the game to change the option until it's generated the puzzle!

Fortunately, I've put in a little facility for that - pressing L&R on the list of games will delete your custom settings so that you can run the game with it's (safe) defaults. The keys and mechanism for this might change over time (for instance, I may have it so that if you start a game while holding down a certain button, it just ignores your config instead of removing it).

On the subject of correcting mistakes, I've also put in "Undo" and "Redo" buttons. These work fantastically and let you roll back and forth in the history of the game you're playing. It's something I never use in these games and nobody had asked for it, but the facility is there so it was only sensible to use it.

The new in-game menus are coming along nicely now - there are one or two layout quirks but nothing that can't be fixed and a few places where I really need to ask the user "are you sure?", but it's working well.

All in all, things are coming along smoothly and it's gradually looking more and more like a v1.0 release. I have a lot more "big" items on the agenda before that point but I'm very pleased with how much better it's looking now that I've had another spate of programming on the project.

Friday 29 August 2008

STPPC2x v1.0 (Work in Progress Information Only)

It's been a while since I posted any updates here and in that time a lot of important things have happened within the GP2X community.

Most importantly, the GP2X has been discontinued (if you didn't know this by now, it was even on Slashdot's frontpage for a while!). This came as a great shame, but hardly a shock, to myself. However, I will be (and have been) continuing development as normal. I don't have an F-200, I don't have a Pandora (an "unofficial" GP2X successor-in-spirit), I don't have a Wiz (an official succesor). I can't afford any of them anyway. Until that situation changes, I'll be programming for the GP2X F-100 (with F-200 compatibility where I can manage it) and will keep programming. The GP2X rekindled my love of programming and I'll be both playing and coding on it until the day my personal unit dies. In fact, just lately I've been seriously looking at the prospect of buying another cheap F-100 second-hand if one comes up.

If I do suddenly manage to get any of those whizzy new machines, though, then I'll still be programming for the GP2X anyway - I prefer the challenge of programming for the lowest denominator. There is little fun in programming on a machine which just laughs at everything you throw at it (however, *playing* on it is another matter entirely!), and a set of 2D puzzles will never really stretch a powerful machine in practical use. So, I'll probably be leaving any Pandora/Wiz conversion of STPPC2x to someone else (to be honest, people would probably just use the official GTK versions on Pandora anyway, or their new Java ports).

That said, development slowed a little this month and last month but this was for completely unrelated reasons. What with a holiday and some end-of-term work at the school I work at, all programming activities took a back-seat. However, when I did get some programming time, I put aside my GP2X for a moment and attempted to update the Palm port of Simon Tatham's Portable Puzzle Collection, the code for which seems to have stagnated a little. However, this proved frustrating and, in the end, fruitless.

My wife has a Palm TX and we found that although the "official" Palm port of the puzzle collection works fantastically on a Palm Tungsten E2, the TX somehow ran the same executable differently. Most importantly, it often saw right-clicks instead of left-clicks all the time, no matter what options were set. This, obviously, made affected games absolutely unplayable. What was odd was that it only occurred in about 50% of the games and there was no way around it short of actually diving into the code and seeing what happened. Additionally, the Palm port doesn't include several of the games in STPPC2x and it would have been nice to get them working on Palm too, not to mention the various bug-fixes and new options that have been added since.

My attempts to recompile a test version of the Palm port proved much more difficult than I ever imagined. First, finding an appropriate build environment was nothing short of a nightmare - the SDK's are hidden away under obscure names that have changed since the README for the Palm port was written, contained only on websites that require arcane registration. After several hours (and some creative hacking), I was able to get a full suite of headers and compilers working. This is when the second and most damning problem showed up.

For some reason, the Palm has a very, very rigid memory structure and programs are written in segments of code that need to be of a certain size. No problem, the original Palm port took care of that with some ever-so-fancy scripting which tags functions so that they end up in seperate modules. With some creative tagging, all the modules are below the required size and they can all "talk" to each other - with nothing more than adding a function name to a script's datafile. However, because of the problems of getting the exact build environment that the original porter used, a straight compile no longer generates the same size code. Thus, a lot of the programs now need to be split into not just two but three or more segments, which greatly increases the complexity of compiling, linking and the various supporting scripts. In short, it's an absolute nightmare.

What started off as "I'll just compile this and see if I can find out what went wrong for Palm TX" turned out to be hours of frustrated downloading, hacking, patching, compiling of compilers followed by more hours of changing headers and filenames, editing scripts and lots of other fannying about just to get the original source code to compile once more in a useable fashion. After deciding to just speed things along and get the simple things running and work on the complex stuff later, I did get a working executable in the end, but without 40% of the games present in it because of the various code size changes and other problems. In short, it really wasn't worth the effort and was certainly useless for anything but a developer.

The frustration was so intense having fought to get to that point that I'd completely forgotten the original point of doing it all and in the end, never even got to looking at the relevant lines of code or whether a simple updated header could fix the problem. I would have spent 5% of the time fixing my problem and the rest just trying to get the original games back into a working state, let alone what would happen once I started introducing the new updates, games, etc. into the Palm collection. In the end, I left it for another day (month, year) and just kept hold of what I had downloaded/patched to get things working that much.

That meant that I was pretty sick of the Puzzle code for a while, although it was hardly the Puzzles' code that was at fault as much as the design of the Palm and/or the gcc compilers/linkers for Palm. Why all that can't be done automatically is beyond me but I'm sure there's a good reason, even if it's just "nobody got around to doing that". I tried other compilers and I tried searching for help but the answer was always the same "There's nothing we can do, split your code into smaller modules".

So, getting back to the GP2X (once I'd mustered some programming enthusiasm again) was an absolutely joy. Compile for x86. Link. Run on laptop. Compile for ARM. Link. Transfer to GP2X. Run. Rinse and repeat. Programming for the GP2X is a cinch in comparison and, more importantly, is intuitive and standardised. If something goes wrong, it's obvious and never anything to do with the compiler/linker being used. I ballsed up a Makefile once, so that things compiled oddly for ARM but okay for x86, but that's hardly anybody's fault but my own.

Unfortunately, my TODO list for the next (and probably "definitive") version of STPPC2x, with which I'm going to tempt fate and call v1.0, is very long but I am working steadily through it, even if I'm not putting out BETA's every month like I used to. A lot of the new stuff involves major infrastructure changes. The dodgy menu code that was thrown in with the intention of having some way to restart a game, and then changed to an actual menu to have some way to pause the game, and then changed to have some way to display the current options (in some of the most horrible code you'll ever see), and then repeatedly altered, bug-fixed and torn apart to fix some interface issues - well, let's just say that it's not going to be practical to extend it again and add the new options that I want to (such as using difficulty presets, etc.).

I've had a design for a new menu for a while and it'll look and work much better than the current one. We're talking a proper menu on the Pause button. With actual sub-menus. And actual proper changeable options. And an actual list of save-games. And an actual list of presets (including custom ones) that can be selected. And all without having to remember fifty keys or cramming it all into one screen.

It does involve touching some code that even I'm not sure I can remember how it works (I made a point of documenting the configuration-option stuff very heavily at the time, because I knew it would become a problem) so it's a big change to make that'll impact on a lot of things. However, all the "big stuff" is already in the code and it's just a matter of making it work in an intuitive way, in the right order, without bugs.

I need to factor out a lot of things to make the changes to the menu and thus there probably won't be many "preview" versions of the new code until it's finished: e.g. at the moment, you are "in the menu" or not, and the helpfile display "sub-menu" is a massive bodge. I need to change that so that you are "in menu number X" etc. so that the game only plays when you're not in a menu and options on sub-menus inherit from their parents etc. correctly and the key-press changes differ depending on the menu you're in etc.

It's a big job but I'm aiming for the magic 1.0 and I'm hoping to get it all working so that the program has that "professional" air to it, rather than the rather hackish backend hidden behind a nice PNG and some bash scripts that the user gets at the moment.

As a first step, I have integrated the "select a game" menu supplied by juanvvc into the main code. This is now just seen as "another type of menu" by the game, so it works much more closely and was a good way to see what sort of functions I need to have. This meant almost a complete re-write of that code but it now uses all the in-game functions to do its job rather than being a tagged-on executable that runs a script, that runs an executable to actually play the game. You won't notice, except that there are some tiny cosmetic changes such as the menu now showing the version number and being "part of" the main program.

Now one program is distributed and run, and the switch in and out of games is nigh-on instantaneous (However, it was pretty damn impressive before!). The Palm port was always the inspiration for this - it uses a so-called "Combined" executable (as does the MacOS port) that has all the games in it. That's now how the GP2X one works, too (after a massive migration from single-game-per-executable to monolithic-executable-that-can-only-run-one-game-at-a-time to the current "proper" combined monolithic executable). Additionally, it means that the "join" between the menu and the games is seamless - so, for instance, a music track could play across both without needing a jolt in between.

It does add a lot of complexities, though. For instance, it does mean that I have to check carefully for memory bugs because they will now accumulate if a player plays a long session of several games without quitting out of the thing entirely. I've already caught quite a few bugs that wouldn't have bitten people on the old menu but bite the second you change in and out of different the games themselves. There are also games which require a resolution change mid-flight if you run them - no matter how you play with them, some games run better in 320x240 and some in 640x480, so the menu has to know about them and switch between them. Fortunately, that's already done and dusted (although for some reason my PC has problems doing that same thing - I must update my SDL libraries!).

All these changes mean, however, that a lot of extraneous files and code can disappear and also that a lot of in-game facilities can make it back out to the menu. I'm hoping to eventually ship just one executable and the associated PNG's, helpfile TXT's and a single menu datafile. If I can manage it, I'd like to put everything but the executable into a single file (probably a ZIP or something) purely so that I can ship the minimum amount of files necessary.

The other thing that I'm working on as and when my mood changes is to have game "persistence". This was one of the things that working on the Palm port brought home to me - if you quit out of the game, you really should be able to go straight back to where you were just by running the program again. It's a bit like an "auto-save" whenever you leave one game and start another, or quit the game entirely.

It'll only work if you specifically leave a game, though, because otherwise it would involve writing to the SD card all the time which is something I want to avoid. Avoiding writes also means doing things like checking whether you've actually done anything to the game or whether you just hit the wrong game on the menu and then quit out straight away. If you didn't press a button, then there's no need to auto-save, which would save one "write" from hitting the disk. It also means that I have to be careful - what if that auto-save is corrupted, or what if it takes hours to load/redraw because it's a massive game? There has to be a facility for the user to ignore it. That means more menu options... All this adds extra code, simple though it may be, which needs careful positioning, checking and re-writing, so it all adds up. Like any big change, it'll be a option for people to turn off - for instance if they want to play on a write-protected card.

I also have some "bigger" items on the TODO list. One of them is to be able to stop a game halfway through generation. Unfortunately, this is quite a tricky one because the games are inherently designed to be single-threaded and non-interruptible while in generation (all the official ports suffer from this and the Palm port suffers especially badly). However, there are a few tweaks to the code that can be made to make them interruptible (even if it takes a few seconds for the interrupt to be "seen" by the program). It means adding code to each and every game, unfortunately, but I think it's a sensible thing to do because hitting a large Bridges game by accident could leave the user with no option but to kill the whole GP2X (or at very least telnet in and kill the process). That's an ugly way to play a game. And now that we have a nice integrated menu to fall back to, there's no reason it can't be done in a nice way.

I'm also pretty certain that the games just aren't drawing themselves properly, even though it's damn close. Other ports show clean lines on all resolutions but the GP2X has some overlap issues. This has been there since the start but I was always of the "it's playable" mindset before so I left it well alone. Unfortunately, without single-stepping the code or sitting down with some graph paper and manually following along, it's rather difficult to see where the problem lays. I'm guessing that there is an off-by-one error somewhere but there are so many "definitions" of the various graphics routines involved that it's hard to track down - does setting a clip rectangle of 10x10 at 5,8 mean that it extends from 5,8 to 15,18 or from 6,9 to 15,18 or from 5,8 to 14,17 or what? It looks likely that I misread something and made a small error between the translation of the puzzles concept of "clipping", "blitting", or "drawing" and SDL's concept of the same. This would fix such things as Solo's missing lines.

One of the other things I have added is massive amounts of debugging code, turned on by compiler options, which should be able to resolve such discrepancies once and for all. It's just a matter of running a debug-compiled version on the PC, capturing the megabytes of debug logs and then manually replicating them on graph paper to see what goes wrong and where.

Then, I have a few extra bits of "polish". I'm considering a musical background noise. I wouldn't normally bother but it's v1.0 and it's a very simple thing to implement. The games seem to have more than enough spare capacity to play music too (the Palm port is noticeably slower on similar-MHz models) and I've found a couple of relaxing background tunes on a Creative Commons site, so when I get bored of the dreary work, I'll plug in some code for that. I've also considered short sound effects for such things as entering a game, pausing it, pressing a menu, clicking within the game etc. None of these things will affect anything if the player doesn't want them - they will be easily turned on and off and may even be off by default.

There is also supposed to be a way to "write down" the definition of a puzzle, so that you can pass it to friends. This is implemented as "Copy" in the desktop versions of these games but I consider it a bit pointless in the modern age. If the GP2X could do Bluetooth or something easily then I would use it as a basis for a "Beam game" option similar to that present on many Palm games. As it is, I might implement it as a menu option purely because it's so simple to do (call one function, get the "answer" as plain text, display it on the screen) but I don't see anybody using it. With the new menus, it can be put there without getting in the way.

The puzzles also have "print" options, but I'm deciding to leave those out entirely because I very much doubt anybody would bother to print them off, and adding the whole Postscript-creation routines into the puzzles is a bit overkill for a function nobody will use and nobody can use easily anyway. You would have to "print" the puzzle to a PS, or possibly PDF, file on the SD card, take it to a desktop machine (which has its own port of STPPC which understands the same savefile format and can print direct) and then send it to a printer. Because it's achievable in an identical amount of time, with an identical process, just by moving a savefile over to the PC version, I'm leaving it out.

I'm looking at downclocking the GP2X when it's not being taxed (i.e. most of the time it's actually in-game or in the menus, but NOT during puzzle creation when the poor thing struggles along) but I've still to experiment and test this thoroughly (when testing, you want to get into the parts you know are buggy as quickly as possible!). There would be a problem if it decided to throttle itself back on a certain game which would actually benefit from going faster and so just frustrate the user for no reason. I don't know if and how it would affect battery life but I hope that running at a slower clock speed is actually better for power consumption that just idling at a higher clock speed. There is a lot of take account of, though, because the cursor-motion and input is tied to the speed of certain timers and it would be very bad if they started getting lagged or overwhelmed because of the number of events happening while it was running slower.

There are lots of other things that I want to do but they are either trivial, cosmetic, only affect the source code, or they really aren't worth mentioning. I don't know when v1.0 will be finished but it will be finished sometime - every time I find myself in a programming mood, I'm on the GP2X straight away. Every time I play the GP2X, I suddenly find myself hacking on the code.

All in all, STPPC2x has been great fun so far and it's only recently that I've actually figured out how to win all the games in it! I still don't succeed every time, and Tents and Blackbox are often the most surprising ones - you get to the end by applying what you think is perfect logic and then you just cannot fathom the answer. Sometimes you can get it by restarting that same game but sometimes you just have to reach for that Solve option and then you start kicking yourself!

I do want to get out a v1.0, something to say "this is a real port of the games", I want it to be polished, I want it to be complete and I want it to stick around with the GP2X. Probably nobody else will continue the port to other platforms based on this particular code (although a couple of people have borrowed the early SDL code that got the games to a playable state for things like PlayStation Portable ports etc.) because there's such an abundance of power in modern consoles to just run the original versions or simple modifications - there are even Java ports of the collection now. But to have hold of a classic games console, quite rare, quite unique, very open, and to have a copy of a polished port for it that I know I wrote - that's something I want to be able to do. I don't care if nobody ever downloads it or nobody else owns the hardware to run it, but I'd like to be able to show it to people and say "I did that".

In twenty years, I want to find my GP2X in a dusty old box somewhere and spot an SD card with "STPPC2x v1.0". I want to plug it in and show any kids I have: This is what I did. This is how we used to make computers work. This is the code and tools I used to do it. This is what a lot of companies "these days" try to make you think is done in a magic box at Microsoft. Look, despite it being 20 years ago, I can still load this stuff up, I can still know how it works, I can still fix it when it goes wrong. Let's have a quick game of it before I put it back.

Monday 30 June 2008

STPPC2x Beta 5

The next step on my efforts to port Simon Tatham's Portable Puzzle Collection to the GP2X. This is now a set of 30 addictive logic and puzzle games (3 are new to this release!). Some are old favourites (like sudoku, sliding puzzles and minesweeper) and others you may not have seen before. An awful lot has changed in this release, not just some extra games, so make sure you read this whole thing!



You can download BETA 5 of STPPC2x immediately from the main website: http://www.ledow.org.uk/gp2x/ or from the GP2X archive (which may take a while to change from Beta4 to Beta5).

PLEASE NOTE: This release is a bit of a leap in how the collection operates. It is recommended that you create a new folder for this version - the directory structure has changed significantly. INI's and SAV's from previous versions are, of course, still compatible but may need a little renaming (same_game.ini to samegame.ini or rect0.sav to rectangles0.sav, etc.)

So, what's new? First, we have a fantastic menu drawn and programmed by juanvvc:



Many thanks to juanvvc for the great work on that, I think it really makes the collection look much neater and more professional. In fact, it works so well with the games that it is now the default menu, even on my own GP2X. Eventually, it'll get merged into the program itself so that there's just one piece of code for the whole thing.

The games are now just one program and one menu to run that program. If anybody still wants to be able to run each of the games individually as they did before, give me a shout, because I still test the games individually on my own machine. If there's demand, I can do two different releases - one with a single executable, one with an executable for each game.

There are also three new games: Slide, Sokoban and Maze 3D.

Slide is an "unfinished" game from the original collection that, as far as I can tell, is working perfectly but can be a bit slow to generate new games (if it takes a *long* while to startup or make a new game, don't worry - it hasn't crashed, it's just slow! I had to make a loading screen just so that this game doesn't make people think it's crashed!).

The object of the game is to slide the highlighted piece into the gated area by moving the blocks around. It sounds easy but it's not!



Sokoban is another "unfinished" game. I'm sure you have all seen this before - push each of the brown "crates" onto one of the circled areas. It is working perfectly but the levels it produces are randomly-generated and therefore usually very simple. But it plays well, so why not.



Maze3D is a third-party game from Eddy Macnaghten. You have to find your way through a 3D maze (2D if you change the options) to find the yellow sphere exit. It can be a little confusing at first. I recommend that you play mazes with "height" of 1 (i.e. a 2D maze) to get the hang of it, before trying smaller 3D mazes (e.g. 3 x 2 x 2, the smallest possible size). You can happily play up to 20x20x20 mazes (it's actually surprisingly fast to generate them), but you'll never find your way out of one that big without the help of the "solve" function, which puts a yellow thread on the screen which you have to follow to find your way out!



Maze3D isn't perfectly suited to the GP2X (it really needs a larger screen, and a better control system) but given that the code for it was last written in January 2006 and that I had to change one (trivial) line to get it to work on the GP2X, it's amazing it works at all! I also tweaked the code a bit more to allow me to put it neatly into the collection and to adjust the colours slightly.

I think Maze3D shows the power of these games as not just "a collection" but an entire puzzle game API that can be used to write lots of different games and get them ported to many platforms simultaneously, without having to write a single line of machine-dependent code. If anyone knows any other third-party games that use this puzzle engine, please shout. If anyone writes a new one that uses this engine (there is example code, documentation and I'll even give you a hand), shout louder!

STPPC2x has also been relicenced as GPLv2. This allows me to add in some useful code from various places. This was prompted by juanvvc thinking the collection was GPL and ended up with me deciding to change the license to GPL!

This beta now has 29 fully-working games, the only remaining one is completely unplayable on the GP2X - mines, a minesweeper clone. Don't run minesweeper - it'll crash. And yes, it's annoying the hell out of me as well that it doesn't work yet.

The full changelog from the previous Beta also includes items such as:

- A single monolithic executable for all the games.
This drastically reduces the size of the collection (from 17Mb to about 3Mb - mostly due to the fact that each game carried 0.5Mb of static SDL code with it). And eventually I'll be merging the menu with the games directly (at the moment, the menu spawns the games individually from the monolithic executable).

- A new "loading" screen because the new game Slide can take forever to load initially and people might think it has crashed.

- Several optimisations to try to reduce CPU use including: Faster and threaded events code, more compiler optimisations, making the main loop sleep a bit more, tricks like the loading screen to make people "think" it's faster, etc.

- Changed the background colour (well, I had to keep juanvvc happy after he made the menu for me!).
White lines are now more easy to see in Bridges, Inertia etc. The GP2X is just colour-inaccurate and the colour difference never showed up properly before (if you tilt the GP2X screen up on the older versions, you can see the white lines were always being drawn but showed as nearly the same colour as the background). I also had to change Maze3D's default colours because on a PC they look fine and on the GP2X, they all look white!

- Lots of tiny interface updates

Feedback is appreciated (especially from F-200 and USB mouse users) and full source code is available from:

http://www.ledow.org.uk/gp2x/

Note that this is an unofficial port - so please don't bother Simon Tatham with any problems, although he is aware of the project's existence.

There is also a "development blog", which will contain articles about developments to come etc. at http://stppc2x.blogspot.com

Monday 2 June 2008

Beta 5 Sneak Preview Screenshots

Sneak previews of Beta5. Enjoy!







Sunday 1 June 2008

Development update

I *am* still working on the collection!

In fact, there's a lot of exciting stuff going on, but I've been holding off on a release until they are ALL ready. I had a slight hindrance of a few hours work being lost but I've managed to recover or reproduce all of it without any problems (and even fixed a problem or two that I knew existed in the lost code, because I was able to start from scratch!).

Some sneaky news to keep people's interest:

New games. (!)
New menu for all the games.
New folder layout.
Better colours (so you can see elements clearer).
Interface cleanup - unsolveable games tell you so, games that can't enter numbers won't let you, made the first load of the in-game menu much quicker etc.

The current release-stopper is F-200 compatibility - I have an accurate way to reproduce all the issues seen with the F-200 touchscreen but it takes a lot of time to test each revision. Also, I'm holding back to see what's going on with the new model F-200's with regards to video/touchscreen co-ordinates being different. I still haven't fixed mines, either, and my patience is wearing out with it.

Anyway, I'm hoping to get a release out soon, even if it doesn't have F-200 touchscreen compatibility. So hang on. I'll get there.

Thursday 15 May 2008

SDL Events and the F-200 touchscreen

It's always the way. Fixing one problem creates several more.

The F-200 touchscreen was stalling because the event queue in SDL (or at least the latest ported version of SDL to the GP2X) is, basically, naff. So instead of getting useful information when the queue was full, I got hundreds of identical MOUSEMOTION events with the same co-ordinates, and it skipped lots and lots of BUTTONPRESS, BUTTONRELEASE and other events that were vital. Surely the wiser thing for the SDL library to do would be to discard all MOUSEMOTION events except the last when the queue is going to overflow, or at least discard *identical* MOUSEMOTION events? You're not going to get "smooth" movement over every pixel you touched anyway, because the queue has overflowed, so why not just trim the queue of useless messages and keep the vital ones?

Anyway, moving to EVENTTHREAD functionality (where a thread is spawned at program start to do nothing but handle checking for events) seems to "fix" the problem and you get touchscreen movement that reports the motion of the stylus properly. Unfortunately, it also significantly increases the latency of all events, including mouse, joystick, timer and touchscreen, when the queue is as busy as it was before. The difference is extremely obvious - without it, the code works fine for everything but touchscreen perfectly well, with it, everything just slows to a crawl but touchscreen works. Dragging a circle in untangle, for instance, literally takes a second or so for game to actual catch up with your motion.

However, I have read of several fixes for that and there's some abstraction of code that can be done to improve the situation, so it's not a big problem - it's just a matter of trimming the code that needs to be executed when events are recieved and sorting out the timing a little. I have a number of fixes that can be implemented:

1) Bob Pendleton's fast events
2) Merging of the mouse timer and game timer into a single event that handles both (should cut the events by about 40-50 per second but they do a lot of work each)
3) Optimising all in-event code (and so hope to get rid of events quicker)
4) Optimising code generally (with the compiler, profiling etc. to get rid of events quicker)

I'm hoping that only the first is necessary. At least now things are reported as they should be and giving expected behaviour. I could never comprehend why touchscreen events bothered to fire if they were MOUSEMOTION to the exact same pixel as the last MOUSEMOTION with no difference in buttons or co-ordinates.

Anyway, the next Beta (dare I move to v1.0 status without mines working?) is shaping up to bring in a lot more users - the menu from juanvvc makes it look a lot better, works much easier and will, I hope, be an integral part of one humungous executable that can run all the games willy-nilly. And hopefully F-200 users will finally be happy (although only one of them - Morgushong - has officially bothered to put in a bug report about this problem).

I'm also setting up an SVN server so that more people can get at the code in an easier fashion. Currently, even my own source control is getting a bit out of hand, with BETA's, public releases, debug builds, testing of various ideas, backups of working code etc. so I need to move it to a more logical format.

Monday 12 May 2008

User-contibruted menu! Thank juanvvc!

Well, my pleas for a nice menu for STPPC2x weren't falling on deaf ears after all. I was recently contacted by juanvvc who has made a fantastic menu for the games that works really well. With his kind permission, I'm going to be including it with the next BETA because it's just so damn useful that within minutes of trying it, I'd modified my whole build environment to use it and put it on my own GP2X to run the games.

So, thank juanvvc for not only giving you a great piece of work but also doing it in such a way that he's been kind enough to provide source for everything included and permission for it to be tied in with STPPC2x. We're going to iron out a few wrinkles first (nothing technical or "wrong", just a few personal preferences of my own) and then it'll become part of the main code.

This will, however, mean that the next version of STPPC2x will have a slightly different directory structure, so you might want to install it into an empty folder and then copy across your INI/SAV files from the older BETA's if you want to keep them. Trust me, though, it'll be worth the effort. I'll post a screenshot when I can get around to it and I'm in the middle of making some a SWF movie to demonstrate the menu, the games and the configuration so that people can see how the newer BETA versions have improved since the first versions.

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.

Tuesday 29 April 2008

BETA 4 News

Okay, BETA 4 is taking a little longer than I want it to but not for any particular technical reason, I'm just doing other things and chasing stuff that's not "visible" to users (e.g. I've been working on game saving for ages but none of the BETA's have yet had any code related to that in them). Mostly refactoring stuff so that the code is more readable and a bit more structured, debugging is simplified, and the menu drawing code isn't *quite* so horrible as it currently is.

When it *does* arrive, it'll have:

- Centered puzzles on the screen (finally - sorry it took so long)
- "Save Default Config" - pressing X on the pause screen saves that configuration (provided it is a valid one) into a human-reabable INI file, which is loaded each time the game is first run. Removing the INI file reverts to the game defaults. On unwritable systems (e.g. write-protected card or one where you don't want to save the config), the game just uses the current defaults but still lets you change them (obviously you can't save them in that case!)
- "Save Game" - You can save the current state of a game (not just the config) and resume it later. At the moment, it's more of a "quicksave" in that there's only one save slot that you can save/load. Handy, though, if the battery light starts to flicker, you can just hit the save option and resume it once you've changed the batteries.
- Tweaked the font sizes etc. a bit
- Mouse acceleration (primitive but it works)
- A couple of memory leaks plugged, a couple of minor bugs fixed, a bit of memory saved.
- Fixed a stupid bug where pressing Solve while you were paused buggered up the screen a bit.

There is one INI file per game, that gets created when you press Save if it doesn't already exist. If you don't press Save nothing is ever written to your SD card. As soon as the INI file is written, the cache is flushed so that the data hits the disk ASAP. Once you get a message to say it saved successfully, it should already be on the disk.

Everything will be saved into these INI files - Saved games (yes, you can save a game into an INI file), Settings, "Presets" (saved blocks of settings), help text, the lot.

The savefile format is plaintext (which gets "INI-ised" when it gets saved), so it's even "editable" from outside the game. Basically it consists of a complicated string to describe the starting point, options, size, game, etc. and then a list of moves that have already been made. The game "replays" the moves when it loads and you end up where you left it. I think I may have to disable access to mines, though, because it's still doing weird stuff and I don't want people to press Save while the game is in a weird state - the game may throw a wobbler when you try to write out a weird save state. Savegames are tiny - you can happily save dozens in each game without adding to the size of the folder noticeably.

Loading in a weird game state isn't a problem - the INI parser library just ignores any rubbish in the file and passes on what it can. The games then each check that the savegame / options are completely valid before they try to play them. This is to try to stop people loading corrupt save games, or those that have been "played with".

I'm trying to avoid playing with the menus at the moment because that code is getting a well-deserved shake-up but once it's done, I hope to introduce more save slots and a way to change between them, and a way to save configuration presets. That may or may not be in BETA 4 depending on how quickly the work progresses and how well I can squeeze them into the menus.

Friday 18 April 2008

Unicode, font, SDL and graphics.

I have just added the feature to allow people to configure the games in STPPC2x. On the way, knowing that my graphical design skills are somewhere in the realm of a small five-year-old with a large crayon, I wanted a quick way to "pretty" up the interface without having to draw anything myself.

I needed a checkbox, which is quite an easy thing to draw anyway. I wanted one that I could tick, cross or leave blank and which wouldn't look like I'd drawn a square box around a poorly fitting line-based cross or tick.

In the end, I looked at what resources I already had included in the project (allowing code re-use, not to mention keeping necessary dependencies to a minimum) and I already had SDL_ttf and the DejaVu font. The font was a random choice because I just wanted a "free to distribute" font that was small and easy to read, but it turned out to work very well.

Hidden away in the depths of the Unicode specification, there are a multitude of symbols that hardly anyone ever uses or even sees. These, apparently, include things like several styles of cross/tick (including "ballot" styles, made to look like a hand-drawn cross/tick), chess figures, dominoes, dice, and all manner of symbols, logos and signs. The mathematical symbols were also out of this world, line-drawing characters, "disabled" symbols, you name it. There are even circled numbers and letters, which prevent having to "guess" how big a number is going to render, fudging the font size and then circling it manually.

As it turned out, the DejaVu fonts have remarkably good Unicode support (the only other real competitor that I have personally seen is Arial Unicode, but obviously there are distribution problems with that one) and included all of the symbols that I felt like using.

But someone could easily write a board game, or avoid spending hours recreating a symbol in a vector format, using the Unicode characters, precise sizing and the DejaVu font. And, obviously, being a font it scales well to all sizes, can be coloured etc to your heart's content and can be rendered inline with text without causing problems. And the DejaVu fonts only take up half-a-megabyte, if that, and contains thousands of pieces of "clipart".

So, with SDL and SDL_ttf, it was simply a matter of changing my conservative SDL_RenderTextSolid to SDL_RenderUTF8Solid and figure out how to include the characters in a C string (Gucharmap on Slackware Linux was a big help here because it gives you the C escape codes for the UTF8 versions of any character in a Unicode font). No more memory is used, no more code is needed if you already have font-rendering code in there, and only a tiny amount of disk space is used for the whole thing. It was a great find and it's improved the look of the menu I was writing immensely.

Thursday 17 April 2008

More Pre-Beta 3 news.

Okay, BETA3 is nearing.

- Help and instructions for the games are included in a basic form (basically a text file printed to the screen). In later versions I may include further windows with general controls and pretty graphics, but for the moment, you can press "Help" under the Pause menu and you get the snippet from PUZZLES_QUICKSTART.TXT that I wrote for the first beta. The text files are editable and once BETA 3 is out, people are welcome to submit an explanation for any game that they think they can explain better (Plain text, 60-columns max, 20 lines max, don't use spaces or tabs for ASCII art).

- Game configurability is in, again in a basic form and I'm working on making it prettier without adding more rubbish into the executables (Unicode dingbats and the Deja Vu font are helping a lot!). All three types of option work ("string", or selecting a number, "boolean", ticking true/false, and "choose", selecting from a dropdown list of predefined options). You can configure all the games but sometimes a particular game has too many options and one or two go off the bottom of the screen ("net" is one culprit - you can edit size, difficulty etc. but not an option on the very bottom), and sometimes you have to select a "probability", between 0 and 1 - that's a pain that I have to manually detect and counteract on a per-game basis (Yuck!). But you can quite happily play and configure virtually all the games to your heart's content. I'll probably leave the fix for the "off-the-bottom" options until another BETA because it requires a revamp of the menuing system.

- Pause menu, which has taken the functionality of New Game and Restart Game out of the Start/Select keys to stop accidents. This is also where configuration, help, etc. can be accessed without affecting the game. If someone has a nice FREE (as in Creative Commons or better) background that would work with black or white text over it, I'd look into the possibility of using that as the pause menu background.

- Background colours have been tweaked ever so slightly. Most people probably won't even see the difference.

- CPU usage is reduced, but you may not notice because it's in areas that don't affect display. I'm hoping to clock down the GP2X quite low when it's on the Pause menu and when the game isn't doing anything (i.e. no animation timer activated, no clicks received) in order to save people's battery life.

- Executable size is significantly reduced. The games are about 50% of the size of previous Beta's with no loss of functionality or visible increase of startup speed. This saves about 15 or more Mb of the size of the total collection when put onto the GP2X, but you won't notice a difference in the already-ZIP'ed download size.

- Patched a couple of possible memory leaks/segfaults that were plaguing post-Beta-2 versions.

I've got a few more prettifying things to do, but I have these on my own GP2X F-100 that I take to work every day and they are very solid and the configuration works really well.

Tuesday 15 April 2008

Some more news on the STPPC2x front:

Beta 3 will hopefully contain help and instructions for the games. If it takes too long, I'll be pushing that back so that people get to use the new configuration menu system first. I was going to use the existing puzzle instructions and some Wiki graphics for controls to help this along but nobody's quite sure of the license for the wiki graphics and the existing instructions are probably too long.

I'm aiming for a single window per game, accessible from the normal pause menu, which gives you the basics for that particular game (How to play) and a single generic window specifying information common to all games (Controls, how to pause, quit, etc.). It would most probably be a text file for the game, so new games can have instructions written by anyone. Unfortunately, it would have to be manually updated for each game which is a bit of a pain, but you can't have everything.

I was *toying* with the idea of some background music (obviously, with an on/off switch) but I don't know if I want to waste my time on that. It started when I thought that a "mouse-click" sound might be a good idea to put into the game. It seems incredibly simple to do, especially with SDL_Mixer, but I usually hate such unnecessary padding.

My plan, if I do implement sound, will be to have, in this order of importance:
An on/off switch for all sound.
Volume control for all sound.
Music in the menus, sound in the game.
A basic MP3/Ogg file in the game folder that people can change to their hearts content (e.g. "backgroundmusic.mp3", "clickeffect.mp3", etc.) so that if they prefer a different tune, they can have one.
A free (Probably creative commons) piece of music and sound effect included with the download (ideas welcome - but with my playing, probably the Mission Impossible theme tune would be best... )

I'm planning to look at saving/loading of games for Beta 4. It's annoying to get through a large game of bridges, only to have the battery die and you can't get it back. Saving/loading looks simple (the puzzles tend to do everything necessary except actually open the file and write to it) but it's the *first* line of code in the games that writes to disk, so I want to be incredibly careful. I'm not sure how it would work just yet but probably it would save to a sequential filename (e.g. net0001.sav, net0002.sav, bridges0001.sav etc.) each time you save and present them in reverse order for loading (sadly, there is no RTC on the GP2X otherwise I would have them named with the date).

CPU usage and speed is also on my list for the next Beta (although Beta 2 made tremendous leaps in that area especially where puzzle creation is concerned) - I'm setting up a code profiling system at the moment so that I can find the hotspots in the SDL code. For sheer number-crunching, the latest GP2X code can generate a 30x30, Hard, 4-bridges-max game of bridges in the same time (or less) as a 600MHz laptop, so I don't think I'm doing too bad on that front (a credit to ARM processors!). The display/animation is a little slower because of software drawing/scaling but the games have adjusted to take account of that since day one (you get less fps when it's animating a move than you would on a PC) - hardware acceleration would solve that problem but it has its downfalls too. Ideally, I'd like to be able to clock the GP2X right down to 66MHz when it's not generating a game or performing an animation (which is about 99% of the time it runs for).

Also, executable size is up for a revamp - I already have #define's for things the GP2X doesn't need, and I strip the executables but I think there's a lot more I can do to shrink them. There is some unnecessary but *seemingly* used code in them which the linker/strip doesn't like to remove, there is no end of fancy tricks to reduce the size including using an executable compressor like UPX on them. There are other things you can do but they all tend to cost you more in terms of memory (even UPX is an initial memory usage vs executable size trade-off), such as zipping the fonts, etc. Even if I save myself, say, 10 Mb on the entire collection without visible differences, I think it's worth the effort.

Anyway, look out for Beta 3 coming "soon", with game configuration menus, pause and (hopefully) instructions inside the game.

Sunday 13 April 2008

Teaser snippet from the Changelog for the next Beta 3 (not released just yet, a few more tiny bugs to iron out):

2008-04-13:
- Implemented pause on the Start button.
- Implemented game-independent colour routines to define black and white for text no matter
what the game uses, so that the status bar always shows up.
- Added game configurability for all games under the Pause menu.
This greatly increases the potential of the puzzle collection and lets you configure
the types of puzzles in all manner of ways. So you can play bridges on a giant board,
cube with an octagon, dominosa with more dominoes, solo in a number of different ways,
net so that the board "wraps" and a million others.
The Pause menu hides all the confgiuration, and you have to start a new game from there
for the options to take effect. The games will tell you if you have set options
incorrectly, e.g. tried to play on a -1 x -1 board etc.
Most games work flawlessly with the options, but some are still flaky because:
- It really needs scrolling for the games with more options (e.g. bridges).
- Some games want you to be able to enter non-integer numbers (e.g. 0.1) but
it's almost impossible to distinguish them from the frontend.

Yes, you can change, width, height, difficulty and every setting possible in the games to suit your taste.
It all "just works", the screen shrinks down and does what it's supposed to do, so don't go too mad and
try and play 30x30 bridges on the GP2X because the chances are that you won't be able to see anything because it will all shrink to fit.

You'll even be able to try new versions of Solo that so far only the SVN version has (so they are not even available in any "official" release from the author himself yet! :-)

Oh, and if you think this port was worth the time and effort you had to wait for it, please have a quick look at my website where you'll find a "donate" button. Got £0.87 left in your Paypal from your recent eBay refund? Why not send it to a programmer!

Wednesday 9 April 2008

Beta 2

New beta 2:

STPPC2x Beta 2

Monday 7 April 2008

Just thought I'd give people an update since STPPC2x Beta 1. The following features will make it into BETA 2, which would almost be v1.0 if it wasn't for mines not working at all - the only game with remaining gameplay issues.

2008-04-07:
- Fixed map's and inertia's drag-drop display problem.
I'm a pillock. Having your source and destination the wrong way round means
that any amount of checking of your parameter values is useless if you don't
check the ORDER of arguments as well. I still say that the functions use
a "backwards" nomenclature for "blitter save/load" but once I switched them
around, it all started working properly without any other hassles.
- Fixed pegs and sped up all games by putting screen updates in the right places.
I'm still a pillock. Although it still draws lots of primitives, we *now* don't
update on every one of them, just the final "drawing". So instead of many
intra-frame updates, we get one end-of-frame update. The documentation wasn't
at all clear on this but I should have debugged it properly earlier.
Also, implemented proper "partial updates" instead of full updates all the time.
- Implemented re-use of loaded fonts.
Increases speed of text games at a cost of memory. I didn't do this before for
debugging reasons and because it worked without it but for the sake of completeness
it now keeps copies of fonts in multiple sizes in RAM in case it re-uses them rather
than constantly load/destroy/load/destroy fonts as the sizes in use changes.
It still doesn't distinguish "types" of fonts (monospaced etc.) but that's only a
minor addition.
- Better descriptive text for errors/startup.
You won't see them unless you are using Sterm / Telnet to run the games but when
something goes wrong, you're more likely to get a useful error message.
- Removed a few bits of unused / unnecessary SDL code.
e.g. initialising audio, overzealous locking, freeing of surfaces that get freed
anyway,...
- Tested code with proper hardware accelerated surfaces.
Little to no performance difference but strange problems related to dragging in
untangle, for example, which gives "jittery" cursors when using page-flipping.
Reverted until cause can be found (not a high priority given the small advantage).
- More error checking and bailing out with a nicer error on certain failures.
e.g. fonts not being present, blits failing, etc.
- Looking again at mines quickly but it's still weird.
- Made sure that the cursor doesn't linger after the game has quit.

Tuesday 1 April 2008

I've just fixed another round of bugs/new features:

- I now have working "status bar" display, so you can see how many moves you've taken, whether you've completed the game or not etc. The same code will be used to display which number is currently selected for input in filling, solo and unequal.

- I've just found an incredibly stupid bug of mine that was loading a font every time it was used without closing it properly (a code path problem that I hadn't noticed). This meant that "fifteen" was getting to about 50 moves and then running out of memory (50 x 20fps x [number of characters in game] x [size of font characters in RAM] x [probability that it would take the bad code path] > [RAM in GP2X]!). How it survived for so long, how it didn't show in other games, how it doesn't make the machine run out of memory quicker, I have no idea. But quitting the game made it clear up after itself and you could run it again or load any other game without problem!

That's now completely fixed and I've gone through the whole code again looking for missing/skipped free's and close's to make sure it doesn't happen with anything else. SDL does a damn good job of clearing up after itself anyway, so memory leakage isn't a problem if you quit a game and then run any other, but I don't like stray pointers. The games don't write *anything* to "disk", i.e the SD card or NAND, but that's no excuse for not checking that everything frees itself properly. I thought I'd been particular careful but apparently my wife makes a very good bug-finder despite never having coded in her life.

- I've linked against Paeryn's SDL libs instead of the default Open2x and it appears to work absolutely fine. However, this opens up the possibility of using hardware accelerated surfaces to do fancy zooming tricks and work the F-200 touchscreen without having to change any code. Again, people with actual F-200's would need to test to make sure. This also allows "panning" of the game area, although I haven't implemented that yet. So, in theory, you could have a 640x480 playboard and move around it by touching the edges of the screen. This would make "pattern", in particular, much easier to play.

- The mouse is now much smoother and faster but still seems to have problems with the way it moves on F-100 at least. You should now be able to switch between left/left-up/up without problems but on the F-100 it sometimes stops for no reason and you have to press the direction again. I've tried several of the "joystick biases" from the Wiki but I can't stop it happening. Anyway, it's much more comfortable to play now.

The following are not implemented (deliberately) on any game but usually run to no more than a handful of lines of code each, plus a GUI to do them in:

- Saving/loading functions (I don't like writing to other people's disks from C... However, the games automatically save/load themselves to an ASCII string using built-in functions and it's just a matter of putting that string somewhere and then letting the user get that string back... that will almost certainly involve GUI work which I'm not interested in doing, or passing command-line parameters from a menu with a GUI that I'm not going to make either)

- Clipboard functions (GP2X hasn't got one!)

- Changing game parameters, like size, difficulty, etc. (a simple matter of querying the midend for parameters available, collecting the parameters from the user and passing to a function... this is all code that isn't affected by my SDL code but someone would have to design an SDL menu that adjusts to each game or another way of presenting the user with a list of options and passing them to a function. I have tested it briefly and the games will automatically adjust to the size and difficulty specified as that is all done within the game code, not the display code)

Icons inside the executables (I can't be bothered to figure out how to do it, but there are .png icons already supplied with the game and I'm really not that interested, especially because I run the games through wrapper scripts which can't have icons! And people using things like GMenu2x or similar can just use the game's icons, I assume).

I'll be submitting a "beta" version of the entire collection once I've had a few more attempts at fixing the outstanding problems (mostly with mines, because that's the only one that's completely unplayable). That will most probably be synched to the latest SVN version as well but the only things that have changed since the revision I'm using are some MacOSX fixes, a tiny "fix" for code cleanliness and allowing you to "drag" and set multiple squares at a time in "filling", so it may not be worth it if it breaks anything at all.

The full collection is 27 games (Eek! I never realised it was that many). 22 are fully-working with just minor display issues that don't affect gameplay. 2 have drag-drop display issues (map, guess) that don't affect actual gameplay. 1 is incredibly slow but works (pegs) and I believe is down to the same drag-drop display issues but exacerbated by the dragged bitmap being larger. 1 sometimes has problems if you use a particular feature (bridges, locking an island with right-click) but it otherwise playable. 1 has fonts too small due to the nature of the size of the game (pattern) but if you squint you can read it. And 1 is unplayable (mines, quits safely on startup with an assert error inside the game code, not the interface code). I don't consider that a bad track record, personally, given that I've built a whole new frontend.

Monday 31 March 2008

For those following the development of these games, I've just fixed the following bugs and I'm gearing up for a release of all the games. Unfortunately, a few still have problems but I see no reason to hold back and do single-releases for much longer.

- You can now input numbers using the L and R buttons and X. This allows you to play filling, solo (sudoku) and unequal. Solo plays fine but unequal needs a specific fix because by default it only uses the numbers 1-4 as far as I can make out. As Solo needs 1-9, this is a pain and means I need game-specific code to make it work with the L/R/X control system. I just need to make something show what number you have selected because at the moment you have to put the number in to find out, then change with L/R. It stays on the same number until you press L/R though so numeric-input games are playable if you can remember a single-digit number.

- I've fixed a few bugs here and there related to mouse/keyboard input. Most people probably wouldn't have noticed as they only affected games that haven't been released yet.

- I've fixed the absolutey idiotic mistake of mine that makes the wrapper-scripts point to the wrong path (I'm a prat). The directory structure will change for the "full release" and I forgot to change it back for the individual release.

- Mines is giving me more problems than anything else, now, despite running perfectly within the development environment. For some reason on the GP2X it doesn't play correctly from the very first second, even though there is NO GP2X-specific code run up until the point it errors out with an "assert". I've looked at the code around the assert (which is in mines.c and I've NEVER had to do anything to the game code, only the SDL interface code) and I have no idea what's wrong.

Running mines on plain Linux with the exact same code, screensize, bit-depth, SDL libraries etc. doesn't give you any problems. It's either a very subtle timing bug or a problem with memory (but I would expect memory errors in that case). Mines, unfortunately, may have to be pushed to the back of the queue.

- I've made it so that L+R now quits, because it's easy to hit Vol+ accidentally if your finger slips off the control pad on the F-100 (I was SO close to finishing my game of dominosa!). I might change that to Vol- / Vol+ in future.

For the games not mentioned below, I haven't tested them thoroughly but they seem to play fine. I'll reserve judgement until I can complete a whole game on them just to make sure but I think they are all releaseable.

Bridges - I have a slight problem with "locking" squares but that just seems to be the way the game works. Once a circle is locked, it's a pain to unlock it. It can be finnicky on my Linux PC too, maybe the lower clock speed exacerbates the problem a little?

Cube - In a state that I could release it.

Fifteen - In a state that I could release it. Sometimes a little slow on animation - using hardware SDL surfaces or overclocking might speed that up but I'm not too worried as it just "skips" animation frames rather than slow the game down.

Blackbox - In a state that I could release it.

Tents - In a state that I could release it.

Pattern - font display a bit too small for some puzzles, but otherwise fine.

Dominosa - In a state that I could release it.

Flip - In a state that I could release it. Sometimes a little slow on animation, like Fifteen.

Guess - Drag-drop problems like Map but playable. I'll probably just edit the game code to remove the cursors, because I've tried lots of different things to stop it doing it and none of them have made the slightest difference.

Lightup - In a state that I could release it.

Netslide - In a state that I could release it. Sometimes a little slow on animation.

Rect - In a state that I could release it.

Samegame - In a state that I could release it.

Sixteen - In a state that I could release it. Sometimes a little slow on animation.

Twiddle - In a state that I could release it. Sometimes a little slow on animation.

Map - drag-drop display problems the same as Guess.

Pegs - drag-drop display problems the same as Guess but which also lead to an enormous slowdown when you drag, making it unplayable. This is the only problem with pegs, though.

Solo - In a state that I could release it.

Filling - In a state that I could release it.

Unequal - In a state that I could release it. Sometimes a subtle bug crops up.


Anyway, expect a release of all the games in their current state "soon". First, I have to fix the mouse once and for all, then get rid of the drag-drop problems that stupidly stop two games from working when the drag-drop display is totally unnecessary. Then I may add a few little touches such as showing the current digit for the L-R buttons, maybe a quick menu for all the games.

I'm also intending to do a full source release with the full collection, with full LICENSE files, a nicer directory structure, all of my build and test scripts, even the exact Open2X toolchain and libs that I used to get it all working.

At least one person wants to take that and try to port the collection to PSP using my SDL code.

Sunday 30 March 2008

"Net" released

Second release: NET!

The strange mouse behaviour has improved a little (and an update to untangle with the same changes has been uploaded too). Anyway, enjoy the second of many games from this collection!

http://archive.gp2x.de/cgi-bin/cfiles.cgi?0,0,0,0,25,2529

Saturday 29 March 2008

"Untangle" released

First release: UNTANGLE!

I had to change the schedule a bit after Net starting exhibiting strange mouse behaviour under certain situations, only on the GP2x. And bridges did something that I need to double-check but I think that's just me being a pillock. Anyway, enjoy the first of many games from this collection!

http://archive.gp2x.de/cgi-bin/cfiles.cgi?0,0,0,0,25,2526

Wednesday 26 March 2008

Okay, so it looks like the order of release will roughly be the following. I'm hoping to get them into some sort of distributable state over the Easter holidays, which for me is the next three weeks. Don't take that as fact, though.

Most tested and verified working through lots of complete games:

Net (most tested, works very well without any problems)
Bridges (very well tested, works very well without any problems)
Mines (user request, works very well without any problems)
Untangle (works very well without any problems)
Cube (works very well without any problems)
Fifteen (works very well without any problems)
Blackbox (works very well without any problems)
Tents (works very well without any problems)
Pattern (font display a bit too small for some puzzles, but otherwise fine) - I'm not too worried about this one given that the excellent GhostPix is the same type of game and infinitely better.

Only basic testing has taken place (i.e. I played with them for a little while by clicking around and checking things changed, and completed the ones that I was able to complete, without any major problems showing up) for these ones:

Dominosa
Flip
Galaxies
Guess
Inertia
Lightup
Loopy
Netslide
Rect
Samegame
Sixteen
Slant
Twiddle

These ones will have to wait until I have released most of the above due to some problem with them:

Map (drag-drop display problems make playing it very ugly)
Pegs (needs looking at to find a quite annoying slowdown when dragging that wasn't there until a few revisions ago, probably SDL Timer related - it looks like it's trying to draw circles over circles over circles as you drag the "mouse")
Solo (requires keyboard input of numbers, so I'll have to bodge that with GP2X controls)
Filling (requires keyboard input of numbers, so I'll have to bodge that with GP2X controls)
Unequal (requires keyboard input of numbers, so I'll have to bodge that with GP2X controls)

If anyone would like to suggest a mapping for the keyboard, or express a preference for right/left/middle click buttons on the normal games, I'd be open to ideas. At the moment, I'm using shoulder buttons but I think it might be easier long-term if I use the top three buttons (A,B,X?) of the right-hand side for "mouse clicks". L+R shoulder buttons will probably change numbers in those games that need them. Select will probably be "restart this game". Start will probably be "new game", with vol+/vol- being "quit".

I'm hoping that F-200 users will get touchscreen but I can't guarantee it as I don't have one (and, honestly, don't really care that much about it so long as it's playable in some fashion, although I am being careful not to use stick-click and other F-100-only features) - but if it's seen as an SDL mouse or it's easy to code, then it will be so. From the look of it, I can open a device file, read an entry and get X,Y co-ords which is enough for "click" but then I'd worry about how you'd right-click or middle-click (probably holding down the relevant button while pressing the screen but then that's more coding to differentiate between F-100's and F-200's and F-200 users who want to use F-100 style controls, etc.).

Changing sizes/difficulty of the puzzles will have to be done by supplying command-line parameters (so a simple menu system could take that away from the actual program executable quite easily), and saving/loading/playing a particular numbered game I really don't care about and stripped out, so all that code would have to be reintroduced by someone else. I suspect the easiest way would be to supply a command-line argument again.

In the future, users would have a "puzzle menu" (which could be quite a simple C / SDL program but I'm not going to write it) which would allow them to select games, change difficulty, size etc. and then run a game. When the game quit, it'd go back to the "puzzle menu". Without such a menu, these programs would have to be run inside script-wrappers if they are to re-execute the main GP2X menu. I'll include those because I care about that, but I don't want to get involved in making a "puzzle menu".