Add custom text animation code
This commit is contained in:
parent
e60d0bb5b2
commit
75e4876478
|
@ -18,7 +18,8 @@ $input_c_files =
|
|||
"src/c/fileselect.c",
|
||||
"src/c/status.c",
|
||||
"src/c/battle.c",
|
||||
"src/c/psi.c"
|
||||
"src/c/psi.c",
|
||||
"src/c/title.c"
|
||||
|
||||
$base_c_address = 0x83755B8;
|
||||
$scripttool_cmd = "bin/ScriptTool/ScriptTool.dll"
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
#include "title.h"
|
||||
|
||||
void title_text_sequence(
|
||||
TITLE_CONTROL *control,
|
||||
TITLE_EXTENDED *ext,
|
||||
TITLE_COORD_TABLE *coords)
|
||||
{
|
||||
int duration = 140; // approximate length of EB's animation,
|
||||
// from the first frame that H is visible
|
||||
// until all letters have stopped moving
|
||||
int frame = control->frame;
|
||||
|
||||
if (frame > duration)
|
||||
{
|
||||
control->frame = -1;
|
||||
ext->sequence++;
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
int x_start = coords->x_start[i];
|
||||
int x_end = coords->x_end[i];
|
||||
int x_delta = x_end - x_start;
|
||||
int x_new = (m2_div((x_delta * frame) << 12, duration) >> 12) + x_start;
|
||||
|
||||
// X coordinate is only 9 bits signed, so clamp the values to a reasonable range
|
||||
if (x_new < -250)
|
||||
x_new = -250;
|
||||
if (x_new > 250)
|
||||
x_new = 250;
|
||||
|
||||
ext->sprites[i].x = x_new;
|
||||
ext->sprites[i].y = coords->y_end[i]; // we're not translating the sprites vertically
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
#ifndef HEADER_TITLE_INCLUDED
|
||||
#define HEADER_TITLE_INCLUDED
|
||||
|
||||
#include "types.h"
|
||||
|
||||
typedef struct TITLE_COORD_TABLE {
|
||||
int unknown_a[3];
|
||||
int y_end[8];
|
||||
int y_start[8];
|
||||
int x_end[8];
|
||||
int x_start[8];
|
||||
} TITLE_COORD_TABLE;
|
||||
|
||||
typedef struct TITLE_SPRITE {
|
||||
struct TITLE_SPRITE *prev;
|
||||
void *anim_table;
|
||||
void *oam_entry_table;
|
||||
void *unknown_table;
|
||||
int unknown_a[5];
|
||||
int x;
|
||||
int y;
|
||||
int unknown_b[5];
|
||||
} TITLE_SPRITE;
|
||||
|
||||
typedef struct TITLE_EXTENDED {
|
||||
unsigned short *pal_buffer[5];
|
||||
byte unknown_a[0x70];
|
||||
int sequence;
|
||||
TITLE_SPRITE sprites[8];
|
||||
int unknown[0x16];
|
||||
} TITLE_EXTENDED;
|
||||
|
||||
typedef struct TITLE_CONTROL {
|
||||
int unknown_a;
|
||||
int frame;
|
||||
int unknown_b[3];
|
||||
TITLE_EXTENDED *ext;
|
||||
int unknown_c[2];
|
||||
} TITLE_CONTROL;
|
||||
|
||||
void title_text_sequence(
|
||||
TITLE_CONTROL *control,
|
||||
TITLE_EXTENDED *ext,
|
||||
TITLE_COORD_TABLE *coords);
|
||||
|
||||
extern int m2_div(int dividend, int divisor);
|
||||
|
||||
#endif
|
|
@ -1582,6 +1582,7 @@ nop
|
|||
// Point to sequence hacks
|
||||
.org 0x8011798 :: dw title_sequence_00
|
||||
.org 0x801179C :: dw title_sequence_01
|
||||
.org 0x80117A4 :: dw title_sequence_03
|
||||
.org 0x80117A8 :: dw title_sequence_04
|
||||
.org 0x80117AC :: dw title_sequence_05
|
||||
.org 0x80117B4 :: dw title_sequence_07
|
||||
|
|
|
@ -111,6 +111,18 @@ beq @@unset
|
|||
@@end:
|
||||
b title_return
|
||||
|
||||
//---------------------------------------------------------
|
||||
title_sequence_03:
|
||||
|
||||
push {r0-r3}
|
||||
mov r0,r2 // 0x2028008
|
||||
mov r1,r9 // 0x2028028
|
||||
mov r2,sp
|
||||
add r2,0x10 // coord table on the stack
|
||||
bl title_text_sequence
|
||||
pop {r0-r3}
|
||||
b title_return
|
||||
|
||||
//---------------------------------------------------------
|
||||
title_sequence_04:
|
||||
|
||||
|
|
Loading…
Reference in New Issue