From 4c888ee4ade6aca57b56eae3ecc5673f0dafdf9b Mon Sep 17 00:00:00 2001 From: nmlgc Date: Fri, 13 Oct 2023 23:17:39 +0200 Subject: [PATCH] [Maintenance] [th04/th05] Demo Play: Move OP return code into the header Part of P0258, funded by [Anonymous] and Blue Bolt. --- th04/main/demo.cpp | 17 ++++------------- th04/main/demo.hpp | 15 +++++++++++++++ th04/main/demo[data].asm | 4 ++-- th04/shiftjis/fns.hpp | 2 ++ 4 files changed, 23 insertions(+), 15 deletions(-) diff --git a/th04/main/demo.cpp b/th04/main/demo.cpp index b112d658..837a56e2 100644 --- a/th04/main/demo.cpp +++ b/th04/main/demo.cpp @@ -17,7 +17,9 @@ void near DemoPlay(void) { - extern const char DEMO_OP[]; + #undef BINARY_OP + #define BINARY_OP DEMOPLAY_BINARY_OP + extern const char BINARY_OP[]; #if (GAME == 5) size_t shift_offset = (resident->demo_num <= 4) ? DEMO_N : DEMO_N_EXTRA; @@ -40,16 +42,5 @@ void near DemoPlay(void) return; } } - HMem::free(DemoBuf); - palette_black_out((GAME == 5) ? 8 : 10); - /* TODO: Replace with the decompiled call - * GameExecl(DEMO_OP); - * once that function is part of the same segment */ - _asm { - push ds; - push offset DEMO_OP; - nop; - push cs; - call near ptr GameExecl; - } + demo_end(); } diff --git a/th04/main/demo.hpp b/th04/main/demo.hpp index dd02b4e0..ff2f1f60 100644 --- a/th04/main/demo.hpp +++ b/th04/main/demo.hpp @@ -15,5 +15,20 @@ // buffer. extern uint8_t *DemoBuf; /* ZUN symbol [MAGNet2010] */ +#define demo_end() { \ + HMem::free(DemoBuf); \ + palette_black_out((GAME == 5) ? 8 : 10); \ + /* TODO: Replace with the decompiled call \ + * GameExecl(BINARY_OP); \ + * once that function is only called from the same segment */ \ + _asm { \ + push ds; \ + push offset BINARY_OP; \ + nop; \ + push cs; \ + call near ptr GameExecl; \ + } \ +} + // Assigns the next frame out of [DemoBuf] to [key_det] and [shiftkey]. void near DemoPlay(); diff --git a/th04/main/demo[data].asm b/th04/main/demo[data].asm index b91f7b16..97129c03 100644 --- a/th04/main/demo[data].asm +++ b/th04/main/demo[data].asm @@ -1,2 +1,2 @@ -public _DEMO_OP -_DEMO_OP db 'op',0 +public _DEMOPLAY_BINARY_OP +_DEMOPLAY_BINARY_OP db 'op',0 diff --git a/th04/shiftjis/fns.hpp b/th04/shiftjis/fns.hpp index 59898a73..928a63d2 100644 --- a/th04/shiftjis/fns.hpp +++ b/th04/shiftjis/fns.hpp @@ -1,3 +1,5 @@ +#define BINARY_OP "op" + #define EYECATCH_FN_FORMAT "eye0.cdg" #define FACESET_REIMU_FN "KAO0.cd2"