diff options
-rw-r--r-- | backends/fs/windows/windows-fs.cpp | 5 | ||||
-rw-r--r-- | backends/platform/wince/CEDevice.cpp | 9 | ||||
-rw-r--r-- | backends/platform/wince/CEDevice.h | 2 | ||||
-rw-r--r-- | backends/platform/wince/CEKeysDialog.cpp | 1 | ||||
-rw-r--r-- | backends/platform/wince/CELauncherDialog.cpp | 6 | ||||
-rw-r--r-- | backends/platform/wince/CELauncherDialog.h | 2 | ||||
-rw-r--r-- | backends/platform/wince/Makefile | 79 | ||||
-rw-r--r-- | backends/platform/wince/PocketSCUMM.rc | 139 | ||||
-rw-r--r-- | backends/platform/wince/missing/missing.cpp | 330 | ||||
-rw-r--r-- | backends/platform/wince/missing/time.h | 10 | ||||
-rw-r--r-- | backends/platform/wince/portdefs.h | 23 | ||||
-rw-r--r-- | backends/platform/wince/resource.h | 28 | ||||
-rw-r--r-- | backends/platform/wince/wince-sdl.cpp | 40 | ||||
-rw-r--r-- | backends/platform/wince/wince-sdl.h | 4 | ||||
-rw-r--r-- | common/scummsys.h | 11 | ||||
-rw-r--r-- | common/util.cpp | 5 | ||||
-rw-r--r-- | engines/scumm/input.cpp | 29 |
17 files changed, 384 insertions, 339 deletions
diff --git a/backends/fs/windows/windows-fs.cpp b/backends/fs/windows/windows-fs.cpp index 7913fd1936..32c1ab42e5 100644 --- a/backends/fs/windows/windows-fs.cpp +++ b/backends/fs/windows/windows-fs.cpp @@ -21,11 +21,16 @@ #ifdef WIN32 +#ifdef _WIN32_WCE +#include <windows.h> +#endif #include "common/stdafx.h" #include "backends/fs/abstract-fs.h" #include <stdio.h> #include <stdlib.h> +#ifndef _WIN32_WCE #include <windows.h> +#endif #include <tchar.h> /* diff --git a/backends/platform/wince/CEDevice.cpp b/backends/platform/wince/CEDevice.cpp index ddf1e9df96..495ba1b274 100644 --- a/backends/platform/wince/CEDevice.cpp +++ b/backends/platform/wince/CEDevice.cpp @@ -64,6 +64,11 @@ static HANDLE (WINAPI* _SetPowerRequirement)(PVOID,int,ULONG,PVOID,ULONG) = NULL static DWORD (WINAPI* _ReleasePowerRequirement)(HANDLE) = NULL; static HANDLE _hPowerManagement = NULL; static DWORD _lastTime = 0; +#ifdef __GNUC__ +extern "C" void WINAPI SystemIdleTimerReset(void); +#define SPI_GETPLATFORMTYPE 257 +#endif + #define TIMER_TRIGGER 9000 @@ -82,7 +87,7 @@ void CEDevice::init() { } if (_SetPowerRequirement) - _hPowerManagement = _SetPowerRequirement(TEXT("BKL1:"), 0, 1, NULL, 0); + _hPowerManagement = _SetPowerRequirement((PVOID) TEXT("BKL1:"), 0, 1, (PVOID) NULL, 0); _lastTime = GetTickCount(); } @@ -154,7 +159,7 @@ bool CEDevice::isSmartphone() { BOOL result = SystemParametersInfo(SPI_GETPLATFORMTYPE, sizeof(platformType), platformType, 0); if (!result && GetLastError() == ERROR_ACCESS_DENIED) return true; - return (wcsnicmp(platformType, TEXT("SmartPhone"), 10) == 0); + return (_wcsnicmp(platformType, TEXT("SmartPhone"), 10) == 0); #endif } diff --git a/backends/platform/wince/CEDevice.h b/backends/platform/wince/CEDevice.h index 07753413e4..1165377caa 100644 --- a/backends/platform/wince/CEDevice.h +++ b/backends/platform/wince/CEDevice.h @@ -28,7 +28,7 @@ #include "common/system.h" #include "common/str.h" -#include <gx.h> +//#include <gx.h> class CEDevice { public: diff --git a/backends/platform/wince/CEKeysDialog.cpp b/backends/platform/wince/CEKeysDialog.cpp index 737a33577c..249f1f6fcd 100644 --- a/backends/platform/wince/CEKeysDialog.cpp +++ b/backends/platform/wince/CEKeysDialog.cpp @@ -33,6 +33,7 @@ using GUI::kCloseCmd; using GUI::StaticTextWidget; using GUI::kTextAlignCenter; using GUI::CommandSender; +using GUI::Actions; enum { kMapCmd = 'map ', diff --git a/backends/platform/wince/CELauncherDialog.cpp b/backends/platform/wince/CELauncherDialog.cpp index 8b19273b55..699a1ac6c9 100644 --- a/backends/platform/wince/CELauncherDialog.cpp +++ b/backends/platform/wince/CELauncherDialog.cpp @@ -83,7 +83,7 @@ void CELauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 d } } -void CELauncherDialog::addCandidate(String &path, DetectedGameList &candidates) { +void CELauncherDialog::addCandidate(Common::String path, DetectedGameList &candidates) { int idx = -1; DetectedGame result; @@ -119,7 +119,7 @@ void CELauncherDialog::addCandidate(String &path, DetectedGameList &candidates) // The auto detector or the user made a choice. // Pick a domain name which does not yet exist (after all, we // are *adding* a game to the config, not replacing). - String domain(result.gameid); + Common::String domain(result.gameid); if (ConfMan.hasGameDomain(domain)) { char suffix = 'a'; domain += suffix; @@ -150,7 +150,7 @@ void CELauncherDialog::automaticScanDirectory(const FilesystemNode &node) { FSList files; node.listDir(files, FilesystemNode::kListFilesOnly); DetectedGameList candidates(PluginManager::instance().detectGames(files)); - addCandidate(node.path(), candidates); + CELauncherDialog::addCandidate((Common::String) node.path(), candidates); // Then recurse on the subdirectories FSList dirs; node.listDir(dirs, FilesystemNode::kListDirectoriesOnly); diff --git a/backends/platform/wince/CELauncherDialog.h b/backends/platform/wince/CELauncherDialog.h index e2d85da8dc..1a9091b15b 100644 --- a/backends/platform/wince/CELauncherDialog.h +++ b/backends/platform/wince/CELauncherDialog.h @@ -33,7 +33,7 @@ public: virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data); protected: void addGame(); - void addCandidate(String &path, DetectedGameList &candidates); + void addCandidate(Common::String path, DetectedGameList &candidates); void automaticScanDirectory(const FilesystemNode &node); }; diff --git a/backends/platform/wince/Makefile b/backends/platform/wince/Makefile new file mode 100644 index 0000000000..8dc5ada0ac --- /dev/null +++ b/backends/platform/wince/Makefile @@ -0,0 +1,79 @@ +# ScummVM Makefile for Windows CE port +# Uses the VLC toolchain +# $URL:$ +# $Id:$ + +srcdir = ../../.. +VPATH = $(srcdir) +#HAVE_GCC3 = false + +#DISABLE_SCUMM = 1 +#DISABLE_SIMON = 1 +#DISABLE_SKY = 1 +#DISABLE_QUEEN = 1 +#DISABLE_GOB = 1 +DISABLE_LURE = 1 +DISABLE_CINE = 1 +DISABLE_SAGA = 1 +#DISABLE_KYRA = 1 +DISABLE_AGI = 1 +#DISABLE_AGOS = 1 +#DISABLE_SWORD1 = 1 +#DISABLE_SWORD2 = 1 + + +CXX = arm-wince-pe-g++ +LD = arm-wince-pe-g++ +AR = arm-wince-pe-ar cru +RANLIB = arm-wince-pe-ranlib +STRIP = arm-wince-pe-strip +WINDRES= arm-wince-pe-windres +MKDIR = mkdir -p +RM = rm -f +RM_REC = rm -rf +ECHO = echo -n +CAT = cat + + +DEFINES := -D_WIN32_WCE=300 -DARM -D__ARM__ -D_ARM_ -DUNICODE -DSCUMM_NEED_ALIGNMENT -DFPM_DEFAULT -DUSE_MAD -DNONSTANDARD_PORT -DUSE_TREMOR -DUSE_VORBIS -DUSE_MPEG2 -DWIN32 -DUSE_ZLIB +DEFINES += -D__stdcall= -Dcdecl= -D__cdecl__= -D__cdecl= -Wno-multichar +DEFINES += -O2 +DEFINES += -DDEBUG -DUSE_WINDBG -g + +INCLUDES := -I$(srcdir) -I. -I$(srcdir)/engines -Ilibs/include -Ilibs/include/sdl -ICEgui -ICEkeys + +CFLAGS := + +CXXFLAGS := $(CFLAGS) + +LDFLAGS := -Llibs/lib -L/usr/local/wince/cross-tools/lib +LIBS := -lSDL -lzlib -lmad -lmpeg2 -ltremorce --entry WinMainCRTStartup + +TARGET = scummvm.exe +OBJS := +MODULE_DIRS += . + +OBJS += CEActionsPocket.o CEDevice.o CEKeysDialog.o CEScaler.o \ + CEActionsSmartphone.o CELauncherDialog.o wince-sdl.o +OBJS += CEgui/GUIElement.o CEgui/Panel.o CEgui/SDL_ImageResource.o \ + CEgui/ItemAction.o CEgui/PanelItem.o CEgui/Toolbar.o \ + CEgui/ItemSwitch.o CEgui/PanelKeyboard.o CEgui/ToolbarHandler.o +OBJS += CEkeys/EventsBuffer.o +OBJS += $(srcdir)/gui/Actions.o $(srcdir)/gui/Key.o $(srcdir)/gui/KeysDialog.o +OBJS += ../sdl/sdl.o ../sdl/graphics.o ../sdl/events.o +OBJS += missing/missing.o +OBJS += PocketSCUMM.o + +include $(srcdir)/Makefile.common + +all: dist + +dist: $(TARGET) + bzip2 -fvk $(TARGET) + $(STRIP) $(TARGET) + +PocketSCUMM.o: + $(WINDRES) $*.rc $@ + +$(TARGET): $(OBJS) + $(LD) $^ $(LDFLAGS) $(LIBS) -o $@ -Wl,-Map,scummvm.exe.map -Wl,--stack,65536 diff --git a/backends/platform/wince/PocketSCUMM.rc b/backends/platform/wince/PocketSCUMM.rc index c11547bc08..71d1155068 100644 --- a/backends/platform/wince/PocketSCUMM.rc +++ b/backends/platform/wince/PocketSCUMM.rc @@ -1,145 +1,24 @@ -//Microsoft eMbedded Visual C++ generated resource script. -// #include "resource.h" -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "newres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// French (France) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA) -#ifdef _WIN32 -LANGUAGE LANG_FRENCH, SUBLANG_FRENCH -#pragma code_page(1252) -#endif //_WIN32 - ///////////////////////////////////////////////////////////////////////////// // // Icon // -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. IDI_POCKETSCUMM ICON DISCARDABLE "icons/scumm_icon.ico" -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE DISCARDABLE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE DISCARDABLE -BEGIN - "#include ""newres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE DISCARDABLE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Menubar -// - -IDR_SMARTFON_MENUBAR_GAMES MENU DISCARDABLE -BEGIN - POPUP "Games" - BEGIN - POPUP "Play" - BEGIN - MENUITEM SEPARATOR - END - MENUITEM SEPARATOR - MENUITEM "Scan", IDM_SMARTFON_SCAN - MENUITEM SEPARATOR - MENUITEM "Quit", IDM_SMARTFON_QUIT - END - POPUP "Options" - BEGIN - POPUP "Keys Mapping" - BEGIN - MENUITEM SEPARATOR - END - MENUITEM "Sound", IDM_SMARTFON_SOUND - MENUITEM "Help", IDM_SMARTFON_HELP - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Data -// - -IDR_SMARTFON_MENUBAR_GAMES SHMENUBAR DISCARDABLE -BEGIN - IDR_SMARTFON_MENUBAR_GAMES, 2, - I_IMAGENONE, ID_MENU_GAMES, TBSTATE_ENABLED, - TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, IDS_CAP_MENUITEM40002, 0, 0, - I_IMAGENONE, ID_MENU_OPTIONS, TBSTATE_ENABLED, - TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, IDS_CAP_OPTIONS, 0, 1, -END - - ///////////////////////////////////////////////////////////////////////////// // // BINARY // -PANEL_GENERIC BINARY DISCARDABLE "images\\panelbig.bmp" -PANEL_KEYBOARD BINARY DISCARDABLE "images\\keyboard.bmp" -ITEM_SKIP BINARY DISCARDABLE "images\\Action.bmp" -ITEM_OPTIONS BINARY DISCARDABLE "images\\DiskwFolder.bmp" -ITEM_SOUND_ON BINARY DISCARDABLE "images\\SoundOn.bmp" -ITEM_SOUND_OFF BINARY DISCARDABLE "images\\SoundOff.bmp" -ITEM_VIEW_PORTRAIT BINARY DISCARDABLE "images\\MonkeyPortrait.bmp" -ITEM_VIEW_LANDSCAPE BINARY DISCARDABLE "images\\MonkeyLandscape.bmp" -ITEM_BINDKEYS BINARY DISCARDABLE "images\\bindkeys.bmp" +PANEL_GENERIC BINARY DISCARDABLE "images/panelbig.bmp" +PANEL_KEYBOARD BINARY DISCARDABLE "images/keyboard.bmp" +ITEM_SKIP BINARY DISCARDABLE "images/Action.bmp" +ITEM_OPTIONS BINARY DISCARDABLE "images/DiskwFolder.bmp" +ITEM_SOUND_ON BINARY DISCARDABLE "images/SoundOn.bmp" +ITEM_SOUND_OFF BINARY DISCARDABLE "images/SoundOff.bmp" +ITEM_VIEW_PORTRAIT BINARY DISCARDABLE "images/MonkeyPortrait.bmp" +ITEM_VIEW_LANDSCAPE BINARY DISCARDABLE "images/MonkeyLandscape.bmp" +ITEM_BINDKEYS BINARY DISCARDABLE "images/bindkeys.bmp" HI_RES_AWARE CEUX {1} - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE DISCARDABLE -BEGIN - IDS_CAP_MENUITEM40002 "Games" - IDS_CAP_OPTIONS "Options" -END - -#endif // French (France) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/backends/platform/wince/missing/missing.cpp b/backends/platform/wince/missing/missing.cpp index e85babc13f..8c7240ce29 100644 --- a/backends/platform/wince/missing/missing.cpp +++ b/backends/platform/wince/missing/missing.cpp @@ -9,7 +9,11 @@ #include <string.h> #include <stdlib.h> #include "sys/stat.h" +#ifndef __GNUC__ #include "sys/time.h" +#else +#include <stdio.h> +#endif #include "time.h" #include "dirent.h" @@ -26,9 +30,159 @@ char *strdup(const char *strSource); #endif -/* Limited dirent implementation. Used by UI.C and DEVICES.C */ +#ifdef __GNUC__ +#define EXT_C extern "C" +#else +#define EXT_C +#endif + +// common missing functions required by both gcc and evc + +void *bsearch(const void *key, const void *base, size_t nmemb, + size_t size, int (*compar)(const void *, const void *)) { + size_t i; + + for (i=0; i<nmemb; i++) + if (compar(key, (void*)((size_t)base + size * i)) == 0) + return (void*)((size_t)base + size * i); + return NULL; +} + static WIN32_FIND_DATA wfd; +/* Very limited implementation of stat. Used by UI.C, MEMORY-P.C (latter is not critical) */ +int stat(const char *fname, struct stat *ss) +{ + TCHAR fnameUnc[MAX_PATH+1]; + HANDLE handle; + int len; + + if(fname == NULL || ss == NULL) + return -1; + + /* Special case (dummy on WinCE) */ + len = strlen(fname); + if(len >= 2 && fname[len-1] == '.' && fname[len-2] == '.' && + (len == 2 || fname[len-3] == '\\')) + { + /* That's everything implemented so far */ + memset(ss, 0, sizeof(struct stat)); + ss->st_size = 1024; + ss->st_mode |= S_IFDIR; + return 0; + } + + MultiByteToWideChar(CP_ACP, 0, fname, -1, fnameUnc, MAX_PATH); + handle = FindFirstFile(fnameUnc, &wfd); + if(handle == INVALID_HANDLE_VALUE) + return -1; + else + { + /* That's everything implemented so far */ + memset(ss, 0, sizeof(struct stat)); + ss->st_size = wfd.nFileSizeLow; + if(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) + ss->st_mode |= S_IFDIR; + + FindClose(handle); + } + return 0; +} + +/* Limited implementation of time.h. time_t formula is possibly incorrect. */ +EXT_C time_t time(time_t* res) +{ + time_t t; + SYSTEMTIME st; + GetLocalTime(&st); + + t = (time_t)(((((((st.wYear-1970)*12+st.wMonth)*31+st.wDay)*7+st.wDayOfWeek)*24+st.wHour)*60+st.wMinute)*60+st.wSecond); + + if(res) + *res = t; + return t; +} + +EXT_C struct tm* localtime(time_t* timer) +{ + static struct tm tmLocalTime; + unsigned long rem = *timer; + + tmLocalTime.tm_sec = (short)(rem % 60); + rem /= 60; + tmLocalTime.tm_min = (short)(rem % 60); + rem /= 60; + tmLocalTime.tm_hour = (short)(rem % 24); + rem /= 24; + tmLocalTime.tm_mday = (short)(rem % 7); + rem /= 7; + tmLocalTime.tm_mday = (short)(rem % 31); + rem /= 31; + tmLocalTime.tm_mon = (short)(rem % 12); + rem /= 12; + tmLocalTime.tm_year = (short)(rem+1970); + + return &tmLocalTime; +} + +char cwd[MAX_PATH+1] = ""; +EXT_C char *getcwd(char *buffer, int maxlen) +{ + TCHAR fileUnc[MAX_PATH+1]; + char* plast; + + if(cwd[0] == 0) + { + GetModuleFileName(NULL, fileUnc, MAX_PATH); + WideCharToMultiByte(CP_ACP, 0, fileUnc, -1, cwd, MAX_PATH, NULL, NULL); + plast = strrchr(cwd, '\\'); + if(plast) + *plast = 0; + /* Special trick to keep start menu clean... */ + if(_stricmp(cwd, "\\windows\\start menu") == 0) + strcpy(cwd, "\\Apps"); + } + if(buffer) + strncpy(buffer, cwd, maxlen); + return cwd; +} + +#ifdef __GNUC__ +#undef GetCurrentDirectory +#endif +EXT_C void GetCurrentDirectory(int len, char *buf) +{ + getcwd(buf,len); +}; + +/* +Windows CE fopen has non-standard behavior -- not +fully qualified paths refer to root folder rather +than current folder (concept not implemented in CE). +*/ +#undef fopen +EXT_C FILE *wce_fopen(const char* fname, const char* fmode) +{ + char fullname[MAX_PATH+1]; + + if(!fname || fname[0] == '\0') + return NULL; + if(fname[0] != '\\' && fname[0] != '/') + { + getcwd(fullname, MAX_PATH); + strncat(fullname, "\\", MAX_PATH-strlen(fullname)-1); + strncat(fullname, fname, MAX_PATH-strlen(fullname)-strlen(fname)); + return fopen(fullname, fmode); + } + else + return fopen(fname, fmode); +} + + +// evc only functions follow +#ifndef __GNUC__ + +/* Limited dirent implementation. Used by UI.C and DEVICES.C */ DIR* opendir(const char* fname) { DIR* pdir; @@ -129,45 +283,6 @@ int closedir(DIR* dir) return 1; } -/* Very limited implementation of stat. Used by UI.C, MEMORY-P.C (latter is not critical) */ -int stat(const char *fname, struct stat *ss) -{ - TCHAR fnameUnc[MAX_PATH+1]; - HANDLE handle; - int len; - - if(fname == NULL || ss == NULL) - return -1; - - /* Special case (dummy on WinCE) */ - len = strlen(fname); - if(len >= 2 && fname[len-1] == '.' && fname[len-2] == '.' && - (len == 2 || fname[len-3] == '\\')) - { - /* That's everything implemented so far */ - memset(ss, 0, sizeof(struct stat)); - ss->st_size = 1024; - ss->st_mode |= S_IFDIR; - return 0; - } - - MultiByteToWideChar(CP_ACP, 0, fname, -1, fnameUnc, MAX_PATH); - handle = FindFirstFile(fnameUnc, &wfd); - if(handle == INVALID_HANDLE_VALUE) - return -1; - else - { - /* That's everything implemented so far */ - memset(ss, 0, sizeof(struct stat)); - ss->st_size = wfd.nFileSizeLow; - if(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) - ss->st_mode |= S_IFDIR; - - FindClose(handle); - } - return 0; -} - /* Remove file by name */ int remove(const char* path) { @@ -264,70 +379,6 @@ char *strdup(const char *strSource) return buffer; } -/* Used in UI.C */ -char cwd[MAX_PATH+1] = ""; -char *getcwd(char *buffer, int maxlen) -{ - TCHAR fileUnc[MAX_PATH+1]; - char* plast; - - if(cwd[0] == 0) - { - GetModuleFileName(NULL, fileUnc, MAX_PATH); - WideCharToMultiByte(CP_ACP, 0, fileUnc, -1, cwd, MAX_PATH, NULL, NULL); - plast = strrchr(cwd, '\\'); - if(plast) - *plast = 0; - /* Special trick to keep start menu clean... */ - if(_stricmp(cwd, "\\windows\\start menu") == 0) - strcpy(cwd, "\\Apps"); - } - if(buffer) - strncpy(buffer, cwd, maxlen); - return cwd; -} - -void GetCurrentDirectory(int len, char *buf) -{ - getcwd(buf,len); -}; - -/* Limited implementation of time.h. time_t formula is possibly incorrect. */ -time_t time(time_t* res) -{ - time_t t; - SYSTEMTIME st; - GetLocalTime(&st); - - t = (time_t)(((((((st.wYear-1970)*12+st.wMonth)*31+st.wDay)*7+st.wDayOfWeek)*24+st.wHour)*60+st.wMinute)*60+st.wSecond); - - if(res) - *res = t; - return t; -} - -struct tm* localtime(time_t* timer) -{ - static struct tm tmLocalTime; - unsigned long rem = *timer; - - tmLocalTime.tm_sec = (short)(rem % 60); - rem /= 60; - tmLocalTime.tm_min = (short)(rem % 60); - rem /= 60; - tmLocalTime.tm_hour = (short)(rem % 24); - rem /= 24; - tmLocalTime.tm_mday = (short)(rem % 7); - rem /= 7; - tmLocalTime.tm_mday = (short)(rem % 31); - rem /= 31; - tmLocalTime.tm_mon = (short)(rem % 12); - rem /= 12; - tmLocalTime.tm_year = (short)(rem+1970); - - return &tmLocalTime; -} - /* Very limited implementation of sys/time.h */ void gettimeofday(struct timeval* tp, void* dummy) { @@ -345,30 +396,6 @@ void usleep(long usec) Sleep(msec); } -/* -Windows CE fopen has non-standard behavior -- not -fully qualified paths refer to root folder rather -than current folder (concept not implemented in CE). -*/ -#undef fopen - -FILE* wce_fopen(const char* fname, const char* fmode) -{ - char fullname[MAX_PATH+1]; - - if(!fname || fname[0] == '\0') - return NULL; - if(fname[0] != '\\' && fname[0] != '/') - { - getcwd(fullname, MAX_PATH); - strncat(fullname, "\\", MAX_PATH-strlen(fullname)-1); - strncat(fullname, fname, MAX_PATH-strlen(fullname)-strlen(fname)); - return fopen(fullname, fmode); - } - else - return fopen(fname, fmode); -} - /* This may provide for better sync mechanism */ unsigned int clock() { @@ -399,16 +426,6 @@ char* getenv(char* name) return ""; } -void *bsearch(const void *key, const void *base, size_t nmemb, - size_t size, int (*compar)(const void *, const void *)) { - size_t i; - - for (i=0; i<nmemb; i++) - if (compar(key, (void*)((size_t)base + size * i)) == 0) - return (void*)((size_t)base + size * i); - return NULL; -} - #if _WIN32_WCE < 300 || defined(_TEST_HPC_STDIO) void *calloc(size_t n, size_t s) { @@ -642,3 +659,40 @@ long int strtol(const char *nptr, char **endptr, int base) { #endif +// gcc build only functions follow +#else // defined(__GNUC__) + +int islower(int c) +{ + return (c>='a' && c<='z'); +} + +int isspace(int c) +{ + return (c==' ' || c=='\f' || c=='\n' || c=='\r' || c=='\t' || c=='\v'); +} + +int isalpha(int c) +{ + return (islower(c) || (c>='A' && c<='Z')); +} + +int isalnum(int c) +{ + return (isalpha(c) || (c>='0' && c<='9')); +} + +int isprint(int c) +{ + static char punct[] = "!\"#%&'();<=>?[\\]*+,-./:^_{|}~"; + int i = 0, flag = 0; + while ((punct[i] != 0) && (flag = (punct[i] != c))) + i++; + return (isalnum(c) || flag); +} + +extern "C" int atexit(void (*function)(void)) +{ + return 0; +} +#endif diff --git a/backends/platform/wince/missing/time.h b/backends/platform/wince/missing/time.h index 40c2894dca..3925b18312 100644 --- a/backends/platform/wince/missing/time.h +++ b/backends/platform/wince/missing/time.h @@ -16,8 +16,14 @@ struct tm short tm_sec; }; -time_t time(time_t* dummy); -struct tm* localtime(time_t* dummy); +#ifdef __GNUC__ +#define EXT_C extern "C" +#else +#define EXT_C +#endif + +EXT_C time_t time(time_t* dummy); +EXT_C struct tm* localtime(time_t* dummy); unsigned int clock(); diff --git a/backends/platform/wince/portdefs.h b/backends/platform/wince/portdefs.h index ccd68b13cd..fca78367e4 100644 --- a/backends/platform/wince/portdefs.h +++ b/backends/platform/wince/portdefs.h @@ -43,10 +43,23 @@ char *strpbrk(const char *s, const char *accept); #ifdef _WIN32_WCE -void *bsearch(const void *, const void *, size_t, size_t, int (*x) (const void *, const void *)); -char *getcwd(char *buf, int size); -void GetCurrentDirectory(int len, char *buf); -#define INVALID_FILE_ATTRIBUTES 0xffffffff +#ifndef __GNUC__ + void *bsearch(const void *, const void *, size_t, size_t, int (*x) (const void *, const void *)); + char *getcwd(char *buf, int size); + typedef int ptrdiff_t; + void GetCurrentDirectory(int len, char *buf); + #define INVALID_FILE_ATTRIBUTES 0xffffffff +#else + #include <math.h> + #undef GetCurrentDirectory + extern "C" void GetCurrentDirectory(int len, char *buf); + #define stricmp _stricmp + #define strnicmp _strnicmp + #define snprintf _snprintf + #define strdup _strdup + #define fopen wce_fopen +#endif + #include <windows.h> #include <stdio.h> #include <stdlib.h> @@ -59,13 +72,11 @@ void GetCurrentDirectory(int len, char *buf); #include <assert.h> #include <mmsystem.h> #include <ctype.h> -#include <Winuser.h> #include <direct.h> #include <time.h> void drawError(char*); #define vsnprintf _vsnprintf -typedef int ptrdiff_t; #endif diff --git a/backends/platform/wince/resource.h b/backends/platform/wince/resource.h index 94eb3c12f0..73e57ae46d 100644 --- a/backends/platform/wince/resource.h +++ b/backends/platform/wince/resource.h @@ -1,14 +1,6 @@ -//{{NO_DEPENDENCIES}} -// Microsoft eMbedded Visual C++ generated include file. -// Used by PocketSCUMM.rc -// #define IDI_POCKETSCUMM 101 -#define IDR_SMARTFON_MENUBAR_GAMES 102 -#define IDR_SMARTFON_MENUBAR_OPTIONS 103 -#define IDB_LOGO 106 #define IMAGE_PANEL 109 #define PANEL_GENERIC 109 -#define IMAGE_KEYBOARD 110 #define PANEL_KEYBOARD 110 #define ITEM_SKIP 114 #define ITEM_OPTIONS 115 @@ -17,23 +9,3 @@ #define ITEM_VIEW_PORTRAIT 120 #define ITEM_VIEW_LANDSCAPE 122 #define ITEM_BINDKEYS 125 -#define IDS_CAP_MENUITEM40002 40003 -#define ID_MENU_GAMES 40006 -#define IDM_SMARTFON_SCAN 40007 -#define IDM_SMARTFON_QUIT 40009 -#define IDS_CAP_OPTIONS 40015 -#define ID_MENU_OPTIONS 40016 -#define IDM_SMARTFON_MUSIC 40017 -#define IDM_SMARTFON_SOUND 40017 -#define IDM_SMARTFON_HELP 40021 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 126 -#define _APS_NEXT_COMMAND_VALUE 40022 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/backends/platform/wince/wince-sdl.cpp b/backends/platform/wince/wince-sdl.cpp index e9c6ce45d1..8e4b822c47 100644 --- a/backends/platform/wince/wince-sdl.cpp +++ b/backends/platform/wince/wince-sdl.cpp @@ -119,10 +119,8 @@ bool isSmartphone() { return _hasSmartphoneResolution; } -// ******************************************************************************************** - // MAIN - +#ifndef __GNUC__ int handleException(EXCEPTION_POINTERS *exceptionPointers) { CEException::writeException(TEXT("\\scummvmCrash"), exceptionPointers); drawError("Unrecoverable exception occurred - see crash dump in latest \\scummvmCrash file"); @@ -133,28 +131,37 @@ int handleException(EXCEPTION_POINTERS *exceptionPointers) { exit(0); return EXCEPTION_EXECUTE_HANDLER; } +#endif OSystem *OSystem_WINCE3_create() { return new OSystem_WINCE3(); } int SDL_main(int argc, char **argv) { + +#ifdef __GNUC__ + // Due to incomplete crt0.o implementation, we go through the constructor function + // list provided by the linker and init all of them + // thanks to joostp and DJWillis + extern void (*__CTOR_LIST__)() ; + void (**constructor)() = &__CTOR_LIST__ ; + constructor++ ; + while(*constructor) { + (*constructor)() ; + constructor++ ; + } +#endif + CEDevice::init(); OSystem_WINCE3::initScreenInfos(); - /* Sanity check */ -//#ifndef WIN32_PLATFORM_WFSP -// if (CEDevice::hasSmartphoneResolution()) { -// MessageBox(NULL, TEXT("This build was not compiled with Smartphone support"), TEXT("ScummVM error"), MB_OK | MB_ICONERROR); -// return 0; -// } -//#endif + /* Avoid print problems - this file will be put in RAM anyway */ stdout_file = fopen("\\scummvm_stdout.txt", "w"); stderr_file = fopen("\\scummvm_stderr.txt", "w"); int res = 0; -#ifndef DEBUG +#if !defined(DEBUG) && !defined(__GNUC__) __try { #endif g_system = OSystem_WINCE3_create(); @@ -162,8 +169,9 @@ int SDL_main(int argc, char **argv) { // Invoke the actual ScummVM main entry point: res = scummvm_main(argc, argv); + //res = scummvm_main(0, NULL); g_system->quit(); // TODO: Consider removing / replacing this! -#ifndef DEBUG +#if !defined(DEBUG) && !defined(__GNUC__) } __except (handleException(GetExceptionInformation())) { } @@ -574,14 +582,14 @@ bool OSystem_WINCE3::checkOggHighSampleRate() { if (!ov_open(testFile, test_ov_file, NULL, 0)) { bool highSampleRate = (ov_info(test_ov_file, -1)->rate == 22050); ov_clear(test_ov_file); - delete test_ov_file; + delete test_ov_file; return highSampleRate; } } // Do not test for OGG samples - too big and too slow anyway :) - delete test_ov_file; + delete test_ov_file; return false; } #endif @@ -1304,12 +1312,14 @@ void OSystem_WINCE3::update_keyboard() { if (_monkeyKeyboard && !_isSmartphone) if (!_panelVisible || _toolbarHandler.activeName() != NAME_PANEL_KEYBOARD) swap_panel(); +#ifndef DISABLE_SCUMM if (_monkeyKeyboard && Scumm::g_scumm->VAR_ROOM != 0xff && Scumm::g_scumm && Scumm::g_scumm->VAR(Scumm::g_scumm->VAR_ROOM) != 108 && Scumm::g_scumm->VAR(Scumm::g_scumm->VAR_ROOM) != 90) { // Switch back to the normal panel now that the keyboard is not used anymore _monkeyKeyboard = false; _toolbarHandler.setActive(NAME_MAIN_PANEL); } +#endif } void OSystem_WINCE3::internUpdateScreen() { @@ -2042,7 +2052,7 @@ bool OSystem_WINCE3::pollEvent(Event &event) { if (_modeChanged) { _modeChanged = false; event.type = EVENT_SCREEN_CHANGED; - screenChangeCount++; + _screenChangeCount++; return true; } diff --git a/backends/platform/wince/wince-sdl.h b/backends/platform/wince/wince-sdl.h index ae1d252f2d..cd1598c9df 100644 --- a/backends/platform/wince/wince-sdl.h +++ b/backends/platform/wince/wince-sdl.h @@ -30,8 +30,8 @@ #include "backends/intern.h" #include "backends/platform/sdl/sdl-common.h" -#include "CEgui.h" -#include "CEkeys.h" +#include "CEGUI.h" +#include "CEKeys.h" #include "CEDevice.h" #include "CEScaler.h" diff --git a/common/scummsys.h b/common/scummsys.h index 0fdecf791a..d586e9795a 100644 --- a/common/scummsys.h +++ b/common/scummsys.h @@ -119,8 +119,10 @@ #define SCUMM_LITTLE_ENDIAN - #define FORCEINLINE __forceinline - #define NORETURN _declspec(noreturn) + #ifndef __GNUC__ + #define FORCEINLINE __forceinline + #define NORETURN _declspec(noreturn) + #endif #define PLUGIN_EXPORT __declspec(dllexport) #if _WIN32_WCE < 300 @@ -133,11 +135,6 @@ typedef unsigned char uint8_t; typedef unsigned short uint16_t; - #if !defined(SDL_COMPILEDVERSION) || (SDL_COMPILEDVERSION < 1210) - typedef signed long int32_t; - typedef unsigned long uint32_t; - #endif - #elif defined(_MSC_VER) #define scumm_stricmp stricmp diff --git a/common/util.cpp b/common/util.cpp index e3bc306c30..aee003363b 100644 --- a/common/util.cpp +++ b/common/util.cpp @@ -25,6 +25,11 @@ #include "common/system.h" #include "gui/debugger.h" +#ifdef _WIN32_WCE +// This is required for the debugger attachment +extern bool isSmartphone(void); +#endif + namespace Common { // diff --git a/engines/scumm/input.cpp b/engines/scumm/input.cpp index 108d88585d..e041f62028 100644 --- a/engines/scumm/input.cpp +++ b/engines/scumm/input.cpp @@ -295,10 +295,6 @@ void ScummEngine::processInput() { #ifdef _WIN32_WCE if (lastKeyHit == KEY_ALL_SKIP) { - // Skip cutscene - if (_smushActive || vm.cutScenePtr[vm.cutSceneStackPointer]) - lastKeyHit = (VAR_CUTSCENEEXIT_KEY != 0xFF) ? (uint)VAR(VAR_CUTSCENEEXIT_KEY) : 27; - else // Skip talk if (VAR_TALKSTOP_KEY != 0xFF && _talkDelay > 0) lastKeyHit = (uint)VAR(VAR_TALKSTOP_KEY); @@ -337,6 +333,7 @@ void ScummEngine_v7::processKeyboard(int lastKeyHit) { return; } +#ifndef _WIN32_WCE if (VAR_CUTSCENEEXIT_KEY != 0xFF && lastKeyHit == VAR(VAR_CUTSCENEEXIT_KEY)) { // Skip cutscene (or active SMUSH video). if (_smushActive) { @@ -351,6 +348,30 @@ void ScummEngine_v7::processKeyboard(int lastKeyHit) { _mouseAndKeyboardStat = lastKeyHit; return; } +#else + // On WinCE we've also got one special for skipping cutscenes or dialog, whatever is appropriate + // Since _smushActive is not a member of the base case class ScummEngine::, we detect here if we're + // playing a cutscene and skip it; else we forward the keystroke through to ScummEngine::processInput. + if (lastKeyHit == KEY_ALL_SKIP || (VAR_CUTSCENEEXIT_KEY != 0xFF && lastKeyHit == VAR(VAR_CUTSCENEEXIT_KEY))) { + int bail = 1; + if (_smushActive) { + if (_game.id == GID_FT) { + _insane->escapeKeyHandler(); + bail = 0; + } else + _smushVideoShouldFinish = true; + } + if ((!_smushActive && vm.cutScenePtr[vm.cutSceneStackPointer]) || _smushVideoShouldFinish) { + abortCutscene(); + bail = 0; + } + if (!bail) { + _mouseAndKeyboardStat = (VAR_CUTSCENEEXIT_KEY != 0xFF) ? (uint)VAR(VAR_CUTSCENEEXIT_KEY) : 27; + return; + } + + } +#endif // Fall back to V6 behavior ScummEngine_v6::processKeyboard(lastKeyHit); |