From a6ace813e4f15cf22334924e517b11a0fbc19861 Mon Sep 17 00:00:00 2001 From: nmlgc Date: Sat, 10 Jul 2021 13:11:30 +0200 Subject: [PATCH] [Decompilation] [th04] Bonus popup point display Part of P0148, funded by [Anonymous]. --- th04/main/hud/popup.asm | 63 ----------------------------------------- th04/main/hud/popup.cpp | 33 +++++++++++++++++++++ th04_main.asm | 1 - 3 files changed, 33 insertions(+), 64 deletions(-) delete mode 100644 th04/main/hud/popup.asm diff --git a/th04/main/hud/popup.asm b/th04/main/hud/popup.asm deleted file mode 100644 index f63f42bb..00000000 --- a/th04/main/hud/popup.asm +++ /dev/null @@ -1,63 +0,0 @@ -if GAME eq 4 -; Yes, specific to the bonus popup, due to the hardcoded position. -public POPUP_PUT_POINTS_TH04 -popup_put_points_th04 proc pascal near - arg @@points:dword - local @@digit:dword, @@divisor:dword, @@buf:byte:SCORE_DIGITS + 2 ; padding... - - push si - push di - mov @@divisor, 1000000 - xor si, si - xor di, di - jmp short @@more_digits? -; --------------------------------------------------------------------------- - -@@digit_loop: - mov eax, @@points - xor edx, edx - div @@divisor - mov @@digit, eax - mov eax, @@points - xor edx, edx - div @@divisor - mov @@points, edx - or di, word ptr @@digit - or di, di - jz short @@omit_leading_zeroes - mov al, byte ptr @@digit - add al, GB_DIGITS - mov @@buf[si], al - jmp short @@divisor_next -; --------------------------------------------------------------------------- - -@@omit_leading_zeroes: - mov @@buf[si], g_EMPTY - -@@divisor_next: - mov ebx, 10 - mov eax, @@divisor - xor edx, edx - div ebx - mov @@divisor, eax - inc si - -@@more_digits?: - cmp @@divisor, 1 - ja short @@digit_loop - mov al, byte ptr @@points - add al, gb_0_ - mov @@buf[SCORE_DIGITS - 2], al ; (ones) - mov @@buf[SCORE_DIGITS - 1], gb_0_ ; ("continues used" digit) - mov @@buf[SCORE_DIGITS - 0], 0 ; (null terminator) - push ((PLAYFIELD_TRAM_LEFT + (PLAYFIELD_TRAM_W / 2)) shl 16) + POPUP_TRAM_Y - push ss - lea ax, @@buf - push ax - push TX_WHITE - call gaiji_putsa - pop di - pop si - ret -popup_put_points_th04 endp -endif diff --git a/th04/main/hud/popup.cpp b/th04/main/hud/popup.cpp index 4bd93459..2b4b9f06 100644 --- a/th04/main/hud/popup.cpp +++ b/th04/main/hud/popup.cpp @@ -3,6 +3,7 @@ #include "x86real.h" #include "pc98.h" #include "master.hpp" +#include "th04/score.h" #include "th01/math/subpixel.hpp" #include "th04/gaiji/gaiji.h" #include "th04/formats/bb.h" @@ -423,3 +424,35 @@ void pascal near popup_update_and_render(void) #undef gaiji_len #undef frame } + +#if (GAME == 4) + void pascal near popup_put_points_th04(unsigned long points) + { + int i; + bool16 past_leading_zeroes; + gaiji_th04_t buf[SCORE_DIGITS + 1]; + unsigned long divisor = 1000000; // Must match SCORE_DIGITS! + unsigned long digit; + + i = 0; + past_leading_zeroes = false; + while(divisor > 1) { + digit = (points / divisor); + points = (points % divisor); + past_leading_zeroes |= digit; + if(past_leading_zeroes) { + buf[i] = static_cast(gb_0_ + digit); + } else { + buf[i] = g_EMPTY; + } + divisor /= 10; + i++; + } + // (ones) + buf[SCORE_DIGITS - 2] = static_cast(gb_0_ + points); + buf[SCORE_DIGITS - 1] = gb_0_; // ("continues used" digit) + buf[SCORE_DIGITS - 0] = g_NULL; // (null terminator) + + popup_put(PLAYFIELD_TRAM_CENTER_X, POPUP_TRAM_Y, buf); + } +#endif diff --git a/th04_main.asm b/th04_main.asm index 2d26b9ea..20a70898 100644 --- a/th04_main.asm +++ b/th04_main.asm @@ -9781,7 +9781,6 @@ main_0_TEXT ends POPUP_UPDATE_AND_RENDER procdesc near main_01_TEXT segment byte public 'CODE' use16 -include th04/main/hud/popup.asm include th04/formats/bb_txt_load.asm ; =============== S U B R O U T I N E =======================================