From dfa212aaf9a64fd55d6a9d68d6714a1fa2a21777 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Tue, 1 May 2012 12:40:08 +0000 Subject: [PATCH] Patch adding Wii support by tueidj, part 8: system-specific changes - conditionally compiles out some code intended for the PC platforms - compat.c: get home directory routine, access() implementation - game.c: don't use ioctl(), lower cache1d size to 8 MiB, Wii-specific initialization code and application directory ("apps/eduke32") git-svn-id: https://svn.eduke32.com/eduke32@2628 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/baselayer.c | 2 +- polymer/eduke32/build/src/compat.c | 21 ++++++++++++++++++++- polymer/eduke32/build/src/sdlayer.c | 2 +- polymer/eduke32/source/game.c | 23 +++++++++++++++++++++++ polymer/eduke32/source/sdlmusic.c | 2 +- 5 files changed, 46 insertions(+), 4 deletions(-) diff --git a/polymer/eduke32/build/src/baselayer.c b/polymer/eduke32/build/src/baselayer.c index fe0b15d7b..326383bdc 100644 --- a/polymer/eduke32/build/src/baselayer.c +++ b/polymer/eduke32/build/src/baselayer.c @@ -377,7 +377,7 @@ int32_t baselayer_init(void) void makeasmwriteable(void) { -#ifndef NOASM +#if !defined(NOASM) && !defined(GEKKO) extern int32_t dep_begin, dep_end; # if defined _WIN32 DWORD oldprot; diff --git a/polymer/eduke32/build/src/compat.c b/polymer/eduke32/build/src/compat.c index 1987bf8c6..f9b2c59c3 100644 --- a/polymer/eduke32/build/src/compat.c +++ b/polymer/eduke32/build/src/compat.c @@ -396,6 +396,14 @@ char *Bgethomedir(void) if (s) s = Bstrdup(s); CFRelease(str); return s; +#elif defined(GEKKO) + // return current drive's name + char *drv, cwd[BMAX_PATH] = {0}; + getcwd(cwd, BMAX_PATH); + drv = strchr(cwd, ':'); + if (drv) + drv[1] = '\0'; + return Bstrdup(cwd); #else char *e = getenv("HOME"); if (!e) return NULL; @@ -845,7 +853,7 @@ uint32_t Bgetsysmemsize(void) } return siz; -#elif (defined(_SC_PAGE_SIZE) || defined(_SC_PAGESIZE)) && defined(_SC_PHYS_PAGES) +#elif (defined(_SC_PAGE_SIZE) || defined(_SC_PAGESIZE)) && defined(_SC_PHYS_PAGES) && !defined(GEKKO) uint32_t siz = UINT_MAX; int64_t scpagesiz, scphyspages; @@ -867,5 +875,16 @@ uint32_t Bgetsysmemsize(void) #endif } +#ifdef GEKKO +int access(const char *pathname, int mode) +{ + struct stat st; + if (stat(pathname, &st)==-1) + return -1; + // TODO: Check mode against st_mode + + return 0; +} +#endif diff --git a/polymer/eduke32/build/src/sdlayer.c b/polymer/eduke32/build/src/sdlayer.c index 5b6c96ed8..921328483 100644 --- a/polymer/eduke32/build/src/sdlayer.c +++ b/polymer/eduke32/build/src/sdlayer.c @@ -242,7 +242,7 @@ void setvsync(int32_t sync) static void attach_debugger_here(void) {} /* XXX: libexecinfo could be used on systems without gnu libc. */ -#if defined __GNUC__ && !defined __OpenBSD__ && !(defined __APPLE__ && defined __BIG_ENDIAN__) +#if defined __GNUC__ && !defined __OpenBSD__ && !(defined __APPLE__ && defined __BIG_ENDIAN__) && !defined(GEKKO) # define PRINTSTACKONSEGV 1 # include #endif diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index 505e66f51..be31c47e2 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -76,7 +76,9 @@ extern int32_t G_GetVersionFromWebsite(char *buffer); #define UPDATEINTERVAL 604800 // 1w #else static int32_t usecwd = 0; +#ifndef GEKKO #include +#endif #endif /* _WIN32 */ int32_t g_quitDeadline = 0; @@ -183,7 +185,11 @@ static char user_quote[MAXUSERQUOTES][178]; // This was 32 for a while, but I think lowering it to 24 will help things like the Dingoo. // Ideally, we would look at our memory usage on our most cramped platform and figure out // how much of that is needed for the underlying OS and things like SDL instead of guessing +#ifndef GEKKO static int32_t MAXCACHE1DSIZE = (24*1048576); +#else +static int32_t MAXCACHE1DSIZE = (8*1048576); +#endif int32_t tempwallptr; @@ -9792,6 +9798,12 @@ void app_crashhandler(void) } #endif +#ifdef GEKKO +void L2Enhance(); +void CON_EnableGecko(int channel,int safe); +bool fatInit (uint32_t cacheSize, bool setAsDefaultDevice); +#endif + int32_t app_main(int32_t argc, const char **argv) { int32_t i = 0, j; @@ -9803,6 +9815,13 @@ int32_t app_main(int32_t argc, const char **argv) ENetCallbacks callbacks = { NULL, NULL, NULL }; #endif +#ifdef GEKKO + L2Enhance(); + CON_EnableGecko(1, 1); + printf("Console started\n"); + fatInit(28, true); +#endif + #ifdef RENDERTYPEWIN if (argc > 1) { @@ -9925,6 +9944,8 @@ int32_t app_main(int32_t argc, const char **argv) "EDuke32 Settings" #elif defined(__APPLE__) "Library/Application Support/EDuke32" +#elif defined(GEKKO) + "apps/eduke32" #else ".eduke32" #endif @@ -10586,7 +10607,9 @@ MAIN_LOOP_RESTART: static uint32_t bufpos = 0; static char buf[128]; +#ifndef GEKKO ioctl(0, FIONBIO, &flag); +#endif if ((nb = read(0, &ch, 1)) > 0 && bufpos < sizeof(buf)) { diff --git a/polymer/eduke32/source/sdlmusic.c b/polymer/eduke32/source/sdlmusic.c index a64e6200d..adf201a49 100644 --- a/polymer/eduke32/source/sdlmusic.c +++ b/polymer/eduke32/source/sdlmusic.c @@ -41,7 +41,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "sdl_inc.h" #include "music.h" -#if !defined _WIN32 +#if !defined _WIN32 && !defined(GEKKO) # define FORK_EXEC_MIDI 1 #endif