diff options
-rw-r--r-- | backends/platform/symbian/src/SymbianOS.cpp | 20 | ||||
-rw-r--r-- | backends/platform/symbian/src/portdefs.h | 42 |
2 files changed, 30 insertions, 32 deletions
diff --git a/backends/platform/symbian/src/SymbianOS.cpp b/backends/platform/symbian/src/SymbianOS.cpp index 3ca6546276..5a5c681e2e 100644 --- a/backends/platform/symbian/src/SymbianOS.cpp +++ b/backends/platform/symbian/src/SymbianOS.cpp @@ -479,6 +479,26 @@ RFs& OSystem_SDL_Symbian::FsSession() { return *_RFs; } +// Symbian bsearch implementation is flawed +void* scumm_bsearch(const void *key, const void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *)) { + // Perform binary search + size_t lo = 0; + size_t hi = nmemb; + while (lo < hi) { + size_t mid = (lo + hi) / 2; + const void *p = ((const char *)base) + mid * size; + int tmp = (*compar)(key, p); + if (tmp < 0) + hi = mid; + else if (tmp > 0) + lo = mid + 1; + else + return (void *)p; + } + + return NULL; +} + FILE* symbian_fopen(const char* name, const char* mode) { TSymbianFileEntry* fileEntry = new TSymbianFileEntry; fileEntry->iInputPos = KErrNotFound; diff --git a/backends/platform/symbian/src/portdefs.h b/backends/platform/symbian/src/portdefs.h index 7e1fd0993a..4d1b0d6d5a 100644 --- a/backends/platform/symbian/src/portdefs.h +++ b/backends/platform/symbian/src/portdefs.h @@ -35,9 +35,6 @@ #include <e32std.h> #include <math.h> -//#define DISABLE_SCALERS // we only need 1x -//#define DISABLE_HQ_SCALERS - #if defined(USE_TREMOR) && !defined(USE_VORBIS) #define USE_VORBIS // make sure this one is defined together with USE_TREMOR! #endif @@ -107,29 +104,19 @@ */ #elif defined (__WINS__) // WINS + extern "C" int SDL_snprintf(char *text, size_t maxlen, const char *fmt, ...); + extern "C" int SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap); + #define snprintf(buf,len,args...) SDL_snprintf(buf,len,args) + #define vsnprintf(buf,len,format,valist) SDL_vsnprintf(buf,len,format,valist) - // let's just blatantly ignore this for now and just get it to work :P but does n't work from the debug function - int inline scumm_snprintf (char *str, unsigned long /*n*/, char const *fmt, ...) { - va_list args; - va_start(args, fmt); - vsprintf(str, fmt, args); - va_end(args); - return strlen(str); - } - - int inline scumm_vsnprintf (char *str, unsigned long /*n*/, char const *fmt, va_list valist) { - vsprintf(str, fmt, valist); - return strlen(str); - } - - #define snprintf scumm_snprintf - #define vsnprintf scumm_vsnprintf void* symbian_malloc (size_t _size); #define malloc symbian_malloc #else // GCCE and the rest - #define snprintf(buf,len,args...) sprintf(buf,args) - #define vsnprintf(buf,len,format,valist) vsprintf(buf,format,valist) + extern "C" int SDL_snprintf(char *text, size_t maxlen, const char *fmt, ...); + extern "C" int SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap); + #define snprintf(buf,len,args...) SDL_snprintf(buf,len,args) + #define vsnprintf(buf,len,format,valist) SDL_vsnprintf(buf,len,format,valist) #endif #ifndef __WINS__ @@ -138,19 +125,10 @@ #define USE_ARM_COSTUME_ASM #define USE_ARM_SOUND_ASM #endif -// somehow nobody has this function... -#define hypot(a, b) sqrt((a)*(a) + (b)*(b)) // Symbian bsearch implementation is flawed -void inline *scumm_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; -} -#define bsearch scumm_bsearch +void *scumm_bsearch(const void *key, const void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *)); +#define bsearch scumm_bsearch // we cannot include SymbianOS.h everywhere, but this works too (functions code is in SymbianOS.cpp) namespace Symbian { |