[Decompilation] [th04/th05] Main menu: Option menu update/render function

Part of P0262, funded by [Anonymous] and Blue Bolt.
This commit is contained in:
nmlgc 2023-11-27 11:29:20 +01:00
parent ad4cd15bb6
commit c6c07e2c4d
5 changed files with 200 additions and 692 deletions

View File

@ -33,11 +33,13 @@
#define ring_min() 0
#endif
#define ring_inc(val, ring_end) \
#define ring_inc_range(val, ring_min, ring_max) { \
(val)++; \
if((val) > (ring_end)) { \
(val) = 0; \
}
if((val) > (ring_max)) { \
(val) = (ring_min); \
} \
}
#define ring_inc(val, ring_end) ring_inc_range(val, 0, ring_end)
#define ring_inc_ge(val, ring_end) \
(val)++; \
@ -45,6 +47,20 @@
(val) = 0; \
}
#define ring_inc_ge_range(val, ring_min, ring_max) { \
(val)++; \
if((val) >= ((ring_max) + 1)) { \
(val) = (ring_min); \
} \
}
#define ring_dec_range(val, ring_min, ring_max) { \
if(val == (ring_min)) { \
(val) = ((ring_max) + 1); \
} \
(val)--; \
}
#define ring_dec(val, ring_end) \
(val)--; \
if(val < ring_min()) { \

View File

@ -7,6 +7,7 @@
#include <string.h>
#include "x86real.h"
#include "shiftjis.hpp"
#include "th01/math/clamp.hpp"
#include "th01/hardware/egc.h"
#include "th02/v_colors.hpp"
#include "th02/op/menu.hpp"
@ -404,3 +405,163 @@ void near main_update_and_render(void)
#undef initialized
}
inline void snd_redetermine_modes_and_reload_se(void) {
#undef SE_FN
extern const char SE_FN[];
snd_determine_modes(resident->bgm_mode, resident->se_mode);
snd_load(SE_FN, SND_LOAD_SE);
}
inline void snd_redetermine_modes_and_restart_bgm(bool also_reload_se) {
#undef BGM_MENU_MAIN_FN
extern const char BGM_MENU_MAIN_FN[];
snd_kaja_func(KAJA_SONG_STOP, 0);
#if (GAME == 5)
if(also_reload_se) {
snd_redetermine_modes_and_reload_se();
} else {
snd_determine_modes(resident->bgm_mode, resident->se_mode);
}
#else
snd_determine_modes(resident->bgm_mode, resident->se_mode);
#endif
snd_load(BGM_MENU_MAIN_FN, SND_LOAD_SONG);
snd_kaja_func(KAJA_SONG_PLAY, 0);
}
inline void return_from_option_to_main(bool& option_initialized) {
option_initialized = false;
menu_sel = MC_OPTION;
in_option = false;
}
void near option_update_and_render(void)
{
#define initialized option_initialized
extern bool initialized;
static bool input_allowed;
if(!initialized) {
// ZUN landmine: [COMMAND_LEFT] doesn't include the cursor. But then
// again, it doesn't matter as the horizontal area unblitted by
// option_unput_and_put() is larger in this menu anyway.
menu_init(
initialized,
input_allowed,
8,
option_unput_and_put,
COMMAND_LEFT,
MENU_MAIN_W,
main_choice_top(MC_COUNT)
);
}
if(!key_det) {
input_allowed = true;
}
if(!input_allowed) {
return;
}
menu_update_vertical(OC_COUNT);
if((key_det & INPUT_OK) || (key_det & INPUT_SHOT)) {
switch(menu_sel) {
case OC_RESET:
resident->rank = RANK_NORMAL;
resident->cfg_lives = CFG_LIVES_DEFAULT;
resident->cfg_bombs = CFG_BOMBS_DEFAULT;
resident->bgm_mode = SND_BGM_FM86;
resident->se_mode = SND_SE_FM;
resident->turbo_mode = true;
snd_redetermine_modes_and_restart_bgm(true);
initialized = false;
break;
case OC_QUIT:
snd_se_play_force(11);
return_from_option_to_main(initialized);
break;
default:
goto right;
}
}
// ZUN bloat: Could have been deduplicated.
if(key_det & INPUT_RIGHT) {
right:
switch(menu_sel) {
case OC_RANK:
ring_inc_range(resident->rank, RANK_EASY, RANK_LUNATIC);
break;
case OC_LIVES:
ring_inc_range(resident->cfg_lives, 1, CFG_LIVES_MAX);
break;
case OC_BOMBS:
ring_inc_range(resident->cfg_bombs, 0, CFG_BOMBS_MAX);
break;
case OC_BGM:
ring_inc_ge_range(resident->bgm_mode, SND_BGM_OFF, SND_BGM_FM86);
snd_redetermine_modes_and_restart_bgm(false);
break;
case OC_SE:
// ZUN bloat: Come on...
if(resident->se_mode == SND_SE_OFF) {
resident->se_mode = SND_SE_BEEP;
} else {
resident->se_mode--;
}
// ZUN bug: TH04 does not immediately apply SE mode changes.
// (Same below for INPUT_LEFT.)
#if (GAME == 5)
snd_redetermine_modes_and_reload_se();
#endif
break;
case OC_TURBO_OR_SLOW:
resident->turbo_mode = (1 - resident->turbo_mode);
break;
}
option_unput_and_put(menu_sel, COL_ACTIVE);
}
if(key_det & INPUT_LEFT) {
switch(menu_sel) {
case OC_RANK:
ring_dec_range(resident->rank, RANK_EASY, RANK_LUNATIC);
break;
case OC_LIVES:
ring_dec_range(resident->cfg_lives, 1, CFG_LIVES_MAX);
break;
case OC_BOMBS:
ring_dec_range(resident->cfg_bombs, 0, CFG_BOMBS_MAX);
break;
case OC_BGM:
// ZUN bloat: Come on...
if(resident->bgm_mode == SND_BGM_OFF) {
resident->bgm_mode = SND_BGM_FM86;
} else {
resident->bgm_mode--;
}
snd_redetermine_modes_and_restart_bgm(false);
break;
case OC_SE:
ring_inc_ge_range(resident->se_mode, SND_SE_OFF, SND_SE_BEEP);
#if (GAME == 5)
snd_redetermine_modes_and_reload_se();
#endif
break;
case OC_TURBO_OR_SLOW:
resident->turbo_mode = (1 - resident->turbo_mode);
break;
}
option_unput_and_put(menu_sel, COL_ACTIVE);
}
if(key_det & INPUT_CANCEL) {
return_from_option_to_main(initialized);
}
if(key_det) {
input_allowed = false;
}
#undef initialized
}

