@@ -47,12 +47,12 @@ ABI_ATTR char (*Variable_SetBuiltIn_Direct)(void* inst, int var_slot, int array_
4747ABI_ATTR void (*Code_Function_GET_the_function)(int numb,char **name,void **code,int *args, int *unk) = NULL;
4848ABI_ATTR void (*_RefThing__dec)(void *ref) = NULL;
4949ABI_ATTR int (*Variable_BuiltIn_Find)(const char *name) = NULL;
50+ ABI_ATTR long (*PrepareGame)(void ) = NULL;
5051ABI_ATTR int (*Code_Variable_Find_Slot_From_Name)(void *instance, const char *name) = NULL;
5152ABI_ATTR int (*Variable_FindName)(const char *name) = NULL; /* Unavailable in GMS 1.4+, very old symbol */
5253ABI_ATTR long (*ExecuteIt)(void *self, void *other, void *code, RValue *args) = NULL;
5354ABI_ATTR long (*ExecuteIt_flags)(void *self, void *other, void *code, RValue *args, int argc) = NULL;
5455
55-
5656bionic_off_t *g_GameFileLength = NULL ; // android had 32bit off_t???
5757char **g_pWorkingDirectory = NULL ;
5858char *g_fNoAudio = NULL ;
@@ -87,6 +87,8 @@ void **g_pGameFileBuffer = NULL;
8787void **g_ppYYStackTrace = NULL ;
8888int *Extension_Main_number = NULL ;
8989
90+ ReentrantHook REHPrepareGame = {};
91+
9092uint8_t prev_kbd_state[N_KEYS ] = {};
9193uint8_t cur_keys[N_KEYS ] = {};
9294
@@ -246,6 +248,16 @@ ABI_ATTR void game_change_reimpl(RValue *ret, void *self, void *other, int argc,
246248 }
247249}
248250
251+ extern int setup_ended;
252+ ABI_ATTR long PrepareGame_hook ()
253+ {
254+ setup_ended = 1 ;
255+ rehook_unhook (&REHPrepareGame);
256+ long ret = PrepareGame ();
257+ warning (" - PrepareGame done.\n " );
258+ return ret;
259+ }
260+
249261void patch_libyoyo (so_module *mod)
250262{
251263 // Load all of the native symbols referenced
@@ -323,6 +335,11 @@ void patch_libyoyo(so_module *mod)
323335 // Depth disable
324336 FIND_SYMBOL (mod, surface_depth_disable, " _Z21F_SurfaceDepthDisableR6RValueP9CInstanceS2_iPS_" );
325337
338+ // Hook the start of the game so we know setup is done
339+ ENSURE_SYMBOL (mod, PrepareGame, " _Z11PrepareGamev" );
340+ rehook_new (mod, &REHPrepareGame, (uintptr_t )PrepareGame, (uintptr_t )&PrepareGame_hook);
341+ rehook_hook (&REHPrepareGame);
342+
326343 // Disable extension support
327344 FIND_SYMBOL (mod, Extension_Main_number, " Extension_Main_number" );
328345 if (gmloader_config.disable_extensions == 1 ) {
0 commit comments