[Decompilation] [th05] Cutscenes: Return key wait animation

Needlessly blitting glyphs to VRAM until the very end, eh?

Part of P0223, funded by Blue Bolt and rosenrose.
This commit is contained in:
nmlgc 2022-11-09 14:48:32 +01:00
parent 815bcc8308
commit 576f49129a
7 changed files with 80 additions and 97 deletions

View File

@ -155,7 +155,7 @@ $**
|
bin\th05\maine.exe: bin\th05\maine.obj bin\th04\cfg_lres.obj th05\maine011.cpp th05\regist.cpp th05\staff.cpp bin\th04\cdg_p_na.obj bin\th04\snd_se_r.obj bin\th04\snd_se.obj bin\th04\bgimage.obj bin\th04\exit.obj bin\th05\vector.obj bin\th05\bgimager.obj bin\th05\snd_load.obj bin\th05\snd_kaja.obj bin\th05\pi_cpp_1.obj bin\th05\pi_asm_1.obj bin\th05\pi_cpp_2.obj bin\th05\pi_asm_2.obj bin\th05\initmain.obj bin\th05\input_s.obj bin\th05\inp_h_w.obj bin\th05\snd_dlym.obj bin\th05\frmdelay.obj bin\th04\cdg_load.obj bin\th05\egcrect.obj bin\th03\hfliplut.obj bin\th04\snd_pmdr.obj bin\th04\snd_mmdr.obj bin\th04\snd_mode.obj
$(CC) $(CFLAGS) $(LARGE_LFLAGS) -DGAME=5 -DBINARY='E' -Z -nbin\th05\ -eMAINE.EXE @&&|
$(CC) $(CFLAGS) $(LARGE_LFLAGS) -DGAME=5 -DBINARY='E' -3 -Z -nbin\th05\ -eMAINE.EXE @&&|
$**
|

View File

@ -34,6 +34,12 @@ extern int script_number_param_default;
// Function ordering fails
// -----------------------
#if (GAME == 5)
// Waits the given amount of frames (0 = forever) for the OK, Shot, or
// Cancel button to be pressed, while showing the ⏎ Return key animation
// in a blocking way.
void pascal near box_wait_animate(int frames_to_wait = 0);
#endif
#if (GAME >= 4)
// Crossfades the text box area from VRAM page 1 to VRAM page 0, spending
// [text_interval] frames on each step.

View File

@ -7,6 +7,11 @@
#include "master.hpp"
extern "C" {
#include "th02/hardware/frmdelay.h"
#if (GAME == 5)
#include "th02/v_colors.hpp"
#include "th04/hardware/bgimage.hpp"
#include "th04/gaiji/gaiji.h"
#endif
}
#include "th03/cutscene/cutscene.hpp"
@ -67,6 +72,60 @@ void near box_1_to_0_animate(void)
egc_off();
#if (GAME == 5)
frame_delay(1);
frame_delay(1); // ZUN quirk
#endif
}
#if (GAME == 5)
void pascal near box_wait_animate(int frames_to_wait)
{
enum {
LEFT = (BOX_RIGHT + GLYPH_FULL_W),
};
unsigned int frames_waited = 0;
bool16 ignore_frames = false;
while(1) {
cutscene_input_sense();
if(key_det == INPUT_NONE) {
break;
}
frame_delay(1);
}
if(frames_to_wait == 0) {
frames_to_wait = 999;
ignore_frames = true;
}
graph_accesspage(0);
while(1) {
cutscene_input_sense();
// ZUN bloat: A white glyph aligned to the 8×16 cell grid, without
// applying boldface… why not just show it on TRAM?
bgimage_put_rect(LEFT, cursor.y, GLYPH_FULL_W, GLYPH_H);
if(
(frames_to_wait <= 0) ||
(key_det & INPUT_OK) ||
(key_det & INPUT_SHOT) ||
(key_det & INPUT_CANCEL)
) {
return;
}
graph_gaiji_putc(
LEFT,
cursor.y,
(ga_RETURN_KEY + ((frames_waited / 8) & (RETURN_KEY_CELS - 1))),
V_WHITE
);
frames_waited++;
if(!ignore_frames) {
frames_to_wait--;
}
frame_delay(1);
}
}
#endif