View File

@ -1,3 +1,7 @@
// File names shared between TH04 and TH05
#define BGM_MENU_MAIN_FN "op"
#define SE_FN "miko"
#define MENU_MAIN_BG_FN "op1.pi"

View File

@ -158,11 +158,8 @@ OP_MAIN_TEXT segment byte public 'CODE' use16
@cfg_save$qv procdesc near
@cfg_save_exit$qv procdesc near
_start_demo procdesc near
@OPTION_UNPUT_AND_PUT$QIUI procdesc pascal near \
sel:word, col:word
@MENU_SEL_UPDATE_AND_RENDER$QCC procdesc pascal near \
max:byte, direction:byte
@main_update_and_render$qv procdesc near
@option_update_and_render$qv procdesc near
OP_MAIN_TEXT ends
; Segment type: Pure code
@ -173,325 +170,6 @@ op_01_TEXT segment byte public 'CODE' use16
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
public OPTION_UPDATE_AND_RENDER
option_update_and_render proc near
push bp
mov bp, sp
push si
cmp _option_initialized, 0
jnz short loc_B0A2
mov _option_input_allowed, 0
call @egc_copy_rect_1_to_0_16$qiiii pascal, (272 shl 16) or 224, (160 shl 16) or 144
xor si, si
jmp short loc_B08D
; ---------------------------------------------------------------------------
loc_B077:
push si
mov al, _menu_sel
cbw
cmp ax, si
jnz short loc_B085
mov ax, 8
jmp short loc_B088
; ---------------------------------------------------------------------------
loc_B085:
mov ax, 1
loc_B088:
push ax
call @option_unput_and_put$qiui
inc si
loc_B08D:
cmp si, 8
jl short loc_B077
mov _menu_unput_and_put, offset @option_unput_and_put$qiui
mov _option_initialized, 1
mov _option_input_allowed, 0
loc_B0A2:
cmp _key_det, INPUT_NONE
jnz short loc_B0AE
mov _option_input_allowed, 1
loc_B0AE:
cmp _option_input_allowed, 0
jz loc_B35B
test _key_det.lo, low INPUT_UP
jz short loc_B0C5
call @menu_sel_update_and_render$qcc pascal, 7, -1
loc_B0C5:
test _key_det.lo, low INPUT_DOWN
jz short loc_B0D3
call @menu_sel_update_and_render$qcc pascal, 7, 1
loc_B0D3:
test _key_det.hi, high INPUT_OK
jnz short loc_B0E3
test _key_det.lo, low INPUT_SHOT
jz loc_B16F
loc_B0E3:
mov al, _menu_sel
cbw
cmp ax, 6
jz short loc_B0F4
cmp ax, 7
jz short loc_B14F
jmp loc_B178
; ---------------------------------------------------------------------------
loc_B0F4:
les bx, _resident
mov es:[bx+resident_t.rank], RANK_NORMAL
mov es:[bx+resident_t.cfg_lives], CFG_LIVES_DEFAULT
mov es:[bx+resident_t.cfg_bombs], CFG_BOMBS_DEFAULT
mov es:[bx+resident_t.bgm_mode], SND_BGM_FM86
mov es:[bx+resident_t.se_mode], SND_SE_FM
mov es:[bx+resident_t.turbo_mode], 1
kajacall KAJA_SONG_STOP
les bx, _resident
mov al, es:[bx+resident_t.bgm_mode]
mov ah, 0
push ax
mov al, es:[bx+resident_t.se_mode]
mov ah, 0
push ax
call snd_determine_modes
call snd_load pascal, ds, offset aOp, SND_LOAD_SONG
kajacall KAJA_SONG_PLAY
mov _option_initialized, 0
jmp short loc_B16F
; ---------------------------------------------------------------------------
loc_B14F:
call _snd_se_reset
call snd_se_play pascal, 11
call _snd_se_update
mov _option_initialized, 0
mov _menu_sel, 4
mov _in_option, 0
loc_B16F:
test _key_det.lo, low INPUT_RIGHT
jz loc_B250
loc_B178:
mov al, _menu_sel
cbw
mov bx, ax
cmp bx, 5
ja loc_B246
add bx, bx
jmp cs:off_B36B[bx]
loc_B18C:
les bx, _resident
inc es:[bx+resident_t.rank]
cmp es:[bx+resident_t.rank], RANK_LUNATIC
jbe loc_B246
mov es:[bx+resident_t.rank], RANK_EASY
jmp loc_B246
; ---------------------------------------------------------------------------
loc_B1A5:
les bx, _resident
inc es:[bx+resident_t.cfg_lives]
cmp es:[bx+resident_t.cfg_lives], CFG_LIVES_MAX
jbe loc_B246
mov es:[bx+resident_t.cfg_lives], 1
jmp loc_B246
; ---------------------------------------------------------------------------
loc_B1BE:
les bx, _resident
inc es:[bx+resident_t.cfg_bombs]
cmp es:[bx+resident_t.cfg_bombs], CFG_BOMBS_MAX
jbe short loc_B246
mov es:[bx+resident_t.cfg_bombs], 0
jmp short loc_B246
; ---------------------------------------------------------------------------
loc_B1D4:
les bx, _resident
inc es:[bx+resident_t.bgm_mode]
cmp es:[bx+resident_t.bgm_mode], SND_BGM_MODE_COUNT
jb short loc_B1E8
mov es:[bx+resident_t.bgm_mode], SND_BGM_OFF
loc_B1E8:
kajacall KAJA_SONG_STOP
les bx, _resident
mov al, es:[bx+resident_t.bgm_mode]
mov ah, 0
push ax
mov al, es:[bx+resident_t.se_mode]
mov ah, 0
push ax
call snd_determine_modes
call snd_load pascal, ds, offset aOp, SND_LOAD_SONG
kajacall KAJA_SONG_PLAY
jmp short loc_B246
; ---------------------------------------------------------------------------
loc_B21C:
les bx, _resident
cmp es:[bx+resident_t.se_mode], SND_SE_OFF
jnz short loc_B22E
mov es:[bx+resident_t.se_mode], SND_SE_BEEP
jmp short loc_B246
; ---------------------------------------------------------------------------
loc_B22E:
les bx, _resident
dec es:[bx+resident_t.se_mode]
jmp short loc_B246
; ---------------------------------------------------------------------------
loc_B238:
les bx, _resident
mov al, 1
sub al, es:[bx+resident_t.turbo_mode]
mov es:[bx+resident_t.turbo_mode], al
loc_B246:
mov al, _menu_sel
cbw
call @option_unput_and_put$qiui pascal, ax, 8
loc_B250:
test _key_det.lo, low INPUT_LEFT
jz loc_B339
mov al, _menu_sel
cbw
mov bx, ax
cmp bx, 5
ja loc_B32F
add bx, bx
jmp cs:off_B35F[bx]
loc_B26D:
les bx, _resident
cmp es:[bx+resident_t.rank], RANK_EASY
jnz short loc_B27D
mov es:[bx+resident_t.rank], RANK_EXTRA
loc_B27D:
les bx, _resident
dec es:[bx+resident_t.rank]
jmp loc_B32F
; ---------------------------------------------------------------------------
loc_B288:
les bx, _resident
cmp es:[bx+resident_t.cfg_lives], 1
jnz short loc_B298
mov es:[bx+resident_t.cfg_lives], (CFG_LIVES_MAX + 1)
loc_B298:
les bx, _resident
dec es:[bx+resident_t.cfg_lives]
jmp loc_B32F
; ---------------------------------------------------------------------------
loc_B2A3:
les bx, _resident
cmp es:[bx+resident_t.cfg_bombs], 0
jnz short loc_B2B3
mov es:[bx+resident_t.cfg_bombs], (CFG_BOMBS_MAX + 1)
loc_B2B3:
les bx, _resident
dec es:[bx+resident_t.cfg_bombs]
jmp short loc_B32F
; ---------------------------------------------------------------------------
loc_B2BD:
les bx, _resident
cmp es:[bx+resident_t.bgm_mode], SND_BGM_OFF
jnz short loc_B2CF
mov es:[bx+resident_t.bgm_mode], SND_BGM_FM86
jmp short loc_B2D7
; ---------------------------------------------------------------------------
loc_B2CF:
les bx, _resident
dec es:[bx+resident_t.bgm_mode]
loc_B2D7:
kajacall KAJA_SONG_STOP
les bx, _resident
mov al, es:[bx+resident_t.bgm_mode]
mov ah, 0
push ax
mov al, es:[bx+resident_t.se_mode]
mov ah, 0
push ax
call snd_determine_modes
call snd_load pascal, ds, offset aOp, SND_LOAD_SONG
kajacall KAJA_SONG_PLAY
jmp short loc_B32F
; ---------------------------------------------------------------------------
loc_B30B:
les bx, _resident
inc es:[bx+resident_t.se_mode]
cmp es:[bx+resident_t.se_mode], SND_SE_MODE_COUNT
jb short loc_B32F
mov es:[bx+resident_t.se_mode], SND_SE_OFF
jmp short loc_B32F
; ---------------------------------------------------------------------------
loc_B321:
les bx, _resident
mov al, 1
sub al, es:[bx+resident_t.turbo_mode]
mov es:[bx+resident_t.turbo_mode], al
loc_B32F:
mov al, _menu_sel
cbw
call @option_unput_and_put$qiui pascal, ax, 8
loc_B339:
test _key_det.hi, high INPUT_CANCEL
jz short loc_B34F
mov _option_initialized, 0
mov _menu_sel, 4
mov _in_option, 0
loc_B34F:
cmp _key_det, INPUT_NONE
jz short loc_B35B
mov _option_input_allowed, 0
loc_B35B:
pop si
pop bp
retn
option_update_and_render endp
; ---------------------------------------------------------------------------
db 0
off_B35F dw offset loc_B26D
dw offset loc_B288
dw offset loc_B2A3
dw offset loc_B2BD
dw offset loc_B30B
dw offset loc_B321
off_B36B dw offset loc_B18C
dw offset loc_B1A5
dw offset loc_B1BE
dw offset loc_B1D4
dw offset loc_B21C
dw offset loc_B238
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
; int __cdecl main(int argc, const char **argv, const char **envp)
@ -539,7 +217,7 @@ loc_B3D3:
mov ah, 0
push ax
call snd_determine_modes
call snd_load pascal, ds, offset aMiko, SND_LOAD_SE
call snd_load pascal, ds, offset _SE_FN, SND_LOAD_SE
les bx, _resident
cmp es:[bx+resident_t.zunsoft_shown], 0
jnz short loc_B40D
@ -583,7 +261,7 @@ loc_B44E:
; ---------------------------------------------------------------------------
loc_B45C:
call option_update_and_render
call @option_update_and_render$qv
loc_B45F:
cmp _key_det, INPUT_NONE
@ -1943,7 +1621,6 @@ include th04/hardware/grppsafx.asm
extern @game_init_op$qnxuc:proc
extern _input_reset_sense:proc
extern _input_sense:proc
extern _snd_se_reset:proc
extern SND_SE_PLAY:proc
extern _snd_se_update:proc
extern @EGC_COPY_RECT_1_TO_0_16$QIIII:proc
@ -1991,7 +1668,7 @@ _MENU_DESC label dword
dd aGqbGav_2 ; "ゲームを開始します(ハード)"
dd aGqbGav_3 ; "ゲームを開始します(ルナティック)"
public _main_menu_initialized
public _main_menu_initialized, _option_initialized
_main_menu_initialized db 0
_option_initialized db 0
@ -2025,14 +1702,15 @@ aGqbGav_0 db '
aGqbGav_1 db 'ゲームを開始します(ノーマル)',0
aGqbGav_2 db 'ゲームを開始します(ハード)',0
aGqbGav_3 db 'ゲームを開始します(ルナティック)',0
public _MENU_MAIN_BG_FN
public _MENU_MAIN_BG_FN, _BGM_MENU_MAIN_FN
_MENU_MAIN_BG_FN db 'op1.pi',0
aOp db 'op',0
_BGM_MENU_MAIN_FN db 'op',0
aMSzlEd_dat db '幻想郷ed.dat',0
asc_F7F7 db 0Ah
db '空きメモリ不足です。メモリ空きを増やしてから実行してね',0Ah,0
aGameft_bft db 'GAMEFT.bft',0
aMiko db 'miko',0
public _SE_FN
_SE_FN db 'miko',0
include libs/master.lib/atrtcmod[data].asm
include libs/master.lib/bfnt_id[data].asm
include libs/master.lib/clip[data].asm
@ -2196,9 +1874,6 @@ aOp1_pi_1 db 'op1.pi',0
extern _resident:dword
extern _in_option:byte
extern _menu_unput_and_put:word
_option_input_allowed = byte ptr $-1 ; place in padding area of previous segment
include libs/master.lib/clip[bss].asm
include libs/master.lib/fil[bss].asm

