From 5c77db08ca99d7203c1261f51e05be5e277eec10 Mon Sep 17 00:00:00 2001 From: nmlgc Date: Fri, 22 May 2020 19:27:50 +0200 Subject: [PATCH] [Decompilation] [th01] High score registration Completing the high score menu with a final stupid set of inconsistencies between REIIDEN.EXE and FUUIN.EXE. Oh well. Part of P0094, funded by Yanga. --- th01/fuuin_02.cpp | 9 + th01/hardware/graph.h | 2 +- th01/hiscore/regist.cpp | 114 ++++++++- th01/hiscore/regist.hpp | 6 + th01/hiscore/regist[data].asm | 16 ++ th01/hiscore/regist_name[data].asm | 7 + th01/hiscore/scoredat.hpp | 11 +- th01/hiscore/scorelod.cpp | 8 +- th01/main_19.cpp | 30 +++ th01_fuuin.asm | 391 +---------------------------- th01_reiiden.asm | 357 ++------------------------ 11 files changed, 220 insertions(+), 731 deletions(-) create mode 100644 th01/hiscore/regist.hpp diff --git a/th01/fuuin_02.cpp b/th01/fuuin_02.cpp index b076f545..d48afc8f 100644 --- a/th01/fuuin_02.cpp +++ b/th01/fuuin_02.cpp @@ -95,6 +95,15 @@ extern const char FOPEN_WB[]; #define regist_input_timeout_inc() #define regist_input_timeout_if_reached(then) +inline void regist_bg_put(const int16_t stage) +{ +} + +#define regist_title_put(left, stage, ranks, fx) { \ + extern const char REGIST_TITLE_FMT[]; \ + graph_printf_fx(left, TITLE_TOP, fx, REGIST_TITLE_FMT, ranks[rank]); \ +} + #include "th01/hiscore/regist.cpp" } diff --git a/th01/hardware/graph.h b/th01/hardware/graph.h index 7d74d972..fb30275d 100644 --- a/th01/hardware/graph.h +++ b/th01/hardware/graph.h @@ -24,7 +24,7 @@ void z_graph_clear_col(uint4_t col); // Fills page #0 with hardware color 0. void z_graph_clear_0(void); -void graph_copy_page_front_to_back(void); +void graph_copy_page_back_to_front(void); /// ----- /// GRCG diff --git a/th01/hiscore/regist.cpp b/th01/hiscore/regist.cpp index 0ed57c9d..f2be0ee0 100644 --- a/th01/hiscore/regist.cpp +++ b/th01/hiscore/regist.cpp @@ -1,10 +1,20 @@ #include "th01/hardware/egc.h" +#include "th01/hardware/grp2xscs.h" #include "th01/hardware/input.hpp" #include "th01/hardware/vsync.h" #define COL_SELECTED 3 #define COL_REGULAR 7 +#define TITLE_LEFT 48 +#define TITLE_TOP 0 +static const int TITLE_BACK_LEFT = 0; +static const int TITLE_BACK_TOP = (RES_Y - GLYPH_H); +static const int TITLE_BACK_W = 288; +static const int TITLE_BACK_H = GLYPH_H; +static const int TITLE_BACK_RIGHT = (TITLE_BACK_LEFT + TITLE_BACK_W); +static const int TITLE_BACK_BOTTOM = (TITLE_BACK_TOP + TITLE_BACK_H); + /// Table /// ----- #define POINT_DIGITS 7 @@ -280,7 +290,7 @@ void regist_put_initial( top, fx_text, (i == entered_place) - ? entered_route[0] : scoredat_routes[i].byte.lo, + ? entered_route[0] : scoredat_routes[i * SCOREDAT_ROUTE_LEN], (i == entered_place) ? entered_route[1] : scoredat_route_byte(i, 1) ); @@ -589,7 +599,7 @@ void regist_name_enter(int entered_place) entered_name_cursor = 0; regist_input_timeout_reset(); left = left_for(0); - top = ALPHABET_TOP; + top = LOWER_TOP; for(i = 0; i < SCOREDAT_NAME_BYTES; i++) { entered_name.byte[i] = ' '; @@ -625,3 +635,103 @@ void regist_name_enter(int entered_place) } scoredat_save(); } + +static const int PLACE_NONE = (SCOREDAT_PLACES + 20); +static const int SCOREDAT_NOT_CLEARED = (SCOREDAT_CLEARED - 10); + +void regist( + int32_t points, int16_t stage, const char route[SCOREDAT_ROUTE_LEN + 1] +) +{ + struct hack { + const char *r[4]; + }; + extern const hack REGIST_TITLE_RANKS; + + scoredat_name_z_t names[SCOREDAT_PLACES]; + const hack RANKS = REGIST_TITLE_RANKS; + long place; + + regist_bg_put(stage); + + graph_accesspage_func(1); + + regist_title_put( + TITLE_BACK_LEFT, stage, RANKS.r, (FX_CLEAR_BG | FX(COL_REGULAR, 2, 0)) + ); + // On page 1, the title should now at (TITLE_BACK_LEFT, TITLE_BACK_TOP) if + // not cleared, or at (TITLE_BACK_LEFT, TITLE_TOP) if cleared. + + graph_accesspage_func(0); + if(stage < SCOREDAT_NOT_CLEARED) { + graph_2xscale_byterect_1_to_0_slow( + TITLE_LEFT, TITLE_TOP, + TITLE_BACK_LEFT, TITLE_BACK_TOP, TITLE_BACK_W, TITLE_BACK_H + ); + graph_move_byterect_interpage( + TITLE_BACK_LEFT, TITLE_BACK_TOP, + TITLE_BACK_RIGHT, TITLE_BACK_BOTTOM, + TITLE_BACK_LEFT, TITLE_BACK_TOP, + 0, 1 + ); + } else { + graph_2xscale_byterect_1_to_0_slow( + TITLE_LEFT, TITLE_TOP, + TITLE_BACK_LEFT, TITLE_TOP, TITLE_BACK_W, TITLE_BACK_H + ); + } + + if(scoredat_load()) { + return; + } + for(place = 0; place < SCOREDAT_PLACES; place++) { + scoredat_name_get(place, names[place].byte); + } + for(place = 0; place < SCOREDAT_PLACES; place++) { + if(points >= scoredat_points[place]) { + break; + } + } + + input_reset_sense(); + + if(place < SCOREDAT_PLACES) { + for(long shift = (SCOREDAT_PLACES - 1); shift > place; shift--) { + strcpy(names[shift].byte, names[shift - 1].byte); + scoredat_points[shift] = scoredat_points[shift - 1]; + scoredat_stages[shift] = scoredat_stages[shift - 1]; + scoredat_route_byte(shift, 0) = scoredat_route_byte(shift, -2); + scoredat_route_byte(shift, 1) = scoredat_route_byte(shift, -1); + } + long p = (SCOREDAT_NAMES_SIZE - 1); + while(((place * SCOREDAT_NAME_BYTES) + SCOREDAT_NAME_BYTES) <= p) { + scoredat_names[p] = scoredat_names[p - SCOREDAT_NAME_BYTES]; + p--; + } + regist_put_initial(place, points, stage, route, names); + alphabet_put_initial(); + + scoredat_points[place] = points; + scoredat_stages[place] = stage; + scoredat_route_byte(place, 0) = route[0]; + scoredat_route_byte(place, 1) = route[1]; + + // Writes the new name to scoredat_names[] and calls scoredat_save() + regist_name_enter(place); + + _ES = FP_SEG(graph_accesspage_func); // Yes, no point to this at all. + scoredat_free(); + return; + } + regist_put_initial(PLACE_NONE, points, stage, route, names); + input_ok = true; + input_shot = true; + while(1) { + input_sense(false); + if(!input_ok || !input_shot) { + break; + } + } + _ES = FP_SEG(graph_accesspage_func); // Yes, no point to this at all. + scoredat_free(); +} diff --git a/th01/hiscore/regist.hpp b/th01/hiscore/regist.hpp new file mode 100644 index 00000000..70a13549 --- /dev/null +++ b/th01/hiscore/regist.hpp @@ -0,0 +1,6 @@ +// Shows the high score list for the current difficulty. If the given game +// result is good enough to be on there, the player is asked to enter a name, +// before the result is inserted and written to the high score file. +void regist( + int32_t points, int16_t stage, const char route[SCOREDAT_ROUTE_LEN + 1] +); diff --git a/th01/hiscore/regist[data].asm b/th01/hiscore/regist[data].asm index a334bed2..51e57d10 100644 --- a/th01/hiscore/regist[data].asm +++ b/th01/hiscore/regist[data].asm @@ -61,3 +61,19 @@ if BINARY eq 'E' endif public _SCOREDAT_FOPEN_WB _SCOREDAT_FOPEN_WB db 'wb',0 +_REGIST_TITLE_RANK_EASY db ' イージー ',0 +_REGIST_TITLE_RANK_NORMAL db ' ノーマル ',0 +_REGIST_TITLE_RANK_HARD db ' ハード  ',0 +_REGIST_TITLE_RANK_LUNATIC db 'ルナティック',0 + +if BINARY eq 'E' + public _REGIST_TITLE_FMT + _REGIST_TITLE_FMT db '東方靈異伝 強者の記録 %s',0 +else + public _REGIST_BG_NOT_CLEARED, _REGIST_BG_CLEARED + public _REGIST_TITLE_1, _REGIST_TITLE_2 + _REGIST_BG_NOT_CLEARED db 'game_o.grp',0 + _REGIST_BG_CLEARED db 'endm_a.grp',0 + _REGIST_TITLE_1 db '東方靈異伝 強者の記録 ',0 + _REGIST_TITLE_2 db '東方靈異伝 強者の記録',0 +endif diff --git a/th01/hiscore/regist_name[data].asm b/th01/hiscore/regist_name[data].asm index ba0c6f49..600f9dc7 100644 --- a/th01/hiscore/regist_name[data].asm +++ b/th01/hiscore/regist_name[data].asm @@ -6,3 +6,10 @@ if BINARY eq 'M' endif _REGIST_NAME_SPACES db '        ',0 _SCOREDAT_MAGIC db 'HISCORE',0 + +public _REGIST_TITLE_RANKS +_REGIST_TITLE_RANKS label dword + dd _REGIST_TITLE_RANK_EASY + dd _REGIST_TITLE_RANK_NORMAL + dd _REGIST_TITLE_RANK_HARD + dd _REGIST_TITLE_RANK_LUNATIC diff --git a/th01/hiscore/scoredat.hpp b/th01/hiscore/scoredat.hpp index 6ff10b1f..5ed94dbf 100644 --- a/th01/hiscore/scoredat.hpp +++ b/th01/hiscore/scoredat.hpp @@ -37,15 +37,16 @@ struct scoredat_t { extern int8_t* scoredat_names; // Yeah, technically a scoredat_name_t. extern int16_t* scoredat_stages; -extern uint32_t* scoredat_points; -extern twobyte_t* scoredat_routes; +extern int32_t* scoredat_points; +extern int8_t* scoredat_routes; // Yeah, technically a twobyte_t. // Byte-wise access to [scoredat_routes]. inline int8_t& scoredat_route_byte(int place, int byte) { - return reinterpret_cast(scoredat_routes)[ - (place * SCOREDAT_ROUTE_LEN) + byte - ]; + if(byte == 0) { + return scoredat_routes[place * SCOREDAT_ROUTE_LEN]; + } + return scoredat_routes[(place * SCOREDAT_ROUTE_LEN) + byte]; } // Null-terminated version of scoredat_name_t, used internally. diff --git a/th01/hiscore/scorelod.cpp b/th01/hiscore/scorelod.cpp index cfa9b7ca..afa75bc5 100644 --- a/th01/hiscore/scorelod.cpp +++ b/th01/hiscore/scorelod.cpp @@ -114,13 +114,13 @@ int scoredat_load() scoredat_names = new int8_t[SCOREDAT_NAMES_SIZE]; scoredat_stages = new int16_t[SCOREDAT_PLACES]; - scoredat_routes = new twobyte_t[SCOREDAT_PLACES]; - scoredat_points = new uint32_t[SCOREDAT_PLACES]; + scoredat_routes = new int8_t[SCOREDAT_ROUTE_LEN * SCOREDAT_PLACES]; + scoredat_points = new int32_t[SCOREDAT_PLACES]; scoredat_read(scoredat_names, SCOREDAT_NAMES_SIZE); - scoredat_read(scoredat_points, sizeof(uint32_t) * SCOREDAT_PLACES); + scoredat_read(scoredat_points, sizeof(int32_t) * SCOREDAT_PLACES); scoredat_read(scoredat_stages, sizeof(int16_t) * SCOREDAT_PLACES); - scoredat_read(scoredat_routes, sizeof(twobyte_t) * SCOREDAT_PLACES); + scoredat_read(scoredat_routes, SCOREDAT_ROUTE_LEN * SCOREDAT_PLACES); scoredat_close(); for(int i = 0; i < SCOREDAT_NAMES_SIZE; i++) { diff --git a/th01/main_19.cpp b/th01/main_19.cpp index b7c2d403..8d97c37b 100644 --- a/th01/main_19.cpp +++ b/th01/main_19.cpp @@ -10,6 +10,8 @@ extern "C" { #include #include "ReC98.h" #include "th01/ranks.h" +#include "th01/formats/grp.h" +#include "th01/hardware/palette.h" #include "th01/hardware/graph.h" #include "th01/hiscore/scoredat.hpp" @@ -73,6 +75,34 @@ void pascal near str_from_kanji(char str[3], uint16_t kanji) #define regist_input_timeout_inc() timeout++; #define regist_input_timeout_if_reached(then) if(timeout > 1000) then +#define regist_bg_put(stage) { \ + extern const char REGIST_BG_NOT_CLEARED[]; \ + extern const char REGIST_BG_CLEARED[]; \ + z_graph_clear_0(); \ + z_palette_black(); \ + graph_accesspage_func(1); \ + \ + if(stage < SCOREDAT_NOT_CLEARED) { \ + grp_put_palette_show(REGIST_BG_NOT_CLEARED); \ + } else { \ + grp_put(REGIST_BG_CLEARED); \ + } \ + graph_copy_page_back_to_front(); \ + z_palette_black_in(); \ +} + +#define regist_title_put(left, stage, ranks, fx) { \ + extern const char REGIST_TITLE_1[]; \ + extern const char REGIST_TITLE_2[]; \ + if(stage < SCOREDAT_NOT_CLEARED) { \ + graph_putsa_fx(left + 0, TITLE_BACK_TOP, fx, REGIST_TITLE_1); \ + graph_putsa_fx(left + 192, TITLE_BACK_TOP, fx, ranks[rank]); \ + } else { \ + graph_putsa_fx(left + 0, TITLE_TOP, fx, REGIST_TITLE_2); \ + graph_putsa_fx(left + 192, TITLE_TOP, fx, ranks[rank]); \ + } \ +} + #include "th01/hiscore/regist.cpp" } diff --git a/th01_fuuin.asm b/th01_fuuin.asm index 3d71fb87..a0205345 100644 --- a/th01_fuuin.asm +++ b/th01_fuuin.asm @@ -30,7 +30,6 @@ include th01/th01.inc extern FTOL@:proc extern F_LUDIV@:proc extern LUMOD@:proc - extern LXLSH@:proc extern LXMUL@:proc extern SCOPY@:proc extern __mbcjmstojis:proc @@ -56,8 +55,6 @@ include th01/th01.inc extern _strcpy:proc extern _vsprintf:proc -fuuin_02 group fuuin_02_TEXT, fuuin_02__TEXT - ; =========================================================================== ; Segment type: Pure code @@ -370,377 +367,9 @@ fuuin_01_TEXT ends fuuin_02_TEXT segment byte public 'CODE' use16 extern _input_sense:proc extern _input_reset_sense:proc - extern _scoredat_load:proc - extern _scoredat_name_get:proc - extern _alphabet_put_initial:proc - extern _regist_put_initial:proc - extern _regist_name_enter:proc + extern _regist:proc fuuin_02_TEXT ends -fuuin_02__TEXT segment byte public 'CODE' use16 - assume cs:fuuin_02 - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_B5D8 proc far - -var_D2 = byte ptr -0D2h -var_D0 = byte ptr -0D0h -var_C0 = byte ptr -0C0h -var_C = word ptr -0Ch -var_A = word ptr -0Ah -var_8 = word ptr -8 -var_6 = word ptr -6 -@@place = word ptr -4 -var_2 = word ptr -2 -@@points = dword ptr 6 -arg_4 = word ptr 0Ah -@@route = dword ptr 0Ch - - enter 0D0h, 0 - push si - push di - mov di, [bp+arg_4] - lea ax, [bp+var_D0] - push ss - push ax - push ds - push offset off_12C1E - mov cx, 10h - call SCOPY@ - push 1 - call _graph_accesspage_func - pop cx - mov al, _rank - mov ah, 0 - shl ax, 2 - lea dx, [bp+var_D0] - add ax, dx - mov bx, ax - push word ptr ss:[bx+2] - push word ptr ss:[bx] ; arglist - push ds - push offset aUmx ; "東方靈異伝 強者の記録 %s" - push 227h ; int - push 0 ; int - push 0 ; int - call _graph_printf_fx - add sp, 0Eh - push 0 - call _graph_accesspage_func - pop cx - cmp di, 1Eh - jge short loc_B666 - push 10h - push 120h - push 180h - push 0 - push 0 - push 30h ; '0' - call _graph_2xscale_byterect_1_to_0_sl - add sp, 0Ch - call _graph_move_byterect_interpage c, 0, 384, 288, RES_Y, 0, 384, 0, 1 - jmp short loc_B67B -; --------------------------------------------------------------------------- - -loc_B666: - push 10h - push 120h - push 0 - push 0 - push 0 - push 30h ; '0' - call _graph_2xscale_byterect_1_to_0_sl - add sp, 0Ch - -loc_B67B: - call fuuin_02:_scoredat_load - or ax, ax - jz short loc_B686 - jmp loc_B941 -; --------------------------------------------------------------------------- - -loc_B686: - mov [bp+var_2], 0 - mov [bp+@@place], 0 - jmp short loc_B6B2 -; --------------------------------------------------------------------------- - -loc_B692: - mov ax, [bp+@@place] - imul ax, ((SCOREDAT_NAME_KANJI + 1) * word) - lea dx, [bp+var_C0] - add ax, dx - call fuuin_02:_scoredat_name_get c, [bp+@@place], ax, ss - add [bp+@@place], 1 - adc [bp+var_2], 0 - -loc_B6B2: - cmp [bp+var_2], 0 - jl short loc_B692 - jnz short loc_B6C0 - cmp [bp+@@place], SCOREDAT_PLACES - jb short loc_B692 - -loc_B6C0: - mov [bp+var_2], 0 - mov [bp+@@place], 0 - jmp short loc_B6F5 -; --------------------------------------------------------------------------- - -loc_B6CC: - mov ax, [bp+@@place] - shl ax, 2 - les bx, _scoredat_points - add bx, ax - mov dx, es:[bx+2] - mov ax, es:[bx] - cmp dx, word ptr [bp+@@points+2] - jg short loc_B6ED - jnz short loc_B6EB - cmp ax, word ptr [bp+@@points] - ja short loc_B6ED - -loc_B6EB: - jmp short loc_B703 -; --------------------------------------------------------------------------- - -loc_B6ED: - add [bp+@@place], 1 - adc [bp+var_2], 0 - -loc_B6F5: - cmp [bp+var_2], 0 - jl short loc_B6CC - jnz short loc_B703 - cmp [bp+@@place], SCOREDAT_PLACES - jb short loc_B6CC - -loc_B703: - call fuuin_02:_input_reset_sense - cmp [bp+var_2], 0 - jle short loc_B710 - jmp loc_B8BD -; --------------------------------------------------------------------------- - -loc_B710: - jl short loc_B71B - cmp [bp+@@place], SCOREDAT_PLACES - jb short loc_B71B - jmp loc_B8BD -; --------------------------------------------------------------------------- - -loc_B71B: - mov [bp+var_6], 0 - mov [bp+var_8], (SCOREDAT_PLACES - 1) - jmp loc_B7D9 -; --------------------------------------------------------------------------- - -loc_B728: - push ss - mov ax, [bp+var_8] - imul ax, ((SCOREDAT_NAME_KANJI + 1) * word) - lea dx, [bp+var_D2] - add ax, dx - push ax ; src - mov ax, [bp+var_8] - imul ax, ((SCOREDAT_NAME_KANJI + 1) * word) - lea dx, [bp+var_C0] - add ax, dx - push ss - push ax ; dest - call _strcpy - add sp, 8 - mov ax, [bp+var_8] - dec ax - shl ax, 2 - les bx, _scoredat_points - add bx, ax - mov dx, es:[bx+2] - mov ax, es:[bx] - mov bx, [bp+var_8] - shl bx, 2 - les si, _scoredat_points - add si, bx - mov es:[si+2], dx - mov es:[si], ax - mov ax, [bp+var_8] - dec ax - add ax, ax - les bx, _scoredat_stages - add bx, ax - mov ax, es:[bx] - mov dx, [bp+var_8] - add dx, dx - les bx, _scoredat_stages - add bx, dx - mov es:[bx], ax - mov bx, [bp+var_8] - add bx, bx - mov es, word ptr _scoredat_routes+2 - add bx, word ptr _scoredat_routes - mov al, es:[bx-2] - mov dx, [bp+var_8] - add dx, dx - les bx, _scoredat_routes - add bx, dx - mov es:[bx], al - mov bx, [bp+var_8] - add bx, bx - mov es, word ptr _scoredat_routes+2 - add bx, word ptr _scoredat_routes - mov al, es:[bx-1] - mov bx, [bp+var_8] - add bx, bx - mov es, word ptr _scoredat_routes+2 - add bx, word ptr _scoredat_routes - mov es:[bx+1], al - sub [bp+var_8], 1 - sbb [bp+var_6], 0 - -loc_B7D9: - mov dx, [bp+var_6] - mov ax, [bp+var_8] - cmp dx, [bp+var_2] - jle short loc_B7E7 - jmp loc_B728 -; --------------------------------------------------------------------------- - -loc_B7E7: - jnz short loc_B7F1 - cmp ax, [bp+@@place] - jbe short loc_B7F1 - jmp loc_B728 -; --------------------------------------------------------------------------- - -loc_B7F1: - mov [bp+var_A], 0 - mov [bp+var_C], (size scoredat_names_t - 1) - jmp short loc_B81E -; --------------------------------------------------------------------------- - -loc_B7FD: - mov bx, [bp+var_C] - mov es, word ptr _scoredat_names+2 - add bx, word ptr _scoredat_names - mov al, es:[bx-SCOREDAT_NAME_BYTES] - les bx, _scoredat_names - add bx, [bp+var_C] - mov es:[bx], al - sub [bp+var_C], 1 - sbb [bp+var_A], 0 - -loc_B81E: - mov dx, [bp+var_2] - mov ax, [bp+@@place] - mov cl, 4 - call far ptr LXLSH@ - add ax, 10h - adc dx, 0 - cmp dx, [bp+var_A] - jl short loc_B7FD - jg short loc_B83D - cmp ax, [bp+var_C] - jbe short loc_B7FD - -loc_B83D: - push ss - lea ax, [bp+var_C0] - push ax - push word ptr [bp+@@route+2] - push word ptr [bp+@@route] - push di - push word ptr [bp+@@points+2] - push word ptr [bp+@@points] - push [bp+@@place] - call _regist_put_initial - add sp, 10h - call _alphabet_put_initial - mov ax, [bp+@@place] - shl ax, 2 - les bx, _scoredat_points - add bx, ax - mov dx, word ptr [bp+@@points+2] - mov ax, word ptr [bp+@@points] - mov es:[bx+2], dx - mov es:[bx], ax - mov ax, [bp+@@place] - add ax, ax - les bx, _scoredat_stages - add bx, ax - mov es:[bx], di - mov ax, [bp+@@place] - add ax, ax - les bx, _scoredat_routes - add bx, ax - push es - les si, [bp+@@route] - mov al, es:[si] - pop es - mov es:[bx], al - les bx, [bp+@@route] - mov al, es:[bx+1] - mov bx, [bp+@@place] - add bx, bx - mov es, word ptr _scoredat_routes+2 - add bx, word ptr _scoredat_routes - mov es:[bx+1], al - call _regist_name_enter stdcall, [bp+@@place] - pop cx - jmp short loc_B8FC -; --------------------------------------------------------------------------- - -loc_B8BD: - push ss - lea ax, [bp+var_C0] - push ax - push word ptr [bp+@@route+2] - push word ptr [bp+@@route] - push di - push word ptr [bp+@@points+2] - push word ptr [bp+@@points] - push 1Eh - call _regist_put_initial - add sp, 10h - mov _input_ok, 1 - mov _input_shot, 1 - -loc_B8E3: - call fuuin_02:_input_sense stdcall, 0 - pop cx - cmp _input_ok, 0 - jz short loc_B8F8 - cmp _input_shot, 0 - jnz short loc_B8FA - -loc_B8F8: - jmp short loc_B8FC -; --------------------------------------------------------------------------- - -loc_B8FA: - jmp short loc_B8E3 -; --------------------------------------------------------------------------- - -loc_B8FC: - mov ax, seg fuuin_08_TEXT - mov es, ax - assume es:fuuin_08_TEXT - call @$bdla$qnv c, word ptr _scoredat_names, word ptr _scoredat_names+2 - call @$bdla$qnv c, word ptr _scoredat_stages, word ptr _scoredat_stages+2 - call @$bdla$qnv c, word ptr _scoredat_routes, word ptr _scoredat_routes+2 - call @$bdla$qnv c, word ptr _scoredat_points, word ptr _scoredat_points+2 - -loc_B941: - pop di - pop si - leave - retf -sub_B5D8 endp - -fuuin_02__TEXT ends - ; =========================================================================== ; Segment type: Pure code @@ -2202,19 +1831,19 @@ loc_C6C7: jnz short loc_C71C push ds push offset aKo ; "完" - push 32h ; '2' + push SCOREDAT_CLEARED_MAKAI jmp short loc_C722 ; --------------------------------------------------------------------------- loc_C71C: push ds push offset aKo_0 ; "完" - push 3Ch ; '<' + push SCOREDAT_CLEARED_JIGOKU loc_C722: push word ptr _score+2 push word ptr _score - call sub_B5D8 + call _regist add sp, 0Ah call sub_A076 pop si @@ -2400,7 +2029,6 @@ fuuin_11_TEXT ends ; Segment type: Pure code fuuin_12_TEXT segment byte public 'CODE' use16 - extern _graph_2xscale_byterect_1_to_0_sl:proc fuuin_12_TEXT ends ; =========================================================================== @@ -2436,20 +2064,9 @@ include th01/hardware/input_main_end[data].asm include th01/hiscore/alphabet_syms[data].asm include th01/hardware/grppfnfx_ptrs[data].asm include th01/hiscore/regist_name[data].asm -off_12C1E dd aB@gcbGwbB@ - ; " イージー " - dd aB@gmbGGlb@ ; " ノーマル " - dd aB@gnbGhb@b@ ; " ハード  " - dd aGlgigegbgbgn ; "ルナティック" include th01/hardware/grppfnfx[data].asm include th01/hiscore/scorelod[data].asm include th01/hiscore/regist[data].asm -aB@gcbGwbB@ db ' イージー ',0 -aB@gmbGGlb@ db ' ノーマル ',0 -aB@gnbGhb@b@ db ' ハード  ',0 -aGlgigegbgbgn db 'ルナティック',0 -; char aUmx[3] -aUmx db '東方靈異伝 強者の記録 %s',0 dd aB@gvguglbB@ ; " モンキー " dd aB@cRlio ; " 類人猿" dd aGzgvgtgsgggugx ; "ホモサピエンス" diff --git a/th01_reiiden.asm b/th01_reiiden.asm index 91b5cf39..31070c18 100644 --- a/th01_reiiden.asm +++ b/th01_reiiden.asm @@ -3460,7 +3460,7 @@ var_C = word ptr -0Ch s1 = dword ptr -0Ah var_6 = word ptr -6 var_4 = word ptr -4 -var_2 = word ptr -2 +@@stage = word ptr -2 _argc = word ptr 6 _argv = dword ptr 8 _envp = dword ptr 0Ch @@ -3468,7 +3468,7 @@ _envp = dword ptr 0Ch enter 1Eh, 0 push si push di - mov [bp+var_2], 0 + mov [bp+@@stage], 0 xor si, si mov [bp+var_4], 0 call _mdrv2_resident @@ -3479,7 +3479,7 @@ _envp = dword ptr 0Ch loc_D54F: push ss - lea ax, [bp+var_2] + lea ax, [bp+@@stage] push ax push ds push offset _continues_total @@ -3537,7 +3537,7 @@ loc_D583: call _puts add sp, 4 push ss - lea ax, [bp+var_2] + lea ax, [bp+@@stage] push ax push ds push offset aD ; "%d" @@ -3553,7 +3553,7 @@ loc_D583: push offset aD ; "%d" call _scanf add sp, 8 - cmp [bp+var_2], 5 + cmp [bp+@@stage], 5 jge short loc_D62C jmp short loc_D644 ; --------------------------------------------------------------------------- @@ -3609,14 +3609,14 @@ loc_D68E: call _mdrv2_check_board loc_D69C: - cmp [bp+var_2], 5 + cmp [bp+@@stage], 5 jge short loc_D6A6 xor ax, ax jmp short loc_D6EE ; --------------------------------------------------------------------------- loc_D6A6: - cmp [bp+var_2], 0Ah + cmp [bp+@@stage], 10 jge short loc_D6BD cmp _route, 0 jnz short loc_D6B8 @@ -3630,7 +3630,7 @@ loc_D6B8: ; --------------------------------------------------------------------------- loc_D6BD: - cmp [bp+var_2], 0Fh + cmp [bp+@@stage], 15 jge short loc_D6D4 cmp _route, 0 jnz short loc_D6CF @@ -3644,7 +3644,7 @@ loc_D6CF: ; --------------------------------------------------------------------------- loc_D6D4: - cmp [bp+var_2], 14h + cmp [bp+@@stage], 20 jge short loc_D6EB cmp _route, 0 jnz short loc_D6E6 @@ -3748,7 +3748,7 @@ loc_D7E2: loc_D7E4: les bx, _resident - mov ax, [bp+var_2] + mov ax, [bp+@@stage] mov es:[bx+reiidenconfig_t.stage], ax mov al, _route mov es:[bx+reiidenconfig_t.route], al @@ -3770,7 +3770,7 @@ loc_D7E4: mov word_360CA, 0 mov word_34A78, 0 mov _player_invincibility_time, 0 - mov ax, [bp+var_2] + mov ax, [bp+@@stage] mov [bp+var_E], ax mov cx, 4 ; switch 4 cases mov bx, offset word_E309 @@ -3977,7 +3977,7 @@ loc_DA2A: pop cx loc_DA49: - mov al, byte ptr [bp+var_2] + mov al, byte ptr [bp+@@stage] inc al mov byte_34A34, al mov al, byte_34ADF @@ -3990,7 +3990,7 @@ loc_DA49: jz short loc_DA7B push di ; int pushd [bp+s1] ; s1 - mov ax, [bp+var_2] + mov ax, [bp+@@stage] mov bx, 5 cwd idiv bx @@ -4040,13 +4040,13 @@ loc_DAD7: mov dword_36C20, 0 mov point_36C28.x, 600 mov point_36C28.y, 280 - mov ax, [bp+var_2] + mov ax, [bp+@@stage] mov bx, 5 cwd idiv bx or dx, dx jz short loc_DB04 - mov ax, [bp+var_2] + mov ax, [bp+@@stage] cwd idiv bx cmp dx, 4 @@ -4329,7 +4329,7 @@ loc_DD6B: push offset unk_3940D call sub_12347 add sp, 4 - push [bp+var_2] + push [bp+@@stage] call sub_C766 cmp _paused, 1 jnz short loc_DDF8 @@ -4422,9 +4422,9 @@ loc_DEDA: loc_DF03: inc si - inc [bp+var_2] + inc [bp+@@stage] les bx, _resident - mov ax, [bp+var_2] + mov ax, [bp+@@stage] mov es:[bx+reiidenconfig_t.stage], ax cmp byte_34ADF, 0 jz short loc_DF23 @@ -4435,7 +4435,7 @@ loc_DF03: ; --------------------------------------------------------------------------- loc_DF23: - push [bp+var_2] + push [bp+@@stage] call sub_13101 loc_DF2B: @@ -4446,7 +4446,7 @@ loc_DF2B: mov es:[bx+reiidenconfig_t.bullet_speed], 0 loc_DF3D: - mov ax, [bp+var_2] + mov ax, [bp+@@stage] mov bx, 5 cwd idiv bx @@ -4697,7 +4697,7 @@ loc_E27B: les bx, _resident mov eax, _score mov es:[bx+reiidenconfig_t.score], eax - cmp [bp+var_2], 5 + cmp [bp+@@stage], 5 jge short loc_E295 mov dx, ds mov ax, offset _SCOREDAT_ROUTE_SHRINE @@ -4719,14 +4719,14 @@ loc_E2A3: loc_E2A8: push dx push ax - mov ax, [bp+var_2] + mov ax, [bp+@@stage] inc ax push ax pushd [_score] - call sub_148B3 + call _regist add sp, 0Ah les bx, _resident - mov ax, [bp+var_2] + mov ax, [bp+@@stage] mov es:[bx+reiidenconfig_t.stage], ax call sub_CC0F @@ -8413,306 +8413,12 @@ main_18_TEXT ends main_19_TEXT segment byte public 'CODE' use16 extern _scoredat_load:proc extern _scoredat_hiscore_get:proc - extern _scoredat_name_get:proc main_19_TEXT ends main_19__TEXT segment byte public 'CODE' use16 assume cs:main_19 - extern _alphabet_put_initial:proc - extern _regist_put_initial:proc extern _scoredat_free:proc - extern _regist_name_enter:proc - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_148B3 proc far - -var_D2 = byte ptr -0D2h -var_D0 = byte ptr -0D0h -var_C0 = byte ptr -0C0h -var_C = dword ptr -0Ch -var_8 = dword ptr -8 -@@place = dword ptr -4 -@@points = dword ptr 6 -arg_4 = word ptr 0Ah -@@route = dword ptr 0Ch - - enter 0D0h, 0 - push si - push di - mov di, [bp+arg_4] - lea ax, [bp+var_D0] - push ss - push ax - push ds - push offset off_358A3 - mov cx, 10h - call SCOPY@ - call _z_graph_clear_0 - call _z_palette_black - push 1 - call _graph_accesspage_func - pop cx - cmp di, 1Eh - jge short loc_148F0 - call _grp_put_palette_show stdcall, offset aGame_o_grp, ds ; "game_o.grp" - jmp short loc_148F9 -; --------------------------------------------------------------------------- - -loc_148F0: - call _grp_put stdcall, offset aEndm_a_grp, ds ; "endm_a.grp" - -loc_148F9: - add sp, 4 - call _graph_copy_page_back_to_front - call _z_palette_black_in - push 1 - call _graph_accesspage_func - pop cx - cmp di, 1Eh - jge short loc_14942 - call _graph_putsa_fx c, 0, large ((FX_CLEAR_BG or 27h) shl 16) or 384, offset aUmx_2, ds ; "東方靈異伝 強者の記録 " - mov al, _rank - cbw - shl ax, 2 - lea dx, [bp+var_D0] - add ax, dx - mov bx, ax - pushd dword ptr ss:[bx] - push ((FX_CLEAR_BG or 27h) shl 16) or 384 - jmp short loc_1496F -; --------------------------------------------------------------------------- - -loc_14942: - call _graph_putsa_fx c, 0, large ((FX_CLEAR_BG or 27h) shl 16) or 0, offset aUmx_1, ds ; "東方靈異伝 強者の記録" - mov al, _rank - cbw - shl ax, 2 - lea dx, [bp+var_D0] - add ax, dx - mov bx, ax - pushd dword ptr ss:[bx] - push ((FX_CLEAR_BG or 27h) shl 16) or 0 - -loc_1496F: - push 192 - call _graph_putsa_fx - add sp, 0Ah - push 0 - call _graph_accesspage_func - pop cx - cmp di, 1Eh - jge short loc_149C0 - push 100120h - push 1800000h - pushd 30h ; '0' - call _graph_2xscale_byterect_1_to_0_sl - add sp, 0Ch - call _graph_move_byterect_interpage c, large (384 shl 16) or 0, large (RES_Y shl 16) or 288, large (384 shl 16) or 0, large (1 shl 16) or 0 - jmp short loc_149D4 -; --------------------------------------------------------------------------- - -loc_149C0: - push 100120h - pushd 0 - pushd 30h ; '0' - call _graph_2xscale_byterect_1_to_0_sl - add sp, 0Ch - -loc_149D4: - call main_19:_scoredat_load - or ax, ax - jnz loc_14BCE - mov [bp+@@place], 0 - jmp short loc_14A04 -; --------------------------------------------------------------------------- - -loc_149E8: - mov ax, word ptr [bp+@@place] - imul ax, ((SCOREDAT_NAME_KANJI + 1) * word) - lea dx, [bp+var_C0] - add ax, dx - call main_19:_scoredat_name_get c, word ptr [bp+@@place], ax, ss - inc [bp+@@place] - -loc_14A04: - cmp [bp+@@place], SCOREDAT_PLACES - jl short loc_149E8 - mov [bp+@@place], 0 - jmp short loc_14A2F -; --------------------------------------------------------------------------- - -loc_14A15: - mov ax, word ptr [bp+@@place] - shl ax, 2 - les bx, _scoredat_points - add bx, ax - mov eax, es:[bx] - cmp eax, [bp+@@points] - jle short loc_14A36 - inc [bp+@@place] - -loc_14A2F: - cmp [bp+@@place], SCOREDAT_PLACES - jl short loc_14A15 - -loc_14A36: - call _input_reset_sense - cmp [bp+@@place], SCOREDAT_PLACES - jge loc_14B8D - mov [bp+var_8], 9 - jmp loc_14AD1 -; --------------------------------------------------------------------------- - -loc_14A4F: - push ss - mov ax, word ptr [bp+var_8] - imul ax, ((SCOREDAT_NAME_KANJI + 1) * word) - lea dx, [bp+var_D2] - add ax, dx - push ax ; src - mov ax, word ptr [bp+var_8] - imul ax, ((SCOREDAT_NAME_KANJI + 1) * word) - lea dx, [bp+var_C0] - add ax, dx - push ss - push ax ; dest - call _strcpy - add sp, 8 - mov ax, word ptr [bp+var_8] - dec ax - shl ax, 2 - les bx, _scoredat_points - add bx, ax - mov eax, es:[bx] - mov dx, word ptr [bp+var_8] - shl dx, 2 - mov bx, word ptr _scoredat_points - add bx, dx - mov es:[bx], eax - mov ax, word ptr [bp+var_8] - dec ax - add ax, ax - les bx, _scoredat_stages - add bx, ax - mov ax, es:[bx] - mov dx, word ptr [bp+var_8] - add dx, dx - mov bx, word ptr _scoredat_stages - add bx, dx - mov es:[bx], ax - mov bx, word ptr [bp+var_8] - add bx, bx - mov es, word ptr _scoredat_routes+2 - add bx, word ptr _scoredat_routes - mov al, es:[bx-2] - mov es:[bx], al - mov al, es:[bx-1] - mov es:[bx+1], al - dec [bp+var_8] - -loc_14AD1: - mov eax, [bp+var_8] - cmp eax, [bp+@@place] - jg loc_14A4F - mov [bp+var_C], (size scoredat_names_t - 1) - jmp short loc_14B04 -; --------------------------------------------------------------------------- - -loc_14AE7: - mov bx, word ptr [bp+var_C] - mov es, word ptr _scoredat_names+2 - add bx, word ptr _scoredat_names - mov al, es:[bx-SCOREDAT_NAME_BYTES] - mov bx, word ptr _scoredat_names - add bx, word ptr [bp+var_C] - mov es:[bx], al - dec [bp+var_C] - -loc_14B04: - mov eax, [bp+@@place] - shl eax, 4 - add eax, SCOREDAT_NAME_BYTES - cmp eax, [bp+var_C] - jle short loc_14AE7 - push ss - lea ax, [bp+var_C0] - push ax - pushd [bp+@@route] - push di - pushd [bp+@@points] - push word ptr [bp+@@place] - call _regist_put_initial - add sp, 10h - call _alphabet_put_initial - mov ax, word ptr [bp+@@place] - shl ax, 2 - les bx, _scoredat_points - add bx, ax - mov eax, [bp+@@points] - mov es:[bx], eax - mov ax, word ptr [bp+@@place] - add ax, ax - les bx, _scoredat_stages - add bx, ax - mov es:[bx], di - mov ax, word ptr [bp+@@place] - add ax, ax - les bx, _scoredat_routes - add bx, ax - push es - les si, [bp+@@route] - mov al, es:[si] - pop es - mov es:[bx], al - les bx, [bp+@@route] - mov al, es:[bx+1] - mov bx, word ptr [bp+@@place] - add bx, bx - mov es, word ptr _scoredat_routes+2 - add bx, word ptr _scoredat_routes - mov es:[bx+1], al - call _regist_name_enter stdcall, word ptr [bp+@@place] - pop cx - jmp short loc_14BC5 -; --------------------------------------------------------------------------- - -loc_14B8D: - push ss - lea ax, [bp+var_C0] - push ax - pushd [bp+@@route] - push di - pushd [bp+@@points] - push 1Eh - call _regist_put_initial - add sp, 10h - mov _input_ok, 1 - mov _input_shot, 1 - -loc_14BAF: - call _input_sense stdcall, 0 - pop cx - cmp _input_ok, 0 - jz short loc_14BC5 - cmp _input_shot, 0 - jnz short loc_14BAF - -loc_14BC5: - mov ax, seg main_06_TEXT - mov es, ax - assume es:main_06_TEXT - call _scoredat_free - -loc_14BCE: - pop di - pop si - leave - retf -sub_148B3 endp - + extern _regist:proc ; =============== S U B R O U T I N E ======================================= @@ -59467,21 +59173,8 @@ aVgvivfb@vyb@vj db ' db 0 include th01/hiscore/alphabet_syms[data].asm include th01/hiscore/regist_name[data].asm -off_358A3 dd aB@gcbGwbB@ - ; " イージー " - dd aB@gmbGGlb@ ; " ノーマル " - dd aB@gnbGhb@b@ ; " ハード  " - dd aGlgigegbgbgn ; "ルナティック" include th01/hiscore/scorelod[data].asm include th01/hiscore/regist[data].asm -aB@gcbGwbB@ db ' イージー ',0 -aB@gmbGGlb@ db ' ノーマル ',0 -aB@gnbGhb@b@ db ' ハード  ',0 -aGlgigegbgbgn db 'ルナティック',0 -aGame_o_grp db 'game_o.grp',0 -aEndm_a_grp db 'endm_a.grp',0 -aUmx_2 db '東方靈異伝 強者の記録 ',0 -aUmx_1 db '東方靈異伝 強者の記録',0 byte_35A44 db 0 db 0 include th01/formats/pf[data].asm