Dariusz Olszewski's changes to support compiling for PocketPC. This

is mostly done with ifdefs in windows.c; so mkfiles.pl generates a
new makefile (Makefile.wce) and Recipe enables it, but it's hardly
any different from Makefile.vc apart from a few definitions at the
top of the files.

Currently the PocketPC build is not enabled in the build script, but
with any luck I'll be able to do so reasonably soon.

[originally from svn r7337]
This commit is contained in:
Simon Tatham
2007-02-26 20:35:47 +00:00
parent 3bfe0fb32e
commit 15f70f527a
24 changed files with 928 additions and 105 deletions

View File

@ -1,7 +1,7 @@
This software is copyright (c) 2004-2007 Simon Tatham.
Portions copyright Richard Boulton, James Harvey, Mike Pinna and
Jonas K<EFBFBD>lker.
Portions copyright Richard Boulton, James Harvey, Mike Pinna, Jonas
K<EFBFBD>lker and Dariusz Olszewski.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files

6
Recipe
View File

@ -10,6 +10,7 @@
!makefile gtk Makefile
!makefile vc Makefile.vc
!makefile wce Makefile.wce
!makefile cygwin Makefile.cyg
!makefile osx Makefile.osx
@ -89,6 +90,11 @@ version.obj: *.c *.h
cl $(VER) $(CFLAGS) /c version.c
!end
!specialobj vc version
!begin wce
version.obj: *.c *.h
$(CC) $(VER) $(CFLAGS) /c version.c
!end
!specialobj wce version
!begin cygwin
version.o: FORCE;
FORCE:

View File

@ -1431,7 +1431,7 @@ const struct game thegame = {
FALSE, FALSE, game_print_size, game_print,
TRUE, /* wants_statusbar */
FALSE, game_timing_state,
0, /* flags */
REQUIRE_RBUTTON, /* flags */
};
/* vim: set shiftwidth=4 tabstop=8: */

View File

@ -2662,7 +2662,7 @@ const struct game thegame = {
TRUE, FALSE, game_print_size, game_print,
FALSE, /* wants_statusbar */
FALSE, game_timing_state,
0, /* flags */
REQUIRE_RBUTTON, /* flags */
};
/* vim: set shiftwidth=4 tabstop=8: */

View File

