Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2005:
[Freeciv-Dev] Freeciv on Pocket PC
Home

[Freeciv-Dev] Freeciv on Pocket PC

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Freeciv on Pocket PC
From: Christian Prochaska <cp.ml.freeciv.dev@xxxxxxxxxxxxxx>
Date: Tue, 29 Nov 2005 23:35:43 +0100

Hi, I've successfully compiled Freeciv for my StrongARM Pocket PC using
Mamaichs port of GCC for the ARM CPU platform (Cygwin version):

http://web.archive.org/web/20041115041606/mamaich.kasone.com/fr_pocket.htm

There is no HOWTO yet, but if you want to try yourself you can get my
complete development environment at

http://web.inf.tu-dresden.de/~s3564543/freeciv-sdl/freeciv-ppc/freeciv-ppc-2005-11-27-dev.7z

or if you just want to play you can download binaries of the game here:

http://web.inf.tu-dresden.de/~s3564543/freeciv-sdl/freeciv-ppc/freeciv-ppc-2005-11-27-bin.zip

(These links will probably change in time, because I don't have enough
webspace to keep more than one version, so if the links don't work
anymore please browse
http://web.inf.tu-dresden.de/~s3564543/freeciv-sdl/ for newer versions)

The archive was compressed using 7zip (http://www.7-zip.org/) and you
should extract it directly to C:\

To build the included Freeciv snapshot just do the following steps:

1.) run C:\freeciv-ppc\msys\1.0\msys.bat
2.) $ cd /c/freeciv-ppc/src
3.) $ ./build_freeciv.sh

If everything goes well you'll find civserver.exe, civclient.exe and the
data directory installed to C:\freeciv-ppc\bin

Then copy these files + the data directory + libc.dll + sdlgcc.dll to
some folder on your Pocket PC and install PocketConsole
(http://www.symbolictools.de/public/pocketconsole/) and PocketCmd
(http://www.symbolictools.de/public/pocketconsole/applications/PocketCMD/index.htm)

If your version of Windows Mobile does not support screen rotation
you'll also need a tool like nyditot (http://www.nyditot.com).

To play the game, switch the display to landscape mode, then run
PocketCmd, then "cd" to the folder where civserver.exe and civclient.exe
are stored and enter "civserver -l logs.txt". Then finally start another
instance of PocketCmd, "cd" to your game folder again and enter
"civclient -l logc.txt -t trident".

If it doesn't work maybe there's not enough free memory available
(server and client together need about 50 MB with trident tileset at
this time, even more with isometric tilesets :-|). Then you could try to
deinstall some of your other software or delete some unused tilesets
from the data directory. Please check the logfiles (logs.txt and
logc.txt), too. (btw. don't run server or client without the -l
parameter, because that will probably make them crash). Finally you
could also delete civserver.exe and start a server on your Windows
machine (for example /c/freeciv-ppc/bin/civserver-mingw32.exe) which
would save some megs of RAM, too. The hostname at the connection dialog
would then have to be the hostname of your windows machine (ah, and
don't forget to enable network routing in the ActiveSync application).

Attached to this mail are the patches that were applied to the Freeciv
source tree. I don't know if they are correct for other arm-wince-pe
compilers too, because I didn't get those other compilers to work yet.
Also, the "freeciv-config-2005-11-27.diff" patch is very ugly because it
changes config.h and a  Makefile, but I don't know how to add the
arm-wince-pe target and the corresponding detection fixes to the right
files. And there's another problem I didn't find a good solution for so
far: tolua.exe is needed during the compilation process, but since I'm
cross-compiling, tolua.exe is built for the target platform and doesn't
run on the Windows host. I temporarely "solved" this by copying
tolua.exe from a Mingw32 compilation to the dependencies/tolua directory
and changing the file extension for the autogenerated file to .exe2, but
of course their should be found another way.

So that's all for now. If you're going to try it, I wish you good luck! :-)

Christian




diff -u -r -b -B -X freeciv/diff_ignore freeciv_orig/client/civclient.c 
freeciv/client/civclient.c
--- freeciv_orig/client/civclient.c     Sun Nov 27 03:16:14 2005
+++ freeciv/client/civclient.c  Sun Nov 27 03:20:18 2005
@@ -156,17 +156,60 @@
 }
 
 /**************************************************************************
+  Under Windows CE command line parameters are stored in unicode string
+  "lpCmd" without name of the executable. WinCE_getArgs() generates 
+  argc and argv from it
+**************************************************************************/
+
+#ifdef UNDER_CE
+
+#define MAX_ARGS 20
+
+static char lpCmd2[255];
+
+static void WinCE_getArgs(char *command, LPWSTR lpCmd, int *argc, char 
*argv[]) {
+  int i = 1;
+
+  WideCharToMultiByte(CP_ACP, 0, lpCmd, -1, lpCmd2, 256, NULL, NULL);
+
+  argv[0] = command;
+  argv[1] = strtok(lpCmd2, " ");
+    
+  if (argv[1] != NULL) {
+    for (i = 2; i < MAX_ARGS; i++) {
+      argv[i] = strtok(NULL, " ");
+      if (argv[i] == NULL)
+        break;
+    }
+  }  
+
+  *argc = i;
+}
+#endif /* UNDER_CE */
+
+/**************************************************************************
 ...
 **************************************************************************/
+#ifdef UNDER_CE
+int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPWSTR lpCmd, int nShow)
+#else
 int main(int argc, char *argv[])
