Skip to content

Commit

Permalink
more
Browse files Browse the repository at this point in the history
  • Loading branch information
red031000 committed Mar 11, 2024
1 parent 151dd52 commit 32d3bef
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 119 deletions.
118 changes: 3 additions & 115 deletions arm9/asm/map_object_s.s
Original file line number Diff line number Diff line change
Expand Up @@ -6,118 +6,6 @@

.text

thumb_func_start sub_0205771C
sub_0205771C: ; 0x0205771C
push {r3-r7, lr}
add r5, r0, #0x0
mov r4, #0x0
bl MapObjectManager_GetObjectCount
add r6, r0, #0x0
add r0, r5, #0x0
bl MapObjectManager_GetObjects
mov r7, #0x4a
add r5, r0, #0x0
lsl r7, r7, #0x2
_02057734:
add r0, r5, #0x0
mov r1, #0x1
bl MapObject_GetFlagsBits
cmp r0, #0x0
beq _02057746
add r0, r5, #0x0
bl MapObject_Remove
_02057746:
add r4, r4, #0x1
add r5, r5, r7
cmp r4, r6
blt _02057734
pop {r3-r7, pc}

thumb_func_start sub_02057750
sub_02057750: ; 0x02057750
push {r3-r7, lr}
add r5, r0, #0x0
bl sub_020587E0
cmp r0, #0x1
beq _02057760
bl GF_AssertFail
_02057760:
add r0, r5, #0x0
mov r4, #0x0
bl MapObjectManager_GetObjectCount
add r6, r0, #0x0
add r0, r5, #0x0
bl MapObjectManager_GetObjects
mov r7, #0x4a
add r5, r0, #0x0
lsl r7, r7, #0x2
_02057776:
add r0, r5, #0x0
mov r1, #0x1
bl MapObject_GetFlagsBits
cmp r0, #0x0
beq _0205779C
mov r1, #0x1
add r0, r5, #0x0
lsl r1, r1, #0xe
bl MapObject_GetFlagsBits
cmp r0, #0x0
beq _0205779C
add r0, r5, #0x0
bl sub_020586C8
add r0, r5, #0x0
bl sub_0205816C
_0205779C:
add r4, r4, #0x1
add r5, r5, r7
cmp r4, r6
blt _02057776
pop {r3-r7, pc}
.balign 4

thumb_func_start sub_020577A8
sub_020577A8: ; 0x020577A8
push {r3-r7, lr}
add r5, r0, #0x0
bl sub_020587E0
cmp r0, #0x1
beq _020577B8
bl GF_AssertFail
_020577B8:
add r0, r5, #0x0
mov r4, #0x0
bl MapObjectManager_GetObjectCount
add r6, r0, #0x0
add r0, r5, #0x0
bl MapObjectManager_GetObjects
mov r7, #0x4a
add r5, r0, #0x0
lsl r7, r7, #0x2
_020577CE:
add r0, r5, #0x0
bl MapObject_IsInUse
cmp r0, #0x1
bne _020577F6
add r0, r5, #0x0
bl sub_02058884
cmp r0, #0x1
bne _020577EA
add r0, r5, #0x0
bl sub_020586DC
b _020577F0
_020577EA:
add r0, r5, #0x0
bl sub_020581B4
_020577F0:
add r0, r5, #0x0
bl sub_02058148
_020577F6:
add r4, r4, #0x1
add r5, r5, r7
cmp r4, r6
blt _020577CE
pop {r3-r7, pc}

thumb_func_start sub_02057800
sub_02057800: ; 0x02057800
push {r3-r7, lr}
Expand Down Expand Up @@ -1292,7 +1180,7 @@ sub_020581B4: ; 0x020581B4
mov r1, #0x0
bl ov05_021F2E0C
add r0, r4, #0x0
bl sub_02058884
bl MapObject_CheckFlag14
cmp r0, #0x0
bne _020581F6
add r0, r4, #0x0
Expand Down Expand Up @@ -2475,8 +2363,8 @@ sub_02058878: ; 0x02058878
.balign 4
_02058880: .word MapObject_SetFlagsBits