@ -47,7 +47,6 @@
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
@ -984,9 +983,8 @@ static game_state *execute_move(game_state *state, char *move)
new_state->cheated = TRUE;
} else {
char *endptr;
const int i = strtol(move, &endptr, errno = 0);
const int i = strtol(move, &endptr, 0);
int value;
if (errno == ERANGE) return NULL;
if (endptr == move) return NULL;
if (*endptr != '_') return NULL;
move = endptr + 1;

View File

@ -3234,7 +3234,7 @@ const struct game thegame = {
FALSE, /* wants_statusbar */
#endif
FALSE, game_timing_state,
0, /* flags */
REQUIRE_RBUTTON, /* flags */
};
#ifdef STANDALONE_SOLVER

View File

@ -126,7 +126,8 @@ $(ICONS): %.ico: %-48d24.png %-48d8.png %-48d4.png \
# Build the .RC files which bind the icons into the applications.
$(RC): %.rc:
echo '200 ICON "$*.ico"' > $@
echo '#include "puzzles.rc2"' > $@
echo '200 ICON "$*.ico"' >> $@
# Build the GTK icon source files.
$(CICONS): %-icon.c: %-16d24.png %-32d24.png %-48d24.png

View File

@ -88,8 +88,11 @@ static game_params *default_params(void)
game_params *ret = snew(game_params);
ret->w = 10;
#ifdef PORTRAIT_SCREEN
ret->h = 10;
#else
ret->h = 8;
#endif
return ret;
}
@ -106,9 +109,15 @@ static game_params *dup_params(game_params *params)
}
static const struct game_params inertia_presets[] = {
#ifdef PORTRAIT_SCREEN
{ 10, 10 },
{ 12, 12 },
{ 16, 16 },
#else
{ 10, 8 },
{ 15, 12 },
{ 20, 16 },
#endif
};
static int game_fetch_preset(int i, char **name, game_params **params)
@ -1511,7 +1520,11 @@ struct game_drawstate {
#define PREFERRED_TILESIZE 32
#define TILESIZE (ds->tilesize)
#ifdef SMALL_SCREEN
#define BORDER (TILESIZE / 4)
#else
#define BORDER (TILESIZE)
#endif
#define HIGHLIGHT_WIDTH (TILESIZE / 10)
#define COORD(x) ( (x) * TILESIZE + BORDER )
#define FROMCOORD(x) ( ((x) - BORDER + TILESIZE) / TILESIZE - 1 )

View File

@ -12,6 +12,11 @@
#include "latin.h"
static void assert_f(p)
{
assert(p);
}
/* --------------------------------------------------------
* Solver.
*/
@ -26,7 +31,7 @@ void latin_solver_place(struct latin_solver *solver, int x, int y, int n)
int i, o = solver->o;
assert(n <= o);
assert(cube(x,y,n));
assert_f(cube(x,y,n));
/*
* Rule out all other numbers in this square.
@ -1188,7 +1193,7 @@ int latin_check(digit *sq, int order)
lcp = snew(lcparams);
lcp->elt = ELT(sq, c, r);
lcp->count = 1;
assert(add234(dict, lcp) == lcp);
assert_f(add234(dict, lcp) == lcp);
} else {
lcp->count++;
}

View File

@ -512,10 +512,12 @@ static const game_params presets[] = {
{ 15, 15, DIFF_EASY, 0 },
{ 15, 15, DIFF_NORMAL, 0 },
{ 15, 15, DIFF_HARD, 0 },
#ifndef SMALL_SCREEN
{ 30, 20, DIFF_EASY, 0 },
{ 30, 20, DIFF_NORMAL, 0 },
{ 30, 20, DIFF_HARD, 0 }
#endif
#endif
};
static int game_fetch_preset(int i, char **name, game_params **params)

22
map.c
View File

@ -100,8 +100,13 @@ static game_params *default_params(void)
{
game_params *ret = snew(game_params);
#ifdef PORTRAIT_SCREEN
ret->w = 16;
ret->h = 18;
#else
ret->w = 20;
ret->h = 15;
#endif
ret->n = 30;
ret->diff = DIFF_NORMAL;
@ -109,12 +114,21 @@ static game_params *default_params(void)
}
static const struct game_params map_presets[] = {
#ifdef PORTRAIT_SCREEN
{16, 18, 30, DIFF_EASY},
{16, 18, 30, DIFF_NORMAL},
{16, 18, 30, DIFF_HARD},
{16, 18, 30, DIFF_RECURSE},
{25, 30, 75, DIFF_NORMAL},
{25, 30, 75, DIFF_HARD},
#else
{20, 15, 30, DIFF_EASY},
{20, 15, 30, DIFF_NORMAL},
{20, 15, 30, DIFF_HARD},
{20, 15, 30, DIFF_RECURSE},
{30, 25, 75, DIFF_NORMAL},
{30, 25, 75, DIFF_HARD},
#endif
};
static int game_fetch_preset(int i, char **name, game_params **params)
@ -2517,10 +2531,18 @@ static void game_set_size(drawing *dr, game_drawstate *ds,
}
const float map_colours[FOUR][3] = {
#ifdef VIVID_COLOURS
// Use more vivid colours (e.g. on the Pocket PC)
{0.75F, 0.25F, 0.25F},
{0.3F, 0.7F, 0.3F},
{0.3F, 0.3F, 0.7F},
{0.85F, 0.85F, 0.1F},
#else
{0.7F, 0.5F, 0.4F},
{0.8F, 0.7F, 0.4F},
{0.5F, 0.6F, 0.4F},
{0.55F, 0.45F, 0.35F},
#endif
};
const int map_hatching[FOUR] = {
HATCH_VERT, HATCH_SLASH, HATCH_HORIZ, HATCH_BACKSLASH

View File

@ -28,7 +28,11 @@ enum {
#define PREFERRED_TILE_SIZE 20
#define TILE_SIZE (ds->tilesize)
#ifdef SMALL_SCREEN
#define BORDER 8
#else
#define BORDER (TILE_SIZE * 3 / 2)
#endif
#define HIGHLIGHT_WIDTH (TILE_SIZE / 10)
#define OUTER_HIGHLIGHT_WIDTH (BORDER / 10)
#define COORD(x) ( (x) * TILE_SIZE + BORDER )
@ -102,8 +106,10 @@ static const struct game_params mines_presets[] = {
{9, 9, 35, TRUE},
{16, 16, 40, TRUE},
{16, 16, 99, TRUE},
#ifndef SMALL_SCREEN
{30, 16, 99, TRUE},
{30, 16, 170, TRUE},
#endif
};
static int game_fetch_preset(int i, char **name, game_params **params)
@ -3103,7 +3109,7 @@ const struct game thegame = {
FALSE, FALSE, game_print_size, game_print,
TRUE, /* wants_statusbar */
TRUE, game_timing_state,
BUTTON_BEATS(LEFT_BUTTON, RIGHT_BUTTON),
BUTTON_BEATS(LEFT_BUTTON, RIGHT_BUTTON) | REQUIRE_RBUTTON,
};
#ifdef STANDALONE_OBFUSCATOR

