// note: int execv(const char *path, char *const argv[]); // - where the array of strings is terminated with a null string // - i.e. this is a bit different for now int execz(const char* filename, int argc, const char** argv) { struct stat st; char filePath[MAXPATHLEN * 2]; int pathLen; const char* args[1]; int i; if (stat (filename, &st) < 0) { return 1; } if (argc <= 0 || !argv) { // Construct a command line if we weren't supplied with one if (!getcwd (filePath, MAXPATHLEN)) { return 2; } pathLen = strlen (filePath); strcpy (filePath + pathLen, filename); args[0] = filePath; argv = args; } // shutdown sound subsystem // note: EffectCancelAll seems to fail to stop // the current sample mmEffectCancelAll(); mmStop(); while (mmActive()) { swiWaitForVBlank(); } // shutdown network subsystem Wifi_DisconnectAP(); Wifi_DisableWifi(); // wait a bit: race condition?? for (i = 0 ; i < 42 ; i++) { swiWaitForVBlank(); } return runNds (load_bin, load_bin_size, st.st_ino, false, true, argc, argv); }
void game_manager::vblank_func() { // If a bug was automatically detected. if ( curr_game_mode == gm_do_halt ) { // Stop the sound stuff if (mmActive()) { //mmPause(); mmSetModuleVolume(static_cast<mm_word>(0)); mmSetJingleVolume(static_cast<mm_word>(0)); mmEffectCancelAll(); mmFrame(); //mmPause(); //mmStop(); } // Enable forced blank reg_dispcnt = dcnt_blank_on; return; } gfx_manager::copy_bgofs_mirror_to_registers(); //mmFrame(); key_poll(); //pause_or_unpause_music(); if ( curr_game_mode != gm_title_screen && curr_game_mode != gm_initializing_the_game ) { mmFrame(); } switch ( curr_game_mode ) { // When on the title screen. case gm_title_screen: break; // When initializing the game case gm_initializing_the_game: break; // When loading a level. case gm_loading_level: hud_manager::hud_was_generated = false; break; // When changing from one sublevel to another. case gm_changing_sublevel: break; // When in a sublevel. case gm_in_sublevel: //gfx_manager::copy_bgofs_mirror_to_registers(); gfx_manager::upload_bg_tiles_to_vram(); copy_oam_mirror_to_oam(); active_level_manager ::copy_sublevel_from_array_2d_helper_to_vram(); sprite_manager::upload_tiles_of_active_sprites_to_vram(); hud_manager::update_hud_in_screenblock_mirror_2d(); hud_manager::copy_hud_from_array_2d_helper_to_vram(); break; // If a bug was automatically detected (this should never be the // case since gm_do_halt is handled at the start of this function). case gm_do_halt: break; default: break; } }