Skip to content

Commit

Permalink
Less hacky mismatched declaration, plus removal of unneeded union
Browse files Browse the repository at this point in the history
  • Loading branch information
mateon1 committed Jul 22, 2024
1 parent 6a420ad commit b3c4114
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 20 deletions.
5 changes: 5 additions & 0 deletions include/code_80A26CC.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ void sub_80A2558(s32, s16 *);
void sub_80A2584(s16, s16);
void sub_80A2598(s16, s16);
u32 sub_80A25AC(u16);
#if !defined(NONMATCHING) && defined(GROUND_SCRIPT_INCOMPLETE_DECLARATIONS)
// Workaround for ExecuteScriptCommand relying on s32 behavior of arguments
const DungeonInfo *sub_80A2608(s32 index);
#else
const DungeonInfo *sub_80A2608(s16 index);
#endif
const DungeonInfo *sub_80A2620(s16 index);
s16 sub_80A2654(s16 index);
s16 sub_80A2668(u32);
Expand Down
10 changes: 10 additions & 0 deletions include/ground_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,18 @@ typedef struct GroundConversionStruct

bool8 sub_8098F88(void);
const char *sub_8098FB4(void);

#if !defined(NONMATCHING) && defined(GROUND_SCRIPT_INCOMPLETE_DECLARATIONS)
// Workaround for ExecuteScriptCommand relying on s32 behavior of arguments
// Arguments could be left fully implicit (as I think they were in the original code),
// but this way at least verifies the argument count
bool8 GroundMainGroundRequest(s32 r0, s32 r1, s32 r2);
bool8 GroundMainRescueRequest(s32 r0, s32 r1);
#else
bool8 GroundMainGroundRequest(s16 r0, u32 r1, s32 r2);
bool8 GroundMainRescueRequest(s16 r0, u32 r1);
#endif

bool32 GroundMainGameEndRequest(u32 r0);
bool32 GroundMainGameCancelRequest(u32 r0);

Expand Down
28 changes: 8 additions & 20 deletions src/ground_script_1.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,33 @@
#include "ground_map.h"
#include "dungeon.h"

// Needs incorrect redeclaration
#define GroundMainGroundRequest jaksdlasjdklajksdklajsd
#define GroundMainRescueRequest pudmvjhieasmlzgvouh
#include "ground_main.h"
#undef GroundMainGroundRequest
#undef GroundMainRescueRequest
bool8 GroundMainGroundRequest(s32 r0, u32 r1, s32 r2);
bool8 GroundMainRescueRequest(s32 r0, u32 r1);
#ifndef NONMATCHING
#define GROUND_SCRIPT_INCOMPLETE_DECLARATIONS
#endif

// Needs incorrect redeclaration
#define sub_80A2608 vpoiuj345nmoszuozgvdyhz
#include "ground_main.h"
#include "code_80A26CC.h"
#undef sub_80A2608
const DungeonInfo *sub_80A2608(s32 index);

typedef struct {
u8 xTiles;
u8 xFlags;
u8 yTiles;
u8 yFlags;
} PosInfo;
typedef union {
u32 raw;
PosInfo fields;
} UPos;
typedef struct GroundObjectData {
u8 kind;
u8 unk1;
u8 widthTiles;
u8 heightTiles;
UPos pos;
PosInfo pos;
ScriptCommand *scripts[4]; // 2 - dialogue script
} GroundObjectData;
typedef struct GroundEffectData {
u8 kind;
u8 unk1;
u8 widthTiles; //???
u8 heightTiles;
UPos pos;
PosInfo pos;
ScriptCommand *script;
} GroundEffectData;

Expand Down Expand Up @@ -466,7 +454,7 @@ s32 ExecuteScriptCommand(Action *action) {
.unk1 = *unk,
.widthTiles = 1,
.heightTiles = 1,
.pos = {.raw = 0},
.pos = {},
.kind = curCmd.arg2,
.scripts = { [3] = gFunctionScriptTable[curCmd.arg1].script },
};
Expand All @@ -493,7 +481,7 @@ s32 ExecuteScriptCommand(Action *action) {
.unk1 = unk,
.widthTiles = 1,
.heightTiles = 1,
.pos = {.raw = 0},
.pos = {},
.kind = curCmd.arg2,
.script = gFunctionScriptTable[curCmd.arg1].script,
};
Expand Down

0 comments on commit b3c4114

Please sign in to comment.