View File

@ -148,11 +148,8 @@ _TEXT ends
OP_MAIN_TEXT segment byte public 'CODE' use16
_start_demo procdesc near
@OPTION_UNPUT_AND_PUT$QIUI procdesc pascal near \
sel:word, col:word
@MENU_SEL_UPDATE_AND_RENDER$QCC procdesc pascal near \
max:byte, direction:byte
@main_update_and_render$qv procdesc near
@option_update_and_render$qv procdesc near
OP_MAIN_TEXT ends
; Segment type: Pure code
@ -162,347 +159,6 @@ CFG_TEXT segment byte public 'CODE' use16
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
public OPTION_UPDATE_AND_RENDER
option_update_and_render proc near
push bp
mov bp, sp
push si
cmp _option_initialized, 0
jnz short loc_AC1F
mov _option_input_allowed, 0
call @egc_copy_rect_1_to_0_16$qiiii pascal, (272 shl 16) or 250, (160 shl 16) or 144
xor si, si
jmp short loc_AC0A
; ---------------------------------------------------------------------------
loc_ABF4:
push si
mov al, _menu_sel
cbw
cmp ax, si
jnz short loc_AC02
mov ax, 0Eh
jmp short loc_AC05
; ---------------------------------------------------------------------------
loc_AC02:
mov ax, 8
loc_AC05:
push ax
call @option_unput_and_put$qiui
inc si
loc_AC0A:
cmp si, 8
jl short loc_ABF4
mov _menu_unput_and_put, offset @option_unput_and_put$qiui
mov _option_initialized, 1
mov _option_input_allowed, 0
loc_AC1F:
cmp _key_det, INPUT_NONE
jnz short loc_AC2B
mov _option_input_allowed, 1
loc_AC2B:
cmp _option_input_allowed, 0
jz loc_AF2E
test _key_det.lo, low INPUT_UP
jz short loc_AC42
call @menu_sel_update_and_render$qcc pascal, 7, -1
loc_AC42:
test _key_det.lo, low INPUT_DOWN
jz short loc_AC50
call @menu_sel_update_and_render$qcc pascal, 7, 1
loc_AC50:
test _key_det.hi, high INPUT_OK
jnz short loc_AC60
test _key_det.lo, low INPUT_SHOT
jz loc_ACF8
loc_AC60:
mov al, _menu_sel
cbw
cmp ax, 6
jz short loc_AC71
cmp ax, 7
jz short loc_ACD8
jmp loc_AD01
; ---------------------------------------------------------------------------
loc_AC71:
les bx, _resident
mov es:[bx+resident_t.rank], RANK_NORMAL
mov es:[bx+resident_t.cfg_lives], CFG_LIVES_DEFAULT
mov es:[bx+resident_t.cfg_bombs], CFG_LIVES_DEFAULT
mov es:[bx+resident_t.bgm_mode], SND_BGM_FM86
mov es:[bx+resident_t.se_mode], SND_SE_FM
mov es:[bx+resident_t.turbo_mode], 1
kajacall KAJA_SONG_STOP
les bx, _resident
mov al, es:[bx+resident_t.bgm_mode]
mov ah, 0
push ax
mov al, es:[bx+resident_t.se_mode]
mov ah, 0
push ax
call snd_determine_modes
call snd_load pascal, ds, offset aMiko, SND_LOAD_SE
call snd_load pascal, ds, offset aOp, SND_LOAD_SONG
kajacall KAJA_SONG_PLAY
mov _option_initialized, 0
jmp short loc_ACF8
; ---------------------------------------------------------------------------
loc_ACD8:
call _snd_se_reset
call snd_se_play pascal, 11
call _snd_se_update
mov _option_initialized, 0
mov _menu_sel, 4
mov _in_option, 0
loc_ACF8:
test _key_det.lo, low INPUT_RIGHT
jz loc_ADFF
loc_AD01:
mov al, _menu_sel
cbw
mov bx, ax
cmp bx, 5
ja loc_ADF5
add bx, bx
jmp cs:off_AF3D[bx]
loc_AD15:
les bx, _resident
inc es:[bx+resident_t.rank]
cmp es:[bx+resident_t.rank], RANK_LUNATIC
jbe loc_ADF5
mov es:[bx+resident_t.rank], RANK_EASY
jmp loc_ADF5
; ---------------------------------------------------------------------------
loc_AD2E:
les bx, _resident
inc es:[bx+resident_t.cfg_lives]
cmp es:[bx+resident_t.cfg_lives], CFG_LIVES_MAX
jbe loc_ADF5
mov es:[bx+resident_t.cfg_lives], 1
jmp loc_ADF5
; ---------------------------------------------------------------------------
loc_AD47:
les bx, _resident
inc es:[bx+resident_t.cfg_bombs]
cmp es:[bx+resident_t.cfg_bombs], CFG_BOMBS_MAX
jbe loc_ADF5
mov es:[bx+resident_t.cfg_bombs], 0
jmp loc_ADF5
; ---------------------------------------------------------------------------
loc_AD60:
les bx, _resident
inc es:[bx+resident_t.bgm_mode]
cmp es:[bx+resident_t.bgm_mode], SND_BGM_MODE_COUNT
jb short loc_AD74
mov es:[bx+resident_t.bgm_mode], SND_BGM_OFF
loc_AD74:
kajacall KAJA_SONG_STOP
les bx, _resident
mov al, es:[bx+resident_t.bgm_mode]
mov ah, 0
push ax
mov al, es:[bx+resident_t.se_mode]
mov ah, 0
push ax
call snd_determine_modes
call snd_load pascal, ds, offset aOp, SND_LOAD_SONG
kajacall KAJA_SONG_PLAY
jmp short loc_ADF5
; ---------------------------------------------------------------------------
loc_ADA8:
les bx, _resident
cmp es:[bx+resident_t.se_mode], SND_SE_OFF
jnz short loc_ADBA
mov es:[bx+resident_t.se_mode], SND_SE_BEEP
jmp short loc_ADC2
; ---------------------------------------------------------------------------
loc_ADBA:
les bx, _resident
dec es:[bx+resident_t.se_mode]
loc_ADC2:
les bx, _resident
mov al, es:[bx+resident_t.bgm_mode]
mov ah, 0
push ax
mov al, es:[bx+resident_t.se_mode]
mov ah, 0
push ax
call snd_determine_modes
call snd_load pascal, ds, offset aMiko, SND_LOAD_SE
jmp short loc_ADF5
; ---------------------------------------------------------------------------
loc_ADE7:
les bx, _resident
mov al, 1
sub al, es:[bx+resident_t.turbo_mode]
mov es:[bx+resident_t.turbo_mode], al
loc_ADF5:
mov al, _menu_sel
cbw
call @option_unput_and_put$qiui pascal, ax, 14
loc_ADFF:
test _key_det.lo, low INPUT_LEFT
jz loc_AF0C
mov al, _menu_sel
cbw
mov bx, ax
cmp bx, 5
ja loc_AF02
add bx, bx
jmp cs:off_AF31[bx]
loc_AE1C:
les bx, _resident
cmp es:[bx+resident_t.rank], RANK_EASY
jnz short loc_AE2C
mov es:[bx+resident_t.rank], RANK_EXTRA
loc_AE2C:
les bx, _resident
dec es:[bx+resident_t.rank]
jmp loc_AF02
; ---------------------------------------------------------------------------
loc_AE37:
les bx, _resident
cmp es:[bx+resident_t.cfg_lives], 1
jnz short loc_AE47
mov es:[bx+resident_t.cfg_lives], (CFG_LIVES_MAX + 1)
loc_AE47:
les bx, _resident
dec es:[bx+resident_t.cfg_lives]
jmp loc_AF02
; ---------------------------------------------------------------------------
loc_AE52:
les bx, _resident
cmp es:[bx+resident_t.cfg_bombs], 0
jnz short loc_AE62
mov es:[bx+resident_t.cfg_bombs], (CFG_BOMBS_MAX + 1)
loc_AE62:
les bx, _resident
dec es:[bx+resident_t.cfg_bombs]
jmp loc_AF02
; ---------------------------------------------------------------------------
loc_AE6D:
les bx, _resident
cmp es:[bx+resident_t.bgm_mode], SND_BGM_OFF
jnz short loc_AE7F
mov es:[bx+resident_t.bgm_mode], SND_BGM_FM86
jmp short loc_AE87
; ---------------------------------------------------------------------------
loc_AE7F:
les bx, _resident
dec es:[bx+resident_t.bgm_mode]
loc_AE87:
kajacall KAJA_SONG_STOP
les bx, _resident
mov al, es:[bx+resident_t.bgm_mode]
mov ah, 0
push ax
mov al, es:[bx+resident_t.se_mode]
mov ah, 0
push ax
call snd_determine_modes
call snd_load pascal, ds, offset aOp, SND_LOAD_SONG
kajacall KAJA_SONG_PLAY
jmp short loc_AF02
; ---------------------------------------------------------------------------
loc_AEBB:
les bx, _resident
inc es:[bx+resident_t.se_mode]
cmp es:[bx+resident_t.se_mode], SND_SE_MODE_COUNT
jb short loc_AECF
mov es:[bx+resident_t.se_mode], SND_SE_OFF
loc_AECF:
les bx, _resident
mov al, es:[bx+resident_t.bgm_mode]
mov ah, 0
push ax
mov al, es:[bx+resident_t.se_mode]
mov ah, 0
push ax
call snd_determine_modes
call snd_load pascal, ds, offset aMiko, SND_LOAD_SE
jmp short loc_AF02
; ---------------------------------------------------------------------------
loc_AEF4:
les bx, _resident
mov al, 1
sub al, es:[bx+resident_t.turbo_mode]
mov es:[bx+resident_t.turbo_mode], al
loc_AF02:
mov al, _menu_sel
cbw
call @option_unput_and_put$qiui pascal, ax, 14
loc_AF0C:
test _key_det.hi, high INPUT_CANCEL
jz short loc_AF22
mov _option_initialized, 0
mov _menu_sel, 4
mov _in_option, 0
loc_AF22:
cmp _key_det, INPUT_NONE
jz short loc_AF2E
mov _option_input_allowed, 0
loc_AF2E:
pop si
pop bp
retn
option_update_and_render endp
; ---------------------------------------------------------------------------
off_AF31 dw offset loc_AE1C
dw offset loc_AE37
dw offset loc_AE52
dw offset loc_AE6D
dw offset loc_AEBB
dw offset loc_AEF4
off_AF3D dw offset loc_AD15
dw offset loc_AD2E
dw offset loc_AD47
dw offset loc_AD60
dw offset loc_ADA8
dw offset loc_ADE7
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
; int __cdecl main(int argc, const char **argv, const char **envp)
@ -546,7 +202,7 @@ loc_AF97:
mov ah, 0
push ax
call snd_determine_modes
call snd_load pascal, ds, offset aMiko, SND_LOAD_SE
call snd_load pascal, ds, offset _SE_FN, SND_LOAD_SE
les bx, _resident
cmp es:[bx+resident_t.zunsoft_shown], 0
jnz short loc_AFD1
@ -597,7 +253,7 @@ loc_B022:
; ---------------------------------------------------------------------------
loc_B032:
call option_update_and_render
call @option_update_and_render$qv
loc_B035:
cmp _key_det, INPUT_NONE
@ -1984,7 +1640,6 @@ SHARED_ segment word public 'CODE' use16
assume es:nothing, ss:nothing, ds:_DATA, fs:nothing, gs:nothing
include th04/hardware/grppsafx.asm
extern _snd_se_reset:proc
extern SND_SE_PLAY:proc
extern _snd_se_update:proc
extern _bgimage_snap:proc
@ -2046,7 +1701,7 @@ _MENU_DESC dd aMENU_START ; "
dd aMENU_START_HARD ; "ゲームを開始します(ハード)"
dd aMENU_START_LUNATIC ; "ゲームを開始します(ルナティック)"
public _main_menu_initialized
public _main_menu_initialized, _option_initialized
_main_menu_initialized db 0
_option_initialized db 0
@ -2079,10 +1734,10 @@ aMENU_START_EASY db '
aMENU_START_NORMAL db 'ゲームを開始します(ノーマル)',0
aMENU_START_HARD db 'ゲームを開始します(ハード)',0
aMENU_START_LUNATIC db 'ゲームを開始します(ルナティック)',0
public _MENU_MAIN_BG_FN
public _MENU_MAIN_BG_FN, _SE_FN, _BGM_MENU_MAIN_FN
_MENU_MAIN_BG_FN db 'op1.pi',0
aMiko db 'miko',0
aOp db 'op',0
_SE_FN db 'miko',0
_BGM_MENU_MAIN_FN db 'op',0
aKaikidan1_dat0 db '怪綺談1.dat',0
aNotEnoughMem db 0Ah
db '空きメモリ不足です。メモリ空きを増やしてから実行してね',0Ah,0
@ -2686,9 +2341,6 @@ aOp_1 db 'op',0
extern _resident:dword
extern _in_option:byte
extern _menu_unput_and_put:word
_option_input_allowed = byte ptr $-1 ; place in padding area of previous segment
include libs/master.lib/clip[bss].asm
include libs/master.lib/fil[bss].asm