thumb_func_start sub_02058884
sub_02058884: ; 0x02058884
thumb_func_start MapObject_CheckFlag14
MapObject_CheckFlag14: ; 0x02058884
ldr r3, _0205888C ; =MapObject_TestFlagsBits
mov r1, #0x1
lsl r1, r1, #0xe
Expand Down
2 changes: 1 addition & 1 deletion arm9/asm/unk_02048904.s
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ sub_02048B34: ; 0x02048B34
ldr r0, [r4, #0x38]
bl sub_02055160
ldr r0, [r4, #0x34]
bl sub_0205771C
bl MapObjectManager_RemoveAllActiveObjects
ldr r0, [r4, #0x34]
bl MapObjectManager_Delete
pop {r4, pc}
Expand Down
4 changes: 2 additions & 2 deletions arm9/global.inc
Original file line number Diff line number Diff line change
Expand Up @@ -3993,7 +3993,7 @@
.extern MapObject_Remove
.extern MapObject_Delete
.extern sub_020576A8
.extern sub_0205771C
.extern MapObjectManager_RemoveAllActiveObjects
.extern sub_02057750
.extern sub_020577A8
.extern sub_02057800
Expand Down Expand Up @@ -4088,7 +4088,7 @@
.extern sub_02058854
.extern sub_02058860
.extern sub_0205886C
.extern sub_02058884
.extern MapObject_CheckFlag14
.extern sub_02058890
.extern MapObject_SetVisible
.extern sub_020588B8
Expand Down
2 changes: 1 addition & 1 deletion arm9/overlays/05/asm/ov05_021F1CB8.s
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ ov05_021F1EC0: ; 0x021F1EC0
add r4, r0, #0
bl sub_020584AC
add r0, r4, #0
bl sub_02058884
bl MapObject_CheckFlag14
cmp r0, #1
bne _021F1ED8
add r0, r4, #0
Expand Down
60 changes: 60 additions & 0 deletions arm9/src/map_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ extern void sub_02058698(LocalMapObject *object, LocalMapObject_UnkCallback call
extern void sub_020586AC(LocalMapObject *object, LocalMapObject_UnkCallback callback);
extern void sub_020586C0(LocalMapObject *object, LocalMapObject_UnkCallback callback);
extern void sub_020586D4(LocalMapObject *object, LocalMapObject_UnkCallback callback);
extern void sub_020586C8(LocalMapObject *object);
extern void sub_0205816C(LocalMapObject *object);
extern BOOL MapObject_CheckFlag14(LocalMapObject *object);
extern void sub_020586DC(LocalMapObject *object);

MapObjectManager *MapObjectManager_Init(FieldSystem *fieldSystem, u32 objectCount, HeapID heapId) {
MapObjectManager *ret = MapObjectManager_New(objectCount);
Expand Down Expand Up @@ -245,3 +249,59 @@ void sub_020576A8(LocalMapObject *object) {
sub_020586C0(object, sub_02058EE0);
sub_020586D4(object, sub_02058EE4);
}

void MapObjectManager_RemoveAllActiveObjects(MapObjectManager *manager) {
s32 i = 0;
s32 count = MapObjectManager_GetObjectCount(manager);
LocalMapObject *objects = MapObjectManager_GetObjects(manager);

do { //BUG: does not check for if count is zero, and will always execute at least once
if (MapObject_GetFlagsBits(objects, MAPOBJECTFLAG_ACTIVE) != 0) {
MapObject_Remove(objects);
}

i++;
objects++;
} while (i < count);
}

void sub_02057750(MapObjectManager *manager) {
GF_ASSERT(sub_020587E0(manager) == TRUE);

s32 i = 0;
s32 count = MapObjectManager_GetObjectCount(manager);
LocalMapObject *objects = MapObjectManager_GetObjects(manager);

do {
if (MapObject_GetFlagsBits(objects, MAPOBJECTFLAG_ACTIVE) != 0 && MapObject_GetFlagsBits(objects, MAPOBJECTFLAG_UNK14) != 0) {
sub_020586C8(objects);
sub_0205816C(objects);
}

i++;
objects++;
} while (i < count);
}

void sub_020577A8(MapObjectManager *manager) {
GF_ASSERT(sub_020587E0(manager) == TRUE);

s32 i = 0;
s32 count = MapObjectManager_GetObjectCount(manager);
LocalMapObject *objects = MapObjectManager_GetObjects(manager);

do {
if (MapObject_IsInUse(objects) == TRUE) {
if (MapObject_CheckFlag14(objects) == TRUE) {
sub_020586DC(objects);
} else {
sub_020581B4(objects);
}

sub_02058148(objects);
}

i++;
objects++;
} while (i < count);
}
3 changes: 3 additions & 0 deletions include/map_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,8 @@ void sub_02057634(LocalMapObject *object, u32 sprite);
void MapObject_Remove(LocalMapObject *object);
void MapObject_Delete(LocalMapObject *object);
void sub_020576A8(LocalMapObject *object);
void MapObjectManager_RemoveAllActiveObjects(MapObjectManager *manager);
void sub_02057750(MapObjectManager *manager);
void sub_020577A8(MapObjectManager *manager);

#endif //POKEDIAMOND_MAP_OBJECT_H

0 comments on commit 32d3bef

Please sign in to comment.