diff options
author | CeRiAl | 2011-10-18 13:10:20 +0200 |
---|---|---|
committer | CeRiAl | 2011-10-18 13:10:20 +0200 |
commit | a97cd0077fbe2df315a9356e38b39a5065b77c02 (patch) | |
tree | 9437da60a9203d3918c56848bcad265f06bb442f /backends/platform | |
parent | 757c522dd1a9ed431e6621dabed776211651ff31 (diff) | |
download | scummvm-rg350-a97cd0077fbe2df315a9356e38b39a5065b77c02.tar.gz scummvm-rg350-a97cd0077fbe2df315a9356e38b39a5065b77c02.tar.bz2 scummvm-rg350-a97cd0077fbe2df315a9356e38b39a5065b77c02.zip |
WINCE: Add workaround for memory management problem on Windows CE < 6.0
This fixes the "32MB memory limit per process" problem in Windows CE < 6.0
Diffstat (limited to 'backends/platform')
-rw-r--r-- | backends/platform/wince/README-WinCE.txt | 21 | ||||
-rw-r--r-- | backends/platform/wince/wince-sdl.cpp | 44 | ||||
-rw-r--r-- | backends/platform/wince/wince.mk | 4 |
3 files changed, 61 insertions, 8 deletions
diff --git a/backends/platform/wince/README-WinCE.txt b/backends/platform/wince/README-WinCE.txt index 60bcf710bb..429168c293 100644 --- a/backends/platform/wince/README-WinCE.txt +++ b/backends/platform/wince/README-WinCE.txt @@ -1,18 +1,23 @@ ScummVM Windows CE FAQ -Last updated: 2011-07-20 -Release version: x.x.x +Last updated: 2011-10-15 +Release version: 1.4.0 ------------------------------------------------------------------------ New in this version ------------------- -x.x.x: -- Changed default values for "high_sample_rate" & "FM_high_quality" to "true" as - most devices today are fast enough to handle this. It's still possible to set - this to "false" if you have a slower device. +1.4.0: +- Changed the memory management so that it is finally possible to break the + 32MB per process barrier on Windows CE. It should be possible now (finally) + to play nearly every game with the "big" binary (scummvm.exe, which includes + all game engines). +- Changed default values for "high_sample_rate" & "FM_high_quality" to "true" + as most devices today are fast enough to handle this. It's still possible to + set this to "false" if you have a slower device. - Fix for TeenAgent & Hugo engines (both weren't running at all, crashed right at the beginning) -- Replaced the game mass-adding functionality with the functionality used on all - other platforms. It now shows progress while searching for games. +- Discworld 2 is now playable (works now because of the new memory management) +- Replaced the game mass-adding functionality with the functionality used on + all other platforms. It now shows progress while searching for games. 1.3.1: - Fix for Normal2xAspect scaler which was causing screen update issues in some diff --git a/backends/platform/wince/wince-sdl.cpp b/backends/platform/wince/wince-sdl.cpp index 1abc3cb350..4e17827e5c 100644 --- a/backends/platform/wince/wince-sdl.cpp +++ b/backends/platform/wince/wince-sdl.cpp @@ -72,6 +72,50 @@ extern "C" _CRTIMP FILE *__cdecl _wfreopen(const wchar_t *, const wchar_t *, FILE *); #endif +#ifdef WRAP_MALLOC + +extern "C" void *__real_malloc(size_t size); +extern "C" void __real_free(void *ptr); + +extern "C" void *__wrap_malloc(size_t size) { +/* + void *ptr = __real_malloc(size); + printf("malloc(%d) = %p\n", size, ptr); + return ptr; +*/ + if (size < 64 * 1024) { + void *ptr = __real_malloc(size+4); +// printf("malloc(%d) = %p\n", size, ptr); + if (ptr != NULL) { + *((HANDLE*)ptr) = 0; + return 4+(char*)ptr; + } + return NULL; + } + HANDLE H = CreateFileMapping((HANDLE)INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, size+4, 0); + void *ptr = MapViewOfFile(H, FILE_MAP_ALL_ACCESS, 0, 0, 0); + *((HANDLE*)ptr) = H; + return 4+(char*)ptr; +} + +extern "C" void __wrap_free(void *ptr) { +/* + __real_free(ptr); + printf("free(%p)\n", ptr); +*/ + if (ptr != NULL) { + HANDLE H = *(HANDLE*)((char *)ptr-4); + if (H == 0) { + __real_free((char*)ptr-4); + return; + } + UnmapViewOfFile((char *)ptr-4); + CloseHandle(H); + } +} + +#endif + using namespace CEGUI; // ******************************************************************************************** diff --git a/backends/platform/wince/wince.mk b/backends/platform/wince/wince.mk index cac3ad4e8f..c5f3274747 100644 --- a/backends/platform/wince/wince.mk +++ b/backends/platform/wince/wince.mk @@ -1,3 +1,7 @@ +ifdef WRAP_MALLOC + LDFLAGS += -Wl,--wrap,malloc -Wl,--wrap,free +endif + backends/platform/wince/PocketSCUMM.o: $(srcdir)/backends/platform/wince/PocketSCUMM.rc $(QUIET)$(MKDIR) $(*D) $(WINDRES) $(WINDRESFLAGS) -I$(srcdir)/backends/platform/wince $< $@ |