Wednesday, 4 March 2009

Simon Tatham's Portable Puzzle Collection - Code for my third-party Mosco puzzle

This is the code for the third-party Mosco puzzle I implemented for Simon Tatham's Portable Puzzle Collection. It can be incorporated into any of the official codebases (e.g. Palm, GTK, Java, etc.) just by putting the two files into the source code directory and re-running before recompiling. I'm putting this here because there aren't many out-of-tree third-party puzzles out there for the collection (the only one I could find was Maze3D).

The code is here:

And there are only two files, mosco.R and mosco.c. It has puzzle generation and a solver (admittedly naive) and should work on all platforms supported by the collection (tested on Linux, Cygwin, and my own SDL/GP2X port).

Saturday, 28 February 2009

Version 1.1

Ledow has released version 1.1 of STPPC2x!

The latest version of my efforts to port Simon Tatham's Portable Puzzle Collection to the GP2X. This is a set of 31 addictive logic and puzzle games. Some are old favourites (like sudoku, sliding puzzles and minesweeper) and others you may not have seen before.

You can download STPPC2x immediately from the main website or from the GP2X archive. The music pack is unchanged and can be downloaded from the main website too.

So, what's new?


Display - Show whether a game supports numeric input, a solver, etc. on the main menu, removed a couple of incorrect screen updates that could make the menu flicker, game preview images now centre properly (e.g. Maze3D's).

Gameplay - All games now have cursor-mode control, status-bar messages now "time out" rather than linger forever.

Input - Digit input for large games that need characters rather than just numbers.

Memory - Can now take advantage of the upper 32Mb of RAM should we ever run out of memory on the GP2X.

Screenshots - Now disabled by default, enable and press Stick-Click to use them.

Size - The size of the executable has been reduced by a number of means: removal of unused code, better final compression, shortening of static buffers, etc. Also, the images have been compressed more using pngcrush. This should save up to 500Kb on the GP2X.


Cube - Massive memory usage (spotted by me) now fixed (by Simon Tatham).
Dominosa - More presets.
Guess - Fixed potential crash.
Loopy - improve generation of "Great-Hexagonal" games, quicker solvers.
Map - "Show immutable regions" option now removed - you can just press Y and the regions that can't be changed highlight in red.
Mosco - Fix completion bug, add end-of-game flash, clicking on the edge tiles highlights squares that could "point" to them, non-square grids and new presets.
Solo - Show intermediate lines properly, enable 4x4 etc. presets, add "Killer" Sudoku mode.

Feedback is appreciated and full source code is available from: or

Monday, 12 January 2009

STPPC2x post-v1.0 update

Yes, I'm still working on it!

However, there were a few problems which meant I had trouble getting a working development environment up and running on a new machine - nothing drastic enough to stop coding but it turned from "must do" to "I'll get around to it".

Anyway, I am still coding and there's quite a few changes that have already gone into the main code repository (, but don't think that what you see in there is all that exists... I'm working on a few new features besides those listed in the previous post, it's just that it's a jumble of half-finished, specific-to-my-PC code that doesn't belong in SVN at the moment.

I won't be coding for Pandora, because STPPC2x is the only thing that I enjoy coding on recently and it would be pointless to port because Simon Tatham's original collection will run fine on it because it has full X-Windows support, but I will continue coding for the GP2X even if I'm the only person who actually uses my code! The Wiz is in a strange middle-ground... if I can get hold of one at some point, I may well port STPPC2x over provided it isn't too different from a programmatic point of view but I'm not going to buy one just to do that.

The Changelog at the SVN repository (latest version can always be found here: ) has the lowdown on what I've finished recently (it doesn't sound very exciting!) and I still use what-will-be-v1.1 on my own GP2X when I'm out and about (I do about 3 hours of train journeys every day and take my GP2X everywhere still - perfect for beta-testing!).

It aten't dead!

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 (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:

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.