Merge pull request #288 from DizzyEggg/ground_link
Some checks failed
GithubCI / build (push) Has been cancelled

This commit is contained in:
Seth Barberee 2024-12-03 07:02:21 -08:00 committed by GitHub
commit 85becce674
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 63 additions and 137 deletions

View File

@ -1,129 +0,0 @@
#include "asm/constants/gba_constants.inc"
#include "asm/macros.inc"
.syntax unified
.text
thumb_func_start GroundLink_GetPos
GroundLink_GetPos:
push {r4,lr}
adds r4, r1, 0
lsls r0, 16
ldr r1, _080AD910
asrs r0, 13
ldr r1, [r1]
adds r2, r1, r0
ldrb r1, [r2, 0x2]
movs r0, 0x4
ands r0, r1
cmp r0, 0
bne _080AD8E4
ldrb r0, [r2]
lsls r3, r0, 11
str r3, [r4]
ldrb r1, [r2, 0x2]
movs r0, 0x2
ands r0, r1
cmp r0, 0
beq _080AD8E4
movs r1, 0x80
lsls r1, 3
adds r0, r3, r1
str r0, [r4]
_080AD8E4:
ldrb r1, [r2, 0x3]
movs r0, 0x4
ands r0, r1
cmp r0, 0
bne _080AD906
ldrb r0, [r2, 0x1]
lsls r3, r0, 11
str r3, [r4, 0x4]
ldrb r1, [r2, 0x3]
movs r0, 0x2
ands r0, r1
cmp r0, 0
beq _080AD906
movs r1, 0x80
lsls r1, 3
adds r0, r3, r1
str r0, [r4, 0x4]
_080AD906:
ldrb r0, [r2, 0x6]
pop {r4}
pop {r1}
bx r1
.align 2, 0
_080AD910: .4byte gCurrentGroundLink
thumb_func_end GroundLink_GetPos
thumb_func_start GroundLink_GetArea
GroundLink_GetArea:
push {r4,r5,lr}
adds r4, r1, 0
adds r5, r2, 0
lsls r0, 16
ldr r1, _080AD98C
asrs r0, 13
ldr r1, [r1]
adds r2, r1, r0
ldr r0, [r3]
ldr r1, [r3, 0x4]
str r0, [r4]
str r1, [r4, 0x4]
ldrb r1, [r2, 0x2]
movs r0, 0x4
ands r0, r1
cmp r0, 0
bne _080AD94E
ldrb r0, [r2]
lsls r3, r0, 11
str r3, [r4]
ldrb r1, [r2, 0x2]
movs r0, 0x2
ands r0, r1
cmp r0, 0
beq _080AD94E
movs r1, 0x80
lsls r1, 3
adds r0, r3, r1
str r0, [r4]
_080AD94E:
ldrb r1, [r2, 0x3]
movs r0, 0x4
ands r0, r1
cmp r0, 0
bne _080AD970
ldrb r0, [r2, 0x1]
lsls r3, r0, 11
str r3, [r4, 0x4]
ldrb r1, [r2, 0x3]
movs r0, 0x2
ands r0, r1
cmp r0, 0
beq _080AD970
movs r1, 0x80
lsls r1, 3
adds r0, r3, r1
str r0, [r4, 0x4]
_080AD970:
ldrb r1, [r2, 0x4]
lsls r1, 11
ldr r0, [r4]
adds r0, r1
str r0, [r5]
ldrb r1, [r2, 0x5]
lsls r1, 11
ldr r0, [r4, 0x4]
adds r0, r1
str r0, [r5, 0x4]
ldrb r0, [r2, 0x6]
pop {r4,r5}
pop {r1}
bx r1
.align 2, 0
_080AD98C: .4byte gCurrentGroundLink
thumb_func_end GroundLink_GetArea
.align 2,0

View File

@ -1,6 +1,10 @@
#ifndef GUARD_GROUND_LINK_H
#define GUARD_GROUND_LINK_H
#include "structs/str_position.h"
void GroundLink_Select(s16 r0);
s32 GroundLink_GetPos(s32 _arg0, PixelPos *pos);
s32 GroundLink_GetArea(s32 _arg0, PixelPos *arg1, PixelPos *arg2, PixelPos *arg3);
#endif // GUARD_GROUND_LINK_H

View File

@ -348,7 +348,6 @@ SECTIONS {
asm/ground_object.o(.text);
asm/ground_effect.o(.text);
src/ground_link.o(.text);
asm/ground_link.o(.text);
asm/ground_event.o(.text);
asm/m4a_1.o(.text);
src/m4a.o(.text);

View File

@ -1,6 +1,8 @@
#include "global.h"
#include "ground_link.h"
#include "debug.h"
#include "ground_script.h"
#include "number_util.h"
EWRAM_DATA_2 const struct GroundLink *gCurrentGroundLink = NULL;
extern DebugLocation gUnknown_8118798;
@ -27,3 +29,59 @@ const struct GroundLink *GetCurrentGroundLink(s16 r0)
u32 a = r0;
return &gCurrentGroundLink[a];
}
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;
}
}
return ptr->ret;
}
s32 GroundLink_GetArea(s32 _arg0, PixelPos *arg1, PixelPos *arg2, PixelPos *arg3)
{
s32 arg0 = (s16) _arg0;
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;
}
}
arg2->x = arg1->x + IntToF248(ptr->width * 8).raw;
arg2->y = arg1->y + IntToF248(ptr->height * 8).raw;
return ptr->ret;
}

View File

@ -113,8 +113,6 @@ s16 sub_80AC448(s16, PixelPos*);
s32 sub_80AC49C(s16, PixelPos*);
s16 sub_80AD360(s16, PixelPos*);
s16 sub_80AD3B4(s16, PixelPos*);
u32 GroundLink_GetPos();
u32 GroundLink_GetArea();
void DeleteGroundEvents(void);
void DeleteGroundLives(void);
void DeleteGroundObjects(void);
@ -942,7 +940,7 @@ s32 ExecuteScriptCommand(Action *action) {
PixelPos unk;
action->callbacks->getHitboxCenter(action->parentObject, &unk);
GroundLink_GetPos((s16)curCmd.arg1, &unk);
action->callbacks->moveReal(action->parentObject, &unk); // landing end of unwanted tailmerge
action->callbacks->moveReal(action->parentObject, &unk);
scriptData->unk2A = (u8)curCmd.argByte;
return 2;
}
@ -979,10 +977,6 @@ s32 ExecuteScriptCommand(Action *action) {
action->callbacks->setPosHeight(action->parentObject, height);
action->scriptData.unk26 = dir;
action->callbacks->setDirection(action->parentObject, dir);
// NONMATCHING: unwanted tailmerge
#ifndef NONNMATCHING
asm("");
#endif
scriptData->unk2A = (u8)curCmd.argByte;
return 2;
}