Skip to content

Commit 9a285f1

Browse files
committed
Removed typedefs from structs and applied static_asserts for struct sizes from the game
1 parent c1b3da6 commit 9a285f1

File tree

13 files changed

+38
-11
lines changed

13 files changed

+38
-11
lines changed

ttyd-tools/rel/include/gc/OSAlloc.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ struct HeapInfo
1818
ChunkInfo *firstUsed;
1919
} __attribute__((__packed__));
2020

21+
static_assert(sizeof(ChunkInfo) == 0xC);
22+
static_assert(sizeof(HeapInfo) == 0xC);
23+
2124
extern "C" {
2225

2326
// DLInsert

ttyd-tools/rel/include/gc/OSModule.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ struct OSModuleInfo
1616
uint32_t version;
1717
} __attribute__((__packed__));
1818

19+
static_assert(sizeof(OSModuleInfo) == 0x20);
20+
1921
extern "C" {
2022

2123
// OSNotifyLink

ttyd-tools/rel/include/gc/card.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@ namespace gc::card {
2828
#define CARD_RESULT_CANCELED -14 // Card operation canceled
2929
#define CARD_RESULT_FATAL_ERROR -128 // Fatal error, non-recoverable
3030

31-
typedef struct CARDFileInfo {
31+
struct CARDFileInfo {
3232
int32_t channel;
3333
int32_t fileNum;
3434
int32_t offset;
3535
int32_t length;
3636
uint16_t iBlock;
3737
uint16_t padding;
38-
} __attribute__((__packed__)) CARDFileInfo;
38+
} __attribute__((__packed__));
3939

40-
typedef struct CARDStat {
40+
struct CARDStat {
4141
char fileName[CARD_FILENAME_MAX];
4242
uint32_t length;
4343
uint32_t time;
@@ -54,10 +54,13 @@ typedef struct CARDStat {
5454
uint32_t offsetIcon[CARD_MAX_ICONS];
5555
uint32_t offsetIconTlut;
5656
uint32_t offsetData;
57-
} __attribute__((__packed__)) CARDStat;
57+
} __attribute__((__packed__));
5858

5959
typedef void (*CARDCallback)(int32_t channel, int32_t result);
6060

61+
static_assert(sizeof(CARDFileInfo) == 0x14);
62+
static_assert(sizeof(CARDStat) == 0x6C);
63+
6164
extern "C" {
6265

6366
int32_t CARDGetResultCode(int32_t channel);

ttyd-tools/rel/include/gc/ppc.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace gc::ppc {
66

7-
typedef union WriteGatherPipe
7+
union WriteGatherPipe
88
{
99
int8_t s8;
1010
int16_t s16;
@@ -16,7 +16,7 @@ typedef union WriteGatherPipe
1616
uint64_t u64;
1717
float f32;
1818
double f64;
19-
} WriteGatherPipe;
19+
};
2020

2121
extern "C" {
2222

ttyd-tools/rel/include/ttyd/battle_unit.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ struct AttackParams
143143
uint8_t unk_0xbf;
144144
} __attribute__((__packed__));
145145

146+
static_assert(sizeof(AttackParams) == 0xC0);
147+
146148
extern "C" {
147149

148150
// BtlUnit_CheckShadowGuard

ttyd-tools/rel/include/ttyd/database.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ struct DatabaseDefinition
1010
int32_t id;
1111
} __attribute__((__packed__));
1212

13+
static_assert(sizeof(DatabaseDefinition) == 0x8);
14+
1315
extern "C" {
1416

1517
void setupDataLoad(const char *mapName);

ttyd-tools/rel/include/ttyd/dispdrv.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ struct DisplayWork
3434
void *user;
3535
} __attribute__((__packed__));
3636

37+
static_assert(sizeof(DisplayWork) == 0x10);
38+
3739
extern "C" {
3840

3941
void dispInit();

ttyd-tools/rel/include/ttyd/event.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ struct EventStageDescription
3333
int32_t eventCount;
3434
} __attribute__((__packed__));
3535

36+
#ifdef TTYD_JP
37+
static_assert(sizeof(EventStageEventDescription) == 0x1C);
38+
static_assert(sizeof(EventStageDescription) == 0xC);
39+
#else
40+
static_assert(sizeof(EventStageEventDescription) == 0x20);
41+
static_assert(sizeof(EventStageDescription) == 0x10);
42+
#endif
43+
3644
extern "C" {
3745

3846
int32_t eventStgNum();

ttyd-tools/rel/include/ttyd/evt_map.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ EVT_DECLARE_USER_FUNC(evt_map_get_flush_color, 5)
8585
EVT_DECLARE_USER_FUNC(check, 1)
8686

8787
// check2(int &is_not_riding)
88-
// Checks if the player is not riding the mapobj with the nammed passed in LW(1).
88+
// Checks if the player is not riding the mapobj with the name passed in LW(1).
8989
EVT_DECLARE_USER_FUNC(check2, 1)
9090

9191
// evt_map_entry_airport_harbor(int mode, char *mapobj_name, int w_unknown)

ttyd-tools/rel/include/ttyd/evtmgr.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ struct EvtEntry
6666
int32_t unk_1ac;
6767
} __attribute__((__packed__));
6868

69-
static_assert(sizeof(EvtEntry) == 0x1B0);
70-
7169
struct EvtWork
7270
{
7371
int32_t entryCount;
@@ -78,6 +76,7 @@ struct EvtWork
7876
int64_t currentEvtTime;
7977
} __attribute__((__packed__));
8078

79+
static_assert(sizeof(EvtEntry) == 0x1B0);
8180
static_assert(sizeof(EvtWork) == 0xA0);
8281

8382
extern "C" {

0 commit comments

Comments
 (0)