View File

@ -284,7 +284,7 @@ sub mfval($) {
# Returns true if the argument is a known makefile type. Otherwise,
# prints a warning and returns false;
if (grep { $type eq $_ }
("vc","vcproj","cygwin","borland","lcc","gtk","mpw","osx")) {
("vc","vcproj","cygwin","borland","lcc","gtk","mpw","osx","wce")) {
return 1;
}
warn "$.:unknown makefile type '$type'\n";
@ -719,6 +719,114 @@ if (defined $makefiles{'vc'}) {
select STDOUT; close OUT;
}
if (defined $makefiles{'wce'}) {
$mftyp = 'wce';
$dirpfx = &dirpfx($makefiles{'wce'}, "\\");
##-- eMbedded Visual C PocketPC makefile
open OUT, ">$makefiles{'wce'}"; select OUT;
print
"# Makefile for $project_name on PocketPC using eMbedded Visual C.\n".
"#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n".
"# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n";
print $help;
print
"\n".
"# If you rename this file to `Makefile', you should change this line,\n".
"# so that the .rsp files still depend on the correct makefile.\n".
"MAKEFILE = Makefile.wce\n".
"\n".
"# This makefile expects the environment to have been set up by one\n".
"# of the PocketPC batch files wcearmv4.bat and wceemulator.bat. No\n".
"# other build targets are currently supported, because they would\n".
"# need a section in this if statement.\n".
"!if \"\$(TARGETCPU)\" == \"emulator\"\n".
"PLATFORM_DEFS=/D \"_i386_\" /D \"i_386_\" /D \"_X86_\" /D \"x86\"\n".
"CC=cl\n".
"BASELIBS=commctrl.lib coredll.lib corelibc.lib aygshell.lib\n".
"MACHINE=IX86\n".
"!else\n".
"PLATFORM_DEFS=/D \"ARM\" /D \"_ARM_\" /D \"ARMV4\"\n".
"CC=clarm\n".
"BASELIBS=commctrl.lib coredll.lib aygshell.lib\n".
"MACHINE=ARM\n".
"!endif\n".
"\n".
"# C compilation flags\n".
"CFLAGS = /nologo /W3 /O1 /MC /D _WIN32_WCE=420 /D \"WIN32_PLATFORM_PSPC=400\" /D UNDER_CE=420 \\\n".
" \$(PLATFORM_DEFS) \\\n".
" /D \"UNICODE\" /D \"_UNICODE\" /D \"NDEBUG\" /D \"NO_HTMLHELP\"\n".
"\n".
"LFLAGS = /nologo /incremental:no \\\n".
" /base:0x00010000 /stack:0x10000,0x1000 /entry:WinMainCRTStartup \\\n".
" /nodefaultlib:libc.lib /nodefaultlib:libcmt.lib /nodefaultlib:msvcrt.lib /nodefaultlib:OLDNAMES.lib \\\n".
" /subsystem:windowsce,4.20 /align:4096 /MACHINE:\$(MACHINE)\n".
"\n".
"RCFL = /d UNDER_CE=420 /d _WIN32_WCE=420 /d \"WIN32_PLATFORM_PSPC=400\" \\\n".
" \$(PLATFORM_DEFS) \\\n".
" /d \"NDEBUG\" /d \"UNICODE\" /d \"_UNICODE\"\n".
"\n";
print &splitline("all:" . join "", map { " $_.exe" } &progrealnames("G"));
print "\n\n";
foreach $p (&prognames("G")) {
($prog, $type) = split ",", $p;
$objstr = &objects($p, "X.obj", "X.res", undef);
print &splitline("$prog.exe: " . $objstr . " $prog.rsp"), "\n";
print "\tlink \$(LFLAGS) -out:$prog.exe -map:$prog.map \@$prog.rsp\n\n";
}
foreach $p (&prognames("G")) {
($prog, $type) = split ",", $p;
print $prog, ".rsp: \$(MAKEFILE)\n";
$objstr = &objects($p, "X.obj", "X.res", undef);
@objlist = split " ", $objstr;
@objlines = ("");
foreach $i (@objlist) {
if (length($objlines[$#objlines] . " $i") > 50) {
push @objlines, "";
}
$objlines[$#objlines] .= " $i";
}
print "\techo \$(BASELIBS) > $prog.rsp\n";
for ($i=0; $i<=$#objlines; $i++) {
print "\techo$objlines[$i] >> $prog.rsp\n";
}
print "\n";
}
foreach $d (&deps("X.obj", "X.res", $dirpfx, "\\")) {
print &splitline(sprintf("%s: %s", $d->{obj}, join " ", @{$d->{deps}})),
"\n";
if ($d->{obj} =~ /\.res$/) {
print "\trc \$(FWHACK) \$(RCFL) -r -fo".
$d->{obj}." ".$d->{deps}->[0]."\n";
} else {
$deflist = join "", map { " /D$_" } @{$d->{defs}};
print "\t\$(CC) \$(COMPAT) \$(FWHACK) \$(CFLAGS) \$(XFLAGS)$deflist".
" /c ".$d->{deps}->[0]." /Fo$d->{obj}\n";
}
}
print "\n";
print $makefile_extra{'wce'};
print "\nclean: tidy\n".
"\t-del *.exe\n\n".
"tidy:\n".
"\t-del *.obj\n".
"\t-del *.res\n".
"\t-del *.pch\n".
"\t-del *.aps\n".
"\t-del *.ilk\n".
"\t-del *.pdb\n".
"\t-del *.rsp\n".
"\t-del *.dsp\n".
"\t-del *.dsw\n".
"\t-del *.ncb\n".
"\t-del *.opt\n".
"\t-del *.plg\n".
"\t-del *.map\n".
"\t-del *.idb\n".
"\t-del debug.log\n";
select STDOUT; close OUT;
}
if (defined $makefiles{'vcproj'}) {
$mftyp = 'vcproj';

8
net.c
View File

@ -46,7 +46,11 @@
#define PREFERRED_TILE_SIZE 32
#define TILE_SIZE (ds->tilesize)
#define TILE_BORDER 1
#ifdef SMALL_SCREEN
#define WINDOW_OFFSET 4
#else
#define WINDOW_OFFSET 16
#endif
#define ROTATE_TIME 0.13F
#define FLASH_FRAME 0.07F
@ -150,12 +154,16 @@ static const struct game_params net_presets[] = {
{7, 7, FALSE, TRUE, 0.0},
{9, 9, FALSE, TRUE, 0.0},
{11, 11, FALSE, TRUE, 0.0},
#ifndef SMALL_SCREEN
{13, 11, FALSE, TRUE, 0.0},
#endif
{5, 5, TRUE, TRUE, 0.0},
{7, 7, TRUE, TRUE, 0.0},
{9, 9, TRUE, TRUE, 0.0},
{11, 11, TRUE, TRUE, 0.0},
#ifndef SMALL_SCREEN
{13, 11, TRUE, TRUE, 0.0},
#endif
};
static int game_fetch_preset(int i, char **name, game_params **params)

BIN
padtoolbar.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -1276,7 +1276,7 @@ const struct game thegame = {
TRUE, FALSE, game_print_size, game_print,
FALSE, /* wants_statusbar */
FALSE, game_timing_state,
0, /* flags */
REQUIRE_RBUTTON, /* flags */
};
#ifdef STANDALONE_SOLVER

View File

@ -67,8 +67,19 @@ enum {
#define BUTTON_BEATS(x,y) ( 1 << (((x)-LEFT_BUTTON)*3+(y)-LEFT_BUTTON) )
/* Flag indicating that Solve operations should be animated */
#define SOLVE_ANIMATES ( 1 << 9 )
/* Pocket PC: Game requires right mouse button emulation */
#define REQUIRE_RBUTTON ( 1 << 10 )
/* Pocket PC: Game requires numeric input */
#define REQUIRE_NUMPAD ( 1 << 11 )
/* end of `flags' word definitions */
#ifdef _WIN32_WCE
/* Pocket PC devices have small, portrait screen that requires more vivid colours */
#define SMALL_SCREEN
#define PORTRAIT_SCREEN
#define VIVID_COLOURS
#endif
#define IGNOREARG(x) ( (x) = (x) )
typedef struct frontend frontend;

65
puzzles.rc2 Normal file
View File

@ -0,0 +1,65 @@
/* Standard stuff that goes into the Windows resources for all puzzles. */
#ifdef _WIN32_WCE
#include <winuser.h>
#include <commctrl.h>
#define SHMENUBAR RCDATA
#define I_IMAGENONE (-2)
#define IDC_STATIC (-1)
#include "resource.h"
IDR_MENUBAR1 MENU DISCARDABLE
BEGIN
POPUP "Game"
BEGIN
MENUITEM "Dummy", 0
END
POPUP "Type"
BEGIN
MENUITEM "Dummy", 0
END
END
IDR_MENUBAR1 SHMENUBAR DISCARDABLE
BEGIN
IDR_MENUBAR1, 2,
I_IMAGENONE, ID_GAME, TBSTATE_ENABLED,
TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, IDS_CAP_GAME, 0, 0,
I_IMAGENONE, ID_TYPE, TBSTATE_ENABLED,
TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, IDS_CAP_TYPE, 0, 1,
END
STRINGTABLE DISCARDABLE
BEGIN
IDS_CAP_GAME "Game"
IDS_CAP_TYPE "Type"
END
IDD_ABOUT DIALOG DISCARDABLE 0, 0, 0, 0
STYLE WS_POPUP
FONT 8, "Tahoma"
BEGIN
LTEXT "", IDC_ABOUT_CAPTION, 4, 4, 150, 8
LTEXT "", IDC_ABOUT_LINE, 4, 16, 150, 1, WS_BORDER
LTEXT "", IDC_ABOUT_GAME, 4, 22, 150, 8
LTEXT "from Simon Tatham's Portable Puzzle Collection",
IDC_STATIC, 4, 36, 150, 8, SS_LEFTNOWORDWRAP
LTEXT "Pocket PC port by Darek Olszewski",
IDC_STATIC, 4, 46, 150, 8
LTEXT "", IDC_ABOUT_VERSION, 4, 60, 150, 8
END
IDD_CONFIG DIALOG DISCARDABLE 0, 0, 0, 0
STYLE WS_POPUP
FONT 8, "Tahoma"
BEGIN
LTEXT "", IDC_CONFIG_CAPTION, 4, 4, 150, 8
LTEXT "", IDC_CONFIG_LINE, 4, 16, 150, 1, WS_BORDER
END
IDR_PADTOOLBAR BITMAP DISCARDABLE "padtoolbar.bmp"
#endif /* _WIN32_WCE */

6
rect.c
View File

@ -60,7 +60,11 @@ struct game_params {
#define PREFERRED_TILE_SIZE 24
#define TILE_SIZE (ds->tilesize)
#ifdef SMALL_SCREEN
#define BORDER (2)
#else
#define BORDER (TILE_SIZE * 3 / 4)
#endif
#define CORNER_TOLERANCE 0.15F
#define CENTRE_TOLERANCE 0.15F
@ -102,8 +106,10 @@ static int game_fetch_preset(int i, char **name, game_params **params)
case 2: w = 11, h = 11; break;
case 3: w = 13, h = 13; break;
case 4: w = 15, h = 15; break;
#ifndef SMALL_SCREEN
case 5: w = 17, h = 17; break;
case 6: w = 19, h = 19; break;
#endif
default: return FALSE;
}

20
resource.h Normal file
View File

@ -0,0 +1,20 @@
#define IDR_MENUBAR1 101
#define ID_GAME 40005
#define ID_TYPE 40006
#define IDS_CAP_GAME 40105
#define IDS_CAP_TYPE 40106
#define IDD_ABOUT 2000
#define IDC_ABOUT_CAPTION 2001
#define IDC_ABOUT_LINE 2002
#define IDC_ABOUT_GAME 2003
#define IDC_ABOUT_VERSION 2004
#define IDD_CONFIG 2100
#define IDC_CONFIG_CAPTION 2101
#define IDC_CONFIG_LINE 2102
#define IDR_PADTOOLBAR 4000

2
solo.c
View File

@ -3085,7 +3085,7 @@ const struct game thegame = {
TRUE, FALSE, game_print_size, game_print,
FALSE, /* wants_statusbar */
FALSE, game_timing_state,
0, /* flags */
REQUIRE_RBUTTON | REQUIRE_NUMPAD, /* flags */
};
#ifdef STANDALONE_SOLVER

View File

@ -2086,7 +2086,7 @@ const struct game thegame = {
TRUE, FALSE, game_print_size, game_print,
FALSE, /* wants_statusbar */
FALSE, game_timing_state,
0, /* flags */
REQUIRE_RBUTTON, /* flags */
};
#ifdef STANDALONE_SOLVER

View File

@ -26,6 +26,11 @@
#include "puzzles.h"
#include "latin.h" /* contains typedef for digit */
static void assert_f(p)
{
assert(p);
}
/* ----------------------------------------------------------
* Constant and structure definitions
*/
@ -971,7 +976,7 @@ static void game_strip(game_state *new, int *scratch, digit *latin,
gg_solved++;
if (solver_state(copy, difficulty) != 1) {
/* put clue back, we can't solve without it. */
assert(gg_place_clue(new, scratch[i], latin, 0) == 1);
assert_f(gg_place_clue(new, scratch[i], latin, 0) == 1);
} else {
#ifdef STANDALONE_SOLVER
if (solver_show_working)
@ -1355,7 +1360,7 @@ static game_state *execute_move(game_state *state, char *move)
p++;
}
if (*p) goto badmove;
assert(check_complete(ret->nums, ret, 1) > 0);
assert_f(check_complete(ret->nums, ret, 1) > 0);
return ret;
} else if (move[0] == 'H') {
return solver_hint(state, NULL, DIFF_EASY, DIFF_EASY);
@ -1748,7 +1753,7 @@ const struct game thegame = {
TRUE, FALSE, game_print_size, game_print,
FALSE, /* wants_statusbar */
FALSE, game_timing_state,
0, /* flags */
REQUIRE_RBUTTON | REQUIRE_NUMPAD, /* flags */
};
/* ----------------------------------------------------------------------

717
windows.c

File diff suppressed because it is too large Load Diff