From c714c533101ccef16c42c2eee64f4ee6b5a28fd0 Mon Sep 17 00:00:00 2001 From: nmlgc Date: Mon, 15 Aug 2022 03:17:54 +0200 Subject: [PATCH] [Decompilation] [th01] Main menu, part 1 (reviewed) 5. Part of P0216, funded by JonathKane. --- th01/core/resstuff.cpp | 2 +- th01/core/resstuff.hpp | 5 +- th01/formats/cfg.hpp | 2 +- th01/formats/cfg.inc | 2 +- th01/hardware/grppsafx.inc | 6 - th01/op_01.cpp | 289 ++++++++++++++++++++++--------------- th01/shiftjis/op.hpp | 3 + th01/th01.inc | 4 - th01_op.asm | 196 ++++++++++--------------- th01_op_data.asm | 14 +- 10 files changed, 261 insertions(+), 262 deletions(-) create mode 100644 th01/shiftjis/op.hpp diff --git a/th01/core/resstuff.cpp b/th01/core/resstuff.cpp index 88ac3c3a..89c7bff4 100644 --- a/th01/core/resstuff.cpp +++ b/th01/core/resstuff.cpp @@ -12,7 +12,7 @@ resident_t far *resident; -void resident_stuff_set( +void resident_create_and_stuff_set( int8_t rank, bgm_mode_t bgm_mode, int8_t bombs, diff --git a/th01/core/resstuff.hpp b/th01/core/resstuff.hpp index c5743fe2..76f97921 100644 --- a/th01/core/resstuff.hpp +++ b/th01/core/resstuff.hpp @@ -1,4 +1,6 @@ -void resident_stuff_set( +// Allocates the resident structure if it doesn't exist yet, and initializes +// the given bunch of data with the respective values. +void resident_create_and_stuff_set( int8_t rank, bgm_mode_t bgm_mode, int8_t bombs, @@ -18,4 +20,5 @@ int resident_stuff_get( int& stage_id ); +// Frees the resident structure if it exists. void resident_free(void); diff --git a/th01/formats/cfg.hpp b/th01/formats/cfg.hpp index bbc3898e..f1638623 100644 --- a/th01/formats/cfg.hpp +++ b/th01/formats/cfg.hpp @@ -13,7 +13,7 @@ static const bgm_mode_t CFG_BGM_MODE_DEFAULT = BGM_MODE_MDRV2; #define CFG_BOMBS_DEFAULT (1) #define CFG_LIVES_EXTRA_DEFAULT (2) -#define CFG_LIVES_EXTRA_MAX (4) +static const int8_t CFG_LIVES_EXTRA_MAX = 5; struct cfg_t { char id[sizeof(CFG_ID) - 1]; diff --git a/th01/formats/cfg.inc b/th01/formats/cfg.inc index 32f64dd7..d8d4dc74 100644 --- a/th01/formats/cfg.inc +++ b/th01/formats/cfg.inc @@ -10,4 +10,4 @@ CFG_BGM_MODE_DEFAULT = 1 CFG_BOMBS_DEFAULT = 1 CFG_LIVES_EXTRA_DEFAULT = 2 -CFG_LIVES_EXTRA_MAX = 4 +CFG_LIVES_EXTRA_MAX = 5 diff --git a/th01/hardware/grppsafx.inc b/th01/hardware/grppsafx.inc index 6074b965..49c9a3a0 100644 --- a/th01/hardware/grppsafx.inc +++ b/th01/hardware/grppsafx.inc @@ -4,12 +4,6 @@ WEIGHT_BOLD = 2 WEIGHT_BLACK = 3 WEIGHT_COUNT = 4 -if (GAME eq 1) - FX_CLEAR_BG = 200h - FX_UNDERLINE = 400h - FX_REVERSE = 800h -endif - if (GAME le 3) FX_WEIGHT_NORMAL = (WEIGHT_NORMAL shl 4) FX_WEIGHT_HEAVY = (WEIGHT_HEAVY shl 4) diff --git a/th01/op_01.cpp b/th01/op_01.cpp index 74a2e3f7..1c3de21e 100644 --- a/th01/op_01.cpp +++ b/th01/op_01.cpp @@ -26,6 +26,11 @@ #include "th01/formats/cfg.hpp" #include "th01/formats/grp.h" #include "th01/snd/mdrv2.h" +#include "th01/shiftjis/op.hpp" + +extern long rand; + +extern const char aReimu_mdt[]; // Unused. The only thing on the main menu with this color is the "1996 ZUN" // text at the bottom... probably part of an effect that we never got to see. @@ -58,11 +63,13 @@ void snap_col_4(void) /// REIIDEN.CFG loading and saving /// ------------------------------ + extern cfg_options_t opts; +extern int8_t debug_mode; // These will be removed once the strings can be defined here #undef CFG_FN #undef CFG_ID -extern const char CFG_FN[], CFG_ID[], FOPEN_RB[], FOPEN_WB[]; +extern char CFG_FN[], CFG_ID[], FOPEN_RB[], FOPEN_WB[]; void cfg_load(void) { @@ -114,6 +121,11 @@ void cfg_save(void) /// Input /// ----- + +static const int MAIN_CHOICE_COUNT = 4; +static const int OPTION_CHOICE_COUNT = 5; +static const int MUSIC_CHOICE_COUNT = 2; + #undef RING_INC #undef RING_DEC @@ -146,7 +158,9 @@ extern char menu_sel; extern bool input_left; extern bool input_cancel; extern bool input_right; -extern unsigned char option_rows; + +// ZUN bloat: Just call resident_free() in the one case it's actually needed. +extern int8_t free_resident_structure_on_title_exit; // ACTUAL TYPE: bool inline void keygroup_sense(REGS& out, REGS& in, char group_id) { in.h.ah = 0x04; @@ -191,6 +205,8 @@ void main_input_sense(void) ok_shot_cancel_sense(out1, in); } +extern uint8_t option_choice_max; + void option_input_sense(void) { REGS in; @@ -205,7 +221,7 @@ void option_input_sense(void) input_onchange_ring(0, (out1.h.ah & K7_ARROW_UP) || (out2.h.ah & K8_NUM_8), - RING_DEC(menu_sel, option_rows) + RING_DEC(menu_sel, option_choice_max) ); input_update_bool( input_left, (out1.h.ah & K7_ARROW_LEFT) || (out2.h.ah & K8_NUM_4) @@ -215,7 +231,7 @@ void option_input_sense(void) input_onchange_ring(1, (out1.h.ah & K7_ARROW_DOWN) || (out2.h.ah & K9_NUM_2), - RING_INC(menu_sel, option_rows) + RING_INC(menu_sel, option_choice_max) ); input_update_bool( input_right, (out1.h.ah & K7_ARROW_RIGHT) || (out2.h.ah & K9_NUM_6) @@ -225,8 +241,6 @@ void option_input_sense(void) } /// ----- -/// White line animation -/// -------------------- void whiteline_put(screen_y_t y) { vram_offset_t vram_offset = vram_offset_shift(0, y); @@ -276,8 +290,8 @@ void whitelines_animate(void) graph_accesspage_func(0); } -void titlescreen_init(void) { - extern const char aReimu_mdt[]; +void title_init(void) +{ extern const char aReiiden2_grp[]; extern const char aReiiden3_grp[]; @@ -291,10 +305,12 @@ void titlescreen_init(void) { graph_accesspage_func(0); z_palette_black_in(); frame_delay(100); + whitelines_animate(); } -void titlescreen_create_op_win(void) { +void title_window_put(void) +{ extern const char aOp_win_grp[]; graph_accesspage_func(1); @@ -304,41 +320,45 @@ void titlescreen_create_op_win(void) { graph_copy_accessed_page_to_other(); } -void key_end_resident_free(void) { - extern char quit_flag; - - if(quit_flag == 1) +void title_exit(void) +{ + if(free_resident_structure_on_title_exit == true) { resident_free(); - + } key_end(); } -extern long rand; -extern char mode; +// Starting the game +// ----------------- -void start(void) { +static const pellet_speed_t PELLET_SPEED_DEFAULT = to_pellet_speed(-0.1); + +void start_game(void) +{ extern char aReiiden_0[]; cfg_save(); - resident_stuff_set(opts.rank, opts.bgm_mode, opts.bombs, opts.lives_extra, rand); - key_end_resident_free(); + resident_create_and_stuff_set( + opts.rank, opts.bgm_mode, opts.bombs, opts.lives_extra, rand + ); + title_exit(); mdrv2_bgm_fade_out_nonblock(); game_switch_binary(); - if(mode == 2) { + if(debug_mode == 2) { resident->debug_mode = DM_TEST; - } else if(mode == 3) { + } else if(debug_mode == 3) { resident->debug_mode = DM_FULL; - } else if(mode == 0) { + } else if(debug_mode == 0) { resident->debug_mode = DM_OFF; } - resident->route = 0; + resident->route = ROUTE_MAKAI; resident->stage_id = 0; - resident->rem_lives = opts.lives_extra + 2; + resident->rem_lives = (opts.lives_extra + 2); resident->point_value = 0; - for(int i = 0; i < 4; i++) { + for(int i = 0; i < SCENE_COUNT; i++) { resident->continues_per_scene[i] = 0; resident->bonus_per_stage[i] = 0; } @@ -347,140 +367,171 @@ void start(void) { resident->continues_total = 0; resident->end_flag = ES_NONE; resident->unused_1 = 0; - resident->snd_need_init = 1; - resident->pellet_speed = -4; + resident->snd_need_init = true; + resident->pellet_speed = PELLET_SPEED_DEFAULT; - execl(aReiiden_0, aReiiden_0, NULL); + execl(aReiiden_0, aReiiden_0, nullptr); } -void Continue(void) { // Reserved keyword +void start_continue(void) +{ cfg_save(); - resident_stuff_set(opts.rank, opts.bgm_mode, opts.bombs, opts.lives_extra, rand); + resident_create_and_stuff_set( + opts.rank, opts.bgm_mode, opts.bombs, opts.lives_extra, rand + ); if(resident->stage_id == 0) { - _ES = FP_SEG(cfg_load); // Yes, no point to this at all + _ES = FP_SEG(cfg_load); // ZUN bloat: Yes, no point to this at all } - key_end_resident_free(); + title_exit(); mdrv2_bgm_fade_out_nonblock(); game_switch_binary(); resident->debug_mode = DM_OFF; - resident->snd_need_init = 1; - resident->rem_lives = opts.lives_extra + 2; + resident->snd_need_init = true; + resident->rem_lives = (opts.lives_extra + 2); resident->unused_1 = 0; - resident->pellet_speed = -4; + resident->pellet_speed = PELLET_SPEED_DEFAULT; resident->point_value = 0; - execl((char*)MK_FP(_DS, CFG_ID), (char*)MK_FP(_DS, CFG_ID), NULL); + execl(CFG_ID, CFG_ID, nullptr); +} +// ----------------- + +/// Main menu +/// --------- +/// Terminology: "Choice" = Top-level menu selection (not amount of values) + +static const int COL_ACTIVE = 15; +static const int16_t FX = FX_WEIGHT_BLACK; + +// Coordinates +// ----------- + +static const screen_x_t MENU_CENTER_X = 316; +static const screen_y_t MENU_CENTER_Y = 316; +static const pixel_t MENU_W = 176; + +static const pixel_t CHOICE_PADDED_H = 20; + +static const int TRACK_COUNT = 15; + +#define choice_top_0(choice_count) ( \ + (MENU_CENTER_Y - (((choice_count) * CHOICE_PADDED_H) / 2)) \ +) + +#define choice_top(choice, choice_count) ( \ + (choice_top_0(choice_count) + (choice * CHOICE_PADDED_H)) \ +) + +#define music_choice_top(choice, choice_count) ( \ + (choice_top_0(choice_count + 1) + (choice * (CHOICE_PADDED_H * 2))) \ +) +// ----------- + +extern const shiftjis_t aSS[]; + +#define choice_put(left, top, col, str) { \ + graph_printf_fx(left, top, (col | FX), (aSS + 2), str); \ } -#define HIT_KEY_CYCLE_DUR 70 -#define HIT_KEY_SHOW_FRAMES 50 +#define choice_put_value(left, top, col, str, val) { \ + graph_printf_fx(left, top, (col | FX), aSS, str, val); \ +} -#define HIT_KEY_LEFT 244 -#define MAIN_MENU_LEFT 228 -#define MAIN_MENU_TOP 306 -#define MAIN_MENU_TEXT_WIDTH 128 -#define MAIN_MENU_TEXT_HEIGHT 16 -#define MAIN_MENU_OPTION_DISTANCE 20 -#define MAIN_MENU_OPTION_TOP 276 +void title_hit_key_put(int frame) +{ + enum { + LEFT = (((RES_X / 2) - GLYPH_FULL_W) - (shiftjis_w(HIT_KEY) / 2)), + TOP = choice_top(0, 1), + }; + extern const shiftjis_t GP_HIT_KEY[]; -void titlescreen_flash_hit_key_prompt(int frame) { - extern const char GP_HIT_KEY[]; - - if(frame % HIT_KEY_CYCLE_DUR < HIT_KEY_SHOW_FRAMES) { - graph_putsa_fx(HIT_KEY_LEFT, MAIN_MENU_TOP, FX_WEIGHT_BOLD | 0xF, GP_HIT_KEY); + if((frame % 70) < 50) { + graph_putsa_fx(LEFT, TOP, (FX_WEIGHT_BOLD | COL_ACTIVE), GP_HIT_KEY); } else { - egc_copy_rect_1_to_0_16(HIT_KEY_LEFT, MAIN_MENU_TOP, MAIN_MENU_TEXT_WIDTH, MAIN_MENU_TEXT_HEIGHT); + egc_copy_rect_1_to_0_16_word_w(LEFT, TOP, shiftjis_w(HIT_KEY), GLYPH_H); } } -#define MAIN_MENU_ENTRY_COUNT 4 -#define OPTIONS_COUNT 5 -#define RANK_COUNT 4 -#define FM_OPTION_COUNT 2 -#define LIFES_AMOUNT_TEXT_COUNT 5 - -#define MUSIC_TEST_MENU_OPTION_COUNT 2 -#define MUSIC_TEST_SONG_COUNT 15 - -template struct text_array_t { - const char* t[c]; +template struct TextArray { + const shiftjis_t* t[Count]; }; -void main_menu_draw_option(int str_idx, int col) { - extern text_array_t MAIN_MENU_TEXT; +void main_choice_unput_and_put(int choice, int col) +{ + extern TextArray MAIN_CHOICES; + const TextArray CHOICES = MAIN_CHOICES; - int _str_idx = str_idx; - int x; - int y; + screen_x_t left = (MENU_CENTER_X - (MAIN_CHOICE_W / 2)); + screen_y_t top = choice_top(choice, MAIN_CHOICE_COUNT); - text_array_t _main_menu_text = MAIN_MENU_TEXT; - - x = HIT_KEY_LEFT; - y = _str_idx * MAIN_MENU_OPTION_DISTANCE + MAIN_MENU_OPTION_TOP; - - graph_putsa_fx(x, y, col | FX_WEIGHT_BLACK, _main_menu_text.t[_str_idx]); + // No unblitting necessary here, as only the colors change. + graph_putsa_fx(left, top, (col | FX), CHOICES.t[choice]); } -extern const char aSS[]; +void option_choice_unput_and_put(int choice, int col) +{ + extern TextArray OPTION_CHOICES; + extern TextArray RANK_VALUES; + extern TextArray BGM_MODE_VALUES; + extern TextArray START_LIFE_VALUES; -void option_menu_draw_option(int option, int col) { - extern text_array_t OPTIONS_TEXT; - extern text_array_t RANK_TEXT; - extern text_array_t FM_OPTION; - extern text_array_t LIFES_AMOUNT_TEXT; + const TextArray CHOICES = OPTION_CHOICES; + const TextArray RANKS = RANK_VALUES; + const TextArray MUSIC_MODES = BGM_MODE_VALUES; + const TextArray START_LIVES = START_LIFE_VALUES; - int _option = option; + screen_x_t left = (MENU_CENTER_X - (MENU_W / 2)); + screen_y_t top = choice_top(choice, OPTION_CHOICE_COUNT); - text_array_t _options_text = OPTIONS_TEXT; - text_array_t _rank_text = RANK_TEXT; - text_array_t _fm_option = FM_OPTION; - text_array_t _lifes_amount_text = LIFES_AMOUNT_TEXT; + egc_copy_rect_1_to_0_16(left, top, MENU_W, GLYPH_H); - int left = MAIN_MENU_LEFT; - int top = _option * 20 + 266; - - egc_copy_rect_1_to_0_16(left, top, 0xB0, 0x10); - - if(_option == 0) { - graph_printf_fx(left, top, col | FX_WEIGHT_BLACK, aSS, _options_text.t[_option], _rank_text.t[opts.rank]); - } else if(_option == 1) { - graph_printf_fx(left, top, col | FX_WEIGHT_BLACK, aSS, _options_text.t[_option], _fm_option.t[opts.bgm_mode]); - } else if(_option == 2) { - graph_printf_fx(left, top, col | FX_WEIGHT_BLACK, aSS, _options_text.t[_option], _lifes_amount_text.t[opts.lives_extra]); - } else if(_option == 3) { - graph_printf_fx(left, top, col | FX_WEIGHT_BLACK, aSS + 2, _options_text.t[_option]); - } else if(_option == 4) { - graph_printf_fx(left, top, col | FX_WEIGHT_BLACK, aSS + 2, _options_text.t[_option]); + if(choice == 0) { + choice_put_value(left, top, col, CHOICES.t[choice], RANKS.t[opts.rank]); + } else if(choice == 1) { + choice_put_value( + left, top, col, CHOICES.t[choice], MUSIC_MODES.t[opts.bgm_mode] + ); + } else if(choice == 2) { + choice_put_value( + left, top, col, CHOICES.t[choice], START_LIVES.t[opts.lives_extra] + ); + } else if(choice == 3) { + choice_put(left, top, col, CHOICES.t[choice]); + } else if(choice == 4) { + choice_put(left, top, col, CHOICES.t[choice]); } } -extern char bgm_playing; -extern const char aS_2d[]; +extern int8_t music_sel; -void music_test_draw(int line, int col) { - int _line = line; +void music_choice_unput_and_put(int choice, int col) +{ + extern const char aS_2d[]; + extern TextArray MUSIC_CHOICES; + extern TextArray MUSIC_TITLES; - extern text_array_t MUSIC_TEST_MENU_TEXT; - extern text_array_t MUSIC_TEST_SONGS; + const TextArray CHOICES = MUSIC_CHOICES; + const TextArray TITLES = MUSIC_TITLES; - text_array_t _music_test_menu_text = MUSIC_TEST_MENU_TEXT; - text_array_t _music_test_songs = MUSIC_TEST_SONGS; + screen_x_t left = (MENU_CENTER_X - (MENU_W / 2)); + screen_y_t top = music_choice_top(choice, MUSIC_CHOICE_COUNT); - int left = MAIN_MENU_LEFT; - int top = _line * 40 + 286; + egc_copy_rect_1_to_0_16(left, top, MENU_W, GLYPH_H); - egc_copy_rect_1_to_0_16(left, top, 176, 16); - - if(_line == 0) { - egc_copy_rect_1_to_0_16(left, top + 20, 192, 16); - graph_printf_fx(left, top, col | FX_WEIGHT_BLACK, aS_2d, _music_test_menu_text.t[_line], bgm_playing); - graph_printf_fx(left, top + 20, col | FX_WEIGHT_BLACK, aSS + 2, _music_test_songs.t[bgm_playing]); - } else if(_line == 1){ - graph_printf_fx(left, top, col | FX_WEIGHT_BLACK, aSS + 2, _music_test_menu_text.t[_line]); + if(choice == 0) { + // ZUN bug: That's larger than the menu? + egc_copy_rect_1_to_0_16( + left, (top + CHOICE_PADDED_H), (MENU_W + GLYPH_FULL_W), GLYPH_H + ); + graph_printf_fx( + left, top, (col | FX), aS_2d, CHOICES.t[choice], music_sel + ); + choice_put(left, (top + CHOICE_PADDED_H), col, TITLES.t[music_sel]); + } else if(choice == 1) { + choice_put(left, top, col, CHOICES.t[choice]); } } - -/// -------------------- +/// --------- diff --git a/th01/shiftjis/op.hpp b/th01/shiftjis/op.hpp new file mode 100644 index 00000000..4381ad66 --- /dev/null +++ b/th01/shiftjis/op.hpp @@ -0,0 +1,3 @@ +#define HIT_KEY " ghs@jdx" + +static const pixel_t MAIN_CHOICE_W = (9 * GLYPH_FULL_W); diff --git a/th01/th01.inc b/th01/th01.inc index ce493634..cabf0a74 100644 --- a/th01/th01.inc +++ b/th01/th01.inc @@ -31,10 +31,6 @@ REGS ends SCENE_COUNT = 4 -DM_OFF = 0 -DM_TEST = 1 -DM_FULL = 3 - reiidenconfig_t struc ; (sizeof=0x4B) id db 13 dup(?) ; = "ReiidenConfig" db ? diff --git a/th01_op.asm b/th01_op.asm index f8995830..9e086708 100644 --- a/th01_op.asm +++ b/th01_op.asm @@ -20,14 +20,12 @@ BINARY = 'O' include ReC98.inc include th01/th01.inc -include th01/hardware/grppsafx.inc include th01/formats/cfg.inc extern SCOPY@:proc extern __setargv__:proc ; main() needs both to be set extern __setenvp__:proc extern _atol:proc - extern _execl:proc extern _int86:proc extern _memcmp:proc extern _printf:proc @@ -79,15 +77,15 @@ op_01__TEXT segment byte public 'CODE' use16 extern @main_input_sense$qv:proc extern @option_input_sense$qv:proc extern @whitelines_animate$qv:proc - extern @titlescreen_init$qv:proc - extern @titlescreen_create_op_win$qv:proc - extern @key_end_resident_free$qv:proc - extern @start$qv:proc - extern @Continue$qv:proc - extern @titlescreen_flash_hit_key_prompt$qi:proc - extern @main_menu_draw_option$qii:proc - extern @option_menu_draw_option$qii:proc - extern @music_test_draw$qii:proc + extern @title_init$qv:proc + extern @title_window_put$qv:proc + extern @title_exit$qv:proc + extern @start_game$qv:proc + extern @start_continue$qv:proc + extern @title_hit_key_put$qi:proc + extern @main_choice_unput_and_put$qii:proc + extern @option_choice_unput_and_put$qii:proc + extern @music_choice_unput_and_put$qii:proc ; =============== S U B R O U T I N E ======================================= @@ -99,23 +97,15 @@ sub_AB97 proc far cmp word_12564, 0 jnz short loc_AC04 call @egc_copy_rect_1_to_0_16$qiiii c, large (266 shl 16) or 220, large (100 shl 16) or 176 - push 50000h - call @main_menu_draw_option$qii - add sp, 4 - push 50001h - call @main_menu_draw_option$qii - add sp, 4 - push 50002h - call @main_menu_draw_option$qii - add sp, 4 - push 50003h - call @main_menu_draw_option$qii - add sp, 4 - push 0Fh + call @main_choice_unput_and_put$qii c, large 0 or (5 shl 16) + call @main_choice_unput_and_put$qii c, large 1 or (5 shl 16) + call @main_choice_unput_and_put$qii c, large 2 or (5 shl 16) + call @main_choice_unput_and_put$qii c, large 3 or (5 shl 16) + push 15 mov al, _menu_sel cbw push ax - call @main_menu_draw_option$qii + call @main_choice_unput_and_put$qii add sp, 4 mov word_12564, 1 mov al, _menu_sel @@ -127,15 +117,12 @@ loc_AC04: cbw cmp ax, word_12562 jz short loc_AC30 - push 5 - push word_12562 - call @main_menu_draw_option$qii - add sp, 4 + call @main_choice_unput_and_put$qii c, word_12562, 5 push 0Fh mov al, _menu_sel cbw push ax - call @main_menu_draw_option$qii + call @main_choice_unput_and_put$qii add sp, 4 mov al, _menu_sel cbw @@ -157,12 +144,12 @@ loc_AC3E: jmp cs:off_AC7C[bx] loc_AC50: - call @start$qv + call @start_game$qv jmp short loc_AC6E ; --------------------------------------------------------------------------- loc_AC56: - call @Continue$qv + call @start_continue$qv jmp short loc_AC6E ; --------------------------------------------------------------------------- @@ -203,38 +190,25 @@ sub_AC84 proc far mov _menu_sel, 0 mov word_12568, 0 mov word_12566, 1 - mov _option_rows, 4 + mov _option_choice_max, 4 call @egc_copy_rect_1_to_0_16$qiiii c, large (276 shl 16) or 220, large (80 shl 16) or 176 - push 0F0000h - call @option_menu_draw_option$qii - add sp, 4 - push 50001h - call @option_menu_draw_option$qii - add sp, 4 - push 50002h - call @option_menu_draw_option$qii - add sp, 4 - push 50003h - call @option_menu_draw_option$qii - add sp, 4 - push 50004h - call @option_menu_draw_option$qii - add sp, 4 + call @option_choice_unput_and_put$qii c, large 0 or (15 shl 16) + call @option_choice_unput_and_put$qii c, large 1 or (5 shl 16) + call @option_choice_unput_and_put$qii c, large 2 or (5 shl 16) + call @option_choice_unput_and_put$qii c, large 3 or (5 shl 16) + call @option_choice_unput_and_put$qii c, large 4 or (5 shl 16) loc_ACF9: mov al, _menu_sel cbw cmp ax, word_12568 jz short loc_AD25 - push 5 - push word_12568 - call @option_menu_draw_option$qii - add sp, 4 + call @option_choice_unput_and_put$qii c, word_12568, 5 push 0Fh mov al, _menu_sel cbw push ax - call @option_menu_draw_option$qii + call @option_choice_unput_and_put$qii add sp, 4 mov al, _menu_sel cbw @@ -284,14 +258,14 @@ loc_AD6F: cbw or ax, ax jge short loc_AD80 - mov _opts.O_lives_extra, CFG_LIVES_EXTRA_MAX + mov _opts.O_lives_extra, (CFG_LIVES_EXTRA_MAX - 1) loc_AD80: push 0Fh mov al, _menu_sel cbw push ax - call @option_menu_draw_option$qii + call @option_choice_unput_and_put$qii add sp, 4 mov word_1256A, 1 jmp short loc_AD9C @@ -342,7 +316,7 @@ loc_ADE8: inc _opts.O_lives_extra mov al, _opts.O_lives_extra cbw - cmp ax, CFG_LIVES_EXTRA_MAX + cmp ax, (CFG_LIVES_EXTRA_MAX - 1) jle short loc_ADFA mov _opts.O_lives_extra, 0 @@ -351,7 +325,7 @@ loc_ADFA: mov al, _menu_sel cbw push ax - call @option_menu_draw_option$qii + call @option_choice_unput_and_put$qii add sp, 4 mov word_1256C, 1 jmp short loc_AE16 @@ -415,11 +389,11 @@ var_3C = byte ptr -3Ch push ss push ax push ds - push offset _MUSIC_TEST_SONG_FILES + push offset _MUSIC_FILES mov cx, 3Ch ; '<' call SCOPY@ call @mdrv2_bgm_stop$qv - mov al, _bgm_playing + mov al, _music_sel cbw shl ax, 2 lea dx, [bp+var_3C] @@ -448,29 +422,22 @@ sub_AEA8 proc far mov word_125AA, 1 mov _input_ok, 0 mov _input_shot, 0 - mov _option_rows, 1 + mov _option_choice_max, 1 call @egc_copy_rect_1_to_0_16$qiiii c, large (266 shl 16) or 220, large (100 shl 16) or 176 - push 0F0000h - call @music_test_draw$qii - add sp, 4 - push 50001h - call @music_test_draw$qii - add sp, 4 + call @music_choice_unput_and_put$qii c, large 0 or (15 shl 16) + call @music_choice_unput_and_put$qii c, large 1 or (5 shl 16) loc_AF00: mov al, _menu_sel cbw cmp ax, word_125AC jz short loc_AF2C - push 5 - push word_125AC - call @music_test_draw$qii - add sp, 4 + call @music_choice_unput_and_put$qii c, word_125AC, 5 push 0Fh mov al, _menu_sel cbw push ax - call @music_test_draw$qii + call @music_choice_unput_and_put$qii add sp, 4 mov al, _menu_sel cbw @@ -485,17 +452,17 @@ loc_AF2C: jnz short loc_AF6F cmp _menu_sel, 0 jnz short loc_AF53 - dec _bgm_playing - cmp _bgm_playing, 0 + dec _music_sel + cmp _music_sel, 0 jge short loc_AF53 - mov _bgm_playing, 0Eh + mov _music_sel, 0Eh loc_AF53: push 0Fh mov al, _menu_sel cbw push ax - call @music_test_draw$qii + call @music_choice_unput_and_put$qii add sp, 4 mov word_125AE, 1 jmp short loc_AF6F @@ -513,17 +480,17 @@ loc_AF6F: jnz short loc_AFB2 cmp _menu_sel, 0 jnz short loc_AF96 - inc _bgm_playing - cmp _bgm_playing, 0Fh + inc _music_sel + cmp _music_sel, 0Fh jl short loc_AF96 - mov _bgm_playing, 0 + mov _music_sel, 0 loc_AF96: push 0Fh mov al, _menu_sel cbw push ax - call @music_test_draw$qii + call @music_choice_unput_and_put$qii add sp, 4 mov word_125B0, 1 jmp short loc_AFB2 @@ -613,7 +580,7 @@ loc_B015: cbw cmp ax, 73h ; 's' jnz short loc_B045 - mov _mode, 1 + mov _debug_mode, 1 loc_B045: les bx, [bp+_argv+2] @@ -622,7 +589,7 @@ loc_B045: cbw cmp ax, 74h ; 't' jnz short loc_B05A - mov _mode, 2 + mov _debug_mode, 2 loc_B05A: les bx, [bp+_argv+2] @@ -631,7 +598,7 @@ loc_B05A: cbw cmp ax, 64h ; 'd' jnz short loc_B06F - mov _mode, 3 + mov _debug_mode, 3 loc_B06F: push 3 ; n @@ -682,7 +649,7 @@ loc_B0D6: call _int86 add sp, 0Ah call key_start - call @titlescreen_init$qv + call @title_init$qv xor ax, ax mov es, ax mov al, es:((50h shl 4) + 00h) ; BIOS_FLAG @@ -699,8 +666,7 @@ loc_B126: push 1 call @frame_delay$qui pop cx - push di - call @titlescreen_flash_hit_key_prompt$qi + call @title_hit_key_put$qi stdcall, di pop cx inc di @@ -708,7 +674,7 @@ loc_B135: call key_sense_bios or ax, ax jz short loc_B126 - call @titlescreen_create_op_win$qv + call @title_window_put$qv mov eax, _rand mov random_seed, eax jmp loc_B21A @@ -812,9 +778,9 @@ loc_B21A: cmp byte_1232C, 0 jz loc_B14D call @cfg_save$qv - mov _quit_flag, 1 + mov _free_resident_structure_on_title, 1 call @mdrv2_bgm_stop$qv - call @key_end_resident_free$qv + call @title_exit$qv push 1 call @graph_accesspage_func$qi pop cx @@ -862,7 +828,6 @@ ztext_TEXT ends initexit_TEXT segment byte public 'CODE' use16 extern @game_init$qv:proc extern @game_exit$qv:proc - extern @game_switch_binary$qv:proc initexit_TEXT ends ; --------------------------------------------------------------------------- @@ -872,10 +837,6 @@ initexit_TEXT ends graph_TEXT segment byte public 'CODE' use16 extern @graph_accesspage_func$qi:proc extern @z_graph_clear$qv:proc - extern @graph_copy_accessed_page_to_othe$qv:proc - extern @z_palette_black$qv:proc - extern @z_palette_black_in$qv:proc - extern @graph_putsa_fx$qiiinxuc:proc graph_TEXT ends ; --------------------------------------------------------------------------- @@ -889,25 +850,19 @@ SHARED ends ; =========================================================================== ; Segment type: Pure code -grppffx_TEXT segment byte public 'CODE' use16 - extern @graph_printf_fx$qiiinxuce:proc +grppffx_TEXT segment byte public 'CODE' grppffx_TEXT ends ; =========================================================================== ; Segment type: Pure code PTN_GRP_GRZ segment byte public 'CODE' use16 - extern @grp_put_palette_show$qnxc:proc - extern @grp_put$qnxc:proc - extern @grp_put_colorkey$qnxc:proc PTN_GRP_GRZ ends ; =========================================================================== ; Segment type: Pure code -resstuff_TEXT segment byte public 'CODE' use16 - extern @resident_stuff_set$qc10bgm_mode_tccl:proc - extern @resident_free$qv:proc +resstuff_TEXT segment byte public 'CODE' resstuff_TEXT ends ; =========================================================================== @@ -918,7 +873,6 @@ mdrv2_TEXT segment byte public 'CODE' use16 extern @mdrv2_bgm_load$qnxc:proc extern @mdrv2_bgm_play$qv:proc extern @mdrv2_bgm_stop$qv:proc - extern @mdrv2_bgm_fade_out_nonblock$qv:proc extern @mdrv2_check_board$qv:proc mdrv2_TEXT ends @@ -932,7 +886,7 @@ op_12_TEXT ends .data extern _opts:cfg_options_t - extern _mode:byte + extern _debug_mode:byte extern _menu_sel:byte extern _input_left:byte extern _input_ok:byte @@ -943,51 +897,51 @@ op_12_TEXT ends extern byte_1232C:byte extern byte_1232D:byte extern byte_1232E:byte - extern _quit_flag:byte + extern _free_resident_structure_on_title:byte extern dword_12330:dword - extern _option_rows:byte + extern _option_choice_max:byte db 0 -public _MAIN_MENU_TEXT -_MAIN_MENU_TEXT label dword +public _MAIN_CHOICES +_MAIN_CHOICES label dword dd aVrvsvVqvs ; " rs`qs " dd aVbvnvmvsvhvmvt ; "bnmshmtd" dd aB@vnvovsvhvnvm ; "@noshnm@" dd aB@b@vpvtvhvsb@ ; "@@pths@@" -public _OPTIONS_TEXT, _RANK_TEXT, _FM_OPTION, _LIFES_AMOUNT_TEXT -_OPTIONS_TEXT label dword +public _OPTION_CHOICES, _RANK_VALUES, _BGM_MODE_VALUES, _START_LIFE_VALUES +_OPTION_CHOICES label dword dd aB@vqvVmvjb@ ; "@q`mj@ " dd aVlvtvrvhvb ; " ltrhb " dd aVovkvVxvdvq ; "ok`xdq " dd aVlbdvsvdvrvs ; "lDsdrs " dd aB@vpvtvhvsb@ ; "@pths@ " -_RANK_TEXT label dword +_RANK_VALUES label dword dd aEasy ; " EASY " dd aNormal ; "NORMAL" dd aHard ; " HARD " dd aLunatic ; "LUNATIC" -_FM_OPTION label dword +_BGM_MODE_VALUES label dword dd aOff ; " OFF " dd aFm ; " FM " -_LIFES_AMOUNT_TEXT label dword +_START_LIFE_VALUES label dword dd a3 ; " 3 " dd a4 ; " 4 " dd a5 ; " 5 " dd a6 ; " 6 " dd a7 ; " 7 " -public _bgm_playing -_bgm_playing db 0 +public _music_sel +_music_sel db 0 -public _MUSIC_TEST_MENU_TEXT -_MUSIC_TEST_MENU_TEXT label dword +public _MUSIC_CHOICES +_MUSIC_CHOICES label dword dd aVlvtvrvhvbb@vm ; "ltrhb@mD" dd aB@b@vpvxvivf ; "@@p " -public _MUSIC_TEST_SONGS -_MUSIC_TEST_SONGS label dword +public _MUSIC_TITLES +_MUSIC_TITLES label dword dd aASacretLot ; " A Sacret Lot" dd aXcvR_o ; " ̐_ " dd aIiiuvIPc ; " i̛ޏ " @@ -1011,8 +965,8 @@ word_12568 dw 0 word_1256A dw 0 word_1256C dw 0 -public _MUSIC_TEST_SONG_FILES -_MUSIC_TEST_SONG_FILES label dword +public _MUSIC_FILES +_MUSIC_FILES label dword dd _aReimu_mdt ; "reimu.mdt" dd aZipangu_mdt ; "ZIPANGU.mdt" dd aSt0_mdt ; "st0.mdt" @@ -1178,6 +1132,4 @@ _columns dd ROW_SIZE dup (?) extern key_backup:byte:786 extern keywork:byte:10 - extern _resident:dword - end diff --git a/th01_op_data.asm b/th01_op_data.asm index 3799e429..2c7032f6 100644 --- a/th01_op_data.asm +++ b/th01_op_data.asm @@ -9,13 +9,13 @@ include pc98.inc include th01/th01.inc include th01/formats/cfg.inc -public _opts, _mode +public _opts, _debug_mode _opts cfg_options_t -_mode db 0 -public _menu_sel, _option_rows +_debug_mode db 0 +public _menu_sel, _option_choice_max public _input_left, _input_right, _input_ok, _input_shot, _input_cancel -public byte_1232A, byte_1232C, byte_1232D, byte_1232E, _quit_flag, dword_12330 -public _main_input_prev, _option_input_prev +public byte_1232A, byte_1232C, byte_1232D, byte_1232E, dword_12330 +public _free_resident_structure_on_title, _main_input_prev, _option_input_prev _menu_sel db 0 _input_left db 0 _input_ok db 0 @@ -26,10 +26,10 @@ _input_right db 0 byte_1232C db 0 byte_1232D db 0 byte_1232E db 0 -_quit_flag db 0 +_free_resident_structure_on_title db 0 dword_12330 dd 0 _main_input_prev dw 2 dup (0) -_option_rows db 3 +_option_choice_max db 3 _option_input_prev dw 2 dup (0) public _WHITELINES_DRAWN_AT _WHITELINES_DRAWN_AT db (RES_Y - 1) dup(0)