--- deliantra/Deliantra-Client/Client.xs 2010/10/14 00:02:39 1.306 +++ deliantra/Deliantra-Client/Client.xs 2012/01/18 23:34:44 1.315 @@ -579,23 +579,27 @@ } static void -deliantra_main () +deliantra_main (SV *real_main) { - char *argv[] = { 0 }; - call_argv ("::main", G_DISCARD | G_VOID, argv); + dSP; + + PUSHMARK (SP); + call_sv (real_main, G_DISCARD | G_VOID); } #ifdef __MACOSX__ + static SV *real_main; + /* to due surprising braindamage on the side of SDL design, we * do some mind-boggling hack here: SDL requires a custom main() * on OS X, so... we provide one and call the original main(), which, - * due to share dlibrary magic, calls -lSDLmain's main, not perl's main, + * due to shared library magic, calls -lSDLmain's main, not perl's main, * and which calls our main (== SDL_main) back. */ extern C_LINKAGE int main (int argc, char *argv[]) { - deliantra_main (); + deliantra_main (real_main); } #undef main @@ -603,16 +607,18 @@ extern C_LINKAGE int main (int argc, char *argv[]); static void - SDL_braino (void) + SDL_main_hack (SV *real_main_) { + real_main = real_main_; + char *argv[] = { "deliantra client", 0 }; (main) (1, argv); } #else static void - SDL_braino (void) + SDL_main_hack (SV *real_main) { - deliantra_main (); + deliantra_main (real_main); } #endif @@ -823,8 +829,8 @@ # undef const_iv }; - for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) - newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); + for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--) + newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); assert (SDLK_MODIFIER_MIN == SDLK_NUMLOCK); assert (SDLK_MODIFIER_MAX == SDLK_COMPOSE); @@ -873,7 +879,8 @@ char *SDL_GetError () -void SDL_braino () +void SDL_main_hack (SV *real_main) + PROTOTYPE: & int SDL_Init (U32 flags) @@ -952,12 +959,9 @@ if (RETVAL) { av_clear (texture_av); - - SDL_WM_SetCaption ("Deliantra MORPG Client " VERSION, "Deliantra"); #define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name); #include "glfunc.h" #undef GL_FUNC - if (!gl.ActiveTexture ) gl.ActiveTexture = gl.ActiveTextureARB; if (!gl.MultiTexCoord2f) gl.MultiTexCoord2f = gl.MultiTexCoord2fARB; } @@ -966,6 +970,9 @@ RETVAL void +SDL_WM_SetCaption (const char *title, const char *icon) + +void SDL_GL_SwapBuffers () char * @@ -977,8 +984,15 @@ int SDL_GetModState () +int +SDL_WaitEvent () + C_ARGS: 0 + +void +SDL_PumpEvents () + void -poll_events () +peep_events () PPCODE: { SDL_Event ev; @@ -1142,6 +1156,10 @@ void IMG_Init (int flags = IMG_INIT_JPG | IMG_INIT_PNG) +# MIX_INIT_MP3 gives smpeg + libstdc++ + libgcc_s +void +Mix_Init (int flags = MIX_INIT_MOD | MIX_INIT_OGG) + void load_image_inline (SV *image_) ALIAS: @@ -2568,9 +2586,10 @@ int sh1 = sh + 2; int sh3 = sh * 3; int sw3 = sw * 3; - uint8_t *darkness1 = (uint8_t *)malloc (sw1 * sh1); SV *darkness3_sv = sv_2mortal (newSV (sw3 * sh3)); uint8_t *darkness3 = (uint8_t *)SvPVX (darkness3_sv); + uint8_t *darkness1 = (uint8_t *)malloc (sw1 * sh1); + memset (darkness1, 0, sw1*sh1); SvPOK_only (darkness3_sv); SvCUR_set (darkness3_sv, sw3 * sh3); @@ -3159,8 +3178,8 @@ # undef const_iv }; - for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) - newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); + for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--) + newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); texture_av = newAV (); AvREAL_off (texture_av);