Skip to content

Commit

Permalink
TSA: MSG: Support TH14's new speech bubble shape/direction command. [V]
Browse files Browse the repository at this point in the history
As of TH16, this is only used in the TH14 Extra Stage for the pre-
midboss dialog, to make Benben's one bubble extend to the right, despite
it being set up with opcode 8 before.

Without this, the MSG patcher thought this was a standard right-side
bubble extending to the left, and since it is positioned quite far left
at 112 pixels, it erroneously shifted the bubble quite a bit to the
right for most translations.

This new opcode could also change the shape of the bubble, but for some
reason, the text for all left-side bubbles is weirdly "indented" by
about 40/80 pixels. Not our problem though, and it's unused anyway.
  • Loading branch information
nmlgc committed Aug 23, 2017
1 parent e5950bc commit 7d1f521
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
34 changes: 33 additions & 1 deletion thcrap_tsa/src/th06_msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ typedef struct {
} hard_line_data_t;
#pragma pack(pop)

typedef uint32_t th14_bubble_shape_data_t;

// Supported opcode commands
typedef enum {
OP_UNKNOWN = 0,
Expand All @@ -51,6 +53,7 @@ typedef enum {
OP_SIDE_LEFT,
OP_SIDE_RIGHT,
OP_BUBBLE_POS,
OP_BUBBLE_SHAPE,
} op_cmd_t;

typedef struct {
Expand Down Expand Up @@ -415,6 +418,7 @@ int op_auto_end(patch_msg_state_t* state)
int process_op(const op_info_t *cur_op, patch_msg_state_t* state)
{
hard_line_data_t* line;
th14_bubble_shape_data_t *shape;
uint16_t linenum;

switch(cur_op->cmd) {
Expand All @@ -430,6 +434,16 @@ int process_op(const op_info_t *cur_op, patch_msg_state_t* state)
state->side = SIDE_RIGHT;
return op_auto_end(state);

case OP_BUBBLE_SHAPE:
shape = (th14_bubble_shape_data_t *)state->cmd_out->data;
assert(state->cmd_out->length >= 4);
// As of TH14, shape values from [0; 15] are valid, larger
// ones crash the game. Not our problem though, who knows,
// maybe they'll be added in a future game.

state->side = (*shape & 1) ? SIDE_RIGHT : SIDE_LEFT;
return op_auto_end(state);

case OP_BUBBLE_POS:
state->bubble_pos = (th128_bubble_pos_t*)state->cmd_out;
assert(state->bubble_pos->length >= 8);
Expand Down Expand Up @@ -692,6 +706,22 @@ const msg_format_t MSG_TH128 = {
}
};

const msg_format_t MSG_TH14 = {
.entry_offset_mul = 2,
.enc_func = msg_crypt_th09,
.opcodes = {
{ 7, OP_SIDE_LEFT },
{ 8, OP_SIDE_RIGHT },
{ 9, OP_AUTO_END },
{ 11, OP_AUTO_END },
{ 17, OP_AUTO_LINE },
{ 25, OP_DELETE },
{ 28, OP_BUBBLE_POS },
{ 32, OP_BUBBLE_SHAPE },
{ 0 }
}
};

// Endings (TH10 and later)
const msg_format_t END_TH10 = {
.entry_offset_mul = 2,
Expand All @@ -707,7 +737,9 @@ const msg_format_t END_TH10 = {

const msg_format_t* msg_format_for(tsa_game_t game)
{
if(game >= TH128) {
if(game >= TH14) {
return &MSG_TH14;
} else if(game >= TH128) {
return &MSG_TH128;
} else if(game >= TH11) {
return &MSG_TH11;
Expand Down
2 changes: 2 additions & 0 deletions thcrap_tsa/src/thcrap_tsa.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ typedef enum {
TH13,

// • Changes the speech bubble shape
// • msg: Adds opcode 32 for overriding the speech bubble shape and
// direction
TH14,

// Any future game without relevant changes
Expand Down

0 comments on commit 7d1f521

Please sign in to comment.