View File

@ -6,10 +6,17 @@
#include "th04/gaiji/bar.h"
#define OVERLAY_FADE_CELS 8
#define RETURN_KEY_CELS 4
typedef enum {
g_NULL = '\0',
g_EMPTY = 0x02,
#if (GAME == 5)
ga_RETURN_KEY = 0x1C,
ga_RETURN_KEY_last = (ga_RETURN_KEY + RETURN_KEY_CELS - 1),
#endif
gaiji_bar(0x20),
gaiji_bar_max(0x30),
g_OVERLAY_FADE,

View File

@ -1,15 +0,0 @@
; ReC98
; -----
; Gaiji available to TH05
include th04/gaiji/gaiji.inc
; Animations
; ----------
ga_RETURN_KEY = 01Ch
ga_RETURN_KEY_0 = ga_RETURN_KEY + 0
ga_RETURN_KEY_1 = ga_RETURN_KEY + 1
ga_RETURN_KEY_2 = ga_RETURN_KEY + 2
ga_RETURN_KEY_3 = ga_RETURN_KEY + 3
ga_RETURN_KEY_CELS = 4
; ----------

View File

@ -2,7 +2,7 @@ GAME = 5
include th05/chars.inc
include th05/mem.inc
include th04/shared.inc
include th05/gaiji/gaiji.inc
include th04/gaiji/gaiji.inc
include th02/v_colors.inc
resident_t struc

View File

@ -510,8 +510,7 @@ sub_A826 proc near
call @box_1_to_0_animate$qv
cmp _fast_forward, 0
jnz short loc_A858
push 0
call sub_A92B
call @box_wait_animate$qi pascal, 0
loc_A858:
mov _cursor.x, BOX_LEFT
@ -525,79 +524,8 @@ maine_01_TEXT ends
maine_01__TEXT segment byte public 'CODE' use16
@box_1_to_0_animate$qv procdesc pascal near
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_A92B proc near
var_2 = word ptr -2
arg_0 = word ptr 4
enter 2, 0
push si
push di
mov si, [bp+arg_0]
xor di, di
mov [bp+var_2], 0
loc_A93B:
call _input_reset_sense_held
cmp _key_det, INPUT_NONE
jz short loc_A950
push 1
call frame_delay
jmp short loc_A93B
; ---------------------------------------------------------------------------
loc_A950:
or si, si
jnz short loc_A95C
mov si, 999
mov [bp+var_2], 1
loc_A95C:
graph_accesspage 0
loc_A962:
call _input_reset_sense_held
call bgimage_put_rect pascal, 576, _cursor.y, (GLYPH_FULL_W shl 16) or GLYPH_H
or si, si
jle short loc_A9BD
test _key_det.hi, high INPUT_OK
jnz short loc_A9BD
test _key_det.lo, low INPUT_SHOT
jnz short loc_A9BD
test _key_det.hi, high INPUT_CANCEL
jnz short loc_A9BD
push 576
push _cursor.y
mov ax, di
shr ax, 3
and ax, ga_RETURN_KEY_CELS - 1
add ax, ga_RETURN_KEY
push ax
push V_WHITE
call graph_gaiji_putc
inc di
cmp [bp+var_2], 0
jnz short loc_A9B4
dec si
loc_A9B4:
push 1
call frame_delay
jmp short loc_A962
; ---------------------------------------------------------------------------
loc_A9BD:
pop di
pop si
leave
retn 2
sub_A92B endp
@BOX_WAIT_ANIMATE$QI procdesc pascal near \
frames_to_wait:word
; =============== S U B R O U T I N E =======================================
@ -656,8 +584,7 @@ loc_AA0B:
call sub_A738
cmp _fast_forward, 0
jnz short loc_AA3E
push [bp+var_2]
call sub_A92B
call @box_wait_animate$qi pascal, [bp+var_2]
jmp short loc_AA3E
; ---------------------------------------------------------------------------
@ -921,8 +848,7 @@ loc_AC87:
call sub_A738
cmp _fast_forward, 0
jnz loc_AF8F ; default
push [bp+var_2]
call sub_A92B
call @box_wait_animate$qi pascal, [bp+var_2]
jmp loc_AF8F ; default
; ---------------------------------------------------------------------------