mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-25 21:45:12 +00:00
use a wrapper for exiting instead of just calling exit()
this might also fix the webgl build issue
This commit is contained in:
parent
62cc4620ec
commit
ece7649b4b
5 changed files with 50 additions and 58 deletions
|
@ -29,8 +29,7 @@
|
||||||
#include "course_table.h"
|
#include "course_table.h"
|
||||||
#include "thread6.h"
|
#include "thread6.h"
|
||||||
#include "../../include/libc/stdlib.h"
|
#include "../../include/libc/stdlib.h"
|
||||||
#include "../pc/configfile.h"
|
#include "../pc/pc_main.h"
|
||||||
#define CONFIG_FILE "sm64config.txt"
|
|
||||||
|
|
||||||
#include "pc/cliopts.h"
|
#include "pc/cliopts.h"
|
||||||
|
|
||||||
|
@ -1024,32 +1023,23 @@ s32 play_mode_paused(void) {
|
||||||
raise_background_noise(1);
|
raise_background_noise(1);
|
||||||
gCameraMovementFlags &= ~CAM_MOVE_PAUSE_SCREEN;
|
gCameraMovementFlags &= ~CAM_MOVE_PAUSE_SCREEN;
|
||||||
set_play_mode(PLAY_MODE_NORMAL);
|
set_play_mode(PLAY_MODE_NORMAL);
|
||||||
}
|
} else if (gPauseScreenMode == 2) {
|
||||||
// Exit level
|
// Exit level
|
||||||
else if (gPauseScreenMode == 2) {
|
|
||||||
|
|
||||||
if (gDebugLevelSelect) {
|
if (gDebugLevelSelect) {
|
||||||
fade_into_special_warp(-9, 1);
|
fade_into_special_warp(-9, 1);
|
||||||
}
|
} else {
|
||||||
|
|
||||||
else {
|
|
||||||
initiate_warp(LEVEL_CASTLE, 1, 0x1F, 0);
|
initiate_warp(LEVEL_CASTLE, 1, 0x1F, 0);
|
||||||
fade_into_special_warp(0, 0);
|
fade_into_special_warp(0, 0);
|
||||||
gSavedCourseNum = COURSE_NONE;
|
gSavedCourseNum = COURSE_NONE;
|
||||||
}
|
}
|
||||||
|
} else if (gPauseScreenMode == 3) {
|
||||||
} // end of gPauseScreenMode == 2 for "EXIT COURSE" option
|
// We should only be getting "int 3" to here
|
||||||
|
|
||||||
if (gPauseScreenMode == 3) { // We should only be getting "int 3" to here
|
|
||||||
initiate_warp(LEVEL_CASTLE, 1, 0x1F, 0);
|
initiate_warp(LEVEL_CASTLE, 1, 0x1F, 0);
|
||||||
fade_into_special_warp(0, 0);
|
fade_into_special_warp(0, 0);
|
||||||
|
game_exit();
|
||||||
//configfile_save(CONFIG_FILE);
|
|
||||||
exit(0); // Appears to automatically save config on exit!
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gCameraMovementFlags &= ~CAM_MOVE_PAUSE_SCREEN;
|
gCameraMovementFlags &= ~CAM_MOVE_PAUSE_SCREEN;
|
||||||
// }
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,7 @@
|
||||||
#include "dialog_ids.h"
|
#include "dialog_ids.h"
|
||||||
#include "thread6.h"
|
#include "thread6.h"
|
||||||
#include "../../include/libc/stdlib.h"
|
#include "../../include/libc/stdlib.h"
|
||||||
#include "../pc/configfile.h"
|
#include "../pc/pc_main.h"
|
||||||
#define CONFIG_FILE "sm64config.txt"
|
|
||||||
|
|
||||||
// TODO: put this elsewhere
|
// TODO: put this elsewhere
|
||||||
enum SaveOption { SAVE_OPT_SAVE_AND_CONTINUE = 1, SAVE_OPT_SAVE_AND_QUIT, SAVE_OPT_SAVE_EXIT_GAME, SAVE_OPT_CONTINUE_DONT_SAVE };
|
enum SaveOption { SAVE_OPT_SAVE_AND_CONTINUE = 1, SAVE_OPT_SAVE_AND_QUIT, SAVE_OPT_SAVE_EXIT_GAME, SAVE_OPT_CONTINUE_DONT_SAVE };
|
||||||
|
@ -263,17 +262,11 @@ void handle_save_menu(struct MarioState *m) {
|
||||||
|
|
||||||
if (gSaveOptSelectIndex == SAVE_OPT_SAVE_AND_QUIT) {
|
if (gSaveOptSelectIndex == SAVE_OPT_SAVE_AND_QUIT) {
|
||||||
fade_into_special_warp(-2, 0); // reset game
|
fade_into_special_warp(-2, 0); // reset game
|
||||||
}
|
} else if (gSaveOptSelectIndex == SAVE_OPT_SAVE_EXIT_GAME) {
|
||||||
|
|
||||||
if (gSaveOptSelectIndex == SAVE_OPT_SAVE_EXIT_GAME) {
|
|
||||||
//configfile_save(CONFIG_FILE); //Redundant, save_file implies save_config? Save config file before fully exiting
|
|
||||||
//initiate_warp(LEVEL_CASTLE, 1, 0x1F, 0);
|
//initiate_warp(LEVEL_CASTLE, 1, 0x1F, 0);
|
||||||
fade_into_special_warp(0, 0);
|
fade_into_special_warp(0, 0);
|
||||||
|
game_exit();
|
||||||
//fade_into_special_warp(-2, 0); // do the reset game thing
|
|
||||||
exit(0); // exit after saving game
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// not quitting
|
// not quitting
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include "game/game_init.h"
|
#include "game/game_init.h"
|
||||||
#include "game/ingame_menu.h"
|
#include "game/ingame_menu.h"
|
||||||
#include "game/options_menu.h"
|
#include "game/options_menu.h"
|
||||||
|
#include "pc/pc_main.h"
|
||||||
#include "pc/cliopts.h"
|
#include "pc/cliopts.h"
|
||||||
#include "pc/configfile.h"
|
#include "pc/configfile.h"
|
||||||
#include "pc/controller/controller_api.h"
|
#include "pc/controller/controller_api.h"
|
||||||
|
@ -161,7 +162,7 @@ struct SubMenu {
|
||||||
/* button action functions */
|
/* button action functions */
|
||||||
|
|
||||||
static void optmenu_act_exit(UNUSED struct Option *self, s32 arg) {
|
static void optmenu_act_exit(UNUSED struct Option *self, s32 arg) {
|
||||||
if (!arg) exit(0); // only exit on A press and not directions
|
if (!arg) game_exit(); // only exit on A press and not directions
|
||||||
}
|
}
|
||||||
|
|
||||||
/* submenu option lists */
|
/* submenu option lists */
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "audio/audio_sdl.h"
|
#include "audio/audio_sdl.h"
|
||||||
#include "audio/audio_null.h"
|
#include "audio/audio_null.h"
|
||||||
|
|
||||||
|
#include "pc_main.h"
|
||||||
#include "cliopts.h"
|
#include "cliopts.h"
|
||||||
#include "configfile.h"
|
#include "configfile.h"
|
||||||
#include "controller/controller_api.h"
|
#include "controller/controller_api.h"
|
||||||
|
@ -46,13 +47,11 @@ void dispatch_audio_sptask(struct SPTask *spTask) {
|
||||||
void set_vblank_handler(s32 index, struct VblankHandler *handler, OSMesgQueue *queue, OSMesg *msg) {
|
void set_vblank_handler(s32 index, struct VblankHandler *handler, OSMesgQueue *queue, OSMesg *msg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t inited = 0;
|
static bool inited = false;
|
||||||
|
|
||||||
#include "game/display.h" // for gGlobalTimer
|
#include "game/display.h" // for gGlobalTimer
|
||||||
void send_display_list(struct SPTask *spTask) {
|
void send_display_list(struct SPTask *spTask) {
|
||||||
if (!inited) {
|
if (!inited) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
gfx_run((Gfx *)spTask->task.t.data_ptr);
|
gfx_run((Gfx *)spTask->task.t.data_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,11 +91,19 @@ void audio_shutdown(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void game_shutdown(void) {
|
void game_deinit(void) {
|
||||||
configfile_save(gCLIOpts.ConfigFile);;
|
configfile_save(gCLIOpts.ConfigFile);;
|
||||||
controller_shutdown();
|
controller_shutdown();
|
||||||
audio_shutdown();
|
audio_shutdown();
|
||||||
gfx_shutdown();
|
gfx_shutdown();
|
||||||
|
inited = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void game_exit(void) {
|
||||||
|
game_deinit();
|
||||||
|
#ifndef TARGET_WEB
|
||||||
|
exit(0);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TARGET_WEB
|
#ifdef TARGET_WEB
|
||||||
|
@ -128,6 +135,7 @@ static void on_anim_frame(double time) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (inited) // only continue if the init flag is still set
|
||||||
request_anim_frame(on_anim_frame);
|
request_anim_frame(on_anim_frame);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -138,12 +146,7 @@ void main_func(void) {
|
||||||
gEffectsMemoryPool = mem_pool_init(0x4000, MEMORY_POOL_LEFT);
|
gEffectsMemoryPool = mem_pool_init(0x4000, MEMORY_POOL_LEFT);
|
||||||
|
|
||||||
configfile_load(gCLIOpts.ConfigFile);
|
configfile_load(gCLIOpts.ConfigFile);
|
||||||
atexit(game_shutdown);
|
|
||||||
|
|
||||||
#ifdef TARGET_WEB
|
|
||||||
emscripten_set_main_loop(em_main_loop, 0, 0);
|
|
||||||
request_anim_frame(on_anim_frame);
|
|
||||||
#endif
|
|
||||||
wm_api = &gfx_sdl;
|
wm_api = &gfx_sdl;
|
||||||
rendering_api = &gfx_opengl_api;
|
rendering_api = &gfx_opengl_api;
|
||||||
gfx_init(wm_api, rendering_api);
|
gfx_init(wm_api, rendering_api);
|
||||||
|
@ -159,16 +162,14 @@ void main_func(void) {
|
||||||
sound_init();
|
sound_init();
|
||||||
|
|
||||||
thread5_game_loop(NULL);
|
thread5_game_loop(NULL);
|
||||||
|
|
||||||
|
inited = true;
|
||||||
|
|
||||||
#ifdef TARGET_WEB
|
#ifdef TARGET_WEB
|
||||||
/*for (int i = 0; i < atoi(argv[1]); i++) {
|
emscripten_set_main_loop(em_main_loop, 0, 0);
|
||||||
game_loop_one_iteration();
|
request_anim_frame(on_anim_frame);
|
||||||
}*/
|
|
||||||
inited = 1;
|
|
||||||
#else
|
#else
|
||||||
inited = 1;
|
|
||||||
while (1) {
|
|
||||||
wm_api->main_loop(produce_one_frame);
|
wm_api->main_loop(produce_one_frame);
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
7
src/pc/pc_main.h
Normal file
7
src/pc/pc_main.h
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
#ifndef _PC_MAIN_H
|
||||||
|
#define _PC_MAIN_H
|
||||||
|
|
||||||
|
void game_deinit(void);
|
||||||
|
void game_exit(void);
|
||||||
|
|
||||||
|
#endif // _PC_MAIN_H
|
Loading…
Reference in a new issue