(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)
This commit is contained in:
truelight 2007-08-04 12:53:41 +00:00
parent cb9d0c69d1
commit 424757c078
6 changed files with 61 additions and 9 deletions

View File

@ -108,7 +108,9 @@ char *FiosBrowseTo(const FiosItem *item)
char *path = _fios_path; char *path = _fios_path;
switch (item->type) { 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; case FIOS_TYPE_DRIVE: sprintf(path, "%c:" PATHSEP, item->title[0]); break;
#endif #endif

View File

@ -840,6 +840,11 @@ void UndrawMouseCursor()
void DrawMouseCursor() 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(); Blitter *blitter = BlitterFactoryBase::GetCurrentBlitter();
int x; int x;
int y; int y;

View File

@ -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]); DeterminePaths(argv[0]);
CheckExternalFiles(); CheckExternalFiles();

View File

@ -66,9 +66,11 @@ static void DedicatedSignalHandler(int sig)
} }
#endif #endif
#ifdef WIN32 #if defined(WIN32)
# include <windows.h> /* GetTickCount */ # include <windows.h> /* GetTickCount */
# if !defined(WINCE)
# include <conio.h> # include <conio.h>
# endif
# include <time.h> # include <time.h>
# include <tchar.h> # include <tchar.h>
static HANDLE _hInputReady, _hWaitForInputHandling; static HANDLE _hInputReady, _hWaitForInputHandling;
@ -78,6 +80,10 @@ static char _win_console_thread_buffer[200];
/* Windows Console thread. Just loop and signal when input has been received */ /* Windows Console thread. Just loop and signal when input has been received */
static void WINAPI CheckForConsoleInput() static void WINAPI CheckForConsoleInput()
{ {
#if defined(WINCE)
/* WinCE doesn't support console stuff */
return;
#else
DWORD nb; DWORD nb;
HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE); HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE);
while (true) { while (true) {
@ -87,6 +93,7 @@ static void WINAPI CheckForConsoleInput()
SetEvent(_hInputReady); SetEvent(_hInputReady);
WaitForSingleObject(_hWaitForInputHandling, INFINITE); WaitForSingleObject(_hWaitForInputHandling, INFINITE);
} }
#endif
} }
static void CreateWindowsConsoleThread() static void CreateWindowsConsoleThread()
@ -133,7 +140,9 @@ const char *VideoDriver_Dedicated::Start(const char * const *parm)
SetDebugString("net=6"); 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) // For win32 we need to allocate a console (debug mode does the same)
CreateConsole(); CreateConsole();
CreateWindowsConsoleThread(); CreateWindowsConsoleThread();

View File

@ -775,6 +775,8 @@ const char *VideoDriver_Win32::Start(const char * const *parm)
FindResolutions(); FindResolutions();
DEBUG(driver, 2, "Resolution for display: %dx%d", _cur_resolution[0], _cur_resolution[1]);
// fullscreen uses those // fullscreen uses those
_wnd.width_org = _cur_resolution[0]; _wnd.width_org = _cur_resolution[0];
_wnd.height_org = _cur_resolution[1]; _wnd.height_org = _cur_resolution[1];

View File

@ -94,7 +94,7 @@ void ShowOSErrorBox(const char *buf)
#endif #endif
} }
#ifdef _MSC_VER #if defined(_MSC_VER) && !defined(WINCE)
static void *_safe_esp; static void *_safe_esp;
static char *_crash_msg; static char *_crash_msg;
@ -734,6 +734,14 @@ bool FiosIsRoot(const char *file)
void FiosGetDrives() 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]; TCHAR drives[256];
const TCHAR *s; const TCHAR *s;
@ -746,6 +754,7 @@ void FiosGetDrives()
ttd_strlcpy(fios->title, fios->name, lengthof(fios->title)); ttd_strlcpy(fios->title, fios->name, lengthof(fios->title));
while (*s++ != '\0'); while (*s++ != '\0');
} }
#endif
} }
bool FiosIsValidFile(const char *path, const struct dirent *ent, struct stat *sb) 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() void CreateConsole()
{ {
#if defined(WINCE)
/* WinCE doesn't support console stuff */
#else
HANDLE hand; HANDLE hand;
CONSOLE_SCREEN_BUFFER_INFO coninfo; CONSOLE_SCREEN_BUFFER_INFO coninfo;
@ -849,6 +861,7 @@ void CreateConsole()
setvbuf(stdin, NULL, _IONBF, 0); setvbuf(stdin, NULL, _IONBF, 0);
setvbuf(stdout, NULL, _IONBF, 0); setvbuf(stdout, NULL, _IONBF, 0);
setvbuf(stderr, NULL, _IONBF, 0); setvbuf(stderr, NULL, _IONBF, 0);
#endif
} }
void ShowInfo(const char *str) void ShowInfo(const char *str)
@ -882,7 +895,11 @@ void ShowInfo(const char *str)
int _set_error_mode(int); int _set_error_mode(int);
#endif #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) int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
#endif
{ {
int argc; int argc;
char *argv[64]; // max 64 command line arguments char *argv[64]; // max 64 command line arguments
@ -893,8 +910,11 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
#endif /* UNICODE */ #endif /* UNICODE */
#if defined(UNICODE) #if defined(UNICODE)
#if !defined(WINCE)
/* Check if a win9x user started the win32 version */ /* 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."); 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_ /* For UNICODE we need to convert the commandline to char* _AND_
* save it because argv[] points into this buffer and thus needs to * 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(); CreateConsole();
#endif #endif
#if !defined(WINCE)
_set_error_mode(_OUT_TO_MSGBOX); // force assertion output to messagebox _set_error_mode(_OUT_TO_MSGBOX); // force assertion output to messagebox
#endif
/* setup random seed to something quite random */ /* setup random seed to something quite random */
_random_seeds[1][0] = _random_seeds[0][0] = GetTickCount(); _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) 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]; TCHAR path[MAX_PATH];
GetCurrentDirectory(MAX_PATH - 1, path); GetCurrentDirectory(MAX_PATH - 1, path);
convert_from_fs(path, buf, size); convert_from_fs(path, buf, size);