[Decompilation] [th03/th04/th05] Cutscenes: Line and box feeds

Part of P0224, funded by Splashman and -Tom-.
This commit is contained in:
nmlgc 2022-11-12 18:07:40 +01:00
parent 0d85265931
commit ac3fba3dce
4 changed files with 59 additions and 107 deletions

View File

@ -66,6 +66,10 @@ extern int script_number_param_default;
// in a blocking way.
void pascal near box_wait_animate(int frames_to_wait = 0);
#else
#define box_wait_animate(frames_to_wait) { \
input_wait_for_change(frames_to_wait); \
}
void near box_bg_allocate_and_snap(void);
void near box_bg_free(void);
#endif
@ -278,3 +282,39 @@ void pascal near script_number_param_read_second(int& ret)
ret = script_number_param_default;
}
}
void near cursor_advance_and_animate(void)
{
cursor.x += GLYPH_FULL_W;
if(cursor.x >= BOX_RIGHT) {
cursor.y += GLYPH_H;
cursor.x = (BOX_LEFT + NAME_W);
if(cursor.y >= BOX_BOTTOM) {
#if (GAME >= 4)
box_1_to_0_animate();
#endif
// ZUN quirk: Since [cursor.y] is >= BOX_BOTTOM here, the TH05
// Return key animation will be displayed at the right edge of the
// "5th" line, below BOX_BOTTOM.
if(!fast_forward) {
box_wait_animate(0);
}
// Unconditionally moving the cursor into the name area? This is
// not what a script author would expect, especially with automatic
// line breaks doing the opposite. If you are forced to write your
// script in a way that anticipates such a cursor move, you might
// as well explicitly add the necessary text box change commands
// manually.
cursor.x = BOX_LEFT;
cursor.y = BOX_TOP;
#if (GAME != 5)
graph_accesspage(1); box_bg_put();
graph_accesspage(0); box_bg_put();
#endif
}
}
}

View File

@ -1210,42 +1210,11 @@ sub_9F8D endp
ret:dword
@SCRIPT_NUMBER_PARAM_READ_SECOND$QMI procdesc pascal near \
ret:dword
@cursor_advance_and_animate$qv procdesc pascal near
CUTSCENE_TEXT ends
mainl_01_TEXT segment byte public 'CODE' use16
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_A5FC proc near
push bp
mov bp, sp
add _cursor.x, GLYPH_FULL_W
cmp _cursor.x, BOX_RIGHT
jl short loc_A64B
add _cursor.y, GLYPH_H
mov _cursor.x, (BOX_LEFT + NAME_W)
cmp _cursor.y, BOX_BOTTOM
jl short loc_A64B
cmp _fast_forward, 0
jnz short loc_A62D
call input_wait_for_change pascal, 0
loc_A62D:
mov _cursor.x, BOX_LEFT
mov _cursor.y, BOX_TOP
graph_accesspage 1
call @box_bg_put$qv
graph_accesspage 0
call @box_bg_put$qv
loc_A64B:
pop bp
retn
sub_A5FC endp
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
@ -1608,7 +1577,7 @@ loc_A945:
mov ah, 0
push ax
call graph_gaiji_putc
call sub_A5FC
call @cursor_advance_and_animate$qv
jmp loc_AC1E ; default
; ---------------------------------------------------------------------------
@ -1991,7 +1960,7 @@ loc_ACFB:
push ax
pushd [bp+var_6]
call graph_putsa_fx
call sub_A5FC
call @cursor_advance_and_animate$qv
cmp _fast_forward, 0
jnz loc_ACA3
cmp _input_sp, INPUT_NONE

View File

