diff --git a/arm9/asm/map_object_s.s b/arm9/asm/map_object_s.s index 7bd294462..957aeb73a 100644 --- a/arm9/asm/map_object_s.s +++ b/arm9/asm/map_object_s.s @@ -4,197 +4,16 @@ .extern UNK_020F6364 .extern sub_02057EE0 .extern sub_0205815C + .extern MapObjectManager_Get + .extern MapObjectManager_GetObjectCount + .extern MapObjectManager_SetFlagsBits + .extern MapObjectManager_ClearFlagsBits + .extern MapObjectManager_GetFlagsBitsMask + .extern MapObjectManager_GetObjects + .extern MapObjectManager_GetFieldSystem .text - thumb_func_start sub_020582F8 -sub_020582F8: ; 0x020582F8 - push {r3-r7, lr} - add r4, r1, #0x0 - mov r1, #0x1 - add r5, r0, #0x0 - add r6, r2, #0x0 - add r7, r3, #0x0 - bl MapObject_TestFlagsBits - cmp r0, #0x0 - bne _02058310 - mov r0, #0x0 - pop {r3-r7, pc} -_02058310: - add r0, r5, #0x0 - bl sub_0205845C - cmp r0, r4 - beq _0205831E - mov r0, #0x0 - pop {r3-r7, pc} -_0205831E: - add r0, r5, #0x0 - add r1, r6, #0x0 - add r2, r7, #0x0 - bl sub_020582A8 - pop {r3-r7, pc} - .balign 4 - - thumb_func_start sub_0205832C -sub_0205832C: ; 0x0205832C - push {r4, lr} - add r4, r1, #0x0 - add r0, r4, #0x0 - bl sub_02058EF8 - add r0, r4, #0x0 - bl MapObject_IsInUse - cmp r0, #0x0 - beq _02058346 - add r0, r4, #0x0 - bl sub_02058348 -_02058346: - pop {r4, pc} - - thumb_func_start sub_02058348 -sub_02058348: ; 0x02058348 - push {r4, lr} - add r4, r0, #0x0 - bl MapObject_GetManager - bl sub_020587E0 - cmp r0, #0x1 - bne _0205835E - add r0, r4, #0x0 - bl ov05_021F1D8C -_0205835E: - pop {r4, pc} - - thumb_func_start MapObjectManager_Get -MapObjectManager_Get: ; 0x02058360 - bx lr - .balign 4 - - thumb_func_start MapObjectManager_SetObjectCount -MapObjectManager_SetObjectCount: ; 0x02058364 - str r1, [r0, #0x4] - bx lr - - thumb_func_start MapObjectManager_GetObjectCount -MapObjectManager_GetObjectCount: ; 0x02058368 - ldr r0, [r0, #0x4] - bx lr - - thumb_func_start sub_0205836C -sub_0205836C: ; 0x0205836C - ldr r1, [r0, #0x8] - add r1, r1, #0x1 - str r1, [r0, #0x8] - bx lr - - thumb_func_start sub_02058374 -sub_02058374: ; 0x02058374 - ldr r1, [r0, #0x8] - sub r1, r1, #0x1 - str r1, [r0, #0x8] - bx lr - - thumb_func_start sub_0205837C -sub_0205837C: ; 0x0205837C - ldr r2, [r0, #0x0] - orr r1, r2 - str r1, [r0, #0x0] - bx lr - - thumb_func_start sub_02058384 -sub_02058384: ; 0x02058384 - ldr r2, [r0, #0x0] - mvn r1, r1 - and r1, r2 - str r1, [r0, #0x0] - bx lr - .balign 4 - - thumb_func_start sub_02058390 -sub_02058390: ; 0x02058390 - ldr r0, [r0, #0x0] - and r0, r1 - bx lr - .balign 4 - - thumb_func_start MapObjectManager_SetPriority -MapObjectManager_SetPriority: ; 0x02058398 - str r1, [r0, #0xc] - bx lr - - thumb_func_start MapObjectManager_GetPriority -MapObjectManager_GetPriority: ; 0x0205839C - ldr r0, [r0, #0xc] - bx lr - - thumb_func_start sub_020583A0 -sub_020583A0: ; 0x020583A0 - add r0, #0x18 - bx lr - - thumb_func_start sub_020583A4 -sub_020583A4: ; 0x020583A4 - mov r2, #0x12 - lsl r2, r2, #0x4 - str r1, [r0, r2] - bx lr - - thumb_func_start sub_020583AC -sub_020583AC: ; 0x020583AC - mov r1, #0x12 - lsl r1, r1, #0x4 - ldr r0, [r0, r1] - bx lr - - thumb_func_start MapObjectManager_SetObjects -MapObjectManager_SetObjects: ; 0x020583B4 - mov r2, #0x49 - lsl r2, r2, #0x2 - str r1, [r0, r2] - bx lr - - thumb_func_start sub_020583BC -sub_020583BC: ; 0x020583BC - mov r1, #0x49 - lsl r1, r1, #0x2 - ldr r0, [r0, r1] - bx lr - - thumb_func_start MapObjectManager_GetConstObjects -MapObjectManager_GetConstObjects: ; 0x020583C4 - mov r1, #0x49 - lsl r1, r1, #0x2 - ldr r0, [r0, r1] - bx lr - - thumb_func_start MapObjectManager_GetObjects -MapObjectManager_GetObjects: ; 0x020583CC - mov r1, #0x49 - lsl r1, r1, #0x2 - ldr r0, [r0, r1] - bx lr - - thumb_func_start sub_020583D4 -sub_020583D4: ; 0x020583D4 - mov r1, #0x4a - ldr r2, [r0, #0x0] - lsl r1, r1, #0x2 - add r1, r2, r1 - str r1, [r0, #0x0] - bx lr - - thumb_func_start MapObjectManager_SetFieldSystemPtr -MapObjectManager_SetFieldSystemPtr: ; 0x020583E0 - mov r2, #0x4a - lsl r2, r2, #0x2 - str r1, [r0, r2] - bx lr - - thumb_func_start MapObjectManager_GetFieldSystemPtr -MapObjectManager_GetFieldSystemPtr: ; 0x020583E8 - mov r1, #0x4a - lsl r1, r1, #0x2 - ldr r0, [r0, r1] - bx lr - thumb_func_start sub_020583F0 sub_020583F0: ; 0x020583F0 str r1, [r0, #0x14] @@ -856,7 +675,7 @@ sub_02058730: ; 0x02058730 MapObject_GetFieldSystem: ; 0x02058738 push {r3, lr} bl sub_02058580 - bl MapObjectManager_GetFieldSystemPtr + bl MapObjectManager_GetFieldSystem pop {r3, pc} thumb_func_start sub_02058744 @@ -881,19 +700,19 @@ _02058760: thumb_func_start sub_02058768 sub_02058768: ; 0x02058768 - ldr r3, _02058770 ; =sub_0205837C + ldr r3, _02058770 ; =MapObjectManager_SetFlagsBits mov r1, #0x6 bx r3 nop -_02058770: .word sub_0205837C +_02058770: .word MapObjectManager_SetFlagsBits thumb_func_start sub_02058774 sub_02058774: ; 0x02058774 - ldr r3, _0205877C ; =sub_02058384 + ldr r3, _0205877C ; =MapObjectManager_ClearFlagsBits mov r1, #0x6 bx r3 nop -_0205877C: .word sub_02058384 +_0205877C: .word MapObjectManager_ClearFlagsBits thumb_func_start MapObjectManager_PauseAllMovement MapObjectManager_PauseAllMovement: ; 0x02058780 @@ -949,7 +768,7 @@ _020587D6: sub_020587E0: ; 0x020587E0 push {r3, lr} mov r1, #0x1 - bl sub_02058390 + bl MapObjectManager_GetFlagsBitsMask cmp r0, #0x0 beq _020587F0 mov r0, #0x1 @@ -964,7 +783,7 @@ sub_020587F4: ; 0x020587F4 add r4, r1, #0x0 bl MapObject_GetManager add r1, r4, #0x0 - bl sub_02058390 + bl MapObjectManager_GetFlagsBitsMask pop {r4, pc} thumb_func_start sub_02058804 @@ -973,11 +792,11 @@ sub_02058804: ; 0x02058804 cmp r1, #0x0 bne _02058812 mov r1, #0x8 - bl sub_0205837C + bl MapObjectManager_SetFlagsBits pop {r3, pc} _02058812: mov r1, #0x8 - bl sub_02058384 + bl MapObjectManager_ClearFlagsBits pop {r3, pc} .balign 4 @@ -985,7 +804,7 @@ _02058812: sub_0205881C: ; 0x0205881C push {r3, lr} mov r1, #0x8 - bl sub_02058390 + bl MapObjectManager_GetFlagsBitsMask cmp r0, #0x0 bne _0205882C mov r0, #0x1 diff --git a/arm9/asm/unk_02058EE8.s b/arm9/asm/unk_02058EE8.s index ae3c02aa5..bb87e8c83 100644 --- a/arm9/asm/unk_02058EE8.s +++ b/arm9/asm/unk_02058EE8.s @@ -2480,7 +2480,7 @@ sub_0205995C: ; 0x0205995C add r6, r3, #0x0 bl MapObject_GetManager add r7, r0, #0x0 - bl sub_020583BC + bl MapObjectManager_GetObjects2 str r0, [sp, #0x8] add r0, r7, #0x0 bl MapObjectManager_GetObjectCount @@ -2543,7 +2543,7 @@ _020599EA: pop {r4-r7, pc} _020599F4: add r0, sp, #0x8 - bl sub_020583D4 + bl MapObjectArray_NextObject ldr r0, [sp, #0x4] sub r0, r0, #0x1 str r0, [sp, #0x4] diff --git a/arm9/global.inc b/arm9/global.inc index 68f289676..f48c78951 100644 --- a/arm9/global.inc +++ b/arm9/global.inc @@ -4006,15 +4006,15 @@ .extern sub_020582A8 .extern sub_020582F8 .extern MapObjectManager_GetObjectCount -.extern sub_0205837C -.extern sub_02058384 -.extern sub_02058390 +.extern MapObjectManager_SetFlagsBits +.extern MapObjectManager_ClearFlagsBits +.extern MapObjectManager_GetFlagsBitsMask .extern MapObjectManager_GetPriority .extern sub_020583A0 .extern sub_020583A4 .extern sub_020583AC -.extern sub_020583BC -.extern sub_020583D4 +.extern MapObjectManager_GetObjects2 +.extern MapObjectArray_NextObject .extern sub_020583F0 .extern sub_020583F4 .extern MapObject_SetFlagsBits diff --git a/arm9/overlays/05/asm/ov05_021F1CB8.s b/arm9/overlays/05/asm/ov05_021F1CB8.s index 3443ded90..86b150282 100644 --- a/arm9/overlays/05/asm/ov05_021F1CB8.s +++ b/arm9/overlays/05/asm/ov05_021F1CB8.s @@ -12,7 +12,7 @@ ov05_021F1CB8: ; 0x021F1CB8 add r5, r0, #0 add r6, r2, #0 add r7, r3, #0 - bl sub_02058390 + bl MapObjectManager_GetFlagsBitsMask cmp r0, #0 beq _021F1CD2 bl GF_AssertFail @@ -48,7 +48,7 @@ _021F1CD2: bl ov05_021F3810 add r0, r5, #0 mov r1, #1 - bl sub_0205837C + bl MapObjectManager_SetFlagsBits add sp, #0x14 pop {r4, r5, r6, r7, pc} .balign 4, 0 @@ -74,7 +74,7 @@ _021F1D3C: bl sub_020583A4 add r0, r4, #0 mov r1, #1 - bl sub_02058384 + bl MapObjectManager_ClearFlagsBits add r0, r4, #0 bl ov05_021F1D80 pop {r4, pc} @@ -105,7 +105,7 @@ ov05_021F1D8C: ; 0x021F1D8C add r4, r0, #0 bl MapObject_GetManager mov r1, #4 - bl sub_02058390 + bl MapObjectManager_GetFlagsBitsMask cmp r0, #0 bne _021F1DC6 mov r1, #1 diff --git a/arm9/overlays/05/asm/ov05_021F1F04.s b/arm9/overlays/05/asm/ov05_021F1F04.s index 6dfb22dd7..790642035 100644 --- a/arm9/overlays/05/asm/ov05_021F1F04.s +++ b/arm9/overlays/05/asm/ov05_021F1F04.s @@ -474,7 +474,7 @@ ov05_021F2284: ; 0x021F2284 bl MapObjectManager_GetObjectCount add r4, r0, #0 add r0, r5, #0 - bl sub_020583BC + bl MapObjectManager_GetObjects2 str r0, [sp] _021F229A: ldr r0, [sp] @@ -502,7 +502,7 @@ _021F22C0: pop {r3, r4, r5, r6, r7, pc} _021F22CE: add r0, sp, #0 - bl sub_020583D4 + bl MapObjectArray_NextObject sub r4, r4, #1 bne _021F229A mov r0, #0 diff --git a/arm9/src/map_object.c b/arm9/src/map_object.c index d01246c2c..382788055 100644 --- a/arm9/src/map_object.c +++ b/arm9/src/map_object.c @@ -37,27 +37,28 @@ static void sub_020581B4(LocalMapObject *object); static BOOL MapObject_ScriptIDIsFFFF(LocalMapObject *object); static void sub_02058214(LocalMapObject *object, ObjectEvent *objectEvent, u32 mapNo); static void sub_02058258(LocalMapObject *object, u32 mapNo, ObjectEvent *objectEvent); +static void sub_0205832C(SysTask *task, LocalMapObject *object); +static void sub_02058348(LocalMapObject *object); +/*static*/ MapObjectManager *MapObjectManager_Get(MapObjectManager *manager); +static void MapObjectManager_SetObjectCount(MapObjectManager *manager, u32 count); +static void sub_0205836C(MapObjectManager *manager); +static void sub_02058374(MapObjectManager *manager); +static void MapObjectManager_SetPriority(MapObjectManager *manager, u32 priority); +static void MapObjectManager_SetObjects(MapObjectManager *manager, LocalMapObject *objects); +static LocalMapObject *MapObjectManager_GetObjects3(MapObjectManager *manager); +static void MapObjectManager_SetFieldSystem(MapObjectManager *manager, FieldSystem *fieldSystem); +/*static*/ FieldSystem *MapObjectManager_GetFieldSystem(MapObjectManager *manager); -extern void MapObjectManager_SetFieldSystemPtr(MapObjectManager *manager, FieldSystem *fieldSystem); -extern void MapObjectManager_SetObjectCount(MapObjectManager *manager, u32 objectCount); -extern void MapObjectManager_SetPriority(MapObjectManager *manager, u32 priority); -extern LocalMapObject *MapObjectManager_GetObjects(MapObjectManager *manager); -extern u32 MapObjectManager_GetObjectCount(MapObjectManager *manager); extern BOOL MapObject_IsInUse(LocalMapObject *object); extern void ov05_021F2AF4(MapObjectManager *manager, void *param0); -extern void *sub_020583A0(MapObjectManager *manager); extern u32 sub_02058450(LocalMapObject *object); extern BOOL MapObject_TestFlagsBits(LocalMapObject *object, MapObjectFlagBits flags); -extern void MapObjectManager_SetObjects(MapObjectManager *manager, LocalMapObject *objects); extern u32 ObjectEvent_GetID(ObjectEvent *objectEvent); extern BOOL ObjectEvent_ScriptIDIsUnset(ObjectEvent *objectEvent); extern u16 ObjectEvent_GetFlagID_AssertScriptIDIsUnset(ObjectEvent *objectEvent); -extern FieldSystem *MapObjectManager_GetFieldSystemPtr(MapObjectManager *manager); extern void sub_02057E90(LocalMapObject *object, MapObjectManager *manager); extern void sub_0205844C(LocalMapObject *object, u32 mapNo); extern void MapObject_SetFlagsBits(LocalMapObject *object, MapObjectFlagBits bits); -extern MapObjectManager *MapObjectManager_Get(MapObjectManager *manager); -extern void sub_0205836C(MapObjectManager *manager); extern void ObjectEvent_SetId(ObjectEvent *objectEvent, u32 id); extern void ObjectEvent_SetSprite(ObjectEvent *objectEvent, u32 sprite); extern void ObjectEvent_SetMovement(ObjectEvent *objectEvent, u32 movement); @@ -83,7 +84,6 @@ extern void sub_020586B4(LocalMapObject *object); extern void sub_02058660(LocalMapObject *object); extern void sub_02058564(LocalMapObject *object); extern MapObjectManager *sub_02058580(LocalMapObject *object); -extern void sub_02058374(MapObjectManager *manager); extern u32 MapObject_GetFlagID(LocalMapObject *object); extern FieldSystem *MapObject_GetFieldSystem(LocalMapObject *object); extern void FieldSystem_FlagSet(FieldSystem *fieldSystem, u16 flag); @@ -157,8 +157,6 @@ extern void MapObject_SetPreviousY(LocalMapObject *object, u32 previousY); extern void MapObject_CreateFromInitArgs(MapObjectInitArgs *args); extern BOOL MapObject_CheckFlag25(LocalMapObject *object); extern u32 sub_02058750(LocalMapObject *object); -extern void sub_0205832C(SysTask *task, LocalMapObject *object); -extern u32 MapObjectManager_GetPriority(MapObjectManager *manager); extern void sub_02058554(LocalMapObject *object, SysTask *task); extern u16 ObjectEvent_GetSpriteID(ObjectEvent *objectEvent); extern u16 ObjectEvent_GetMovement(ObjectEvent *objectEvent); @@ -190,7 +188,6 @@ extern LocalMapObject_UnkCallback sub_02058D44(UnkLMOCallbackStruct2 *callbackSt extern void sub_020586C0(LocalMapObject *object, LocalMapObject_UnkCallback callback); extern LocalMapObject_UnkCallback sub_02058D48(UnkLMOCallbackStruct2 *callbackStruct); extern void sub_020586D4(LocalMapObject *object, LocalMapObject_UnkCallback callback); -extern const LocalMapObject *MapObjectManager_GetConstObjects(MapObjectManager *manager); extern u16 FieldSystem_VarGetObjectEventGraphicsId(FieldSystem *fieldSystem, u16 spriteId); extern u32 sub_02059D1C(LocalMapObject *object); extern void sub_02058EE8(LocalMapObject *object); @@ -199,10 +196,13 @@ extern void ov05_021F2E0C(LocalMapObject *object, BOOL set); extern void sub_0205868C(LocalMapObject *object); extern void MapObject_SetFlag14(LocalMapObject *object); extern void *sub_02058744(LocalMapObject *object); +extern u32 sub_0205845C(LocalMapObject *object); +extern void sub_02058EF8(LocalMapObject *object); +extern void ov05_021F1D8C(LocalMapObject *object); MapObjectManager *MapObjectManager_Init(FieldSystem *fieldSystem, u32 objectCount, u32 priority) { MapObjectManager *ret = MapObjectManager_New(objectCount); - MapObjectManager_SetFieldSystemPtr(ret, fieldSystem); + MapObjectManager_SetFieldSystem(ret, fieldSystem); MapObjectManager_SetObjectCount(ret, objectCount); MapObjectManager_SetPriority(ret, priority); @@ -276,7 +276,7 @@ static LocalMapObject *MapObject_CreateFromObjectEvent(MapObjectManager *manager return ret; } - MapObject_InitFromObjectEvent(ret, objectEvent, MapObjectManager_GetFieldSystemPtr(manager)); + MapObject_InitFromObjectEvent(ret, objectEvent, MapObjectManager_GetFieldSystem(manager)); sub_02057E90(ret, manager); sub_0205844C(ret, mapNo); sub_020581A4(ret); @@ -313,7 +313,7 @@ LocalMapObject *MapObject_CreateFromObjectEventWithId(MapObjectManager *manager, ObjectEvent *objectEvent = ObjectEvent_GetById(id, objectEventCount, (ObjectEvent *)events); if (objectEvent != NULL) { u32 flagId = ObjectEvent_GetFlagID(objectEvent); - FieldSystem *fieldSystem = MapObjectManager_GetFieldSystemPtr(manager); + FieldSystem *fieldSystem = MapObjectManager_GetFieldSystem(manager); if (FieldSystem_FlagCheck(fieldSystem, (u16)flagId) == FALSE) { ret = MapObject_CreateFromObjectEvent(manager, objectEvent, mapNo); } @@ -582,7 +582,7 @@ void MapObject_CreateFromMultipleObjectEvents(MapObjectManager *manager, u32 map } static void MapObject_CreateFromInitArgs(MapObjectInitArgs *args) { - FieldSystem *fieldSystem = MapObjectManager_GetFieldSystemPtr(args->manager); + FieldSystem *fieldSystem = MapObjectManager_GetFieldSystem(args->manager); ObjectEvent *objectEvents = args->objectEvents; do { // must be do while due to initial check @@ -757,7 +757,7 @@ LocalMapObject *MapObjectManager_GetFirstActiveObjectByID(MapObjectManager *mana GF_ASSERT(manager != NULL); s32 count = MapObjectManager_GetObjectCount(manager); - LocalMapObject *objects = (LocalMapObject *)MapObjectManager_GetConstObjects(manager); + LocalMapObject *objects = MapObjectManager_GetObjects3(manager); do { if (MapObject_TestFlagsBits(objects, MAPOBJECTFLAG_ACTIVE) == TRUE && MapObject_CheckFlag25(objects) == FALSE && MapObject_GetID(objects) == id) { return objects; @@ -772,7 +772,7 @@ LocalMapObject *MapObjectManager_GetFirstActiveObjectByID(MapObjectManager *mana LocalMapObject *MapObjectManager_GetFirstActiveObjectWithMovement(MapObjectManager *manager, u32 movement) { s32 count = MapObjectManager_GetObjectCount(manager); - LocalMapObject *objects = (LocalMapObject *)MapObjectManager_GetConstObjects(manager); + LocalMapObject *objects = MapObjectManager_GetObjects3(manager); do { if (MapObject_TestFlagsBits(objects, MAPOBJECTFLAG_ACTIVE) == TRUE && MapObject_GetMovement(objects) == movement) { @@ -792,7 +792,7 @@ BOOL MapObjectManager_GetNextObjectWithFlagFromIndex(MapObjectManager *manager, return FALSE; } - LocalMapObject *objects = (LocalMapObject *)MapObjectManager_GetConstObjects(manager); + LocalMapObject *objects = MapObjectManager_GetObjects3(manager); LocalMapObject *object = objects + *index; do { (*index)++; @@ -904,3 +904,115 @@ BOOL sub_020582A8(LocalMapObject *object, u32 mapId, u32 flagId) { return TRUE; } + +BOOL sub_020582F8(LocalMapObject *object, u32 spriteId, u32 mapId, u32 flagId) { + if (!MapObject_TestFlagsBits(object, MAPOBJECTFLAG_ACTIVE)) { + return FALSE; + } + + u32 objectSpriteId = sub_0205845C(object); + if (objectSpriteId != spriteId) { + return FALSE; + } + + return sub_020582A8(object, mapId, flagId); +} + +static void sub_0205832C(SysTask *task, LocalMapObject *object) { + sub_02058EF8(object); + if (MapObject_IsInUse(object)) { + sub_02058348(object); + } +} + +static void sub_02058348(LocalMapObject *object) { + if (sub_020587E0(MapObject_GetManager(object)) == TRUE) { + ov05_021F1D8C(object); + } +} + +// Likely a scrubbed debug func, but WTF is GF smoking? +/*static*/ MapObjectManager *MapObjectManager_Get(MapObjectManager *manager) { + return manager; +} + +static void MapObjectManager_SetObjectCount(MapObjectManager *manager, u32 count) { + manager->objectCount = count; +} + +u32 MapObjectManager_GetObjectCount(MapObjectManager *manager) { + return manager->objectCount; +} + +static void sub_0205836C(MapObjectManager *manager) { + manager->unk8++; +} + +static void sub_02058374(MapObjectManager *manager) { + manager->unk8--; +} + +void MapObjectManager_SetFlagsBits(MapObjectManager *manager, u32 bits) { + manager->flags |= bits; +} + +void MapObjectManager_ClearFlagsBits(MapObjectManager *manager, u32 bits) { + manager->flags &= ~bits; +} + +u32 MapObjectManager_GetFlagsBitsMask(MapObjectManager *manager, u32 bits) { + return manager->flags & bits; +} + +static void MapObjectManager_SetPriority(MapObjectManager *manager, u32 priority) { + manager->priority = priority; +} + +u32 MapObjectManager_GetPriority(MapObjectManager *manager) { + return manager->priority; +} + +// type of unk18 is unknown, it's a u32 in MapObjectManager, but unsure what it's supposed to be +// leaving return as a void * to reflect this +void *sub_020583A0(MapObjectManager *manager) { + return &manager->unk18; +} + +void sub_020583A4(MapObjectManager *manager, u32 param1) { + manager->unk120 = param1; +} + +u32 sub_020583AC(MapObjectManager *manager) { + return manager->unk120; +} + +static void MapObjectManager_SetObjects(MapObjectManager *manager, LocalMapObject *objects) { + manager->objects = objects; +} + +// the 2 here is bad, however this is *exactly* the same as the lower GetObjects +LocalMapObject *MapObjectManager_GetObjects2(MapObjectManager *manager) { + return manager->objects; +} + +// same as above +static LocalMapObject *MapObjectManager_GetObjects3(MapObjectManager *manager) { + return manager->objects; +} + +// this one is the original because it's used the most +LocalMapObject *MapObjectManager_GetObjects(MapObjectManager *manager) { + return manager->objects; +} + +void MapObjectArray_NextObject(LocalMapObject **objects) { + (*objects)++; +} + +static void MapObjectManager_SetFieldSystem(MapObjectManager *manager, FieldSystem *fieldSystem) { + manager->fieldSystem = fieldSystem; +} + +/*static*/ FieldSystem *MapObjectManager_GetFieldSystem(MapObjectManager *manager) { + return manager->fieldSystem; +} diff --git a/include/field_system.h b/include/field_system.h index c0faa1bb7..d180a55ea 100644 --- a/include/field_system.h +++ b/include/field_system.h @@ -6,6 +6,7 @@ #include "bg_window.h" #include "camera.h" #include "field_player_avatar.h" +#include "field_types_def.h" #include "save.h" #include "task.h" @@ -22,10 +23,6 @@ typedef struct UnkFieldStruct04 { u32 unk0C; } UnkFieldStruct04; -typedef struct MapObjectManager { // must be in this func, cause otheriwse build will fail - u8 padding[0x12C]; -} MapObjectManager; // todo: fill out - typedef struct UnkStruct_020464D4 { u16 unk0[4]; u8 padding[0x108]; diff --git a/include/field_types_def.h b/include/field_types_def.h new file mode 100644 index 000000000..e8f412c26 --- /dev/null +++ b/include/field_types_def.h @@ -0,0 +1,7 @@ +#ifndef POKEDIAMOND_FIELD_TYPES_DEF_H +#define POKEDIAMOND_FIELD_TYPES_DEF_H + +typedef struct LocalMapObject LocalMapObject; +typedef struct MapObjectManager MapObjectManager; + +#endif // POKEDIAMOND_FIELD_TYPES_DEF_H diff --git a/include/map_object.h b/include/map_object.h index e5e38d121..af9186873 100644 --- a/include/map_object.h +++ b/include/map_object.h @@ -4,6 +4,7 @@ #include "global.h" #include "field_system.h" +#include "field_types_def.h" #include "heap.h" typedef struct SavedMapObject { @@ -33,9 +34,22 @@ typedef struct SavedMapObject { u8 unk40[16]; } SavedMapObject; -typedef struct LocalMapObject { +struct MapObjectManager { + u32 flags; + u32 objectCount; + u32 unk8; + u32 priority; + u8 padding[0x8]; + u32 unk18; + u8 padding2[0x104]; + u32 unk120; + LocalMapObject *objects; + FieldSystem *fieldSystem; +}; + +struct LocalMapObject { u8 padding[0x128]; // todo verify size -} LocalMapObject; +}; typedef struct ObjectEvent { u8 padding[0x8]; @@ -129,5 +143,17 @@ LocalMapObject *MapObjectManager_GetFirstActiveObjectWithMovement(MapObjectManag BOOL MapObjectManager_GetNextObjectWithFlagFromIndex(MapObjectManager *manager, LocalMapObject **objectDest, s32 *index, MapObjectFlagBits flag); u32 sub_0205829C(LocalMapObject *object, u32 param1); BOOL sub_020582A8(LocalMapObject *object, u32 mapId, u32 flagId); +BOOL sub_020582F8(LocalMapObject *object, u32 spriteId, u32 mapId, u32 flagId); +u32 MapObjectManager_GetObjectCount(MapObjectManager *manager); +void MapObjectManager_SetFlagsBits(MapObjectManager *manager, u32 bits); +void MapObjectManager_ClearFlagsBits(MapObjectManager *manager, u32 bits); +u32 MapObjectManager_GetFlagsBitsMask(MapObjectManager *manager, u32 bits); +u32 MapObjectManager_GetPriority(MapObjectManager *manager); +void *sub_020583A0(MapObjectManager *manager); +void sub_020583A4(MapObjectManager *manager, u32 param1); +u32 sub_020583AC(MapObjectManager *manager); +LocalMapObject *MapObjectManager_GetObjects2(MapObjectManager *manager); +LocalMapObject *MapObjectManager_GetObjects(MapObjectManager *manager); +void MapObjectArray_NextObject(LocalMapObject **objects); #endif // POKEDIAMOND_MAP_OBJECT_H