summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2007-08-04 12:53:41 +0000
committertruelight <truelight@openttd.org>2007-08-04 12:53:41 +0000
commit424757c078410041cce35a8678b59b7a56c47ccb (patch)
tree95e47824c2caa1c36c3ad2d37010fe7f16650f26 /src
parentcb9d0c69d1fac53c479b678741f82df084b1b5ba (diff)
downloadopenttd-424757c078410041cce35a8678b59b7a56c47ccb.tar.xz
(svn r10781) -Fix: ported more pieces to WinCE, so it compiles a bit more
-Fix: WinCE doesn't support console -Fix: Set debug lvl4 when running a debug WinCE build (as you can't give parameters any easy way)
Diffstat (limited to 'src')
-rw-r--r--src/fios.cpp4
-rw-r--r--src/gfx.cpp5
-rw-r--r--src/openttd.cpp5
-rw-r--r--src/video/dedicated_v.cpp21
-rw-r--r--src/video/win32_v.cpp2
-rw-r--r--src/win32.cpp33
6 files changed, 61 insertions, 9 deletions
diff --git a/src/fios.cpp b/src/fios.cpp
index 0f347d1a7..31c3d8390 100644
--- a/src/fios.cpp
+++ b/src/fios.cpp
@@ -108,7 +108,9 @@ char *FiosBrowseTo(const FiosItem *item)
char *path = _fios_path;
switch (item->type) {
-#if defined(WIN32) || defined(__OS2__)
+#if defined(WINCE)
+ case FIOS_TYPE_DRIVE: sprintf(path, PATHSEP ""); break;
+#elif defined(WIN32) || defined(__OS2__)
case FIOS_TYPE_DRIVE: sprintf(path, "%c:" PATHSEP, item->title[0]); break;
#endif
diff --git a/src/gfx.cpp b/src/gfx.cpp
index faf011bae..c915b38f5 100644
--- a/src/gfx.cpp
+++ b/src/gfx.cpp
@@ -840,6 +840,11 @@ void UndrawMouseCursor()
void DrawMouseCursor()
{
+#if defined(WINCE)
+ /* Don't ever draw the mouse for WinCE, as we work with a stylus */
+ return;
+#endif
+
Blitter *blitter = BlitterFactoryBase::GetCurrentBlitter();
int x;
int y;
diff --git a/src/openttd.cpp b/src/openttd.cpp
index f20003a49..ae415748b 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -452,6 +452,11 @@ int ttd_main(int argc, char *argv[])
}
}
+#if defined(WINCE) && defined(_DEBUG)
+ /* Switch on debug lvl 4 for WinCE if Debug release, as you can't give params, and you most likely do want this information */
+ SetDebugString("4");
+#endif
+
DeterminePaths(argv[0]);
CheckExternalFiles();
diff --git a/src/video/dedicated_v.cpp b/src/video/dedicated_v.cpp
index d4bfa7cbc..3d9490c59 100644
--- a/src/video/dedicated_v.cpp
+++ b/src/video/dedicated_v.cpp
@@ -66,11 +66,13 @@ static void DedicatedSignalHandler(int sig)
}
#endif
-#ifdef WIN32
-#include <windows.h> /* GetTickCount */
-#include <conio.h>
-#include <time.h>
-#include <tchar.h>
+#if defined(WIN32)
+# include <windows.h> /* GetTickCount */
+# if !defined(WINCE)
+# include <conio.h>
+# endif
+# include <time.h>
+# include <tchar.h>
static HANDLE _hInputReady, _hWaitForInputHandling;
static HANDLE _hThread; // Thread to close
static char _win_console_thread_buffer[200];
@@ -78,6 +80,10 @@ static char _win_console_thread_buffer[200];
/* Windows Console thread. Just loop and signal when input has been received */
static void WINAPI CheckForConsoleInput()
{
+#if defined(WINCE)
+ /* WinCE doesn't support console stuff */
+ return;
+#else
DWORD nb;
HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE);
while (true) {
@@ -87,6 +93,7 @@ static void WINAPI CheckForConsoleInput()
SetEvent(_hInputReady);
WaitForSingleObject(_hWaitForInputHandling, INFINITE);
}
+#endif
}
static void CreateWindowsConsoleThread()
@@ -133,7 +140,9 @@ const char *VideoDriver_Dedicated::Start(const char * const *parm)
SetDebugString("net=6");
-#ifdef WIN32
+#if defined(WINCE)
+ /* WinCE doesn't support console stuff */
+#elif defined(WIN32)
// For win32 we need to allocate a console (debug mode does the same)
CreateConsole();
CreateWindowsConsoleThread();
diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp
index 46c6cc851..a963575c5 100644
--- a/src/video/win32_v.cpp
+++ b/src/video/win32_v.cpp
@@ -775,6 +775,8 @@ const char *VideoDriver_Win32::Start(const char * const *parm)
FindResolutions();
+ DEBUG(driver, 2, "Resolution for display: %dx%d", _cur_resolution[0], _cur_resolution[1]);
+
// fullscreen uses those
_wnd.width_org = _cur_resolution[0];
_wnd.height_org = _cur_resolution[1];
diff --git a/src/win32.cpp b/src/win32.cpp
index bcc1fda43..892f724c1 100644
--- a/src/win32.cpp
+++ b/src/win32.cpp
@@ -94,7 +94,7 @@ void ShowOSErrorBox(const char *buf)
#endif
}
-#ifdef _MSC_VER
+#if defined(_MSC_VER) && !defined(WINCE)
static void *_safe_esp;
static char *_crash_msg;
@@ -734,6 +734,14 @@ bool FiosIsRoot(const char *file)
void FiosGetDrives()
{
+#if defined(WINCE)
+ /* WinCE only knows one drive: / */
+ FiosItem *fios = FiosAlloc();
+ fios->type = FIOS_TYPE_DRIVE;
+ fios->mtime = 0;
+ snprintf(fios->name, lengthof(fios->name), PATHSEP "");
+ ttd_strlcpy(fios->title, fios->name, lengthof(fios->title));
+#else
TCHAR drives[256];
const TCHAR *s;
@@ -746,6 +754,7 @@ void FiosGetDrives()
ttd_strlcpy(fios->title, fios->name, lengthof(fios->title));
while (*s++ != '\0');
}
+#endif
}
bool FiosIsValidFile(const char *path, const struct dirent *ent, struct stat *sb)
@@ -821,6 +830,9 @@ static int ParseCommandLine(char *line, char **argv, int max_argc)
void CreateConsole()
{
+#if defined(WINCE)
+ /* WinCE doesn't support console stuff */
+#else
HANDLE hand;
CONSOLE_SCREEN_BUFFER_INFO coninfo;
@@ -849,6 +861,7 @@ void CreateConsole()
setvbuf(stdin, NULL, _IONBF, 0);
setvbuf(stdout, NULL, _IONBF, 0);
setvbuf(stderr, NULL, _IONBF, 0);
+#endif
}
void ShowInfo(const char *str)
@@ -882,7 +895,11 @@ void ShowInfo(const char *str)
int _set_error_mode(int);
#endif
+#if defined(WINCE)
+int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
+#else
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
+#endif
{
int argc;
char *argv[64]; // max 64 command line arguments
@@ -893,8 +910,11 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
#endif /* UNICODE */
#if defined(UNICODE)
+
+#if !defined(WINCE)
/* Check if a win9x user started the win32 version */
if (HASBIT(GetVersion(), 31)) error("This version of OpenTTD doesn't run on windows 95/98/ME.\nPlease download the win9x binary and try again.");
+#endif
/* For UNICODE we need to convert the commandline to char* _AND_
* save it because argv[] points into this buffer and thus needs to
@@ -908,7 +928,9 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
CreateConsole();
#endif
+#if !defined(WINCE)
_set_error_mode(_OUT_TO_MSGBOX); // force assertion output to messagebox
+#endif
/* setup random seed to something quite random */
_random_seeds[1][0] = _random_seeds[0][0] = GetTickCount();
@@ -951,7 +973,14 @@ void GetCurrentDirectoryW(int length, wchar_t *path)
char *getcwd(char *buf, size_t size)
{
-#if defined(UNICODE)
+#if defined(WINCE)
+ TCHAR path[MAX_PATH];
+ GetModuleFileName(NULL, path, MAX_PATH);
+ convert_from_fs(path, buf, size);
+ /* GetModuleFileName returns dir with file, so remove everything behind latest '\\' */
+ char *p = strrchr(buf, '\\');
+ if (p != NULL) *p = '\0';
+#elif defined(UNICODE)
TCHAR path[MAX_PATH];
GetCurrentDirectory(MAX_PATH - 1, path);
convert_from_fs(path, buf, size);