diff --git a/th04/end/entry.cpp b/th04/end/entry.cpp index a09aec11..2aa6953e 100644 --- a/th04/end/entry.cpp +++ b/th04/end/entry.cpp @@ -1,6 +1,14 @@ +#include +#include #include "platform.h" +#include "pc98.h" +#include "planar.h" #include "master.hpp" +extern "C" { +#include "th03/formats/cdg.h" +} #include "th03/formats/cfg_impl.hpp" +#include "th03/core/initexit.h" resident_t far* resident; @@ -12,3 +20,15 @@ resident_t __seg* near cfg_load_resident_ptr(void) cfg_t cfg; return cfg_load_and_set_resident(cfg, CFG_FN); } + +void pascal near game_exit_and_exec(char* fn) +{ + cdg_free_all(); + graph_hide(); + text_clear(); + #if (GAME != 5) + gaiji_restore(); + #endif + game_exit(); + execl(fn, fn, nullptr); +} diff --git a/th04_maine.asm b/th04_maine.asm index 6034e76d..4390e61c 100644 --- a/th04_maine.asm +++ b/th04_maine.asm @@ -22,7 +22,6 @@ include ReC98.inc include th04/th04.inc include th04/hardware/grppsafx.inc - extern _execl:proc extern _tolower:proc extern __ctype:byte @@ -149,6 +148,8 @@ _TEXT ends MAINE_E_TEXT segment byte public 'CODE' use16 @cfg_load_resident_ptr$qv procdesc near + @GAME_EXIT_AND_EXEC$QNC procdesc pascal near \ + fn_off:word, fn_seg:word MAINE_E_TEXT ends ; Segment type: Pure code @@ -157,32 +158,6 @@ CUTSCENE_TEXT segment byte public 'CODE' use16 ;org 9 assume es:nothing, ss:nothing, ds:_DATA, fs:nothing, gs:nothing -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -; int __stdcall sub_A08A(char *arg0) -sub_A08A proc near - -_arg0 = dword ptr 4 - - push bp - mov bp, sp - call cdg_free_all - call graph_hide - call text_clear - call gaiji_restore - call @game_exit$qv - pushd 0 - pushd [bp+_arg0] ; arg0 - pushd [bp+_arg0] ; path - call _execl - add sp, 0Ch - pop bp - retn 4 -sub_A08A endp - - ; =============== S U B R O U T I N E ======================================= ; Attributes: bp-based frame @@ -319,9 +294,7 @@ loc_A27E: loc_A281: kajacall KAJA_SONG_FADE, 4 - push ds - push offset arg0 ; "op" - call sub_A08A + call @game_exit_and_exec$qnc pascal, ds, offset arg0 ; "op" locret_A290: leave @@ -3204,7 +3177,6 @@ SHARED_ segment word public 'CODE' use16 include th04/hardware/grppsafx.asm extern CDG_PUT_8:proc - extern @game_exit$qv:proc extern @GAME_INIT_MAIN$QNXUC:proc extern _input_reset_sense:proc extern _input_sense:proc diff --git a/th05_maine.asm b/th05_maine.asm index f1629a3f..1c832a4f 100644 --- a/th05_maine.asm +++ b/th05_maine.asm @@ -23,7 +23,6 @@ include th05/th05.inc include th01/math/subpixel.inc include th04/hardware/grppsafx.inc - extern _execl:proc extern _tolower:proc extern __ctype:byte @@ -156,6 +155,8 @@ _TEXT ends MAINE_E_TEXT segment byte public 'CODE' use16 @cfg_load_resident_ptr$qv procdesc near + @GAME_EXIT_AND_EXEC$QNC procdesc pascal near \ + fn_off:word, fn_seg:word MAINE_E_TEXT ends ; Segment type: Pure code @@ -164,31 +165,6 @@ CUTSCENE_TEXT segment byte public 'CODE' use16 ;org 5 assume es:nothing, ss:nothing, ds:_DATA, fs:nothing, gs:nothing -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -; int __stdcall sub_A576(char *arg0) -sub_A576 proc near - -_arg0 = dword ptr 4 - - push bp - mov bp, sp - call cdg_free_all - call graph_hide - call text_clear - call @game_exit$qv - pushd 0 - pushd [bp+_arg0] ; arg0 - pushd [bp+_arg0] ; path - call _execl - add sp, 0Ch - pop bp - retn 4 -sub_A576 endp - - ; =============== S U B R O U T I N E ======================================= ; Attributes: bp-based frame @@ -292,9 +268,7 @@ loc_A67E: loc_A684: kajacall KAJA_SONG_FADE, 4 - push ds - push offset arg0 ; "op" - call sub_A576 + call @game_exit_and_exec$qnc pascal, ds, offset arg0 ; "op" loc_A693: pop bp @@ -6325,7 +6299,6 @@ include th04/hardware/grppsafx.asm extern _snd_se_update:proc extern _bgimage_snap:proc extern _bgimage_free:proc - extern @game_exit$qv:proc extern VECTOR2_AT:proc extern BGIMAGE_PUT_RECT_16:proc extern SND_LOAD:proc