@ -347,45 +347,14 @@ _main endp
ret:dword
@SCRIPT_NUMBER_PARAM_READ_SECOND$QMI procdesc pascal near \
ret:dword
@box_1_to_0_animate$qv procdesc pascal near
@cursor_advance_and_animate$qv procdesc pascal near
CUTSCENE_TEXT ends
maine_01_TEXT segment byte public 'CODE' use16
maine_01_TEXT ends
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_A73B proc near
push bp
mov bp, sp
add _cursor.x, GLYPH_FULL_W
cmp _cursor.x, BOX_RIGHT
jl short loc_A78D
add _cursor.y, GLYPH_H
mov _cursor.x, (BOX_LEFT + NAME_W)
cmp _cursor.y, BOX_BOTTOM
jl short loc_A78D
call @box_1_to_0_animate$qv
cmp _fast_forward, 0
jnz short loc_A76F
call input_wait_for_change pascal, 0
loc_A76F:
mov _cursor.x, BOX_LEFT
mov _cursor.y, BOX_TOP
graph_accesspage 1
call @box_bg_put$qv
graph_accesspage 0
call @box_bg_put$qv
loc_A78D:
pop bp
retn
sub_A73B endp
maine_01_TEXT ends
maine_01__TEXT segment byte public 'CODE' use16
@box_1_to_0_animate$qv procdesc pascal near
maine_01__TEXT segment byte public 'CODE' use16
; =============== S U B R O U T I N E =======================================
@ -706,7 +675,7 @@ loc_AAF2:
mov ah, 0
push ax
call graph_gaiji_putc
call sub_A73B
call @cursor_advance_and_animate$qv
jmp loc_ADB5 ; default
; ---------------------------------------------------------------------------
@ -1079,7 +1048,7 @@ loc_AE82:
push word ptr [bp+var_6+2]
push bx
call graph_putsa_fx
call sub_A73B
call @cursor_advance_and_animate$qv
jmp loc_AE2D
; ---------------------------------------------------------------------------

View File

@ -27,7 +27,7 @@ include th04/hardware/grppsafx.inc
extern _tolower:proc
extern __ctype:byte
maine_01 group CFG_LRES_TEXT, CUTSCENE_TEXT, maine_01_TEXT, maine_01__TEXT, maine_01___TEXT
maine_01 group CFG_LRES_TEXT, CUTSCENE_TEXT, maine_01_TEXT, maine_01__TEXT, maine_01__TEXT, maine_01___TEXT
g_SHARED group SHARED, SHARED_
; ===========================================================================
@ -309,43 +309,17 @@ _main endp
ret:dword
@SCRIPT_NUMBER_PARAM_READ_SECOND$QMI procdesc pascal near \
ret:dword
CUTSCENE_TEXT ends
maine_01_TEXT segment byte public 'CODE' use16
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_A826 proc near
push bp
mov bp, sp
add _cursor.x, GLYPH_FULL_W
cmp _cursor.x, BOX_RIGHT
jl short loc_A864
add _cursor.y, GLYPH_H
mov _cursor.x, (BOX_LEFT + NAME_W)
cmp _cursor.y, BOX_BOTTOM
jl short loc_A864
call @box_1_to_0_animate$qv
cmp _fast_forward, 0
jnz short loc_A858
call @box_wait_animate$qi pascal, 0
loc_A858:
mov _cursor.x, BOX_LEFT
mov _cursor.y, BOX_TOP
loc_A864:
pop bp
retn
sub_A826 endp
maine_01_TEXT ends
maine_01__TEXT segment byte public 'CODE' use16
@cursor_advance_and_animate$qv procdesc pascal near
@box_1_to_0_animate$qv procdesc pascal near
@BOX_WAIT_ANIMATE$QI procdesc pascal near \
frames_to_wait:word
@cursor_advance_and_animate$qv procdesc pascal near
CUTSCENE_TEXT ends
maine_01_TEXT segment byte public 'CODE' use16
maine_01_TEXT ends
maine_01__TEXT segment byte public 'CODE' use16
; =============== S U B R O U T I N E =======================================
@ -1180,7 +1154,7 @@ loc_B164:
graph_accesspage 0
loc_B18D:
call sub_A826
call @cursor_advance_and_animate$qv
mov si, 1
jmp loc_B005
; ---------------------------------------------------------------------------