+#endif
 {
   int i, loglevel;
   int ui_options = 0;
   bool ui_separator = FALSE;
   char *option=NULL;
 
+#ifdef UNDER_CE
+  int argc = 0;
+  char *argv[MAX_ARGS];
+  
+  WinCE_getArgs("civclient.exe", lpCmd, &argc, argv);
+#endif
+
   /* Load win32 post-crash debugger */
-#ifdef WIN32_NATIVE
+#if defined WIN32_NATIVE && !defined UNDER_CE
 # ifndef NDEBUG
   if (LoadLibrary("exchndl.dll") == NULL) {
 #  ifdef DEBUG
diff -u -r -b -B -X freeciv/diff_ignore freeciv_orig/client/servers.c 
freeciv/client/servers.c
--- freeciv_orig/client/servers.c       Sun Nov 27 03:16:14 2005
+++ freeciv/client/servers.c    Sun Nov 27 03:20:18 2005
@@ -331,7 +331,7 @@
     char filename[MAX_PATH];
 
     GetTempPath(sizeof(filename), filename);
-    cat_snprintf(filename, sizeof(filename) "fctmp%d", myrand());
+    cat_snprintf(filename, sizeof(filename), "fctmp%d", myrand());
 
     scan->meta.fp = fopen(filename, "w+b");
 #else
diff -u -r -b -B -X freeciv/diff_ignore freeciv_orig/server/civserver.c 
freeciv/server/civserver.c
--- freeciv_orig/server/civserver.c     Sun Nov 27 03:16:16 2005
+++ freeciv/server/civserver.c  Sun Nov 27 03:20:18 2005
@@ -78,19 +78,60 @@
 #endif
 
 /**************************************************************************
+  Under Windows CE command line parameters are stored in unicode string
+  "lpCmd" without name of the executable. WinCE_getArgs() generates 
+  argc and argv from it
+**************************************************************************/
+
+#ifdef UNDER_CE
+
+#define MAX_ARGS 20
+
+static char lpCmd2[255];
+
+static void WinCE_getArgs(char *command, LPWSTR lpCmd, int *argc, char 
*argv[]) {
+  int i = 1;
+
+  WideCharToMultiByte(CP_ACP, 0, lpCmd, -1, lpCmd2, 256, NULL, NULL);
+
+  argv[0] = command;
+  argv[1] = strtok(lpCmd2, " ");
+
+  if (argv[1] != NULL) {
+    for (i = 2; i < MAX_ARGS; i++) {
+      argv[i] = strtok(NULL, " ");
+      if (argv[i] == NULL)
+        break;
+    }
+  }  
+
+  *argc = i;
+}
+#endif /* UNDER_CE */
+
+/**************************************************************************
  Entry point for Freeciv server.  Basically, does two things:
   1. Parses command-line arguments (possibly dialog, on mac).
   2. Calls the main server-loop routine.
 **************************************************************************/
+#ifdef UNDER_CE
+int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPWSTR lpCmd, int nShow)
+#else
 int main(int argc, char *argv[])
+#endif
 {
   int inx;
   bool showhelp = FALSE;
   bool showvers = FALSE;
   char *option = NULL;
 
+#ifdef UNDER_CE
+  int argc = 0;
+  char *argv[MAX_ARGS];
+#endif  
+
   /* Load win32 post-crash debugger */
-#ifdef WIN32_NATIVE
+#if defined WIN32_NATIVE && !defined UNDER_CE
 # ifndef NDEBUG
   if (LoadLibrary("exchndl.dll") == NULL) {
 #  ifdef DEBUG
@@ -111,7 +152,12 @@
 
 #ifdef GENERATING_MAC
   Mac_options(argc);
+#else
+#ifdef UNDER_CE
+  WinCE_getArgs("civserver.exe", lpCmd, &argc, argv);
 #endif
+#endif
+
   /* no  we don't use GNU's getopt or even the "standard" getopt */
   /* yes we do have reasons ;)                                   */
   inx = 1;
diff -u -r -b -B -X freeciv/diff_ignore freeciv_orig/server/console.c 
freeciv/server/console.c
--- freeciv_orig/server/console.c       Sun Nov 27 03:16:16 2005
+++ freeciv/server/console.c    Sun Nov 27 03:20:18 2005
@@ -154,7 +154,9 @@
 ************************************************************************/
 void con_flush(void)
 {
+#ifndef UNDER_CE
   fflush(stdout);
+#endif  
 }
 
 /************************************************************************
diff -u -r -b -B -X freeciv/diff_ignore freeciv_orig/server/sernet.c 
freeciv/server/sernet.c
--- freeciv_orig/server/sernet.c        Sun Nov 27 03:16:16 2005
+++ freeciv/server/sernet.c     Sun Nov 27 03:20:18 2005
@@ -561,7 +561,7 @@
 #ifdef SOCKET_ZERO_ISNT_STDIN
       my_init_console();
 #else
-#   if !defined(__VMS)
+#   if !defined(__VMS) && !defined UNDER_CE
       FD_SET(0, &readfs);
 #   endif      
 #endif
diff -u -r -b -B -X freeciv/diff_ignore freeciv_orig/utility/fciconv.c 
freeciv/utility/fciconv.c
--- freeciv_orig/utility/fciconv.c      Sun Nov 27 03:16:16 2005
+++ freeciv/utility/fciconv.c   Sun Nov 27 03:20:18 2005
@@ -352,6 +352,20 @@
   }
   recursion = FALSE;
 
+#ifdef UNDER_CE
+  /*
+   fputs, fprintf, fflush, ... on stdout/stderr make programs that are linked
+   against winsock crash on my PDA, so don't use these functions here
+  */
+  if ((stream != stdout) && (stream != stderr)) {
+#endif                                       
+           
   fputs(output, stream);
   fflush(stream);
+  
+#ifdef UNDER_CE
+  }
+#endif                                                  
+  
 }
+
diff -u -r -b -B -X freeciv/diff_ignore freeciv_orig/utility/netintf.c 
freeciv/utility/netintf.c
--- freeciv_orig/utility/netintf.c      Sun Nov 27 03:16:18 2005
+++ freeciv/utility/netintf.c   Sun Nov 27 03:20:18 2005
@@ -132,6 +132,10 @@
 void my_nonblock(int sockfd)
 {
 #ifdef NONBLOCKING_SOCKETS
+#ifdef HAVE_WINSOCK
+  unsigned long b = 1;
+  ioctlsocket(sockfd, FIONBIO, &b);
+#else
 #ifdef HAVE_FCNTL
   int f_set;
 
@@ -151,6 +155,7 @@
   if (ioctl(sockfd, FIONBIO, (char*)&value) == -1) {
     freelog(LOG_ERROR, "ioctl failed: %s", mystrerror());
   }
+#endif
 #endif
 #endif
 #else
diff -u -r -b -B -X freeciv/diff_ignore freeciv_orig/utility/shared.c 
freeciv/utility/shared.c
--- freeciv_orig/utility/shared.c       Sun Nov 27 03:16:18 2005
+++ freeciv/utility/shared.c    Sun Nov 27 03:20:18 2005
@@ -795,7 +795,7 @@
   }
 #endif
 
-#ifdef WIN32_NATIVE
+#if defined WIN32_NATIVE && !defined UNDER_CE
   /* On win32 the GetUserName function will give us the login name. */
   {
     char name[UNLEN + 1];
@@ -1538,7 +1538,7 @@
       *dir = 0;
     }
 
-#ifdef WIN32_NATIVE
+#if defined WIN32_NATIVE && !defined UNDER_CE
     mkdir(path);
 #else
     mkdir(path, 0755);





diff -u -r -X devel/diff_ignore devel_orig/client/gui-sdl/gui_main.h 
devel/client/gui-sdl/gui_main.h
--- devel_orig/client/gui-sdl/gui_main.h        Tue Nov 15 05:52:44 2005
+++ devel/client/gui-sdl/gui_main.h     Fri Nov 18 01:30:32 2005
@@ -25,7 +25,7 @@
 #include "gui_main_g.h"
 
 /* enable this to adjust sizes for 320x240 resolution */
-/*#define SMALL_SCREEN*/
+#define SMALL_SCREEN
 
 /* #define DEBUG_SDL */
 
diff -u -r -X devel/diff_ignore devel_orig/common/connection.h 
devel/common/connection.h
--- devel_orig/common/connection.h      Mon Oct 17 15:15:34 2005
+++ devel/common/connection.h   Fri Nov 18 01:30:14 2005
@@ -22,7 +22,7 @@
 #include <sys/time.h>
 #endif
 
-#define USE_COMPRESSION
+/*#define USE_COMPRESSION*/
 
 /**************************************************************************
   The connection struct and related stuff.





diff -u -r -b -B freeciv_orig/config.h freeciv/config.h
--- freeciv_orig/config.h       Sun Nov 27 03:41:56 2005
+++ freeciv/config.h    Sun Nov 27 03:52:22 2005
@@ -3,6 +3,7 @@
 
 /* Mingw32-specific setting - root */
 /* #undef ALWAYS_ROOT */
+#define ALWAYS_ROOT
 
 /* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
    systems. This function is required for `alloca.c' support on those systems.
@@ -48,7 +49,7 @@
 #define HAVE_ARGZ_H 1
 
 /* Define to 1 if you have the <arpa/inet.h> header file. */
-#define HAVE_ARPA_INET_H 1
+/*#define HAVE_ARPA_INET_H 1*/
 
 /* Define to 1 if you have the `bind' function. */
 #define HAVE_BIND 1
@@ -198,10 +199,10 @@
 /* #undef HAVE_MUNMAP */
 
 /* Define to 1 if you have the <netdb.h> header file. */
-#define HAVE_NETDB_H 1
+/*#define HAVE_NETDB_H 1*/
 
 /* Define to 1 if you have the <netinet/in.h> header file. */
-#define HAVE_NETINET_IN_H 1
+/*#define HAVE_NETINET_IN_H 1*/
 
 /* Modern readline */
 /* #undef HAVE_NEWLIBREADLINE */
@@ -304,7 +305,7 @@
 #define HAVE_SYS_SIGNAL_H 1
 
 /* Define to 1 if you have the <sys/socket.h> header file. */
-#define HAVE_SYS_SOCKET_H 1
+/*#define HAVE_SYS_SOCKET_H 1*/
 
 /* Define to 1 if you have the <sys/stat.h> header file. */
 #define HAVE_SYS_STAT_H 1
@@ -313,7 +314,7 @@
 #define HAVE_SYS_TERMIO_H 1
 
 /* Define to 1 if you have the <sys/time.h> header file. */
-#define HAVE_SYS_TIME_H 1
+/*#define HAVE_SYS_TIME_H 1*/
 
 /* Define to 1 if you have the <sys/types.h> header file. */
 #define HAVE_SYS_TYPES_H 1
@@ -356,9 +357,10 @@
 
 /* Mingw32-specific setting - winsock */
 /* #undef HAVE_WINSOCK */
+#define HAVE_WINSOCK
 
 /* Define to 1 if `fork' works. */
-#define HAVE_WORKING_FORK 1
+/*#define HAVE_WORKING_FORK 1*/
 
 /* Define to 1 if `vfork' works. */
 /* #undef HAVE_WORKING_VFORK */
diff -u -r -b -B freeciv_orig/dependencies/tolua/Makefile 
freeciv/dependencies/tolua/Makefile
--- freeciv_orig/dependencies/tolua/Makefile    Sun Nov 27 03:41:56 2005
+++ freeciv/dependencies/tolua/Makefile Sun Nov 27 03:53:08 2005
@@ -89,7 +89,7 @@
 ECHO_N = -n
 ECHO_T = 
 EGREP = grep -E
-EXEEXT = .exe
+EXEEXT = .exe2
 FT2_CFLAGS = -I/c/freeciv-ppc/arm-wince-pe/arm-wince-pe/include/freetype2 
-I/c/freeciv-ppc/arm-wince-pe/arm-wince-pe/include
 FT2_CONFIG = /c/freeciv-ppc/arm-wince-pe/arm-wince-pe/bin/freetype-config
 FT2_LIBS = -L/c/freeciv-ppc/arm-wince-pe/arm-wince-pe/lib -lfreetype -lz






[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] Freeciv on Pocket PC, Christian Prochaska <=