Merge pull request #396 from SethBarberee/ground_link

ground_link cleanup and data
This commit is contained in:
Seth Barberee
2025-05-25 09:32:04 -07:00
committed by GitHub
4 changed files with 7 additions and 54 deletions

View File

@@ -262,22 +262,3 @@ gUnknown_8118758: @ 8118758
.4byte gUnknown_81185D8
.4byte 0x56A
.4byte GroundEffect_Action_Text
.string "pksdir0\0"
.align 2,0
@ Ground Link
.global GroundLink_FileText
GroundLink_FileText: @ FileText
.string "../ground/ground_link.c\0"
.align 2,0
.global GroundLink_SelectText
GroundLink_SelectText: @ SelectText
.string "GroundLink_Select\0"
.align 2,0
.global gUnknown_8118798
gUnknown_8118798: @ 8118798
.4byte GroundLink_FileText
.byte 0x4D, 0x00, 0x00, 0x00
.4byte GroundLink_SelectText

View File

@@ -2,6 +2,7 @@
#define GUARD_GROUND_SCRIPT_H
#include "structs/str_position.h"
#include "number_util.h"
// size: 0x10
typedef struct ScriptCommand
@@ -201,6 +202,7 @@ struct GroundScriptHeader {
const struct GroundLink *links;
};
// NOTE: F248 macros can match but has to be written this way to match in Blue
static inline void SetUnkInGroundEvent(const CompactPos *posPtr, PixelPos *dst)
{
if (!(posPtr->xFlags & 4)) {

View File

@@ -703,6 +703,7 @@ SECTIONS {
src/ground_script_file.o(.rodata);
src/ground_lives.o(.rodata);
data/data_8115F5C_1.o(.rodata);
src/ground_link.o(.rodata);
src/ground_event.o(.rodata);
src/unk_dungeon_load_maybe.o(.rodata);
data/data_8115F5C_3.o(.rodata);

View File

@@ -1,4 +1,5 @@
#include "global.h"
#include "globaldata.h"
#include "ground_link.h"
#include "debug.h"
#include "ground_script.h"
@@ -20,7 +21,7 @@ void sub_80AD874(void)
void GroundLink_Select(s16 r0)
{
const struct GroundScriptHeader *gs = GetGroundScript(r0, &gUnknown_8118798);
const struct GroundScriptHeader *gs = GetGroundScript(r0, DEBUG_LOC_PTR("../ground/ground_link.c", 77, "GroundLink_Select"));
gCurrentGroundLink = gs->links;
}
@@ -35,23 +36,7 @@ s32 GroundLink_GetPos(s32 _arg0, PixelPos *pos)
s32 arg0 = (s16)(_arg0);
const struct GroundLink *ptr = &gCurrentGroundLink[arg0];
if (!(ptr->pos.xFlags & 4)) {
s32 xAdd = IntToF248(4).raw;
pos->x = IntToF248(ptr->pos.xTiles * 8).raw;
if (ptr->pos.xFlags & 2) {
pos->x += xAdd;
}
}
if (!(ptr->pos.yFlags & 4)) {
s32 yAdd = IntToF248(4).raw;
pos->y = IntToF248(ptr->pos.yTiles * 8).raw;
if (ptr->pos.yFlags & 2) {
pos->y += yAdd;
}
}
SetUnkInGroundEvent(&ptr->pos, pos);
return ptr->ret;
}
@@ -62,24 +47,8 @@ s32 GroundLink_GetArea(s32 _arg0, PixelPos *arg1, PixelPos *arg2, PixelPos *arg3
const struct GroundLink *ptr = &gCurrentGroundLink[arg0];
*arg1 = *arg3;
if (!(ptr->pos.xFlags & 4))
{
s32 xAdd = IntToF248(4).raw;
arg1->x = IntToF248(ptr->pos.xTiles * 8).raw;
if (ptr->pos.xFlags & 2)
arg1->x += xAdd;
}
if (!(ptr->pos.yFlags & 4))
{
s32 yAdd = IntToF248(4).raw;
arg1->y = IntToF248(ptr->pos.yTiles * 8).raw;
if (ptr->pos.yFlags & 2) {
arg1->y += yAdd;
}
}
SetUnkInGroundEvent(&ptr->pos, arg1);
arg2->x = arg1->x + IntToF248(ptr->width * 8).raw;
arg2->y = arg1->y + IntToF248(ptr->height * 8).raw;