Finish code_8044CC8.s

This commit is contained in:
Kermalis 2024-11-05 10:50:03 -05:00
parent 723475af05
commit c0872f639c
4 changed files with 47 additions and 88 deletions

View File

@ -1,75 +0,0 @@
#include "asm/constants/gba_constants.inc"
#include "asm/macros.inc"
.syntax unified
.text
thumb_func_start sub_8045064
sub_8045064:
push {r4-r7,lr}
mov r7, r9
mov r6, r8
push {r6,r7}
movs r1, 0
ldr r0, _080450D4
mov r8, r0
ldr r0, [r0]
cmp r1, r0
bge _080450C8
mov r7, r8
ldr r2, _080450D8
mov r9, r2
ldr r0, _080450DC
mov r12, r0
_08045082:
adds r4, r1, 0x1
ldr r0, [r7]
adds r5, r4, 0
cmp r5, r0
bge _080450BE
lsls r0, r1, 2
mov r1, r12
adds r3, r0, r1
mov r6, r9
lsls r0, r5, 2
adds r2, r0, r1
_08045098:
ldrh r1, [r3]
lsls r1, 3
adds r1, r6
ldrh r0, [r2]
lsls r0, 3
adds r0, r6
ldr r1, [r1]
ldr r0, [r0]
cmp r1, r0
ble _080450B4
ldr r1, [r3]
ldr r0, [r2]
str r0, [r3]
str r1, [r2]
_080450B4:
adds r2, 0x4
adds r4, 0x1
ldr r0, [r7]
cmp r4, r0
blt _08045098
_080450BE:
adds r1, r5, 0
mov r2, r8
ldr r0, [r2]
cmp r1, r0
blt _08045082
_080450C8:
pop {r3,r4}
mov r8, r3
mov r9, r4
pop {r4-r7}
pop {r0}
bx r0
.align 2, 0
_080450D4: .4byte gUnknown_202EE6C
_080450D8: .4byte gUnknown_80F7C54
_080450DC: .4byte gUnknown_202EE44
thumb_func_end sub_8045064

View File

@ -1,13 +1,14 @@
#ifndef GUARD_CODE_8044CC8_H
#define GUARD_CODE_8044CC8_H
struct unkStruct_202EE44
// size: 0x4
typedef struct unkStruct_202EE44
{
u16 unk0;
u8 unk2;
bool8 unk3;
};
} unkStruct_202EE44;
extern struct unkStruct_202EE44 gUnknown_202EE44[10];
extern unkStruct_202EE44 gUnknown_202EE44[10];
#endif // GUARD_CODE_8044CC8_H

View File

@ -215,7 +215,6 @@ SECTIONS {
asm/code_8044210.o(.text);
src/dungeon_action.o(.text);
src/code_8044CC8.o(.text);
asm/code_8044CC8.o(.text);
src/dungeon_util.o(.text);
asm/code_80450F8.o(.text);
src/dungeon_visibility.o(.text);

View File

@ -5,26 +5,39 @@
#include "code_8044CC8.h"
#include "items.h"
// size: 0x8
typedef struct ItemText
{
u8 *desc;
u8 *useText;
} ItemText;
extern const ItemText gActions[];
extern u16 gUnknown_80F6964[NUM_ITEM_CATEGORIES];
extern u8 gUnknown_80F697C[];
extern u8 *gUnknown_80F91EC[];
extern u8 *gUnknown_80F7C50[10];
// size: 0x8
typedef struct unkStr_80F7C54
{
u32 unk0;
u8 *text;
} unkStr_80F7C54;
EWRAM_DATA unkStruct_202EE44 gUnknown_202EE44[10] = {0};
extern s32 gUnknown_202EE6C;
bool8 sub_80461C8(Position *, u32);
void sub_80460F8(Position *, Item *, u32);
extern const ItemText gActions[];
extern u16 gUnknown_80F6964[NUM_ITEM_CATEGORIES];
extern u8 gUnknown_80F697C[];
extern u8 *gUnknown_80F7C50[10];
extern const unkStr_80F7C54 gUnknown_80F7C54[65];
extern u8 *gUnknown_80F91EC[];
extern u8 sub_8043D10(void);
extern bool8 sub_8045888(Entity *);
EWRAM_DATA struct unkStruct_202EE44 gUnknown_202EE44[10] = {0};
void sub_80460F8(Position *, Item *, u32);
bool8 sub_80461C8(Position *, u32);
Item * sub_8044CC8(Entity *param_1, unkStruct_8044CC8 *param_2)
{
@ -249,3 +262,24 @@ bool8 IsNotAttacking(Entity *param_1, bool8 param_2)
return TRUE;
}
}
void sub_8045064(void)
{
s32 i;
s32 j;
unkStruct_202EE44 *iPtr;
unkStruct_202EE44 *jPtr;
unkStruct_202EE44 temp;
for (i = 0; i < gUnknown_202EE6C; i++) {
for (j = i + 1; j < gUnknown_202EE6C; j++) {
iPtr = &gUnknown_202EE44[i];
jPtr = &gUnknown_202EE44[j];
if ((s32)gUnknown_80F7C54[iPtr->unk0].unk0 > (s32)gUnknown_80F7C54[jPtr->unk0].unk0) {
temp = *iPtr;
*iPtr = *jPtr;
*jPtr = temp;
}
}
}
}