From e15942bb7c85d628fc412628a3520be126c31fed Mon Sep 17 00:00:00 2001 From: nmlgc Date: Sun, 29 May 2022 23:04:21 +0200 Subject: [PATCH] [Maintenance] [th01] Add string length calculation wrappers for VRAM typing Part of P0197, funded by Yanga and Ember2528. --- th01/end/type.h | 8 -------- th01/end/type.hpp | 15 +++++++++++++++ th01/fuuin_04.cpp | 10 +++++----- th01_fuuin.asm | 48 +++++++++++++++++++++++------------------------ 4 files changed, 44 insertions(+), 37 deletions(-) delete mode 100644 th01/end/type.h create mode 100644 th01/end/type.hpp diff --git a/th01/end/type.h b/th01/end/type.h deleted file mode 100644 index a422aee5..00000000 --- a/th01/end/type.h +++ /dev/null @@ -1,8 +0,0 @@ -// Types [len] half- (ank) or full-width (kanji) characters of [str] onto the -// given position in VRAM, with a frame delay between each character. -void pascal graph_type_ank( - screen_x_t left, vram_y_t top, int len, const char *str -); -void pascal graph_type_kanji( - screen_x_t left, vram_y_t top, int len, const char *str -); diff --git a/th01/end/type.hpp b/th01/end/type.hpp new file mode 100644 index 00000000..609b267e --- /dev/null +++ b/th01/end/type.hpp @@ -0,0 +1,15 @@ +// Types [len] half- (ank) or full-width (kanji) characters of [str] onto the +// given position in VRAM, with a frame delay between each character. +void pascal graph_type_ank_n( + screen_x_t left, vram_y_t top, int len, const char *str +); +void pascal graph_type_kanji_n( + screen_x_t left, vram_y_t top, int len, const char *str +); + +#define graph_type_ank(left, top, str) { \ + graph_type_ank_n(left, top, (sizeof(str) - 1), str); \ +} +#define graph_type_kanji(left, top, str) { \ + graph_type_kanji_n(left, top, ((sizeof(str) - 1) / 2), str); \ +} diff --git a/th01/fuuin_04.cpp b/th01/fuuin_04.cpp index 3569b7e7..020db9ee 100644 --- a/th01/fuuin_04.cpp +++ b/th01/fuuin_04.cpp @@ -14,8 +14,8 @@ extern "C" { #include "th01/hardware/graph.h" #include "th01/hardware/palette.h" #include "th01/hardware/vsync.h" -#include "th01/end/type.h" } +#include "th01/end/type.hpp" #define TYPE_DELAY 3 #define TYPE_FX (15 | FX_WEIGHT_NORMAL) @@ -102,9 +102,11 @@ void pascal grp_palette_white_in(unsigned int frames) } /// ------------------ +} + #pragma option -O- -void pascal graph_type_ank( +void pascal graph_type_ank_n( screen_x_t left, vram_y_t top, int len, const char *str ) { @@ -116,7 +118,7 @@ void pascal graph_type_ank( } } -void pascal graph_type_kanji( +void pascal graph_type_kanji_n( screen_x_t left, vram_y_t top, int len, const char *str ) { @@ -128,5 +130,3 @@ void pascal graph_type_kanji( frame_delay(TYPE_DELAY); } } - -} diff --git a/th01_fuuin.asm b/th01_fuuin.asm index a57401d7..103117b0 100644 --- a/th01_fuuin.asm +++ b/th01_fuuin.asm @@ -522,7 +522,7 @@ sub_BC7C proc near pop cx call _frame_delay stdcall, 100 pop cx - call graph_type_ank pascal, 232, 316, 22, ds, offset aTryToNoContinu ; "Try to 'No continue'!!" + call @graph_type_ank_n$qiiinxc pascal, 232, 316, 22, ds, offset aTryToNoContinu ; "Try to 'No continue'!!" push 232 push 348 push 22 @@ -582,7 +582,7 @@ loc_BD62: pop cx call _frame_delay stdcall, 100 pop cx - call graph_type_ank pascal, 232, 316, 22, ds, offset aTryToNoConti_0 ; "Try to 'No continue'!!" + call @graph_type_ank_n$qiiinxc pascal, 232, 316, 22, ds, offset aTryToNoConti_0 ; "Try to 'No continue'!!" push 232 push 348 push 22 @@ -590,7 +590,7 @@ loc_BD62: push offset aBadEnding1 ; " Bad Ending1 " loc_BDAC: - call graph_type_ank + call @graph_type_ank_n$qiiinxc call _frame_delay stdcall, 300 pop cx pop si @@ -713,8 +713,8 @@ sub_BE83 proc near pop cx call _frame_delay stdcall, 150 pop cx - call graph_type_ank pascal, 256, 316, 16, ds, offset aCongratulation ; "Congratulations!" - call graph_type_ank pascal, 232, 348, 22, ds, offset aGoodEnding2 ; " Good Ending2 " + call @graph_type_ank_n$qiiinxc pascal, 256, 316, 16, ds, offset aCongratulation ; "Congratulations!" + call @graph_type_ank_n$qiiinxc pascal, 232, 348, 22, ds, offset aGoodEnding2 ; " Good Ending2 " call _frame_delay stdcall, 300 pop cx pop bp @@ -784,8 +784,8 @@ loc_BF51: pop cx call _frame_delay stdcall, 150 pop cx - call graph_type_ank pascal, 256, 316, 16, ds, offset aCongratulati_0 ; "Congratulations!" - call graph_type_ank pascal, 232, 348, 22, ds, offset aGoodEnding1 ; " Good Ending1 " + call @graph_type_ank_n$qiiinxc pascal, 256, 316, 16, ds, offset aCongratulati_0 ; "Congratulations!" + call @graph_type_ank_n$qiiinxc pascal, 232, 348, 22, ds, offset aGoodEnding1 ; " Good Ending1 " call _frame_delay stdcall, 300 pop cx pop si @@ -852,12 +852,12 @@ loc_C078: call grp_palette_settone pascal, 100 call _frame_delay stdcall, 50 pop cx - call graph_type_ank pascal, 272, 316, 13, ds, offset aStage5Boss ; "STAGE 5 BOSS" - call graph_type_ank pascal, 232, 348, 22, ds, offset aGatekeeperSing ; "Gatekeeper 'SinGyoku'" + call @graph_type_ank_n$qiiinxc pascal, 272, 316, 13, ds, offset aStage5Boss ; "STAGE 5 BOSS" + call @graph_type_ank_n$qiiinxc pascal, 232, 348, 22, ds, offset aGatekeeperSing ; "Gatekeeper 'SinGyoku'" call sub_C009 pascal, 1 cmp _end_flag, 1 jnz short loc_C0E1 - call graph_type_ank pascal, 272, 316, 13, ds, offset aStage10Boss ; "STAGE 10 BOSS" + call @graph_type_ank_n$qiiinxc pascal, 272, 316, 13, ds, offset aStage10Boss ; "STAGE 10 BOSS" push 232 push 348 push 22 @@ -867,7 +867,7 @@ loc_C078: ; --------------------------------------------------------------------------- loc_C0E1: - call graph_type_ank pascal, 272, 316, 13, ds, offset aStage10Boss_0 ; "STAGE 10 BOSS" + call @graph_type_ank_n$qiiinxc pascal, 272, 316, 13, ds, offset aStage10Boss_0 ; "STAGE 10 BOSS" push 232 push 348 push 23 @@ -875,11 +875,11 @@ loc_C0E1: push offset aRevengefulGhos ; "Revengeful Ghost 'Mima'" loc_C0FE: - call graph_type_ank + call @graph_type_ank_n$qiiinxc call sub_C009 pascal, 2 cmp _end_flag, 1 jnz short loc_C12E - call graph_type_ank pascal, 272, 316, 13, ds, offset aStage15Boss ; "STAGE 15 BOSS" + call @graph_type_ank_n$qiiinxc pascal, 272, 316, 13, ds, offset aStage15Boss ; "STAGE 15 BOSS" push 232 push 348 push 22 @@ -889,7 +889,7 @@ loc_C0FE: ; --------------------------------------------------------------------------- loc_C12E: - call graph_type_ank pascal, 272, 316, 13, ds, offset aStage15Boss_0 ; "STAGE 15 BOSS" + call @graph_type_ank_n$qiiinxc pascal, 272, 316, 13, ds, offset aStage15Boss_0 ; "STAGE 15 BOSS" push 256 push 348 push 17 @@ -897,11 +897,11 @@ loc_C12E: push offset aHellmoonKikuri ; "HellMoon 'Kikuri'" loc_C14B: - call graph_type_ank + call @graph_type_ank_n$qiiinxc call sub_C009 pascal, 3 cmp _end_flag, 1 jnz short loc_C17B - call graph_type_ank pascal, 272, 316, 13, ds, offset aStage20Boss ; "STAGE 20 BOSS" + call @graph_type_ank_n$qiiinxc pascal, 272, 316, 13, ds, offset aStage20Boss ; "STAGE 20 BOSS" push 232 push 348 push 22 @@ -911,7 +911,7 @@ loc_C14B: ; --------------------------------------------------------------------------- loc_C17B: - call graph_type_ank pascal, 272, 316, 13, ds, offset aStage20Boss_0 ; "STAGE 20 BOSS" + call @graph_type_ank_n$qiiinxc pascal, 272, 316, 13, ds, offset aStage20Boss_0 ; "STAGE 20 BOSS" push 224 push 348 push 24 @@ -919,7 +919,7 @@ loc_C17B: push offset aAstralKnightKo ; "Astral Knight 'Konngara'" loc_C198: - call graph_type_ank + call @graph_type_ank_n$qiiinxc call _frame_delay stdcall, 150 pop cx pop bp @@ -1331,9 +1331,9 @@ var_10 = byte ptr -10h call _graph_accesspage_func pop cx call grp_palette_black_in pascal, 8 - call graph_type_kanji pascal, 400, 32, 5, ds, offset aUmx_1 ; "“Œ•ϋθΛˆΩ“`" - call graph_type_ank pascal, 496, 32, 3, ds, offset aVer ; "ver" - call graph_type_ank pascal, 528, 32, 4, ds, offset a1_10 ; "1.10" + call @graph_type_kanji_n$qiiinxc pascal, 400, 32, 5, ds, offset aUmx_1 ; "“Œ•ϋθΛˆΩ“`" + call @graph_type_ank_n$qiiinxc pascal, 496, 32, 3, ds, offset aVer ; "ver" + call @graph_type_ank_n$qiiinxc pascal, 528, 32, 4, ds, offset a1_10 ; "1.10" call _frame_delay stdcall, 30 pop cx mov al, _rank @@ -1449,7 +1449,7 @@ loc_C647: add sp, 0Eh call _frame_delay stdcall, 30 pop cx - call graph_type_ank pascal, 296, 352, 29, ds, offset aThankYouForPla ; " Thank you for Playing !! " + call @graph_type_ank_n$qiiinxc pascal, 296, 352, 29, ds, offset aThankYouForPla ; " Thank you for Playing !! " call _graph_printf_fx c, 264, 384, 12h, offset aBBBVavVVPNjbBB, ds ; "ššš‚ ‚Θ‚½‚̏̍†ššš" call _frame_delay stdcall, 50 pop cx @@ -1531,8 +1531,8 @@ fuuin_04_TEXT segment byte public 'CODE' use16 extern GRP_PALETTE_BLACK_IN:proc extern GRP_PALETTE_WHITE_OUT:proc extern GRP_PALETTE_WHITE_IN:proc - extern GRAPH_TYPE_ANK:proc - extern GRAPH_TYPE_KANJI:proc + extern @GRAPH_TYPE_ANK_N$QIIINXC:proc + extern @GRAPH_TYPE_KANJI_N$QIIINXC:proc fuuin_04_TEXT ends ; ===========================================================================