Skip to content

Commit

Permalink
dump tactician related data
Browse files Browse the repository at this point in the history
  • Loading branch information
MokhaLeee committed Aug 25, 2024
1 parent b8e8b56 commit 34a07e5
Show file tree
Hide file tree
Showing 8 changed files with 703 additions and 119 deletions.
13 changes: 0 additions & 13 deletions data/const_data_sio.s

This file was deleted.

24 changes: 10 additions & 14 deletions include/sio.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct ProcTactician {
/* 32 */ u8 unk32;
/* 33 */ u8 unk33;
/* 34 */ s16 conf_idx;
/* 36 */ s16 unk36;
/* 36 */ s16 conf_idx_bak;
/* 38 */ u8 cur_len; /* used tactician name string length */
/* 39 */ u8 unk39;
/* 3A */ u8 unk3A;
Expand All @@ -36,12 +36,11 @@ struct ProcTactician {

struct TacticianTextConf {
/* 00 */ u8 * str[0xC];
/* 30 */ u16 xpos;
/* 32 */ u16 unk32;
/* 34 */ u8 unk34;
/* 35 */ STRUCT_PAD(0x35, 0x36);
/* 36 */ s16 unk36[4];
/* 3E */ u8 unk3E;
/* 30 */ u16 x, y;
/* 34 */ u8 kind;
/* 35 */ u8 _pad_;
/* 36 */ s16 adj_idx[4];
/* 3E */ u8 action;
};

extern const struct TacticianTextConf gTacticianTextConf[];
Expand Down Expand Up @@ -214,12 +213,12 @@ void TacticianDrawCharacters(struct ProcTactician * proc);
int StrLen(u8 * buf);
void Tactician_InitScreen(struct ProcTactician * proc);
void SioUpdateTeam(char * str, int team);
void sub_80449E8(struct ProcTactician * proc, int idx, const struct TacticianTextConf * conf);
void Tactician_MoveHand(struct ProcTactician * proc, int idx, const struct TacticianTextConf * conf);
void TacticianTryAppendChar(struct ProcTactician * proc, const struct TacticianTextConf * conf);
void TacticianTryDeleteChar(struct ProcTactician * proc, const struct TacticianTextConf * conf);
void SaveTactician(struct ProcTactician * proc, const struct TacticianTextConf * conf);
bool sub_8044B78(struct ProcTactician * proc, const struct TacticianTextConf * conf, u32 c, int d);
void sub_8044C54(struct ProcTactician * proc, const struct TacticianTextConf * conf);
void Tactician_LoopCore(struct ProcTactician * proc, const struct TacticianTextConf * conf);
void Tactician_Loop(struct ProcTactician * proc);
void sub_8044F84(void);
void sub_8044FE4(struct ProcTactician * proc);
Expand Down Expand Up @@ -933,11 +932,8 @@ extern int gUnk_Sio_0203DD8C;
// extern ??? gUnk_Sio_0203DDB4
extern s8 gUnk_Sio_0203DDDC;

// extern ??? gUnknown_080D8714
extern s16 gUnknown_080D9C9E[];
// extern ??? gUnknown_080D9D34
// extern ??? gUnknown_080D9D4D
// extern ??? gUnknown_080D9D56
extern const s16 SioTacticianIndexMap[];
extern const int gLinkArenaStatusMsg[];
extern u8 const gUnknown_080D9D5E[];
extern s8 const gUnknown_080D9D61[];
extern u16 const Sprite_080D9D6E[];
Expand Down
2 changes: 1 addition & 1 deletion include/sio_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ struct LinkArenaStMaybe
/* 0B */ u8 unk_0B;
/* 0C */ struct Text texts[11];
/* 64 */ struct Text unk_64[7]; // maybe not all text?
/* 9C */ u8 unk_9C[4];
/* 9C */ u8 linking_status[4];
/* A0 */ u8 unk_A0;
/* A1 */ u8 unk_A1[4][15];
STRUCT_PAD(0xDD, 0xEC);
Expand Down
2 changes: 1 addition & 1 deletion ldscript.txt
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ SECTIONS
. = ALIGN(4); src/cpextra_80407F0.o(.rodata);
. = ALIGN(4); src/sio_core.o(.rodata);
. = ALIGN(4); src/sio_main.o(.rodata);
. = ALIGN(4); data/const_data_sio.o(.rodata);
. = ALIGN(4); src/sio_tactician.o(.rodata);
. = ALIGN(4); src/sio_main2.o(.rodata);
. = ALIGN(4); src/sio_postbattle.o(.rodata);
. = ALIGN(4); src/sio_result.o(.rodata);
Expand Down
78 changes: 78 additions & 0 deletions scripts/dump_tactician.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/bin/python3
import struct

bin_file_path = "baserom.gba"
start_offset = 0x0d8740
struct_count = 81

TACTICIAN_TEXT_CONF_FORMAT = "<12I 2H B 2x 4h B"
STRUCT_SIZE = 0x40

def read_string(f):
array = bytearray(b'')

while True:
byte = f.read(1)[0]

if byte == 0:
break

array.append(byte)

return array

def parse_jis(addr):
with open(bin_file_path, "rb") as f:
f.seek(addr & 0x1FFFFFF)

array = read_string(f)

if len(array) == 0:
return "\\0"
elif array[0] == 0x20:
return "\\n"
else:
return array.decode('cp932')

with open(bin_file_path, "rb") as f:
f.seek(start_offset)

print("const struct TacticianTextConf gTacticianTextConf[] = {")

for i in range(struct_count):
data = f.read(STRUCT_SIZE)
if len(data) < STRUCT_SIZE:
print("Error: Not enough data read from the file.")
break

print(f" [{i}] = " + "{")
print( " .str = { ", end="")
print(f"\"{parse_jis(int.from_bytes(data[0x00:0x04], 'little'))}\", ", end="")
print(f"\"{parse_jis(int.from_bytes(data[0x04:0x08], 'little'))}\",", end = "")
print(f"\"{parse_jis(int.from_bytes(data[0x08:0x0C], 'little'))}\",", end = "")
print(f"\"{parse_jis(int.from_bytes(data[0x0C:0x10], 'little'))}\",", end = "")
print(f"\"{parse_jis(int.from_bytes(data[0x10:0x14], 'little'))}\",", end = "")
print(f"\"{parse_jis(int.from_bytes(data[0x14:0x18], 'little'))}\",", end = "")
print(f"\"{parse_jis(int.from_bytes(data[0x18:0x1C], 'little'))}\",", end = "")
print(f"\"{parse_jis(int.from_bytes(data[0x1C:0x20], 'little'))}\",", end = "")
print(f"\"{parse_jis(int.from_bytes(data[0x20:0x24], 'little'))}\",", end = "")
print(f"\"{parse_jis(int.from_bytes(data[0x24:0x28], 'little'))}\",", end = "")
print(f"\"{parse_jis(int.from_bytes(data[0x28:0x2C], 'little'))}\",", end = "")
print(f"\"{parse_jis(int.from_bytes(data[0x2C:0x30], 'little'))}\",", end = "")
print( "},")
print(f" .x = 0x{int.from_bytes(data[0x30:0x32], 'little'):X},")
print(f" .y = 0x{int.from_bytes(data[0x32:0x34], 'little'):X},")

if data[0x34] != 0:
print(f" .kind = {data[0x34]},")

if data[0x35] != 0:
print(f" .pad = 0x{data[0x35]:02X},")

print(f" .adj_idx = {{ {int.from_bytes(data[0x36:0x38], 'little')}, {int.from_bytes(data[0x38:0x3A], 'little')}, {int.from_bytes(data[0x3A:0x3C], 'little')}, {int.from_bytes(data[0x3C:0x3E], 'little')} }},")

if data[0x3E] != 0:
print(f" .action = {data[0x3E]}")

print( " },")
print("};")
24 changes: 11 additions & 13 deletions src/sio_bat.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,27 +254,25 @@ void sub_8045CE0(void)
return;
}

extern int gUnknown_080D9D34[];

//! FE8U = 0x08045CEC
void sub_8045CEC(void)
{
int i;

for (i = 0; i < 4; i++)
{
if (gLinkArenaSt.unk_9C[i] != gSioSt->playerStatus[i])
if (gLinkArenaSt.linking_status[i] != gSioSt->playerStatus[i])
{
gLinkArenaSt.unk_9C[i] = gSioSt->playerStatus[i];
gLinkArenaSt.linking_status[i] = gSioSt->playerStatus[i];

ClearText(&gLinkArenaSt.texts[i]);
Text_SetColor(&gLinkArenaSt.texts[i], 0);

if (gLinkArenaSt.unk_9C[i] < 5)
if (gLinkArenaSt.linking_status[i] < 5)
{
PutDrawTextCentered(
&gLinkArenaSt.texts[i], 0xb, 5 + i * 3,
GetStringFromIndex(gUnknown_080D9D34[gLinkArenaSt.unk_9C[i]]), 10);
GetStringFromIndex(gLinkArenaStatusMsg[gLinkArenaSt.linking_status[i]]), 10);
ApplyPalette(gUnknown_085ADDA8, 0x13 + i);
}
else
Expand Down Expand Up @@ -319,7 +317,7 @@ void sub_8045DC0(struct SioBatProc * proc)

for (i = 0; i < 4; i++)
{
gLinkArenaSt.unk_9C[i] = 0xff;
gLinkArenaSt.linking_status[i] = 0xff;
}

sub_8045CEC();
Expand Down Expand Up @@ -720,7 +718,7 @@ void sub_80464B0(struct SioBatProc * proc)

for (i = 0; i < 4; i++)
{
gLinkArenaSt.unk_9C[i] = 0;
gLinkArenaSt.linking_status[i] = 0;
}

gSioSt->unk_00A = 1 << gSioSt->selfId;
Expand Down Expand Up @@ -756,7 +754,7 @@ void sub_8046580(struct SioBatProc * proc)
{
proc->unk_58 = (u8)SioEmitData((u8 *)&gUnknown_085A9884->units[proc->unk_64], 0x28);
proc->unk_64++;
gLinkArenaSt.unk_9C[gSioSt->selfId] = proc->unk_64;
gLinkArenaSt.linking_status[gSioSt->selfId] = proc->unk_64;
}

if ((GetGameClock() % 0x26) == 0)
Expand All @@ -766,15 +764,15 @@ void sub_8046580(struct SioBatProc * proc)
if (got != 0)
{
int base = outSenderId[0] * 0x40 + 1;
struct Unit * unit = GetUnit(base + gLinkArenaSt.unk_9C[outSenderId[0]]);
struct Unit * unit = GetUnit(base + gLinkArenaSt.linking_status[outSenderId[0]]);

ClearUnit(unit);
LoadSavedUnit(buf, unit);
sub_8046478(unit);

unit->index = gLinkArenaSt.unk_9C[outSenderId[0]] + base;
unit->index = gLinkArenaSt.linking_status[outSenderId[0]] + base;

if (gLinkArenaSt.unk_9C[outSenderId[0]] == 0)
if (gLinkArenaSt.linking_status[outSenderId[0]] == 0)
{
gUnk_Sio_0203DD90.unk_24[outSenderId[0]] = GetUnitMiniPortraitId(unit);
}
Expand All @@ -784,7 +782,7 @@ void sub_8046580(struct SioBatProc * proc)
unit->state = US_BIT9;
}

gLinkArenaSt.unk_9C[outSenderId[0]]++;
gLinkArenaSt.linking_status[outSenderId[0]]++;
}

for (i = 0; i < 4; i++)
Expand Down
2 changes: 1 addition & 1 deletion src/sio_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ void SioMain_Loop(void)
break;

case SIO_MSG_86:
gLinkArenaSt.unk_9C[message->param] = 1;
gLinkArenaSt.linking_status[message->param] = 1;
gSioSt->playerStatus[message->param] = PLAYER_STATUS_5;
gSioSt->unk_009 |= 1 << message->param;
gSioSt->timeoutClock[message->param] = 0;
Expand Down
Loading

0 comments on commit 34a07e5

Please sign in to comment.