From e8588b1b0a84581ad7b5dec283a99da1681f2115 Mon Sep 17 00:00:00 2001 From: nmlgc Date: Fri, 29 Jan 2021 18:14:41 +0100 Subject: [PATCH] [Separate translation units] [th02] game_exit() Part of P0133, funded by [Anonymous]. --- Makefile.mak | 6 +++--- th02/core/exit.c | 31 +++++++++++++++++++++++++++++++ th02/core/initexit.h | 5 +++++ th02/core/initop.cpp | 1 + th02/exit.c | 26 +------------------------- th02/main02_2.cpp | 4 +--- th02/maine022.cpp | 4 +--- th02/op_02_2.cpp | 4 +--- th02/th02.h | 5 ----- 9 files changed, 44 insertions(+), 42 deletions(-) create mode 100644 th02/core/exit.c diff --git a/Makefile.mak b/Makefile.mak index 3471ba5f..1be26e0a 100644 --- a/Makefile.mak +++ b/Makefile.mak @@ -78,17 +78,17 @@ bin\th02\zun_res.com: th02\zun_res1.c th02\zun_res2.c th02\zun_res3.c $** | masters.lib -bin\th02\op.exe: th02\op_01.cpp bin\exit_dos.obj bin\th02\zunerror.obj bin\th02\grppsafx.obj bin\th02\op.obj th02\op_02_1.cpp bin\th02\pi_load.obj bin\th02\grp_rect.obj bin\frmdely2.obj th02\op_02_2.cpp bin\th02\snd_mmdr.obj bin\th02\snd_mode.obj bin\th02\snd_pmdr.obj bin\th02\snd_load.obj bin\th02\pi_put.obj bin\th02\snd_kaja.obj th02\op_02_3.cpp bin\th02\snd_se.obj bin\frmdely1.obj th02\op_03.cpp th02\op_04.cpp th02\op_05.cpp th02\op_06.cpp +bin\th02\op.exe: th02\op_01.cpp bin\exit_dos.obj bin\th02\zunerror.obj bin\th02\grppsafx.obj bin\th02\op.obj th02\op_02_1.cpp bin\th02\pi_load.obj bin\th02\grp_rect.obj bin\frmdely2.obj th02\op_02_2.cpp bin\th02\exit.obj bin\th02\snd_mmdr.obj bin\th02\snd_mode.obj bin\th02\snd_pmdr.obj bin\th02\snd_load.obj bin\th02\pi_put.obj bin\th02\snd_kaja.obj th02\op_02_3.cpp bin\th02\snd_se.obj bin\frmdely1.obj th02\op_03.cpp th02\op_04.cpp th02\op_05.cpp th02\op_06.cpp $(CC) $(CFLAGS) -ml -Z -DGAME=2 -nbin\th02\ -eOP.EXE @&&| $** | -bin\th02\main.exe: bin\th02\main.obj bin\th02\zunerror.obj th02\main02_1.cpp bin\th02\pi_load.obj bin\th02\vector.obj bin\frmdely1.obj th02\main02_2.cpp bin\th02\snd_mmdr.obj bin\th02\snd_mode.obj bin\th02\snd_pmdr.obj bin\th02\snd_dlyv.obj bin\th02\snd_load.obj th02\mptn_i.cpp bin\th02\initmain.obj bin\th02\pi_put.obj bin\th02\snd_kaja.obj bin\th02\snd_dlym.obj bin\th02\snd_se.obj th02\main_03.cpp +bin\th02\main.exe: bin\th02\main.obj bin\th02\zunerror.obj th02\main02_1.cpp bin\th02\pi_load.obj bin\th02\vector.obj bin\frmdely1.obj th02\main02_2.cpp bin\th02\exit.obj bin\th02\snd_mmdr.obj bin\th02\snd_mode.obj bin\th02\snd_pmdr.obj bin\th02\snd_dlyv.obj bin\th02\snd_load.obj th02\mptn_i.cpp bin\th02\initmain.obj bin\th02\pi_put.obj bin\th02\snd_kaja.obj bin\th02\snd_dlym.obj bin\th02\snd_se.obj th02\main_03.cpp $(CC) $(CFLAGS) -ml -Z -DGAME=2 -nbin\th02\ -eMAIN.EXE @&&| $** | -bin\th02\maine.exe: bin\th02\maine.obj bin\th02\grppsafx.obj th02\maine021.cpp bin\th02\pi_load.obj bin\frmdely1.obj th02\maine022.cpp bin\th02\snd_mmdr.obj bin\th02\snd_mode.obj bin\th02\snd_pmdr.obj bin\th02\snd_load.obj bin\th02\initmain.obj bin\th02\pi_put.obj bin\th02\snd_kaja.obj bin\th02\snd_dlym.obj th02\maine_03.c th02\maine_04.cpp th02\maine_05.cpp +bin\th02\maine.exe: bin\th02\maine.obj bin\th02\grppsafx.obj th02\maine021.cpp bin\th02\pi_load.obj bin\frmdely1.obj th02\maine022.cpp bin\th02\exit.obj bin\th02\snd_mmdr.obj bin\th02\snd_mode.obj bin\th02\snd_pmdr.obj bin\th02\snd_load.obj bin\th02\initmain.obj bin\th02\pi_put.obj bin\th02\snd_kaja.obj bin\th02\snd_dlym.obj th02\maine_03.c th02\maine_04.cpp th02\maine_05.cpp $(CC) $(CFLAGS) -ml -3 -Z -DGAME=2 -nbin\th02\ -eMAINE.EXE @&&| $** | diff --git a/th02/core/exit.c b/th02/core/exit.c new file mode 100644 index 00000000..1471dfb1 --- /dev/null +++ b/th02/core/exit.c @@ -0,0 +1,31 @@ +#pragma codeseg SHARED + +#include +#include "master.hpp" +#include "th02/core/initexit.h" + +void game_exit(void) +{ + pfend(); + graph_clear_both(); + +#if (GAME >= 4) + mem_unassign(); + vsync_end(); +#else + vsync_end(); + mem_unassign(); +#endif + + text_clear(); + +#if (GAME >= 3) + js_end(); +#endif + + egc_start(); + +#if (GAME >= 4) + bgm_finish(); +#endif +} diff --git a/th02/core/initexit.h b/th02/core/initexit.h index 648b8a56..731724e3 100644 --- a/th02/core/initexit.h +++ b/th02/core/initexit.h @@ -5,3 +5,8 @@ void game_exit(void); void game_exit_to_dos(void); + +#define graph_clear_both() \ + graph_accesspage(1); graph_clear(); \ + graph_accesspage(0); graph_clear(); \ + graph_accesspage(0); graph_showpage(0); diff --git a/th02/core/initop.cpp b/th02/core/initop.cpp index 7c9e17a8..10a0ab09 100644 --- a/th02/core/initop.cpp +++ b/th02/core/initop.cpp @@ -1,3 +1,4 @@ +#include #include "th01/hardware/vplanset.h" int game_init_op(void) diff --git a/th02/exit.c b/th02/exit.c index 0c646293..f06aa961 100644 --- a/th02/exit.c +++ b/th02/exit.c @@ -1,25 +1 @@ -void game_exit(void) -{ - pfend(); - graph_clear_both(); - -#if GAME >= 4 - mem_unassign(); - vsync_end(); -#else - vsync_end(); - mem_unassign(); -#endif - - text_clear(); - -#if GAME >= 3 - js_end(); -#endif - - egc_start(); - -#if GAME >= 4 - bgm_finish(); -#endif -} +#include "th02/core/exit.c" diff --git a/th02/main02_2.cpp b/th02/main02_2.cpp index 8bce44c1..2c3899cf 100644 --- a/th02/main02_2.cpp +++ b/th02/main02_2.cpp @@ -7,12 +7,10 @@ #pragma option -3 extern "C" { -#include -#include "th02/th02.h" +#include "platform.h" #include "master.hpp" #include "th02/hardware/frmdelay.h" #include "th02/hardware/input.hpp" #include "th02/hardware/input.c" -#include "th02/exit.c" } diff --git a/th02/maine022.cpp b/th02/maine022.cpp index 840867a1..ab6e6895 100644 --- a/th02/maine022.cpp +++ b/th02/maine022.cpp @@ -6,8 +6,7 @@ #pragma codeseg SHARED extern "C" { -#include -#include "th02/th02.h" +#include "platform.h" #include "master.hpp" #include "th02/hardware/frmdelay.h" #include "th02/hardware/input.hpp" @@ -17,5 +16,4 @@ extern "C" { extern const char pf_fn[] = PF_FN; #include "th02/hardware/input.c" -#include "th02/exit.c" } diff --git a/th02/op_02_2.cpp b/th02/op_02_2.cpp index 01eee85d..bab71c1c 100644 --- a/th02/op_02_2.cpp +++ b/th02/op_02_2.cpp @@ -7,8 +7,7 @@ #pragma option -3 extern "C" { -#include -#include "th02/th02.h" +#include "platform.h" #include "master.hpp" #include "th02/mem.h" #include "th02/core/initexit.h" @@ -22,5 +21,4 @@ const char pf_fn[] = PF_FN; #include "th02/hardware/input.c" #include "th02/core/initop.cpp" -#include "th02/exit.c" } diff --git a/th02/th02.h b/th02/th02.h index e372306c..5644b199 100644 --- a/th02/th02.h +++ b/th02/th02.h @@ -10,11 +10,6 @@ // Hardware // ------- -#define graph_clear_both() \ - graph_accesspage(1); graph_clear(); \ - graph_accesspage(0); graph_clear(); \ - graph_accesspage(0); graph_showpage(0); - #include "th01/hardware/grppsafx.h" // -------