From 63dd0ea397ff01787753f182541ed8324f2d498b Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 6 Sep 2017 08:35:16 -0400 Subject: [PATCH 001/191] Spawn source files for Field Map Obj --- include/field_map_obj.h | 10 ++++++++++ src/field_map_obj.c | 16 ++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 include/field_map_obj.h create mode 100644 src/field_map_obj.c diff --git a/include/field_map_obj.h b/include/field_map_obj.h new file mode 100644 index 000000000..ebc445794 --- /dev/null +++ b/include/field_map_obj.h @@ -0,0 +1,10 @@ +#ifndef POKEEMERALD_FIELD_MAP_OBJ_H +#define POKEEMERALD_FIELD_MAP_OBJ_H + +// Exported struct declarations + +// Exported RAM declarations + +// Exported ROM declarations + +#endif //POKEEMERALD_FIELD_MAP_OBJ_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c new file mode 100644 index 000000000..ec9a7c002 --- /dev/null +++ b/src/field_map_obj.c @@ -0,0 +1,16 @@ +// Includes + +#include "global.h" +#include "field_map_obj.h" + +// Static struct declarations + +// Static RAM declarations + +// Static ROM declarations + +// ROM data + +// Code + + From 83dbdc031856410b8b1b9154900cfcb5c069ec46 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 6 Sep 2017 08:46:47 -0400 Subject: [PATCH 002/191] npc_clear_ids_and_state --- asm/field_map_obj.s | 19 ------------------- include/global.h | 5 +++++ ld_script.txt | 1 + src/field_map_obj.c | 9 ++++++++- 4 files changed, 14 insertions(+), 20 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index ff3c8c48d..5801bbc5f 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,25 +5,6 @@ .text - thumb_func_start npc_clear_ids_and_state -npc_clear_ids_and_state: @ 808D3F0 - push {r4,lr} - adds r4, r0, 0 - movs r1, 0 - movs r2, 0x24 - bl memset - movs r0, 0xFF - strb r0, [r4, 0x8] - movs r0, 0x1 - negs r0, r0 - strb r0, [r4, 0x9] - strb r0, [r4, 0xA] - strb r0, [r4, 0x1C] - pop {r4} - pop {r0} - bx r0 - thumb_func_end npc_clear_ids_and_state - thumb_func_start npcs_clear_ids_and_state npcs_clear_ids_and_state: @ 808D410 push {r4,r5,lr} diff --git a/include/global.h b/include/global.h index c43b57e03..f9c5f68be 100644 --- a/include/global.h +++ b/include/global.h @@ -9,6 +9,11 @@ // to help in decompiling #define asm_comment(x) asm volatile("@ -- " x " -- ") +#ifdef __APPLE__ +void memset(void *, int, size_t); +void memcpy(void *, const void *, size_t); +#endif // __APPLE__ + #define ARRAY_COUNT(array) (sizeof(array) / sizeof((array)[0])) #define POKEMON_NAME_LENGTH 10 diff --git a/ld_script.txt b/ld_script.txt index d0ae744d1..6e9a7e63c 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -85,6 +85,7 @@ SECTIONS { asm/field_camera.o(.text); asm/field_door.o(.text); asm/field_player_avatar.o(.text); + src/field_map_obj.o(.text); asm/field_map_obj.o(.text); asm/field_ground_effect.o(.text); asm/map_obj_8097404.o(.text); diff --git a/src/field_map_obj.c b/src/field_map_obj.c index ec9a7c002..9451863b4 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -13,4 +13,11 @@ // Code - +void npc_clear_ids_and_state(struct MapObject *mapObject) +{ + memset(mapObject, 0, sizeof(struct MapObject)); + mapObject->localId = 0xFF; + mapObject->mapNum = -1; + mapObject->mapGroup = -1; + mapObject->mapobj_unk_1C = -1; +} From f677873d07dddd9eb43f1a9070bf9b2ac5f61749 Mon Sep 17 00:00:00 2001 From: scnorton Date: Wed, 6 Sep 2017 09:25:16 -0400 Subject: [PATCH 003/191] npcs_clear_ids_and_state --- asm/field_map_obj.s | 22 ---------------------- include/field_map_obj.h | 2 ++ src/field_map_obj.c | 9 +++++++++ 3 files changed, 11 insertions(+), 22 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 5801bbc5f..0ea219238 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,28 +5,6 @@ .text - thumb_func_start npcs_clear_ids_and_state -npcs_clear_ids_and_state: @ 808D410 - push {r4,r5,lr} - movs r4, 0 - ldr r5, =gUnknown_02037350 -_0808D416: - lsls r0, r4, 3 - adds r0, r4 - lsls r0, 2 - adds r0, r5 - bl npc_clear_ids_and_state - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0xF - bls _0808D416 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end npcs_clear_ids_and_state - thumb_func_start sub_808D438 sub_808D438: @ 808D438 push {lr} diff --git a/include/field_map_obj.h b/include/field_map_obj.h index ebc445794..e40f09062 100644 --- a/include/field_map_obj.h +++ b/include/field_map_obj.h @@ -5,6 +5,8 @@ // Exported RAM declarations +extern struct MapObject gUnknown_02037350[16]; + // Exported ROM declarations #endif //POKEEMERALD_FIELD_MAP_OBJ_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 9451863b4..193182775 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -21,3 +21,12 @@ void npc_clear_ids_and_state(struct MapObject *mapObject) mapObject->mapGroup = -1; mapObject->mapobj_unk_1C = -1; } + +void npcs_clear_ids_and_state(void) +{ + u8 i; + for (i = 0; i < ARRAY_COUNT(gUnknown_02037350); i ++) + { + npc_clear_ids_and_state(&gUnknown_02037350[i]); + } +} From a08f11cab32bf4e2557f33fd275ec8c7b4f165c9 Mon Sep 17 00:00:00 2001 From: scnorton Date: Wed, 6 Sep 2017 09:29:59 -0400 Subject: [PATCH 004/191] sub_808D438 --- asm/field_map_obj.s | 11 ----------- include/field_map_obj.h | 2 ++ include/field_player_avatar.h | 10 ++++++++++ include/rom4.h | 7 +++++++ src/field_map_obj.c | 17 +++++++++++++++-- 5 files changed, 34 insertions(+), 13 deletions(-) create mode 100644 include/field_player_avatar.h create mode 100644 include/rom4.h diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 0ea219238..321f556f1 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,17 +5,6 @@ .text - thumb_func_start sub_808D438 -sub_808D438: @ 808D438 - push {lr} - bl strange_npc_table_clear - bl npcs_clear_ids_and_state - bl ClearPlayerAvatarInfo - bl sub_808D450 - pop {r0} - bx r0 - thumb_func_end sub_808D438 - thumb_func_start sub_808D450 sub_808D450: @ 808D450 push {r4-r6,lr} diff --git a/include/field_map_obj.h b/include/field_map_obj.h index e40f09062..30490d4c6 100644 --- a/include/field_map_obj.h +++ b/include/field_map_obj.h @@ -9,4 +9,6 @@ extern struct MapObject gUnknown_02037350[16]; // Exported ROM declarations +void sub_808D438(void); + #endif //POKEEMERALD_FIELD_MAP_OBJ_H diff --git a/include/field_player_avatar.h b/include/field_player_avatar.h new file mode 100644 index 000000000..8438add26 --- /dev/null +++ b/include/field_player_avatar.h @@ -0,0 +1,10 @@ +// +// Created by Scott Norton on 9/6/17. +// + +#ifndef POKEEMERALD_FIELD_PLAYER_AVATAR_H +#define POKEEMERALD_FIELD_PLAYER_AVATAR_H + +void ClearPlayerAvatarInfo(void); + +#endif //POKEEMERALD_FIELD_PLAYER_AVATAR_H diff --git a/include/rom4.h b/include/rom4.h new file mode 100644 index 000000000..956160afb --- /dev/null +++ b/include/rom4.h @@ -0,0 +1,7 @@ + +#ifndef POKEEMERALD_ROM4_H +#define POKEEMERALD_ROM4_H + +void strange_npc_table_clear(void); + +#endif //POKEEMERALD_ROM4_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 193182775..fd4a19397 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -1,6 +1,9 @@ // Includes #include "global.h" +#include "sprite.h" +#include "rom4.h" +#include "field_player_avatar.h" #include "field_map_obj.h" // Static struct declarations @@ -9,11 +12,13 @@ // Static ROM declarations +void sub_808D450(void); + // ROM data // Code -void npc_clear_ids_and_state(struct MapObject *mapObject) +/*static*/ void npc_clear_ids_and_state(struct MapObject *mapObject) { memset(mapObject, 0, sizeof(struct MapObject)); mapObject->localId = 0xFF; @@ -22,7 +27,7 @@ void npc_clear_ids_and_state(struct MapObject *mapObject) mapObject->mapobj_unk_1C = -1; } -void npcs_clear_ids_and_state(void) +static void npcs_clear_ids_and_state(void) { u8 i; for (i = 0; i < ARRAY_COUNT(gUnknown_02037350); i ++) @@ -30,3 +35,11 @@ void npcs_clear_ids_and_state(void) npc_clear_ids_and_state(&gUnknown_02037350[i]); } } + +void sub_808D438(void) +{ + strange_npc_table_clear(); + npcs_clear_ids_and_state(); + ClearPlayerAvatarInfo(); + sub_808D450(); +} From 368b0f9ee8500c5f15d511c827d8b59795fab82b Mon Sep 17 00:00:00 2001 From: scnorton Date: Wed, 6 Sep 2017 09:38:38 -0400 Subject: [PATCH 005/191] sub_808D450 --- asm/field_map_obj.s | 77 ----------------------------------------- include/field_map_obj.h | 4 +++ src/field_map_obj.c | 19 +++++++++- 3 files changed, 22 insertions(+), 78 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 321f556f1..ccd56427c 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,83 +5,6 @@ .text - thumb_func_start sub_808D450 -sub_808D450: @ 808D450 - push {r4-r6,lr} - mov r6, r10 - mov r5, r9 - mov r4, r8 - push {r4-r6} - ldr r0, =gFieldEffectObjectTemplatePointers - ldr r0, [r0, 0x54] - mov r9, r0 - movs r1, 0 - movs r2, 0 - movs r3, 0x1F - bl CreateSpriteAtEnd - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gSprites - mov r10, r1 - lsls r4, r0, 4 - adds r4, r0 - lsls r4, 2 - add r4, r10 - ldrb r1, [r4, 0x1] - movs r5, 0x4 - negs r5, r5 - adds r0, r5, 0 - ands r0, r1 - movs r1, 0x1 - mov r8, r1 - mov r1, r8 - orrs r0, r1 - strb r0, [r4, 0x1] - adds r0, r4, 0 - bl InitSpriteAffineAnim - adds r0, r4, 0 - movs r1, 0 - bl StartSpriteAffineAnim - adds r4, 0x3E - ldrb r0, [r4] - movs r6, 0x4 - orrs r0, r6 - strb r0, [r4] - mov r0, r9 - movs r1, 0 - movs r2, 0 - movs r3, 0x1F - bl CreateSpriteAtEnd - lsls r0, 24 - lsrs r0, 24 - lsls r4, r0, 4 - adds r4, r0 - lsls r4, 2 - add r4, r10 - ldrb r0, [r4, 0x1] - ands r5, r0 - mov r0, r8 - orrs r5, r0 - strb r5, [r4, 0x1] - adds r0, r4, 0 - bl InitSpriteAffineAnim - adds r0, r4, 0 - movs r1, 0x1 - bl StartSpriteAffineAnim - adds r4, 0x3E - ldrb r0, [r4] - orrs r0, r6 - strb r0, [r4] - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_808D450 - thumb_func_start sub_808D4F4 sub_808D4F4: @ 808D4F4 push {lr} diff --git a/include/field_map_obj.h b/include/field_map_obj.h index 30490d4c6..d92b28f8c 100644 --- a/include/field_map_obj.h +++ b/include/field_map_obj.h @@ -11,4 +11,8 @@ extern struct MapObject gUnknown_02037350[16]; void sub_808D438(void); +// Exported data declarations + +extern const struct SpriteTemplate *const gFieldEffectObjectTemplatePointers[]; + #endif //POKEEMERALD_FIELD_MAP_OBJ_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index fd4a19397..7b5731e68 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -12,7 +12,7 @@ // Static ROM declarations -void sub_808D450(void); +/*static*/ void sub_808D450(void); // ROM data @@ -43,3 +43,20 @@ void sub_808D438(void) ClearPlayerAvatarInfo(); sub_808D450(); } + +/*static*/ void sub_808D450(void) +{ + u8 spriteIdx; + + spriteIdx = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[21], 0, 0, 31); + gSprites[spriteIdx].oam.affineMode = 1; + InitSpriteAffineAnim(&gSprites[spriteIdx]); + StartSpriteAffineAnim(&gSprites[spriteIdx], 0); + gSprites[spriteIdx].invisible = TRUE; + + spriteIdx = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[21], 0, 0, 31); + gSprites[spriteIdx].oam.affineMode = 1; + InitSpriteAffineAnim(&gSprites[spriteIdx]); + StartSpriteAffineAnim(&gSprites[spriteIdx], 1); + gSprites[spriteIdx].invisible = TRUE; +} From f3f8c5ec2c476aa6db557f30dc830d6b4f9bc741 Mon Sep 17 00:00:00 2001 From: scnorton Date: Wed, 6 Sep 2017 09:42:10 -0400 Subject: [PATCH 006/191] sub_808D4F4 --- asm/field_map_obj.s | 29 ----------------------------- src/field_map_obj.c | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 29 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index ccd56427c..6fd4e2005 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,35 +5,6 @@ .text - thumb_func_start sub_808D4F4 -sub_808D4F4: @ 808D4F4 - push {lr} - movs r1, 0 - ldr r2, =gUnknown_02037350 - ldrb r0, [r2] - b _0808D518 - .pool -_0808D504: - adds r0, r1, 0x1 - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0xF - bhi _0808D51E - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r0, [r0] -_0808D518: - lsls r0, 31 - cmp r0, 0 - bne _0808D504 -_0808D51E: - adds r0, r1, 0 - pop {r1} - bx r1 - thumb_func_end sub_808D4F4 - thumb_func_start GetFieldObjectIdByLocalIdAndMap @ u8 GetFieldObjectIdByLocalIdAndMap(u8 localId, u8 mapId, u8 mapGroupId) GetFieldObjectIdByLocalIdAndMap: @ 808D524 diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 7b5731e68..46cc0585c 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -30,6 +30,7 @@ static void npcs_clear_ids_and_state(void) { u8 i; + for (i = 0; i < ARRAY_COUNT(gUnknown_02037350); i ++) { npc_clear_ids_and_state(&gUnknown_02037350[i]); @@ -60,3 +61,17 @@ void sub_808D438(void) StartSpriteAffineAnim(&gSprites[spriteIdx], 1); gSprites[spriteIdx].invisible = TRUE; } + +u8 sub_808D4F4(void) +{ + u8 i; + + for (i = 0; i < ARRAY_COUNT(gUnknown_02037350); i ++) + { + if (!gUnknown_02037350[i].active) + { + break; + } + } + return i; +} From ea9dabdfab6d2a28d9119c2c23db43903ad4ecae Mon Sep 17 00:00:00 2001 From: scnorton Date: Wed, 6 Sep 2017 09:49:51 -0400 Subject: [PATCH 007/191] TryGetFieldObjectIdByLocalIdAndMap --- asm/field_map_obj.s | 50 ----------------------------------------- include/field_map_obj.h | 2 ++ src/field_map_obj.c | 21 +++++++++++++++++ 3 files changed, 23 insertions(+), 50 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 6fd4e2005..45de31c5d 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,56 +5,6 @@ .text - thumb_func_start GetFieldObjectIdByLocalIdAndMap -@ u8 GetFieldObjectIdByLocalIdAndMap(u8 localId, u8 mapId, u8 mapGroupId) -GetFieldObjectIdByLocalIdAndMap: @ 808D524 - push {lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, 24 - lsrs r1, 24 - lsls r2, 24 - lsrs r2, 24 - cmp r0, 0xFE - bls _0808D53C - bl GetFieldObjectIdByLocalId - b _0808D540 -_0808D53C: - bl GetFieldObjectIdByLocalIdAndMapInternal -_0808D540: - lsls r0, 24 - lsrs r0, 24 - pop {r1} - bx r1 - thumb_func_end GetFieldObjectIdByLocalIdAndMap - - thumb_func_start TryGetFieldObjectIdByLocalIdAndMap -@ bool8 TryGetFieldObjectIdByLocalIdAndMap(u8 localId, u8 mapId, u8 mapGroupId, u8 *fieldObjectId) -TryGetFieldObjectIdByLocalIdAndMap: @ 808D548 - push {r4,lr} - adds r4, r3, 0 - lsls r0, 24 - lsrs r0, 24 - lsls r1, 24 - lsrs r1, 24 - lsls r2, 24 - lsrs r2, 24 - bl GetFieldObjectIdByLocalIdAndMap - strb r0, [r4] - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x10 - beq _0808D56A - movs r0, 0 - b _0808D56C -_0808D56A: - movs r0, 0x1 -_0808D56C: - pop {r4} - pop {r1} - bx r1 - thumb_func_end TryGetFieldObjectIdByLocalIdAndMap - thumb_func_start GetFieldObjectIdByXY @ u8 GetFieldObjectIdByXY(s16 x, s16 y) GetFieldObjectIdByXY: @ 808D574 diff --git a/include/field_map_obj.h b/include/field_map_obj.h index d92b28f8c..cb6eceb69 100644 --- a/include/field_map_obj.h +++ b/include/field_map_obj.h @@ -10,6 +10,8 @@ extern struct MapObject gUnknown_02037350[16]; // Exported ROM declarations void sub_808D438(void); +u8 GetFieldObjectIdByLocalIdAndMap(u8, u8, u8); +bool8 TryGetFieldObjectIdByLocalIdAndMap(u8, u8, u8, u8 *); // Exported data declarations diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 46cc0585c..61b915878 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -13,6 +13,8 @@ // Static ROM declarations /*static*/ void sub_808D450(void); +/*static*/ u8 GetFieldObjectIdByLocalId(u8); +/*static*/ u8 GetFieldObjectIdByLocalIdAndMapInternal(u8, u8, u8); // ROM data @@ -75,3 +77,22 @@ u8 sub_808D4F4(void) } return i; } + +u8 GetFieldObjectIdByLocalIdAndMap(u8 localId, u8 mapId, u8 mapGroupId) +{ + if (localId < 0xff) + { + return GetFieldObjectIdByLocalIdAndMapInternal(localId, mapId, mapGroupId); + } + return GetFieldObjectIdByLocalId(localId); +} + +bool8 TryGetFieldObjectIdByLocalIdAndMap(u8 localId, u8 mapId, u8 mapGroupId, u8 *fieldObjectId) +{ + *fieldObjectId = GetFieldObjectIdByLocalIdAndMap(localId, mapId, mapGroupId); + if (*fieldObjectId == 16) + { + return TRUE; + } + return FALSE; +} From f15191bfc28effef4155b26186bd4236182b88aa Mon Sep 17 00:00:00 2001 From: scnorton Date: Wed, 6 Sep 2017 09:52:31 -0400 Subject: [PATCH 008/191] GetFieldObjectIdByXY --- asm/field_map_obj.s | 41 ----------------------------------------- include/field_map_obj.h | 1 + src/field_map_obj.c | 15 ++++++++++++++- 3 files changed, 15 insertions(+), 42 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 45de31c5d..106fde060 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,47 +5,6 @@ .text - thumb_func_start GetFieldObjectIdByXY -@ u8 GetFieldObjectIdByXY(s16 x, s16 y) -GetFieldObjectIdByXY: @ 808D574 - push {r4-r6,lr} - movs r3, 0 - ldr r5, =gUnknown_02037350 - lsls r0, 16 - asrs r4, r0, 16 - lsls r1, 16 - asrs r1, 16 -_0808D582: - lsls r0, r3, 3 - adds r0, r3 - lsls r0, 2 - adds r2, r0, r5 - ldrb r0, [r2] - lsls r0, 31 - cmp r0, 0 - beq _0808D5A2 - movs r6, 0x10 - ldrsh r0, [r2, r6] - cmp r0, r4 - bne _0808D5A2 - movs r6, 0x12 - ldrsh r0, [r2, r6] - cmp r0, r1 - beq _0808D5AC -_0808D5A2: - adds r0, r3, 0x1 - lsls r0, 24 - lsrs r3, r0, 24 - cmp r3, 0xF - bls _0808D582 -_0808D5AC: - adds r0, r3, 0 - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end GetFieldObjectIdByXY - thumb_func_start GetFieldObjectIdByLocalIdAndMapInternal @ u8 GetFieldObjectIdByLocalIdAndMapInternal(u8 localId, u8 mapId, u8 mapGroupId) GetFieldObjectIdByLocalIdAndMapInternal: @ 808D5B8 diff --git a/include/field_map_obj.h b/include/field_map_obj.h index cb6eceb69..3100f72ff 100644 --- a/include/field_map_obj.h +++ b/include/field_map_obj.h @@ -12,6 +12,7 @@ extern struct MapObject gUnknown_02037350[16]; void sub_808D438(void); u8 GetFieldObjectIdByLocalIdAndMap(u8, u8, u8); bool8 TryGetFieldObjectIdByLocalIdAndMap(u8, u8, u8, u8 *); +u8 GetFieldObjectIdByXY(s16, s16); // Exported data declarations diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 61b915878..88b9d7eab 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -90,9 +90,22 @@ u8 GetFieldObjectIdByLocalIdAndMap(u8 localId, u8 mapId, u8 mapGroupId) bool8 TryGetFieldObjectIdByLocalIdAndMap(u8 localId, u8 mapId, u8 mapGroupId, u8 *fieldObjectId) { *fieldObjectId = GetFieldObjectIdByLocalIdAndMap(localId, mapId, mapGroupId); - if (*fieldObjectId == 16) + if (*fieldObjectId == ARRAY_COUNT(gUnknown_02037350)) { return TRUE; } return FALSE; } + +u8 GetFieldObjectIdByXY(s16 x, s16 y) +{ + u8 i; + for (i = 0; i < ARRAY_COUNT(gUnknown_02037350); i ++) + { + if (gUnknown_02037350[i].active && gUnknown_02037350[i].coords2.x == x && gUnknown_02037350[i].coords2.y == y) + { + break; + } + } + return i; +} From 1087d1c8227fbcdb768bc96b96c969dd2c9cb598 Mon Sep 17 00:00:00 2001 From: scnorton Date: Wed, 6 Sep 2017 10:48:51 -0400 Subject: [PATCH 009/191] GetFieldObjectIdByLocalIdAndMapInternal; rename gUnknown_02037350 to gMapObjects --- asm/battle_setup.s | 10 +- asm/berry.s | 2 +- asm/bike.s | 38 ++--- asm/field_control_avatar.s | 6 +- asm/field_effect.s | 82 +++++----- asm/field_effect_helpers.s | 40 ++--- asm/field_map_obj.s | 238 ++++++++++++------------------ asm/field_player_avatar.s | 96 ++++++------ asm/fldeff_80F9BCC.s | 6 +- asm/fldeff_emotion.s | 6 +- asm/item_use.s | 8 +- asm/link.s | 4 +- asm/load_save.s | 4 +- asm/map_obj_8097404.s | 8 +- asm/map_obj_lock.s | 18 +-- asm/porthole.s | 2 +- asm/rom4.s | 28 ++-- asm/rom6.s | 12 +- asm/rom_80AEFFC.s | 10 +- asm/rom_80C6FA0.s | 4 +- asm/rom_818CFC8.s | 18 +-- asm/rom_81BE66C.s | 30 ++-- asm/scrcmd.s | 10 +- asm/script_pokemon_util_80F87D8.s | 2 +- asm/secret_base.s | 2 +- asm/shop.s | 4 +- asm/trainer_see.s | 14 +- include/field_map_obj.h | 2 - include/global.fieldmap.h | 4 +- src/field_map_obj.c | 29 +++- sym_ewram.txt | 2 +- 31 files changed, 354 insertions(+), 385 deletions(-) diff --git a/asm/battle_setup.s b/asm/battle_setup.s index 1093fa1cb..a07561464 100644 --- a/asm/battle_setup.s +++ b/asm/battle_setup.s @@ -1883,7 +1883,7 @@ SingleTrainerWantsBattle: @ 80B162C ldr r2, =gUnknown_03005DF0 strb r0, [r2] ldr r4, =gScriptLastTalked - ldr r3, =gUnknown_02037350 + ldr r3, =gMapObjects lsls r2, r0, 3 adds r2, r0 lsls r2, 2 @@ -1911,7 +1911,7 @@ TwoTrainersWantBattle: @ 80B1670 ldr r2, =gUnknown_03005DF0 strb r0, [r2] ldr r4, =gScriptLastTalked - ldr r3, =gUnknown_02037350 + ldr r3, =gMapObjects lsls r2, r0, 3 adds r2, r0 lsls r2, 2 @@ -1965,7 +1965,7 @@ sub_80B16D8: @ 80B16D8 lsls r4, r0, 3 adds r4, r0 lsls r4, 2 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects adds r4, r0 ldrb r0, [r4, 0x18] lsls r0, 28 @@ -2341,7 +2341,7 @@ sub_80B1A14: @ 80B1A14 b _080B1AD8 .pool _080B1A44: - ldr r3, =gUnknown_02037350 + ldr r3, =gMapObjects ldr r2, =gUnknown_03006090 ldr r0, =gUnknown_02038BFC ldrb r1, [r0] @@ -2381,7 +2381,7 @@ _080B1A7C: b _080B1AD8 .pool _080B1AAC: - ldr r3, =gUnknown_02037350 + ldr r3, =gMapObjects ldr r2, =gUnknown_03006090 ldr r0, =gUnknown_02038BFC ldrb r1, [r0] diff --git a/asm/berry.s b/asm/berry.s index 54c4333d5..ec8f225cd 100644 --- a/asm/berry.s +++ b/asm/berry.s @@ -1065,7 +1065,7 @@ ResetBerryTreeSparkleFlags: @ 80E1D6C lsls r2, 16 asrs r2, 16 mov r9, r2 - ldr r4, =gUnknown_02037350 + ldr r4, =gMapObjects lsls r3, 16 asrs r3, 16 mov r8, r3 diff --git a/asm/bike.s b/asm/bike.s index 8a064bcf2..00db73ca1 100644 --- a/asm/bike.s +++ b/asm/bike.s @@ -131,7 +131,7 @@ sub_8119238: @ 8119238 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r4, r0, r1 ldrb r1, [r4, 0x1E] adds r0, r5, 0 @@ -166,7 +166,7 @@ sub_8119280: @ 8119280 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r4, r0, r1 ldrb r1, [r4, 0x1E] adds r0, r5, 0 @@ -525,7 +525,7 @@ CheckMovementInputAcroBikeStandingWheelie: @ 8119540 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r1, r0, r1 movs r0, 0 strb r0, [r5, 0x2] @@ -613,7 +613,7 @@ CheckMovementInputAcroBikeBunnyHop: @ 81195E0 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r7, r0, r1 movs r0, 0x2 mov r1, r8 @@ -698,7 +698,7 @@ CheckMovementInputAcroBikeMovingWheelie: @ 8119688 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r7, r0, r1 movs r0, 0x2 mov r9, r0 @@ -802,7 +802,7 @@ CheckMovementInputAcroBikeUnknownMode5: @ 8119764 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r0, r1 ldrb r2, [r0, 0x1] movs r1, 0x3 @@ -868,7 +868,7 @@ sub_81197F4: @ 81197F4 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r5, r0, r1 ldrb r1, [r5, 0x1E] adds r0, r4, 0 @@ -898,7 +898,7 @@ sub_8119830: @ 8119830 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r4, r0, r1 ldrb r1, [r4, 0x1E] adds r0, r5, 0 @@ -966,7 +966,7 @@ sub_81198C0: @ 81198C0 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r5, r0, r1 ldrb r1, [r5, 0x1E] adds r0, r4, 0 @@ -995,7 +995,7 @@ sub_81198FC: @ 81198FC lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r5, r0, r1 ldrb r1, [r5, 0x1E] adds r0, r4, 0 @@ -1024,7 +1024,7 @@ sub_8119938: @ 8119938 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r5, r0, r1 ldrb r1, [r5, 0x1E] adds r0, r4, 0 @@ -1053,7 +1053,7 @@ sub_8119974: @ 8119974 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r5, r0, r1 ldrb r1, [r5, 0x1E] adds r0, r4, 0 @@ -1082,7 +1082,7 @@ sub_81199B0: @ 81199B0 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r5, r0, r1 ldrb r1, [r5, 0x1E] adds r0, r4, 0 @@ -1161,7 +1161,7 @@ _08119A58: lsls r4, r0, 3 adds r4, r0 lsls r4, 2 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects adds r4, r0 movs r0, 0x22 bl PlaySE @@ -1203,7 +1203,7 @@ sub_8119AA4: @ 8119AA4 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r5, r0, r1 ldrb r1, [r5, 0x1E] adds r0, r4, 0 @@ -1272,7 +1272,7 @@ sub_8119B34: @ 8119B34 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r5, r0, r1 ldrb r1, [r5, 0x1E] adds r0, r4, 0 @@ -1341,7 +1341,7 @@ sub_8119BC4: @ 8119BC4 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r5, r0, r1 ldrb r1, [r5, 0x1E] adds r0, r4, 0 @@ -1686,7 +1686,7 @@ sub_8119E38: @ 8119E38 lsls r4, r0, 3 adds r4, r0 lsls r4, 2 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects adds r4, r0 ldrh r1, [r4, 0x10] add r0, sp, 0x4 @@ -1965,7 +1965,7 @@ player_should_look_direction_be_enforced_upon_movement: @ 811A044 lsls r0, 24 cmp r0, 0 beq _0811A078 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects ldr r0, =gUnknown_02037590 ldrb r1, [r0, 0x5] lsls r0, r1, 3 diff --git a/asm/field_control_avatar.s b/asm/field_control_avatar.s index 8b52e3b76..3d989e9e4 100644 --- a/asm/field_control_avatar.s +++ b/asm/field_control_avatar.s @@ -552,7 +552,7 @@ _0809C30E: lsrs r3, r0, 24 cmp r3, 0x10 beq _0809C32E - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects lsls r2, r3, 3 adds r0, r2, r3 lsls r0, 2 @@ -615,7 +615,7 @@ TryGetMapObjectScript: @ 809C384 lsrs r4, r0, 24 cmp r4, 0x10 beq _0809C3B4 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects lsls r2, r4, 3 adds r0, r2, r4 lsls r0, 2 @@ -652,7 +652,7 @@ _0809C3B4: lsrs r4, r0, 24 cmp r4, 0x10 beq _0809C400 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects lsls r2, r4, 3 adds r0, r2, r4 lsls r0, 2 diff --git a/asm/field_effect.s b/asm/field_effect.s index 08efc480b..b073103f3 100644 --- a/asm/field_effect.s +++ b/asm/field_effect.s @@ -2032,7 +2032,7 @@ mapldr_08084390: @ 80B6AA4 ldr r0, =c3_080843F8 movs r1, 0 bl CreateTask - ldr r4, =gUnknown_02037350 + ldr r4, =gMapObjects ldr r3, =gUnknown_02037590 ldrb r1, [r3, 0x5] lsls r0, r1, 3 @@ -2168,7 +2168,7 @@ sub_80B6BCC: @ 80B6BCC lsls r5, r0, 3 adds r5, r0 lsls r5, 2 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects mov r8, r0 add r5, r8 ldrb r0, [r6, 0x4] @@ -2282,7 +2282,7 @@ sub_80B6C90: @ 80B6C90 movs r0, 0x1 strh r0, [r5, 0xA] strh r1, [r5, 0xC] - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects ldrb r0, [r6, 0x5] lsls r1, r0, 3 adds r1, r0 @@ -2314,7 +2314,7 @@ sub_80B6D04: @ 80B6D04 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r6, r0, r1 ldrb r1, [r2, 0x4] lsls r0, r1, 4 @@ -2556,7 +2556,7 @@ sub_80B6EE0: @ 80B6EE0 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r4, r0, r1 adds r0, r4, 0 bl FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive @@ -2833,7 +2833,7 @@ sub_80B7114: @ 80B7114 lsls r4, r0, 3 adds r4, r0 lsls r4, 2 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects adds r4, r0 movs r0, 0x4 bl GetFaceDirectionAnimId @@ -3068,7 +3068,7 @@ sub_80B72F4: @ 80B72F4 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r4, r0, r1 adds r0, r4, 0 bl FieldObjectClearAnimIfSpecialAnimFinished @@ -3143,7 +3143,7 @@ _080B7396: lsls r1, r0, 3 adds r1, r0 lsls r1, 2 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects adds r1, r0 ldr r2, [r2] adds r0, r4, 0 @@ -3392,7 +3392,7 @@ dive_3_unknown: @ 80B7580 lsls r0, 24 cmp r0, 0 bne _080B75C4 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects ldr r0, =gUnknown_02037590 ldrb r1, [r0, 0x5] lsls r0, r1, 3 @@ -3451,7 +3451,7 @@ _080B7604: lsls r1, r0, 3 adds r1, r0 lsls r1, 2 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects adds r1, r0 ldrb r0, [r5, 0x4] lsls r2, r0, 4 @@ -3781,7 +3781,7 @@ _080B78A4: lsls r1, r0, 3 adds r1, r0 lsls r1, 2 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects adds r1, r0 ldrb r0, [r5, 0x4] lsls r2, r0, 4 @@ -4030,7 +4030,7 @@ _080B7AA0: lsls r1, r0, 3 adds r1, r0 lsls r1, 2 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects adds r1, r0 ldrb r0, [r5, 0x4] lsls r2, r0, 4 @@ -4364,7 +4364,7 @@ _080B7D60: lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r5, r0, r1 adds r0, r5, 0 bl FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive @@ -4465,7 +4465,7 @@ mapldr_080859D4: @ 80B7E48 ldr r1, =gUnknown_03005DAC movs r0, 0 str r0, [r1] - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects ldr r0, =gUnknown_02037590 ldrb r1, [r0, 0x5] lsls r0, r1, 3 @@ -4542,7 +4542,7 @@ sub_80B7EE8: @ 80B7EE8 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r6, r0, r1 ldrh r1, [r5, 0xA] movs r2, 0xA @@ -4700,7 +4700,7 @@ sub_80B8034: @ 80B8034 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r5, r0, r1 ldrh r1, [r4, 0xA] movs r2, 0xA @@ -4770,7 +4770,7 @@ sub_80B80C4: @ 80B80C4 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r3, r0, r1 ldrb r1, [r2, 0x4] lsls r0, r1, 4 @@ -4910,7 +4910,7 @@ mapldr_08085D88: @ 80B8200 ldr r1, =gUnknown_03005DAC movs r0, 0 str r0, [r1] - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects ldr r0, =gUnknown_02037590 ldrb r1, [r0, 0x5] lsls r0, r1, 3 @@ -4983,7 +4983,7 @@ sub_80B8280: @ 80B8280 adds r0, r1 negs r0, r0 strh r0, [r2, 0x26] - ldr r3, =gUnknown_02037350 + ldr r3, =gMapObjects ldrb r0, [r5, 0x5] lsls r1, r0, 3 adds r1, r0 @@ -5032,7 +5032,7 @@ sub_80B830C: @ 80B830C lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r6, r0, r1 ldrb r1, [r2, 0x4] lsls r0, r1, 4 @@ -5161,7 +5161,7 @@ sub_80B8410: @ 80B8410 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r5, r0, r1 ldrh r0, [r4, 0xA] subs r0, 0x1 @@ -6348,7 +6348,7 @@ sub_80B8DB4: @ 80B8DB4 adds r0, r6, 0 mov r1, r8 bl PlayerGetDestCoords - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects ldrb r1, [r5, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -6379,7 +6379,7 @@ sub_80B8E14: @ 80B8E14 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r4, r0, r1 adds r0, r4, 0 bl FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive @@ -6415,7 +6415,7 @@ sub_80B8E60: @ 80B8E60 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r0, r1 bl FieldObjectCheckIfSpecialAnimFinishedOrInactive lsls r0, 24 @@ -6454,7 +6454,7 @@ sub_80B8EA8: @ 80B8EA8 lsls r4, r0, 3 adds r4, r0 lsls r4, 2 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects adds r4, r0 movs r0, 0x3 bl GetPlayerAvatarGraphicsIdByStateId @@ -6503,7 +6503,7 @@ sub_80B8F24: @ 80B8F24 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r4, r0, r1 adds r0, r4, 0 bl FieldObjectClearAnimIfSpecialAnimFinished @@ -6834,7 +6834,7 @@ sub_80B9204: @ 80B9204 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r4, r0, r1 adds r0, r4, 0 bl FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive @@ -6875,7 +6875,7 @@ sub_80B925C: @ 80B925C lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r0, r1 bl FieldObjectClearAnimIfSpecialAnimFinished lsls r0, 24 @@ -6911,7 +6911,7 @@ sub_80B92A0: @ 80B92A0 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r5, r0, r1 ldrh r1, [r4, 0x26] movs r0, 0x8 @@ -6960,7 +6960,7 @@ sub_80B92F8: @ 80B92F8 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r0, r1 movs r1, 0x2 bl FieldObjectSetSpecialAnim @@ -6980,7 +6980,7 @@ sub_80B933C: @ 80B933C lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r2, r0, r1 ldrh r1, [r4, 0xC] movs r3, 0xC @@ -7028,7 +7028,7 @@ sub_80B9390: @ 80B9390 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r4, r0, r1 movs r0, 0x3 bl GetPlayerAvatarGraphicsIdByStateId @@ -7092,7 +7092,7 @@ sub_80B9418: @ 80B9418 lsls r4, r0, 3 adds r4, r0 lsls r4, 2 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects adds r4, r0 adds r0, r4, 0 bl FieldObjectClearAnimIfSpecialAnimActive @@ -7587,7 +7587,7 @@ sub_80B9804: @ 80B9804 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r4, r0, r1 adds r0, r4, 0 bl FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive @@ -7678,7 +7678,7 @@ _080B98D0: lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r0, r1 ldrb r0, [r0, 0x4] lsls r4, r0, 4 @@ -7765,7 +7765,7 @@ sub_80B9978: @ 80B9978 lsls r5, r0, 3 adds r5, r0 lsls r5, 2 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects adds r5, r0 ldrb r0, [r5, 0x4] lsls r4, r0, 4 @@ -7815,7 +7815,7 @@ sub_80B99F0: @ 80B99F0 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r0, r1 bl FieldObjectClearAnimIfSpecialAnimFinished lsls r0, 24 @@ -7877,7 +7877,7 @@ sub_80B9A60: @ 80B9A60 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r4, r0, r1 movs r7, 0 ldrh r1, [r5, 0x26] @@ -8119,7 +8119,7 @@ sub_80B9C54: @ 80B9C54 asrs r0, 16 cmp r0, 0x78 ble _080B9CC2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects movs r1, 0x4 ldrsh r0, [r7, r1] lsls r1, r0, 3 @@ -8357,7 +8357,7 @@ sub_80B9E28: @ 80B9E28 lsls r4, r0, 3 adds r4, r0 lsls r4, 2 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects adds r4, r0 movs r0, 0x10 ldrsh r5, [r4, r0] @@ -8507,7 +8507,7 @@ _080B9F7C: lsls r4, r0, 3 adds r4, r0 lsls r4, 2 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects adds r4, r0 ldrh r0, [r5, 0x4] strh r0, [r6, 0x20] diff --git a/asm/field_effect_helpers.s b/asm/field_effect_helpers.s index fc2a8682a..69c67672c 100644 --- a/asm/field_effect_helpers.s +++ b/asm/field_effect_helpers.s @@ -248,7 +248,7 @@ objc_reflection_maybe: @ 81540A8 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r7, r0, r1 ldrb r1, [r7, 0x4] lsls r0, r1, 4 @@ -581,7 +581,7 @@ oei_shadow: @ 8154340 bl GetFieldObjectIdByLocalIdAndMap lsls r0, 24 lsrs r0, 24 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects lsls r1, r0, 3 adds r1, r0 lsls r1, 2 @@ -673,7 +673,7 @@ _08154412: lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r4, r0, r1 ldrb r0, [r4, 0x4] lsls r1, r0, 4 @@ -909,7 +909,7 @@ _08154604: lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r2, r0, r1 ldr r0, [r2, 0x10] ldr r1, [r5, 0x30] @@ -1248,7 +1248,7 @@ _081548B4: lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r2, r0, r1 ldr r0, [r2, 0x10] ldr r1, [r5, 0x30] @@ -1346,7 +1346,7 @@ sub_815496C: @ 815496C lsls r1, r0, 3 adds r1, r0 lsls r1, 2 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects adds r5, r1, r0 ldr r0, =gFieldEffectObjectTemplatePointers ldr r0, [r0, 0x78] @@ -1432,7 +1432,7 @@ sub_8154A10: @ 8154A10 lsls r0, 24 cmp r0, 0 bne _08154A4E - ldr r5, =gUnknown_02037350 + ldr r5, =gMapObjects mov r0, sp ldrb r1, [r0] lsls r0, r1, 3 @@ -1787,7 +1787,7 @@ sub_8154CEC: @ 8154CEC lsls r1, r0, 3 adds r1, r0 lsls r1, 2 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects adds r5, r1, r0 ldr r0, =gFieldEffectObjectTemplatePointers ldr r0, [r0, 0x34] @@ -1881,7 +1881,7 @@ _08154DC0: b _08154E0A _08154DCA: ldr r3, =gSprites - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects mov r0, sp ldrb r1, [r0] lsls r0, r1, 3 @@ -2040,7 +2040,7 @@ sub_8154EFC: @ 8154EFC lsls r1, r0, 3 adds r1, r0 lsls r1, 2 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects adds r6, r1, r0 ldr r0, =gFieldEffectObjectTemplatePointers ldr r0, [r0, 0x34] @@ -2127,7 +2127,7 @@ sub_8154FB4: @ 8154FB4 lsls r0, 24 cmp r0, 0 bne _08154FEE - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects mov r0, sp ldrb r1, [r0] lsls r0, r1, 3 @@ -2248,7 +2248,7 @@ sub_81550B4: @ 81550B4 lsls r1, r0, 3 adds r1, r0 lsls r1, 2 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects adds r5, r1, r0 ldr r0, =gFieldEffectObjectTemplatePointers ldr r0, [r0, 0x7C] @@ -2332,7 +2332,7 @@ sub_8155158: @ 8155158 lsls r0, 24 cmp r0, 0 bne _08155192 - ldr r5, =gUnknown_02037350 + ldr r5, =gMapObjects mov r0, sp ldrb r1, [r0] lsls r0, r1, 3 @@ -2765,7 +2765,7 @@ sub_81554AC: @ 81554AC movs r2, 0x32 ldrsh r1, [r4, r2] bl CurrentMapDrawMetatileAt - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects ldr r0, =gUnknown_02037590 ldrb r1, [r0, 0x5] lsls r0, r1, 3 @@ -2972,7 +2972,7 @@ sub_8155658: @ 8155658 lsls r4, r0, 3 adds r4, r0 lsls r4, 2 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects adds r4, r0 ldrb r0, [r4, 0x4] lsls r5, r0, 4 @@ -3325,7 +3325,7 @@ sub_8155900: @ 8155900 lsls r1, r0, 3 adds r1, r0 lsls r1, 2 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects adds r6, r1, r0 ldr r0, =gFieldEffectObjectTemplatePointers ldr r0, [r0, 0x74] @@ -3419,7 +3419,7 @@ sub_81559BC: @ 81559BC lsls r0, 24 cmp r0, 0 bne _081559F6 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects mov r0, sp ldrb r1, [r0] lsls r0, r1, 3 @@ -3474,7 +3474,7 @@ _08155A46: strh r6, [r4, 0x20] strh r5, [r4, 0x22] ldr r3, =gSprites - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects mov r0, sp ldrb r1, [r0] lsls r0, r1, 3 @@ -3793,7 +3793,7 @@ sub_8155C88: @ 8155C88 adds r0, r5, 0 bl FieldEffectStop _08155CB8: - ldr r4, =gUnknown_02037350 + ldr r4, =gMapObjects mov r0, sp ldrb r1, [r0] lsls r0, r1, 3 @@ -4514,7 +4514,7 @@ _08156212: lsls r0, r7, 3 adds r0, r7 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r4, r0, r1 ldrb r0, [r4] lsls r0, 31 diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 106fde060..01e04f04b 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,52 +5,6 @@ .text - thumb_func_start GetFieldObjectIdByLocalIdAndMapInternal -@ u8 GetFieldObjectIdByLocalIdAndMapInternal(u8 localId, u8 mapId, u8 mapGroupId) -GetFieldObjectIdByLocalIdAndMapInternal: @ 808D5B8 - push {r4-r6,lr} - lsls r0, 24 - lsrs r5, r0, 24 - lsls r1, 24 - lsrs r4, r1, 24 - lsls r2, 24 - lsrs r2, 24 - movs r1, 0 - ldr r6, =gUnknown_02037350 -_0808D5CA: - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - adds r3, r0, r6 - ldrb r0, [r3] - lsls r0, 31 - cmp r0, 0 - beq _0808D5F4 - ldrb r0, [r3, 0x8] - cmp r0, r5 - bne _0808D5F4 - ldrb r0, [r3, 0x9] - cmp r0, r4 - bne _0808D5F4 - ldrb r0, [r3, 0xA] - cmp r0, r2 - bne _0808D5F4 - adds r0, r1, 0 - b _0808D600 - .pool -_0808D5F4: - adds r0, r1, 0x1 - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0xF - bls _0808D5CA - movs r0, 0x10 -_0808D600: - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end GetFieldObjectIdByLocalIdAndMapInternal - thumb_func_start GetFieldObjectIdByLocalId @ u8 GetFieldObjectIdByLocalId(u8 localId) GetFieldObjectIdByLocalId: @ 808D608 @@ -58,7 +12,7 @@ GetFieldObjectIdByLocalId: @ 808D608 lsls r0, 24 lsrs r3, r0, 24 movs r2, 0 - ldr r4, =gUnknown_02037350 + ldr r4, =gMapObjects _0808D612: lsls r0, r2, 3 adds r0, r2 @@ -116,7 +70,7 @@ _0808D66E: lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r4, r0, r1 adds r0, r4, 0 bl npc_clear_ids_and_state @@ -333,7 +287,7 @@ GetAvailableFieldObjectSlot: @ 808D810 lsls r2, 24 lsrs r4, r2, 24 movs r2, 0 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects ldrb r0, [r1] lsls r0, 31 adds r7, r1, 0 @@ -378,7 +332,7 @@ _0808D868: _0808D870: mov r0, r12 strb r2, [r0] - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects _0808D876: lsls r0, r2, 3 adds r0, r2 @@ -452,7 +406,7 @@ RemoveFieldObjectByLocalIdAndMap: @ 808D8C4 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r0, r1 bl RemoveFieldObject _0808D902: @@ -511,7 +465,7 @@ _0808D95C: lsls r0, r4, 3 adds r0, r4 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r0, r1 bl RemoveFieldObject _0808D972: @@ -563,7 +517,7 @@ _0808D9C8: lsls r4, r0, 3 adds r0, r4, r0 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r6, r0, r1 ldrb r0, [r6, 0x5] bl GetFieldObjectGraphicsInfo @@ -618,7 +572,7 @@ _0808DA24: mov r8, r0 cmp r0, 0x40 bne _0808DA64 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects mov r2, r9 adds r1, r4, r2 lsls r1, 2 @@ -802,7 +756,7 @@ SpawnFieldObject: @ 808DB40 .pool _0808DBBC: ldr r4, =gSprites - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects lsls r0, r2, 3 adds r0, r2 lsls r0, 2 @@ -1455,7 +1409,7 @@ _0808E0AA: lsls r0, r3, 3 adds r0, r3 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r2, r0, r1 ldr r0, [r2] ldr r1, =0x00010001 @@ -1555,7 +1509,7 @@ sub_808E16C: @ 808E16C lsrs r5, 16 bl ClearPlayerAvatarInfo movs r6, 0 - ldr r7, =gUnknown_02037350 + ldr r7, =gMapObjects lsls r4, 16 lsls r5, 16 _0808E186: @@ -1623,7 +1577,7 @@ _0808E1EC: lsls r0, r1, 3 add r0, r9 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r6, r0, r1 movs r0, 0 str r0, [sp, 0x20] @@ -1848,7 +1802,7 @@ SetPlayerAvatarFieldObjectIdAndObjectId: @ 808E3C4 ldr r5, =gUnknown_02037590 strb r0, [r5, 0x5] strb r1, [r5, 0x4] - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects lsls r4, r0, 3 adds r4, r0 lsls r4, 2 @@ -2021,7 +1975,7 @@ sub_808E504: @ 808E504 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r0, r1 adds r1, r4, 0 bl FieldObjectSetGraphicsId @@ -2097,7 +2051,7 @@ FieldObjectTurnByLocalIdAndMap: @ 808E594 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r0, r1 adds r1, r4, 0 bl FieldObjectTurn @@ -2118,7 +2072,7 @@ sub_808E5D4: @ 808E5D4 lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 bl FieldObjectTurn pop {r0} @@ -2279,7 +2233,7 @@ npc_by_local_id_and_map_set_field_1_bit_x20: @ 808E6F8 lsls r0, 24 cmp r0, 0 bne _0808E73A - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects mov r0, sp ldrb r0, [r0] lsls r1, r0, 3 @@ -2334,7 +2288,7 @@ sub_808E75C: @ 808E75C lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r0, r1 ldrb r1, [r0] movs r2, 0x4 @@ -2368,7 +2322,7 @@ sub_808E78C: @ 808E78C lsls r2, r0, 3 adds r2, r0 lsls r2, 2 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects adds r2, r0 ldrb r1, [r2, 0x4] lsls r0, r1, 4 @@ -2410,7 +2364,7 @@ sub_808E7E4: @ 808E7E4 lsls r1, r0, 3 adds r1, r0 lsls r1, 2 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects adds r1, r0 ldrb r2, [r1, 0x3] movs r0, 0x5 @@ -2448,7 +2402,7 @@ sub_808E82C: @ 808E82C lsls r0, 24 cmp r0, 0 bne _0808E870 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects mov r0, sp ldrb r1, [r0] lsls r0, r1, 3 @@ -2927,7 +2881,7 @@ sub_808EBA8: @ 808EBA8 lsls r0, r3, 3 adds r0, r3 lsls r0, 2 - ldr r3, =gUnknown_02037350 + ldr r3, =gMapObjects adds r0, r3 movs r3, 0xE0 lsls r3, 11 @@ -2968,7 +2922,7 @@ UpdateFieldObjectCoordsForCameraUpdate: @ 808EC10 cmp r0, 0 beq _0808EC68 movs r3, 0 - ldr r5, =gUnknown_02037350 + ldr r5, =gMapObjects movs r0, 0x4 ldrsh r4, [r2, r0] movs r0, 0x8 @@ -3026,7 +2980,7 @@ GetFieldObjectIdByXYZ: @ 808EC78 lsls r2, 24 lsrs r5, r2, 24 movs r4, 0 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects mov r8, r0 _0808EC90: lsls r0, r4, 3 @@ -3546,7 +3500,7 @@ GetFieldObjectScriptPointerByFieldObjectId: @ 808F01C push {lr} lsls r0, 24 lsrs r0, 24 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects lsls r2, r0, 3 adds r2, r0 lsls r2, 2 @@ -3582,7 +3536,7 @@ GetFieldObjectFlagIdByFieldObjectId: @ 808F058 push {lr} lsls r0, 24 lsrs r0, 24 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects lsls r2, r0, 3 adds r2, r0 lsls r2, 2 @@ -3613,7 +3567,7 @@ sub_808F080: @ 808F080 lsls r0, 24 cmp r0, 0 bne _0808F0B4 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects mov r0, sp ldrb r1, [r0] lsls r0, r1, 3 @@ -3635,7 +3589,7 @@ _0808F0B6: sub_808F0BC: @ 808F0BC lsls r0, 24 lsrs r0, 24 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects lsls r1, r0, 3 adds r1, r0 lsls r1, 2 @@ -3660,7 +3614,7 @@ sub_808F0D4: @ 808F0D4 lsls r0, 24 cmp r0, 0 bne _0808F108 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects mov r0, sp ldrb r1, [r0] lsls r0, r1, 3 @@ -3683,7 +3637,7 @@ _0808F10A: FieldObjectGetBerryTreeId: @ 808F110 lsls r0, 24 lsrs r0, 24 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects lsls r1, r0, 3 adds r1, r0 lsls r1, 2 @@ -3892,7 +3846,7 @@ sub_808F254: @ 808F254 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r0, r1 bl sub_808F208 _0808F282: @@ -3930,7 +3884,7 @@ _0808F2B6: lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r0, r1 ldr r1, =gUnknown_082766A2 bl sub_808F228 @@ -3942,7 +3896,7 @@ _0808F2D4: lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r0, r1 ldr r1, =gUnknown_082766A6 bl sub_808F228 @@ -4070,7 +4024,7 @@ FieldObjectCB_NoMovement1: @ 808F3E0 lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =FieldObjectCB2_NoMovement1 bl FieldObjectStep @@ -4094,7 +4048,7 @@ FieldObjectCB_GoRandomDirections: @ 808F408 lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =FieldObjectCB2_GoRandomDirections bl FieldObjectStep @@ -4833,7 +4787,7 @@ FieldObjectCB_LookRandomDirections: @ 808F944 lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =FieldObjectCB2_LookRandomDirections bl FieldObjectStep @@ -5007,7 +4961,7 @@ FieldObjectCB_RandomlyGoNorthOrSouth: @ 808FA84 lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =FieldObjectCB2_RandomlyGoNorthOrSouth bl FieldObjectStep @@ -5220,7 +5174,7 @@ FieldObjectCB_RandomlyGoEastOrWest: @ 808FC08 lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =FieldObjectCB2_RandomlyGoEastOrWest bl FieldObjectStep @@ -5430,7 +5384,7 @@ FieldObjectCB_FaceFixedDirection: @ 808FD8C lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =FieldObjectCB2_FaceFixedDirection bl FieldObjectStep @@ -5524,7 +5478,7 @@ FieldObjectCB_BerryTree: @ 808FE2C lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r5, r0, r1 ldrh r1, [r4, 0x3C] movs r0, 0x1 @@ -5822,7 +5776,7 @@ FieldObjectCB_RandomlyLookNorthOrSouth: @ 8090050 lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =FieldObjectCB2_RandomlyLookNorthOrSouth bl FieldObjectStep @@ -5990,7 +5944,7 @@ FieldObjectCB_RandomlyLookEastOrWest: @ 8090190 lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =FieldObjectCB2_RandomlyLookEastOrWest bl FieldObjectStep @@ -6158,7 +6112,7 @@ FieldObjectCB_RandomlyLookNorthOrWest: @ 80902D0 lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =FieldObjectCB2_RandomlyLookNorthOrWest bl FieldObjectStep @@ -6326,7 +6280,7 @@ FieldObjectCB_RandomlyLookNorthOrEast: @ 8090410 lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =sub_8090434 bl FieldObjectStep @@ -6494,7 +6448,7 @@ FieldObjectCB_RandomlyLookSouthOrWest: @ 8090550 lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =sub_8090574 bl FieldObjectStep @@ -6662,7 +6616,7 @@ FieldObjectCB_RandomlyLookSouthOrEast: @ 8090690 lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =sub_80906B4 bl FieldObjectStep @@ -6830,7 +6784,7 @@ FieldObjectCB_RandomlyLookNorthOrSouthOrWest: @ 80907D0 lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =sub_80907F4 bl FieldObjectStep @@ -6998,7 +6952,7 @@ FieldObjectCB_RandomlyLookNorthOrSouthOrEast: @ 8090910 lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =sub_8090934 bl FieldObjectStep @@ -7166,7 +7120,7 @@ FieldObjectCB_RandomlyLookNorthOrEastOrWest: @ 8090A50 lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =sub_8090A74 bl FieldObjectStep @@ -7334,7 +7288,7 @@ FieldObjectCB_RandomlyLookSouthOrEastOrWest: @ 8090B90 lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =sub_8090BB4 bl FieldObjectStep @@ -7502,7 +7456,7 @@ FieldObjectCB_LookAroundCounterclockwise: @ 8090CD0 lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =sub_8090CF4 bl FieldObjectStep @@ -7642,7 +7596,7 @@ FieldObjectCB_LookAroundClockwise: @ 8090DD4 lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =sub_8090DF8 bl FieldObjectStep @@ -7781,7 +7735,7 @@ FieldObjectCB_AlternatelyGoInOppositeDirections: @ 8090ED8 lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =sub_8090EFC bl FieldObjectStep @@ -8099,7 +8053,7 @@ FieldObjectCB_GoInDirectionSequence1: @ 8091138 lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =sub_809115C bl FieldObjectStep @@ -8172,7 +8126,7 @@ FieldObjectCB_GoInDirectionSequence2: @ 80911C4 lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =sub_80911E8 bl FieldObjectStep @@ -8245,7 +8199,7 @@ FieldObjectCB_GoInDirectionSequence3: @ 8091250 lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =sub_8091274 bl FieldObjectStep @@ -8318,7 +8272,7 @@ FieldObjectCB_GoInDirectionSequence4: @ 80912DC lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =sub_8091300 bl FieldObjectStep @@ -8391,7 +8345,7 @@ FieldObjectCB_GoInDirectionSequence5: @ 8091368 lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =sub_809138C bl FieldObjectStep @@ -8465,7 +8419,7 @@ FieldObjectCB_GoInDirectionSequence6: @ 80913F4 lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =sub_8091418 bl FieldObjectStep @@ -8538,7 +8492,7 @@ FieldObjectCB_GoInDirectionSequence7: @ 8091480 lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =sub_80914A4 bl FieldObjectStep @@ -8611,7 +8565,7 @@ FieldObjectCB_GoInDirectionSequence8: @ 809150C lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =sub_8091530 bl FieldObjectStep @@ -8684,7 +8638,7 @@ FieldObjectCB_GoInDirectionSequence9: @ 8091598 lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =sub_80915BC bl FieldObjectStep @@ -8757,7 +8711,7 @@ FieldObjectCB_GoInDirectionSequence10: @ 8091624 lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =sub_8091648 bl FieldObjectStep @@ -8830,7 +8784,7 @@ FieldObjectCB_GoInDirectionSequence11: @ 80916B0 lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =sub_80916D4 bl FieldObjectStep @@ -8903,7 +8857,7 @@ FieldObjectCB_GoInDirectionSequence12: @ 809173C lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =sub_8091760 bl FieldObjectStep @@ -8976,7 +8930,7 @@ FieldObjectCB_GoInDirectionSequence13: @ 80917C8 lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =sub_80917EC bl FieldObjectStep @@ -9049,7 +9003,7 @@ FieldObjectCB_GoInDirectionSequence14: @ 8091854 lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =sub_8091878 bl FieldObjectStep @@ -9122,7 +9076,7 @@ FieldObjectCB_GoInDirectionSequence15: @ 80918E0 lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =sub_8091904 bl FieldObjectStep @@ -9195,7 +9149,7 @@ FieldObjectCB_GoInDirectionSequence16: @ 809196C lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =sub_8091990 bl FieldObjectStep @@ -9268,7 +9222,7 @@ FieldObjectCB_GoInDirectionSequence17: @ 80919F8 lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =sub_8091A1C bl FieldObjectStep @@ -9341,7 +9295,7 @@ FieldObjectCB_GoInDirectionSequence18: @ 8091A84 lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =sub_8091AA8 bl FieldObjectStep @@ -9414,7 +9368,7 @@ FieldObjectCB_GoInDirectionSequence19: @ 8091B10 lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =sub_8091B34 bl FieldObjectStep @@ -9487,7 +9441,7 @@ FieldObjectCB_GoInDirectionSequence20: @ 8091B9C lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =sub_8091BC0 bl FieldObjectStep @@ -9560,7 +9514,7 @@ FieldObjectCB_GoInDirectionSequence21: @ 8091C28 lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =sub_8091C4C bl FieldObjectStep @@ -9633,7 +9587,7 @@ FieldObjectCB_GoInDirectionSequence22: @ 8091CB4 lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =sub_8091CD8 bl FieldObjectStep @@ -9706,7 +9660,7 @@ FieldObjectCB_GoInDirectionSequence23: @ 8091D40 lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =sub_8091D64 bl FieldObjectStep @@ -9779,7 +9733,7 @@ FieldObjectCB_GoInDirectionSequence24: @ 8091DCC lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =sub_8091DF0 bl FieldObjectStep @@ -9852,7 +9806,7 @@ FieldObjectCB_CopyPlayer1: @ 8091E58 lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =sub_8091E7C bl FieldObjectStep @@ -9906,7 +9860,7 @@ sub_8091EC0: @ 8091EC0 push {r4-r7,lr} adds r6, r0, 0 adds r7, r1, 0 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects ldr r3, =gUnknown_02037590 ldrb r1, [r3, 0x5] lsls r0, r1, 3 @@ -10629,7 +10583,7 @@ FieldObjectCB_CopyPlayer2: @ 8092494 lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =sub_80924B8 bl FieldObjectStep @@ -10661,7 +10615,7 @@ mss_08062EA4: @ 80924D8 push {r4-r7,lr} adds r6, r0, 0 adds r7, r1, 0 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects ldr r3, =gUnknown_02037590 ldrb r1, [r3, 0x5] lsls r0, r1, 3 @@ -10713,7 +10667,7 @@ FieldObjectCB_TreeDisguise: @ 809253C lsls r1, r0, 3 adds r1, r0 lsls r1, 2 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects adds r4, r1, r0 adds r6, r4, 0 adds r6, 0x21 @@ -10747,7 +10701,7 @@ _08092584: lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r0, r1 ldr r2, =sub_80925AC adds r1, r5, 0 @@ -10776,7 +10730,7 @@ FieldObjectCB_MountainDisguise: @ 80925B8 lsls r1, r0, 3 adds r1, r0 lsls r1, 2 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects adds r4, r1, r0 adds r6, r4, 0 adds r6, 0x21 @@ -10810,7 +10764,7 @@ _08092600: lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r0, r1 ldr r2, =sub_80925AC adds r1, r5, 0 @@ -10828,7 +10782,7 @@ FieldObjectCB_Hidden1: @ 8092628 adds r3, r0, 0 movs r1, 0x3C ldrsh r0, [r3, r1] - ldr r4, =gUnknown_02037350 + ldr r4, =gMapObjects cmp r0, 0 bne _08092668 movs r0, 0x2E @@ -10926,7 +10880,7 @@ FieldObjectCB_WalkInPlace1: @ 80926D4 lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =sub_80926F8 bl FieldObjectStep @@ -10985,7 +10939,7 @@ FieldObjectCB_WalkInPlace4: @ 8092744 lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =sub_8092768 bl FieldObjectStep @@ -11044,7 +10998,7 @@ FieldObjectCB_WalkInPlace2: @ 80927B4 lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =sub_80927D8 bl FieldObjectStep @@ -11104,7 +11058,7 @@ FieldObjectCB_WalkInPlace3: @ 8092824 lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =sub_8092848 bl FieldObjectStep @@ -11163,7 +11117,7 @@ FieldObjectCB_Hidden2: @ 8092894 lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =sub_80928B8 bl FieldObjectStep @@ -11985,7 +11939,7 @@ _08092E2E: lsls r0, r4, 3 adds r0, r4 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r2, r0, r1 ldrb r0, [r2] lsls r0, 31 @@ -12055,7 +12009,7 @@ sub_8092E9C: @ 8092E9C cmp r0, 0 bne _08092EE8 ldr r3, =gSprites - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects mov r0, sp ldrb r1, [r0] lsls r0, r1, 3 @@ -12099,7 +12053,7 @@ sub_8092EF0: @ 8092EF0 cmp r0, 0 bne _08092F2E ldr r3, =gSprites - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects mov r0, sp ldrb r1, [r0] lsls r0, r1, 3 @@ -16723,7 +16677,7 @@ sub_8094F38: @ 8094F38 ldrsh r0, [r5, r1] movs r2, 0x12 ldrsh r1, [r5, r2] - ldr r4, =gUnknown_02037350 + ldr r4, =gMapObjects mov r2, sp ldrb r2, [r2] lsls r3, r2, 3 @@ -16769,7 +16723,7 @@ sub_8094F94: @ 8094F94 ldrsh r0, [r5, r1] movs r2, 0x12 ldrsh r1, [r5, r2] - ldr r4, =gUnknown_02037350 + ldr r4, =gMapObjects mov r2, sp ldrb r2, [r2] lsls r3, r2, 3 diff --git a/asm/field_player_avatar.s b/asm/field_player_avatar.s index e88eaa650..9a5cc323c 100644 --- a/asm/field_player_avatar.s +++ b/asm/field_player_avatar.s @@ -15,7 +15,7 @@ FieldObjectCB_NoMovement2: @ 808A998 lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldr r2, =FieldObjectCB2_NoMovement2 bl FieldObjectStep @@ -48,7 +48,7 @@ player_step: @ 808A9C0 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r5, r0, r1 adds r0, r5, 0 bl sub_808C280 @@ -240,7 +240,7 @@ GetForcedMovementByMetatileBehavior: @ 808AB38 ands r0, r1 cmp r0, 0 bne _0808AB8A - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects ldrb r1, [r3, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -290,7 +290,7 @@ ForcedMovement_None: @ 808AB94 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r0, r1 ldrb r2, [r0, 0x1] movs r1, 0x3 @@ -386,7 +386,7 @@ DoForcedMovementInCurrentDirection: @ 808AC58 lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 ldrb r2, [r0, 0x1] movs r3, 0x4 @@ -528,7 +528,7 @@ ForcedMovement_Slide: @ 808AD60 lsls r2, r3, 3 adds r2, r3 lsls r2, 2 - ldr r3, =gUnknown_02037350 + ldr r3, =gMapObjects adds r2, r3 ldrb r3, [r2, 0x1] movs r4, 0x4 @@ -623,7 +623,7 @@ ForcedMovement_MuddySlope: @ 808AE10 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r4, r0, r1 ldrb r1, [r4, 0x18] movs r0, 0xF0 @@ -809,7 +809,7 @@ _0808AF68: lsls r0, 24 cmp r0, 0 beq _0808AFB0 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects ldrb r1, [r4, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -848,7 +848,7 @@ CheckForPlayerAvatarCollision: @ 808AFBC lsls r4, r0, 3 adds r4, r0 lsls r4, 2 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects adds r4, r0 ldrh r1, [r4, 0x10] add r0, sp, 0x4 @@ -899,7 +899,7 @@ sub_808B028: @ 808B028 lsls r4, r0, 3 adds r4, r0 lsls r4, 2 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects adds r4, r0 ldrh r1, [r4, 0x10] add r0, sp, 0x4 @@ -1187,7 +1187,7 @@ sub_808B238: @ 808B238 lsrs r6, r0, 24 cmp r6, 0x10 beq _0808B2D8 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects lsls r1, r6, 3 adds r1, r6 lsls r1, 2 @@ -1290,7 +1290,7 @@ IsPlayerCollidingWithFarawayIslandMew: @ 808B324 lsls r1, r2, 3 adds r1, r2 lsls r1, 2 - ldr r5, =gUnknown_02037350 + ldr r5, =gMapObjects adds r3, r1, r5 ldrh r2, [r3, 0x10] mov r1, sp @@ -1401,7 +1401,7 @@ _0808B3F4: lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r0, r1 ldr r1, [r2] bl _call_via_r1 @@ -1621,7 +1621,7 @@ _0808B5B6: thumb_func_start player_is_anim_in_certain_ranges player_is_anim_in_certain_ranges: @ 808B5BC push {lr} - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects ldr r0, =gUnknown_02037590 ldrb r1, [r0, 0x5] lsls r0, r1, 3 @@ -1696,7 +1696,7 @@ PlayerIsAnimActive: @ 808B63C lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r0, r1 bl FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive lsls r0, 24 @@ -1715,7 +1715,7 @@ PlayerCheckIfAnimFinishedOrInactive: @ 808B660 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r0, r1 bl FieldObjectCheckIfSpecialAnimFinishedOrInactive lsls r0, 24 @@ -1727,7 +1727,7 @@ PlayerCheckIfAnimFinishedOrInactive: @ 808B660 thumb_func_start player_set_x22 player_set_x22: @ 808B684 - ldr r3, =gUnknown_02037350 + ldr r3, =gMapObjects ldr r1, =gUnknown_02037590 ldrb r2, [r1, 0x5] lsls r1, r2, 3 @@ -1742,7 +1742,7 @@ player_set_x22: @ 808B684 thumb_func_start player_get_x22 player_get_x22: @ 808B6A0 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects ldr r0, =gUnknown_02037590 ldrb r1, [r0, 0x5] lsls r0, r1, 3 @@ -1766,7 +1766,7 @@ sub_808B6BC: @ 808B6BC lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r0, r2 bl FieldObjectForceSetSpecialAnim pop {r0} @@ -1793,7 +1793,7 @@ player_npc_set_state_and_x22_etc: @ 808B6E4 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r0, r1 adds r1, r5, 0 bl FieldObjectSetSpecialAnim @@ -2013,7 +2013,7 @@ _0808B872: lsls r0, 24 cmp r0, 0 beq _0808B89A - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects ldrb r1, [r4, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -2219,7 +2219,7 @@ PlayCollisionSoundIfNotFacingWarp: @ 808B9EC sub sp, 0x4 lsls r0, 24 lsrs r4, r0, 24 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects ldr r0, =gUnknown_02037590 ldrb r1, [r0, 0x5] lsls r0, r1, 3 @@ -2275,7 +2275,7 @@ GetXYCoordsOneStepInFrontOfPlayer: @ 808BA68 push {r4,r5,lr} adds r4, r0, 0 adds r5, r1, 0 - ldr r3, =gUnknown_02037350 + ldr r3, =gMapObjects ldr r2, =gUnknown_02037590 ldrb r1, [r2, 0x5] lsls r0, r1, 3 @@ -2307,7 +2307,7 @@ GetXYCoordsOneStepInFrontOfPlayer: @ 808BA68 @ void PlayerGetDestCoords(u16 *x, u16 *y) PlayerGetDestCoords: @ 808BAAC push {r4,r5,lr} - ldr r5, =gUnknown_02037350 + ldr r5, =gMapObjects ldr r4, =gUnknown_02037590 ldrb r3, [r4, 0x5] lsls r2, r3, 3 @@ -2339,7 +2339,7 @@ plaer_get_pos_including_state_based_drift: @ 808BADC lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r3, r0, r1 ldrb r1, [r3] movs r0, 0xC0 @@ -2465,7 +2465,7 @@ _0808BC30: thumb_func_start player_get_direction_lower_nybble @ u8 player_get_direction_lower_nybble() player_get_direction_lower_nybble: @ 808BC38 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects ldr r0, =gUnknown_02037590 ldrb r1, [r0, 0x5] lsls r0, r1, 3 @@ -2482,7 +2482,7 @@ player_get_direction_lower_nybble: @ 808BC38 thumb_func_start player_get_direction_upper_nybble @ u8 player_get_direction_upper_nybble() player_get_direction_upper_nybble: @ 808BC58 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects ldr r0, =gUnknown_02037590 ldrb r1, [r0, 0x5] lsls r0, r1, 3 @@ -2498,7 +2498,7 @@ player_get_direction_upper_nybble: @ 808BC58 thumb_func_start PlayerGetZCoord @ u8 PlayerGetZCoord() PlayerGetZCoord: @ 808BC74 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects ldr r0, =gUnknown_02037590 ldrb r1, [r0, 0x5] lsls r0, r1, 3 @@ -2521,7 +2521,7 @@ sub_808BC90: @ 808BC90 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r0, r1 lsls r3, 16 asrs r3, 16 @@ -2578,7 +2578,7 @@ sub_808BCF4: @ 808BCF4 lsls r4, r0, 3 adds r4, r0 lsls r4, 2 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects adds r4, r0 adds r0, r4, 0 bl npc_clear_strange_bits @@ -2809,7 +2809,7 @@ IsPlayerFacingSurfableFishableWater: @ 808BE74 lsls r4, r0, 3 adds r4, r0 lsls r4, 2 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects adds r4, r0 ldrh r1, [r4, 0x10] mov r0, sp @@ -3060,7 +3060,7 @@ InitPlayerAvatar: @ 808BFE0 lsls r4, r5, 3 adds r4, r5 lsls r4, 2 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects adds r4, r0 ldrb r0, [r4, 0x2] movs r1, 0x1 @@ -3097,7 +3097,7 @@ sub_808C0A8: @ 808C0A8 push {r4-r6,lr} lsls r0, 24 lsrs r4, r0, 24 - ldr r6, =gUnknown_02037350 + ldr r6, =gMapObjects ldr r5, =gUnknown_02037590 ldrb r0, [r5, 0x5] lsls r1, r0, 3 @@ -3152,7 +3152,7 @@ sub_808C114: @ 808C114 lsls r4, r0, 3 adds r4, r0 lsls r4, 2 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects adds r4, r0 movs r0, 0x5 bl GetPlayerAvatarGraphicsIdByStateId @@ -3186,7 +3186,7 @@ sub_808C15C: @ 808C15C lsls r4, r0, 3 adds r4, r0 lsls r4, 2 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects adds r4, r0 movs r0, 0x6 bl GetPlayerAvatarGraphicsIdByStateId @@ -3227,7 +3227,7 @@ sub_808C1B4: @ 808C1B4 lsls r4, r0, 3 adds r4, r0 lsls r4, 2 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects adds r4, r0 movs r0, 0x2 bl GetPlayerAvatarGraphicsIdByStateId @@ -3276,7 +3276,7 @@ sub_808C228: @ 808C228 lsls r4, r0, 3 adds r4, r0 lsls r4, 2 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects adds r4, r0 movs r0, 0x7 bl GetPlayerAvatarGraphicsIdByStateId @@ -3414,7 +3414,7 @@ taskFF_bump_boulder: @ 808C34C lsrs r0, 24 ldr r6, =gUnknown_08497530 ldr r2, =gTasks - ldr r5, =gUnknown_02037350 + ldr r5, =gMapObjects lsls r1, r0, 2 adds r1, r0 lsls r1, 3 @@ -3625,7 +3625,7 @@ _0808C50A: lsls r1, r0, 3 adds r1, r0 lsls r1, 2 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects adds r1, r0 ldr r2, [r2] adds r0, r4, 0 @@ -3726,7 +3726,7 @@ _0808C5E2: lsls r1, r0, 3 adds r1, r0 lsls r1, 2 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects adds r1, r0 ldr r2, [r2] adds r0, r4, 0 @@ -3936,7 +3936,7 @@ taskFF_0805D1D4: @ 808C7A8 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r5, r0, r1 adds r0, r5, 0 bl FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive @@ -3983,7 +3983,7 @@ sub_808C814: @ 808C814 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r4, r0, r1 adds r0, r4, 0 bl FieldObjectClearAnimIfSpecialAnimFinished @@ -4127,7 +4127,7 @@ fish1: @ 808C918 ldrh r1, [r6] adds r1, r0 strh r1, [r5, 0x22] - ldr r3, =gUnknown_02037350 + ldr r3, =gMapObjects ldr r2, =gUnknown_02037590 ldrb r1, [r2, 0x5] lsls r0, r1, 3 @@ -4579,7 +4579,7 @@ _0808CCBC: lsls r4, r0, 3 adds r4, r0 lsls r4, 2 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects mov r8, r0 add r4, r8 ldrh r1, [r5, 0x24] @@ -4792,7 +4792,7 @@ fishE: @ 808CE8C lsls r4, r0, 3 adds r4, r0 lsls r4, 2 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects mov r8, r0 add r4, r8 ldrh r1, [r6, 0x24] @@ -4984,7 +4984,7 @@ _0808D03A: ands r0, r1 cmp r0, 0 beq _0808D05E - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects ldrb r1, [r3, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -5037,7 +5037,7 @@ sub_808D094: @ 808D094 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r4, r0, r1 ldrb r1, [r4, 0x4] lsls r0, r1, 4 @@ -5217,7 +5217,7 @@ sub_808D1FC: @ 808D1FC lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r4, r0, r1 ldrb r1, [r4, 0x4] lsls r0, r1, 4 diff --git a/asm/fldeff_80F9BCC.s b/asm/fldeff_80F9BCC.s index ac1cd5a82..465f64db3 100644 --- a/asm/fldeff_80F9BCC.s +++ b/asm/fldeff_80F9BCC.s @@ -1722,7 +1722,7 @@ _080FA9CA: sub_80FA9D0: @ 80FA9D0 push {r4,lr} sub sp, 0x4 - ldr r3, =gUnknown_02037350 + ldr r3, =gMapObjects ldr r2, =gUnknown_02037590 ldrb r1, [r2, 0x5] lsls r0, r1, 3 @@ -2312,7 +2312,7 @@ sub_80FAEF0: @ 80FAEF0 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r4, r0, r1 adds r0, r4, 0 bl FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive @@ -2362,7 +2362,7 @@ sub_80FAF64: @ 80FAF64 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r5, r0, r1 adds r0, r5, 0 bl FieldObjectClearAnimIfSpecialAnimFinished diff --git a/asm/fldeff_emotion.s b/asm/fldeff_emotion.s index 845f5618f..f8b66da0d 100644 --- a/asm/fldeff_emotion.s +++ b/asm/fldeff_emotion.s @@ -167,7 +167,7 @@ _080B4756: bl FieldEffectStop b _080B47B2 _080B4764: - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects mov r0, sp ldrb r1, [r0] lsls r0, r1, 3 @@ -274,7 +274,7 @@ sub_80B4808: @ 80B4808 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r0, r1 ldrb r0, [r0, 0x18] lsls r0, 28 @@ -301,7 +301,7 @@ _080B4870: lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r0, r1 ldrb r0, [r0, 0x18] lsls r0, 28 diff --git a/asm/item_use.s b/asm/item_use.s index 4f9e9e65a..cd1c38215 100644 --- a/asm/item_use.s +++ b/asm/item_use.s @@ -1306,7 +1306,7 @@ sub_80FDA24: @ 80FDA24 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r4, =gUnknown_02037350 + ldr r4, =gMapObjects adds r0, r4 bl FieldObjectClearAnimIfSpecialAnimFinished movs r0, 0xFF @@ -1356,7 +1356,7 @@ sub_80FDA94: @ 80FDA94 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r0, r1 bl FieldObjectCheckIfSpecialAnimFinishedOrInactive lsls r0, 24 @@ -1395,7 +1395,7 @@ sub_80FDADC: @ 80FDADC lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r0, r1 bl FieldObjectCheckIfSpecialAnimFinishedOrInactive lsls r0, 24 @@ -1759,7 +1759,7 @@ sub_80FDE2C: @ 80FDE2C lsrs r2, r0, 24 cmp r2, 0x10 beq _080FDE68 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects lsls r1, r2, 3 adds r1, r2 lsls r1, 2 diff --git a/asm/link.s b/asm/link.s index 39cf6ba5e..022922164 100644 --- a/asm/link.s +++ b/asm/link.s @@ -31367,7 +31367,7 @@ sub_8019AD8: @ 8019AD8 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r4, r0, r1 adds r0, r4, 0 bl FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive @@ -31413,7 +31413,7 @@ sub_8019B3C: @ 8019B3C lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r4, r0, r1 adds r0, r4, 0 bl FieldObjectClearAnimIfSpecialAnimFinished diff --git a/asm/load_save.s b/asm/load_save.s index 344e05147..589e001c1 100644 --- a/asm/load_save.s +++ b/asm/load_save.s @@ -332,7 +332,7 @@ save_serialize_npcs: @ 8076E1C movs r5, 0xA3 lsls r5, 4 mov r8, r5 - ldr r4, =gUnknown_02037350 + ldr r4, =gMapObjects movs r3, 0 movs r2, 0xF _08076E32: @@ -370,7 +370,7 @@ save_deserialize_npcs: @ 8076E64 movs r5, 0xA3 lsls r5, 4 mov r8, r5 - ldr r4, =gUnknown_02037350 + ldr r4, =gMapObjects movs r3, 0 movs r2, 0xF _08076E7A: diff --git a/asm/map_obj_8097404.s b/asm/map_obj_8097404.s index 404ae3675..50284a013 100644 --- a/asm/map_obj_8097404.s +++ b/asm/map_obj_8097404.s @@ -87,7 +87,7 @@ _0809748E: player_bitmagic: @ 8097494 push {r4,r5,lr} movs r4, 0 - ldr r5, =gUnknown_02037350 + ldr r5, =gMapObjects _0809749A: lsls r0, r4, 3 adds r0, r4 @@ -121,7 +121,7 @@ sub_80974D0: @ 80974D0 lsls r0, 24 lsrs r5, r0, 24 movs r4, 0 - ldr r6, =gUnknown_02037350 + ldr r6, =gMapObjects _080974DA: cmp r4, r5 beq _080974FC @@ -209,7 +209,7 @@ _0809756C: sub_809757C: @ 809757C push {r4,r5,lr} movs r4, 0 - ldr r5, =gUnknown_02037350 + ldr r5, =gMapObjects _08097582: lsls r0, r4, 3 adds r0, r4 @@ -1757,7 +1757,7 @@ sub_8098074: @ 8098074 lsls r1, 24 lsrs r5, r1, 24 movs r4, 0 - ldr r7, =gUnknown_02037350 + ldr r7, =gMapObjects _08098082: cmp r4, r6 beq _080980A8 diff --git a/asm/map_obj_lock.s b/asm/map_obj_lock.s index 7547f23c0..6cb8c508e 100644 --- a/asm/map_obj_lock.s +++ b/asm/map_obj_lock.s @@ -97,7 +97,7 @@ _0809842A: ldrsh r0, [r5, r1] cmp r0, 0 bne _08098452 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects ldr r0, =gUnknown_03005DF0 ldrb r1, [r0] lsls r0, r1, 3 @@ -160,7 +160,7 @@ sub_80984A0: @ 80984A0 bl CreateTask lsls r0, 24 lsrs r5, r0, 24 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects ldrb r1, [r4] lsls r0, r1, 3 adds r0, r1 @@ -199,7 +199,7 @@ sub_80984F4: @ 80984F4 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r0, r1 bl FieldObjectClearAnimIfSpecialAnimFinished bl sub_80D338C @@ -212,7 +212,7 @@ sub_80984F4: @ 80984F4 thumb_func_start sub_8098524 sub_8098524: @ 8098524 push {r4,lr} - ldr r4, =gUnknown_02037350 + ldr r4, =gMapObjects ldr r0, =gUnknown_03005DF0 ldrb r1, [r0] lsls r0, r1, 3 @@ -254,7 +254,7 @@ sub_8098574: @ 8098574 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r0, r1 ldr r1, =gScriptFacing ldrb r1, [r1] @@ -272,7 +272,7 @@ sub_809859C: @ 809859C lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r0, r1 bl FieldObjectClearAnimIfSpecialAnimActive pop {r0} @@ -307,7 +307,7 @@ _080985E8: ldrsh r0, [r5, r1] cmp r0, 0 bne _0809860C - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects lsls r1, r7, 3 adds r1, r7 lsls r1, 2 @@ -374,7 +374,7 @@ sub_8098630: @ 8098630 mov r1, r9 adds r6, r0, r1 strh r4, [r6, 0xC] - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects mov r8, r2 lsls r0, r4, 3 adds r0, r4 @@ -429,7 +429,7 @@ _080986E0: lsls r0, 3 adds r5, r0, r1 strh r4, [r5, 0xC] - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects lsls r0, r4, 3 adds r0, r4 lsls r0, 2 diff --git a/asm/porthole.s b/asm/porthole.s index 2ba6ec83a..a1bcff977 100644 --- a/asm/porthole.s +++ b/asm/porthole.s @@ -231,7 +231,7 @@ _080FB75E: sub_80FB768: @ 80FB768 push {lr} bl sub_80FB6EC - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects ldr r0, =gUnknown_02037590 ldrb r1, [r0, 0x5] lsls r0, r1, 3 diff --git a/asm/rom4.s b/asm/rom4.s index 2f047b639..10d607683 100644 --- a/asm/rom4.s +++ b/asm/rom4.s @@ -4395,7 +4395,7 @@ sub_8086A68: @ 8086A68 thumb_func_start sub_8086A80 sub_8086A80: @ 8086A80 push {lr} - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects ldr r3, =gUnknown_02037590 ldrb r1, [r3, 0x5] lsls r0, r1, 3 @@ -6030,7 +6030,7 @@ sub_80876F0: @ 80876F0 lsls r5, r6, 3 adds r5, r6 lsls r5, 2 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects adds r5, r0 adds r0, r4, 0 bl sub_80876C4 @@ -6128,7 +6128,7 @@ sub_80877DC: @ 80877DC lsls r1, r0, 3 adds r1, r0 lsls r1, 2 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects adds r1, r0 strb r2, [r1, 0x19] _080877FE: @@ -6148,7 +6148,7 @@ sub_808780C: @ 808780C lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r4, r0, r1 ldrb r0, [r4, 0x4] cmp r0, 0x40 @@ -6183,7 +6183,7 @@ sub_8087858: @ 8087858 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r0, r1 ldrb r0, [r0, 0x4] bx lr @@ -6200,7 +6200,7 @@ sub_8087878: @ 8087878 lsls r0, r3, 3 adds r0, r3 lsls r0, 2 - ldr r3, =gUnknown_02037350 + ldr r3, =gMapObjects adds r0, r3 ldrh r3, [r0, 0x10] strh r3, [r1] @@ -6220,7 +6220,7 @@ sub_80878A0: @ 80878A0 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r0, r1 ldrb r0, [r0, 0x19] bx lr @@ -6237,7 +6237,7 @@ sub_80878C0: @ 80878C0 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r0, r1 ldrb r0, [r0, 0xB] lsls r0, 28 @@ -6256,7 +6256,7 @@ sub_80878E4: @ 80878E4 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r0, r1 adds r0, 0x21 movs r1, 0 @@ -6292,7 +6292,7 @@ _0808792E: lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r1, r0, r1 movs r6, 0x10 ldrsh r0, [r1, r6] @@ -6332,7 +6332,7 @@ sub_808796C: @ 808796C lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r6, r0, r1 ldrb r0, [r5] cmp r0, 0 @@ -6584,7 +6584,7 @@ npc_080587EC: @ 8087B40 mov r12, r2 lsls r3, 16 movs r4, 0 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects mov r9, r0 lsrs r2, r3, 16 mov r10, r2 @@ -6660,7 +6660,7 @@ sub_8087BCC: @ 8087BCC lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r4, r0, r1 ldrb r0, [r2] cmp r0, 0 @@ -6748,7 +6748,7 @@ sub_8087C8C: @ 8087C8C lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r6, r0, r1 ldrh r0, [r6, 0xC] strh r0, [r5, 0x20] diff --git a/asm/rom6.s b/asm/rom6.s index 9ded5bf72..a0f23d720 100644 --- a/asm/rom6.s +++ b/asm/rom6.s @@ -23,7 +23,7 @@ npc_before_player_of_type: @ 8135424 bl GetFieldObjectIdByXYZ lsls r0, 24 lsrs r0, 24 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects lsls r1, r0, 3 adds r1, r0 lsls r1, 2 @@ -75,7 +75,7 @@ task08_080C9820: @ 813549C lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r4, r0, r1 adds r0, r4, 0 bl FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive @@ -132,7 +132,7 @@ sub_813552C: @ 813552C lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r0, r1 bl FieldObjectCheckIfSpecialAnimFinishedOrInactive lsls r0, 24 @@ -196,7 +196,7 @@ _081355B8: lsls r4, r0, 3 adds r4, r0 lsls r4, 2 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects adds r4, r0 bl GetPlayerAvatarGraphicsIdByCurrentState adds r1, r0, 0 @@ -5673,7 +5673,7 @@ _08138454: lsrs r2, r0, 24 cmp r2, 0x10 beq _081384E6 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects lsls r0, r2, 3 adds r0, r2 lsls r0, 2 @@ -7257,7 +7257,7 @@ SpawnScriptFieldObject: @ 8139158 bl SpawnSpecialFieldObjectParametrized lsls r0, 24 lsrs r0, 24 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects lsls r1, r0, 3 adds r1, r0 lsls r1, 2 diff --git a/asm/rom_80AEFFC.s b/asm/rom_80AEFFC.s index 8d28c089d..2c7fe2898 100644 --- a/asm/rom_80AEFFC.s +++ b/asm/rom_80AEFFC.s @@ -599,7 +599,7 @@ _080AF4A4: lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r0, r1 movs r1, 0x8 bl FieldObjectSetSpecialAnim @@ -630,7 +630,7 @@ _080AF4DC: lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r0, r1 bl FieldObjectClearAnimIfSpecialAnimFinished movs r0, 0x3 @@ -719,7 +719,7 @@ _080AF5A2: lsls r4, r0, 3 adds r4, r0 lsls r4, 2 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects adds r4, r0 bl player_get_direction_lower_nybble lsls r0, 24 @@ -1370,7 +1370,7 @@ _080AFB26: lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r4, =gUnknown_02037350 + ldr r4, =gMapObjects adds r0, r4 bl FieldObjectClearAnimIfSpecialAnimActive movs r0, 0xFF @@ -1414,7 +1414,7 @@ _080AFB6C: lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r0, r1 bl FieldObjectClearAnimIfSpecialAnimFinished movs r0, 0 diff --git a/asm/rom_80C6FA0.s b/asm/rom_80C6FA0.s index 440b576d2..17399a49d 100644 --- a/asm/rom_80C6FA0.s +++ b/asm/rom_80C6FA0.s @@ -23955,7 +23955,7 @@ _080D3630: lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r0, r1 bl npc_sync_anim_pause_bits _080D3646: @@ -24023,7 +24023,7 @@ sub_80D36A4: @ 80D36A4 lsls r0, r2, 3 adds r0, r2 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r4, r0, r1 adds r0, r4, 0 bl FieldObjectIsSpecialAnimActive diff --git a/asm/rom_818CFC8.s b/asm/rom_818CFC8.s index fdf71043e..37e0802be 100644 --- a/asm/rom_818CFC8.s +++ b/asm/rom_818CFC8.s @@ -17486,7 +17486,7 @@ sub_81963F0: @ 81963F0 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r0, r1 bl FieldObjectClearAnimIfSpecialAnimFinished bl sub_80D338C @@ -53023,7 +53023,7 @@ _081A896E: lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r0, r1 bl FieldObjectClearAnimIfSpecialAnimFinished bl sub_80D338C @@ -53321,7 +53321,7 @@ _081A8BB4: bne _081A8BDC b _081A8D32 _081A8BDC: - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects lsls r1, r2, 3 adds r1, r2 lsls r1, 2 @@ -54324,7 +54324,7 @@ sub_81A9424: @ 81A9424 lsls r1, 4 adds r1, r0 mov r8, r1 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects ldr r0, =gUnknown_03005DF0 ldrb r1, [r0] lsls r0, r1, 3 @@ -54372,7 +54372,7 @@ _081A9488: mov r9, r0 _081A94AE: ldr r3, =gUnknown_08613ED8 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects ldr r0, =gUnknown_03005DF0 ldrb r1, [r0] lsls r0, r1, 3 @@ -54984,7 +54984,7 @@ sub_81A9998: @ 81A9998 mov r8, r0 ldr r1, =0x0000028e mov r12, r1 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects mov r9, r0 _081A99CC: movs r2, 0 @@ -55125,7 +55125,7 @@ GetBattlePyramidTrainerFlag: @ 81A9AC4 ldr r1, =0x00000e2a adds r2, r1 ldr r4, =gBitTable - ldr r3, =gUnknown_02037350 + ldr r3, =gMapObjects lsls r1, r0, 3 adds r1, r0 lsls r1, 2 @@ -55179,7 +55179,7 @@ sub_81A9B44: @ 81A9B44 lsls r0, 16 lsrs r5, r0, 16 movs r3, 0 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects mov r12, r0 ldr r6, =gUnknown_03005DF0 ldr r1, =gSaveBlock1Ptr @@ -86877,4 +86877,4 @@ GetGlyphWidthFont6: @ 81BA6CC thumb_func_end GetGlyphWidthFont6 - .align 2, 0 @ Don't pad with nop. \ No newline at end of file + .align 2, 0 @ Don't pad with nop. diff --git a/asm/rom_81BE66C.s b/asm/rom_81BE66C.s index 297252c7e..c1b5f9142 100644 --- a/asm/rom_81BE66C.s +++ b/asm/rom_81BE66C.s @@ -225,7 +225,7 @@ sub_81BE808: @ 81BE808 lsls r2, r0, 3 adds r2, r0 lsls r2, 2 - ldr r4, =gUnknown_02037350 + ldr r4, =gMapObjects adds r2, r4 ldr r3, =gSprites ldrb r1, [r2, 0x4] @@ -42692,7 +42692,7 @@ sub_81D427C: @ 81D427C lsls r1, r0, 3 adds r1, r0 lsls r1, 2 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects adds r5, r1, r2 ldr r4, =gUnknown_030012F8 ldr r3, =gUnknown_02037590 @@ -42730,7 +42730,7 @@ _081D42CA: mov r8, r0 cmp r0, 0x3 bls _081D42CA - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects ldr r0, =gUnknown_02037590 ldrb r1, [r0, 0x5] lsls r0, r1, 3 @@ -42786,7 +42786,7 @@ _081D4356: _081D4360: movs r4, 0 mov r8, r4 - ldr r6, =gUnknown_02037350 + ldr r6, =gMapObjects mov r10, r6 _081D4368: ldr r3, =gUnknown_02037590 @@ -42804,7 +42804,7 @@ _081D4368: ldrsh r2, [r4, r6] movs r6, 0 ldrsh r0, [r0, r6] - ldr r6, =gUnknown_02037350 + ldr r6, =gMapObjects mov r9, r6 mov r12, r3 adds r7, r1, 0 @@ -42952,7 +42952,7 @@ _081D449E: ldrsh r1, [r4, r3] movs r3, 0 ldrsh r0, [r0, r3] - ldr r3, =gUnknown_02037350 + ldr r3, =gMapObjects mov r9, r3 mov r12, r2 cmp r1, r0 @@ -43210,7 +43210,7 @@ _081D46D0: ldrsh r0, [r0, r3] cmp r0, 0 bne _081D476E - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects ldr r0, =gUnknown_02037590 ldrb r1, [r0, 0x5] lsls r0, r1, 3 @@ -43235,7 +43235,7 @@ _081D46D0: beq _081D470C b _081D447C _081D470C: - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects ldr r0, =gUnknown_02037590 ldrb r1, [r0, 0x5] lsls r0, r1, 3 @@ -43289,7 +43289,7 @@ _081D476E: ldrsh r0, [r0, r2] cmp r0, 0 bne _081D480C - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects ldr r0, =gUnknown_02037590 ldrb r1, [r0, 0x5] lsls r0, r1, 3 @@ -43314,7 +43314,7 @@ _081D476E: beq _081D47AA b _081D45AA _081D47AA: - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects ldr r0, =gUnknown_02037590 ldrb r1, [r0, 0x5] lsls r0, r1, 3 @@ -43385,7 +43385,7 @@ sub_81D4834: @ 81D4834 lsls r0, 16 lsls r1, 16 lsrs r4, r1, 16 - ldr r3, =gUnknown_02037350 + ldr r3, =gMapObjects ldr r1, =gUnknown_02037590 ldrb r2, [r1, 0x5] lsls r1, r2, 3 @@ -43436,7 +43436,7 @@ sub_81D4890: @ 81D4890 lsls r1, r0, 3 adds r1, r0 lsls r1, 2 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects adds r4, r1, r0 movs r1, 0 ldr r3, =gUnknown_030012FC @@ -43684,7 +43684,7 @@ sub_81D4A90: @ 81D4A90 lsls r1, r0, 3 adds r1, r0 lsls r1, 2 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects adds r5, r1, r0 ldrb r1, [r5, 0x1] movs r0, 0x21 @@ -46426,7 +46426,7 @@ GetTrainerHillTrainerFlag: @ 81D619C bl sub_81D5520 lsls r0, 24 lsrs r0, 23 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects lsls r1, r4, 3 adds r1, r4 lsls r1, 2 @@ -56756,4 +56756,4 @@ _081DB66C: .align 2, 0 @ Don't pad with nop. - \ No newline at end of file + diff --git a/asm/scrcmd.s b/asm/scrcmd.s index d22965e54..c2332e73c 100644 --- a/asm/scrcmd.s +++ b/asm/scrcmd.s @@ -2987,7 +2987,7 @@ sA9_unknown: @ 809A974 thumb_func_start s5A_face_player s5A_face_player: @ 809A9A4 push {r4,lr} - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects ldr r0, =gUnknown_03005DF0 ldrb r1, [r0] lsls r0, r1, 3 @@ -3163,7 +3163,7 @@ sub_809AAEC: @ 809AAEC movs r0, 0 b _0809AB3A _0809AAFC: - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects ldr r0, =gUnknown_03005DF0 ldrb r1, [r0] lsls r0, r1, 3 @@ -3208,7 +3208,7 @@ s6B_release: @ 809AB44 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r0, r1 bl FieldObjectClearAnimIfSpecialAnimFinished bl sub_80D338C @@ -3223,7 +3223,7 @@ s6B_release: @ 809AB44 s6C_release_2: @ 809AB7C push {r4,lr} bl textbox_close - ldr r4, =gUnknown_02037350 + ldr r4, =gMapObjects ldr r0, =gUnknown_03005DF0 ldrb r1, [r0] lsls r0, r1, 3 @@ -5397,7 +5397,7 @@ sub_809BBFC: @ 809BBFC movs r0, 0 b _0809BC30 _0809BC0C: - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects ldr r0, =gUnknown_03005DF0 ldrb r1, [r0] lsls r0, r1, 3 diff --git a/asm/script_pokemon_util_80F87D8.s b/asm/script_pokemon_util_80F87D8.s index b98058fa4..d207e287b 100644 --- a/asm/script_pokemon_util_80F87D8.s +++ b/asm/script_pokemon_util_80F87D8.s @@ -508,7 +508,7 @@ _080F8BBA: bl GetFieldObjectIdByLocalIdAndMap lsls r0, 24 lsrs r0, 24 - ldr r2, =gUnknown_02037350 + ldr r2, =gMapObjects lsls r1, r0, 3 adds r1, r0 lsls r1, 2 diff --git a/asm/secret_base.s b/asm/secret_base.s index 3f6db1f6b..06ccaa9da 100644 --- a/asm/secret_base.s +++ b/asm/secret_base.s @@ -756,7 +756,7 @@ sub_80E90C8: @ 80E90C8 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r0, r1 movs r1, 0x2 bl FieldObjectTurn diff --git a/asm/shop.s b/asm/shop.s index 0655f1851..1e86ea645 100644 --- a/asm/shop.s +++ b/asm/shop.s @@ -1633,7 +1633,7 @@ _080E07AA: lsrs r0, 24 mov r1, r12 strh r0, [r1] - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects lsls r0, r6, 3 adds r0, r6 lsls r0, 2 @@ -1730,7 +1730,7 @@ BuyMenuDrawFieldObjects: @ 80E08F0 movs r7, 0 ldr r0, =gUnknown_02039F70 mov r8, r0 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects mov r10, r1 ldr r2, =gSprites mov r9, r2 diff --git a/asm/trainer_see.s b/asm/trainer_see.s index 8a3d984cf..03c8d3320 100644 --- a/asm/trainer_see.s +++ b/asm/trainer_see.s @@ -15,7 +15,7 @@ CheckForTrainersWantingBattle: @ 80B3BE8 ldr r0, =gUnknown_02038BFC strb r1, [r0] movs r4, 0 - ldr r6, =gUnknown_02037350 + ldr r6, =gMapObjects _080B3BF8: lsls r0, r4, 3 adds r0, r4 @@ -180,7 +180,7 @@ _080B3D56: lsls r4, r5, 3 adds r0, r4, r5 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r0, r1 bl CheckIfTrainerCanApproachPlayer lsls r0, 24 @@ -227,7 +227,7 @@ _080B3D8A: mov r1, r8 adds r0, r1, r5 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r0, r1 subs r1, r6, 0x1 lsls r1, 24 @@ -691,7 +691,7 @@ c3_8081EDC: @ 80B4118 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r5, r0, r1 ldrb r0, [r5] lsls r0, 31 @@ -887,7 +887,7 @@ _080B427A: lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r4, r0, r1 adds r0, r4, 0 bl FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive @@ -906,7 +906,7 @@ _080B42D2: lsls r4, r0, 3 adds r4, r0 lsls r4, 2 - ldr r0, =gUnknown_02037350 + ldr r0, =gMapObjects adds r4, r0 ldrb r0, [r5, 0x18] lsls r0, 28 @@ -941,7 +941,7 @@ sub_80B4318: @ 80B4318 lsls r0, r1, 3 adds r0, r1 lsls r0, 2 - ldr r1, =gUnknown_02037350 + ldr r1, =gMapObjects adds r4, r0, r1 adds r0, r4, 0 bl FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive diff --git a/include/field_map_obj.h b/include/field_map_obj.h index 3100f72ff..93a90d2c8 100644 --- a/include/field_map_obj.h +++ b/include/field_map_obj.h @@ -5,8 +5,6 @@ // Exported RAM declarations -extern struct MapObject gUnknown_02037350[16]; - // Exported ROM declarations void sub_808D438(void); diff --git a/include/global.fieldmap.h b/include/global.fieldmap.h index 4029132e8..3e0c7729a 100644 --- a/include/global.fieldmap.h +++ b/include/global.fieldmap.h @@ -1,6 +1,8 @@ #ifndef GUARD_GLOBAL_FIELDMAP_H #define GUARD_GLOBAL_FIELDMAP_H +#define NUM_FIELD_OBJECTS 16 + enum { CONNECTION_SOUTH = 1, @@ -381,7 +383,7 @@ struct Camera s32 y; }; -extern struct MapObject gMapObjects[]; +extern struct MapObject gMapObjects[NUM_FIELD_OBJECTS]; extern u8 gSelectedMapObject; extern struct MapHeader gMapHeader; extern struct PlayerAvatar gPlayerAvatar; diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 88b9d7eab..1b4ba0b7f 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -33,9 +33,9 @@ static void npcs_clear_ids_and_state(void) { u8 i; - for (i = 0; i < ARRAY_COUNT(gUnknown_02037350); i ++) + for (i = 0; i < ARRAY_COUNT(gMapObjects); i ++) { - npc_clear_ids_and_state(&gUnknown_02037350[i]); + npc_clear_ids_and_state(&gMapObjects[i]); } } @@ -68,9 +68,9 @@ u8 sub_808D4F4(void) { u8 i; - for (i = 0; i < ARRAY_COUNT(gUnknown_02037350); i ++) + for (i = 0; i < ARRAY_COUNT(gMapObjects); i ++) { - if (!gUnknown_02037350[i].active) + if (!gMapObjects[i].active) { break; } @@ -90,7 +90,7 @@ u8 GetFieldObjectIdByLocalIdAndMap(u8 localId, u8 mapId, u8 mapGroupId) bool8 TryGetFieldObjectIdByLocalIdAndMap(u8 localId, u8 mapId, u8 mapGroupId, u8 *fieldObjectId) { *fieldObjectId = GetFieldObjectIdByLocalIdAndMap(localId, mapId, mapGroupId); - if (*fieldObjectId == ARRAY_COUNT(gUnknown_02037350)) + if (*fieldObjectId == ARRAY_COUNT(gMapObjects)) { return TRUE; } @@ -100,12 +100,27 @@ bool8 TryGetFieldObjectIdByLocalIdAndMap(u8 localId, u8 mapId, u8 mapGroupId, u8 u8 GetFieldObjectIdByXY(s16 x, s16 y) { u8 i; - for (i = 0; i < ARRAY_COUNT(gUnknown_02037350); i ++) + + for (i = 0; i < ARRAY_COUNT(gMapObjects); i ++) { - if (gUnknown_02037350[i].active && gUnknown_02037350[i].coords2.x == x && gUnknown_02037350[i].coords2.y == y) + if (gMapObjects[i].active && gMapObjects[i].coords2.x == x && gMapObjects[i].coords2.y == y) { break; } } return i; } + +u8 GetFieldObjectIdByLocalIdAndMapInternal(u8 localId, u8 mapId, u8 mapGroupId) +{ + u8 i; + + for (i = 0; i < ARRAY_COUNT(gMapObjects); i ++) + { + if (gMapObjects[i].active && gMapObjects[i].localId == localId && gMapObjects[i].mapNum == mapId && gMapObjects[i].mapGroup == mapGroupId) + { + return i; + } + } + return ARRAY_COUNT(gMapObjects); +} diff --git a/sym_ewram.txt b/sym_ewram.txt index b2dcd8e41..71b6ffeae 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -761,7 +761,7 @@ gUnknown_02037348: @ 2037348 gUnknown_0203734C: @ 203734C .space 0x4 -gUnknown_02037350: @ 2037350 +gMapObjects: @ 2037350 .space 0x240 gUnknown_02037590: @ 2037590 From 9498dfa71c811b09f319bc9c9656c08f3182c9dc Mon Sep 17 00:00:00 2001 From: scnorton Date: Wed, 6 Sep 2017 14:25:17 -0400 Subject: [PATCH 010/191] InitFieldObjectStateFromTemplate (nonmatching, same as ruby) --- asm/field_map_obj.s | 192 ------------------------------- include/field_map_obj.h | 1 + include/global.fieldmap.h | 3 +- include/global.h | 1 + src/field_map_obj.c | 230 +++++++++++++++++++++++++++++++++++++- 5 files changed, 233 insertions(+), 194 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 01e04f04b..8afd73a01 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,198 +5,6 @@ .text - thumb_func_start GetFieldObjectIdByLocalId -@ u8 GetFieldObjectIdByLocalId(u8 localId) -GetFieldObjectIdByLocalId: @ 808D608 - push {r4,lr} - lsls r0, 24 - lsrs r3, r0, 24 - movs r2, 0 - ldr r4, =gMapObjects -_0808D612: - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - adds r1, r0, r4 - ldrb r0, [r1] - lsls r0, 31 - cmp r0, 0 - beq _0808D630 - ldrb r0, [r1, 0x8] - cmp r0, r3 - bne _0808D630 - adds r0, r2, 0 - b _0808D63C - .pool -_0808D630: - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0xF - bls _0808D612 - movs r0, 0x10 -_0808D63C: - pop {r4} - pop {r1} - bx r1 - thumb_func_end GetFieldObjectIdByLocalId - - thumb_func_start InitFieldObjectStateFromTemplate -@ u8 InitFieldObjectStateFromTemplate(struct FieldObjectTemplate *fieldObjectTemplate, u8 mapId, u8 mapGroupId) -InitFieldObjectStateFromTemplate: @ 808D644 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x4 - adds r5, r0, 0 - lsls r1, 24 - lsrs r6, r1, 24 - lsls r2, 24 - lsrs r7, r2, 24 - ldrb r0, [r5] - adds r1, r6, 0 - adds r2, r7, 0 - mov r3, sp - bl GetAvailableFieldObjectSlot - lsls r0, 24 - cmp r0, 0 - beq _0808D66E - movs r0, 0x10 - b _0808D762 -_0808D66E: - mov r0, sp - ldrb r1, [r0] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, =gMapObjects - adds r4, r0, r1 - adds r0, r4, 0 - bl npc_clear_ids_and_state - ldrh r3, [r5, 0x4] - adds r3, 0x7 - lsls r3, 16 - lsrs r3, 16 - ldrh r2, [r5, 0x6] - adds r2, 0x7 - lsls r2, 16 - lsrs r2, 16 - ldrb r0, [r4] - movs r1, 0x1 - orrs r0, r1 - movs r1, 0x4 - orrs r0, r1 - strb r0, [r4] - ldrb r0, [r5, 0x1] - strb r0, [r4, 0x5] - ldrb r0, [r5, 0x9] - strb r0, [r4, 0x6] - ldrb r0, [r5] - strb r0, [r4, 0x8] - strb r6, [r4, 0x9] - strb r7, [r4, 0xA] - strh r3, [r4, 0xC] - strh r2, [r4, 0xE] - strh r3, [r4, 0x10] - strh r2, [r4, 0x12] - strh r3, [r4, 0x14] - strh r2, [r4, 0x16] - ldrb r0, [r5, 0x8] - movs r7, 0xF - adds r1, r7, 0 - ands r1, r0 - ldrb r2, [r4, 0xB] - movs r0, 0x10 - negs r0, r0 - mov r8, r0 - ands r0, r2 - orrs r0, r1 - strb r0, [r4, 0xB] - ldrb r1, [r5, 0x8] - lsls r1, 4 - ands r0, r7 - orrs r0, r1 - strb r0, [r4, 0xB] - ldrb r1, [r5, 0xA] - lsls r1, 28 - movs r0, 0xF - mov r9, r0 - lsrs r1, 28 - ldrb r2, [r4, 0x19] - mov r0, r8 - ands r0, r2 - orrs r0, r1 - strb r0, [r4, 0x19] - ldrb r1, [r5, 0xA] - lsrs r1, 4 - lsls r1, 4 - ands r0, r7 - orrs r0, r1 - strb r0, [r4, 0x19] - ldrh r0, [r5, 0xC] - strb r0, [r4, 0x7] - ldrh r0, [r5, 0xE] - strb r0, [r4, 0x1D] - ldr r1, =gUnknown_085055CD - ldrb r0, [r5, 0x9] - adds r0, r1 - ldrb r1, [r0] - adds r0, r4, 0 - adds r0, 0x20 - strb r1, [r0] - ldrb r1, [r0] - adds r0, r4, 0 - bl FieldObjectSetDirection - adds r0, r4, 0 - bl FieldObjectHandleDynamicGraphicsId - ldr r1, =gUnknown_0850557C - ldrb r0, [r4, 0x6] - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0 - beq _0808D75E - ldrb r2, [r4, 0x19] - adds r0, r7, 0 - ands r0, r2 - cmp r0, 0 - bne _0808D746 - lsls r0, r2, 28 - lsrs r0, 28 - adds r0, 0x1 - mov r1, r9 - ands r0, r1 - mov r1, r8 - ands r1, r2 - orrs r1, r0 - strb r1, [r4, 0x19] -_0808D746: - ldrb r2, [r4, 0x19] - movs r0, 0xF0 - ands r0, r2 - cmp r0, 0 - bne _0808D75E - lsrs r1, r2, 4 - adds r1, 0x1 - lsls r1, 4 - adds r0, r7, 0 - ands r0, r2 - orrs r0, r1 - strb r0, [r4, 0x19] -_0808D75E: - mov r0, sp - ldrb r0, [r0] -_0808D762: - add sp, 0x4 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end InitFieldObjectStateFromTemplate - thumb_func_start sub_808D77C sub_808D77C: @ 808D77C push {r4-r7,lr} diff --git a/include/field_map_obj.h b/include/field_map_obj.h index 93a90d2c8..3381d847b 100644 --- a/include/field_map_obj.h +++ b/include/field_map_obj.h @@ -11,6 +11,7 @@ void sub_808D438(void); u8 GetFieldObjectIdByLocalIdAndMap(u8, u8, u8); bool8 TryGetFieldObjectIdByLocalIdAndMap(u8, u8, u8, u8 *); u8 GetFieldObjectIdByXY(s16, s16); +void FieldObjectSetDirection(struct MapObject *, u8); // Exported data declarations diff --git a/include/global.fieldmap.h b/include/global.fieldmap.h index 3e0c7729a..b0a36aa55 100644 --- a/include/global.fieldmap.h +++ b/include/global.fieldmap.h @@ -226,7 +226,8 @@ struct MapObject /*0x14*/ struct Coords16 coords3; /*0x18*/ u8 mapobj_unk_18:4; //current direction? /*0x18*/ u8 placeholder18:4; - /*0x19*/ u8 mapobj_unk_19; + /*0x19*/ u8 mapobj_unk_19:4; + /*0x19*/ u8 mapobj_unk_19b:4; /*0x1A*/ u8 mapobj_unk_1A; /*0x1B*/ u8 mapobj_unk_1B; /*0x1C*/ u8 mapobj_unk_1C; diff --git a/include/global.h b/include/global.h index f9c5f68be..0c0f86470 100644 --- a/include/global.h +++ b/include/global.h @@ -8,6 +8,7 @@ // to help in decompiling #define asm_comment(x) asm volatile("@ -- " x " -- ") +#define asm_unified(x) asm(".syntax unified\n" x "\n.syntax divided") #ifdef __APPLE__ void memset(void *, int, size_t); diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 1b4ba0b7f..b97d5c0dc 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -15,14 +15,19 @@ /*static*/ void sub_808D450(void); /*static*/ u8 GetFieldObjectIdByLocalId(u8); /*static*/ u8 GetFieldObjectIdByLocalIdAndMapInternal(u8, u8, u8); +/*static*/ bool8 GetAvailableFieldObjectSlot(u16, u8, u8, u8 *); +/*static*/ void FieldObjectHandleDynamicGraphicsId(struct MapObject *); // ROM data +const u8 gUnknown_085055CD[0x53]; +const u8 gUnknown_0850557C[0x51]; + // Code /*static*/ void npc_clear_ids_and_state(struct MapObject *mapObject) { - memset(mapObject, 0, sizeof(struct MapObject)); + *mapObject = (struct MapObject){}; mapObject->localId = 0xFF; mapObject->mapNum = -1; mapObject->mapGroup = -1; @@ -124,3 +129,226 @@ u8 GetFieldObjectIdByLocalIdAndMapInternal(u8 localId, u8 mapId, u8 mapGroupId) } return ARRAY_COUNT(gMapObjects); } + +u8 GetFieldObjectIdByLocalId(u8 localId) +{ + u8 i; + + for (i = 0; i < ARRAY_COUNT(gMapObjects); i ++) + { + if (gMapObjects[i].active && gMapObjects[i].localId == localId) + { + return i; + } + } + return ARRAY_COUNT(gMapObjects); +} + +// This function has the same nonmatching quirk as in Ruby/Sapphire. +#ifdef NONMATCHING +u8 InitFieldObjectStateFromTemplate(struct MapObjectTemplate *template, u8 mapId, u8 mapGroupId) +{ + u8 slot; + struct MapObject *mapObject; + u16 x; + u16 y; + + if (GetAvailableFieldObjectSlot(template->localId, mapId, mapGroupId, &slot)) + { + return ARRAY_COUNT(gMapObjects); + } + mapObject = &gMapObjects[slot]; + npc_clear_ids_and_state(mapObject); + x = template->x + 7; + y = template->y + 7; + mapObject->active = TRUE; + mapObject->mapobj_bit_2 = TRUE; + mapObject->graphicsId = template->graphicsId; + mapObject->animPattern = template->movementType; + mapObject->localId = template->localId; + mapObject->mapNum = mapId; + mapObject->mapGroup = mapGroupId; + mapObject->coords1.x = x; + mapObject->coords1.y = y; + mapObject->coords2.x = x; + mapObject->coords2.y = y; + mapObject->coords3.x = x; + mapObject->coords3.y = y; + mapObject->mapobj_unk_0B_0 = template->elevation; + mapObject->elevation = template->elevation; + mapObject->mapobj_unk_19 = template->unkA_0; + mapObject->mapobj_unk_19b = template->unkA_4; + mapObject->trainerType = template->unkC; + mapObject->trainerRange_berryTreeId = template->unkE; + mapObject->mapobj_unk_20 = gUnknown_085055CD[template->movementType]; + FieldObjectSetDirection(mapObject, mapObject->mapobj_unk_20); + FieldObjectHandleDynamicGraphicsId(mapObject); + if (gUnknown_0850557C[mapObject->animPattern]) + { + if (mapObject->mapobj_unk_19 == 0) + { + mapObject->mapobj_unk_19 ++; + } + if (mapObject->mapobj_unk_19b == 0) + { + mapObject->mapobj_unk_19b ++; + } + } + return slot; +} +#else +__attribute__((naked)) u8 InitFieldObjectStateFromTemplate(struct MapObjectTemplate *template, u8 mapId, u8 mapGroupId) +{ + asm_unified("\tpush {r4-r7,lr}\n" + "\tmov r7, r9\n" + "\tmov r6, r8\n" + "\tpush {r6,r7}\n" + "\tsub sp, 0x4\n" + "\tadds r5, r0, 0\n" + "\tlsls r1, 24\n" + "\tlsrs r6, r1, 24\n" + "\tlsls r2, 24\n" + "\tlsrs r7, r2, 24\n" + "\tldrb r0, [r5]\n" + "\tadds r1, r6, 0\n" + "\tadds r2, r7, 0\n" + "\tmov r3, sp\n" + "\tbl GetAvailableFieldObjectSlot\n" + "\tlsls r0, 24\n" + "\tcmp r0, 0\n" + "\tbeq _0808D66E\n" + "\tmovs r0, 0x10\n" + "\tb _0808D762\n" + "_0808D66E:\n" + "\tmov r0, sp\n" + "\tldrb r1, [r0]\n" + "\tlsls r0, r1, 3\n" + "\tadds r0, r1\n" + "\tlsls r0, 2\n" + "\tldr r1, =gMapObjects\n" + "\tadds r4, r0, r1\n" + "\tadds r0, r4, 0\n" + "\tbl npc_clear_ids_and_state\n" + "\tldrh r3, [r5, 0x4]\n" + "\tadds r3, 0x7\n" + "\tlsls r3, 16\n" + "\tlsrs r3, 16\n" + "\tldrh r2, [r5, 0x6]\n" + "\tadds r2, 0x7\n" + "\tlsls r2, 16\n" + "\tlsrs r2, 16\n" + "\tldrb r0, [r4]\n" + "\tmovs r1, 0x1\n" + "\torrs r0, r1\n" + "\tmovs r1, 0x4\n" + "\torrs r0, r1\n" + "\tstrb r0, [r4]\n" + "\tldrb r0, [r5, 0x1]\n" + "\tstrb r0, [r4, 0x5]\n" + "\tldrb r0, [r5, 0x9]\n" + "\tstrb r0, [r4, 0x6]\n" + "\tldrb r0, [r5]\n" + "\tstrb r0, [r4, 0x8]\n" + "\tstrb r6, [r4, 0x9]\n" + "\tstrb r7, [r4, 0xA]\n" + "\tstrh r3, [r4, 0xC]\n" + "\tstrh r2, [r4, 0xE]\n" + "\tstrh r3, [r4, 0x10]\n" + "\tstrh r2, [r4, 0x12]\n" + "\tstrh r3, [r4, 0x14]\n" + "\tstrh r2, [r4, 0x16]\n" + "\tldrb r0, [r5, 0x8]\n" + "\tmovs r7, 0xF\n" + "\tadds r1, r7, 0\n" + "\tands r1, r0\n" + "\tldrb r2, [r4, 0xB]\n" + "\tmovs r0, 0x10\n" + "\tnegs r0, r0\n" + "\tmov r8, r0\n" + "\tands r0, r2\n" + "\torrs r0, r1\n" + "\tstrb r0, [r4, 0xB]\n" + "\tldrb r1, [r5, 0x8]\n" + "\tlsls r1, 4\n" + "\tands r0, r7\n" + "\torrs r0, r1\n" + "\tstrb r0, [r4, 0xB]\n" + "\tldrb r1, [r5, 0xA]\n" + "\tlsls r1, 28\n" + "\tmovs r0, 0xF\n" + "\tmov r9, r0\n" + "\tlsrs r1, 28\n" + "\tldrb r2, [r4, 0x19]\n" + "\tmov r0, r8\n" + "\tands r0, r2\n" + "\torrs r0, r1\n" + "\tstrb r0, [r4, 0x19]\n" + "\tldrb r1, [r5, 0xA]\n" + "\tlsrs r1, 4\n" + "\tlsls r1, 4\n" + "\tands r0, r7\n" + "\torrs r0, r1\n" + "\tstrb r0, [r4, 0x19]\n" + "\tldrh r0, [r5, 0xC]\n" + "\tstrb r0, [r4, 0x7]\n" + "\tldrh r0, [r5, 0xE]\n" + "\tstrb r0, [r4, 0x1D]\n" + "\tldr r1, =gUnknown_085055CD\n" + "\tldrb r0, [r5, 0x9]\n" + "\tadds r0, r1\n" + "\tldrb r1, [r0]\n" + "\tadds r0, r4, 0\n" + "\tadds r0, 0x20\n" + "\tstrb r1, [r0]\n" + "\tldrb r1, [r0]\n" + "\tadds r0, r4, 0\n" + "\tbl FieldObjectSetDirection\n" + "\tadds r0, r4, 0\n" + "\tbl FieldObjectHandleDynamicGraphicsId\n" + "\tldr r1, =gUnknown_0850557C\n" + "\tldrb r0, [r4, 0x6]\n" + "\tadds r0, r1\n" + "\tldrb r0, [r0]\n" + "\tcmp r0, 0\n" + "\tbeq _0808D75E\n" + "\tldrb r2, [r4, 0x19]\n" + "\tadds r0, r7, 0\n" + "\tands r0, r2\n" + "\tcmp r0, 0\n" + "\tbne _0808D746\n" + "\tlsls r0, r2, 28\n" + "\tlsrs r0, 28\n" + "\tadds r0, 0x1\n" + "\tmov r1, r9\n" + "\tands r0, r1\n" + "\tmov r1, r8\n" + "\tands r1, r2\n" + "\torrs r1, r0\n" + "\tstrb r1, [r4, 0x19]\n" + "_0808D746:\n" + "\tldrb r2, [r4, 0x19]\n" + "\tmovs r0, 0xF0\n" + "\tands r0, r2\n" + "\tcmp r0, 0\n" + "\tbne _0808D75E\n" + "\tlsrs r1, r2, 4\n" + "\tadds r1, 0x1\n" + "\tlsls r1, 4\n" + "\tadds r0, r7, 0\n" + "\tands r0, r2\n" + "\torrs r0, r1\n" + "\tstrb r0, [r4, 0x19]\n" + "_0808D75E:\n" + "\tmov r0, sp\n" + "\tldrb r0, [r0]\n" + "_0808D762:\n" + "\tadd sp, 0x4\n" + "\tpop {r3,r4}\n" + "\tmov r8, r3\n" + "\tmov r9, r4\n" + "\tpop {r4-r7}\n" + "\tpop {r1}\n" + "\tbx r1\n" + ".pool"); +} +#endif From 6448563ede13d51682cbf1988a2072291f3b3df0 Mon Sep 17 00:00:00 2001 From: scnorton Date: Wed, 6 Sep 2017 16:14:55 -0400 Subject: [PATCH 011/191] unref_sub_808D77C --- asm/battle_setup.s | 4 +- asm/bike.s | 4 +- asm/decoration.s | 18 ++++----- asm/field_camera.s | 6 +-- asm/field_control_avatar.s | 28 ++++++------- asm/field_map_obj.s | 82 +------------------------------------- asm/field_tasks.s | 2 +- asm/fieldmap.s | 30 +++++++------- asm/fldeff_80F9BCC.s | 2 +- asm/fldeff_teleport.s | 2 +- asm/item_use.s | 10 ++--- asm/pokemon_3.s | 2 +- asm/region_map.s | 8 ++-- asm/rom4.s | 56 +++++++++++++------------- asm/rom6.s | 14 +++---- asm/rom_80C6FA0.s | 8 ++-- asm/rom_818CFC8.s | 22 +++++----- asm/rom_81BE66C.s | 24 +++++------ asm/script.s | 2 +- asm/secret_base.s | 12 +++--- asm/shop.s | 2 +- asm/tileset.s | 4 +- asm/tv.s | 14 +++---- asm/weather.s | 2 +- asm/wild_encounter.s | 10 ++--- include/rom_818CFC8.h | 11 +++++ include/rom_81BE66C.h | 10 +++++ src/field_map_obj.c | 35 ++++++++++++++++ sym_ewram.txt | 2 +- 29 files changed, 202 insertions(+), 224 deletions(-) create mode 100644 include/rom_818CFC8.h create mode 100644 include/rom_81BE66C.h diff --git a/asm/battle_setup.s b/asm/battle_setup.s index a07561464..a4b143703 100644 --- a/asm/battle_setup.s +++ b/asm/battle_setup.s @@ -678,7 +678,7 @@ _080B0C16: lsls r0, 24 cmp r0, 0 bne _080B0D18 - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrb r0, [r0, 0x17] subs r0, 0x1 cmp r0, 0x8 @@ -830,7 +830,7 @@ _080B0D54: lsls r0, 24 cmp r0, 0 bne _080B0D7C - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrb r0, [r0, 0x17] cmp r0, 0x4 beq _080B0D78 diff --git a/asm/bike.s b/asm/bike.s index 00db73ca1..22d52c0fa 100644 --- a/asm/bike.s +++ b/asm/bike.s @@ -1775,7 +1775,7 @@ sub_8119EF0: @ 8119EF0 lsls r0, 24 cmp r0, 0 bne _08119F08 - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrb r0, [r0, 0x17] cmp r0, 0x8 bne _08119F10 @@ -2173,7 +2173,7 @@ IsRunningDisallowed: @ 811A1DC push {lr} lsls r0, 24 lsrs r2, r0, 24 - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrb r1, [r0, 0x1A] movs r0, 0x4 ands r0, r1 diff --git a/asm/decoration.s b/asm/decoration.s index 9d228be38..26449f85d 100644 --- a/asm/decoration.s +++ b/asm/decoration.s @@ -2472,7 +2472,7 @@ sub_8127E18: @ 8127E18 push {r5-r7} sub sp, 0x4 movs r6, 0 - ldr r7, =gUnknown_02037318 + ldr r7, =gMapHeader ldr r0, =gSpecialVar_0x8005 mov r8, r0 ldr r1, =gSpecialVar_0x8006 @@ -2500,7 +2500,7 @@ _08127E34: ldrh r0, [r0, 0x14] cmp r0, r5 beq _08127E82 - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldr r3, [r0, 0x4] ldrb r6, [r3] adds r4, r5, 0 @@ -3938,7 +3938,7 @@ _08128A64: ldrh r1, [r0, 0x22] adds r1, 0x2 strh r1, [r0, 0x22] - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrb r0, [r0, 0x14] cmp r0, 0x56 bne _08128A84 @@ -4282,7 +4282,7 @@ _08128D48: movs r0, 0x2 ldrsh r1, [r2, r0] subs r1, 0x7 - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldr r0, [r0] ldr r0, [r0, 0x4] cmp r1, r0 @@ -4316,7 +4316,7 @@ _08128D82: ldrsh r0, [r2, r4] adds r1, r0 subs r1, 0x8 - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldr r0, [r0] ldr r0, [r0] cmp r1, r0 @@ -5559,7 +5559,7 @@ _08129744: ldrb r0, [r4] bl sub_81296EC movs r1, 0 - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldr r0, [r0, 0x4] ldrb r2, [r0] cmp r1, r2 @@ -5591,7 +5591,7 @@ _08129796: sub_81297AC: @ 81297AC push {r4-r6,lr} movs r2, 0 - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldr r0, [r0, 0x4] ldrb r1, [r0] cmp r2, r1 @@ -5684,7 +5684,7 @@ _08129846: _0812985E: adds r0, r4, 0x7 add r0, r8 - ldr r1, =gUnknown_02037318 + ldr r1, =gMapHeader ldr r3, [r1] ldr r1, [sp] subs r2, r1, r6 @@ -5817,7 +5817,7 @@ _08129968: adds r0, r5, 0 adds r1, r4, 0 bl DisplayItemMessageOnField - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrb r0, [r0, 0x14] cmp r0, 0x56 bne _08129994 diff --git a/asm/field_camera.s b/asm/field_camera.s index 450e96174..cead2954c 100644 --- a/asm/field_camera.s +++ b/asm/field_camera.s @@ -135,7 +135,7 @@ DrawWholeMapView: @ 8089C34 ldrsh r0, [r1, r2] movs r2, 0x2 ldrsh r1, [r1, r2] - ldr r2, =gUnknown_02037318 + ldr r2, =gMapHeader ldr r2, [r2] bl DrawWholeMapViewInternal ldr r1, =gUnknown_03000E20 @@ -225,7 +225,7 @@ RedrawMapSlicesForCameraUpdate: @ 8089CE4 adds r5, r0, 0 adds r6, r1, 0 adds r7, r2, 0 - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldr r4, [r0] cmp r6, 0 ble _08089CFC @@ -476,7 +476,7 @@ CurrentMapDrawMetatileAt: @ 8089EA0 adds r1, r0, 0 cmp r1, 0 blt _08089ECC - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldr r0, [r0] lsls r1, 16 lsrs r1, 16 diff --git a/asm/field_control_avatar.s b/asm/field_control_avatar.s index 3d989e9e4..85009cc5b 100644 --- a/asm/field_control_avatar.s +++ b/asm/field_control_avatar.s @@ -704,7 +704,7 @@ TryGetInvisibleMapObjectScript: @ 809C458 push {r4,r5,lr} lsls r2, 24 lsrs r5, r2, 24 - ldr r4, =gUnknown_02037318 + ldr r4, =gMapHeader ldrh r1, [r0] subs r1, 0x7 lsls r1, 16 @@ -1194,7 +1194,7 @@ sub_809C89C: @ 809C89C lsls r0, 24 cmp r0, 0 beq _0809C8D4 - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrb r0, [r0, 0x17] cmp r0, 0x5 bne _0809C8D4 @@ -1264,7 +1264,7 @@ _0809C930: thumb_func_start mapheader_trigger_activate_at__run_now mapheader_trigger_activate_at__run_now: @ 809C938 push {r4,lr} - ldr r4, =gUnknown_02037318 + ldr r4, =gMapHeader ldrh r1, [r0] subs r1, 0x7 lsls r1, 16 @@ -1545,7 +1545,7 @@ overworld_poison_timer_set: @ 809CB80 thumb_func_start overworld_poison_step overworld_poison_step: @ 809CB94 push {lr} - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrb r0, [r0, 0x17] cmp r0, 0x9 beq _0809CBD4 @@ -1639,7 +1639,7 @@ mapheader_run_first_tag2_script_list_match_conditionally: @ 809CC38 lsrs r4, 16 lsls r5, 24 lsrs r5, 24 - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader mov r8, r0 adds r1, r7, 0 bl map_warp_check_packed @@ -1683,7 +1683,7 @@ sub_809CC9C: @ 809CC9C adds r6, r0, 0 lsls r1, 16 lsrs r5, r1, 16 - ldr r7, =gUnknown_02037318 + ldr r7, =gMapHeader adds r0, r7, 0 adds r1, r6, 0 bl map_warp_check_packed @@ -1958,7 +1958,7 @@ sub_809CEB0: @ 809CEB0 adds r4, r0, 0 cmp r4, 0 bne _0809CEE8 - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldr r0, [r0, 0x4] ldr r5, [r0, 0x8] b _0809CF0E @@ -1976,7 +1976,7 @@ _0809CEF0: adds r5, r0, 0 b _0809CF0E _0809CF00: - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldr r0, [r0, 0x4] lsls r2, r4, 24 asrs r1, r2, 21 @@ -2053,7 +2053,7 @@ map_warp_consider_2_to_inside: @ 809CF78 lsrs r0, 24 cmp r0, 0x1 bne _0809CFB0 - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldr r1, [r0, 0x4] adds r0, r5, 0 bl sub_80E9668 @@ -2067,7 +2067,7 @@ _0809CFB0: lsrs r0, 24 cmp r0, 0x1 bne _0809CFFC - ldr r6, =gUnknown_02037318 + ldr r6, =gMapHeader adds r0, r6, 0 adds r1, r5, 0 bl map_warp_check_packed @@ -2243,7 +2243,7 @@ _0809D0E4: thumb_func_start sub_809D0F4 sub_809D0F4: @ 809D0F4 push {r4,lr} - ldr r4, =gUnknown_02037318 + ldr r4, =gMapHeader ldrh r1, [r0] subs r1, 0x7 lsls r1, 16 @@ -2316,7 +2316,7 @@ dive_warp: @ 809D16C adds r4, r0, 0 lsls r1, 16 lsrs r5, r1, 16 - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrb r0, [r0, 0x17] cmp r0, 0x5 bne _0809D1A4 @@ -2389,7 +2389,7 @@ sub_809D1E8: @ 809D1E8 bl MapGridGetMetatileBehaviorAt lsls r0, 24 lsrs r5, r0, 24 - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrb r0, [r0, 0x17] cmp r0, 0x5 bne _0809D244 @@ -2491,7 +2491,7 @@ sub_809D2BC: @ 809D2BC movs r2, 0x2 ldrsh r1, [r4, r2] bl MapGridGetMetatileBehaviorAt - ldr r4, =gUnknown_02037318 + ldr r4, =gMapHeader adds r0, r4, 0 mov r1, sp bl map_warp_check_packed diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 8afd73a01..31b522467 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,84 +5,6 @@ .text - thumb_func_start sub_808D77C -sub_808D77C: @ 808D77C - push {r4-r7,lr} - mov r7, r8 - push {r7} - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - ldr r4, =gUnknown_02037318 - ldr r0, [r4, 0x4] - cmp r0, 0 - beq _0808D7FE - bl InBattlePyramid - lsls r0, 24 - cmp r0, 0 - beq _0808D7A8 - bl sub_81AAA40 - lsls r0, 24 - lsrs r6, r0, 24 - b _0808D7CA - .pool -_0808D7A8: - bl InTrainerHill - cmp r0, 0 - beq _0808D7C6 - movs r6, 0x2 - b _0808D7CA -_0808D7B4: - ldr r0, [r7] - ldrb r1, [r0, 0x5] - ldrb r2, [r0, 0x4] - adds r0, r4, 0 - bl InitFieldObjectStateFromTemplate - lsls r0, 24 - lsrs r0, 24 - b _0808D800 -_0808D7C6: - ldr r0, [r4, 0x4] - ldrb r6, [r0] -_0808D7CA: - movs r5, 0 - cmp r5, r6 - bcs _0808D7FE - ldr r7, =gSaveBlock1Ptr -_0808D7D2: - lsls r0, r5, 1 - adds r0, r5 - lsls r0, 3 - movs r1, 0xC7 - lsls r1, 4 - adds r0, r1 - ldr r1, [r7] - adds r4, r1, r0 - ldrb r0, [r4] - cmp r0, r8 - bne _0808D7F4 - ldrh r0, [r4, 0x14] - bl FlagGet - lsls r0, 24 - cmp r0, 0 - beq _0808D7B4 -_0808D7F4: - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, r6 - bcc _0808D7D2 -_0808D7FE: - movs r0, 0x10 -_0808D800: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_808D77C - thumb_func_start GetAvailableFieldObjectSlot @ bool8 GetAvailableFieldObjectSlot(u16 localId, u8 mapId, u8 mapGroupId, u8 *fieldObjectId) GetAvailableFieldObjectSlot: @ 808D810 @@ -1066,7 +988,7 @@ SpawnFieldObjectsInView: @ 808DF80 lsls r1, 16 lsrs r1, 16 str r1, [sp, 0x8] - ldr r5, =gUnknown_02037318 + ldr r5, =gMapHeader ldr r0, [r5, 0x4] cmp r0, 0 beq _0808E078 @@ -3478,7 +3400,7 @@ GetFieldObjectTemplateByLocalIdAndMap: @ 808F128 movs r0, 0xC7 lsls r0, 4 adds r1, r0 - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldr r0, [r0, 0x4] b _0808F16C .pool diff --git a/asm/field_tasks.s b/asm/field_tasks.s index 5f9a49f94..fb99bbc0e 100644 --- a/asm/field_tasks.s +++ b/asm/field_tasks.s @@ -1201,7 +1201,7 @@ sub_809E1C8: @ 809E1C8 mov r7, r9 mov r6, r8 push {r6,r7} - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldr r0, [r0] ldr r1, [r0] mov r9, r1 diff --git a/asm/fieldmap.s b/asm/fieldmap.s index 037133d1e..d2416248f 100644 --- a/asm/fieldmap.s +++ b/asm/fieldmap.s @@ -19,7 +19,7 @@ mapconnection_get_mapheader: @ 8087D44 thumb_func_start not_trainer_hill_battle_pyramid not_trainer_hill_battle_pyramid: @ 8087D54 push {r4,lr} - ldr r4, =gUnknown_02037318 + ldr r4, =gMapHeader adds r0, r4, 0 bl mapheader_copy_mapdata_with_padding ldr r0, [r4, 0x4] @@ -34,7 +34,7 @@ not_trainer_hill_battle_pyramid: @ 8087D54 thumb_func_start sub_8087D74 sub_8087D74: @ 8087D74 push {r4,lr} - ldr r4, =gUnknown_02037318 + ldr r4, =gMapHeader adds r0, r4, 0 bl mapheader_copy_mapdata_with_padding movs r0, 0 @@ -554,7 +554,7 @@ MapGridGetZCoordAt: @ 8088144 b _08088196 .pool _08088174: - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldr r3, [r0] adds r1, r2, 0x1 movs r2, 0x1 @@ -613,7 +613,7 @@ MapGridIsImpassableAt: @ 80881B0 b _08088202 .pool _080881E0: - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldr r3, [r0] adds r1, r2, 0x1 movs r2, 0x1 @@ -675,7 +675,7 @@ MapGridGetMetatileIdAt: @ 8088224 b _08088278 .pool _08088254: - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldr r3, [r0] adds r1, r5, 0x1 movs r2, 0x1 @@ -702,7 +702,7 @@ _08088278: b _080882B0 .pool _0808828C: - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldr r3, [r0] adds r1, r5, 0x1 movs r2, 0x1 @@ -839,7 +839,7 @@ GetBehaviorByMetatileId: @ 8088370 ldr r0, =0x000001ff cmp r2, r0 bhi _08088394 - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldr r0, [r0] ldr r0, [r0, 0x10] ldr r1, [r0, 0x10] @@ -854,7 +854,7 @@ _08088394: b _080883B6 .pool _080883A4: - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldr r0, [r0] ldr r0, [r0, 0x14] ldr r1, [r0, 0x10] @@ -1029,7 +1029,7 @@ _080884EC: mov r9, r1 cmp r6, r0 bne _08088508 - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldr r0, [r0] ldr r0, [r0, 0x4] subs r0, 0x1 @@ -1104,7 +1104,7 @@ _08088574: asrs r1, r2, 16 bl sub_80D423C _08088584: - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldr r0, [r0] ldr r0, [r0, 0x4] subs r0, 0x1 @@ -1282,7 +1282,7 @@ GetMapBorderIdAt: @ 808869C b _08088700 .pool _080886D8: - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldr r3, [r0] adds r1, r4, 0x1 movs r2, 0x1 @@ -1607,7 +1607,7 @@ sub_8088950: @ 8088950 mov r8, r2 lsls r0, 24 lsrs r6, r0, 24 - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldr r0, [r0, 0xC] ldr r7, [r0] ldr r4, [r0, 0x4] @@ -1664,7 +1664,7 @@ sub_80889A8: @ 80889A8 blt _08088A00 cmp r4, 0x2 bgt _080889E0 - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldr r0, [r0] ldr r1, [r0] ldr r0, [r2] @@ -1676,7 +1676,7 @@ sub_80889A8: @ 80889A8 _080889E0: cmp r6, 0x4 bgt _08088A00 - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldr r0, [r0] ldr r1, [r0, 0x4] ldr r0, [r2] @@ -1792,7 +1792,7 @@ sub_8088A8C: @ 8088A8C mov r8, r0 lsls r1, 16 lsrs r1, 16 - ldr r2, =gUnknown_02037318 + ldr r2, =gMapHeader ldr r0, [r2, 0xC] cmp r0, 0 bne _08088AB4 diff --git a/asm/fldeff_80F9BCC.s b/asm/fldeff_80F9BCC.s index 465f64db3..d5e620c77 100644 --- a/asm/fldeff_80F9BCC.s +++ b/asm/fldeff_80F9BCC.s @@ -468,7 +468,7 @@ _080F9F54: sub_80F9F5C: @ 80F9F5C push {lr} ldr r0, =gUnknown_0203AB40 - ldr r1, =gUnknown_02037318 + ldr r1, =gMapHeader ldr r1, [r1, 0x4] bl sub_80E9608 bl sub_80E8B6C diff --git a/asm/fldeff_teleport.s b/asm/fldeff_teleport.s index bbca5095f..0e14cd418 100644 --- a/asm/fldeff_teleport.s +++ b/asm/fldeff_teleport.s @@ -8,7 +8,7 @@ thumb_func_start SetUpFieldMove_Teleport SetUpFieldMove_Teleport: @ 817C8BC push {lr} - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrb r0, [r0, 0x17] bl is_light_level_1_2_3_or_6 lsls r0, 24 diff --git a/asm/item_use.s b/asm/item_use.s index cd1c38215..8d3c0ce41 100644 --- a/asm/item_use.s +++ b/asm/item_use.s @@ -553,7 +553,7 @@ ItemUseOnFieldCB_Itemfinder: @ 80FD4B8 push {r4,lr} lsls r0, 24 lsrs r4, r0, 24 - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldr r0, [r0, 0x4] adds r1, r4, 0 bl ItemfinderCheckForHiddenItems @@ -906,7 +906,7 @@ _080FD76C: subs r0, r5, r0 lsls r0, 16 lsrs r1, r0, 16 - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldr r0, [r0] ldr r0, [r0, 0x4] b _080FD79E @@ -918,7 +918,7 @@ _080FD784: adds r0, r5 b _080FD798 _080FD78E: - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldr r0, [r0] ldr r0, [r0] adds r0, 0x7 @@ -964,7 +964,7 @@ sub_80FD7C8: @ 80FD7C8 lsls r0, 24 lsrs r0, 24 str r0, [sp, 0x4] - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldr r1, [r0] ldr r0, [r1] adds r0, 0x7 @@ -2288,7 +2288,7 @@ re_escape_rope: @ 80FE2D8 thumb_func_start sub_80FE314 sub_80FE314: @ 80FE314 push {lr} - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrb r1, [r0, 0x1A] movs r0, 0x2 ands r0, r1 diff --git a/asm/pokemon_3.s b/asm/pokemon_3.s index ca77a64a4..22c72f443 100644 --- a/asm/pokemon_3.s +++ b/asm/pokemon_3.s @@ -5733,7 +5733,7 @@ _0806EA7C: mov r8, r2 movs r7, 0x50 _0806EAC6: - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrh r1, [r0, 0x12] movs r0, 0xD2 lsls r0, 1 diff --git a/asm/region_map.s b/asm/region_map.s index 716981813..7a0a5dae3 100644 --- a/asm/region_map.s +++ b/asm/region_map.s @@ -1571,7 +1571,7 @@ _08123904: _08123928: ldr r4, =gUnknown_0203A144 ldr r0, [r4] - ldr r3, =gUnknown_02037318 + ldr r3, =gMapHeader ldrb r1, [r3, 0x14] movs r2, 0 strh r1, [r0] @@ -1599,7 +1599,7 @@ _08123956: b _08123ABE .pool _0812396C: - ldr r2, =gUnknown_02037318 + ldr r2, =gMapHeader ldrb r1, [r2, 0x1A] movs r0, 0x2 ands r0, r1 @@ -1685,7 +1685,7 @@ _081239E4: _08123A28: ldr r4, =gUnknown_0203A144 ldr r0, [r4] - ldr r1, =gUnknown_02037318 + ldr r1, =gMapHeader ldrb r1, [r1, 0x14] strh r1, [r0] cmp r1, 0x57 @@ -2811,7 +2811,7 @@ sub_8124288: @ 8124288 str r0, [sp, 0x10] ldr r0, =SpriteCallbackDummy str r0, [sp, 0x14] - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrb r0, [r0, 0x14] bl sub_8124668 cmp r0, 0 diff --git a/asm/rom4.s b/asm/rom4.s index 10d607683..b6a5c0fa0 100644 --- a/asm/rom4.s +++ b/asm/rom4.s @@ -278,7 +278,7 @@ CopyFieldObjectTemplatesToSav1: @ 8084894 ldr r2, =0x05000180 mov r0, sp bl CpuSet - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldr r2, [r0, 0x4] ldr r0, [r2, 0x4] ldr r1, [r5] @@ -302,7 +302,7 @@ CopyFieldObjectTemplatesToSav1: @ 8084894 @ void CopyFieldObjectTemplateCoordsToSav1() CopyFieldObjectTemplateCoordsToSav1: @ 80848E0 push {lr} - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldr r1, [r0, 0x4] ldr r0, =gSaveBlock1Ptr ldr r0, [r0] @@ -393,7 +393,7 @@ _08084978: mapdata_load_assets_to_gpu_and_full_redraw: @ 8084980 push {r4,lr} bl move_tilemap_camera_to_upper_left_corner - ldr r4, =gUnknown_02037318 + ldr r4, =gMapHeader ldr r0, [r4] bl copy_map_tileset1_tileset2_to_vram ldr r0, [r4] @@ -571,7 +571,7 @@ warp1_get_mapheader: @ 8084AA8 set_current_map_header_from_sav1_save_old_name: @ 8084ACC push {r4-r6,lr} ldr r1, =gUnknown_020322FC - ldr r4, =gUnknown_02037318 + ldr r4, =gMapHeader ldrb r0, [r4, 0x14] strh r0, [r1] ldr r5, =gSaveBlock1Ptr @@ -607,7 +607,7 @@ set_current_map_header_from_sav1_save_old_name: @ 8084ACC thumb_func_start set_current_map_header_from_sav1 set_current_map_header_from_sav1: @ 8084B1C push {r4,r5,lr} - ldr r4, =gUnknown_02037318 + ldr r4, =gMapHeader ldr r0, =gSaveBlock1Ptr ldr r1, [r0] movs r0, 0x4 @@ -646,7 +646,7 @@ update_camera_pos_from_warpid: @ 8084B5C adds r4, r0, 0 cmp r1, 0 blt _08084B94 - ldr r3, =gUnknown_02037318 + ldr r3, =gMapHeader ldr r0, [r3, 0x4] ldrb r5, [r0, 0x1] cmp r1, r5 @@ -680,7 +680,7 @@ _08084B94: b _08084BCC _08084BB0: ldr r3, [r4] - ldr r2, =gUnknown_02037318 + ldr r2, =gMapHeader ldr r0, [r2] ldr r0, [r0] lsrs r1, r0, 31 @@ -1232,7 +1232,7 @@ sub_8084FC0: @ 8084FC0 push {r4,lr} lsls r0, 24 lsrs r4, r0, 24 - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldr r0, [r0, 0xC] ldr r3, [r0] ldr r1, [r0, 0x4] @@ -1366,7 +1366,7 @@ mliX_load_map: @ 8085098 str r3, [sp] adds r2, r3, 0 bl warp1_set - ldr r4, =gUnknown_02037318 + ldr r4, =gMapHeader ldrb r0, [r4, 0x14] cmp r0, 0x3A beq _080850C8 @@ -1407,7 +1407,7 @@ _08085116: bl sub_80AEE20 bl wild_encounter_reset_coro_args bl mapheader_run_script_with_tag_x5 - ldr r2, =gUnknown_02037318 + ldr r2, =gMapHeader ldrb r0, [r2, 0x14] cmp r0, 0x3A bne _0808514C @@ -1436,7 +1436,7 @@ mli0_load_map: @ 8085160 ands r0, r1 cmp r0, 0 bne _080851A2 - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrh r1, [r0, 0x12] ldr r0, =0x00000169 cmp r1, r0 @@ -1453,7 +1453,7 @@ _08085190: _0808519E: bl CopyFieldObjectTemplatesToSav1 _080851A2: - ldr r4, =gUnknown_02037318 + ldr r4, =gMapHeader ldrb r0, [r4, 0x17] bl is_light_level_1_2_3_5_or_6 lsls r0, 24 @@ -1802,7 +1802,7 @@ cur_mapdata_block_role_at_screen_center_acc_to_sav1: @ 8085450 thumb_func_start sav1_map_is_biking_allowed sav1_map_is_biking_allowed: @ 8085474 push {lr} - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrb r1, [r0, 0x1A] movs r0, 0x1 ands r0, r1 @@ -1821,7 +1821,7 @@ _0808548E: thumb_func_start update_sav1_flash_used_on_map update_sav1_flash_used_on_map: @ 8085494 push {lr} - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrb r1, [r0, 0x15] cmp r1, 0 bne _080854B0 @@ -1897,7 +1897,7 @@ sub_8085524: @ 8085524 ldr r1, [r1] strh r0, [r1, 0x32] bl get_mapdata_header - ldr r1, =gUnknown_02037318 + ldr r1, =gMapHeader str r0, [r1] pop {r0} bx r0 @@ -3471,7 +3471,7 @@ sub_80861E8: @ 80861E8 thumb_func_start sub_8086204 sub_8086204: @ 8086204 push {lr} - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrb r1, [r0, 0x1A] movs r0, 0xF8 ands r0, r1 @@ -3507,7 +3507,7 @@ _0808624A: bl GetCurrentTrainerHillMapId lsls r0, 24 lsrs r4, r0, 24 - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrh r1, [r0, 0x12] ldr r0, =0x00000169 cmp r1, r0 @@ -3528,7 +3528,7 @@ _0808628A: bl sub_809757C bl sub_809E7B0 bl sub_8084788 - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrh r1, [r0, 0x12] ldr r0, =0x00000169 cmp r1, r0 @@ -3739,13 +3739,13 @@ _08086492: bl move_tilemap_camera_to_upper_left_corner b _08086506 _08086498: - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldr r0, [r0] bl copy_map_tileset1_to_vram b _08086506 .pool _080864A8: - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldr r0, [r0] bl copy_map_tileset2_to_vram b _08086506 @@ -3756,7 +3756,7 @@ _080864B8: lsrs r0, 24 cmp r0, 0x1 beq _08086512 - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldr r0, [r0] bl apply_map_tileset1_tileset2_palette b _08086506 @@ -3858,13 +3858,13 @@ _080865A6: bl move_tilemap_camera_to_upper_left_corner b _08086622 _080865AC: - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldr r0, [r0] bl copy_map_tileset1_to_vram b _08086622 .pool _080865BC: - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldr r0, [r0] bl copy_map_tileset2_to_vram b _08086622 @@ -3875,7 +3875,7 @@ _080865CC: lsrs r0, 24 cmp r0, 0x1 beq _0808662E - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldr r0, [r0] bl apply_map_tileset1_tileset2_palette b _08086622 @@ -3887,7 +3887,7 @@ _080865EE: bl cur_mapheader_run_tileset_funcs_after_some_cpuset b _08086622 _080865F4: - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrb r1, [r0, 0x1A] movs r0, 0xF8 ands r0, r1 @@ -4027,13 +4027,13 @@ _0808671E: bl move_tilemap_camera_to_upper_left_corner b _08086792 _08086724: - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldr r0, [r0] bl copy_map_tileset1_to_vram b _08086792 .pool _08086734: - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldr r0, [r0] bl copy_map_tileset2_to_vram b _08086792 @@ -4044,7 +4044,7 @@ _08086744: lsrs r0, 24 cmp r0, 0x1 beq _080867A8 - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldr r0, [r0] bl apply_map_tileset1_tileset2_palette b _08086792 diff --git a/asm/rom6.s b/asm/rom6.s index a0f23d720..ef2d27110 100644 --- a/asm/rom6.s +++ b/asm/rom6.s @@ -88,7 +88,7 @@ task08_080C9820: @ 813549C cmp r0, 0 beq _0813551E _081354D2: - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrb r0, [r0, 0x17] cmp r0, 0x5 bne _08135504 @@ -3346,7 +3346,7 @@ sub_81370FC: @ 81370FC b _08137152 .pool _08137134: - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrb r0, [r0, 0x15] cmp r0, 0x1 bne _08137170 @@ -5213,7 +5213,7 @@ is_tile_that_overrides_player_control: @ 81380D8 lsls r0, 24 cmp r0, 0 beq _0813810A - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrb r0, [r0, 0x17] cmp r0, 0x1 blt _0813810A @@ -5250,7 +5250,7 @@ sub_8138120: @ 8138120 lsls r0, 24 cmp r0, 0 beq _08138152 - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrb r0, [r0, 0x17] cmp r0, 0x1 blt _08138152 @@ -5287,7 +5287,7 @@ sub_8138168: @ 8138168 lsls r0, 24 cmp r0, 0 beq _0813819A - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrb r0, [r0, 0x17] cmp r0, 0x1 blt _0813819A @@ -5324,7 +5324,7 @@ sub_81381B0: @ 81381B0 lsls r0, 24 cmp r0, 0 beq _081381E2 - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrb r0, [r0, 0x17] cmp r0, 0x1 blt _081381E2 @@ -5361,7 +5361,7 @@ sub_81381F8: @ 81381F8 lsls r0, 24 cmp r0, 0 beq _0813822A - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrb r0, [r0, 0x17] cmp r0, 0x1 blt _0813822A diff --git a/asm/rom_80C6FA0.s b/asm/rom_80C6FA0.s index 17399a49d..04d4c29f4 100644 --- a/asm/rom_80C6FA0.s +++ b/asm/rom_80C6FA0.s @@ -26359,7 +26359,7 @@ ShowMapNamePopUpWindow: @ 80D49B0 lsls r0, 24 cmp r0, 0 beq _080D4A08 - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrh r1, [r0, 0x12] movs r0, 0xBD lsls r0, 1 @@ -26391,7 +26391,7 @@ _080D49F2: _080D4A08: mov r4, sp adds r4, 0xF - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrb r1, [r0, 0x14] adds r0, r4, 0 movs r2, 0 @@ -26610,7 +26610,7 @@ LoadMapNamePopUpWindowBg: @ 80D4BE0 bl GetMapNamePopUpWindowId lsls r0, 24 lsrs r5, r0, 24 - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrb r1, [r0, 0x14] cmp r1, 0x57 bls _080D4C0A @@ -26647,7 +26647,7 @@ _080D4C0A: bl CallWindowFunction adds r0, r5, 0 bl PutWindowTilemap - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrb r0, [r0, 0x16] cmp r0, 0xE bne _080D4C6C diff --git a/asm/rom_818CFC8.s b/asm/rom_818CFC8.s index 37e0802be..b78cbccdd 100644 --- a/asm/rom_818CFC8.s +++ b/asm/rom_818CFC8.s @@ -16833,7 +16833,7 @@ _08195ED2: thumb_func_start sub_8195ED8 sub_8195ED8: @ 8195ED8 push {r4,lr} - ldr r4, =gUnknown_02037318 + ldr r4, =gMapHeader ldrb r0, [r4, 0x17] bl is_light_level_1_2_3_or_6 lsls r0, 24 @@ -16857,7 +16857,7 @@ sub_8195ED8: @ 8195ED8 cmp r0, 0 beq _08195F30 _08195F0E: - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrb r0, [r0, 0x14] cmp r0, 0x38 bne _08195F38 @@ -16932,7 +16932,7 @@ sub_8195F68: @ 8195F68 bl sub_8196844 adds r4, r0, 0 bl sub_819672C - ldr r1, =gUnknown_02037318 + ldr r1, =gMapHeader lsls r0, 16 lsrs r0, 16 ldrb r1, [r1, 0x14] @@ -17938,7 +17938,7 @@ sub_81967AC: @ 81967AC beq _081967EC adds r0, r5, 0 bl sub_819672C - ldr r1, =gUnknown_02037318 + ldr r1, =gMapHeader lsls r0, 16 lsrs r0, 16 ldrb r1, [r1, 0x14] @@ -25773,7 +25773,7 @@ _0819A3D6: b _0819A43C .pool _0819A404: - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrb r1, [r0, 0x14] adds r0, r5, 0 bl sub_81245DC @@ -49364,7 +49364,7 @@ _081A6BEE: sub_81A6BF4: @ 81A6BF4 push {lr} movs r2, 0 - ldr r1, =gUnknown_02037318 + ldr r1, =gMapHeader ldr r3, =0xfffffea5 adds r0, r3, 0 ldrh r1, [r1, 0x12] @@ -51948,7 +51948,7 @@ sub_81A8090: @ 81A8090 InBattlePike: @ 81A80A8 push {lr} movs r2, 0 - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrh r1, [r0, 0x12] ldr r3, =0xfffffea1 adds r0, r1, r3 @@ -55513,7 +55513,7 @@ sub_81A9E28: @ 81A9E28 thumb_func_start InBattlePyramid InBattlePyramid: @ 81A9E40 push {lr} - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrh r1, [r0, 0x12] ldr r0, =0x00000169 cmp r1, r0 @@ -55539,7 +55539,7 @@ _081A9E66: sub_81A9E6C: @ 81A9E6C push {lr} movs r2, 0 - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrh r1, [r0, 0x12] ldr r0, =0x00000169 cmp r1, r0 @@ -77653,7 +77653,7 @@ _081B5880: thumb_func_start sub_81B5884 sub_81B5884: @ 81B5884 push {lr} - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrb r0, [r0, 0x17] bl is_light_level_1_2_3_or_6 lsls r0, 24 @@ -85842,7 +85842,7 @@ sub_81B9E88: @ 81B9E88 sub_81B9E94: @ 81B9E94 push {lr} movs r2, 0 - ldr r1, =gUnknown_02037318 + ldr r1, =gMapHeader ldrb r0, [r1, 0x14] cmp r0, 0x8 bne _081B9EB2 diff --git a/asm/rom_81BE66C.s b/asm/rom_81BE66C.s index c1b5f9142..ad83d6402 100644 --- a/asm/rom_81BE66C.s +++ b/asm/rom_81BE66C.s @@ -21069,7 +21069,7 @@ sub_81C98D4: @ 81C98D4 _081C98D8: adds r0, r4, 0 bl sub_81CB0C8 - ldr r1, =gUnknown_02037318 + ldr r1, =gMapHeader lsls r0, 24 lsrs r0, 24 ldrb r1, [r1, 0x14] @@ -23981,7 +23981,7 @@ sub_81CAF78: @ 81CAF78 adds r4, r0, 0 movs r0, 0 strb r0, [r6] - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrb r0, [r0, 0x17] bl is_light_level_1_2_3_or_6 lsls r0, 24 @@ -24309,7 +24309,7 @@ sub_81CB1D0: @ 81CB1D0 bne _081CB218 adds r0, r1, 0 bl sub_81CAEA4 - ldr r1, =gUnknown_02037318 + ldr r1, =gMapHeader lsls r0, 16 lsrs r0, 16 ldrb r1, [r1, 0x14] @@ -24330,7 +24330,7 @@ _081CB218: bne _081CB258 adds r0, r1, 0 bl sub_81CAEA4 - ldr r1, =gUnknown_02037318 + ldr r1, =gMapHeader lsls r0, 16 lsrs r0, 16 ldrb r1, [r1, 0x14] @@ -26717,7 +26717,7 @@ _081CC4F0: b _081CC51A .pool _081CC4F8: - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrb r0, [r0, 0x14] bl sub_8124668 str r0, [r4, 0xC] @@ -44923,7 +44923,7 @@ _081D54EE: thumb_func_start sub_81D5520 sub_81D5520: @ 81D5520 - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrb r0, [r0, 0x12] adds r0, 0x61 lsls r0, 24 @@ -45134,7 +45134,7 @@ sub_81D56B0: @ 81D56B0 ldr r0, =0x00000eec bl AllocZeroed str r0, [r4] - ldr r1, =gUnknown_02037318 + ldr r1, =gMapHeader ldrb r1, [r1, 0x12] adds r1, 0x61 strb r1, [r0] @@ -46192,7 +46192,7 @@ _081D5FE6: lsls r0, 24 lsrs r0, 24 mov r9, r0 - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldr r0, [r0] ldr r2, [r0, 0xC] ldr r1, =gUnknown_03005DC0 @@ -46261,7 +46261,7 @@ _081D605E: thumb_func_start InTrainerHill InTrainerHill: @ 81D6074 push {lr} - ldr r1, =gUnknown_02037318 + ldr r1, =gMapHeader ldr r2, =0xfffffe61 adds r0, r2, 0 ldrh r1, [r1, 0x12] @@ -46283,7 +46283,7 @@ _081D608C: @ u8 GetCurrentTrainerHillMapId() GetCurrentTrainerHillMapId: @ 81D609C push {lr} - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrh r2, [r0, 0x12] ldr r0, =0x0000019f cmp r2, r0 @@ -46335,7 +46335,7 @@ _081D60F8: thumb_func_start sub_81D6100 sub_81D6100: @ 81D6100 push {lr} - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrh r1, [r0, 0x12] ldr r0, =0x000001a3 movs r2, 0 @@ -46369,7 +46369,7 @@ sub_81D6134: @ 81D6134 lsrs r0, 24 cmp r0, 0x1 bne _081D614C - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldr r0, [r0, 0x4] ldr r0, [r0, 0x8] adds r0, 0x8 diff --git a/asm/script.s b/asm/script.s index e625b5625..b55b27eca 100644 --- a/asm/script.s +++ b/asm/script.s @@ -442,7 +442,7 @@ mapheader_get_tagged_pointer: @ 8098F88 push {lr} lsls r0, 24 lsrs r1, r0, 24 - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldr r2, [r0, 0x8] cmp r2, 0 beq _08098F9C diff --git a/asm/secret_base.s b/asm/secret_base.s index 06ccaa9da..99e15fe0f 100644 --- a/asm/secret_base.s +++ b/asm/secret_base.s @@ -251,7 +251,7 @@ sub_80E8CB0: @ 80E8CB0 lsls r2, 16 lsrs r2, 16 mov r10, r2 - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldr r0, [r0] mov r8, r0 movs r0, 0 @@ -502,7 +502,7 @@ _080E8E32: movs r1, 0x2 strb r1, [r0] ldr r0, =0x00004026 - ldr r1, =gUnknown_02037318 + ldr r1, =gMapHeader ldrb r1, [r1, 0x14] bl VarSet pop {r3} @@ -727,7 +727,7 @@ sub_80E9068: @ 80E9068 thumb_func_start sub_80E909C sub_80E909C: @ 80E909C push {lr} - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrb r0, [r0, 0x17] cmp r0, 0x9 bne _080E90C0 @@ -1104,7 +1104,7 @@ _080E93BE: b _080E9554 _080E93D4: movs r5, 0 - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldr r3, [r0, 0x4] ldrb r4, [r3] mov r9, r0 @@ -1294,7 +1294,7 @@ _080E9562: sub_80E9578: @ 80E9578 push {r4-r6,lr} movs r5, 0 - ldr r1, =gUnknown_02037318 + ldr r1, =gMapHeader ldr r0, [r1, 0x4] ldrb r0, [r0] cmp r5, r0 @@ -1936,7 +1936,7 @@ sub_80E9AC0: @ 80E9AC0 thumb_func_start sub_80E9AD0 sub_80E9AD0: @ 80E9AD0 push {r4-r7,lr} - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldr r4, [r0, 0x4] movs r6, 0 b _080E9B62 diff --git a/asm/shop.s b/asm/shop.s index 1e86ea645..d8074a41e 100644 --- a/asm/shop.s +++ b/asm/shop.s @@ -1293,7 +1293,7 @@ BuyMenuDrawMapBg: @ 80E0584 mov r5, r8 push {r5-r7} sub sp, 0x4 - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldr r0, [r0] mov r9, r0 mov r4, sp diff --git a/asm/tileset.s b/asm/tileset.s index 97c1e78c2..0605c7621 100644 --- a/asm/tileset.s +++ b/asm/tileset.s @@ -182,7 +182,7 @@ cur_mapheader_run_tileset1_func: @ 80A0AA8 ldr r1, =gUnknown_03000F40 movs r0, 0 str r0, [r1] - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldr r0, [r0] ldr r0, [r0, 0x10] cmp r0, 0 @@ -208,7 +208,7 @@ cur_mapheader_run_tileset2_func: @ 80A0AE4 ldr r1, =gUnknown_03000F44 movs r0, 0 str r0, [r1] - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldr r0, [r0] ldr r0, [r0, 0x14] cmp r0, 0 diff --git a/asm/tv.s b/asm/tv.s index ccf232dd0..7c80b85a6 100644 --- a/asm/tv.s +++ b/asm/tv.s @@ -742,7 +742,7 @@ GabbyAndTyAfterInterview: @ 80EC448 orrs r0, r2 strb r0, [r1] ldr r0, [r5] - ldr r1, =gUnknown_02037318 + ldr r1, =gMapHeader ldrb r1, [r1, 0x14] ldr r2, =0x00002bac adds r0, r2 @@ -1221,7 +1221,7 @@ _080EC8CA: strh r0, [r4, 0x4] ldrh r0, [r1, 0x6] strh r0, [r4, 0x8] - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrb r0, [r0, 0x14] strb r0, [r4, 0xA] pop {r4} @@ -1309,7 +1309,7 @@ _080EC940: mov r1, r8 ldrb r0, [r1] strb r0, [r4, 0x11] - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrb r0, [r0, 0x14] strb r0, [r4, 0x12] adds r0, r4, 0 @@ -2311,7 +2311,7 @@ SaveRecordedItemPurchasesForTVShow: @ 80ED238 movs r0, 0x16 strb r0, [r5] strb r4, [r5, 0x1] - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrb r0, [r0, 0x14] strb r0, [r5, 0x12] movs r4, 0 @@ -3333,7 +3333,7 @@ _080EDBCC: bl sub_80C0844 _080EDBD2: strh r0, [r4, 0x2] - ldr r1, =gUnknown_02037318 + ldr r1, =gMapHeader ldrb r0, [r1, 0x14] strb r0, [r4, 0x7] ldrh r0, [r1, 0x12] @@ -3491,7 +3491,7 @@ sub_80EDCE8: @ 80EDCE8 ldr r0, =gSpecialVar_0x8005 ldrh r0, [r0] strh r0, [r4, 0x2] - ldr r1, =gUnknown_02037318 + ldr r1, =gMapHeader ldrb r0, [r1, 0x14] strb r0, [r4, 0x4] ldrh r0, [r1, 0x12] @@ -4049,7 +4049,7 @@ _080EE1B6: strb r1, [r4, 0x1] movs r5, 0 ldr r6, =gUnknown_03005D10 - ldr r3, =gUnknown_02037318 + ldr r3, =gMapHeader ldr r7, =gSaveBlock2Ptr adds r2, r6, 0 adds r2, 0x36 diff --git a/asm/weather.s b/asm/weather.s index 7bb483e4a..769d77c6b 100644 --- a/asm/weather.s +++ b/asm/weather.s @@ -7544,7 +7544,7 @@ sub_80AEDBC: @ 80AEDBC ldr r0, [r4] adds r0, 0x2E ldrb r5, [r0] - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrb r0, [r0, 0x16] bl sub_80AEEE8 ldr r1, [r4] diff --git a/asm/wild_encounter.s b/asm/wild_encounter.s index c2e57a3f3..79222e3a9 100644 --- a/asm/wild_encounter.s +++ b/asm/wild_encounter.s @@ -46,7 +46,7 @@ sub_80B48C4: @ 80B48C4 ldrh r5, [r2] cmp r5, r9 bhi _080B496E - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader mov r10, r0 _080B4906: movs r4, 0 @@ -956,7 +956,7 @@ _080B4FBA: cmp r0, 0 beq _080B5000 _080B4FE0: - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrh r1, [r0, 0x12] movs r0, 0xB3 lsls r0, 1 @@ -1191,7 +1191,7 @@ _080B519A: lsrs r0, 24 cmp r0, 0x1 bne _080B51E8 - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrh r1, [r0, 0x12] ldr r0, =0x00000169 cmp r1, r0 @@ -1319,7 +1319,7 @@ _080B52A6: ldr r0, =0x0000ffff cmp r5, r0 bne _080B539C - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrh r1, [r0, 0x12] movs r0, 0xB3 lsls r0, 1 @@ -1658,7 +1658,7 @@ sub_80B5578: @ 80B5578 ldr r0, =0x0000ffff cmp r4, r0 bne _080B562C - ldr r0, =gUnknown_02037318 + ldr r0, =gMapHeader ldrh r1, [r0, 0x12] movs r0, 0xB3 lsls r0, 1 diff --git a/include/rom_818CFC8.h b/include/rom_818CFC8.h new file mode 100644 index 000000000..9b6f96893 --- /dev/null +++ b/include/rom_818CFC8.h @@ -0,0 +1,11 @@ +// +// Created by Scott Norton on 9/6/17. +// + +#ifndef POKEEMERALD_ROM_818CFC8_H +#define POKEEMERALD_ROM_818CFC8_H + +bool8 InBattlePyramid(void); +u8 sub_81AAA40(void); + +#endif //POKEEMERALD_ROM_818CFC8_H diff --git a/include/rom_81BE66C.h b/include/rom_81BE66C.h new file mode 100644 index 000000000..d92c500d6 --- /dev/null +++ b/include/rom_81BE66C.h @@ -0,0 +1,10 @@ +// +// Created by Scott Norton on 9/6/17. +// + +#ifndef POKEEMERALD_ROM_81BE66C_H +#define POKEEMERALD_ROM_81BE66C_H + +bool32 InTrainerHill(void); + +#endif //POKEEMERALD_ROM_81BE66C_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index b97d5c0dc..b33cf0669 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -4,6 +4,9 @@ #include "sprite.h" #include "rom4.h" #include "field_player_avatar.h" +#include "event_data.h" +#include "rom_818CFC8.h" +#include "rom_81BE66C.h" #include "field_map_obj.h" // Static struct declarations @@ -352,3 +355,35 @@ __attribute__((naked)) u8 InitFieldObjectStateFromTemplate(struct MapObjectTempl ".pool"); } #endif + +u8 unref_sub_808D77C(u8 localId) +{ + u8 i; + u8 nObjects; + struct MapObjectTemplate *template; + + if (gMapHeader.events != NULL) + { + if (InBattlePyramid()) + { + nObjects = sub_81AAA40(); + } + else if (InTrainerHill()) + { + nObjects = 2; + } + else + { + nObjects = gMapHeader.events->mapObjectCount; + } + for (i = 0; i < nObjects; i ++) + { + template = &gSaveBlock1Ptr->mapObjectTemplates[i]; + if (template->localId == localId && !FlagGet(template->flagId)) + { + return InitFieldObjectStateFromTemplate(template, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup); + } + } + } + return ARRAY_COUNT(gMapObjects); +} diff --git a/sym_ewram.txt b/sym_ewram.txt index 71b6ffeae..df8f32f6a 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -746,7 +746,7 @@ gUnknown_02032308: @ 2032308 gUnknown_02032318: @ 2032318 .space 0x5000 -gUnknown_02037318: @ 2037318 +gMapHeader: @ 2037318 .space 0x1C gUnknown_02037334: @ 2037334 From e0601236483588158e08dd83da3d6cb8ee491420 Mon Sep 17 00:00:00 2001 From: scnorton Date: Wed, 6 Sep 2017 17:25:20 -0400 Subject: [PATCH 012/191] GetAvailableFieldObjectSlot --- asm/field_map_obj.s | 90 --------------------------------------------- src/field_map_obj.c | 23 ++++++++++++ 2 files changed, 23 insertions(+), 90 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 31b522467..f9366b2e9 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,96 +5,6 @@ .text - thumb_func_start GetAvailableFieldObjectSlot -@ bool8 GetAvailableFieldObjectSlot(u16 localId, u8 mapId, u8 mapGroupId, u8 *fieldObjectId) -GetAvailableFieldObjectSlot: @ 808D810 - push {r4-r7,lr} - mov r12, r3 - lsls r0, 16 - lsrs r6, r0, 16 - lsls r1, 24 - lsrs r5, r1, 24 - lsls r2, 24 - lsrs r4, r2, 24 - movs r2, 0 - ldr r1, =gMapObjects - ldrb r0, [r1] - lsls r0, 31 - adds r7, r1, 0 - cmp r0, 0 - beq _0808D864 - adds r3, r1, 0 -_0808D830: - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - adds r1, r0, r3 - ldrb r0, [r1, 0x8] - cmp r0, r6 - bne _0808D84A - ldrb r0, [r1, 0x9] - cmp r0, r5 - bne _0808D84A - ldrb r0, [r1, 0xA] - cmp r0, r4 - beq _0808D868 -_0808D84A: - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0xF - bhi _0808D868 - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - adds r0, r7 - ldrb r0, [r0] - lsls r0, 31 - cmp r0, 0 - bne _0808D830 -_0808D864: - cmp r2, 0xF - bls _0808D870 -_0808D868: - movs r0, 0x1 - b _0808D8A4 - .pool -_0808D870: - mov r0, r12 - strb r2, [r0] - ldr r1, =gMapObjects -_0808D876: - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - adds r3, r0, r1 - ldrb r0, [r3] - lsls r0, 31 - cmp r0, 0 - beq _0808D898 - ldrb r0, [r3, 0x8] - cmp r0, r6 - bne _0808D898 - ldrb r0, [r3, 0x9] - cmp r0, r5 - bne _0808D898 - ldrb r0, [r3, 0xA] - cmp r0, r4 - beq _0808D868 -_0808D898: - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0xF - bls _0808D876 - movs r0, 0 -_0808D8A4: - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end GetAvailableFieldObjectSlot - thumb_func_start RemoveFieldObject @ void RemoveFieldObject(npc_state *fieldObject) RemoveFieldObject: @ 808D8B0 diff --git a/src/field_map_obj.c b/src/field_map_obj.c index b33cf0669..28f001b5d 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -387,3 +387,26 @@ u8 unref_sub_808D77C(u8 localId) } return ARRAY_COUNT(gMapObjects); } + +bool8 GetAvailableFieldObjectSlot(u16 localId, u8 mapNum, u8 mapGroup, u8 *result) +{ + u8 i = 0; + + for (i = 0; i < ARRAY_COUNT(gMapObjects); i ++) + { + if (!gMapObjects[i].active) + break; + if (gMapObjects[i].localId == localId && gMapObjects[i].mapNum == mapNum && gMapObjects[i].mapGroup == mapGroup) + return TRUE; + } + if (i >= ARRAY_COUNT(gMapObjects)) + return TRUE; + *result = i; + do + { + if (gMapObjects[i].active && gMapObjects[i].localId == localId && gMapObjects[i].mapNum == mapNum && gMapObjects[i].mapGroup == mapGroup) + return TRUE; + i ++; + } while (i < ARRAY_COUNT(gMapObjects)); + return FALSE; +} From a6269f2f0f94d93b834aae8e15a3dea6789b30c0 Mon Sep 17 00:00:00 2001 From: scnorton Date: Wed, 6 Sep 2017 17:29:13 -0400 Subject: [PATCH 013/191] Static --- src/field_map_obj.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 28f001b5d..0a2f6dbea 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -16,9 +16,9 @@ // Static ROM declarations /*static*/ void sub_808D450(void); -/*static*/ u8 GetFieldObjectIdByLocalId(u8); -/*static*/ u8 GetFieldObjectIdByLocalIdAndMapInternal(u8, u8, u8); -/*static*/ bool8 GetAvailableFieldObjectSlot(u16, u8, u8, u8 *); +static u8 GetFieldObjectIdByLocalId(u8); +static u8 GetFieldObjectIdByLocalIdAndMapInternal(u8, u8, u8); +static bool8 GetAvailableFieldObjectSlot(u16, u8, u8, u8 *); /*static*/ void FieldObjectHandleDynamicGraphicsId(struct MapObject *); // ROM data @@ -28,7 +28,7 @@ const u8 gUnknown_0850557C[0x51]; // Code -/*static*/ void npc_clear_ids_and_state(struct MapObject *mapObject) +static void npc_clear_ids_and_state(struct MapObject *mapObject) { *mapObject = (struct MapObject){}; mapObject->localId = 0xFF; @@ -119,7 +119,7 @@ u8 GetFieldObjectIdByXY(s16 x, s16 y) return i; } -u8 GetFieldObjectIdByLocalIdAndMapInternal(u8 localId, u8 mapId, u8 mapGroupId) +static u8 GetFieldObjectIdByLocalIdAndMapInternal(u8 localId, u8 mapId, u8 mapGroupId) { u8 i; @@ -388,7 +388,12 @@ u8 unref_sub_808D77C(u8 localId) return ARRAY_COUNT(gMapObjects); } -bool8 GetAvailableFieldObjectSlot(u16 localId, u8 mapNum, u8 mapGroup, u8 *result) +static bool8 GetAvailableFieldObjectSlot(u16 localId, u8 mapNum, u8 mapGroup, u8 *result) +// Looks for an empty slot. +// Returns FALSE and the location of the available slot +// in *result. +// If no slots are available, or if the object is already +// loaded, returns TRUE. { u8 i = 0; From 942400ddbf15ca8ac9d56279e971dd6f4e1c800d Mon Sep 17 00:00:00 2001 From: scnorton Date: Wed, 6 Sep 2017 17:55:36 -0400 Subject: [PATCH 014/191] RemoveFieldObject --- asm/field_map_obj.s | 14 -------------- src/field_map_obj.c | 7 +++++++ 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index f9366b2e9..5be423e0a 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,20 +5,6 @@ .text - thumb_func_start RemoveFieldObject -@ void RemoveFieldObject(npc_state *fieldObject) -RemoveFieldObject: @ 808D8B0 - push {lr} - ldrb r2, [r0] - movs r1, 0x2 - negs r1, r1 - ands r1, r2 - strb r1, [r0] - bl RemoveFieldObjectInternal - pop {r0} - bx r0 - thumb_func_end RemoveFieldObject - thumb_func_start RemoveFieldObjectByLocalIdAndMap @ void RemoveFieldObjectByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapBank) RemoveFieldObjectByLocalIdAndMap: @ 808D8C4 diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 0a2f6dbea..7420895ab 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -20,6 +20,7 @@ static u8 GetFieldObjectIdByLocalId(u8); static u8 GetFieldObjectIdByLocalIdAndMapInternal(u8, u8, u8); static bool8 GetAvailableFieldObjectSlot(u16, u8, u8, u8 *); /*static*/ void FieldObjectHandleDynamicGraphicsId(struct MapObject *); +/*static*/ void RemoveFieldObjectInternal (struct MapObject *); // ROM data @@ -415,3 +416,9 @@ static bool8 GetAvailableFieldObjectSlot(u16 localId, u8 mapNum, u8 mapGroup, u8 } while (i < ARRAY_COUNT(gMapObjects)); return FALSE; } + +void RemoveFieldObject(struct MapObject *mapObject) +{ + mapObject->active = FALSE; + RemoveFieldObjectInternal(mapObject); +} From 398186d7c42b009218ff1fea17f7b474e1c6389e Mon Sep 17 00:00:00 2001 From: scnorton Date: Wed, 6 Sep 2017 18:12:44 -0400 Subject: [PATCH 015/191] RemoveFieldObjectInternal --- asm/field_map_obj.s | 74 --------------------------------------------- src/field_map_obj.c | 20 ++++++++++++ 2 files changed, 20 insertions(+), 74 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 5be423e0a..436350899 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,80 +5,6 @@ .text - thumb_func_start RemoveFieldObjectByLocalIdAndMap -@ void RemoveFieldObjectByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapBank) -RemoveFieldObjectByLocalIdAndMap: @ 808D8C4 - push {lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r0, 24 - lsls r1, 24 - lsrs r1, 24 - lsls r2, 24 - lsrs r2, 24 - mov r3, sp - bl TryGetFieldObjectIdByLocalIdAndMap - lsls r0, 24 - cmp r0, 0 - bne _0808D902 - mov r0, sp - ldrb r0, [r0] - bl GetFieldObjectFlagIdByFieldObjectId - lsls r0, 16 - lsrs r0, 16 - bl FlagSet - mov r0, sp - ldrb r1, [r0] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, =gMapObjects - adds r0, r1 - bl RemoveFieldObject -_0808D902: - add sp, 0x4 - pop {r0} - bx r0 - .pool - thumb_func_end RemoveFieldObjectByLocalIdAndMap - - thumb_func_start RemoveFieldObjectInternal -@ void RemoveFieldObjectInternal(npc_state *fieldObject) -RemoveFieldObjectInternal: @ 808D90C - push {r4,lr} - sub sp, 0x8 - adds r4, r0, 0 - ldrb r0, [r4, 0x5] - bl GetFieldObjectGraphicsInfo - ldrh r2, [r0, 0x6] - ldr r1, =0xffff0000 - ldr r0, [sp, 0x4] - ands r0, r1 - orrs r0, r2 - str r0, [sp, 0x4] - ldr r2, =gSprites - ldrb r1, [r4, 0x4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r1, r2, 0 - adds r1, 0xC - adds r0, r1 - mov r1, sp - str r1, [r0] - ldrb r1, [r4, 0x4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - bl DestroySprite - add sp, 0x8 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end RemoveFieldObjectInternal - thumb_func_start sub_808D958 sub_808D958: @ 808D958 push {r4,lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 7420895ab..52f798f9b 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -21,6 +21,8 @@ static u8 GetFieldObjectIdByLocalIdAndMapInternal(u8, u8, u8); static bool8 GetAvailableFieldObjectSlot(u16, u8, u8, u8 *); /*static*/ void FieldObjectHandleDynamicGraphicsId(struct MapObject *); /*static*/ void RemoveFieldObjectInternal (struct MapObject *); +/*static*/ u16 GetFieldObjectFlagIdByFieldObjectId(u8); +/*static*/ struct MapObjectGraphicsInfo *GetFieldObjectGraphicsInfo(u8); // ROM data @@ -422,3 +424,21 @@ void RemoveFieldObject(struct MapObject *mapObject) mapObject->active = FALSE; RemoveFieldObjectInternal(mapObject); } + +void RemoveFieldObjectByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup) +{ + u8 index; + if (!TryGetFieldObjectIdByLocalIdAndMap(localId, mapNum, mapGroup, &index)) + { + FlagSet(GetFieldObjectFlagIdByFieldObjectId(index)); + RemoveFieldObject(&gMapObjects[index]); + } +} + +void RemoveFieldObjectInternal(struct MapObject *mapObject) +{ + struct SpriteFrameImage image; + image.size = GetFieldObjectGraphicsInfo(mapObject->graphicsId)->size; + gSprites[mapObject->spriteId].images = ℑ + DestroySprite(&gSprites[mapObject->spriteId]); +} From e0216d60459fac28bf6759159a4c4cfa007bf6c2 Mon Sep 17 00:00:00 2001 From: scnorton Date: Wed, 6 Sep 2017 18:26:37 -0400 Subject: [PATCH 016/191] unref_sub_808D958 --- asm/bike.s | 92 ++++++++++----------- asm/field_camera.s | 2 +- asm/field_control_avatar.s | 4 +- asm/field_effect.s | 106 ++++++++++++------------ asm/field_effect_helpers.s | 2 +- asm/field_map_obj.s | 33 +------- asm/field_player_avatar.s | 164 ++++++++++++++++++------------------- asm/fldeff_80F9BCC.s | 22 ++--- asm/fldeff_emotion.s | 2 +- asm/link.s | 4 +- asm/map_obj_8097404.s | 6 +- asm/map_obj_lock.s | 2 +- asm/porthole.s | 2 +- asm/rom4.s | 2 +- asm/rom6.s | 8 +- asm/rom_80C6FA0.s | 2 +- asm/rom_81BE66C.s | 24 +++--- asm/secret_base.s | 2 +- asm/trainer_see.s | 6 +- include/field_map_obj.h | 6 ++ src/field_map_obj.c | 25 ++++-- sym_ewram.txt | 2 +- 22 files changed, 255 insertions(+), 263 deletions(-) diff --git a/asm/bike.s b/asm/bike.s index 22d52c0fa..7ea4a4598 100644 --- a/asm/bike.s +++ b/asm/bike.s @@ -15,7 +15,7 @@ MovePlayerOnBike: @ 8119164 lsrs r4, r1, 16 lsls r2, 16 lsrs r2, 16 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0] movs r0, 0x2 ands r0, r1 @@ -72,7 +72,7 @@ CheckMovementInputMachBike: @ 81191CC cmp r1, 0 bne _081191F4 strb r0, [r4] - ldr r2, =gUnknown_02037590 + ldr r2, =gPlayerAvatar ldrb r0, [r2, 0xB] cmp r0, 0 bne _08119208 @@ -81,7 +81,7 @@ CheckMovementInputMachBike: @ 81191CC b _0811921C .pool _081191F4: - ldr r2, =gUnknown_02037590 + ldr r2, =gPlayerAvatar cmp r1, r3 beq _08119218 ldrb r0, [r2, 0x2] @@ -126,7 +126,7 @@ sub_8119238: @ 8119238 push {r4,r5,lr} lsls r0, 24 lsrs r5, r0, 24 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -161,7 +161,7 @@ sub_8119280: @ 8119280 lsls r0, 24 lsrs r5, r0, 24 adds r7, r5, 0 - ldr r6, =gUnknown_02037590 + ldr r6, =gPlayerAvatar ldrb r1, [r6, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -255,7 +255,7 @@ sub_8119344: @ 8119344 lsls r0, 24 lsrs r5, r0, 24 adds r7, r5, 0 - ldr r6, =gUnknown_02037590 + ldr r6, =gPlayerAvatar ldrb r0, [r6, 0xB] cmp r0, 0 beq _0811935A @@ -352,7 +352,7 @@ CheckMovementInputAcroBike: @ 8119400 lsls r2, 16 lsrs r2, 16 ldr r4, =gUnknown_0859749C - ldr r3, =gUnknown_02037590 + ldr r3, =gPlayerAvatar ldrb r3, [r3, 0x8] lsls r3, 2 adds r3, r4 @@ -377,7 +377,7 @@ CheckMovementInputAcroBikeNormal: @ 811942C bl player_get_direction_upper_nybble lsls r0, 24 lsrs r3, r0, 24 - ldr r2, =gUnknown_02037590 + ldr r2, =gPlayerAvatar movs r0, 0 strb r0, [r2, 0xA] ldrb r1, [r4] @@ -417,11 +417,11 @@ _0811946C: b _081194C0 _0811948A: ldrb r0, [r4] - ldr r2, =gUnknown_02037590 + ldr r2, =gPlayerAvatar cmp r0, r3 beq _081194BC _08119492: - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x2] adds r2, r0, 0 cmp r1, 0x2 @@ -453,7 +453,7 @@ _081194C0: CheckMovementInputAcroBikeChangingDirection: @ 81194C8 push {r4-r6,lr} adds r5, r0, 0 - ldr r4, =gUnknown_02037590 + ldr r4, =gPlayerAvatar ldrb r0, [r4, 0x9] strb r0, [r5] ldrb r0, [r4, 0xA] @@ -520,7 +520,7 @@ CheckMovementInputAcroBikeStandingWheelie: @ 8119540 bl player_get_direction_upper_nybble lsls r0, 24 lsrs r6, r0, 24 - ldr r5, =gUnknown_02037590 + ldr r5, =gPlayerAvatar ldrb r1, [r5, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -553,7 +553,7 @@ _08119594: adds r0, 0x1 strb r0, [r5, 0xA] _0811959A: - ldr r1, =gUnknown_02037590 + ldr r1, =gPlayerAvatar ldrb r0, [r1, 0xA] cmp r0, 0x27 bls _081195B4 @@ -608,7 +608,7 @@ CheckMovementInputAcroBikeBunnyHop: @ 81195E0 lsls r0, 24 lsrs r5, r0, 24 adds r2, r5, 0 - ldr r4, =gUnknown_02037590 + ldr r4, =gPlayerAvatar ldrb r1, [r4, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -661,7 +661,7 @@ _08119668: movs r0, 0x6 b _08119676 _0811966E: - ldr r1, =gUnknown_02037590 + ldr r1, =gPlayerAvatar movs r0, 0x2 strb r0, [r1, 0x2] movs r0, 0x7 @@ -693,7 +693,7 @@ CheckMovementInputAcroBikeMovingWheelie: @ 8119688 lsls r0, 24 lsrs r5, r0, 24 adds r2, r5, 0 - ldr r4, =gUnknown_02037590 + ldr r4, =gPlayerAvatar ldrb r1, [r4, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -732,7 +732,7 @@ _081196F6: movs r0, 0x4 b _08119750 _081196FC: - ldr r1, =gUnknown_02037590 + ldr r1, =gPlayerAvatar movs r0, 0x2 strb r0, [r1, 0x2] movs r0, 0xC @@ -770,7 +770,7 @@ _08119736: movs r0, 0x5 b _08119750 _08119748: - ldr r1, =gUnknown_02037590 + ldr r1, =gPlayerAvatar movs r0, 0x2 strb r0, [r1, 0x2] movs r0, 0xA @@ -797,7 +797,7 @@ CheckMovementInputAcroBikeUnknownMode5: @ 8119764 lsrs r4, 16 lsls r5, 16 lsrs r5, 16 - ldr r6, =gUnknown_02037590 + ldr r6, =gPlayerAvatar ldrb r1, [r6, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -836,7 +836,7 @@ CheckMovementInputAcroBikeUnknownMode6: @ 81197C0 lsrs r1, 16 lsls r2, 16 lsrs r2, 16 - ldr r4, =gUnknown_02037590 + ldr r4, =gPlayerAvatar movs r3, 0 strb r3, [r4, 0x8] bl CheckMovementInputAcroBike @@ -863,7 +863,7 @@ sub_81197F4: @ 81197F4 push {r4,r5,lr} lsls r0, 24 lsrs r4, r0, 24 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -893,7 +893,7 @@ sub_8119830: @ 8119830 lsls r0, 24 lsrs r5, r0, 24 adds r6, r5, 0 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -961,7 +961,7 @@ sub_81198C0: @ 81198C0 push {r4,r5,lr} lsls r0, 24 lsrs r4, r0, 24 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -990,7 +990,7 @@ sub_81198FC: @ 81198FC push {r4,r5,lr} lsls r0, 24 lsrs r4, r0, 24 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -1019,7 +1019,7 @@ sub_8119938: @ 8119938 push {r4,r5,lr} lsls r0, 24 lsrs r4, r0, 24 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -1048,7 +1048,7 @@ sub_8119974: @ 8119974 push {r4,r5,lr} lsls r0, 24 lsrs r4, r0, 24 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -1077,7 +1077,7 @@ sub_81199B0: @ 81199B0 push {r4,r5,lr} lsls r0, 24 lsrs r4, r0, 24 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -1156,7 +1156,7 @@ _08119A50: bl sub_81197F4 b _08119A84 _08119A58: - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r0, [r0, 0x5] lsls r4, r0, 3 adds r4, r0 @@ -1198,7 +1198,7 @@ sub_8119AA4: @ 8119AA4 lsls r0, 24 lsrs r4, r0, 24 adds r6, r4, 0 - ldr r7, =gUnknown_02037590 + ldr r7, =gPlayerAvatar ldrb r1, [r7, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -1267,7 +1267,7 @@ sub_8119B34: @ 8119B34 lsls r0, 24 lsrs r4, r0, 24 adds r6, r4, 0 - ldr r7, =gUnknown_02037590 + ldr r7, =gPlayerAvatar ldrb r1, [r7, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -1336,7 +1336,7 @@ sub_8119BC4: @ 8119BC4 lsls r0, 24 lsrs r4, r0, 24 adds r6, r4, 0 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -1396,7 +1396,7 @@ sub_8119C3C: @ 8119C3C lsrs r3, r0, 16 lsls r1, 16 lsrs r2, r1, 16 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0] movs r0, 0x4 ands r0, r1 @@ -1421,7 +1421,7 @@ sub_8119C64: @ 8119C64 bl sub_8119DF8 lsls r0, 24 lsrs r2, r0, 24 - ldr r4, =gUnknown_02037590 + ldr r4, =gPlayerAvatar ldr r0, [r4, 0xC] movs r1, 0xF ands r0, r1 @@ -1443,7 +1443,7 @@ _08119C9A: movs r0, 0xF adds r2, r5, 0 ands r2, r0 - ldr r4, =gUnknown_02037590 + ldr r4, =gPlayerAvatar ldr r0, [r4, 0x10] movs r1, 0xF ands r0, r1 @@ -1532,7 +1532,7 @@ sub_8119D30: @ 8119D30 _08119D36: ldr r0, =gUnknown_085974C0 adds r4, r5, r0 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldr r1, [r0, 0xC] ldr r2, [r0, 0x10] ldr r0, [r4, 0x8] @@ -1570,7 +1570,7 @@ _08119D7A: sub_8119D80: @ 8119D80 push {r4,lr} lsls r0, 24 - ldr r3, =gUnknown_02037590 + ldr r3, =gPlayerAvatar ldr r2, [r3, 0xC] lsls r2, 4 movs r1, 0xF0 @@ -1604,7 +1604,7 @@ _08119D9C: sub_8119DBC: @ 8119DBC push {r4,lr} lsls r0, 24 - ldr r3, =gUnknown_02037590 + ldr r3, =gPlayerAvatar ldr r2, [r3, 0x10] lsls r2, 4 movs r1, 0xF0 @@ -1681,7 +1681,7 @@ sub_8119E38: @ 8119E38 adds r6, r0, 0 lsls r6, 24 lsrs r6, 24 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r0, [r0, 0x5] lsls r4, r0, 3 adds r4, r0 @@ -1922,7 +1922,7 @@ _08119FF2: sub_8119FF8: @ 8119FF8 push {r4,lr} sub sp, 0x4 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0] movs r0, 0x18 ands r0, r1 @@ -1966,7 +1966,7 @@ player_should_look_direction_be_enforced_upon_movement: @ 811A044 cmp r0, 0 beq _0811A078 ldr r2, =gMapObjects - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -1996,7 +1996,7 @@ GetOnOffBike: @ 811A080 ldr r1, =gUnknown_02037348 movs r0, 0 strb r0, [r1] - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0] movs r0, 0x6 ands r0, r1 @@ -2026,7 +2026,7 @@ _0811A0C4: thumb_func_start sub_811A0D0 sub_811A0D0: @ 811A0D0 push {lr} - ldr r2, =gUnknown_02037590 + ldr r2, =gPlayerAvatar movs r3, 0 strb r3, [r2, 0x8] strb r3, [r2, 0x9] @@ -2064,7 +2064,7 @@ _0811A0FA: sub_811A114: @ 811A114 lsls r0, 24 lsrs r0, 24 - ldr r2, =gUnknown_02037590 + ldr r2, =gPlayerAvatar strb r0, [r2, 0xA] lsrs r1, r0, 1 adds r0, r1 @@ -2075,7 +2075,7 @@ sub_811A114: @ 811A114 thumb_func_start sub_811A128 sub_811A128: @ 811A128 - ldr r1, =gUnknown_02037590 + ldr r1, =gPlayerAvatar movs r0, 0 strb r0, [r1, 0xA] strb r0, [r1, 0xB] @@ -2091,7 +2091,7 @@ sub_811A138: @ 811A138 mov r0, sp movs r2, 0x6 bl memcpy - ldr r2, =gUnknown_02037590 + ldr r2, =gPlayerAvatar ldrb r1, [r2] movs r0, 0x2 ands r0, r1 @@ -2130,7 +2130,7 @@ _0811A182: sub_811A188: @ 811A188 push {r4,r5,lr} sub sp, 0x4 - ldr r5, =gUnknown_02037590 + ldr r5, =gPlayerAvatar ldrb r1, [r5] movs r0, 0x4 ands r0, r1 diff --git a/asm/field_camera.s b/asm/field_camera.s index cead2954c..35359f444 100644 --- a/asm/field_camera.s +++ b/asm/field_camera.s @@ -1082,7 +1082,7 @@ CameraPanningCB_PanAhead: @ 808A360 b _0808A3FC .pool _0808A374: - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r0, [r0, 0x3] cmp r0, 0x1 bne _0808A394 diff --git a/asm/field_control_avatar.s b/asm/field_control_avatar.s index 85009cc5b..3b1052473 100644 --- a/asm/field_control_avatar.s +++ b/asm/field_control_avatar.s @@ -44,7 +44,7 @@ process_overworld_input: @ 809BF08 lsls r2, 16 lsrs r2, 16 mov r8, r2 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r6, [r0, 0x3] ldrb r0, [r0, 0x2] mov r9, r0 @@ -1368,7 +1368,7 @@ _0809CA04: bl sub_80B215C bl happiness_algorithm_step bl sub_81D4998 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0] movs r0, 0x40 ands r0, r1 diff --git a/asm/field_effect.s b/asm/field_effect.s index b073103f3..03789eada 100644 --- a/asm/field_effect.s +++ b/asm/field_effect.s @@ -2033,7 +2033,7 @@ mapldr_08084390: @ 80B6AA4 movs r1, 0 bl CreateTask ldr r4, =gMapObjects - ldr r3, =gUnknown_02037590 + ldr r3, =gPlayerAvatar ldrb r1, [r3, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -2163,7 +2163,7 @@ sub_80B6BCC: @ 80B6BCC mov r5, r8 push {r5,r6} mov r9, r0 - ldr r6, =gUnknown_02037590 + ldr r6, =gPlayerAvatar ldrb r0, [r6, 0x5] lsls r5, r0, 3 adds r5, r0 @@ -2256,7 +2256,7 @@ _080B6C88: sub_80B6C90: @ 80B6C90 push {r4-r6,lr} adds r5, r0, 0 - ldr r6, =gUnknown_02037590 + ldr r6, =gPlayerAvatar ldrb r0, [r6, 0x4] lsls r2, r0, 4 adds r2, r0 @@ -2309,7 +2309,7 @@ sub_80B6C90: @ 80B6C90 sub_80B6D04: @ 80B6D04 push {r4-r6,lr} adds r4, r0, 0 - ldr r2, =gUnknown_02037590 + ldr r2, =gPlayerAvatar ldrb r1, [r2, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -2454,7 +2454,7 @@ _080B6E0E: thumb_func_start sub_80B6E18 sub_80B6E18: @ 80B6E18 push {lr} - ldr r1, =gUnknown_02037590 + ldr r1, =gPlayerAvatar movs r0, 0 strb r0, [r1, 0x6] bl script_env_2_disable @@ -2551,7 +2551,7 @@ sub_80B6EC0: @ 80B6EC0 sub_80B6EE0: @ 80B6EE0 push {r4,r5,lr} adds r5, r0, 0 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -2664,7 +2664,7 @@ sub_80B6FA8: @ 80B6FA8 sub_80B6FB8: @ 80B6FB8 push {r4,r5,lr} adds r5, r0, 0 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r0, [r0, 0x4] lsls r4, r0, 4 adds r4, r0 @@ -2702,7 +2702,7 @@ _080B6FF6: sub_80B7004: @ 80B7004 push {r4,r5,lr} adds r5, r0, 0 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r0, [r0, 0x4] lsls r4, r0, 4 adds r4, r0 @@ -2828,7 +2828,7 @@ sub_80B7114: @ 80B7114 sub sp, 0x4 adds r5, r0, 0 bl CameraObjectReset2 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r0, [r0, 0x5] lsls r4, r0, 3 adds r4, r0 @@ -2883,7 +2883,7 @@ _080B717E: sub_80B7190: @ 80B7190 push {r4,r5,lr} adds r5, r0, 0 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r0, [r0, 0x4] lsls r4, r0, 4 adds r4, r0 @@ -2914,7 +2914,7 @@ sub_80B7190: @ 80B7190 sub_80B71D0: @ 80B71D0 push {r4,r5,lr} adds r4, r0, 0 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x4] lsls r0, r1, 4 adds r0, r1 @@ -2962,7 +2962,7 @@ _080B721E: sub_80B7230: @ 80B7230 push {r4,r5,lr} adds r5, r0, 0 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r0, [r0, 0x4] lsls r4, r0, 4 adds r4, r0 @@ -2993,7 +2993,7 @@ sub_80B7230: @ 80B7230 sub_80B7270: @ 80B7270 push {r4,r5,lr} adds r4, r0, 0 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x4] lsls r0, r1, 4 adds r0, r1 @@ -3063,7 +3063,7 @@ _080B72EE: thumb_func_start sub_80B72F4 sub_80B72F4: @ 80B72F4 push {r4,lr} - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -3138,7 +3138,7 @@ _080B7396: ldrsh r2, [r4, r0] lsls r2, 2 adds r2, r5 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r0, [r0, 0x5] lsls r1, r0, 3 adds r1, r0 @@ -3162,7 +3162,7 @@ sub_80B73D0: @ 80B73D0 push {r4,lr} adds r4, r0, 0 bl script_env_2_enable - ldr r1, =gUnknown_02037590 + ldr r1, =gPlayerAvatar movs r0, 0x1 strb r0, [r1, 0x6] ldrh r0, [r4, 0x8] @@ -3268,7 +3268,7 @@ _080B748E: cmp r4, 0 bne _080B74C4 bl script_env_2_disable - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar strb r4, [r0, 0x6] ldr r0, =sub_80B7384 bl FindTaskIdByFunc @@ -3347,7 +3347,7 @@ _080B751E: thumb_func_start dive_1_lock dive_1_lock: @ 80B7544 - ldr r2, =gUnknown_02037590 + ldr r2, =gPlayerAvatar movs r1, 0x1 strb r1, [r2, 0x6] ldrh r1, [r0, 0x8] @@ -3393,7 +3393,7 @@ dive_3_unknown: @ 80B7580 cmp r0, 0 bne _080B75C4 ldr r2, =gMapObjects - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -3437,7 +3437,7 @@ sub_80B75F0: @ 80B75F0 lsrs r0, 24 ldr r6, =gUnknown_0855C438 ldr r2, =gTasks - ldr r5, =gUnknown_02037590 + ldr r5, =gPlayerAvatar lsls r1, r0, 2 adds r1, r0 lsls r1, 3 @@ -3480,7 +3480,7 @@ sub_80B764C: @ 80B764C bl CameraObjectReset2 movs r0, 0 bl SetCameraPanningCallback - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar movs r2, 0x1 strb r2, [r0, 0x6] ldrb r0, [r5, 0x3] @@ -3767,7 +3767,7 @@ sub_80B7890: @ 80B7890 lsrs r0, 24 ldr r6, =gUnknown_0855C450 ldr r2, =gTasks - ldr r5, =gUnknown_02037590 + ldr r5, =gPlayerAvatar lsls r1, r0, 2 adds r1, r0 lsls r1, 3 @@ -3808,7 +3808,7 @@ sub_80B78EC: @ 80B78EC adds r4, r1, 0 bl CameraObjectReset2 bl player_bitmagic - ldr r1, =gUnknown_02037590 + ldr r1, =gPlayerAvatar movs r0, 0x1 strb r0, [r1, 0x6] ldrb r0, [r4, 0x1] @@ -3915,7 +3915,7 @@ sub_80B79BC: @ 80B79BC lsls r0, 24 cmp r0, 0 beq _080B79E6 - ldr r1, =gUnknown_02037590 + ldr r1, =gPlayerAvatar movs r0, 0 strb r0, [r1, 0x6] bl script_env_2_disable @@ -4016,7 +4016,7 @@ sub_80B7A8C: @ 80B7A8C lsrs r0, 24 ldr r6, =gUnknown_0855C460 ldr r2, =gTasks - ldr r5, =gUnknown_02037590 + ldr r5, =gPlayerAvatar lsls r1, r0, 2 adds r1, r0 lsls r1, 3 @@ -4057,7 +4057,7 @@ sub_80B7AE8: @ 80B7AE8 adds r4, r1, 0 bl player_bitmagic bl CameraObjectReset2 - ldr r1, =gUnknown_02037590 + ldr r1, =gPlayerAvatar movs r0, 0x1 strb r0, [r1, 0x6] ldrb r0, [r4, 0x3] @@ -4359,7 +4359,7 @@ sub_80B7D34: @ 80B7D34 bl music_something bl sub_80AF0B4 _080B7D60: - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -4466,7 +4466,7 @@ mapldr_080859D4: @ 80B7E48 movs r0, 0 str r0, [r1] ldr r2, =gMapObjects - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -4537,7 +4537,7 @@ sub_80B7EE8: @ 80B7EE8 mov r0, sp movs r2, 0x5 bl memcpy - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -4695,7 +4695,7 @@ sub_80B8034: @ 80B8034 mov r0, sp movs r2, 0x5 bl memcpy - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -4765,7 +4765,7 @@ sub_80B80C4: @ 80B80C4 mov r0, sp movs r2, 0x5 bl memcpy - ldr r2, =gUnknown_02037590 + ldr r2, =gPlayerAvatar ldrb r1, [r2, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -4911,7 +4911,7 @@ mapldr_08085D88: @ 80B8200 movs r0, 0 str r0, [r1] ldr r2, =gMapObjects - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -4961,7 +4961,7 @@ sub_80B8280: @ 80B8280 lsls r0, 24 cmp r0, 0 beq _080B82F6 - ldr r5, =gUnknown_02037590 + ldr r5, =gPlayerAvatar ldrb r0, [r5, 0x4] lsls r2, r0, 4 adds r2, r0 @@ -5027,7 +5027,7 @@ sub_80B830C: @ 80B830C mov r0, sp movs r2, 0x5 bl memcpy - ldr r2, =gUnknown_02037590 + ldr r2, =gPlayerAvatar ldrb r1, [r2, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -5156,7 +5156,7 @@ sub_80B8410: @ 80B8410 mov r0, sp movs r2, 0x5 bl memcpy - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -6335,7 +6335,7 @@ sub_80B8DB4: @ 80B8DB4 adds r4, r0, 0 bl script_env_2_enable bl player_bitmagic - ldr r5, =gUnknown_02037590 + ldr r5, =gPlayerAvatar movs r0, 0x1 strb r0, [r5, 0x6] movs r0, 0x8 @@ -6374,7 +6374,7 @@ sub_80B8DB4: @ 80B8DB4 sub_80B8E14: @ 80B8E14 push {r4,r5,lr} adds r5, r0, 0 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -6410,7 +6410,7 @@ _080B8E50: sub_80B8E60: @ 80B8E60 push {r4,lr} adds r4, r0, 0 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -6449,7 +6449,7 @@ sub_80B8EA8: @ 80B8EA8 lsls r0, 24 cmp r0, 0 bne _080B8F12 - ldr r5, =gUnknown_02037590 + ldr r5, =gPlayerAvatar ldrb r0, [r5, 0x5] lsls r4, r0, 3 adds r4, r0 @@ -6498,7 +6498,7 @@ _080B8F12: thumb_func_start sub_80B8F24 sub_80B8F24: @ 80B8F24 push {r4,r5,lr} - ldr r5, =gUnknown_02037590 + ldr r5, =gPlayerAvatar ldrb r1, [r5, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -6829,7 +6829,7 @@ sub_80B91D4: @ 80B91D4 sub_80B9204: @ 80B9204 push {r4-r6,lr} adds r5, r0, 0 - ldr r6, =gUnknown_02037590 + ldr r6, =gPlayerAvatar ldrb r1, [r6, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -6870,7 +6870,7 @@ _080B924C: sub_80B925C: @ 80B925C push {r4,lr} adds r4, r0, 0 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -6906,7 +6906,7 @@ sub_80B92A0: @ 80B92A0 lsls r0, 24 cmp r0, 0 bne _080B92E8 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -6955,7 +6955,7 @@ sub_80B92F8: @ 80B92F8 strh r0, [r4, 0xC] movs r0, 0x1 bl SetPlayerAvatarTransitionFlags - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -6975,7 +6975,7 @@ _080B932C: sub_80B933C: @ 80B933C push {r4,lr} adds r4, r0, 0 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -7023,7 +7023,7 @@ sub_80B9390: @ 80B9390 asrs r0, 16 cmp r0, 0x7 ble _080B9406 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -7087,7 +7087,7 @@ sub_80B9418: @ 80B9418 asrs r0, 16 cmp r0, 0x9 ble _080B9464 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r0, [r0, 0x5] lsls r4, r0, 3 adds r4, r0 @@ -7582,7 +7582,7 @@ sub_80B97D4: @ 80B97D4 sub_80B9804: @ 80B9804 push {r4-r6,lr} adds r5, r0, 0 - ldr r6, =gUnknown_02037590 + ldr r6, =gPlayerAvatar ldrb r1, [r6, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -7673,7 +7673,7 @@ sub_80B98B8: @ 80B98B8 cmp r0, 0 bne _080B9910 _080B98D0: - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -7720,7 +7720,7 @@ sub_80B9924: @ 80B9924 mov r0, sp movs r2, 0x24 bl memcpy - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r0, [r0, 0x4] lsls r1, r0, 4 adds r1, r0 @@ -7760,7 +7760,7 @@ sub_80B9978: @ 80B9978 lsls r0, 24 cmp r0, 0 beq _080B99DC - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r0, [r0, 0x5] lsls r5, r0, 3 adds r5, r0 @@ -7810,7 +7810,7 @@ _080B99DC: sub_80B99F0: @ 80B99F0 push {r4,lr} adds r4, r0, 0 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -7872,7 +7872,7 @@ sub_80B9A60: @ 80B9A60 lsls r0, 16 cmp r0, 0 bne _080B9ACA - ldr r6, =gUnknown_02037590 + ldr r6, =gPlayerAvatar ldrb r1, [r6, 0x5] lsls r0, r1, 3 adds r0, r1 diff --git a/asm/field_effect_helpers.s b/asm/field_effect_helpers.s index 69c67672c..cef6287ff 100644 --- a/asm/field_effect_helpers.s +++ b/asm/field_effect_helpers.s @@ -2766,7 +2766,7 @@ sub_81554AC: @ 81554AC ldrsh r1, [r4, r2] bl CurrentMapDrawMetatileAt ldr r2, =gMapObjects - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 436350899..ff3aff842 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,33 +5,6 @@ .text - thumb_func_start sub_808D958 -sub_808D958: @ 808D958 - push {r4,lr} - movs r4, 0 -_0808D95C: - ldr r0, =gUnknown_02037590 - ldrb r0, [r0, 0x5] - cmp r4, r0 - beq _0808D972 - lsls r0, r4, 3 - adds r0, r4 - lsls r0, 2 - ldr r1, =gMapObjects - adds r0, r1 - bl RemoveFieldObject -_0808D972: - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0xF - bls _0808D95C - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_808D958 - thumb_func_start SpawnFieldObjectInternal @ u8 SpawnFieldObjectInternal(struct FieldObjectTemplate *romFieldObject, struct objtemplate *template, int mapId, int mapGroupId, u16 movingCameraOffsetX, u16 movingCameraOffsetY) SpawnFieldObjectInternal: @ 808D98C @@ -1351,7 +1324,7 @@ SetPlayerAvatarFieldObjectIdAndObjectId: @ 808E3C4 push {r4,r5,lr} lsls r0, 24 lsrs r0, 24 - ldr r5, =gUnknown_02037590 + ldr r5, =gPlayerAvatar strb r0, [r5, 0x5] strb r1, [r5, 0x4] ldr r1, =gMapObjects @@ -9413,7 +9386,7 @@ sub_8091EC0: @ 8091EC0 adds r6, r0, 0 adds r7, r1, 0 ldr r2, =gMapObjects - ldr r3, =gUnknown_02037590 + ldr r3, =gPlayerAvatar ldrb r1, [r3, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -10168,7 +10141,7 @@ mss_08062EA4: @ 80924D8 adds r6, r0, 0 adds r7, r1, 0 ldr r2, =gMapObjects - ldr r3, =gUnknown_02037590 + ldr r3, =gPlayerAvatar ldrb r1, [r3, 0x5] lsls r0, r1, 3 adds r0, r1 diff --git a/asm/field_player_avatar.s b/asm/field_player_avatar.s index 9a5cc323c..e9fee369a 100644 --- a/asm/field_player_avatar.s +++ b/asm/field_player_avatar.s @@ -43,7 +43,7 @@ player_step: @ 808A9C0 lsrs r7, r1, 16 lsls r2, 16 lsrs r6, r2, 16 - ldr r4, =gUnknown_02037590 + ldr r4, =gPlayerAvatar ldrb r1, [r4, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -153,7 +153,7 @@ npc_clear_strange_bits: @ 808AA9C adds r2, 0x2 ands r1, r2 strb r1, [r0, 0x1] - ldr r2, =gUnknown_02037590 + ldr r2, =gPlayerAvatar ldrb r1, [r2] movs r0, 0x7F ands r0, r1 @@ -172,7 +172,7 @@ MovePlayerAvatarUsingKeypadInput: @ 808AAC0 lsrs r4, r1, 16 lsls r2, 16 lsrs r2, 16 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0] movs r0, 0x6 ands r0, r1 @@ -197,7 +197,7 @@ _0808AAF0: @ void PlayerAllowForcedMovementIfMovingSameDirection() PlayerAllowForcedMovementIfMovingSameDirection: @ 808AAF8 push {lr} - ldr r2, =gUnknown_02037590 + ldr r2, =gPlayerAvatar ldrb r0, [r2, 0x2] cmp r0, 0x2 bne _0808AB0A @@ -234,7 +234,7 @@ TryDoMetatileBehaviorForcedMovment: @ 808AB14 @ u8 GetForcedMovementByMetatileBehavior() GetForcedMovementByMetatileBehavior: @ 808AB38 push {r4-r6,lr} - ldr r3, =gUnknown_02037590 + ldr r3, =gPlayerAvatar ldrb r1, [r3] movs r0, 0x20 ands r0, r1 @@ -280,7 +280,7 @@ _0808AB8C: thumb_func_start ForcedMovement_None ForcedMovement_None: @ 808AB94 push {r4,lr} - ldr r4, =gUnknown_02037590 + ldr r4, =gPlayerAvatar ldrb r1, [r4] movs r0, 0x40 ands r0, r1 @@ -325,7 +325,7 @@ DoForcedMovement: @ 808ABE0 mov r9, r1 lsls r0, 24 lsrs r5, r0, 24 - ldr r6, =gUnknown_02037590 + ldr r6, =gPlayerAvatar adds r0, r5, 0 bl CheckForPlayerAvatarCollision lsls r0, 24 @@ -381,7 +381,7 @@ _0808AC48: DoForcedMovementInCurrentDirection: @ 808AC58 push {lr} adds r1, r0, 0 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r2, [r0, 0x5] lsls r0, r2, 3 adds r0, r2 @@ -523,7 +523,7 @@ ForcedMovement_Slide: @ 808AD60 push {r4,lr} lsls r0, 24 lsrs r0, 24 - ldr r2, =gUnknown_02037590 + ldr r2, =gPlayerAvatar ldrb r3, [r2, 0x5] lsls r2, r3, 3 adds r2, r3 @@ -618,7 +618,7 @@ ForcedMovement_0xBC: @ 808AE04 thumb_func_start ForcedMovement_MuddySlope ForcedMovement_MuddySlope: @ 808AE10 push {r4,lr} - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -691,7 +691,7 @@ CheckMovementInputNotOnBike: @ 808AE98 lsrs r4, r0, 24 cmp r4, 0 bne _0808AEB0 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar strb r4, [r0, 0x2] movs r0, 0 b _0808AED2 @@ -702,7 +702,7 @@ _0808AEB0: lsrs r0, 24 cmp r4, r0 beq _0808AECC - ldr r1, =gUnknown_02037590 + ldr r1, =gPlayerAvatar ldrb r0, [r1, 0x2] cmp r0, 0x2 beq _0808AECC @@ -710,7 +710,7 @@ _0808AEB0: b _0808AED0 .pool _0808AECC: - ldr r1, =gUnknown_02037590 + ldr r1, =gPlayerAvatar movs r0, 0x2 _0808AED0: strb r0, [r1, 0x2] @@ -784,7 +784,7 @@ _0808AF3C: bl PlayerNotOnBikeCollide b _0808AFB6 _0808AF4E: - ldr r4, =gUnknown_02037590 + ldr r4, =gPlayerAvatar ldrb r1, [r4] movs r0, 0x8 ands r0, r1 @@ -843,7 +843,7 @@ CheckForPlayerAvatarCollision: @ 808AFBC adds r6, r0, 0 lsls r6, 24 lsrs r6, 24 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r0, [r0, 0x5] lsls r4, r0, 3 adds r4, r0 @@ -894,7 +894,7 @@ sub_808B028: @ 808B028 adds r6, r0, 0 lsls r6, 24 lsrs r6, 24 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r0, [r0, 0x5] lsls r4, r0, 3 adds r4, r0 @@ -1102,7 +1102,7 @@ sub_808B1BC: @ 808B1BC lsrs r4, r1, 16 lsls r2, 24 lsrs r6, r2, 24 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0] movs r0, 0x8 ands r0, r1 @@ -1285,7 +1285,7 @@ IsPlayerCollidingWithFarawayIslandMew: @ 808B324 sub sp, 0x4 lsls r0, 24 lsrs r0, 24 - ldr r1, =gUnknown_02037590 + ldr r1, =gPlayerAvatar ldrb r2, [r1, 0x5] lsls r1, r2, 3 adds r1, r2 @@ -1369,7 +1369,7 @@ SetPlayerAvatarTransitionFlags: @ 808B3CC push {lr} lsls r0, 16 lsrs r0, 16 - ldr r2, =gUnknown_02037590 + ldr r2, =gPlayerAvatar ldrb r1, [r2, 0x1] orrs r0, r1 strb r0, [r2, 0x1] @@ -1383,7 +1383,7 @@ SetPlayerAvatarTransitionFlags: @ 808B3CC @ void DoPlayerAvatarTransition() DoPlayerAvatarTransition: @ 808B3E8 push {r4,r5,lr} - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r4, [r0, 0x1] cmp r4, 0 beq _0808B428 @@ -1396,7 +1396,7 @@ _0808B3F4: ldr r0, =gUnknown_084974B8 lsls r2, r5, 2 adds r2, r0 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -1412,7 +1412,7 @@ _0808B416: lsrs r4, 1 cmp r5, 0x7 bls _0808B3F4 - ldr r1, =gUnknown_02037590 + ldr r1, =gPlayerAvatar movs r0, 0 strb r0, [r1, 0x1] _0808B428: @@ -1529,7 +1529,7 @@ PlayerAvatarTransition_Surfing: @ 808B4D8 movs r2, 0x12 ldrsh r0, [r4, r2] str r0, [r1, 0x4] - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r0, [r0, 0x5] str r0, [r1, 0x8] movs r0, 0x8 @@ -1574,7 +1574,7 @@ PlayerAvatarTransition_Underwater: @ 808B534 thumb_func_start PlayerAvatarTransition_ReturnToField @ void PlayerAvatarTransition_ReturnToField(struct npc_state *fieldObject) PlayerAvatarTransition_ReturnToField: @ 808B568 - ldr r2, =gUnknown_02037590 + ldr r2, =gPlayerAvatar ldrb r1, [r2] movs r0, 0x20 orrs r0, r1 @@ -1586,7 +1586,7 @@ PlayerAvatarTransition_ReturnToField: @ 808B568 thumb_func_start sub_808B578 sub_808B578: @ 808B578 push {r4,lr} - ldr r4, =gUnknown_02037590 + ldr r4, =gPlayerAvatar movs r0, 0 strb r0, [r4, 0x3] bl PlayerIsAnimActive @@ -1622,7 +1622,7 @@ _0808B5B6: player_is_anim_in_certain_ranges: @ 808B5BC push {lr} ldr r2, =gMapObjects - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -1673,7 +1673,7 @@ sub_808B618: @ 808B618 lsls r0, 24 cmp r0, 0 beq _0808B634 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r0, [r0, 0x2] cmp r0, 0x1 beq _0808B634 @@ -1691,7 +1691,7 @@ _0808B636: @ bool8 PlayerIsAnimActive() PlayerIsAnimActive: @ 808B63C push {lr} - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -1710,7 +1710,7 @@ PlayerIsAnimActive: @ 808B63C @ bool8 PlayerCheckIfAnimFinishedOrInactive() PlayerCheckIfAnimFinishedOrInactive: @ 808B660 push {lr} - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -1728,7 +1728,7 @@ PlayerCheckIfAnimFinishedOrInactive: @ 808B660 thumb_func_start player_set_x22 player_set_x22: @ 808B684 ldr r3, =gMapObjects - ldr r1, =gUnknown_02037590 + ldr r1, =gPlayerAvatar ldrb r2, [r1, 0x5] lsls r1, r2, 3 adds r1, r2 @@ -1743,7 +1743,7 @@ player_set_x22: @ 808B684 thumb_func_start player_get_x22 player_get_x22: @ 808B6A0 ldr r2, =gMapObjects - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -1761,7 +1761,7 @@ sub_808B6BC: @ 808B6BC adds r1, r0, 0 lsls r1, 24 lsrs r1, 24 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r2, [r0, 0x5] lsls r0, r2, 3 adds r0, r2 @@ -1788,7 +1788,7 @@ player_npc_set_state_and_x22_etc: @ 808B6E4 bne _0808B712 adds r0, r4, 0 bl player_set_x22 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -2002,7 +2002,7 @@ PlayerJumpLedge: @ 808B840 thumb_func_start sub_808B864 sub_808B864: @ 808B864 push {r4,lr} - ldr r4, =gUnknown_02037590 + ldr r4, =gPlayerAvatar ldrb r0, [r4, 0x3] cmp r0, 0x2 beq _0808B872 @@ -2220,7 +2220,7 @@ PlayCollisionSoundIfNotFacingWarp: @ 808B9EC lsls r0, 24 lsrs r4, r0, 24 ldr r2, =gMapObjects - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -2276,7 +2276,7 @@ GetXYCoordsOneStepInFrontOfPlayer: @ 808BA68 adds r4, r0, 0 adds r5, r1, 0 ldr r3, =gMapObjects - ldr r2, =gUnknown_02037590 + ldr r2, =gPlayerAvatar ldrb r1, [r2, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -2308,7 +2308,7 @@ GetXYCoordsOneStepInFrontOfPlayer: @ 808BA68 PlayerGetDestCoords: @ 808BAAC push {r4,r5,lr} ldr r5, =gMapObjects - ldr r4, =gUnknown_02037590 + ldr r4, =gPlayerAvatar ldrb r3, [r4, 0x5] lsls r2, r3, 3 adds r2, r3 @@ -2334,7 +2334,7 @@ plaer_get_pos_including_state_based_drift: @ 808BADC push {r4,r5,lr} adds r4, r0, 0 adds r5, r1, 0 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -2466,7 +2466,7 @@ _0808BC30: @ u8 player_get_direction_lower_nybble() player_get_direction_lower_nybble: @ 808BC38 ldr r2, =gMapObjects - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -2483,7 +2483,7 @@ player_get_direction_lower_nybble: @ 808BC38 @ u8 player_get_direction_upper_nybble() player_get_direction_upper_nybble: @ 808BC58 ldr r2, =gMapObjects - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -2499,7 +2499,7 @@ player_get_direction_upper_nybble: @ 808BC58 @ u8 PlayerGetZCoord() PlayerGetZCoord: @ 808BC74 ldr r2, =gMapObjects - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -2516,7 +2516,7 @@ sub_808BC90: @ 808BC90 push {lr} adds r3, r0, 0 adds r2, r1, 0 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -2537,7 +2537,7 @@ sub_808BC90: @ 808BC90 thumb_func_start TestPlayerAvatarFlags @ u32 TestPlayerAvatarFlags(u32 mask) TestPlayerAvatarFlags: @ 808BCC0 - ldr r1, =gUnknown_02037590 + ldr r1, =gPlayerAvatar ldrb r1, [r1] ands r1, r0 adds r0, r1, 0 @@ -2547,7 +2547,7 @@ TestPlayerAvatarFlags: @ 808BCC0 thumb_func_start sub_808BCD0 sub_808BCD0: @ 808BCD0 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r0, [r0] bx lr .pool @@ -2556,7 +2556,7 @@ sub_808BCD0: @ 808BCD0 thumb_func_start GetPlayerAvatarObjectId @ u8 GetPlayerAvatarObjectId() GetPlayerAvatarObjectId: @ 808BCDC - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r0, [r0, 0x4] bx lr .pool @@ -2573,7 +2573,7 @@ sub_808BCE8: @ 808BCE8 thumb_func_start sub_808BCF4 sub_808BCF4: @ 808BCF4 push {r4,lr} - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r0, [r0, 0x5] lsls r4, r0, 3 adds r4, r0 @@ -2659,7 +2659,7 @@ GetPlayerAvatarGraphicsIdByStateId: @ 808BD8C push {lr} lsls r0, 24 lsrs r0, 24 - ldr r1, =gUnknown_02037590 + ldr r1, =gPlayerAvatar ldrb r1, [r1, 0x7] bl GetPlayerAvatarGraphicsIdByStateIdAndGender lsls r0, 24 @@ -2804,7 +2804,7 @@ _0808BE70: IsPlayerFacingSurfableFishableWater: @ 808BE74 push {r4,r5,lr} sub sp, 0x4 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r0, [r0, 0x5] lsls r4, r0, 3 adds r4, r0 @@ -2871,7 +2871,7 @@ _0808BEF6: @ void ClearPlayerAvatarInfo() ClearPlayerAvatarInfo: @ 808BF00 push {lr} - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar movs r1, 0 movs r2, 0x24 bl memset @@ -2885,7 +2885,7 @@ ClearPlayerAvatarInfo: @ 808BF00 SetPlayerAvatarStateMask: @ 808BF14 lsls r0, 24 lsrs r0, 24 - ldr r3, =gUnknown_02037590 + ldr r3, =gPlayerAvatar ldrb r2, [r3] movs r1, 0xE0 ands r1, r2 @@ -2937,7 +2937,7 @@ _0808BF64: @ u8 GetPlayerAvatarGraphicsIdByCurrentState() GetPlayerAvatarGraphicsIdByCurrentState: @ 808BF6C push {r4-r6,lr} - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r5, [r0] movs r2, 0 ldr r3, =gUnknown_0849750C @@ -2980,7 +2980,7 @@ SetPlayerAvatarExtraStateTransition: @ 808BFB0 lsrs r0, 24 lsls r4, 24 lsrs r4, 24 - ldr r5, =gUnknown_02037590 + ldr r5, =gPlayerAvatar ldrb r1, [r5, 0x7] bl GetPlayerAvatarStateTransitionByGraphicsId lsls r0, 24 @@ -3072,7 +3072,7 @@ InitPlayerAvatar: @ 808BFE0 mov r1, r9 bl FieldObjectTurn bl ClearPlayerAvatarInfo - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar strb r6, [r0, 0x2] strb r6, [r0, 0x3] strb r5, [r0, 0x5] @@ -3098,7 +3098,7 @@ sub_808C0A8: @ 808C0A8 lsls r0, 24 lsrs r4, r0, 24 ldr r6, =gMapObjects - ldr r5, =gUnknown_02037590 + ldr r5, =gPlayerAvatar ldrb r0, [r5, 0x5] lsls r1, r0, 3 adds r1, r0 @@ -3147,7 +3147,7 @@ _0808C100: thumb_func_start sub_808C114 sub_808C114: @ 808C114 push {r4,r5,lr} - ldr r5, =gUnknown_02037590 + ldr r5, =gPlayerAvatar ldrb r0, [r5, 0x5] lsls r4, r0, 3 adds r4, r0 @@ -3181,7 +3181,7 @@ sub_808C15C: @ 808C15C adds r5, r0, 0 lsls r5, 24 lsrs r5, 24 - ldr r6, =gUnknown_02037590 + ldr r6, =gPlayerAvatar ldrb r0, [r6, 0x5] lsls r4, r0, 3 adds r4, r0 @@ -3222,7 +3222,7 @@ sub_808C1B4: @ 808C1B4 adds r5, r0, 0 lsls r5, 24 lsrs r5, 24 - ldr r6, =gUnknown_02037590 + ldr r6, =gPlayerAvatar ldrb r0, [r6, 0x5] lsls r4, r0, 3 adds r4, r0 @@ -3271,7 +3271,7 @@ sub_808C228: @ 808C228 adds r5, r0, 0 lsls r5, 24 lsrs r5, 24 - ldr r6, =gUnknown_02037590 + ldr r6, =gPlayerAvatar ldrb r0, [r6, 0x5] lsls r4, r0, 3 adds r4, r0 @@ -3424,7 +3424,7 @@ _0808C360: ldrsh r3, [r4, r0] lsls r3, 2 adds r3, r6 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r0, [r0, 0x5] lsls r1, r0, 3 adds r1, r0 @@ -3453,7 +3453,7 @@ sub_808C3A4: @ 808C3A4 push {r4,lr} adds r4, r0, 0 bl script_env_2_enable - ldr r1, =gUnknown_02037590 + ldr r1, =gPlayerAvatar movs r0, 0x1 strb r0, [r1, 0x6] ldrh r0, [r4, 0x8] @@ -3571,7 +3571,7 @@ sub_808C484: @ 808C484 bl FieldObjectClearAnimIfSpecialAnimFinished adds r0, r5, 0 bl FieldObjectClearAnimIfSpecialAnimFinished - ldr r1, =gUnknown_02037590 + ldr r1, =gPlayerAvatar movs r0, 0 strb r0, [r1, 0x6] bl script_env_2_disable @@ -3620,7 +3620,7 @@ _0808C50A: ldrsh r2, [r4, r0] lsls r2, 2 adds r2, r5 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r0, [r0, 0x5] lsls r1, r0, 3 adds r1, r0 @@ -3644,7 +3644,7 @@ sub_808C544: @ 808C544 push {r4-r6,lr} adds r6, r0, 0 adds r4, r1, 0 - ldr r5, =gUnknown_02037590 + ldr r5, =gPlayerAvatar movs r0, 0x1 strb r0, [r5, 0x6] adds r0, r4, 0 @@ -3721,7 +3721,7 @@ _0808C5E2: ldrsh r2, [r4, r0] lsls r2, 2 adds r2, r5 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r0, [r0, 0x5] lsls r1, r0, 3 adds r1, r0 @@ -3749,7 +3749,7 @@ sub_808C61C: @ 808C61C ldrb r1, [r1, 0x18] lsrs r1, 4 strh r1, [r0, 0xA] - ldr r1, =gUnknown_02037590 + ldr r1, =gPlayerAvatar movs r0, 0x1 strb r0, [r1, 0x6] bl script_env_2_enable @@ -3873,7 +3873,7 @@ sub_808C6FC: @ 808C6FC adds r0, r5, 0 bl FieldObjectSetSpecialAnim bl script_env_2_disable - ldr r1, =gUnknown_02037590 + ldr r1, =gPlayerAvatar movs r0, 0 strb r0, [r1, 0x6] ldr r0, =sub_808C5D0 @@ -3898,7 +3898,7 @@ sub_808C750: @ 808C750 bl script_env_2_enable bl sav1_reset_battle_music_maybe bl sub_8085898 - ldr r2, =gUnknown_02037590 + ldr r2, =gPlayerAvatar ldrb r1, [r2] movs r0, 0xF7 ands r0, r1 @@ -3931,7 +3931,7 @@ taskFF_0805D1D4: @ 808C7A8 push {r4-r6,lr} lsls r0, 24 lsrs r6, r0, 24 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -3978,7 +3978,7 @@ sub_808C814: @ 808C814 push {r4-r6,lr} lsls r0, 24 lsrs r5, r0, 24 - ldr r6, =gUnknown_02037590 + ldr r6, =gPlayerAvatar ldrb r1, [r6, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -4083,7 +4083,7 @@ fish0: @ 808C8F8 push {r4,lr} adds r4, r0, 0 bl script_env_2_enable - ldr r1, =gUnknown_02037590 + ldr r1, =gPlayerAvatar movs r0, 0x1 strb r0, [r1, 0x6] ldrh r0, [r4, 0x8] @@ -4128,7 +4128,7 @@ fish1: @ 808C918 adds r1, r0 strh r1, [r5, 0x22] ldr r3, =gMapObjects - ldr r2, =gUnknown_02037590 + ldr r2, =gPlayerAvatar ldrb r1, [r2, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -4366,7 +4366,7 @@ _0808CB30: _0808CB32: cmp r6, 0x1 bne _0808CB5C - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r0, [r0, 0x4] lsls r4, r0, 4 adds r4, r0 @@ -4574,7 +4574,7 @@ _0808CCBC: lsrs r6, r0, 16 cmp r6, 0 bne _0808CD50 - ldr r7, =gUnknown_02037590 + ldr r7, =gPlayerAvatar ldrb r0, [r7, 0x5] lsls r4, r0, 3 adds r4, r0 @@ -4633,7 +4633,7 @@ _0808CD50: cmp r0, 0 beq _0808CD80 _0808CD58: - ldr r1, =gUnknown_02037590 + ldr r1, =gPlayerAvatar movs r0, 0 strb r0, [r1, 0x6] bl script_env_2_disable @@ -4664,7 +4664,7 @@ fishB: @ 808CD94 sub sp, 0x10 adds r5, r0, 0 bl sub_808CF78 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r0, [r0, 0x4] lsls r4, r0, 4 adds r4, r0 @@ -4712,7 +4712,7 @@ fishC: @ 808CE04 sub sp, 0x10 adds r5, r0, 0 bl sub_808CF78 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r0, [r0, 0x4] lsls r4, r0, 4 adds r4, r0 @@ -4777,7 +4777,7 @@ fishE: @ 808CE8C adds r6, r0, 0 bl sub_808CF78 ldr r7, =gSprites - ldr r5, =gUnknown_02037590 + ldr r5, =gPlayerAvatar ldrb r0, [r5, 0x4] lsls r1, r0, 4 adds r1, r0 @@ -4855,7 +4855,7 @@ fishF: @ 808CF2C lsrs r1, r0, 16 cmp r1, 0 bne _0808CF68 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar strb r1, [r0, 0x6] bl script_env_2_disable bl sub_809757C @@ -4879,7 +4879,7 @@ _0808CF68: thumb_func_start sub_808CF78 sub_808CF78: @ 808CF78 push {r4-r7,lr} - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x4] lsls r0, r1, 4 adds r0, r1 @@ -4978,7 +4978,7 @@ _0808D02A: movs r0, 0x8 strh r0, [r4, 0x26] _0808D03A: - ldr r3, =gUnknown_02037590 + ldr r3, =gPlayerAvatar ldrb r1, [r3] movs r0, 0x8 ands r0, r1 @@ -5032,7 +5032,7 @@ sub_808D094: @ 808D094 lsls r0, 24 lsrs r0, 24 adds r2, r0, 0 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -5212,7 +5212,7 @@ sub_808D1FC: @ 808D1FC lsls r0, 24 lsrs r0, 24 mov r8, r0 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 diff --git a/asm/fldeff_80F9BCC.s b/asm/fldeff_80F9BCC.s index d5e620c77..960c8e244 100644 --- a/asm/fldeff_80F9BCC.s +++ b/asm/fldeff_80F9BCC.s @@ -480,7 +480,7 @@ sub_80F9F5C: @ 80F9F5C thumb_func_start sub_80F9F78 sub_80F9F78: @ 80F9F78 push {lr} - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0] movs r0, 0x6 ands r0, r1 @@ -692,7 +692,7 @@ sub_80FA13C: @ 80FA13C bl sub_80F9F78 ldr r0, =gUnknown_0858E600 ldr r3, =gSprites - ldr r1, =gUnknown_02037590 + ldr r1, =gPlayerAvatar ldrb r1, [r1, 0x4] lsls r2, r1, 4 adds r2, r1 @@ -849,7 +849,7 @@ _080FA274: bl sub_80F9F78 ldr r0, =gUnknown_0858E618 ldr r3, =gSprites - ldr r1, =gUnknown_02037590 + ldr r1, =gPlayerAvatar ldrb r1, [r1, 0x4] lsls r2, r1, 4 adds r2, r1 @@ -1000,7 +1000,7 @@ sub_80FA3AC: @ 80FA3AC bl sub_80F9F78 ldr r0, =gUnknown_0858E630 ldr r3, =gSprites - ldr r1, =gUnknown_02037590 + ldr r1, =gPlayerAvatar ldrb r1, [r1, 0x4] lsls r2, r1, 4 adds r2, r1 @@ -1723,7 +1723,7 @@ sub_80FA9D0: @ 80FA9D0 push {r4,lr} sub sp, 0x4 ldr r3, =gMapObjects - ldr r2, =gUnknown_02037590 + ldr r2, =gPlayerAvatar ldrb r1, [r2, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -1835,7 +1835,7 @@ _080FAABC: _080FAAC6: ldr r0, =gUnknown_0858E68C ldr r3, =gSprites - ldr r1, =gUnknown_02037590 + ldr r1, =gPlayerAvatar ldrb r1, [r1, 0x4] lsls r2, r1, 4 adds r2, r1 @@ -1857,7 +1857,7 @@ _080FAAC6: _080FAAFC: ldr r0, =gUnknown_0858E68C ldr r3, =gSprites - ldr r1, =gUnknown_02037590 + ldr r1, =gPlayerAvatar ldrb r1, [r1, 0x4] lsls r2, r1, 4 adds r2, r1 @@ -1876,7 +1876,7 @@ _080FAAFC: _080FAB2C: ldr r0, =gUnknown_0858E68C ldr r3, =gSprites - ldr r1, =gUnknown_02037590 + ldr r1, =gPlayerAvatar ldrb r1, [r1, 0x4] lsls r2, r1, 4 adds r2, r1 @@ -1898,7 +1898,7 @@ _080FAB4C: _080FAB64: ldr r0, =gUnknown_0858E68C ldr r3, =gSprites - ldr r1, =gUnknown_02037590 + ldr r1, =gPlayerAvatar ldrb r1, [r1, 0x4] lsls r2, r1, 4 adds r2, r1 @@ -2307,7 +2307,7 @@ sub_80FAEF0: @ 80FAEF0 push {r4,r5,lr} lsls r0, 24 lsrs r5, r0, 24 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -2357,7 +2357,7 @@ sub_80FAF64: @ 80FAF64 push {r4,r5,lr} lsls r0, 24 lsrs r4, r0, 24 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 diff --git a/asm/fldeff_emotion.s b/asm/fldeff_emotion.s index f8b66da0d..dce540074 100644 --- a/asm/fldeff_emotion.s +++ b/asm/fldeff_emotion.s @@ -296,7 +296,7 @@ sub_80B4808: @ 80B4808 b _080B489E .pool _080B4870: - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 diff --git a/asm/link.s b/asm/link.s index 022922164..91d0e513b 100644 --- a/asm/link.s +++ b/asm/link.s @@ -27235,7 +27235,7 @@ sub_8017940: @ 8017940 ldrsh r0, [r4, r1] cmp r0, 0x8 bne _08017978 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r0, [r0, 0x3] cmp r0, 0x2 beq _0801796E @@ -31141,7 +31141,7 @@ bgid_upload_textbox_1: @ 8019938 thumb_func_start is_walking_or_running is_walking_or_running: @ 8019958 push {lr} - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r0, [r0, 0x3] cmp r0, 0x2 beq _08019966 diff --git a/asm/map_obj_8097404.s b/asm/map_obj_8097404.s index 50284a013..6bc74d0e5 100644 --- a/asm/map_obj_8097404.s +++ b/asm/map_obj_8097404.s @@ -97,7 +97,7 @@ _0809749A: lsls r0, 31 cmp r0, 0 beq _080974B8 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r0, [r0, 0x5] cmp r4, r0 beq _080974B8 @@ -133,7 +133,7 @@ _080974DA: lsls r0, 31 cmp r0, 0 beq _080974FC - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r0, [r0, 0x5] cmp r4, r0 beq _080974FC @@ -1771,7 +1771,7 @@ _08098082: lsls r0, 31 cmp r0, 0 beq _080980A8 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r0, [r0, 0x5] cmp r4, r0 beq _080980A8 diff --git a/asm/map_obj_lock.s b/asm/map_obj_lock.s index 6cb8c508e..f02f8526b 100644 --- a/asm/map_obj_lock.s +++ b/asm/map_obj_lock.s @@ -8,7 +8,7 @@ thumb_func_start walkrun_is_standing_still walkrun_is_standing_still: @ 8098388 push {lr} - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r0, [r0, 0x3] cmp r0, 0x1 beq _0809839C diff --git a/asm/porthole.s b/asm/porthole.s index a1bcff977..42ecc303a 100644 --- a/asm/porthole.s +++ b/asm/porthole.s @@ -232,7 +232,7 @@ sub_80FB768: @ 80FB768 push {lr} bl sub_80FB6EC ldr r2, =gMapObjects - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 diff --git a/asm/rom4.s b/asm/rom4.s index b6a5c0fa0..bf16055e7 100644 --- a/asm/rom4.s +++ b/asm/rom4.s @@ -4396,7 +4396,7 @@ sub_8086A68: @ 8086A68 sub_8086A80: @ 8086A80 push {lr} ldr r2, =gMapObjects - ldr r3, =gUnknown_02037590 + ldr r3, =gPlayerAvatar ldrb r1, [r3, 0x5] lsls r0, r1, 3 adds r0, r1 diff --git a/asm/rom6.s b/asm/rom6.s index ef2d27110..4ccc2e05f 100644 --- a/asm/rom6.s +++ b/asm/rom6.s @@ -68,7 +68,7 @@ task08_080C9820: @ 813549C lsrs r5, r0, 24 adds r6, r5, 0 bl script_env_2_enable - ldr r1, =gUnknown_02037590 + ldr r1, =gPlayerAvatar movs r0, 0x1 strb r0, [r1, 0x6] ldrb r1, [r1, 0x5] @@ -127,7 +127,7 @@ sub_813552C: @ 813552C push {r4,lr} lsls r0, 24 lsrs r4, r0, 24 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -191,7 +191,7 @@ _081355B0: movs r0, 0x3 str r0, [r6, 0x8] _081355B8: - ldr r5, =gUnknown_02037590 + ldr r5, =gPlayerAvatar ldrb r0, [r5, 0x5] lsls r4, r0, 3 adds r4, r0 @@ -244,7 +244,7 @@ sub_813561C: @ 813561C ldrh r0, [r0, 0x1A] orrs r1, r0 bl _call_via_r1 - ldr r1, =gUnknown_02037590 + ldr r1, =gPlayerAvatar movs r0, 0 strb r0, [r1, 0x6] adds r0, r4, 0 diff --git a/asm/rom_80C6FA0.s b/asm/rom_80C6FA0.s index 04d4c29f4..35215e80c 100644 --- a/asm/rom_80C6FA0.s +++ b/asm/rom_80C6FA0.s @@ -24601,7 +24601,7 @@ _080D3B64: movs r6, 0 ldr r5, =gSprites _080D3BA0: - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x4] lsls r0, r1, 4 adds r0, r1 diff --git a/asm/rom_81BE66C.s b/asm/rom_81BE66C.s index ad83d6402..7b3b695e3 100644 --- a/asm/rom_81BE66C.s +++ b/asm/rom_81BE66C.s @@ -236,7 +236,7 @@ sub_81BE808: @ 81BE808 ldrh r1, [r0, 0x26] adds r1, 0x4 strh r1, [r0, 0x26] - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r0, [r0, 0x5] lsls r1, r0, 3 adds r1, r0 @@ -42695,7 +42695,7 @@ sub_81D427C: @ 81D427C ldr r2, =gMapObjects adds r5, r1, r2 ldr r4, =gUnknown_030012F8 - ldr r3, =gUnknown_02037590 + ldr r3, =gPlayerAvatar ldrb r1, [r3, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -42731,7 +42731,7 @@ _081D42CA: cmp r0, 0x3 bls _081D42CA ldr r2, =gMapObjects - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -42789,7 +42789,7 @@ _081D4360: ldr r6, =gMapObjects mov r10, r6 _081D4368: - ldr r3, =gUnknown_02037590 + ldr r3, =gPlayerAvatar ldrb r1, [r3, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -42896,7 +42896,7 @@ _081D4410: beq _081D4446 b _081D45AA _081D4446: - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -42938,7 +42938,7 @@ _081D4488: cmp r0, 0 bne _081D4538 _081D449E: - ldr r2, =gUnknown_02037590 + ldr r2, =gPlayerAvatar ldrb r1, [r2, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -43042,7 +43042,7 @@ _081D4540: beq _081D4576 b _081D447C _081D4576: - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -43211,7 +43211,7 @@ _081D46D0: cmp r0, 0 bne _081D476E ldr r2, =gMapObjects - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -43236,7 +43236,7 @@ _081D46D0: b _081D447C _081D470C: ldr r2, =gMapObjects - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -43290,7 +43290,7 @@ _081D476E: cmp r0, 0 bne _081D480C ldr r2, =gMapObjects - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -43315,7 +43315,7 @@ _081D476E: b _081D45AA _081D47AA: ldr r2, =gMapObjects - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -43386,7 +43386,7 @@ sub_81D4834: @ 81D4834 lsls r1, 16 lsrs r4, r1, 16 ldr r3, =gMapObjects - ldr r1, =gUnknown_02037590 + ldr r1, =gPlayerAvatar ldrb r2, [r1, 0x5] lsls r1, r2, 3 adds r1, r2 diff --git a/asm/secret_base.s b/asm/secret_base.s index 99e15fe0f..e67212350 100644 --- a/asm/secret_base.s +++ b/asm/secret_base.s @@ -751,7 +751,7 @@ sub_80E90C8: @ 80E90C8 push {r4,lr} lsls r0, 24 lsrs r4, r0, 24 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 diff --git a/asm/trainer_see.s b/asm/trainer_see.s index 03c8d3320..1b3e33e98 100644 --- a/asm/trainer_see.s +++ b/asm/trainer_see.s @@ -882,7 +882,7 @@ _080B427A: bl sub_808F23C adds r0, r5, 0 bl sub_808F208 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 @@ -901,7 +901,7 @@ _080B427A: beq _080B4308 _080B42D2: bl sub_808BCE8 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r0, [r0, 0x5] lsls r4, r0, 3 adds r4, r0 @@ -936,7 +936,7 @@ sub_80B4318: @ 80B4318 push {r4,r5,lr} lsls r0, 24 lsrs r5, r0, 24 - ldr r0, =gUnknown_02037590 + ldr r0, =gPlayerAvatar ldrb r1, [r0, 0x5] lsls r0, r1, 3 adds r0, r1 diff --git a/include/field_map_obj.h b/include/field_map_obj.h index 3381d847b..6ca6b4103 100644 --- a/include/field_map_obj.h +++ b/include/field_map_obj.h @@ -5,6 +5,8 @@ // Exported RAM declarations + + // Exported ROM declarations void sub_808D438(void); @@ -12,6 +14,10 @@ u8 GetFieldObjectIdByLocalIdAndMap(u8, u8, u8); bool8 TryGetFieldObjectIdByLocalIdAndMap(u8, u8, u8, u8 *); u8 GetFieldObjectIdByXY(s16, s16); void FieldObjectSetDirection(struct MapObject *, u8); +u8 GetFieldObjectIdByXY(s16, s16); +u8 sub_808D4F4(void); +void RemoveFieldObject(struct MapObject *); +void RemoveFieldObjectByLocalIdAndMap(u8, u8, u8); // Exported data declarations diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 52f798f9b..6e15d3e86 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -15,12 +15,12 @@ // Static ROM declarations -/*static*/ void sub_808D450(void); +void sub_808D450(void); static u8 GetFieldObjectIdByLocalId(u8); static u8 GetFieldObjectIdByLocalIdAndMapInternal(u8, u8, u8); static bool8 GetAvailableFieldObjectSlot(u16, u8, u8, u8 *); /*static*/ void FieldObjectHandleDynamicGraphicsId(struct MapObject *); -/*static*/ void RemoveFieldObjectInternal (struct MapObject *); +static void RemoveFieldObjectInternal (struct MapObject *); /*static*/ u16 GetFieldObjectFlagIdByFieldObjectId(u8); /*static*/ struct MapObjectGraphicsInfo *GetFieldObjectGraphicsInfo(u8); @@ -136,7 +136,7 @@ static u8 GetFieldObjectIdByLocalIdAndMapInternal(u8 localId, u8 mapId, u8 mapGr return ARRAY_COUNT(gMapObjects); } -u8 GetFieldObjectIdByLocalId(u8 localId) +static u8 GetFieldObjectIdByLocalId(u8 localId) { u8 i; @@ -152,7 +152,7 @@ u8 GetFieldObjectIdByLocalId(u8 localId) // This function has the same nonmatching quirk as in Ruby/Sapphire. #ifdef NONMATCHING -u8 InitFieldObjectStateFromTemplate(struct MapObjectTemplate *template, u8 mapId, u8 mapGroupId) +/*static*/ u8 InitFieldObjectStateFromTemplate(struct MapObjectTemplate *template, u8 mapId, u8 mapGroupId) { u8 slot; struct MapObject *mapObject; @@ -203,7 +203,7 @@ u8 InitFieldObjectStateFromTemplate(struct MapObjectTemplate *template, u8 mapId return slot; } #else -__attribute__((naked)) u8 InitFieldObjectStateFromTemplate(struct MapObjectTemplate *template, u8 mapId, u8 mapGroupId) +/*static*/ __attribute__((naked)) u8 InitFieldObjectStateFromTemplate(struct MapObjectTemplate *template, u8 mapId, u8 mapGroupId) { asm_unified("\tpush {r4-r7,lr}\n" "\tmov r7, r9\n" @@ -435,10 +435,23 @@ void RemoveFieldObjectByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup) } } -void RemoveFieldObjectInternal(struct MapObject *mapObject) +static void RemoveFieldObjectInternal(struct MapObject *mapObject) { struct SpriteFrameImage image; image.size = GetFieldObjectGraphicsInfo(mapObject->graphicsId)->size; gSprites[mapObject->spriteId].images = ℑ DestroySprite(&gSprites[mapObject->spriteId]); } + +void unref_sub_808D958(void) +{ + u8 i; + + for (i = 0; i < ARRAY_COUNT(gMapObjects); i ++) + { + if (i != gPlayerAvatar.mapObjectId) + { + RemoveFieldObject(&gMapObjects[i]); + } + } +} diff --git a/sym_ewram.txt b/sym_ewram.txt index df8f32f6a..bfe8faeb9 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -764,7 +764,7 @@ gUnknown_0203734C: @ 203734C gMapObjects: @ 2037350 .space 0x240 -gUnknown_02037590: @ 2037590 +gPlayerAvatar: @ 2037590 .space 0x14 gUnknown_020375A4: @ 20375A4 From b79e3af0a8aaed5528e57c965101aa4c0b59bad1 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 6 Sep 2017 20:28:36 -0400 Subject: [PATCH 017/191] SpawnFieldObjectInternal --- asm/field_map_obj.s | 214 ---------------------------------- include/field_ground_effect.h | 15 +++ include/field_map_obj.h | 5 + src/field_map_obj.c | 63 ++++++++++ 4 files changed, 83 insertions(+), 214 deletions(-) create mode 100644 include/field_ground_effect.h diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index ff3aff842..f59a3a7c9 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,220 +5,6 @@ .text - thumb_func_start SpawnFieldObjectInternal -@ u8 SpawnFieldObjectInternal(struct FieldObjectTemplate *romFieldObject, struct objtemplate *template, int mapId, int mapGroupId, u16 movingCameraOffsetX, u16 movingCameraOffsetY) -SpawnFieldObjectInternal: @ 808D98C - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - mov r8, r1 - adds r1, r2, 0 - adds r2, r3, 0 - ldr r3, [sp, 0x24] - ldr r4, [sp, 0x28] - lsls r1, 24 - lsrs r1, 24 - lsls r2, 24 - lsrs r2, 24 - lsls r3, 16 - lsrs r3, 16 - mov r10, r3 - lsls r4, 16 - lsrs r4, 16 - str r4, [sp] - bl InitFieldObjectStateFromTemplate - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 - cmp r0, 0x10 - bne _0808D9C8 - movs r0, 0x10 - b _0808DB2C -_0808D9C8: - mov r0, r9 - lsls r4, r0, 3 - adds r0, r4, r0 - lsls r0, 2 - ldr r1, =gMapObjects - adds r6, r0, r1 - ldrb r0, [r6, 0x5] - bl GetFieldObjectGraphicsInfo - adds r7, r0, 0 - ldrb r0, [r7, 0xC] - lsls r0, 28 - lsrs r5, r0, 28 - cmp r5, 0 - bne _0808D9F4 - ldrh r0, [r7, 0x2] - movs r1, 0 - bl npc_load_two_palettes__no_record - b _0808DA16 - .pool -_0808D9F4: - cmp r5, 0xA - bne _0808DA02 - ldrh r0, [r7, 0x2] - movs r1, 0xA - bl npc_load_two_palettes__and_record - b _0808DA16 -_0808DA02: - cmp r5, 0xF - bls _0808DA16 - adds r0, r5, 0 - subs r0, 0x10 - lsls r0, 24 - lsrs r5, r0, 24 - ldrh r0, [r7, 0x2] - adds r1, r5, 0 - bl sub_808EAB0 -_0808DA16: - ldrb r0, [r6, 0x6] - cmp r0, 0x4C - bne _0808DA24 - ldrb r0, [r6, 0x1] - movs r1, 0x20 - orrs r0, r1 - strb r0, [r6, 0x1] -_0808DA24: - ldr r1, =0x0000ffff - adds r0, r1, 0 - mov r2, r8 - strh r0, [r2, 0x2] - mov r0, r8 - movs r1, 0 - movs r2, 0 - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - cmp r0, 0x40 - bne _0808DA64 - ldr r0, =gMapObjects - mov r2, r9 - adds r1, r4, r2 - lsls r1, 2 - adds r1, r0 - ldrb r2, [r1] - movs r0, 0x2 - negs r0, r0 - ands r0, r2 - strb r0, [r1] - movs r0, 0x10 - b _0808DB2C - .pool -_0808DA64: - mov r1, r8 - lsls r0, r1, 4 - add r0, r8 - lsls r0, 2 - ldr r1, =gSprites - adds r4, r0, r1 - mov r2, r10 - lsls r0, r2, 16 - asrs r0, 16 - ldrh r1, [r6, 0x10] - adds r0, r1 - lsls r0, 16 - asrs r0, 16 - ldr r2, [sp] - lsls r1, r2, 16 - asrs r1, 16 - ldrh r2, [r6, 0x12] - adds r1, r2 - lsls r1, 16 - asrs r1, 16 - adds r2, r4, 0 - adds r2, 0x20 - adds r3, r4, 0 - adds r3, 0x22 - bl sub_8092FF0 - ldrh r0, [r7, 0x8] - lsls r0, 16 - asrs r0, 17 - negs r0, r0 - adds r1, r4, 0 - adds r1, 0x28 - strb r0, [r1] - ldrh r0, [r7, 0xA] - lsls r0, 16 - asrs r0, 17 - negs r0, r0 - adds r2, r4, 0 - adds r2, 0x29 - strb r0, [r2] - ldrh r0, [r4, 0x20] - adds r0, 0x8 - strh r0, [r4, 0x20] - ldrh r1, [r4, 0x22] - adds r1, 0x10 - movs r0, 0 - ldrsb r0, [r2, r0] - adds r0, r1 - strh r0, [r4, 0x22] - lsls r2, r5, 4 - ldrb r1, [r4, 0x5] - movs r0, 0xF - ands r0, r1 - orrs r0, r2 - strb r0, [r4, 0x5] - adds r2, r4, 0 - adds r2, 0x3E - ldrb r0, [r2] - movs r1, 0x2 - orrs r0, r1 - strb r0, [r2] - mov r0, r9 - strh r0, [r4, 0x2E] - mov r1, r8 - strb r1, [r6, 0x4] - ldrb r1, [r7, 0xC] - lsls r1, 25 - lsrs r1, 31 - lsls r1, 4 - ldrb r2, [r6, 0x1] - movs r0, 0x11 - negs r0, r0 - ands r0, r2 - orrs r0, r1 - strb r0, [r6, 0x1] - lsls r0, 27 - cmp r0, 0 - blt _0808DB16 - ldrb r0, [r6, 0x18] - lsls r0, 28 - lsrs r0, 28 - bl FieldObjectDirectionToImageAnimId - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 24 - adds r0, r4, 0 - bl StartSpriteAnim -_0808DB16: - ldrb r0, [r6, 0xB] - lsrs r0, 4 - adds r1, r4, 0 - movs r2, 0x1 - bl SetObjectSubpriorityByZCoord - adds r0, r6, 0 - adds r1, r4, 0 - bl sub_8096518 - mov r0, r9 -_0808DB2C: - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end SpawnFieldObjectInternal - thumb_func_start SpawnFieldObject @ u8 SpawnFieldObject(struct FieldObjectTemplate *romNpc, u8 mapId, u8 mapGroupId, u16 movingCameraOffsetX, u16 movingCameraOffsetY) SpawnFieldObject: @ 808DB40 diff --git a/include/field_ground_effect.h b/include/field_ground_effect.h new file mode 100644 index 000000000..2b93273db --- /dev/null +++ b/include/field_ground_effect.h @@ -0,0 +1,15 @@ +// +// Created by scott on 9/6/2017. +// + +#ifndef POKEEMERALD_FIELD_GROUND_EFFECT_H +#define POKEEMERALD_FIELD_GROUND_EFFECT_H + +// Exported type declarations + +// Exported RAM declarations + +// Exported ROM declarations +void SetObjectSubpriorityByZCoord(u8, struct Sprite *, u8); + +#endif //POKEEMERALD_FIELD_GROUND_EFFECT_H diff --git a/include/field_map_obj.h b/include/field_map_obj.h index 6ca6b4103..6ddff4901 100644 --- a/include/field_map_obj.h +++ b/include/field_map_obj.h @@ -18,6 +18,11 @@ u8 GetFieldObjectIdByXY(s16, s16); u8 sub_808D4F4(void); void RemoveFieldObject(struct MapObject *); void RemoveFieldObjectByLocalIdAndMap(u8, u8, u8); +void npc_load_two_palettes__no_record(u16, u8); +void npc_load_two_palettes__and_record(u16, u8); +void sub_808EAB0(u16, u8); +void sub_8092FF0(s16, s16, s16 *, s16 *); +u8 FieldObjectDirectionToImageAnimId(u8); // Exported data declarations diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 6e15d3e86..a3fb1a5d3 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -7,6 +7,7 @@ #include "event_data.h" #include "rom_818CFC8.h" #include "rom_81BE66C.h" +#include "field_ground_effect.h" #include "field_map_obj.h" // Static struct declarations @@ -23,6 +24,7 @@ static bool8 GetAvailableFieldObjectSlot(u16, u8, u8, u8 *); static void RemoveFieldObjectInternal (struct MapObject *); /*static*/ u16 GetFieldObjectFlagIdByFieldObjectId(u8); /*static*/ struct MapObjectGraphicsInfo *GetFieldObjectGraphicsInfo(u8); +void sub_8096518(struct MapObject *, struct Sprite *); // ROM data @@ -455,3 +457,64 @@ void unref_sub_808D958(void) } } } + +u8 SpawnFieldObjectInternal(struct MapObjectTemplate *mapObjectTemplate, struct SpriteTemplate *spriteTemplate, u8 mapNum, u8 mapGroup, s16 cameraX, s16 cameraY) +{ + struct MapObject *mapObject; + struct MapObjectGraphicsInfo *graphicsInfo; + struct Sprite *sprite; + u8 mapObjectId; + u8 paletteSlot; + u8 spriteId; + + mapObjectId = InitFieldObjectStateFromTemplate(mapObjectTemplate, mapNum, mapGroup); + if (mapObjectId == ARRAY_COUNT(gMapObjects)) + { + return ARRAY_COUNT(gMapObjects); + } + mapObject = &gMapObjects[mapObjectId]; + graphicsInfo = GetFieldObjectGraphicsInfo(mapObject->graphicsId); + paletteSlot = graphicsInfo->paletteSlot; + if (paletteSlot == 0) + { + npc_load_two_palettes__no_record(graphicsInfo->paletteTag1, 0); + } + else if (paletteSlot == 10) + { + npc_load_two_palettes__and_record(graphicsInfo->paletteTag1, 10); + } + else if (paletteSlot >= 16) + { + paletteSlot -= 16; + sub_808EAB0(graphicsInfo->paletteTag1, paletteSlot); + } + if (mapObject->animPattern == 0x4c) + { + mapObject->mapobj_bit_13 = TRUE; + } + *(u16 *)&spriteTemplate->paletteTag = 0xFFFF; + spriteId = CreateSprite(spriteTemplate, 0, 0, 0); + if (spriteId == MAX_SPRITES) + { + gMapObjects[mapObjectId].active = FALSE; + return ARRAY_COUNT(gMapObjects); + } + sprite = &gSprites[spriteId]; + sub_8092FF0(mapObject->coords2.x + cameraX, mapObject->coords2.y + cameraY, &sprite->pos1.x, &sprite->pos1.y); + sprite->centerToCornerVecX = -(graphicsInfo->width >> 1); + sprite->centerToCornerVecY = -(graphicsInfo->height >> 1); + sprite->pos1.x += 8; + sprite->pos1.y += 16 + sprite->centerToCornerVecY; + sprite->oam.paletteNum = paletteSlot; + sprite->coordOffsetEnabled = TRUE; + sprite->data0 = mapObjectId; + mapObject->spriteId = spriteId; + mapObject->mapobj_bit_12 = graphicsInfo->inanimate; + if (!mapObject->mapobj_bit_12) + { + StartSpriteAnim(sprite, FieldObjectDirectionToImageAnimId(mapObject->mapobj_unk_18)); + } + SetObjectSubpriorityByZCoord(mapObject->elevation, sprite, 1); + sub_8096518(mapObject, sprite); + return mapObjectId; +} From bd4b3c4c6da148415e8c5ebeb8c72455776a5f19 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 6 Sep 2017 21:46:53 -0400 Subject: [PATCH 018/191] SpawnFieldObject --- asm/field_map_obj.s | 99 --------------------------------------------- src/field_map_obj.c | 31 +++++++++++++- 2 files changed, 29 insertions(+), 101 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index f59a3a7c9..600997c7f 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,105 +5,6 @@ .text - thumb_func_start SpawnFieldObject -@ u8 SpawnFieldObject(struct FieldObjectTemplate *romNpc, u8 mapId, u8 mapGroupId, u16 movingCameraOffsetX, u16 movingCameraOffsetY) -SpawnFieldObject: @ 808DB40 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x2C - mov r9, r0 - adds r6, r1, 0 - mov r8, r2 - adds r4, r3, 0 - ldr r5, [sp, 0x48] - lsls r6, 24 - lsrs r6, 24 - mov r0, r8 - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - lsls r4, 16 - lsrs r4, 16 - lsls r5, 16 - lsrs r5, 16 - movs r0, 0 - str r0, [sp, 0x20] - mov r1, r9 - ldrb r0, [r1, 0x1] - bl GetFieldObjectGraphicsInfo - adds r7, r0, 0 - add r2, sp, 0x20 - mov r0, r9 - add r1, sp, 0x8 - bl MakeObjectTemplateFromFieldObjectTemplate - ldrh r3, [r7, 0x6] - ldr r2, =0xffff0000 - add r1, sp, 0x24 - ldr r0, [r1, 0x4] - ands r0, r2 - orrs r0, r3 - str r0, [r1, 0x4] - str r1, [sp, 0x14] - lsls r4, 16 - asrs r4, 16 - str r4, [sp] - lsls r5, 16 - asrs r5, 16 - str r5, [sp, 0x4] - mov r0, r9 - add r1, sp, 0x8 - adds r2, r6, 0 - mov r3, r8 - bl SpawnFieldObjectInternal - lsls r0, 24 - lsrs r2, r0, 24 - adds r5, r2, 0 - cmp r2, 0x10 - bne _0808DBBC - movs r0, 0x10 - b _0808DBF2 - .pool -_0808DBBC: - ldr r4, =gSprites - ldr r1, =gMapObjects - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - adds r3, r0, r1 - ldrb r1, [r3, 0x4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r1, r4, 0 - adds r1, 0xC - adds r0, r1 - ldr r1, [r7, 0x1C] - str r1, [r0] - ldr r2, [sp, 0x20] - cmp r2, 0 - beq _0808DBF0 - ldrb r1, [r3, 0x4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - adds r1, r2, 0 - bl SetSubspriteTables -_0808DBF0: - adds r0, r5, 0 -_0808DBF2: - add sp, 0x2C - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end SpawnFieldObject - thumb_func_start SpawnSpecialFieldObject @ u8 SpawnSpecialFieldObject(struct FieldObjectTemplate *romFieldObject) SpawnSpecialFieldObject: @ 808DC08 diff --git a/src/field_map_obj.c b/src/field_map_obj.c index a3fb1a5d3..8b78a54a1 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -23,8 +23,9 @@ static bool8 GetAvailableFieldObjectSlot(u16, u8, u8, u8 *); /*static*/ void FieldObjectHandleDynamicGraphicsId(struct MapObject *); static void RemoveFieldObjectInternal (struct MapObject *); /*static*/ u16 GetFieldObjectFlagIdByFieldObjectId(u8); -/*static*/ struct MapObjectGraphicsInfo *GetFieldObjectGraphicsInfo(u8); +/*static*/ const struct MapObjectGraphicsInfo *GetFieldObjectGraphicsInfo(u8); void sub_8096518(struct MapObject *, struct Sprite *); +/*static*/ void MakeObjectTemplateFromFieldObjectTemplate(struct MapObjectTemplate *, struct SpriteTemplate *, const struct SubspriteTable **); // ROM data @@ -461,7 +462,7 @@ void unref_sub_808D958(void) u8 SpawnFieldObjectInternal(struct MapObjectTemplate *mapObjectTemplate, struct SpriteTemplate *spriteTemplate, u8 mapNum, u8 mapGroup, s16 cameraX, s16 cameraY) { struct MapObject *mapObject; - struct MapObjectGraphicsInfo *graphicsInfo; + const struct MapObjectGraphicsInfo *graphicsInfo; struct Sprite *sprite; u8 mapObjectId; u8 paletteSlot; @@ -518,3 +519,29 @@ u8 SpawnFieldObjectInternal(struct MapObjectTemplate *mapObjectTemplate, struct sub_8096518(mapObject, sprite); return mapObjectId; } + +u8 SpawnFieldObject(struct MapObjectTemplate *mapObjectTemplate, u8 mapNum, u8 mapGroup, s16 cameraX, s16 cameraY) +{ + const struct MapObjectGraphicsInfo *graphicsInfo; + struct SpriteTemplate spriteTemplate; + const struct SubspriteTable *subspriteTable; + struct SpriteFrameImage spriteFrameImage; + u8 mapObjectId; + + subspriteTable = NULL; + graphicsInfo = GetFieldObjectGraphicsInfo(mapObjectTemplate->graphicsId); + MakeObjectTemplateFromFieldObjectTemplate(mapObjectTemplate, &spriteTemplate, &subspriteTable); + spriteFrameImage.size = graphicsInfo->size; + spriteTemplate.images = &spriteFrameImage; + mapObjectId = SpawnFieldObjectInternal(mapObjectTemplate, &spriteTemplate, mapNum, mapGroup, cameraX, cameraY); + if (mapObjectId == ARRAY_COUNT(gMapObjects)) + { + return ARRAY_COUNT(gMapObjects); + } + gSprites[gMapObjects[mapObjectId].spriteId].images = graphicsInfo->images; + if (subspriteTable != NULL) + { + SetSubspriteTables(&gSprites[gMapObjects[mapObjectId].spriteId], subspriteTable); + } + return mapObjectId; +} From 22c836795669b9c7d2d244dc4f0becaabfe6a198 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 6 Sep 2017 22:00:51 -0400 Subject: [PATCH 019/191] SpawnSpecialFieldObject --- asm/field_map_obj.s | 32 -------------------------------- src/field_map_obj.c | 10 ++++++++++ 2 files changed, 10 insertions(+), 32 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 600997c7f..213af130e 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,38 +5,6 @@ .text - thumb_func_start SpawnSpecialFieldObject -@ u8 SpawnSpecialFieldObject(struct FieldObjectTemplate *romFieldObject) -SpawnSpecialFieldObject: @ 808DC08 - push {r4-r6,lr} - sub sp, 0x8 - adds r5, r0, 0 - mov r4, sp - adds r4, 0x6 - add r0, sp, 0x4 - adds r1, r4, 0 - bl GetFieldObjectMovingCameraOffset - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldrb r1, [r0, 0x5] - ldrb r2, [r0, 0x4] - add r0, sp, 0x4 - movs r6, 0 - ldrsh r3, [r0, r6] - movs r6, 0 - ldrsh r0, [r4, r6] - str r0, [sp] - adds r0, r5, 0 - bl SpawnFieldObject - lsls r0, 24 - lsrs r0, 24 - add sp, 0x8 - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end SpawnSpecialFieldObject - thumb_func_start SpawnSpecialFieldObjectParametrized @ u8 SpawnSpecialFieldObjectParametrized(u8 graphicsId, u8 movementBehavior, u8 localId, u16 x, u16 y, u8 z) SpawnSpecialFieldObjectParametrized: @ 808DC44 diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 8b78a54a1..9c25e148a 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -26,6 +26,7 @@ static void RemoveFieldObjectInternal (struct MapObject *); /*static*/ const struct MapObjectGraphicsInfo *GetFieldObjectGraphicsInfo(u8); void sub_8096518(struct MapObject *, struct Sprite *); /*static*/ void MakeObjectTemplateFromFieldObjectTemplate(struct MapObjectTemplate *, struct SpriteTemplate *, const struct SubspriteTable **); +/*static*/ void GetFieldObjectMovingCameraOffset(s16 *, s16 *); // ROM data @@ -545,3 +546,12 @@ u8 SpawnFieldObject(struct MapObjectTemplate *mapObjectTemplate, u8 mapNum, u8 m } return mapObjectId; } + +u8 SpawnSpecialFieldObject(struct MapObjectTemplate *mapObjectTemplate) +{ + s16 cameraX; + s16 cameraY; + + GetFieldObjectMovingCameraOffset(&cameraX, &cameraY); + return SpawnFieldObject(mapObjectTemplate, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, cameraX, cameraY); +} From 1f83a2885e540dbf473e3f5200e35f5fc6df96b3 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 6 Sep 2017 22:33:11 -0400 Subject: [PATCH 020/191] Through MakeObjectTemplateFromFieldObjectGraphicsInfo --- asm/field_map_obj.s | 127 -------------------------------------------- src/field_map_obj.c | 60 +++++++++++++++++++-- 2 files changed, 55 insertions(+), 132 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 213af130e..e7740b66c 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,133 +5,6 @@ .text - thumb_func_start SpawnSpecialFieldObjectParametrized -@ u8 SpawnSpecialFieldObjectParametrized(u8 graphicsId, u8 movementBehavior, u8 localId, u16 x, u16 y, u8 z) -SpawnSpecialFieldObjectParametrized: @ 808DC44 - push {r4-r6,lr} - mov r6, r8 - push {r6} - sub sp, 0x18 - ldr r4, [sp, 0x2C] - ldr r5, [sp, 0x30] - mov r8, r5 - lsls r0, 24 - lsrs r0, 24 - lsls r3, 16 - ldr r5, =0xfff90000 - adds r3, r5 - lsrs r3, 16 - lsls r4, 16 - adds r4, r5 - lsrs r4, 16 - mov r5, sp - movs r6, 0 - strb r2, [r5] - mov r2, sp - strb r0, [r2, 0x1] - mov r0, sp - strb r6, [r0, 0x2] - movs r5, 0 - strh r3, [r0, 0x4] - strh r4, [r0, 0x6] - mov r2, r8 - strb r2, [r0, 0x8] - strb r1, [r0, 0x9] - mov r2, sp - ldrb r1, [r2, 0xA] - movs r0, 0x10 - negs r0, r0 - ands r0, r1 - strb r0, [r2, 0xA] - mov r0, sp - strb r5, [r0, 0xA] - strh r6, [r0, 0xC] - strh r6, [r0, 0xE] - bl SpawnSpecialFieldObject - lsls r0, 24 - lsrs r0, 24 - add sp, 0x18 - pop {r3} - mov r8, r3 - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end SpawnSpecialFieldObjectParametrized - - thumb_func_start show_sprite -show_sprite: @ 808DCAC - push {r4-r7,lr} - sub sp, 0x8 - lsls r0, 24 - lsrs r0, 24 - lsls r1, 24 - lsrs r7, r1, 24 - lsls r2, 24 - lsrs r6, r2, 24 - adds r1, r7, 0 - adds r2, r6, 0 - bl GetFieldObjectTemplateByLocalIdAndMap - adds r5, r0, 0 - cmp r5, 0 - beq _0808DCF2 - mov r4, sp - adds r4, 0x6 - add r0, sp, 0x4 - adds r1, r4, 0 - bl GetFieldObjectMovingCameraOffset - add r0, sp, 0x4 - movs r1, 0 - ldrsh r3, [r0, r1] - movs r1, 0 - ldrsh r0, [r4, r1] - str r0, [sp] - adds r0, r5, 0 - adds r1, r7, 0 - adds r2, r6, 0 - bl SpawnFieldObject - lsls r0, 24 - lsrs r0, 24 - b _0808DCF4 -_0808DCF2: - movs r0, 0x10 -_0808DCF4: - add sp, 0x8 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end show_sprite - - thumb_func_start MakeObjectTemplateFromFieldObjectGraphicsInfo -@ void MakeObjectTemplateFromFieldObjectGraphicsInfo(u8 graphicsId, void ( *callback)(), struct objtemplate *objectTemplate, SpriteOamTable **spriteOamTables) -MakeObjectTemplateFromFieldObjectGraphicsInfo: @ 808DCFC - push {r4-r6,lr} - adds r5, r1, 0 - adds r4, r2, 0 - adds r6, r3, 0 - lsls r0, 24 - lsrs r0, 24 - bl GetFieldObjectGraphicsInfo - ldrh r1, [r0] - strh r1, [r4] - ldrh r1, [r0, 0x2] - strh r1, [r4, 0x2] - ldr r1, [r0, 0x10] - str r1, [r4, 0x4] - ldr r1, [r0, 0x18] - str r1, [r4, 0x8] - ldr r1, [r0, 0x1C] - str r1, [r4, 0xC] - ldr r1, [r0, 0x20] - str r1, [r4, 0x10] - str r5, [r4, 0x14] - ldr r0, [r0, 0x14] - str r0, [r6] - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end MakeObjectTemplateFromFieldObjectGraphicsInfo - thumb_func_start MakeObjectTemplateFromFieldObjectGraphicsInfoWithCallbackIndex @ void MakeObjectTemplateFromFieldObjectGraphicsInfoWithCallbackIndex(u16 graphicsId, u16 callbackIndex, struct objtemplate *objectTemplate, SpriteOamTable **spriteOamTables) MakeObjectTemplateFromFieldObjectGraphicsInfoWithCallbackIndex: @ 808DD30 diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 9c25e148a..e6376d156 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -27,6 +27,7 @@ static void RemoveFieldObjectInternal (struct MapObject *); void sub_8096518(struct MapObject *, struct Sprite *); /*static*/ void MakeObjectTemplateFromFieldObjectTemplate(struct MapObjectTemplate *, struct SpriteTemplate *, const struct SubspriteTable **); /*static*/ void GetFieldObjectMovingCameraOffset(s16 *, s16 *); +/*static*/ struct MapObjectTemplate *GetFieldObjectTemplateByLocalIdAndMap(u8, u8, u8); // ROM data @@ -525,13 +526,13 @@ u8 SpawnFieldObject(struct MapObjectTemplate *mapObjectTemplate, u8 mapNum, u8 m { const struct MapObjectGraphicsInfo *graphicsInfo; struct SpriteTemplate spriteTemplate; - const struct SubspriteTable *subspriteTable; + const struct SubspriteTable *subspriteTables; struct SpriteFrameImage spriteFrameImage; u8 mapObjectId; - subspriteTable = NULL; + subspriteTables = NULL; graphicsInfo = GetFieldObjectGraphicsInfo(mapObjectTemplate->graphicsId); - MakeObjectTemplateFromFieldObjectTemplate(mapObjectTemplate, &spriteTemplate, &subspriteTable); + MakeObjectTemplateFromFieldObjectTemplate(mapObjectTemplate, &spriteTemplate, &subspriteTables); spriteFrameImage.size = graphicsInfo->size; spriteTemplate.images = &spriteFrameImage; mapObjectId = SpawnFieldObjectInternal(mapObjectTemplate, &spriteTemplate, mapNum, mapGroup, cameraX, cameraY); @@ -540,9 +541,9 @@ u8 SpawnFieldObject(struct MapObjectTemplate *mapObjectTemplate, u8 mapNum, u8 m return ARRAY_COUNT(gMapObjects); } gSprites[gMapObjects[mapObjectId].spriteId].images = graphicsInfo->images; - if (subspriteTable != NULL) + if (subspriteTables != NULL) { - SetSubspriteTables(&gSprites[gMapObjects[mapObjectId].spriteId], subspriteTable); + SetSubspriteTables(&gSprites[gMapObjects[mapObjectId].spriteId], subspriteTables); } return mapObjectId; } @@ -555,3 +556,52 @@ u8 SpawnSpecialFieldObject(struct MapObjectTemplate *mapObjectTemplate) GetFieldObjectMovingCameraOffset(&cameraX, &cameraY); return SpawnFieldObject(mapObjectTemplate, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, cameraX, cameraY); } + +u8 SpawnSpecialFieldObjectParametrized(u8 graphicsId, u8 movementBehavior, u8 localId, s16 x, s16 y, u8 z) +{ + struct MapObjectTemplate mapObjectTemplate; + + x -= 7; + y -= 7; + mapObjectTemplate.localId = localId; + mapObjectTemplate.graphicsId = graphicsId; + mapObjectTemplate.unk2 = 0; + mapObjectTemplate.x = x; + mapObjectTemplate.y = y; + mapObjectTemplate.elevation = z; + mapObjectTemplate.movementType = movementBehavior; + mapObjectTemplate.unkA_0 = 0; + mapObjectTemplate.unkA_4 = 0; + mapObjectTemplate.unkC = 0; + mapObjectTemplate.unkE = 0; + return SpawnSpecialFieldObject(&mapObjectTemplate); +} + +u8 show_sprite(u8 localId, u8 mapNum, u8 mapGroup) +{ + struct MapObjectTemplate *mapObjectTemplate; + s16 cameraX; + s16 cameraY; + + mapObjectTemplate = GetFieldObjectTemplateByLocalIdAndMap(localId, mapNum, mapGroup); + if (mapObjectTemplate == NULL) + { + return ARRAY_COUNT(gMapObjects); + } + GetFieldObjectMovingCameraOffset(&cameraX, &cameraY); + return SpawnFieldObject(mapObjectTemplate, mapNum, mapGroup, cameraX, cameraY); +} + +void MakeObjectTemplateFromFieldObjectGraphicsInfo(u16 graphicsId, void (*callback)(struct Sprite *), struct SpriteTemplate *sprTemplate, const struct SubspriteTable **subspriteTables) +{ + const struct MapObjectGraphicsInfo *gfxInfo = GetFieldObjectGraphicsInfo(graphicsId); + + sprTemplate->tileTag = gfxInfo->tileTag; + sprTemplate->paletteTag = gfxInfo->paletteTag1; + sprTemplate->oam = gfxInfo->oam; + sprTemplate->anims = gfxInfo->anims; + sprTemplate->images = gfxInfo->images; + sprTemplate->affineAnims = gfxInfo->affineAnims; + sprTemplate->callback = callback; + *subspriteTables = gfxInfo->subspriteTables; +} From 112177b57f6f5ca95cd97bbe7a9a86924b341e5c Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 6 Sep 2017 22:46:44 -0400 Subject: [PATCH 021/191] Slight touching up of data3.s; denote boundaries of data/field_map_obj.s for future split --- asm/field_map_obj.s | 18 ------------------ data/data3.s | 7 ++++++- src/field_map_obj.c | 12 ++++++++++-- 3 files changed, 16 insertions(+), 21 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index e7740b66c..34578ec5c 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,24 +5,6 @@ .text - thumb_func_start MakeObjectTemplateFromFieldObjectGraphicsInfoWithCallbackIndex -@ void MakeObjectTemplateFromFieldObjectGraphicsInfoWithCallbackIndex(u16 graphicsId, u16 callbackIndex, struct objtemplate *objectTemplate, SpriteOamTable **spriteOamTables) -MakeObjectTemplateFromFieldObjectGraphicsInfoWithCallbackIndex: @ 808DD30 - push {r4,lr} - lsls r0, 16 - lsrs r0, 16 - lsls r1, 16 - ldr r4, =gUnknown_08505438 - lsrs r1, 14 - adds r1, r4 - ldr r1, [r1] - bl MakeObjectTemplateFromFieldObjectGraphicsInfo - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end MakeObjectTemplateFromFieldObjectGraphicsInfoWithCallbackIndex - thumb_func_start MakeObjectTemplateFromFieldObjectTemplate @ void MakeObjectTemplateFromFieldObjectTemplate(struct FieldObjectTemplate *fieldObjectTemplate, struct objtemplate *objectTemplate, SpriteOamTable **spriteOamTables) MakeObjectTemplateFromFieldObjectTemplate: @ 808DD50 diff --git a/data/data3.s b/data/data3.s index ee1ad294a..01f23aa12 100644 --- a/data/data3.s +++ b/data/data3.s @@ -642,6 +642,8 @@ gUnknown_084975B0:: @ 84975B0 gUnknown_084975BC:: @ 84975BC .incbin "baserom.gba", 0x4975bc, 0x8 +// data/field_map_obj.s + gUnknown_084975C4:: @ 84975C4 .incbin "baserom.gba", 0x4975c4, 0x10 @@ -661,8 +663,9 @@ gUnknown_0850557C:: @ 850557C .incbin "baserom.gba", 0x50557c, 0x51 gUnknown_085055CD:: @ 85055CD - .incbin "baserom.gba", 0x5055cd, 0x53 + .incbin "baserom.gba", 0x5055cd, 0x51 + .align 2, 0 @ 8505620 .include "data/graphics/field_objects/field_object_graphics_info_pointers.inc" @@ -1136,6 +1139,8 @@ gUnknown_0850DFBC:: @ 850DFBC gUnknown_0850DFC2:: @ 850DFC2 .incbin "baserom.gba", 0x50dfc2, 0x61a +// end data/field_map_obj.s + gUnknown_0850E5DC:: @ 850E5DC .incbin "baserom.gba", 0x50e5dc, 0x8 diff --git a/src/field_map_obj.c b/src/field_map_obj.c index e6376d156..e3e0b7158 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -10,6 +10,8 @@ #include "field_ground_effect.h" #include "field_map_obj.h" +#define NUM_FIELD_MAP_OBJECT_TEMPLATES 0x51 + // Static struct declarations // Static RAM declarations @@ -31,8 +33,9 @@ void sub_8096518(struct MapObject *, struct Sprite *); // ROM data -const u8 gUnknown_085055CD[0x53]; -const u8 gUnknown_0850557C[0x51]; +void (*const gUnknown_08505438[NUM_FIELD_MAP_OBJECT_TEMPLATES])(struct Sprite *); +const u8 gUnknown_0850557C[NUM_FIELD_MAP_OBJECT_TEMPLATES]; +const u8 gUnknown_085055CD[NUM_FIELD_MAP_OBJECT_TEMPLATES]; // Code @@ -605,3 +608,8 @@ void MakeObjectTemplateFromFieldObjectGraphicsInfo(u16 graphicsId, void (*callba sprTemplate->callback = callback; *subspriteTables = gfxInfo->subspriteTables; } + +void MakeObjectTemplateFromFieldObjectGraphicsInfoWithCallbackIndex(u16 graphicsId, u16 callbackIndex, struct SpriteTemplate *sprTemplate, const struct SubspriteTable **subspriteTables) +{ + MakeObjectTemplateFromFieldObjectGraphicsInfo(graphicsId, gUnknown_08505438[callbackIndex], sprTemplate, subspriteTables); +} From 12562aa2d42e1692aff319b091258d5c24a9e040 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 7 Sep 2017 14:16:30 -0400 Subject: [PATCH 022/191] MakeObjectTemplateFromFieldObjectTemplate --- asm/field_map_obj.s | 16 ---------------- src/field_map_obj.c | 5 +++++ src/malloc.c | 5 +++-- 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 34578ec5c..571223ec3 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,22 +5,6 @@ .text - thumb_func_start MakeObjectTemplateFromFieldObjectTemplate -@ void MakeObjectTemplateFromFieldObjectTemplate(struct FieldObjectTemplate *fieldObjectTemplate, struct objtemplate *objectTemplate, SpriteOamTable **spriteOamTables) -MakeObjectTemplateFromFieldObjectTemplate: @ 808DD50 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - adds r3, r2, 0 - ldrb r0, [r4, 0x1] - ldrb r1, [r4, 0x9] - adds r2, r5, 0 - bl MakeObjectTemplateFromFieldObjectGraphicsInfoWithCallbackIndex - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end MakeObjectTemplateFromFieldObjectTemplate - thumb_func_start AddPseudoFieldObject @ void AddPseudoFieldObject(u8 graphicsId, void ( *callback)(), u16 x, u16 y, u8 subpriority) AddPseudoFieldObject: @ 808DD68 diff --git a/src/field_map_obj.c b/src/field_map_obj.c index e3e0b7158..819721773 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -613,3 +613,8 @@ void MakeObjectTemplateFromFieldObjectGraphicsInfoWithCallbackIndex(u16 graphics { MakeObjectTemplateFromFieldObjectGraphicsInfo(graphicsId, gUnknown_08505438[callbackIndex], sprTemplate, subspriteTables); } + +void MakeObjectTemplateFromFieldObjectTemplate(struct MapObjectTemplate *mapObjectTemplate, struct SpriteTemplate *spriteTemplate, const struct SubspriteTable **subspriteTables) +{ + MakeObjectTemplateFromFieldObjectGraphicsInfoWithCallbackIndex(mapObjectTemplate->graphicsId, mapObjectTemplate->movementType, spriteTemplate, subspriteTables); +} diff --git a/src/malloc.c b/src/malloc.c index 948303c6f..5317565dc 100644 --- a/src/malloc.c +++ b/src/malloc.c @@ -40,7 +40,7 @@ void PutMemBlockHeader(void *block, struct MemBlock *prev, struct MemBlock *next void PutFirstMemBlockHeader(void *block, u32 size) { - PutMemBlockHeader(block, (struct MemBlock *)block, (struct MemBlock *)block, size - 16); + PutMemBlockHeader(block, (struct MemBlock *)block, (struct MemBlock *)block, size - sizeof(struct MemBlock)); } void *AllocInternal(void *heapStart, u32 size) @@ -50,6 +50,7 @@ void *AllocInternal(void *heapStart, u32 size) struct MemBlock *splitBlock; u32 foundBlockSize; + // Alignment if (size & 3) size = 4 * ((size / 4) + 1); @@ -60,7 +61,7 @@ void *AllocInternal(void *heapStart, u32 size) foundBlockSize = pos->size; if (foundBlockSize >= size) { - if (foundBlockSize - size <= 31) { + if (foundBlockSize - size < 2 * sizeof(struct MemBlock)) { // The block isn't much bigger than the requested size, // so just use it. pos->flag = TRUE; From f7742a68ae57ffa9e7b965c6cc816f7977b9e467 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 7 Sep 2017 14:31:23 -0400 Subject: [PATCH 023/191] AddPseudoFieldObject --- asm/field_map_obj.s | 79 --------------------------------------------- include/malloc.h | 4 +++ src/field_map_obj.c | 27 ++++++++++++++++ 3 files changed, 31 insertions(+), 79 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 571223ec3..7be604b27 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,85 +5,6 @@ .text - thumb_func_start AddPseudoFieldObject -@ void AddPseudoFieldObject(u8 graphicsId, void ( *callback)(), u16 x, u16 y, u8 subpriority) -AddPseudoFieldObject: @ 808DD68 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - ldr r0, [sp, 0x20] - lsls r4, 16 - lsrs r4, 16 - lsls r2, 16 - lsrs r2, 16 - mov r8, r2 - lsls r3, 16 - lsrs r7, r3, 16 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 - movs r0, 0x18 - bl Alloc - adds r6, r0, 0 - adds r0, r4, 0 - adds r1, r5, 0 - adds r2, r6, 0 - mov r3, sp - bl MakeObjectTemplateFromFieldObjectGraphicsInfo - ldrh r1, [r6, 0x2] - ldr r0, =0x0000ffff - cmp r1, r0 - beq _0808DDAE - adds r0, r1, 0 - bl sub_808E894 -_0808DDAE: - mov r0, r8 - lsls r1, r0, 16 - asrs r1, 16 - lsls r2, r7, 16 - asrs r2, 16 - adds r0, r6, 0 - mov r3, r9 - bl CreateSprite - lsls r0, 24 - lsrs r5, r0, 24 - adds r0, r6, 0 - bl Free - cmp r5, 0x40 - beq _0808DDF2 - ldr r1, [sp] - cmp r1, 0 - beq _0808DDF2 - lsls r4, r5, 4 - adds r4, r5 - lsls r4, 2 - ldr r0, =gSprites - adds r4, r0 - adds r0, r4, 0 - bl SetSubspriteTables - adds r4, 0x42 - ldrb r1, [r4] - movs r0, 0x3F - ands r0, r1 - movs r1, 0x80 - orrs r0, r1 - strb r0, [r4] -_0808DDF2: - adds r0, r5, 0 - add sp, 0x4 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end AddPseudoFieldObject - thumb_func_start sprite_new sprite_new: @ 808DE0C push {r4-r7,lr} diff --git a/include/malloc.h b/include/malloc.h index bd870ede3..b3216b05c 100644 --- a/include/malloc.h +++ b/include/malloc.h @@ -1,6 +1,10 @@ #ifndef GUARD_MALLOC_H #define GUARD_MALLOC_H +#define malloc Alloc +#define calloc AllocZeroed +#define free Free + void *Alloc(u32 size); void *AllocZeroed(u32 size); void Free(void *pointer); diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 819721773..c434ee7db 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -1,6 +1,7 @@ // Includes #include "global.h" +#include "malloc.h" #include "sprite.h" #include "rom4.h" #include "field_player_avatar.h" @@ -30,6 +31,7 @@ void sub_8096518(struct MapObject *, struct Sprite *); /*static*/ void MakeObjectTemplateFromFieldObjectTemplate(struct MapObjectTemplate *, struct SpriteTemplate *, const struct SubspriteTable **); /*static*/ void GetFieldObjectMovingCameraOffset(s16 *, s16 *); /*static*/ struct MapObjectTemplate *GetFieldObjectTemplateByLocalIdAndMap(u8, u8, u8); +/*static*/ void sub_808E894(u16); // ROM data @@ -618,3 +620,28 @@ void MakeObjectTemplateFromFieldObjectTemplate(struct MapObjectTemplate *mapObje { MakeObjectTemplateFromFieldObjectGraphicsInfoWithCallbackIndex(mapObjectTemplate->graphicsId, mapObjectTemplate->movementType, spriteTemplate, subspriteTables); } + +u8 AddPseudoFieldObject(u16 graphicsId, void (*callback)(struct Sprite *), s16 x, s16 y, u8 subpriority) +{ + struct SpriteTemplate *spriteTemplate; + const struct SubspriteTable *subspriteTables; + struct Sprite *sprite; + u8 spriteIdx; + + spriteTemplate = malloc(sizeof(struct SpriteTemplate)); + MakeObjectTemplateFromFieldObjectGraphicsInfo(graphicsId, callback, spriteTemplate, &subspriteTables); + if (spriteTemplate->paletteTag != 0xffff) + { + sub_808E894(spriteTemplate->paletteTag); + } + spriteIdx = CreateSprite(spriteTemplate, x, y, subpriority); + free(spriteTemplate); + + if (spriteIdx != MAX_SPRITES && subspriteTables != NULL) + { + sprite = &gSprites[spriteIdx]; + SetSubspriteTables(sprite, subspriteTables); + sprite->subspriteMode = 2; + } + return spriteIdx; +} From 64ebd9b4fb54fae34a8f7cebb14588b89693d4a3 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 7 Sep 2017 15:50:49 -0400 Subject: [PATCH 024/191] sprite_new --- asm/field_map_obj.s | 178 ---------------------------------- include/field_ground_effect.h | 1 + include/field_map_obj.h | 1 + include/map_obj_8097404.h | 15 +++ src/field_map_obj.c | 50 ++++++++++ 5 files changed, 67 insertions(+), 178 deletions(-) create mode 100644 include/map_obj_8097404.h diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 7be604b27..187797022 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,184 +5,6 @@ .text - thumb_func_start sprite_new -sprite_new: @ 808DE0C - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x20 - adds r5, r0, 0 - ldr r0, [sp, 0x40] - ldr r4, [sp, 0x44] - lsls r5, 24 - lsrs r5, 24 - lsls r1, 24 - lsrs r1, 24 - mov r9, r1 - add r1, sp, 0x18 - mov r8, r1 - strh r2, [r1] - mov r6, sp - adds r6, 0x1A - strh r3, [r6] - lsls r0, 24 - lsrs r7, r0, 24 - lsls r4, 24 - lsrs r4, 24 - mov r10, r4 - adds r0, r5, 0 - bl GetFieldObjectGraphicsInfo - adds r4, r0, 0 - ldr r1, =sub_8097AC8 - add r3, sp, 0x1C - adds r0, r5, 0 - mov r2, sp - bl MakeObjectTemplateFromFieldObjectGraphicsInfo - mov r1, sp - ldr r2, =0x0000ffff - adds r0, r2, 0 - strh r0, [r1, 0x2] - mov r1, r8 - movs r2, 0 - ldrsh r0, [r1, r2] - adds r0, 0x7 - strh r0, [r1] - movs r1, 0 - ldrsh r0, [r6, r1] - adds r0, 0x7 - strh r0, [r6] - mov r0, r8 - adds r1, r6, 0 - movs r2, 0x8 - movs r3, 0x10 - bl sub_80930E0 - mov r2, r8 - movs r0, 0 - ldrsh r1, [r2, r0] - movs r0, 0 - ldrsh r2, [r6, r0] - mov r0, sp - movs r3, 0 - bl CreateSpriteAtEnd - lsls r0, 24 - lsrs r6, r0, 24 - cmp r6, 0x40 - beq _0808DF6C - lsls r0, r6, 4 - adds r0, r6 - lsls r0, 2 - ldr r1, =gSprites - adds r5, r0, r1 - ldrh r0, [r4, 0x8] - lsls r0, 16 - asrs r0, 17 - negs r0, r0 - adds r1, r5, 0 - adds r1, 0x28 - strb r0, [r1] - ldrh r0, [r4, 0xA] - lsls r0, 16 - asrs r0, 17 - negs r0, r0 - adds r1, 0x1 - strb r0, [r1] - movs r0, 0 - ldrsb r0, [r1, r0] - ldrh r1, [r5, 0x22] - adds r0, r1 - strh r0, [r5, 0x22] - ldrb r0, [r4, 0xC] - lsls r0, 28 - lsrs r0, 24 - ldrb r1, [r5, 0x5] - movs r3, 0xF - adds r2, r3, 0 - ands r2, r1 - orrs r2, r0 - strb r2, [r5, 0x5] - lsls r1, r2, 24 - lsrs r0, r1, 28 - cmp r0, 0xF - bls _0808DEE4 - subs r0, 0x10 - lsls r0, 4 - ands r2, r3 - orrs r2, r0 - strb r2, [r5, 0x5] -_0808DEE4: - adds r2, r5, 0 - adds r2, 0x3E - ldrb r0, [r2] - movs r1, 0x2 - orrs r0, r1 - strb r0, [r2] - mov r2, r9 - strh r2, [r5, 0x2E] - strh r7, [r5, 0x30] - ldrb r1, [r4, 0xC] - adds r0, r3, 0 - ands r0, r1 - cmp r0, 0xA - bne _0808DF18 - ldrh r0, [r4, 0x2] - lsls r1, 28 - lsrs r1, 28 - bl npc_load_two_palettes__and_record - b _0808DF2C - .pool -_0808DF18: - lsls r1, 28 - lsrs r0, r1, 28 - cmp r0, 0xF - bls _0808DF2C - ldrh r0, [r4, 0x2] - lsrs r2, r1, 28 - movs r1, 0xF0 - orrs r1, r2 - bl sub_808EAB0 -_0808DF2C: - ldr r1, [sp, 0x1C] - cmp r1, 0 - beq _0808DF48 - adds r0, r5, 0 - bl SetSubspriteTables - adds r2, r5, 0 - adds r2, 0x42 - ldrb r0, [r2] - movs r1, 0x3F - ands r1, r0 - movs r0, 0x80 - orrs r1, r0 - strb r1, [r2] -_0808DF48: - adds r0, r5, 0 - adds r1, r7, 0 - bl InitObjectPriorityByZCoord - adds r0, r7, 0 - adds r1, r5, 0 - movs r2, 0x1 - bl SetObjectSubpriorityByZCoord - mov r0, r10 - bl FieldObjectDirectionToImageAnimId - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 24 - adds r0, r5, 0 - bl StartSpriteAnim -_0808DF6C: - adds r0, r6, 0 - add sp, 0x20 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sprite_new - thumb_func_start SpawnFieldObjectsInView @ void SpawnFieldObjectsInView(u16 movingCameraOffsetX, u16 movingCameraOffsetY) SpawnFieldObjectsInView: @ 808DF80 diff --git a/include/field_ground_effect.h b/include/field_ground_effect.h index 2b93273db..0c90f50dc 100644 --- a/include/field_ground_effect.h +++ b/include/field_ground_effect.h @@ -11,5 +11,6 @@ // Exported ROM declarations void SetObjectSubpriorityByZCoord(u8, struct Sprite *, u8); +void InitObjectPriorityByZCoord(struct Sprite *, u8); #endif //POKEEMERALD_FIELD_GROUND_EFFECT_H diff --git a/include/field_map_obj.h b/include/field_map_obj.h index 6ddff4901..40f94ccab 100644 --- a/include/field_map_obj.h +++ b/include/field_map_obj.h @@ -23,6 +23,7 @@ void npc_load_two_palettes__and_record(u16, u8); void sub_808EAB0(u16, u8); void sub_8092FF0(s16, s16, s16 *, s16 *); u8 FieldObjectDirectionToImageAnimId(u8); +void sub_80930E0(s16 *, s16 *, u8, u8); // Exported data declarations diff --git a/include/map_obj_8097404.h b/include/map_obj_8097404.h new file mode 100644 index 000000000..6296febe4 --- /dev/null +++ b/include/map_obj_8097404.h @@ -0,0 +1,15 @@ +// +// Created by scott on 9/7/2017. +// + +#ifndef POKEEMERALD_MAP_OBJ_8097404_H +#define POKEEMERALD_MAP_OBJ_8097404_H + +// Exported type declarations + +// Exported RAM declarations + +// Exported ROM declarations +void sub_8097AC8(struct Sprite *); + +#endif //POKEEMERALD_MAP_OBJ_8097404_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index c434ee7db..82e74747d 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -9,6 +9,7 @@ #include "rom_818CFC8.h" #include "rom_81BE66C.h" #include "field_ground_effect.h" +#include "map_obj_8097404.h" #include "field_map_obj.h" #define NUM_FIELD_MAP_OBJECT_TEMPLATES 0x51 @@ -645,3 +646,52 @@ u8 AddPseudoFieldObject(u16 graphicsId, void (*callback)(struct Sprite *), s16 x } return spriteIdx; } + +u8 sprite_new(u8 graphicsId, u8 a1, s16 x, s16 y, u8 z, u8 direction) +{ + const struct MapObjectGraphicsInfo *graphicsInfo; + struct SpriteTemplate spriteTemplate; + const struct SubspriteTable *subspriteTables; + u8 spriteId; + struct Sprite *sprite; + + graphicsInfo = GetFieldObjectGraphicsInfo(graphicsId); + MakeObjectTemplateFromFieldObjectGraphicsInfo(graphicsId, sub_8097AC8, &spriteTemplate, &subspriteTables); + *(u16 *)&spriteTemplate.paletteTag = 0xffff; + x += 7; + y += 7; + sub_80930E0(&x, &y, 8, 16); + spriteId = CreateSpriteAtEnd(&spriteTemplate, x, y, 0); + if (spriteId != MAX_SPRITES) + { + sprite = &gSprites[spriteId]; + sprite->centerToCornerVecX = -(graphicsInfo->width >> 1); + sprite->centerToCornerVecY = -(graphicsInfo->height >> 1); + sprite->pos1.y += sprite->centerToCornerVecY; + sprite->oam.paletteNum = graphicsInfo->paletteSlot; + if (sprite->oam.paletteNum >= 16) + { + sprite->oam.paletteNum -= 16; + } + sprite->coordOffsetEnabled = TRUE; + sprite->data0 = a1; + sprite->data1 = z; + if (graphicsInfo->paletteSlot == 10) + { + npc_load_two_palettes__and_record(graphicsInfo->paletteTag1, graphicsInfo->paletteSlot); + } + else if (graphicsInfo->paletteSlot >= 16) + { + sub_808EAB0(graphicsInfo->paletteTag1, graphicsInfo->paletteSlot | 0xf0); + } + if (subspriteTables != NULL) + { + SetSubspriteTables(sprite, subspriteTables); + sprite->subspriteMode = 2; + } + InitObjectPriorityByZCoord(sprite, z); + SetObjectSubpriorityByZCoord(z, sprite, 1); + StartSpriteAnim(sprite, FieldObjectDirectionToImageAnimId(direction)); + } + return spriteId; +} From f128e4c4f0e1214801178e643223a77d8ec904f8 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 7 Sep 2017 15:58:38 -0400 Subject: [PATCH 025/191] SpawnFieldObjectsInView --- asm/field_map_obj.s | 135 -------------------------------------------- src/field_map_obj.c | 44 +++++++++++++++ 2 files changed, 44 insertions(+), 135 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 187797022..af47dd1f0 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,141 +5,6 @@ .text - thumb_func_start SpawnFieldObjectsInView -@ void SpawnFieldObjectsInView(u16 movingCameraOffsetX, u16 movingCameraOffsetY) -SpawnFieldObjectsInView: @ 808DF80 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x10 - lsls r0, 16 - lsrs r0, 16 - str r0, [sp, 0x4] - lsls r1, 16 - lsrs r1, 16 - str r1, [sp, 0x8] - ldr r5, =gMapHeader - ldr r0, [r5, 0x4] - cmp r0, 0 - beq _0808E078 - ldr r0, =gSaveBlock1Ptr - ldr r2, [r0] - ldrh r1, [r2] - subs r0, r1, 0x2 - lsls r0, 16 - lsrs r0, 16 - mov r8, r0 - adds r1, 0x11 - lsls r1, 16 - lsrs r1, 16 - str r1, [sp, 0xC] - ldrh r4, [r2, 0x2] - adds r0, r4, 0 - adds r0, 0x10 - lsls r0, 16 - lsrs r0, 16 - mov r10, r0 - bl InBattlePyramid - lsls r0, 24 - cmp r0, 0 - beq _0808DFE0 - bl sub_81AAA40 - lsls r0, 24 - lsrs r6, r0, 24 - b _0808DFF0 - .pool -_0808DFE0: - bl InTrainerHill - cmp r0, 0 - beq _0808DFEC - movs r6, 0x2 - b _0808DFF0 -_0808DFEC: - ldr r0, [r5, 0x4] - ldrb r6, [r0] -_0808DFF0: - movs r5, 0 - cmp r5, r6 - bcs _0808E078 - lsls r0, r4, 16 - asrs r0, 16 - mov r9, r0 - mov r1, r8 - lsls r0, r1, 16 - asrs r0, 16 - mov r8, r0 -_0808E004: - lsls r0, r5, 1 - adds r0, r5 - lsls r0, 3 - movs r2, 0xC7 - lsls r2, 4 - adds r0, r2 - ldr r3, =gSaveBlock1Ptr - ldr r1, [r3] - adds r4, r1, r0 - ldrh r0, [r4, 0x4] - adds r0, 0x7 - lsls r0, 16 - lsrs r2, r0, 16 - ldrh r0, [r4, 0x6] - adds r0, 0x7 - lsls r0, 16 - asrs r1, r0, 16 - cmp r9, r1 - bgt _0808E06E - mov r7, r10 - lsls r0, r7, 16 - asrs r0, 16 - cmp r0, r1 - blt _0808E06E - lsls r0, r2, 16 - asrs r1, r0, 16 - cmp r8, r1 - bgt _0808E06E - ldr r2, [sp, 0xC] - lsls r0, r2, 16 - asrs r0, 16 - cmp r0, r1 - blt _0808E06E - ldrh r0, [r4, 0x14] - bl FlagGet - lsls r0, 24 - cmp r0, 0 - bne _0808E06E - ldr r3, =gSaveBlock1Ptr - ldr r0, [r3] - ldrb r1, [r0, 0x5] - ldrb r2, [r0, 0x4] - ldr r7, [sp, 0x4] - lsls r3, r7, 16 - ldr r7, [sp, 0x8] - lsls r0, r7, 16 - asrs r0, 16 - str r0, [sp] - adds r0, r4, 0 - asrs r3, 16 - bl SpawnFieldObject -_0808E06E: - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, r6 - bcc _0808E004 -_0808E078: - add sp, 0x10 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end SpawnFieldObjectsInView - thumb_func_start RemoveFieldObjectsOutsideView @ void RemoveFieldObjectsOutsideView() RemoveFieldObjectsOutsideView: @ 808E08C diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 82e74747d..b6a7f9c9a 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -695,3 +695,47 @@ u8 sprite_new(u8 graphicsId, u8 a1, s16 x, s16 y, u8 z, u8 direction) } return spriteId; } + +void SpawnFieldObjectsInView(s16 cameraX, s16 cameraY) +{ + u8 i; + s16 left; + s16 right; + s16 top; + s16 bottom; + u8 objectCount; + s16 npcX; + s16 npcY; + + if (gMapHeader.events != NULL) + { + left = gSaveBlock1Ptr->pos.x - 2; + right = gSaveBlock1Ptr->pos.x + 17; + top = gSaveBlock1Ptr->pos.y; + bottom = gSaveBlock1Ptr->pos.y + 16; + + if (InBattlePyramid()) + { + objectCount = sub_81AAA40(); + } + else if (InTrainerHill()) + { + objectCount = 2; + } + else + { + objectCount = gMapHeader.events->mapObjectCount; + } + + for (i = 0; i < objectCount; i++) + { + struct MapObjectTemplate *template = &gSaveBlock1Ptr->mapObjectTemplates[i]; + npcX = template->x + 7; + npcY = template->y + 7; + + if (top <= npcY && bottom >= npcY && left <= npcX && right >= npcX + && !FlagGet(template->flagId)) + SpawnFieldObject(template, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, cameraX, cameraY); + } + } +} From 341a4735bc3e702104574055b97f1d691668bc14 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 7 Sep 2017 16:09:59 -0400 Subject: [PATCH 026/191] RemoveFieldObjectsOutsideView --- asm/field_control_avatar.s | 2 +- asm/field_map_obj.s | 53 +------------------------------------- asm/rom4.s | 28 ++++++++++---------- include/rom4.h | 22 ++++++++++++++++ src/field_map_obj.c | 25 ++++++++++++++++++ sym_ewram.txt | 2 +- 6 files changed, 64 insertions(+), 68 deletions(-) diff --git a/asm/field_control_avatar.s b/asm/field_control_avatar.s index 3b1052473..4f29f2b3a 100644 --- a/asm/field_control_avatar.s +++ b/asm/field_control_avatar.s @@ -567,7 +567,7 @@ _0809C32E: .pool _0809C33C: movs r4, 0 - ldr r1, =gUnknown_02032308 + ldr r1, =gLinkPlayerMapObjects _0809C340: ldrb r0, [r1] cmp r0, 0x1 diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index af47dd1f0..3b3d230ab 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,57 +5,6 @@ .text - thumb_func_start RemoveFieldObjectsOutsideView -@ void RemoveFieldObjectsOutsideView() -RemoveFieldObjectsOutsideView: @ 808E08C - push {r4-r6,lr} - movs r3, 0 - ldr r6, =gUnknown_02032308 -_0808E092: - movs r2, 0 - movs r4, 0 - adds r5, r3, 0x1 -_0808E098: - lsls r0, r2, 2 - adds r1, r0, r6 - ldrb r0, [r1] - cmp r0, 0 - beq _0808E0AA - ldrb r1, [r1, 0x2] - cmp r3, r1 - bne _0808E0AA - movs r4, 0x1 -_0808E0AA: - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x3 - bls _0808E098 - cmp r4, 0 - bne _0808E0D2 - lsls r0, r3, 3 - adds r0, r3 - lsls r0, 2 - ldr r1, =gMapObjects - adds r2, r0, r1 - ldr r0, [r2] - ldr r1, =0x00010001 - ands r0, r1 - cmp r0, 0x1 - bne _0808E0D2 - adds r0, r2, 0 - bl RemoveFieldObjectIfOutsideView -_0808E0D2: - lsls r0, r5, 24 - lsrs r3, r0, 24 - cmp r3, 0xF - bls _0808E092 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end RemoveFieldObjectsOutsideView - thumb_func_start RemoveFieldObjectIfOutsideView @ void RemoveFieldObjectIfOutsideView(npc_state *fieldObject) RemoveFieldObjectIfOutsideView: @ 808E0EC @@ -183,7 +132,7 @@ sub_808E1B8: @ 808E1B8 lsrs r2, 16 str r2, [sp, 0x24] movs r7, 0 - ldr r2, =gUnknown_02032308 + ldr r2, =gLinkPlayerMapObjects _0808E1DA: lsls r0, r7, 2 adds r1, r0, r2 diff --git a/asm/rom4.s b/asm/rom4.s index bf16055e7..b36de6f2e 100644 --- a/asm/rom4.s +++ b/asm/rom4.s @@ -5480,7 +5480,7 @@ sub_80872D8: @ 80872D8 movs r0, 0x1 _080872EA: strb r0, [r6, 0x1] - ldr r1, =gUnknown_02032308 + ldr r1, =gLinkPlayerMapObjects lsls r0, r4, 2 adds r0, r1 ldrb r0, [r0, 0x3] @@ -5977,7 +5977,7 @@ sub_80876C4: @ 80876C4 thumb_func_start strange_npc_table_clear strange_npc_table_clear: @ 80876CC push {lr} - ldr r0, =gUnknown_02032308 + ldr r0, =gLinkPlayerMapObjects movs r1, 0 movs r2, 0x10 bl memset @@ -6025,7 +6025,7 @@ sub_80876F0: @ 80876F0 lsls r6, 24 lsrs r6, 24 lsls r4, r7, 2 - ldr r0, =gUnknown_02032308 + ldr r0, =gLinkPlayerMapObjects adds r4, r0 lsls r5, r6, 3 adds r5, r6 @@ -6118,7 +6118,7 @@ sub_80877DC: @ 80877DC lsls r0, 24 lsls r1, 24 lsrs r2, r1, 24 - ldr r1, =gUnknown_02032308 + ldr r1, =gLinkPlayerMapObjects lsrs r0, 22 adds r1, r0, r1 ldrb r0, [r1] @@ -6142,7 +6142,7 @@ sub_808780C: @ 808780C push {r4,r5,lr} lsls r0, 24 lsrs r0, 22 - ldr r1, =gUnknown_02032308 + ldr r1, =gLinkPlayerMapObjects adds r5, r0, r1 ldrb r1, [r5, 0x2] lsls r0, r1, 3 @@ -6176,7 +6176,7 @@ _08087838: thumb_func_start sub_8087858 sub_8087858: @ 8087858 lsls r0, 24 - ldr r1, =gUnknown_02032308 + ldr r1, =gLinkPlayerMapObjects lsrs r0, 22 adds r0, r1 ldrb r1, [r0, 0x2] @@ -6193,7 +6193,7 @@ sub_8087858: @ 8087858 thumb_func_start sub_8087878 sub_8087878: @ 8087878 lsls r0, 24 - ldr r3, =gUnknown_02032308 + ldr r3, =gLinkPlayerMapObjects lsrs r0, 22 adds r0, r3 ldrb r3, [r0, 0x2] @@ -6213,7 +6213,7 @@ sub_8087878: @ 8087878 thumb_func_start sub_80878A0 sub_80878A0: @ 80878A0 lsls r0, 24 - ldr r1, =gUnknown_02032308 + ldr r1, =gLinkPlayerMapObjects lsrs r0, 22 adds r0, r1 ldrb r1, [r0, 0x2] @@ -6230,7 +6230,7 @@ sub_80878A0: @ 80878A0 thumb_func_start sub_80878C0 sub_80878C0: @ 80878C0 lsls r0, 24 - ldr r1, =gUnknown_02032308 + ldr r1, =gLinkPlayerMapObjects lsrs r0, 22 adds r0, r1 ldrb r1, [r0, 0x2] @@ -6249,7 +6249,7 @@ sub_80878C0: @ 80878C0 thumb_func_start sub_80878E4 sub_80878E4: @ 80878E4 lsls r0, 24 - ldr r1, =gUnknown_02032308 + ldr r1, =gLinkPlayerMapObjects lsrs r0, 22 adds r0, r1 ldrb r1, [r0, 0x2] @@ -6271,7 +6271,7 @@ sub_80878E4: @ 80878E4 sub_808790C: @ 808790C push {r4-r6,lr} movs r2, 0 - ldr r5, =gUnknown_02032308 + ldr r5, =gLinkPlayerMapObjects lsls r0, 16 asrs r4, r0, 16 lsls r1, 16 @@ -6326,7 +6326,7 @@ sub_808796C: @ 808796C lsrs r3, r1, 24 adds r2, r3, 0 lsrs r0, 22 - ldr r1, =gUnknown_02032308 + ldr r1, =gLinkPlayerMapObjects adds r5, r0, r1 ldrb r1, [r5, 0x2] lsls r0, r1, 3 @@ -6654,7 +6654,7 @@ sub_8087BCC: @ 8087BCC lsls r1, 24 lsrs r3, r1, 24 lsls r2, r5, 2 - ldr r0, =gUnknown_02032308 + ldr r0, =gLinkPlayerMapObjects adds r2, r0 ldrb r1, [r2, 0x2] lsls r0, r1, 3 @@ -6742,7 +6742,7 @@ sub_8087C8C: @ 8087C8C movs r0, 0x2E ldrsh r4, [r5, r0] lsls r4, 2 - ldr r0, =gUnknown_02032308 + ldr r0, =gLinkPlayerMapObjects adds r4, r0 ldrb r1, [r4, 0x2] lsls r0, r1, 3 diff --git a/include/rom4.h b/include/rom4.h index 956160afb..655ce3fde 100644 --- a/include/rom4.h +++ b/include/rom4.h @@ -2,6 +2,28 @@ #ifndef POKEEMERALD_ROM4_H #define POKEEMERALD_ROM4_H +struct UnkPlayerStruct +{ + u8 player_field_0; + u8 player_field_1; +}; + +struct LinkPlayerMapObject +{ + u8 active; + u8 linkPlayerId; + u8 mapObjId; + u8 mode; +}; + +struct UCoords32 +{ + u32 x, y; +}; + + +extern struct LinkPlayerMapObject gLinkPlayerMapObjects[4]; + void strange_npc_table_clear(void); #endif //POKEEMERALD_ROM4_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index b6a7f9c9a..0d04c4063 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -33,6 +33,7 @@ void sub_8096518(struct MapObject *, struct Sprite *); /*static*/ void GetFieldObjectMovingCameraOffset(s16 *, s16 *); /*static*/ struct MapObjectTemplate *GetFieldObjectTemplateByLocalIdAndMap(u8, u8, u8); /*static*/ void sub_808E894(u16); +/*static*/ void RemoveFieldObjectIfOutsideView(struct MapObject *mapObject); // ROM data @@ -739,3 +740,27 @@ void SpawnFieldObjectsInView(s16 cameraX, s16 cameraY) } } } + +void RemoveFieldObjectsOutsideView(void) +{ + u8 i; + u8 j; + bool8 isActiveLinkPlayer; + struct MapObject *mapObject; + + for (i = 0; i < ARRAY_COUNT(gMapObjects); i ++) + { + for (j = 0, isActiveLinkPlayer = FALSE; j < ARRAY_COUNT(gLinkPlayerMapObjects); j ++) + { + if (gLinkPlayerMapObjects[j].active && i == gLinkPlayerMapObjects[j].mapObjId) + isActiveLinkPlayer = TRUE; + } + if (!isActiveLinkPlayer) + { + mapObject = &gMapObjects[i]; + + if (mapObject->active && !mapObject->mapobj_bit_16) + RemoveFieldObjectIfOutsideView(mapObject); + } + } +} diff --git a/sym_ewram.txt b/sym_ewram.txt index bfe8faeb9..f1a138b7a 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -740,7 +740,7 @@ gUnknown_02032304: @ 2032304 gUnknown_02032306: @ 2032306 .space 0x2 -gUnknown_02032308: @ 2032308 +gLinkPlayerMapObjects: @ 2032308 .space 0x10 gUnknown_02032318: @ 2032318 From 44be18e1dfc9a0eb58159b219762b3397d89e449 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 7 Sep 2017 17:41:56 -0400 Subject: [PATCH 027/191] RemoveFieldObjectIfOutsideView --- asm/field_map_obj.s | 69 --------------------------------------------- src/field_map_obj.c | 21 ++++++++++++++ 2 files changed, 21 insertions(+), 69 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 3b3d230ab..61b470b55 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,75 +5,6 @@ .text - thumb_func_start RemoveFieldObjectIfOutsideView -@ void RemoveFieldObjectIfOutsideView(npc_state *fieldObject) -RemoveFieldObjectIfOutsideView: @ 808E0EC - push {r4-r7,lr} - adds r3, r0, 0 - ldr r0, =gSaveBlock1Ptr - ldr r2, [r0] - ldrh r0, [r2] - subs r1, r0, 0x2 - lsls r1, 16 - adds r0, 0x11 - lsls r0, 16 - lsrs r5, r0, 16 - ldrh r4, [r2, 0x2] - adds r0, r4, 0 - adds r0, 0x10 - lsls r0, 16 - lsrs r6, r0, 16 - movs r0, 0x10 - ldrsh r2, [r3, r0] - lsrs r7, r1, 16 - asrs r1, 16 - cmp r2, r1 - blt _0808E132 - lsls r0, r5, 16 - asrs r0, 16 - cmp r2, r0 - bgt _0808E132 - movs r0, 0x12 - ldrsh r1, [r3, r0] - lsls r0, r4, 16 - asrs r0, 16 - cmp r1, r0 - blt _0808E132 - lsls r0, r6, 16 - asrs r0, 16 - cmp r1, r0 - ble _0808E160 -_0808E132: - movs r0, 0xC - ldrsh r1, [r3, r0] - lsls r0, r7, 16 - asrs r0, 16 - cmp r1, r0 - blt _0808E15A - lsls r0, r5, 16 - asrs r0, 16 - cmp r1, r0 - bgt _0808E15A - movs r0, 0xE - ldrsh r1, [r3, r0] - lsls r0, r4, 16 - asrs r0, 16 - cmp r1, r0 - blt _0808E15A - lsls r0, r6, 16 - asrs r0, 16 - cmp r1, r0 - ble _0808E160 -_0808E15A: - adds r0, r3, 0 - bl RemoveFieldObject -_0808E160: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end RemoveFieldObjectIfOutsideView - thumb_func_start sub_808E16C sub_808E16C: @ 808E16C push {r4-r7,lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 0d04c4063..caf43ce6a 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -764,3 +764,24 @@ void RemoveFieldObjectsOutsideView(void) } } } + +void RemoveFieldObjectIfOutsideView(struct MapObject *mapObject) +{ + s16 left; + s16 right; + s16 top; + s16 bottom; + + left = gSaveBlock1Ptr->pos.x - 2; + right = gSaveBlock1Ptr->pos.x + 17; + top = gSaveBlock1Ptr->pos.y; + bottom = gSaveBlock1Ptr->pos.y + 16; + + if (mapObject->coords2.x >= left && mapObject->coords2.x <= right + && mapObject->coords2.y >= top && mapObject->coords2.y <= bottom) + return; + if (mapObject->coords1.x >= left && mapObject->coords1.x <= right + && mapObject->coords1.y >= top && mapObject->coords1.y <= bottom) + return; + RemoveFieldObject(mapObject); +} From 113482a7cc748d80526de6b981887c5eca30f6b5 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 7 Sep 2017 18:54:51 -0400 Subject: [PATCH 028/191] sub_808E16C --- asm/field_map_obj.s | 40 ---------------------------------------- src/field_map_obj.c | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 40 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 61b470b55..0e90f7562 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,46 +5,6 @@ .text - thumb_func_start sub_808E16C -sub_808E16C: @ 808E16C - push {r4-r7,lr} - adds r4, r0, 0 - adds r5, r1, 0 - lsls r4, 16 - lsrs r4, 16 - lsls r5, 16 - lsrs r5, 16 - bl ClearPlayerAvatarInfo - movs r6, 0 - ldr r7, =gMapObjects - lsls r4, 16 - lsls r5, 16 -_0808E186: - lsls r0, r6, 3 - adds r0, r6 - lsls r0, 2 - adds r0, r7 - ldrb r0, [r0] - lsls r0, 31 - cmp r0, 0 - beq _0808E1A0 - adds r0, r6, 0 - asrs r1, r4, 16 - asrs r2, r5, 16 - bl sub_808E1B8 -_0808E1A0: - adds r0, r6, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 - cmp r6, 0xF - bls _0808E186 - bl sub_808D450 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_808E16C - thumb_func_start sub_808E1B8 sub_808E1B8: @ 808E1B8 push {r4-r7,lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index caf43ce6a..3e3f22a45 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -34,6 +34,7 @@ void sub_8096518(struct MapObject *, struct Sprite *); /*static*/ struct MapObjectTemplate *GetFieldObjectTemplateByLocalIdAndMap(u8, u8, u8); /*static*/ void sub_808E894(u16); /*static*/ void RemoveFieldObjectIfOutsideView(struct MapObject *mapObject); +/*static*/ void sub_808E1B8(u8, s16, s16); // ROM data @@ -785,3 +786,18 @@ void RemoveFieldObjectIfOutsideView(struct MapObject *mapObject) return; RemoveFieldObject(mapObject); } + +void sub_808E16C(s16 x, s16 y) +{ + u8 i; + + ClearPlayerAvatarInfo(); + for (i = 0; i < ARRAY_COUNT(gMapObjects); i ++) + { + if (gMapObjects[i].active) + { + sub_808E1B8(i, x, y); + } + } + sub_808D450(); +} From de8ef5e12599098abd71c97f654192f6a8cbe900 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 7 Sep 2017 19:28:46 -0400 Subject: [PATCH 029/191] sub_808E1B8 --- asm/field_map_obj.s | 223 --------------------------------- include/field_effect_helpers.h | 15 +++ src/field_map_obj.c | 82 +++++++++++- 3 files changed, 95 insertions(+), 225 deletions(-) create mode 100644 include/field_effect_helpers.h diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 0e90f7562..aeca020ab 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,229 +5,6 @@ .text - thumb_func_start sub_808E1B8 -sub_808E1B8: @ 808E1B8 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x28 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 - lsls r1, 16 - lsrs r1, 16 - mov r10, r1 - lsls r2, 16 - lsrs r2, 16 - str r2, [sp, 0x24] - movs r7, 0 - ldr r2, =gLinkPlayerMapObjects -_0808E1DA: - lsls r0, r7, 2 - adds r1, r0, r2 - ldrb r0, [r1] - cmp r0, 0 - beq _0808E1EC - ldrb r1, [r1, 0x2] - cmp r9, r1 - bne _0808E1EC - b _0808E374 -_0808E1EC: - adds r0, r7, 0x1 - lsls r0, 24 - lsrs r7, r0, 24 - cmp r7, 0x3 - bls _0808E1DA - mov r1, r9 - lsls r0, r1, 3 - add r0, r9 - lsls r0, 2 - ldr r1, =gMapObjects - adds r6, r0, r1 - movs r0, 0 - str r0, [sp, 0x20] - ldrb r0, [r6, 0x5] - bl GetFieldObjectGraphicsInfo - adds r5, r0, 0 - ldrh r2, [r5, 0x6] - ldr r1, =0xffff0000 - add r4, sp, 0x18 - ldr r0, [r4, 0x4] - ands r0, r1 - orrs r0, r2 - str r0, [r4, 0x4] - ldrb r0, [r6, 0x5] - ldrb r1, [r6, 0x6] - add r3, sp, 0x20 - mov r2, sp - bl MakeObjectTemplateFromFieldObjectGraphicsInfoWithCallbackIndex - str r4, [sp, 0xC] - mov r1, sp - ldr r2, =0x0000ffff - adds r0, r2, 0 - strh r0, [r1, 0x2] - ldrb r0, [r5, 0xC] - lsls r1, r0, 28 - lsrs r0, r1, 28 - mov r8, r0 - cmp r0, 0 - bne _0808E258 - ldrh r0, [r5, 0x2] - lsrs r1, 28 - bl npc_load_two_palettes__no_record - b _0808E27E - .pool -_0808E258: - mov r2, r8 - cmp r2, 0xA - bne _0808E268 - ldrh r0, [r5, 0x2] - lsrs r1, 28 - bl npc_load_two_palettes__and_record - b _0808E27E -_0808E268: - mov r0, r8 - cmp r0, 0xF - bls _0808E27E - subs r0, 0x10 - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - ldrh r0, [r5, 0x2] - mov r1, r8 - bl sub_808EAB0 -_0808E27E: - mov r1, sp - ldr r2, =0x0000ffff - adds r0, r2, 0 - strh r0, [r1, 0x2] - mov r0, sp - movs r1, 0 - movs r2, 0 - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r7, r0, 24 - cmp r7, 0x40 - beq _0808E374 - lsls r0, r7, 4 - adds r0, r7 - lsls r0, 2 - ldr r1, =gSprites - adds r4, r0, r1 - mov r1, r10 - lsls r0, r1, 16 - asrs r0, 16 - ldrh r2, [r6, 0x10] - adds r0, r2 - lsls r0, 16 - asrs r0, 16 - ldr r2, [sp, 0x24] - lsls r1, r2, 16 - asrs r1, 16 - ldrh r2, [r6, 0x12] - adds r1, r2 - lsls r1, 16 - asrs r1, 16 - adds r2, r4, 0 - adds r2, 0x20 - adds r3, r4, 0 - adds r3, 0x22 - bl sub_8092FF0 - ldrh r0, [r5, 0x8] - lsls r0, 16 - asrs r0, 17 - negs r0, r0 - adds r1, r4, 0 - adds r1, 0x28 - strb r0, [r1] - ldrh r0, [r5, 0xA] - lsls r0, 16 - asrs r0, 17 - negs r0, r0 - adds r2, r4, 0 - adds r2, 0x29 - strb r0, [r2] - ldrh r0, [r4, 0x20] - adds r0, 0x8 - strh r0, [r4, 0x20] - ldrh r1, [r4, 0x22] - adds r1, 0x10 - movs r0, 0 - ldrsb r0, [r2, r0] - adds r0, r1 - strh r0, [r4, 0x22] - ldr r0, [r5, 0x1C] - str r0, [r4, 0xC] - ldrb r0, [r6, 0x6] - cmp r0, 0xB - bne _0808E312 - mov r0, r9 - adds r1, r7, 0 - bl SetPlayerAvatarFieldObjectIdAndObjectId - bl sub_8154228 - strb r0, [r6, 0x1B] -_0808E312: - ldr r1, [sp, 0x20] - cmp r1, 0 - beq _0808E31E - adds r0, r4, 0 - bl SetSubspriteTables -_0808E31E: - mov r0, r8 - lsls r2, r0, 4 - ldrb r1, [r4, 0x5] - movs r0, 0xF - ands r0, r1 - orrs r0, r2 - strb r0, [r4, 0x5] - adds r2, r4, 0 - adds r2, 0x3E - ldrb r0, [r2] - movs r1, 0x2 - orrs r0, r1 - strb r0, [r2] - mov r1, r9 - strh r1, [r4, 0x2E] - strb r7, [r6, 0x4] - ldrb r0, [r6, 0x1] - lsls r0, 27 - cmp r0, 0 - blt _0808E362 - ldrb r0, [r6, 0x6] - cmp r0, 0xB - beq _0808E362 - ldrb r0, [r6, 0x18] - lsls r0, 28 - lsrs r0, 28 - bl FieldObjectDirectionToImageAnimId - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 24 - adds r0, r4, 0 - bl StartSpriteAnim -_0808E362: - adds r0, r6, 0 - bl sub_808E38C - ldrb r0, [r6, 0xB] - lsrs r0, 4 - adds r1, r4, 0 - movs r2, 0x1 - bl SetObjectSubpriorityByZCoord -_0808E374: - add sp, 0x28 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_808E1B8 - thumb_func_start sub_808E38C @ void sub_808E38C(struct npc_state *fieldObject) sub_808E38C: @ 808E38C diff --git a/include/field_effect_helpers.h b/include/field_effect_helpers.h new file mode 100644 index 000000000..673d59139 --- /dev/null +++ b/include/field_effect_helpers.h @@ -0,0 +1,15 @@ +// +// Created by scott on 9/7/2017. +// + +#ifndef POKEEMERALD_FIELD_EFFECT_HELPERS_H +#define POKEEMERALD_FIELD_EFFECT_HELPERS_H + +// Exported type declarations + +// Exported RAM declarations + +// Exported ROM declarations +u8 sub_8154228(void); + +#endif //POKEEMERALD_FIELD_EFFECT_HELPERS_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 3e3f22a45..69aa2b8f8 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -10,6 +10,7 @@ #include "rom_81BE66C.h" #include "field_ground_effect.h" #include "map_obj_8097404.h" +#include "field_effect_helpers.h" #include "field_map_obj.h" #define NUM_FIELD_MAP_OBJECT_TEMPLATES 0x51 @@ -33,8 +34,10 @@ void sub_8096518(struct MapObject *, struct Sprite *); /*static*/ void GetFieldObjectMovingCameraOffset(s16 *, s16 *); /*static*/ struct MapObjectTemplate *GetFieldObjectTemplateByLocalIdAndMap(u8, u8, u8); /*static*/ void sub_808E894(u16); -/*static*/ void RemoveFieldObjectIfOutsideView(struct MapObject *mapObject); -/*static*/ void sub_808E1B8(u8, s16, s16); +/*static*/ void RemoveFieldObjectIfOutsideView(struct MapObject *); +static void sub_808E1B8(u8, s16, s16); +/*static*/ void SetPlayerAvatarFieldObjectIdAndObjectId(u8, u8); +/*static*/ void sub_808E38C(struct MapObject *); // ROM data @@ -801,3 +804,78 @@ void sub_808E16C(s16 x, s16 y) } sub_808D450(); } + +static void sub_808E1B8(u8 mapObjectId, s16 x, s16 y) +{ + u8 spriteId; + u8 paletteSlot; + struct MapObject *mapObject; + const struct SubspriteTable *subspriteTables; + const struct MapObjectGraphicsInfo *graphicsInfo; + struct SpriteFrameImage spriteFrameImage; + struct SpriteTemplate spriteTemplate; + struct Sprite *sprite; + +#define i spriteId + for (i = 0; i < ARRAY_COUNT(gLinkPlayerMapObjects); i ++) + { + if (gLinkPlayerMapObjects[i].active && mapObjectId == gLinkPlayerMapObjects[i].mapObjId) + { + return; + } + } +#undef i + + mapObject = &gMapObjects[mapObjectId]; + subspriteTables = NULL; + graphicsInfo = GetFieldObjectGraphicsInfo(mapObject->graphicsId); + spriteFrameImage.size = graphicsInfo->size; + MakeObjectTemplateFromFieldObjectGraphicsInfoWithCallbackIndex(mapObject->graphicsId, mapObject->animPattern, &spriteTemplate, &subspriteTables); + spriteTemplate.images = &spriteFrameImage; + *(u16 *)&spriteTemplate.paletteTag = 0xffff; + paletteSlot = graphicsInfo->paletteSlot; + if (paletteSlot == 0) + { + npc_load_two_palettes__no_record(graphicsInfo->paletteTag1, graphicsInfo->paletteSlot); + } + else if (paletteSlot == 10) + { + npc_load_two_palettes__and_record(graphicsInfo->paletteTag1, graphicsInfo->paletteSlot); + } + else if (paletteSlot >= 16) + { + paletteSlot -= 16; + sub_808EAB0(graphicsInfo->paletteTag1, paletteSlot); + } + *(u16 *)&spriteTemplate.paletteTag = 0xffff; + spriteId = CreateSprite(&spriteTemplate, 0, 0, 0); + if (spriteId != MAX_SPRITES) + { + sprite = &gSprites[spriteId]; + sub_8092FF0(x + mapObject->coords2.x, y + mapObject->coords2.y, &sprite->pos1.x, &sprite->pos1.y); + sprite->centerToCornerVecX = -(graphicsInfo->width >> 1); + sprite->centerToCornerVecY = -(graphicsInfo->height >> 1); + sprite->pos1.x += 8; + sprite->pos1.y += 16 + sprite->centerToCornerVecY; + sprite->images = graphicsInfo->images; + if (mapObject->animPattern == 0x0b) + { + SetPlayerAvatarFieldObjectIdAndObjectId(mapObjectId, spriteId); + mapObject->mapobj_unk_1B = sub_8154228(); + } + if (subspriteTables != NULL) + { + SetSubspriteTables(sprite, subspriteTables); + } + sprite->oam.paletteNum = paletteSlot; + sprite->coordOffsetEnabled = TRUE; + sprite->data0 = mapObjectId; + mapObject->spriteId = spriteId; + if (!mapObject->mapobj_bit_12 && mapObject->animPattern != 0x0b) + { + StartSpriteAnim(sprite, FieldObjectDirectionToImageAnimId(mapObject->mapobj_unk_18)); + } + sub_808E38C(mapObject); + SetObjectSubpriorityByZCoord(mapObject->elevation, sprite, 1); + } +} From 11786cc325937ce4c0a37b3db40df26dcd785018 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 7 Sep 2017 19:45:30 -0400 Subject: [PATCH 030/191] sub_808E38C --- asm/field_map_obj.s | 32 -------------------------------- include/field_map_obj.h | 10 ++++++++-- src/field_map_obj.c | 41 +++++++++++++++++++++++++++-------------- 3 files changed, 35 insertions(+), 48 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index aeca020ab..299893a29 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,38 +5,6 @@ .text - thumb_func_start sub_808E38C -@ void sub_808E38C(struct npc_state *fieldObject) -sub_808E38C: @ 808E38C - push {lr} - ldrb r2, [r0] - movs r3, 0x3 - negs r3, r3 - adds r1, r3, 0 - ands r1, r2 - movs r2, 0x4 - orrs r1, r2 - strb r1, [r0] - ldrb r2, [r0, 0x2] - movs r1, 0x41 - negs r1, r1 - ands r1, r2 - ands r1, r3 - movs r2, 0x5 - negs r2, r2 - ands r1, r2 - subs r2, 0x4 - ands r1, r2 - subs r2, 0x8 - ands r1, r2 - subs r2, 0x10 - ands r1, r2 - strb r1, [r0, 0x2] - bl FieldObjectClearAnim - pop {r0} - bx r0 - thumb_func_end sub_808E38C - thumb_func_start SetPlayerAvatarFieldObjectIdAndObjectId @ void SetPlayerAvatarFieldObjectIdAndObjectId(u8 fieldObjectId, u8 objectId) SetPlayerAvatarFieldObjectIdAndObjectId: @ 808E3C4 diff --git a/include/field_map_obj.h b/include/field_map_obj.h index 40f94ccab..3e7bdf932 100644 --- a/include/field_map_obj.h +++ b/include/field_map_obj.h @@ -14,16 +14,22 @@ u8 GetFieldObjectIdByLocalIdAndMap(u8, u8, u8); bool8 TryGetFieldObjectIdByLocalIdAndMap(u8, u8, u8, u8 *); u8 GetFieldObjectIdByXY(s16, s16); void FieldObjectSetDirection(struct MapObject *, u8); -u8 GetFieldObjectIdByXY(s16, s16); u8 sub_808D4F4(void); -void RemoveFieldObject(struct MapObject *); void RemoveFieldObjectByLocalIdAndMap(u8, u8, u8); void npc_load_two_palettes__no_record(u16, u8); void npc_load_two_palettes__and_record(u16, u8); +void sub_808E16C(s16, s16); void sub_808EAB0(u16, u8); void sub_8092FF0(s16, s16, s16 *, s16 *); u8 FieldObjectDirectionToImageAnimId(u8); void sub_80930E0(s16 *, s16 *, u8, u8); +void FieldObjectClearAnim(struct MapObject *); +void SpawnFieldObjectsInView(s16, s16); +u8 sprite_new(u8, u8, s16, s16, u8, u8); +u8 AddPseudoFieldObject(u16, void (*)(struct Sprite *), s16, s16, u8); +u8 show_sprite(u8, u8, u8); +u8 SpawnSpecialFieldObjectParametrized(u8, u8, u8, s16, s16, u8); +u8 SpawnSpecialFieldObject(struct MapObjectTemplate *); // Exported data declarations diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 69aa2b8f8..469993068 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -21,7 +21,7 @@ // Static ROM declarations -void sub_808D450(void); +static void sub_808D450(void); static u8 GetFieldObjectIdByLocalId(u8); static u8 GetFieldObjectIdByLocalIdAndMapInternal(u8, u8, u8); static bool8 GetAvailableFieldObjectSlot(u16, u8, u8, u8 *); @@ -30,11 +30,11 @@ static void RemoveFieldObjectInternal (struct MapObject *); /*static*/ u16 GetFieldObjectFlagIdByFieldObjectId(u8); /*static*/ const struct MapObjectGraphicsInfo *GetFieldObjectGraphicsInfo(u8); void sub_8096518(struct MapObject *, struct Sprite *); -/*static*/ void MakeObjectTemplateFromFieldObjectTemplate(struct MapObjectTemplate *, struct SpriteTemplate *, const struct SubspriteTable **); +static void MakeObjectTemplateFromFieldObjectTemplate(struct MapObjectTemplate *, struct SpriteTemplate *, const struct SubspriteTable **); /*static*/ void GetFieldObjectMovingCameraOffset(s16 *, s16 *); /*static*/ struct MapObjectTemplate *GetFieldObjectTemplateByLocalIdAndMap(u8, u8, u8); /*static*/ void sub_808E894(u16); -/*static*/ void RemoveFieldObjectIfOutsideView(struct MapObject *); +static void RemoveFieldObjectIfOutsideView(struct MapObject *); static void sub_808E1B8(u8, s16, s16); /*static*/ void SetPlayerAvatarFieldObjectIdAndObjectId(u8, u8); /*static*/ void sub_808E38C(struct MapObject *); @@ -74,7 +74,7 @@ void sub_808D438(void) sub_808D450(); } -/*static*/ void sub_808D450(void) +static void sub_808D450(void) { u8 spriteIdx; @@ -168,7 +168,7 @@ static u8 GetFieldObjectIdByLocalId(u8 localId) // This function has the same nonmatching quirk as in Ruby/Sapphire. #ifdef NONMATCHING -/*static*/ u8 InitFieldObjectStateFromTemplate(struct MapObjectTemplate *template, u8 mapId, u8 mapGroupId) +static u8 InitFieldObjectStateFromTemplate(struct MapObjectTemplate *template, u8 mapId, u8 mapGroupId) { u8 slot; struct MapObject *mapObject; @@ -219,7 +219,7 @@ static u8 GetFieldObjectIdByLocalId(u8 localId) return slot; } #else -/*static*/ __attribute__((naked)) u8 InitFieldObjectStateFromTemplate(struct MapObjectTemplate *template, u8 mapId, u8 mapGroupId) +static __attribute__((naked)) u8 InitFieldObjectStateFromTemplate(struct MapObjectTemplate *template, u8 mapId, u8 mapGroupId) { asm_unified("\tpush {r4-r7,lr}\n" "\tmov r7, r9\n" @@ -435,7 +435,7 @@ static bool8 GetAvailableFieldObjectSlot(u16 localId, u8 mapNum, u8 mapGroup, u8 return FALSE; } -void RemoveFieldObject(struct MapObject *mapObject) +static void RemoveFieldObject(struct MapObject *mapObject) { mapObject->active = FALSE; RemoveFieldObjectInternal(mapObject); @@ -472,7 +472,7 @@ void unref_sub_808D958(void) } } -u8 SpawnFieldObjectInternal(struct MapObjectTemplate *mapObjectTemplate, struct SpriteTemplate *spriteTemplate, u8 mapNum, u8 mapGroup, s16 cameraX, s16 cameraY) +static u8 SpawnFieldObjectInternal(struct MapObjectTemplate *mapObjectTemplate, struct SpriteTemplate *spriteTemplate, u8 mapNum, u8 mapGroup, s16 cameraX, s16 cameraY) { struct MapObject *mapObject; const struct MapObjectGraphicsInfo *graphicsInfo; @@ -533,7 +533,7 @@ u8 SpawnFieldObjectInternal(struct MapObjectTemplate *mapObjectTemplate, struct return mapObjectId; } -u8 SpawnFieldObject(struct MapObjectTemplate *mapObjectTemplate, u8 mapNum, u8 mapGroup, s16 cameraX, s16 cameraY) +static u8 SpawnFieldObject(struct MapObjectTemplate *mapObjectTemplate, u8 mapNum, u8 mapGroup, s16 cameraX, s16 cameraY) { const struct MapObjectGraphicsInfo *graphicsInfo; struct SpriteTemplate spriteTemplate; @@ -603,7 +603,7 @@ u8 show_sprite(u8 localId, u8 mapNum, u8 mapGroup) return SpawnFieldObject(mapObjectTemplate, mapNum, mapGroup, cameraX, cameraY); } -void MakeObjectTemplateFromFieldObjectGraphicsInfo(u16 graphicsId, void (*callback)(struct Sprite *), struct SpriteTemplate *sprTemplate, const struct SubspriteTable **subspriteTables) +static void MakeObjectTemplateFromFieldObjectGraphicsInfo(u16 graphicsId, void (*callback)(struct Sprite *), struct SpriteTemplate *sprTemplate, const struct SubspriteTable **subspriteTables) { const struct MapObjectGraphicsInfo *gfxInfo = GetFieldObjectGraphicsInfo(graphicsId); @@ -617,12 +617,12 @@ void MakeObjectTemplateFromFieldObjectGraphicsInfo(u16 graphicsId, void (*callba *subspriteTables = gfxInfo->subspriteTables; } -void MakeObjectTemplateFromFieldObjectGraphicsInfoWithCallbackIndex(u16 graphicsId, u16 callbackIndex, struct SpriteTemplate *sprTemplate, const struct SubspriteTable **subspriteTables) +static void MakeObjectTemplateFromFieldObjectGraphicsInfoWithCallbackIndex(u16 graphicsId, u16 callbackIndex, struct SpriteTemplate *sprTemplate, const struct SubspriteTable **subspriteTables) { MakeObjectTemplateFromFieldObjectGraphicsInfo(graphicsId, gUnknown_08505438[callbackIndex], sprTemplate, subspriteTables); } -void MakeObjectTemplateFromFieldObjectTemplate(struct MapObjectTemplate *mapObjectTemplate, struct SpriteTemplate *spriteTemplate, const struct SubspriteTable **subspriteTables) +static void MakeObjectTemplateFromFieldObjectTemplate(struct MapObjectTemplate *mapObjectTemplate, struct SpriteTemplate *spriteTemplate, const struct SubspriteTable **subspriteTables) { MakeObjectTemplateFromFieldObjectGraphicsInfoWithCallbackIndex(mapObjectTemplate->graphicsId, mapObjectTemplate->movementType, spriteTemplate, subspriteTables); } @@ -745,7 +745,7 @@ void SpawnFieldObjectsInView(s16 cameraX, s16 cameraY) } } -void RemoveFieldObjectsOutsideView(void) +/*static*/ void RemoveFieldObjectsOutsideView(void) { u8 i; u8 j; @@ -769,7 +769,7 @@ void RemoveFieldObjectsOutsideView(void) } } -void RemoveFieldObjectIfOutsideView(struct MapObject *mapObject) +static void RemoveFieldObjectIfOutsideView(struct MapObject *mapObject) { s16 left; s16 right; @@ -879,3 +879,16 @@ static void sub_808E1B8(u8 mapObjectId, s16 x, s16 y) SetObjectSubpriorityByZCoord(mapObject->elevation, sprite, 1); } } + +/*static*/ void sub_808E38C(struct MapObject *mapObject) +{ + mapObject->mapobj_bit_1 = FALSE; + mapObject->mapobj_bit_2 = TRUE; + mapObject->mapobj_bit_22 = FALSE; + mapObject->mapobj_bit_17 = FALSE; + mapObject->mapobj_bit_18 = FALSE; + mapObject->mapobj_bit_19 = FALSE; + mapObject->mapobj_bit_20 = FALSE; + mapObject->mapobj_bit_21 = FALSE; + FieldObjectClearAnim(mapObject); +} From f8e8adf82ec56e986ece7a5eb6de87977ce2f506 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 7 Sep 2017 20:04:59 -0400 Subject: [PATCH 031/191] SetPlayerAvatarFieldObjectIdAndObjectId --- asm/field_map_obj.s | 26 -------------------------- include/field_player_avatar.h | 2 ++ src/field_map_obj.c | 12 +++++++++++- 3 files changed, 13 insertions(+), 27 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 299893a29..a560fb8f7 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,32 +5,6 @@ .text - thumb_func_start SetPlayerAvatarFieldObjectIdAndObjectId -@ void SetPlayerAvatarFieldObjectIdAndObjectId(u8 fieldObjectId, u8 objectId) -SetPlayerAvatarFieldObjectIdAndObjectId: @ 808E3C4 - push {r4,r5,lr} - lsls r0, 24 - lsrs r0, 24 - ldr r5, =gPlayerAvatar - strb r0, [r5, 0x5] - strb r1, [r5, 0x4] - ldr r1, =gMapObjects - lsls r4, r0, 3 - adds r4, r0 - lsls r4, 2 - adds r4, r1 - ldrb r0, [r4, 0x5] - bl GetPlayerAvatarGenderByGraphicsId - strb r0, [r5, 0x7] - ldrb r0, [r4, 0x5] - movs r1, 0x20 - bl SetPlayerAvatarExtraStateTransition - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end SetPlayerAvatarFieldObjectIdAndObjectId - thumb_func_start FieldObjectSetGraphicsId @ void FieldObjectSetGraphicsId(npc_state *npcState, u8 graphicsId) FieldObjectSetGraphicsId: @ 808E3F8 diff --git a/include/field_player_avatar.h b/include/field_player_avatar.h index 8438add26..5e2f0822c 100644 --- a/include/field_player_avatar.h +++ b/include/field_player_avatar.h @@ -6,5 +6,7 @@ #define POKEEMERALD_FIELD_PLAYER_AVATAR_H void ClearPlayerAvatarInfo(void); +void SetPlayerAvatarExtraStateTransition(u8, u8); +u8 GetPlayerAvatarGenderByGraphicsId(u8); #endif //POKEEMERALD_FIELD_PLAYER_AVATAR_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 469993068..53dd1a863 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -36,7 +36,7 @@ static void MakeObjectTemplateFromFieldObjectTemplate(struct MapObjectTemplate * /*static*/ void sub_808E894(u16); static void RemoveFieldObjectIfOutsideView(struct MapObject *); static void sub_808E1B8(u8, s16, s16); -/*static*/ void SetPlayerAvatarFieldObjectIdAndObjectId(u8, u8); +static void SetPlayerAvatarFieldObjectIdAndObjectId(u8, u8); /*static*/ void sub_808E38C(struct MapObject *); // ROM data @@ -205,6 +205,8 @@ static u8 InitFieldObjectStateFromTemplate(struct MapObjectTemplate *template, u mapObject->mapobj_unk_20 = gUnknown_085055CD[template->movementType]; FieldObjectSetDirection(mapObject, mapObject->mapobj_unk_20); FieldObjectHandleDynamicGraphicsId(mapObject); + + // This block is the culprit if (gUnknown_0850557C[mapObject->animPattern]) { if (mapObject->mapobj_unk_19 == 0) @@ -892,3 +894,11 @@ static void sub_808E1B8(u8 mapObjectId, s16 x, s16 y) mapObject->mapobj_bit_21 = FALSE; FieldObjectClearAnim(mapObject); } + +static void SetPlayerAvatarFieldObjectIdAndObjectId(u8 mapObjectId, u8 spriteId) +{ + gPlayerAvatar.mapObjectId = mapObjectId; + gPlayerAvatar.spriteId = spriteId; + gPlayerAvatar.gender = GetPlayerAvatarGenderByGraphicsId(gMapObjects[mapObjectId].graphicsId); + SetPlayerAvatarExtraStateTransition(gMapObjects[mapObjectId].graphicsId, 0x20); +} From a87b35f9a73c09994bbe389fc73299b185db1fac Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 7 Sep 2017 21:04:32 -0400 Subject: [PATCH 032/191] FieldObjectSetGraphicsId --- asm/field_map_obj.s | 134 ---------------------------------------- include/field_map_obj.h | 3 + src/field_map_obj.c | 41 ++++++++++++ 3 files changed, 44 insertions(+), 134 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index a560fb8f7..4bd603c83 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,140 +5,6 @@ .text - thumb_func_start FieldObjectSetGraphicsId -@ void FieldObjectSetGraphicsId(npc_state *npcState, u8 graphicsId) -FieldObjectSetGraphicsId: @ 808E3F8 - push {r4-r7,lr} - mov r7, r8 - push {r7} - adds r7, r0, 0 - lsls r1, 24 - lsrs r1, 24 - mov r8, r1 - mov r0, r8 - bl GetFieldObjectGraphicsInfo - adds r6, r0, 0 - ldrb r1, [r7, 0x4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r1, =gSprites - adds r4, r0, r1 - ldrb r0, [r6, 0xC] - lsls r1, r0, 28 - lsrs r5, r1, 28 - cmp r5, 0 - bne _0808E434 - ldrh r0, [r6, 0x2] - adds r1, r5, 0 - bl pal_patch_for_npc - b _0808E456 - .pool -_0808E434: - cmp r5, 0xA - bne _0808E442 - ldrh r0, [r6, 0x2] - lsrs r1, 28 - bl npc_load_two_palettes__and_record - b _0808E456 -_0808E442: - cmp r5, 0xF - bls _0808E456 - adds r0, r5, 0 - subs r0, 0x10 - lsls r0, 24 - lsrs r5, r0, 24 - ldrh r0, [r6, 0x2] - adds r1, r5, 0 - bl sub_808EAB0 -_0808E456: - ldr r0, [r6, 0x10] - ldrb r2, [r0, 0x1] - lsrs r2, 6 - lsls r2, 6 - ldrb r3, [r4, 0x1] - movs r1, 0x3F - adds r0, r1, 0 - ands r0, r3 - orrs r0, r2 - strb r0, [r4, 0x1] - ldr r0, [r6, 0x10] - ldrb r0, [r0, 0x3] - lsrs r0, 6 - lsls r0, 6 - ldrb r2, [r4, 0x3] - ands r1, r2 - orrs r1, r0 - strb r1, [r4, 0x3] - ldr r0, [r6, 0x1C] - str r0, [r4, 0xC] - ldr r0, [r6, 0x18] - str r0, [r4, 0x8] - ldr r0, [r6, 0x14] - str r0, [r4, 0x18] - lsls r2, r5, 4 - ldrb r1, [r4, 0x5] - movs r0, 0xF - ands r0, r1 - orrs r0, r2 - strb r0, [r4, 0x5] - ldrb r1, [r6, 0xC] - lsls r1, 25 - lsrs r1, 31 - lsls r1, 4 - ldrb r2, [r7, 0x1] - movs r0, 0x11 - negs r0, r0 - ands r0, r2 - orrs r0, r1 - strb r0, [r7, 0x1] - mov r0, r8 - strb r0, [r7, 0x5] - movs r1, 0x10 - ldrsh r0, [r7, r1] - movs r2, 0x12 - ldrsh r1, [r7, r2] - adds r2, r4, 0 - adds r2, 0x20 - adds r3, r4, 0 - adds r3, 0x22 - bl sub_8093038 - ldrh r0, [r6, 0x8] - lsls r0, 16 - asrs r0, 17 - negs r0, r0 - adds r1, r4, 0 - adds r1, 0x28 - strb r0, [r1] - ldrh r0, [r6, 0xA] - lsls r0, 16 - asrs r0, 17 - negs r0, r0 - adds r2, r4, 0 - adds r2, 0x29 - strb r0, [r2] - ldrh r0, [r4, 0x20] - adds r0, 0x8 - strh r0, [r4, 0x20] - ldrh r1, [r4, 0x22] - adds r1, 0x10 - movs r0, 0 - ldrsb r0, [r2, r0] - adds r0, r1 - strh r0, [r4, 0x22] - ldrb r0, [r7, 0x1] - lsrs r0, 7 - cmp r0, 0 - beq _0808E4F8 - bl CameraObjectReset1 -_0808E4F8: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end FieldObjectSetGraphicsId - thumb_func_start sub_808E504 sub_808E504: @ 808E504 push {r4,lr} diff --git a/include/field_map_obj.h b/include/field_map_obj.h index 3e7bdf932..14845b6d9 100644 --- a/include/field_map_obj.h +++ b/include/field_map_obj.h @@ -18,6 +18,7 @@ u8 sub_808D4F4(void); void RemoveFieldObjectByLocalIdAndMap(u8, u8, u8); void npc_load_two_palettes__no_record(u16, u8); void npc_load_two_palettes__and_record(u16, u8); +void pal_patch_for_npc(u16, u8); void sub_808E16C(s16, s16); void sub_808EAB0(u16, u8); void sub_8092FF0(s16, s16, s16 *, s16 *); @@ -30,6 +31,8 @@ u8 AddPseudoFieldObject(u16, void (*)(struct Sprite *), s16, s16, u8); u8 show_sprite(u8, u8, u8); u8 SpawnSpecialFieldObjectParametrized(u8, u8, u8, s16, s16, u8); u8 SpawnSpecialFieldObject(struct MapObjectTemplate *); +void sub_8093038(s16, s16, s16 *, s16 *); +void CameraObjectReset1(void); // Exported data declarations diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 53dd1a863..bbdaaf6ec 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -902,3 +902,44 @@ static void SetPlayerAvatarFieldObjectIdAndObjectId(u8 mapObjectId, u8 spriteId) gPlayerAvatar.gender = GetPlayerAvatarGenderByGraphicsId(gMapObjects[mapObjectId].graphicsId); SetPlayerAvatarExtraStateTransition(gMapObjects[mapObjectId].graphicsId, 0x20); } + +void FieldObjectSetGraphicsId(struct MapObject *mapObject, u8 graphicsId) +{ + const struct MapObjectGraphicsInfo *graphicsInfo; + struct Sprite *sprite; + u8 paletteSlot; + + graphicsInfo = GetFieldObjectGraphicsInfo(graphicsId); + sprite = &gSprites[mapObject->spriteId]; + paletteSlot = graphicsInfo->paletteSlot; + if (paletteSlot == 0) + { + pal_patch_for_npc(graphicsInfo->paletteTag1, graphicsInfo->paletteSlot); + } + else if (paletteSlot == 10) + { + npc_load_two_palettes__and_record(graphicsInfo->paletteTag1, graphicsInfo->paletteSlot); + } + else if (paletteSlot >= 16) + { + paletteSlot -= 16; + sub_808EAB0(graphicsInfo->paletteTag1, paletteSlot); + } + sprite->oam.shape = graphicsInfo->oam->shape; + sprite->oam.size = graphicsInfo->oam->size; + sprite->images = graphicsInfo->images; + sprite->anims = graphicsInfo->anims; + sprite->subspriteTables = graphicsInfo->subspriteTables; + sprite->oam.paletteNum = paletteSlot; + mapObject->mapobj_bit_12 = graphicsInfo->inanimate; + mapObject->graphicsId = graphicsId; + sub_8093038(mapObject->coords2.x, mapObject->coords2.y, &sprite->pos1.x, &sprite->pos1.y); + sprite->centerToCornerVecX = -(graphicsInfo->width >> 1); + sprite->centerToCornerVecY = -(graphicsInfo->height >> 1); + sprite->pos1.x += 8; + sprite->pos1.y += 16 + sprite->centerToCornerVecY; + if (mapObject->mapobj_bit_15) + { + CameraObjectReset1(); + } +} From ad99377734e1f982a347e33da60c82bf1120c2f3 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 7 Sep 2017 21:17:55 -0400 Subject: [PATCH 033/191] unref_sub_808E504 --- asm/field_map_obj.s | 34 ---------------------------------- include/field_map_obj.h | 1 + src/field_map_obj.c | 12 +++++++++++- 3 files changed, 12 insertions(+), 35 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 4bd603c83..798da2ae5 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,40 +5,6 @@ .text - thumb_func_start sub_808E504 -sub_808E504: @ 808E504 - push {r4,lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r0, 24 - lsls r1, 24 - lsrs r1, 24 - lsls r2, 24 - lsrs r2, 24 - lsls r3, 24 - lsrs r4, r3, 24 - mov r3, sp - bl TryGetFieldObjectIdByLocalIdAndMap - lsls r0, 24 - cmp r0, 0 - bne _0808E538 - mov r0, sp - ldrb r1, [r0] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, =gMapObjects - adds r0, r1 - adds r1, r4, 0 - bl FieldObjectSetGraphicsId -_0808E538: - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_808E504 - thumb_func_start FieldObjectTurn @ void FieldObjectTurn(struct npc_state *fieldObject, u8 direction) FieldObjectTurn: @ 808E544 diff --git a/include/field_map_obj.h b/include/field_map_obj.h index 14845b6d9..7b0905c93 100644 --- a/include/field_map_obj.h +++ b/include/field_map_obj.h @@ -33,6 +33,7 @@ u8 SpawnSpecialFieldObjectParametrized(u8, u8, u8, s16, s16, u8); u8 SpawnSpecialFieldObject(struct MapObjectTemplate *); void sub_8093038(s16, s16, s16 *, s16 *); void CameraObjectReset1(void); +void FieldObjectSetGraphicsId(struct MapObject *, u8); // Exported data declarations diff --git a/src/field_map_obj.c b/src/field_map_obj.c index bbdaaf6ec..b85432e69 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -782,7 +782,7 @@ static void RemoveFieldObjectIfOutsideView(struct MapObject *mapObject) right = gSaveBlock1Ptr->pos.x + 17; top = gSaveBlock1Ptr->pos.y; bottom = gSaveBlock1Ptr->pos.y + 16; - + if (mapObject->coords2.x >= left && mapObject->coords2.x <= right && mapObject->coords2.y >= top && mapObject->coords2.y <= bottom) return; @@ -943,3 +943,13 @@ void FieldObjectSetGraphicsId(struct MapObject *mapObject, u8 graphicsId) CameraObjectReset1(); } } + +void unref_sub_808E504(u8 localId, u8 mapNum, u8 mapGroup, u8 graphicsId) +{ + u8 mapObjectId; + + if (!TryGetFieldObjectIdByLocalIdAndMap(localId, mapNum, mapGroup, &mapObjectId)) + { + FieldObjectSetGraphicsId(&gMapObjects[mapObjectId], graphicsId); + } +} From ddcce8c3bc831023894191ceac058b8f2fe31ced Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Fri, 8 Sep 2017 13:41:55 -0400 Subject: [PATCH 034/191] FieldObjectTurn --- asm/field_map_obj.s | 76 ----------------------------------------- include/field_map_obj.h | 2 ++ src/field_map_obj.c | 22 +++++++++++- 3 files changed, 23 insertions(+), 77 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 798da2ae5..e4e4850dc 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,82 +5,6 @@ .text - thumb_func_start FieldObjectTurn -@ void FieldObjectTurn(struct npc_state *fieldObject, u8 direction) -FieldObjectTurn: @ 808E544 - push {r4-r6,lr} - adds r6, r0, 0 - lsls r1, 24 - lsrs r1, 24 - bl FieldObjectSetDirection - ldrb r0, [r6, 0x1] - lsls r0, 27 - cmp r0, 0 - blt _0808E58A - ldrb r0, [r6, 0x4] - lsls r4, r0, 4 - adds r4, r0 - lsls r4, 2 - ldr r5, =gSprites - adds r4, r5 - ldrb r0, [r6, 0x18] - lsls r0, 28 - lsrs r0, 28 - bl FieldObjectDirectionToImageAnimId - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 24 - adds r0, r4, 0 - bl StartSpriteAnim - ldrb r1, [r6, 0x4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - movs r1, 0 - bl SeekSpriteAnim -_0808E58A: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectTurn - - thumb_func_start FieldObjectTurnByLocalIdAndMap -@ void FieldObjectTurnByLocalIdAndMap(u8 localId, u8 mapId, u8 mapGroupId) -FieldObjectTurnByLocalIdAndMap: @ 808E594 - push {r4,lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r0, 24 - lsls r1, 24 - lsrs r1, 24 - lsls r2, 24 - lsrs r2, 24 - lsls r3, 24 - lsrs r4, r3, 24 - mov r3, sp - bl TryGetFieldObjectIdByLocalIdAndMap - lsls r0, 24 - cmp r0, 0 - bne _0808E5C8 - mov r0, sp - ldrb r1, [r0] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, =gMapObjects - adds r0, r1 - adds r1, r4, 0 - bl FieldObjectTurn -_0808E5C8: - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectTurnByLocalIdAndMap - thumb_func_start sub_808E5D4 sub_808E5D4: @ 808E5D4 push {lr} diff --git a/include/field_map_obj.h b/include/field_map_obj.h index 7b0905c93..34e8d4ac0 100644 --- a/include/field_map_obj.h +++ b/include/field_map_obj.h @@ -34,6 +34,8 @@ u8 SpawnSpecialFieldObject(struct MapObjectTemplate *); void sub_8093038(s16, s16, s16 *, s16 *); void CameraObjectReset1(void); void FieldObjectSetGraphicsId(struct MapObject *, u8); +void FieldObjectTurn(struct MapObject *, u8); +void FieldObjectTurnByLocalIdAndMap(u8, u8, u8); // Exported data declarations diff --git a/src/field_map_obj.c b/src/field_map_obj.c index b85432e69..55f1fd9fb 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -944,7 +944,7 @@ void FieldObjectSetGraphicsId(struct MapObject *mapObject, u8 graphicsId) } } -void unref_sub_808E504(u8 localId, u8 mapNum, u8 mapGroup, u8 graphicsId) +void FieldObjectSetGraphicsIdByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup, u8 graphicsId) { u8 mapObjectId; @@ -953,3 +953,23 @@ void unref_sub_808E504(u8 localId, u8 mapNum, u8 mapGroup, u8 graphicsId) FieldObjectSetGraphicsId(&gMapObjects[mapObjectId], graphicsId); } } + +void FieldObjectTurn(struct MapObject *mapObject, u8 direction) +{ + FieldObjectSetDirection(mapObject, direction); + if (!mapObject->mapobj_bit_12) + { + StartSpriteAnim(&gSprites[mapObject->spriteId], FieldObjectDirectionToImageAnimId(mapObject->mapobj_unk_18)); + SeekSpriteAnim(&gSprites[mapObject->spriteId], 0); + } +} + +void FieldObjectTurnByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup, u8 direction) +{ + u8 mapObjectId; + + if (!TryGetFieldObjectIdByLocalIdAndMap(localId, mapNum, mapGroup, &mapObjectId)) + { + FieldObjectTurn(&gMapObjects[mapObjectId], direction); + } +} From 9b98055ecc5174e92c1cf4bcad8f7a1ecc317581 Mon Sep 17 00:00:00 2001 From: scnorton Date: Fri, 8 Sep 2017 13:46:21 -0400 Subject: [PATCH 035/191] PlayerObjectTurn --- asm/field_map_obj.s | 17 ----------------- include/field_map_obj.h | 2 +- src/field_map_obj.c | 5 +++++ 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index e4e4850dc..18d5d3ed5 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,23 +5,6 @@ .text - thumb_func_start sub_808E5D4 -sub_808E5D4: @ 808E5D4 - push {lr} - lsls r1, 24 - lsrs r1, 24 - ldrb r2, [r0, 0x5] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - bl FieldObjectTurn - pop {r0} - bx r0 - .pool - thumb_func_end sub_808E5D4 - thumb_func_start get_berry_tree_graphics @ void get_berry_tree_graphics(npc_state *npcState, struct obj *obj) get_berry_tree_graphics: @ 808E5F4 diff --git a/include/field_map_obj.h b/include/field_map_obj.h index 34e8d4ac0..97c55f12a 100644 --- a/include/field_map_obj.h +++ b/include/field_map_obj.h @@ -35,7 +35,7 @@ void sub_8093038(s16, s16, s16 *, s16 *); void CameraObjectReset1(void); void FieldObjectSetGraphicsId(struct MapObject *, u8); void FieldObjectTurn(struct MapObject *, u8); -void FieldObjectTurnByLocalIdAndMap(u8, u8, u8); +void FieldObjectTurnByLocalIdAndMap(u8, u8, u8, u8); // Exported data declarations diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 55f1fd9fb..4d5efd1b9 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -973,3 +973,8 @@ void FieldObjectTurnByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup, u8 direc FieldObjectTurn(&gMapObjects[mapObjectId], direction); } } + +void PlayerObjectTurn(struct PlayerAvatar *playerAvatar, u8 direction) +{ + FieldObjectTurn(&gMapObjects[playerAvatar->mapObjectId], direction); +} From 823f8d6a0c827025f280e1d57fb71959ca529fbe Mon Sep 17 00:00:00 2001 From: scnorton Date: Fri, 8 Sep 2017 14:05:45 -0400 Subject: [PATCH 036/191] get_berry_tree_graphics --- asm/field_map_obj.s | 77 --------------------------------------------- include/berry.h | 17 ++++++++++ src/field_map_obj.c | 26 +++++++++++++++ 3 files changed, 43 insertions(+), 77 deletions(-) create mode 100644 include/berry.h diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 18d5d3ed5..4d2cd9f9c 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,83 +5,6 @@ .text - thumb_func_start get_berry_tree_graphics -@ void get_berry_tree_graphics(npc_state *npcState, struct obj *obj) -get_berry_tree_graphics: @ 808E5F4 - push {r4-r7,lr} - adds r5, r0, 0 - adds r7, r1, 0 - ldrb r0, [r5, 0x1] - movs r1, 0x20 - orrs r0, r1 - strb r0, [r5, 0x1] - adds r4, r7, 0 - adds r4, 0x3E - ldrb r0, [r4] - movs r1, 0x4 - orrs r0, r1 - strb r0, [r4] - ldrb r0, [r5, 0x1D] - bl GetStageByBerryTreeId - lsls r0, 24 - lsrs r6, r0, 24 - cmp r6, 0 - beq _0808E680 - ldrb r1, [r5, 0x1] - movs r0, 0x21 - negs r0, r0 - ands r0, r1 - strb r0, [r5, 0x1] - ldrb r1, [r4] - movs r0, 0x5 - negs r0, r0 - ands r0, r1 - strb r0, [r4] - ldrb r0, [r5, 0x1D] - bl GetBerryTypeByBerryTreeId - subs r0, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - subs r0, r6, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 - cmp r4, 0x2B - bls _0808E648 - movs r4, 0 -_0808E648: - ldr r0, =gBerryTreeFieldObjectGraphicsIdTablePointers - lsls r4, 2 - adds r0, r4, r0 - ldr r0, [r0] - adds r0, r6 - ldrb r1, [r0] - adds r0, r5, 0 - bl FieldObjectSetGraphicsId - ldr r0, =gBerryTreePicTablePointers - adds r0, r4, r0 - ldr r0, [r0] - str r0, [r7, 0xC] - ldr r0, =gBerryTreePaletteSlotTablePointers - adds r4, r0 - ldr r0, [r4] - adds r0, r6 - ldrb r1, [r0] - lsls r1, 4 - ldrb r2, [r7, 0x5] - movs r0, 0xF - ands r0, r2 - orrs r0, r1 - strb r0, [r7, 0x5] - adds r0, r7, 0 - adds r1, r6, 0 - bl StartSpriteAnim -_0808E680: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end get_berry_tree_graphics - thumb_func_start GetFieldObjectGraphicsInfo @ FieldObjectGraphicsInfo *GetFieldObjectGraphicsInfo(u8 graphicsId) GetFieldObjectGraphicsInfo: @ 808E694 diff --git a/include/berry.h b/include/berry.h new file mode 100644 index 000000000..6d8d8d483 --- /dev/null +++ b/include/berry.h @@ -0,0 +1,17 @@ +// +// Created by Scott Norton on 9/8/17. +// + +#ifndef POKEEMERALD_BERRY_H +#define POKEEMERALD_BERRY_H + +#define NUM_BERRIES 44 + +extern const u8 *const gBerryTreeFieldObjectGraphicsIdTablePointers[NUM_BERRIES]; +extern const struct SpriteFrameImage *const gBerryTreePicTablePointers[NUM_BERRIES]; +extern const u8 *const gBerryTreePaletteSlotTablePointers[NUM_BERRIES]; + +u8 GetStageByBerryTreeId(u8); +u8 GetBerryTypeByBerryTreeId(u8); + +#endif //POKEEMERALD_BERRY_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 4d5efd1b9..37ab01762 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -4,6 +4,7 @@ #include "malloc.h" #include "sprite.h" #include "rom4.h" +#include "berry.h" #include "field_player_avatar.h" #include "event_data.h" #include "rom_818CFC8.h" @@ -978,3 +979,28 @@ void PlayerObjectTurn(struct PlayerAvatar *playerAvatar, u8 direction) { FieldObjectTurn(&gMapObjects[playerAvatar->mapObjectId], direction); } + +void get_berry_tree_graphics(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 berryStage; + u8 berryId; + + mapObject->mapobj_bit_13 = TRUE; + sprite->invisible = TRUE; + berryStage = GetStageByBerryTreeId(mapObject->trainerRange_berryTreeId); + if (berryStage != 0) + { + mapObject->mapobj_bit_13 = FALSE; + sprite->invisible = FALSE; + berryId = GetBerryTypeByBerryTreeId(mapObject->trainerRange_berryTreeId) - 1; + berryStage -= 1; + if (berryId >= NUM_BERRIES) + { + berryId = 0; + } + FieldObjectSetGraphicsId(mapObject, gBerryTreeFieldObjectGraphicsIdTablePointers[berryId][berryStage]); + sprite->images = gBerryTreePicTablePointers[berryId]; + sprite->oam.paletteNum = gBerryTreePaletteSlotTablePointers[berryId][berryStage]; + StartSpriteAnim(sprite, berryStage); + } +} From e0b2e6cdbf0ff124a8e6a83f580418a06cee9df7 Mon Sep 17 00:00:00 2001 From: scnorton Date: Fri, 8 Sep 2017 14:16:44 -0400 Subject: [PATCH 037/191] GetFieldObjectGraphicsInfo --- asm/field_map_obj.s | 40 -------------------------------------- include/field_map_obj.h | 5 +++-- include/mauville_old_man.h | 10 ++++++++++ src/field_map_obj.c | 25 +++++++++++++++++++++++- 4 files changed, 37 insertions(+), 43 deletions(-) create mode 100644 include/mauville_old_man.h diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 4d2cd9f9c..8179cb0ec 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,46 +5,6 @@ .text - thumb_func_start GetFieldObjectGraphicsInfo -@ FieldObjectGraphicsInfo *GetFieldObjectGraphicsInfo(u8 graphicsId) -GetFieldObjectGraphicsInfo: @ 808E694 - push {lr} - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0xEF - bls _0808E6AC - adds r0, r1, 0 - adds r0, 0x10 - lsls r0, 24 - lsrs r0, 24 - bl VarGetFieldObjectGraphicsId - adds r1, r0, 0 -_0808E6AC: - cmp r1, 0x45 - bne _0808E6C4 - bl sub_81201C8 - lsls r0, 24 - ldr r1, =gMauvilleOldManGraphicsInfoPointers - lsrs r0, 22 - adds r0, r1 - ldr r0, [r0] - b _0808E6D2 - .pool -_0808E6C4: - cmp r1, 0xEE - bls _0808E6CA - movs r1, 0x5 -_0808E6CA: - ldr r0, =gFieldObjectGraphicsInfoPointers - lsls r1, 2 - adds r1, r0 - ldr r0, [r1] -_0808E6D2: - pop {r1} - bx r1 - .pool - thumb_func_end GetFieldObjectGraphicsInfo - thumb_func_start FieldObjectHandleDynamicGraphicsId @ void FieldObjectHandleDynamicGraphicsId(struct npc_state *fieldObject) FieldObjectHandleDynamicGraphicsId: @ 808E6DC diff --git a/include/field_map_obj.h b/include/field_map_obj.h index 97c55f12a..5eaee20d9 100644 --- a/include/field_map_obj.h +++ b/include/field_map_obj.h @@ -1,12 +1,13 @@ #ifndef POKEEMERALD_FIELD_MAP_OBJ_H #define POKEEMERALD_FIELD_MAP_OBJ_H +#define NUM_OBJECT_GRAPHICS_INFO 239 +#define SPRITE_VAR 240 + // Exported struct declarations // Exported RAM declarations - - // Exported ROM declarations void sub_808D438(void); diff --git a/include/mauville_old_man.h b/include/mauville_old_man.h new file mode 100644 index 000000000..5ed7b203b --- /dev/null +++ b/include/mauville_old_man.h @@ -0,0 +1,10 @@ +// +// Created by Scott Norton on 9/8/17. +// + +#ifndef POKEEMERALD_MAUVILLE_OLD_MAN_H +#define POKEEMERALD_MAUVILLE_OLD_MAN_H + +u8 sub_81201C8(void); + +#endif //POKEEMERALD_MAUVILLE_OLD_MAN_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 37ab01762..775a7b4e4 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -11,6 +11,7 @@ #include "rom_81BE66C.h" #include "field_ground_effect.h" #include "map_obj_8097404.h" +#include "mauville_old_man.h" #include "field_effect_helpers.h" #include "field_map_obj.h" @@ -45,6 +46,8 @@ static void SetPlayerAvatarFieldObjectIdAndObjectId(u8, u8); void (*const gUnknown_08505438[NUM_FIELD_MAP_OBJECT_TEMPLATES])(struct Sprite *); const u8 gUnknown_0850557C[NUM_FIELD_MAP_OBJECT_TEMPLATES]; const u8 gUnknown_085055CD[NUM_FIELD_MAP_OBJECT_TEMPLATES]; +const struct MapObjectGraphicsInfo *const gMauvilleOldManGraphicsInfoPointers[7]; +const struct MapObjectGraphicsInfo *const gFieldObjectGraphicsInfoPointers[0xEF]; // Code @@ -980,7 +983,7 @@ void PlayerObjectTurn(struct PlayerAvatar *playerAvatar, u8 direction) FieldObjectTurn(&gMapObjects[playerAvatar->mapObjectId], direction); } -void get_berry_tree_graphics(struct MapObject *mapObject, struct Sprite *sprite) +/*static*/ void get_berry_tree_graphics(struct MapObject *mapObject, struct Sprite *sprite) { u8 berryStage; u8 berryId; @@ -1004,3 +1007,23 @@ void get_berry_tree_graphics(struct MapObject *mapObject, struct Sprite *sprite) StartSpriteAnim(sprite, berryStage); } } + +const struct MapObjectGraphicsInfo *GetFieldObjectGraphicsInfo(u8 graphicsId) +{ + u8 bard; + + if (graphicsId >= SPRITE_VAR) + { + graphicsId = VarGetFieldObjectGraphicsId(graphicsId - SPRITE_VAR); + } + if (graphicsId == 0x45) + { + bard = sub_81201C8(); + return gMauvilleOldManGraphicsInfoPointers[bard]; + } + if (graphicsId >= NUM_OBJECT_GRAPHICS_INFO) + { + graphicsId = 0x05; // LittleBoy1 + } + return gFieldObjectGraphicsInfoPointers[graphicsId]; +} From 511474cc15f8c7f52d4311b82898ee5c331b1260 Mon Sep 17 00:00:00 2001 From: scnorton Date: Fri, 8 Sep 2017 14:20:13 -0400 Subject: [PATCH 038/191] FieldObjectHandleDynamicGraphicsId --- asm/field_map_obj.s | 19 ------------------- src/field_map_obj.c | 10 +++++++++- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 8179cb0ec..b41d6607e 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,25 +5,6 @@ .text - thumb_func_start FieldObjectHandleDynamicGraphicsId -@ void FieldObjectHandleDynamicGraphicsId(struct npc_state *fieldObject) -FieldObjectHandleDynamicGraphicsId: @ 808E6DC - push {r4,lr} - adds r4, r0, 0 - ldrb r0, [r4, 0x5] - cmp r0, 0xEF - bls _0808E6F2 - adds r0, 0x10 - lsls r0, 24 - lsrs r0, 24 - bl VarGetFieldObjectGraphicsId - strb r0, [r4, 0x5] -_0808E6F2: - pop {r4} - pop {r0} - bx r0 - thumb_func_end FieldObjectHandleDynamicGraphicsId - thumb_func_start npc_by_local_id_and_map_set_field_1_bit_x20 npc_by_local_id_and_map_set_field_1_bit_x20: @ 808E6F8 push {r4,lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 775a7b4e4..c8d25341f 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -27,7 +27,7 @@ static void sub_808D450(void); static u8 GetFieldObjectIdByLocalId(u8); static u8 GetFieldObjectIdByLocalIdAndMapInternal(u8, u8, u8); static bool8 GetAvailableFieldObjectSlot(u16, u8, u8, u8 *); -/*static*/ void FieldObjectHandleDynamicGraphicsId(struct MapObject *); +static void FieldObjectHandleDynamicGraphicsId(struct MapObject *); static void RemoveFieldObjectInternal (struct MapObject *); /*static*/ u16 GetFieldObjectFlagIdByFieldObjectId(u8); /*static*/ const struct MapObjectGraphicsInfo *GetFieldObjectGraphicsInfo(u8); @@ -1027,3 +1027,11 @@ const struct MapObjectGraphicsInfo *GetFieldObjectGraphicsInfo(u8 graphicsId) } return gFieldObjectGraphicsInfoPointers[graphicsId]; } + +static void FieldObjectHandleDynamicGraphicsId(struct MapObject *mapObject) +{ + if (mapObject->graphicsId >= SPRITE_VAR) + { + mapObject->graphicsId = VarGetFieldObjectGraphicsId(mapObject->graphicsId - SPRITE_VAR); + } +} From 67955bb51a14b464add672774a50b67788cf56c6 Mon Sep 17 00:00:00 2001 From: scnorton Date: Fri, 8 Sep 2017 14:36:58 -0400 Subject: [PATCH 039/191] npc_by_local_id_and_map_set_field_1_bit_x20 --- asm/field_map_obj.s | 42 ----------------------------------------- include/field_map_obj.h | 2 ++ src/field_map_obj.c | 11 ++++++++++- 3 files changed, 12 insertions(+), 43 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index b41d6607e..53565e334 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,48 +5,6 @@ .text - thumb_func_start npc_by_local_id_and_map_set_field_1_bit_x20 -npc_by_local_id_and_map_set_field_1_bit_x20: @ 808E6F8 - push {r4,lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r0, 24 - lsls r1, 24 - lsrs r1, 24 - lsls r2, 24 - lsrs r2, 24 - lsls r3, 24 - lsrs r4, r3, 24 - mov r3, sp - bl TryGetFieldObjectIdByLocalIdAndMap - lsls r0, 24 - cmp r0, 0 - bne _0808E73A - ldr r2, =gMapObjects - mov r0, sp - ldrb r0, [r0] - lsls r1, r0, 3 - adds r1, r0 - lsls r1, 2 - adds r1, r2 - movs r0, 0x1 - adds r2, r4, 0 - ands r2, r0 - lsls r2, 5 - ldrb r3, [r1, 0x1] - movs r0, 0x21 - negs r0, r0 - ands r0, r3 - orrs r0, r2 - strb r0, [r1, 0x1] -_0808E73A: - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end npc_by_local_id_and_map_set_field_1_bit_x20 - thumb_func_start FieldObjectGetLocalIdAndMap @ void FieldObjectGetLocalIdAndMap(struct npc_state *fieldObject, u8 *localId, u8 *mapId, u8 *mapGroupId) FieldObjectGetLocalIdAndMap: @ 808E748 diff --git a/include/field_map_obj.h b/include/field_map_obj.h index 5eaee20d9..bf99cec87 100644 --- a/include/field_map_obj.h +++ b/include/field_map_obj.h @@ -37,6 +37,8 @@ void CameraObjectReset1(void); void FieldObjectSetGraphicsId(struct MapObject *, u8); void FieldObjectTurn(struct MapObject *, u8); void FieldObjectTurnByLocalIdAndMap(u8, u8, u8, u8); +const struct MapObjectGraphicsInfo *GetFieldObjectGraphicsInfo(u8); +void npc_by_local_id_and_map_set_field_1_bit_x20(u8, u8, u8, u8); // Exported data declarations diff --git a/src/field_map_obj.c b/src/field_map_obj.c index c8d25341f..bac056ee6 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -30,7 +30,6 @@ static bool8 GetAvailableFieldObjectSlot(u16, u8, u8, u8 *); static void FieldObjectHandleDynamicGraphicsId(struct MapObject *); static void RemoveFieldObjectInternal (struct MapObject *); /*static*/ u16 GetFieldObjectFlagIdByFieldObjectId(u8); -/*static*/ const struct MapObjectGraphicsInfo *GetFieldObjectGraphicsInfo(u8); void sub_8096518(struct MapObject *, struct Sprite *); static void MakeObjectTemplateFromFieldObjectTemplate(struct MapObjectTemplate *, struct SpriteTemplate *, const struct SubspriteTable **); /*static*/ void GetFieldObjectMovingCameraOffset(s16 *, s16 *); @@ -1035,3 +1034,13 @@ static void FieldObjectHandleDynamicGraphicsId(struct MapObject *mapObject) mapObject->graphicsId = VarGetFieldObjectGraphicsId(mapObject->graphicsId - SPRITE_VAR); } } + +void npc_by_local_id_and_map_set_field_1_bit_x20(u8 localId, u8 mapNum, u8 mapGroup, u8 state) +{ + u8 mapObjectId; + + if (!TryGetFieldObjectIdByLocalIdAndMap(localId, mapNum, mapGroup, &mapObjectId)) + { + gMapObjects[mapObjectId].mapobj_bit_13 = state; + } +} From 05685f396150113bb4124493e6ada131e0e8307f Mon Sep 17 00:00:00 2001 From: scnorton Date: Fri, 8 Sep 2017 14:40:34 -0400 Subject: [PATCH 040/191] FieldObjectGetLocalIdAndMap --- asm/field_map_obj.s | 15 --------------- src/field_map_obj.c | 7 +++++++ 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 53565e334..def08bb9c 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,21 +5,6 @@ .text - thumb_func_start FieldObjectGetLocalIdAndMap -@ void FieldObjectGetLocalIdAndMap(struct npc_state *fieldObject, u8 *localId, u8 *mapId, u8 *mapGroupId) -FieldObjectGetLocalIdAndMap: @ 808E748 - push {r4,lr} - ldrb r4, [r0, 0x8] - strb r4, [r1] - ldrb r1, [r0, 0x9] - strb r1, [r2] - ldrb r0, [r0, 0xA] - strb r0, [r3] - pop {r4} - pop {r0} - bx r0 - thumb_func_end FieldObjectGetLocalIdAndMap - thumb_func_start sub_808E75C sub_808E75C: @ 808E75C push {lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index bac056ee6..94e2fb694 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -1044,3 +1044,10 @@ void npc_by_local_id_and_map_set_field_1_bit_x20(u8 localId, u8 mapNum, u8 mapGr gMapObjects[mapObjectId].mapobj_bit_13 = state; } } + +void FieldObjectGetLocalIdAndMap(struct MapObject *mapObject, u8 *localId, u8 *mapNum, u8 *mapGroup) +{ + *localId = mapObject->localId; + *mapNum = mapObject->mapNum; + *mapGroup = mapObject->mapGroup; +} From 62eca9535836a9e57fd15c5ec9f12707d44d0597 Mon Sep 17 00:00:00 2001 From: scnorton Date: Fri, 8 Sep 2017 14:53:00 -0400 Subject: [PATCH 041/191] sub_808E75C --- asm/field_map_obj.s | 27 --------------------- src/field_map_obj.c | 57 ++++++++++++++++++++++++++++----------------- 2 files changed, 35 insertions(+), 49 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index def08bb9c..27e136350 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,33 +5,6 @@ .text - thumb_func_start sub_808E75C -sub_808E75C: @ 808E75C - push {lr} - lsls r0, 16 - asrs r0, 16 - lsls r1, 16 - asrs r1, 16 - bl GetFieldObjectIdByXY - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0x10 - beq _0808E784 - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, =gMapObjects - adds r0, r1 - ldrb r1, [r0] - movs r2, 0x4 - orrs r1, r2 - strb r1, [r0] -_0808E784: - pop {r0} - bx r0 - .pool - thumb_func_end sub_808E75C - thumb_func_start sub_808E78C sub_808E78C: @ 808E78C push {r4,lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 94e2fb694..ac4f85a47 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -63,7 +63,7 @@ static void npcs_clear_ids_and_state(void) { u8 i; - for (i = 0; i < ARRAY_COUNT(gMapObjects); i ++) + for (i = 0; i < NUM_FIELD_OBJECTS; i ++) { npc_clear_ids_and_state(&gMapObjects[i]); } @@ -98,7 +98,7 @@ u8 sub_808D4F4(void) { u8 i; - for (i = 0; i < ARRAY_COUNT(gMapObjects); i ++) + for (i = 0; i < NUM_FIELD_OBJECTS; i ++) { if (!gMapObjects[i].active) { @@ -120,7 +120,7 @@ u8 GetFieldObjectIdByLocalIdAndMap(u8 localId, u8 mapId, u8 mapGroupId) bool8 TryGetFieldObjectIdByLocalIdAndMap(u8 localId, u8 mapId, u8 mapGroupId, u8 *fieldObjectId) { *fieldObjectId = GetFieldObjectIdByLocalIdAndMap(localId, mapId, mapGroupId); - if (*fieldObjectId == ARRAY_COUNT(gMapObjects)) + if (*fieldObjectId == NUM_FIELD_OBJECTS) { return TRUE; } @@ -131,7 +131,7 @@ u8 GetFieldObjectIdByXY(s16 x, s16 y) { u8 i; - for (i = 0; i < ARRAY_COUNT(gMapObjects); i ++) + for (i = 0; i < NUM_FIELD_OBJECTS; i ++) { if (gMapObjects[i].active && gMapObjects[i].coords2.x == x && gMapObjects[i].coords2.y == y) { @@ -145,28 +145,28 @@ static u8 GetFieldObjectIdByLocalIdAndMapInternal(u8 localId, u8 mapId, u8 mapGr { u8 i; - for (i = 0; i < ARRAY_COUNT(gMapObjects); i ++) + for (i = 0; i < NUM_FIELD_OBJECTS; i ++) { if (gMapObjects[i].active && gMapObjects[i].localId == localId && gMapObjects[i].mapNum == mapId && gMapObjects[i].mapGroup == mapGroupId) { return i; } } - return ARRAY_COUNT(gMapObjects); + return NUM_FIELD_OBJECTS; } static u8 GetFieldObjectIdByLocalId(u8 localId) { u8 i; - for (i = 0; i < ARRAY_COUNT(gMapObjects); i ++) + for (i = 0; i < NUM_FIELD_OBJECTS; i ++) { if (gMapObjects[i].active && gMapObjects[i].localId == localId) { return i; } } - return ARRAY_COUNT(gMapObjects); + return NUM_FIELD_OBJECTS; } // This function has the same nonmatching quirk as in Ruby/Sapphire. @@ -180,7 +180,7 @@ static u8 InitFieldObjectStateFromTemplate(struct MapObjectTemplate *template, u if (GetAvailableFieldObjectSlot(template->localId, mapId, mapGroupId, &slot)) { - return ARRAY_COUNT(gMapObjects); + return NUM_FIELD_OBJECTS; } mapObject = &gMapObjects[slot]; npc_clear_ids_and_state(mapObject); @@ -409,7 +409,7 @@ u8 unref_sub_808D77C(u8 localId) } } } - return ARRAY_COUNT(gMapObjects); + return NUM_FIELD_OBJECTS; } static bool8 GetAvailableFieldObjectSlot(u16 localId, u8 mapNum, u8 mapGroup, u8 *result) @@ -421,14 +421,14 @@ static bool8 GetAvailableFieldObjectSlot(u16 localId, u8 mapNum, u8 mapGroup, u8 { u8 i = 0; - for (i = 0; i < ARRAY_COUNT(gMapObjects); i ++) + for (i = 0; i < NUM_FIELD_OBJECTS; i ++) { if (!gMapObjects[i].active) break; if (gMapObjects[i].localId == localId && gMapObjects[i].mapNum == mapNum && gMapObjects[i].mapGroup == mapGroup) return TRUE; } - if (i >= ARRAY_COUNT(gMapObjects)) + if (i >= NUM_FIELD_OBJECTS) return TRUE; *result = i; do @@ -436,7 +436,7 @@ static bool8 GetAvailableFieldObjectSlot(u16 localId, u8 mapNum, u8 mapGroup, u8 if (gMapObjects[i].active && gMapObjects[i].localId == localId && gMapObjects[i].mapNum == mapNum && gMapObjects[i].mapGroup == mapGroup) return TRUE; i ++; - } while (i < ARRAY_COUNT(gMapObjects)); + } while (i < NUM_FIELD_OBJECTS); return FALSE; } @@ -468,7 +468,7 @@ void unref_sub_808D958(void) { u8 i; - for (i = 0; i < ARRAY_COUNT(gMapObjects); i ++) + for (i = 0; i < NUM_FIELD_OBJECTS; i ++) { if (i != gPlayerAvatar.mapObjectId) { @@ -487,9 +487,9 @@ static u8 SpawnFieldObjectInternal(struct MapObjectTemplate *mapObjectTemplate, u8 spriteId; mapObjectId = InitFieldObjectStateFromTemplate(mapObjectTemplate, mapNum, mapGroup); - if (mapObjectId == ARRAY_COUNT(gMapObjects)) + if (mapObjectId == NUM_FIELD_OBJECTS) { - return ARRAY_COUNT(gMapObjects); + return NUM_FIELD_OBJECTS; } mapObject = &gMapObjects[mapObjectId]; graphicsInfo = GetFieldObjectGraphicsInfo(mapObject->graphicsId); @@ -516,7 +516,7 @@ static u8 SpawnFieldObjectInternal(struct MapObjectTemplate *mapObjectTemplate, if (spriteId == MAX_SPRITES) { gMapObjects[mapObjectId].active = FALSE; - return ARRAY_COUNT(gMapObjects); + return NUM_FIELD_OBJECTS; } sprite = &gSprites[spriteId]; sub_8092FF0(mapObject->coords2.x + cameraX, mapObject->coords2.y + cameraY, &sprite->pos1.x, &sprite->pos1.y); @@ -552,9 +552,9 @@ static u8 SpawnFieldObject(struct MapObjectTemplate *mapObjectTemplate, u8 mapNu spriteFrameImage.size = graphicsInfo->size; spriteTemplate.images = &spriteFrameImage; mapObjectId = SpawnFieldObjectInternal(mapObjectTemplate, &spriteTemplate, mapNum, mapGroup, cameraX, cameraY); - if (mapObjectId == ARRAY_COUNT(gMapObjects)) + if (mapObjectId == NUM_FIELD_OBJECTS) { - return ARRAY_COUNT(gMapObjects); + return NUM_FIELD_OBJECTS; } gSprites[gMapObjects[mapObjectId].spriteId].images = graphicsInfo->images; if (subspriteTables != NULL) @@ -602,7 +602,7 @@ u8 show_sprite(u8 localId, u8 mapNum, u8 mapGroup) mapObjectTemplate = GetFieldObjectTemplateByLocalIdAndMap(localId, mapNum, mapGroup); if (mapObjectTemplate == NULL) { - return ARRAY_COUNT(gMapObjects); + return NUM_FIELD_OBJECTS; } GetFieldObjectMovingCameraOffset(&cameraX, &cameraY); return SpawnFieldObject(mapObjectTemplate, mapNum, mapGroup, cameraX, cameraY); @@ -757,7 +757,7 @@ void SpawnFieldObjectsInView(s16 cameraX, s16 cameraY) bool8 isActiveLinkPlayer; struct MapObject *mapObject; - for (i = 0; i < ARRAY_COUNT(gMapObjects); i ++) + for (i = 0; i < NUM_FIELD_OBJECTS; i ++) { for (j = 0, isActiveLinkPlayer = FALSE; j < ARRAY_COUNT(gLinkPlayerMapObjects); j ++) { @@ -800,7 +800,7 @@ void sub_808E16C(s16 x, s16 y) u8 i; ClearPlayerAvatarInfo(); - for (i = 0; i < ARRAY_COUNT(gMapObjects); i ++) + for (i = 0; i < NUM_FIELD_OBJECTS; i ++) { if (gMapObjects[i].active) { @@ -1051,3 +1051,16 @@ void FieldObjectGetLocalIdAndMap(struct MapObject *mapObject, u8 *localId, u8 *m *mapNum = mapObject->mapNum; *mapGroup = mapObject->mapGroup; } + +void sub_808E75C(s16 x, s16 y) +{ + u8 mapObjectId; + struct MapObject *mapObject; + + mapObjectId = GetFieldObjectIdByXY(x, y); + if (mapObjectId != NUM_FIELD_OBJECTS) + { + mapObject = &gMapObjects[mapObjectId]; + mapObject->mapobj_bit_2 = TRUE; + } +} From 782f21f63e1ac8615203818ebb69f40e91cc70f2 Mon Sep 17 00:00:00 2001 From: scnorton Date: Fri, 8 Sep 2017 14:58:17 -0400 Subject: [PATCH 042/191] sub_808E78C --- asm/field_map_obj.s | 44 -------------------------------------------- src/field_map_obj.c | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 44 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 27e136350..2eac13c30 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,50 +5,6 @@ .text - thumb_func_start sub_808E78C -sub_808E78C: @ 808E78C - push {r4,lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r0, 24 - lsls r1, 24 - lsrs r1, 24 - lsls r2, 24 - lsrs r2, 24 - lsls r3, 24 - lsrs r4, r3, 24 - mov r3, sp - bl TryGetFieldObjectIdByLocalIdAndMap - lsls r0, 24 - cmp r0, 0 - bne _0808E7D2 - mov r0, sp - ldrb r0, [r0] - lsls r2, r0, 3 - adds r2, r0 - lsls r2, 2 - ldr r0, =gMapObjects - adds r2, r0 - ldrb r1, [r2, 0x4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r1, =gSprites - adds r0, r1 - ldrb r1, [r2, 0x3] - movs r3, 0x4 - orrs r1, r3 - strb r1, [r2, 0x3] - adds r0, 0x43 - strb r4, [r0] -_0808E7D2: - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_808E78C - thumb_func_start sub_808E7E4 sub_808E7E4: @ 808E7E4 push {lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index ac4f85a47..a4d7e4097 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -1064,3 +1064,18 @@ void sub_808E75C(s16 x, s16 y) mapObject->mapobj_bit_2 = TRUE; } } + +void sub_808E78C(u8 localId, u8 mapNum, u8 mapGroup, u8 subpriority) +{ + u8 mapObjectId; + struct MapObject *mapObject; + struct Sprite *sprite; + + if (!TryGetFieldObjectIdByLocalIdAndMap(localId, mapNum, mapGroup, &mapObjectId)) + { + mapObject = &gMapObjects[mapObjectId]; + sprite = &gSprites[mapObject->spriteId]; + mapObject->mapobj_bit_26 = TRUE; + sprite->subpriority = subpriority; + } +} From 8ef5d059550cb5d6d21639992e6ce67a9dd327f0 Mon Sep 17 00:00:00 2001 From: scnorton Date: Fri, 8 Sep 2017 15:05:04 -0400 Subject: [PATCH 043/191] sub_808E7E4 --- asm/field_map_obj.s | 38 -------------------------------------- src/field_map_obj.c | 13 +++++++++++++ 2 files changed, 13 insertions(+), 38 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 2eac13c30..6375fd2a3 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,44 +5,6 @@ .text - thumb_func_start sub_808E7E4 -sub_808E7E4: @ 808E7E4 - push {lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r0, 24 - lsls r1, 24 - lsrs r1, 24 - lsls r2, 24 - lsrs r2, 24 - mov r3, sp - bl TryGetFieldObjectIdByLocalIdAndMap - lsls r0, 24 - cmp r0, 0 - bne _0808E820 - mov r0, sp - ldrb r0, [r0] - lsls r1, r0, 3 - adds r1, r0 - lsls r1, 2 - ldr r0, =gMapObjects - adds r1, r0 - ldrb r2, [r1, 0x3] - movs r0, 0x5 - negs r0, r0 - ands r0, r2 - strb r0, [r1, 0x3] - ldrb r0, [r1] - movs r2, 0x4 - orrs r0, r2 - strb r0, [r1] -_0808E820: - add sp, 0x4 - pop {r0} - bx r0 - .pool - thumb_func_end sub_808E7E4 - thumb_func_start sub_808E82C sub_808E82C: @ 808E82C push {r4,r5,lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index a4d7e4097..910a58ffb 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -1079,3 +1079,16 @@ void sub_808E78C(u8 localId, u8 mapNum, u8 mapGroup, u8 subpriority) sprite->subpriority = subpriority; } } + +void sub_808E7E4(u8 localId, u8 mapNum, u8 mapGroup) +{ + u8 mapObjectId; + struct MapObject *mapObject; + + if (!TryGetFieldObjectIdByLocalIdAndMap(localId, mapNum, mapGroup, &mapObjectId)) + { + mapObject = &gMapObjects[mapObjectId]; + mapObject->mapobj_bit_26 = FALSE; + mapObject->mapobj_bit_2 = TRUE; + } +} From d3edf5642ed0f76f678bb4c566a7c96eaf793fdd Mon Sep 17 00:00:00 2001 From: scnorton Date: Fri, 8 Sep 2017 15:08:10 -0400 Subject: [PATCH 044/191] sub_808E82C --- asm/field_map_obj.s | 43 ------------------------------------------- src/field_map_obj.c | 13 +++++++++++++ 2 files changed, 13 insertions(+), 43 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 6375fd2a3..bf6d371e8 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,49 +5,6 @@ .text - thumb_func_start sub_808E82C -sub_808E82C: @ 808E82C - push {r4,r5,lr} - sub sp, 0x4 - ldr r4, [sp, 0x10] - lsls r0, 24 - lsrs r0, 24 - lsls r1, 24 - lsrs r1, 24 - lsls r2, 24 - lsrs r2, 24 - lsls r3, 16 - lsrs r5, r3, 16 - lsls r4, 16 - lsrs r4, 16 - mov r3, sp - bl TryGetFieldObjectIdByLocalIdAndMap - lsls r0, 24 - cmp r0, 0 - bne _0808E870 - ldr r2, =gMapObjects - mov r0, sp - ldrb r1, [r0] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r1, [r0, 0x4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r1, =gSprites - adds r0, r1 - strh r5, [r0, 0x24] - strh r4, [r0, 0x26] -_0808E870: - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_808E82C - thumb_func_start gpu_pal_allocator_reset__manage_upper_four gpu_pal_allocator_reset__manage_upper_four: @ 808E880 push {lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 910a58ffb..5a31881ad 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -1092,3 +1092,16 @@ void sub_808E7E4(u8 localId, u8 mapNum, u8 mapGroup) mapObject->mapobj_bit_2 = TRUE; } } + +void sub_808E82C(u8 localId, u8 mapNum, u8 mapGroup, s16 x, s16 y) +{ + u8 mapObjectId; + struct Sprite *sprite; + + if (!TryGetFieldObjectIdByLocalIdAndMap(localId, mapNum, mapGroup, &mapObjectId)) + { + sprite = &gSprites[gMapObjects[mapObjectId].spriteId]; + sprite->pos2.x = x; + sprite->pos2.y = y; + } +} From db2b371e70a8cbf1134866906c7eccaae7f65203 Mon Sep 17 00:00:00 2001 From: scnorton Date: Fri, 8 Sep 2017 15:11:29 -0400 Subject: [PATCH 045/191] gpu_pal_allocator_reset__manage_upper_four --- asm/field_map_obj.s | 12 ------------ include/global.h | 2 ++ src/field_map_obj.c | 6 ++++++ 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index bf6d371e8..e1925f10e 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,18 +5,6 @@ .text - thumb_func_start gpu_pal_allocator_reset__manage_upper_four -gpu_pal_allocator_reset__manage_upper_four: @ 808E880 - push {lr} - bl FreeAllSpritePalettes - ldr r1, =gReservedSpritePaletteCount - movs r0, 0xC - strb r0, [r1] - pop {r0} - bx r0 - .pool - thumb_func_end gpu_pal_allocator_reset__manage_upper_four - thumb_func_start sub_808E894 sub_808E894: @ 808E894 push {lr} diff --git a/include/global.h b/include/global.h index 0c0f86470..c406c507f 100644 --- a/include/global.h +++ b/include/global.h @@ -730,4 +730,6 @@ struct Bitmap // TODO: Find a better spot for this u32 height:16; }; +extern u8 gReservedSpritePaletteCount; + #endif // GUARD_GLOBAL_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 5a31881ad..cb3390844 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -1105,3 +1105,9 @@ void sub_808E82C(u8 localId, u8 mapNum, u8 mapGroup, s16 x, s16 y) sprite->pos2.y = y; } } + +void gpu_pal_allocator_reset__manage_upper_four(void) +{ + FreeAllSpritePalettes(); + gReservedSpritePaletteCount = 12; +} From 1de5a14a35f6da79a2bc603ce5a0cb3a116c31b0 Mon Sep 17 00:00:00 2001 From: scnorton Date: Fri, 8 Sep 2017 15:18:03 -0400 Subject: [PATCH 046/191] sub_808E894 --- asm/field_map_obj.s | 21 --------------------- include/data3.h | 10 ++++++++++ src/field_map_obj.c | 14 ++++++++++++++ 3 files changed, 24 insertions(+), 21 deletions(-) create mode 100644 include/data3.h diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index e1925f10e..992f70a11 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,27 +5,6 @@ .text - thumb_func_start sub_808E894 -sub_808E894: @ 808E894 - push {lr} - lsls r0, 16 - lsrs r0, 16 - bl FindFieldObjectPaletteIndexByTag - lsls r0, 24 - lsrs r1, r0, 24 - ldr r0, =0x000011ff - cmp r1, r0 - beq _0808E8B2 - lsls r0, r1, 3 - ldr r1, =gUnknown_0850BBC8 - adds r0, r1 - bl sub_808E8F4 -_0808E8B2: - pop {r0} - bx r0 - .pool - thumb_func_end sub_808E894 - thumb_func_start sub_808E8C0 sub_808E8C0: @ 808E8C0 push {r4-r6,lr} diff --git a/include/data3.h b/include/data3.h new file mode 100644 index 000000000..1f082e3fb --- /dev/null +++ b/include/data3.h @@ -0,0 +1,10 @@ +// +// Created by Scott Norton on 9/8/17. +// + +#ifndef POKEEMERALD_DATA3_H +#define POKEEMERALD_DATA3_H + +extern const struct SpritePalette gUnknown_0850BBC8[]; + +#endif //POKEEMERALD_DATA3_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index cb3390844..7122bcc9e 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -4,6 +4,7 @@ #include "malloc.h" #include "sprite.h" #include "rom4.h" +#include "data3.h" #include "berry.h" #include "field_player_avatar.h" #include "event_data.h" @@ -39,6 +40,8 @@ static void RemoveFieldObjectIfOutsideView(struct MapObject *); static void sub_808E1B8(u8, s16, s16); static void SetPlayerAvatarFieldObjectIdAndObjectId(u8, u8); /*static*/ void sub_808E38C(struct MapObject *); +/*static*/ void sub_808E8F4(const struct SpritePalette *); +/*static*/ u16 FindFieldObjectPaletteIndexByTag(u16); // ROM data @@ -1111,3 +1114,14 @@ void gpu_pal_allocator_reset__manage_upper_four(void) FreeAllSpritePalettes(); gReservedSpritePaletteCount = 12; } + +void sub_808E894(u16 paletteTag) +{ + u16 paletteSlot; + + paletteSlot = (u8)FindFieldObjectPaletteIndexByTag(paletteTag); + if (paletteSlot != 0x11ff) // always true + { + sub_808E8F4(&gUnknown_0850BBC8[paletteSlot]); + } +} From 444887ba228a94866641bfa2d420cf1903af1a82 Mon Sep 17 00:00:00 2001 From: scnorton Date: Fri, 8 Sep 2017 15:21:32 -0400 Subject: [PATCH 047/191] sub_808E8C0 --- asm/field_map_obj.s | 30 ------------------------------ src/field_map_obj.c | 10 ++++++++++ 2 files changed, 10 insertions(+), 30 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 992f70a11..faf5bb23c 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,36 +5,6 @@ .text - thumb_func_start sub_808E8C0 -sub_808E8C0: @ 808E8C0 - push {r4-r6,lr} - adds r5, r0, 0 - movs r4, 0 - ldrh r0, [r5] - ldr r1, =0x000011ff - cmp r0, r1 - beq _0808E8EA - adds r6, r1, 0 -_0808E8D0: - lsls r0, r4, 1 - adds r0, r5 - ldrh r0, [r0] - bl sub_808E894 - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - lsls r0, r4, 1 - adds r0, r5 - ldrh r0, [r0] - cmp r0, r6 - bne _0808E8D0 -_0808E8EA: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_808E8C0 - thumb_func_start sub_808E8F4 @ u8 sub_808E8F4(struct TaggedObjectPalette *taggedPalette) sub_808E8F4: @ 808E8F4 diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 7122bcc9e..1ae142075 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -1125,3 +1125,13 @@ void sub_808E894(u16 paletteTag) sub_808E8F4(&gUnknown_0850BBC8[paletteSlot]); } } + +void sub_808E8C0(u16 *paletteTags) +{ + u8 i; + + for (i = 0; paletteTags[i] != 0x11ff; i ++) + { + sub_808E894(paletteTags[i]); + } +} From 2d3ce87c4c653d1789192e0083ee93a2090cdca5 Mon Sep 17 00:00:00 2001 From: scnorton Date: Fri, 8 Sep 2017 15:27:08 -0400 Subject: [PATCH 048/191] sub_808E8F4 --- asm/field_map_obj.s | 24 ------------------------ src/field_map_obj.c | 15 ++++++++++++--- 2 files changed, 12 insertions(+), 27 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index faf5bb23c..6316bd0b7 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,30 +5,6 @@ .text - thumb_func_start sub_808E8F4 -@ u8 sub_808E8F4(struct TaggedObjectPalette *taggedPalette) -sub_808E8F4: @ 808E8F4 - push {r4,lr} - adds r4, r0, 0 - ldrh r0, [r4, 0x4] - bl IndexOfSpritePaletteTag - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0xFF - bne _0808E912 - adds r0, r4, 0 - bl LoadSpritePalette - lsls r0, 24 - lsrs r0, 24 - b _0808E914 -_0808E912: - movs r0, 0xFF -_0808E914: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_808E8F4 - thumb_func_start pal_patch_for_npc @ void pal_patch_for_npc(u16 tag, u8 slot) pal_patch_for_npc: @ 808E91C diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 1ae142075..ccc88db15 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -35,12 +35,12 @@ void sub_8096518(struct MapObject *, struct Sprite *); static void MakeObjectTemplateFromFieldObjectTemplate(struct MapObjectTemplate *, struct SpriteTemplate *, const struct SubspriteTable **); /*static*/ void GetFieldObjectMovingCameraOffset(s16 *, s16 *); /*static*/ struct MapObjectTemplate *GetFieldObjectTemplateByLocalIdAndMap(u8, u8, u8); -/*static*/ void sub_808E894(u16); +static void sub_808E894(u16); static void RemoveFieldObjectIfOutsideView(struct MapObject *); static void sub_808E1B8(u8, s16, s16); static void SetPlayerAvatarFieldObjectIdAndObjectId(u8, u8); /*static*/ void sub_808E38C(struct MapObject *); -/*static*/ void sub_808E8F4(const struct SpritePalette *); +/*static*/ u8 sub_808E8F4(const struct SpritePalette *); /*static*/ u16 FindFieldObjectPaletteIndexByTag(u16); // ROM data @@ -1115,7 +1115,7 @@ void gpu_pal_allocator_reset__manage_upper_four(void) gReservedSpritePaletteCount = 12; } -void sub_808E894(u16 paletteTag) +static void sub_808E894(u16 paletteTag) { u16 paletteSlot; @@ -1135,3 +1135,12 @@ void sub_808E8C0(u16 *paletteTags) sub_808E894(paletteTags[i]); } } + +u8 sub_808E8F4(const struct SpritePalette *spritePalette) +{ + if (IndexOfSpritePaletteTag(spritePalette->tag) != 0xff) + { + return 0xff; + } + return LoadSpritePalette(spritePalette); +} From e6e0dc80f6ec0284ae49fd83847fac241c9e86b3 Mon Sep 17 00:00:00 2001 From: scnorton Date: Fri, 8 Sep 2017 17:17:03 -0400 Subject: [PATCH 049/191] pal_patch_for_npc --- asm/field_map_obj.s | 29 ----------------------------- src/field_map_obj.c | 9 +++++++++ 2 files changed, 9 insertions(+), 29 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 6316bd0b7..b6ce802ff 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,35 +5,6 @@ .text - thumb_func_start pal_patch_for_npc -@ void pal_patch_for_npc(u16 tag, u8 slot) -pal_patch_for_npc: @ 808E91C - push {r4,lr} - adds r4, r1, 0 - lsls r0, 16 - lsrs r0, 16 - lsls r4, 24 - lsrs r4, 24 - bl FindFieldObjectPaletteIndexByTag - lsls r0, 24 - ldr r1, =gUnknown_0850BBC8 - lsrs r0, 21 - adds r0, r1 - ldr r0, [r0] - lsls r4, 20 - movs r1, 0x80 - lsls r1, 17 - adds r4, r1 - lsrs r4, 16 - adds r1, r4, 0 - movs r2, 0x20 - bl LoadPalette - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end pal_patch_for_npc - thumb_func_start pal_patch_for_npc_range @ void pal_patch_for_npc_range(u16 *tags, u8 minSlot, u8 maxSlot) pal_patch_for_npc_range: @ 808E954 diff --git a/src/field_map_obj.c b/src/field_map_obj.c index ccc88db15..c8d147e6d 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -6,6 +6,7 @@ #include "rom4.h" #include "data3.h" #include "berry.h" +#include "palette.h" #include "field_player_avatar.h" #include "event_data.h" #include "rom_818CFC8.h" @@ -1144,3 +1145,11 @@ u8 sub_808E8F4(const struct SpritePalette *spritePalette) } return LoadSpritePalette(spritePalette); } + +void pal_patch_for_npc(u16 paletteTag, u8 paletteSlot) +{ + u8 paletteIdx; + + paletteIdx = FindFieldObjectPaletteIndexByTag(paletteTag); + LoadPalette(gUnknown_0850BBC8[paletteIdx].data, 16 * paletteSlot + 256, 0x20); +} From 07b1668623f6d028d1c1f32c29e377064f577680 Mon Sep 17 00:00:00 2001 From: scnorton Date: Fri, 8 Sep 2017 17:21:58 -0400 Subject: [PATCH 050/191] pal_patch_for_npc_range --- asm/field_map_obj.s | 27 --------------------------- src/field_map_obj.c | 10 ++++++++++ 2 files changed, 10 insertions(+), 27 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index b6ce802ff..9f880e0c1 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,33 +5,6 @@ .text - thumb_func_start pal_patch_for_npc_range -@ void pal_patch_for_npc_range(u16 *tags, u8 minSlot, u8 maxSlot) -pal_patch_for_npc_range: @ 808E954 - push {r4-r6,lr} - adds r5, r0, 0 - lsls r1, 24 - lsrs r4, r1, 24 - lsls r2, 24 - lsrs r6, r2, 24 - cmp r4, r6 - bcs _0808E978 -_0808E964: - ldrh r0, [r5] - adds r1, r4, 0 - bl pal_patch_for_npc - adds r5, 0x2 - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, r6 - bcc _0808E964 -_0808E978: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end pal_patch_for_npc_range - thumb_func_start FindFieldObjectPaletteIndexByTag @ u8 FindFieldObjectPaletteIndexByTag(u16 tag) FindFieldObjectPaletteIndexByTag: @ 808E980 diff --git a/src/field_map_obj.c b/src/field_map_obj.c index c8d147e6d..4e785e969 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -1153,3 +1153,13 @@ void pal_patch_for_npc(u16 paletteTag, u8 paletteSlot) paletteIdx = FindFieldObjectPaletteIndexByTag(paletteTag); LoadPalette(gUnknown_0850BBC8[paletteIdx].data, 16 * paletteSlot + 256, 0x20); } + +void pal_patch_for_npc_range(u16 *paletteTags, u8 minSlot, u8 maxSlot) +{ + while (minSlot < maxSlot) + { + pal_patch_for_npc(*paletteTags, minSlot); + paletteTags ++; + minSlot ++; + } +} From 5a020a47f3ac99bf80854817873e211cbf22102d Mon Sep 17 00:00:00 2001 From: scnorton Date: Fri, 8 Sep 2017 17:34:12 -0400 Subject: [PATCH 051/191] FindFieldObjectPaletteIndexByTag --- asm/field_map_obj.s | 41 ----------------------------------------- include/field_map_obj.h | 6 ++++++ src/field_map_obj.c | 24 +++++++++++++++++++----- 3 files changed, 25 insertions(+), 46 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 9f880e0c1..2475b649b 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,47 +5,6 @@ .text - thumb_func_start FindFieldObjectPaletteIndexByTag -@ u8 FindFieldObjectPaletteIndexByTag(u16 tag) -FindFieldObjectPaletteIndexByTag: @ 808E980 - push {r4-r6,lr} - lsls r0, 16 - lsrs r5, r0, 16 - movs r2, 0 - ldr r0, =gUnknown_0850BBC8 - ldrh r1, [r0, 0x4] - ldr r3, =0x000011ff - adds r4, r0, 0 - cmp r1, r3 - beq _0808E9C0 - adds r6, r4, 0 - adds r1, r3, 0 -_0808E998: - lsls r0, r2, 3 - adds r0, r6 - ldrh r0, [r0, 0x4] - cmp r0, r5 - bne _0808E9B0 - adds r0, r2, 0 - b _0808E9C2 - .pool -_0808E9B0: - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - lsls r0, r2, 3 - adds r0, r4 - ldrh r0, [r0, 0x4] - cmp r0, r1 - bne _0808E998 -_0808E9C0: - movs r0, 0xFF -_0808E9C2: - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end FindFieldObjectPaletteIndexByTag - thumb_func_start npc_load_two_palettes__no_record @ void npc_load_two_palettes__no_record(u16 tag, u8 slot) npc_load_two_palettes__no_record: @ 808E9C8 diff --git a/include/field_map_obj.h b/include/field_map_obj.h index bf99cec87..04bdb42d4 100644 --- a/include/field_map_obj.h +++ b/include/field_map_obj.h @@ -39,6 +39,12 @@ void FieldObjectTurn(struct MapObject *, u8); void FieldObjectTurnByLocalIdAndMap(u8, u8, u8, u8); const struct MapObjectGraphicsInfo *GetFieldObjectGraphicsInfo(u8); void npc_by_local_id_and_map_set_field_1_bit_x20(u8, u8, u8, u8); +void gpu_pal_allocator_reset__manage_upper_four(void); +void sub_808E82C(u8, u8, u8, s16, s16); +void sub_808E7E4(u8, u8, u8); +void sub_808E78C(u8, u8, u8, u8); +void sub_808E75C(s16, s16); +void FieldObjectGetLocalIdAndMap(struct MapObject *, u8 *, u8 *, u8 *); // Exported data declarations diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 4e785e969..0614a82d7 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -41,8 +41,8 @@ static void RemoveFieldObjectIfOutsideView(struct MapObject *); static void sub_808E1B8(u8, s16, s16); static void SetPlayerAvatarFieldObjectIdAndObjectId(u8, u8); /*static*/ void sub_808E38C(struct MapObject *); -/*static*/ u8 sub_808E8F4(const struct SpritePalette *); -/*static*/ u16 FindFieldObjectPaletteIndexByTag(u16); +static u8 sub_808E8F4(const struct SpritePalette *); +static u8 FindFieldObjectPaletteIndexByTag(u16); // ROM data @@ -1120,7 +1120,7 @@ static void sub_808E894(u16 paletteTag) { u16 paletteSlot; - paletteSlot = (u8)FindFieldObjectPaletteIndexByTag(paletteTag); + paletteSlot = FindFieldObjectPaletteIndexByTag(paletteTag); if (paletteSlot != 0x11ff) // always true { sub_808E8F4(&gUnknown_0850BBC8[paletteSlot]); @@ -1137,7 +1137,7 @@ void sub_808E8C0(u16 *paletteTags) } } -u8 sub_808E8F4(const struct SpritePalette *spritePalette) +static u8 sub_808E8F4(const struct SpritePalette *spritePalette) { if (IndexOfSpritePaletteTag(spritePalette->tag) != 0xff) { @@ -1148,7 +1148,7 @@ u8 sub_808E8F4(const struct SpritePalette *spritePalette) void pal_patch_for_npc(u16 paletteTag, u8 paletteSlot) { - u8 paletteIdx; + u16 paletteIdx; paletteIdx = FindFieldObjectPaletteIndexByTag(paletteTag); LoadPalette(gUnknown_0850BBC8[paletteIdx].data, 16 * paletteSlot + 256, 0x20); @@ -1163,3 +1163,17 @@ void pal_patch_for_npc_range(u16 *paletteTags, u8 minSlot, u8 maxSlot) minSlot ++; } } + +static u8 FindFieldObjectPaletteIndexByTag(u16 tag) +{ + u8 i; + + for (i = 0; gUnknown_0850BBC8[i].tag != 0x11ff; i ++) + { + if (gUnknown_0850BBC8[i].tag == tag) + { + return i; + } + } + return 0xff; +} From dddb44e3018ba915564d6e1a3bcc888ec37aa0bd Mon Sep 17 00:00:00 2001 From: scnorton Date: Fri, 8 Sep 2017 17:58:41 -0400 Subject: [PATCH 052/191] npc_load_two_palettes__no_record --- asm/field_map_obj.s | 53 --------------------------------------------- include/data3.h | 7 ++++++ src/field_map_obj.c | 18 +++++++++++++++ 3 files changed, 25 insertions(+), 53 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 2475b649b..f34bde8ad 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,59 +5,6 @@ .text - thumb_func_start npc_load_two_palettes__no_record -@ void npc_load_two_palettes__no_record(u16 tag, u8 slot) -npc_load_two_palettes__no_record: @ 808E9C8 - push {r4-r6,lr} - lsls r0, 16 - lsrs r4, r0, 16 - lsls r1, 24 - lsrs r5, r1, 24 - adds r0, r4, 0 - adds r1, r5, 0 - bl pal_patch_for_npc - movs r3, 0 - ldr r1, =gUnknown_0850BD00 - ldrh r0, [r1] - ldr r2, =0x000011ff - cmp r0, r2 - beq _0808EA30 - ldr r0, =gUnknown_084975C4 - adds r5, r0 - adds r6, r2, 0 -_0808E9EC: - lsls r2, r3, 3 - adds r0, r2, r1 - ldrh r0, [r0] - cmp r0, r4 - bne _0808EA20 - adds r1, 0x4 - adds r1, r2, r1 - ldr r0, =gUnknown_020375B4 - ldrb r0, [r0] - ldr r1, [r1] - lsls r0, 1 - adds r0, r1 - ldrh r0, [r0] - ldrb r1, [r5] - bl pal_patch_for_npc - b _0808EA30 - .pool -_0808EA20: - adds r0, r3, 0x1 - lsls r0, 24 - lsrs r3, r0, 24 - lsls r0, r3, 3 - adds r0, r1 - ldrh r0, [r0] - cmp r0, r6 - bne _0808E9EC -_0808EA30: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end npc_load_two_palettes__no_record - thumb_func_start npc_load_two_palettes__and_record @ void npc_load_two_palettes__and_record(u16 tag, u8 slot) npc_load_two_palettes__and_record: @ 808EA38 diff --git a/include/data3.h b/include/data3.h index 1f082e3fb..5318d44ec 100644 --- a/include/data3.h +++ b/include/data3.h @@ -5,6 +5,13 @@ #ifndef POKEEMERALD_DATA3_H #define POKEEMERALD_DATA3_H +struct PairedPalettes { + u16 tag; + const u16 *data; +}; + extern const struct SpritePalette gUnknown_0850BBC8[]; +extern const struct PairedPalettes gUnknown_0850BD00[15]; +extern u8 gUnknown_084975C4[0x10]; #endif //POKEEMERALD_DATA3_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 0614a82d7..fae9b12d8 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -23,6 +23,9 @@ // Static RAM declarations +extern u8 gUnknown_020375B4; +extern u16 gUnknown_020375B6; + // Static ROM declarations static void sub_808D450(void); @@ -1177,3 +1180,18 @@ static u8 FindFieldObjectPaletteIndexByTag(u16 tag) } return 0xff; } + +void npc_load_two_palettes__no_record(u16 tag, u8 slot) +{ + u8 i; + + pal_patch_for_npc(tag, slot); + for (i = 0; gUnknown_0850BD00[i].tag != 0x11ff; i ++) + { + if (gUnknown_0850BD00[i].tag == tag) + { + pal_patch_for_npc(gUnknown_0850BD00[i].data[gUnknown_020375B4], gUnknown_084975C4[slot]); + return; + } + } +} From a17a1bb27aeca68624c2b8d1b55cbd44e1c34e11 Mon Sep 17 00:00:00 2001 From: scnorton Date: Fri, 8 Sep 2017 18:04:23 -0400 Subject: [PATCH 053/191] npc_load_two_palettes__and_record --- asm/field_map_obj.s | 55 --------------------------------------------- include/data3.h | 1 + src/field_map_obj.c | 16 +++++++++++++ 3 files changed, 17 insertions(+), 55 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index f34bde8ad..0cc7f1fe3 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,61 +5,6 @@ .text - thumb_func_start npc_load_two_palettes__and_record -@ void npc_load_two_palettes__and_record(u16 tag, u8 slot) -npc_load_two_palettes__and_record: @ 808EA38 - push {r4-r6,lr} - lsls r0, 16 - lsrs r4, r0, 16 - lsls r1, 24 - lsrs r5, r1, 24 - ldr r0, =gUnknown_020375B6 - strh r4, [r0] - adds r0, r4, 0 - adds r1, r5, 0 - bl pal_patch_for_npc - movs r3, 0 - ldr r1, =gUnknown_0850BD78 - ldrh r0, [r1] - ldr r2, =0x000011ff - cmp r0, r2 - beq _0808EAA8 - ldr r0, =gUnknown_084975C4 - adds r5, r0 - adds r6, r2, 0 -_0808EA60: - lsls r2, r3, 3 - adds r0, r2, r1 - ldrh r0, [r0] - cmp r0, r4 - bne _0808EA98 - adds r1, 0x4 - adds r1, r2, r1 - ldr r0, =gUnknown_020375B4 - ldrb r0, [r0] - ldr r1, [r1] - lsls r0, 1 - adds r0, r1 - ldrh r0, [r0] - ldrb r1, [r5] - bl pal_patch_for_npc - b _0808EAA8 - .pool -_0808EA98: - adds r0, r3, 0x1 - lsls r0, 24 - lsrs r3, r0, 24 - lsls r0, r3, 3 - adds r0, r1 - ldrh r0, [r0] - cmp r0, r6 - bne _0808EA60 -_0808EAA8: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end npc_load_two_palettes__and_record - thumb_func_start sub_808EAB0 sub_808EAB0: @ 808EAB0 push {lr} diff --git a/include/data3.h b/include/data3.h index 5318d44ec..f44a61263 100644 --- a/include/data3.h +++ b/include/data3.h @@ -12,6 +12,7 @@ struct PairedPalettes { extern const struct SpritePalette gUnknown_0850BBC8[]; extern const struct PairedPalettes gUnknown_0850BD00[15]; +extern const struct PairedPalettes gUnknown_0850BD78[15]; extern u8 gUnknown_084975C4[0x10]; #endif //POKEEMERALD_DATA3_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index fae9b12d8..b5a0ce5e5 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -1195,3 +1195,19 @@ void npc_load_two_palettes__no_record(u16 tag, u8 slot) } } } + +void npc_load_two_palettes__and_record(u16 tag, u8 slot) +{ + u8 i; + + gUnknown_020375B6 = tag; + pal_patch_for_npc(tag, slot); + for (i = 0; gUnknown_0850BD78[i].tag != 0x11ff; i ++) + { + if (gUnknown_0850BD78[i].tag == tag) + { + pal_patch_for_npc(gUnknown_0850BD78[i].data[gUnknown_020375B4], gUnknown_084975C4[slot]); + return; + } + } +} From b639ca3b15bea19d7115d7ad619a1e6140015740 Mon Sep 17 00:00:00 2001 From: scnorton Date: Fri, 8 Sep 2017 18:12:27 -0400 Subject: [PATCH 054/191] sub_808EAB0 --- asm/field_map_obj.s | 12 ------------ include/field_map_obj.h | 1 - src/field_map_obj.c | 6 ++++++ 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 0cc7f1fe3..2bf3ce572 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,18 +5,6 @@ .text - thumb_func_start sub_808EAB0 -sub_808EAB0: @ 808EAB0 - push {lr} - lsls r0, 16 - lsrs r0, 16 - lsls r1, 24 - lsrs r1, 24 - bl pal_patch_for_npc - pop {r0} - bx r0 - thumb_func_end sub_808EAB0 - thumb_func_start sub_808EAC4 sub_808EAC4: @ 808EAC4 push {r4,lr} diff --git a/include/field_map_obj.h b/include/field_map_obj.h index 04bdb42d4..c5b23103f 100644 --- a/include/field_map_obj.h +++ b/include/field_map_obj.h @@ -21,7 +21,6 @@ void npc_load_two_palettes__no_record(u16, u8); void npc_load_two_palettes__and_record(u16, u8); void pal_patch_for_npc(u16, u8); void sub_808E16C(s16, s16); -void sub_808EAB0(u16, u8); void sub_8092FF0(s16, s16, s16 *, s16 *); u8 FieldObjectDirectionToImageAnimId(u8); void sub_80930E0(s16 *, s16 *, u8, u8); diff --git a/src/field_map_obj.c b/src/field_map_obj.c index b5a0ce5e5..8042348f2 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -46,6 +46,7 @@ static void SetPlayerAvatarFieldObjectIdAndObjectId(u8, u8); /*static*/ void sub_808E38C(struct MapObject *); static u8 sub_808E8F4(const struct SpritePalette *); static u8 FindFieldObjectPaletteIndexByTag(u16); +static void sub_808EAB0(u16, u8); // ROM data @@ -1211,3 +1212,8 @@ void npc_load_two_palettes__and_record(u16 tag, u8 slot) } } } + +static void sub_808EAB0(u16 tag, u8 slot) +{ + pal_patch_for_npc(tag, slot); +} From 43c3b9fdff01c05860969d80fbc6ae0b0dbbcb90 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Fri, 8 Sep 2017 21:25:20 -0400 Subject: [PATCH 055/191] unref_sub_808EAC4 --- asm/field_map_obj.s | 20 -------------------- src/field_map_obj.c | 8 ++++++++ 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 2bf3ce572..57ea7af2e 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,26 +5,6 @@ .text - thumb_func_start sub_808EAC4 -sub_808EAC4: @ 808EAC4 - push {r4,lr} - ldrh r3, [r0, 0x10] - strh r3, [r0, 0x14] - ldrh r4, [r0, 0x12] - strh r4, [r0, 0x16] - lsls r1, 16 - asrs r1, 16 - adds r1, r3 - strh r1, [r0, 0x10] - lsls r2, 16 - asrs r2, 16 - adds r2, r4 - strh r2, [r0, 0x12] - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_808EAC4 - thumb_func_start npc_coords_shift @ void npc_coords_shift(struct npc_state *fieldObject, u16 x, u16 y) npc_coords_shift: @ 808EAE4 diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 8042348f2..e5025fccf 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -1217,3 +1217,11 @@ static void sub_808EAB0(u16 tag, u8 slot) { pal_patch_for_npc(tag, slot); } + +void unref_sub_808EAC4(struct MapObject *mapObject, s16 x, s16 y) +{ + mapObject->coords3.x = mapObject->coords2.x; + mapObject->coords3.y = mapObject->coords2.y; + mapObject->coords2.x = x + mapObject->coords3.x; + mapObject->coords2.y = y + mapObject->coords3.y; +} From 70e982d1fabc62a6d145b1a8dda866931886bb4d Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Fri, 8 Sep 2017 21:27:02 -0400 Subject: [PATCH 056/191] npc_coords_shift --- asm/field_map_obj.s | 12 ------------ include/field_map_obj.h | 1 + src/field_map_obj.c | 13 +++++++++++-- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 57ea7af2e..f0cd4f07b 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,18 +5,6 @@ .text - thumb_func_start npc_coords_shift -@ void npc_coords_shift(struct npc_state *fieldObject, u16 x, u16 y) -npc_coords_shift: @ 808EAE4 - ldrh r3, [r0, 0x10] - strh r3, [r0, 0x14] - ldrh r3, [r0, 0x12] - strh r3, [r0, 0x16] - strh r1, [r0, 0x10] - strh r2, [r0, 0x12] - bx lr - thumb_func_end npc_coords_shift - thumb_func_start npc_coords_set @ void npc_coords_set(struct npc_state *fieldObject, u16 x, u16 y) npc_coords_set: @ 808EAF4 diff --git a/include/field_map_obj.h b/include/field_map_obj.h index c5b23103f..4eb6f85d5 100644 --- a/include/field_map_obj.h +++ b/include/field_map_obj.h @@ -44,6 +44,7 @@ void sub_808E7E4(u8, u8, u8); void sub_808E78C(u8, u8, u8, u8); void sub_808E75C(s16, s16); void FieldObjectGetLocalIdAndMap(struct MapObject *, u8 *, u8 *, u8 *); +void npc_coords_shift(struct MapObject *, s16, s16); // Exported data declarations diff --git a/src/field_map_obj.c b/src/field_map_obj.c index e5025fccf..6298c977b 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -1222,6 +1222,15 @@ void unref_sub_808EAC4(struct MapObject *mapObject, s16 x, s16 y) { mapObject->coords3.x = mapObject->coords2.x; mapObject->coords3.y = mapObject->coords2.y; - mapObject->coords2.x = x + mapObject->coords3.x; - mapObject->coords2.y = y + mapObject->coords3.y; + mapObject->coords2.x += x; + mapObject->coords2.y += y; } + +void npc_coords_shift(struct MapObject *mapObject, s16 x, s16 y) +{ + mapObject->coords3.x = mapObject->coords2.x; + mapObject->coords3.y = mapObject->coords2.y; + mapObject->coords2.x = x; + mapObject->coords2.y = y; +} + From 019935fb73b7a065c735045a80d5124132ee6e5e Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Fri, 8 Sep 2017 21:28:22 -0400 Subject: [PATCH 057/191] npc_coords_set --- asm/field_map_obj.s | 14 -------------- src/field_map_obj.c | 8 ++++++++ 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index f0cd4f07b..fb93b5333 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,20 +5,6 @@ .text - thumb_func_start npc_coords_set -@ void npc_coords_set(struct npc_state *fieldObject, u16 x, u16 y) -npc_coords_set: @ 808EAF4 - lsls r1, 16 - lsrs r1, 16 - lsls r2, 16 - lsrs r2, 16 - strh r1, [r0, 0x14] - strh r2, [r0, 0x16] - strh r1, [r0, 0x10] - strh r2, [r0, 0x12] - bx lr - thumb_func_end npc_coords_set - thumb_func_start sub_808EB08 sub_808EB08: @ 808EB08 push {r4-r7,lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 6298c977b..c7d9e32d7 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -1234,3 +1234,11 @@ void npc_coords_shift(struct MapObject *mapObject, s16 x, s16 y) mapObject->coords2.y = y; } +/*static*/ void npc_coords_set(struct MapObject *mapObject, s16 x, s16 y) +{ + mapObject->coords3.x = x; + mapObject->coords3.y = y; + mapObject->coords2.x = x; + mapObject->coords2.y = y; +} + From ba6987b7335d6b3f0a641e0dee62be37bff4ffd8 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Fri, 8 Sep 2017 21:35:46 -0400 Subject: [PATCH 058/191] sub_808EB08 --- asm/field_map_obj.s | 79 ----------------------------------------- include/field_map_obj.h | 1 + src/field_map_obj.c | 20 +++++++++++ 3 files changed, 21 insertions(+), 79 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index fb93b5333..d61478b62 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,85 +5,6 @@ .text - thumb_func_start sub_808EB08 -sub_808EB08: @ 808EB08 - push {r4-r7,lr} - mov r7, r8 - push {r7} - adds r6, r0, 0 - adds r4, r1, 0 - adds r5, r2, 0 - lsls r4, 16 - lsrs r4, 16 - lsls r5, 16 - lsrs r5, 16 - ldrb r1, [r6, 0x4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r1, =gSprites - adds r7, r0, r1 - ldrb r0, [r6, 0x5] - bl GetFieldObjectGraphicsInfo - mov r8, r0 - lsls r4, 16 - asrs r4, 16 - lsls r5, 16 - asrs r5, 16 - adds r0, r6, 0 - adds r1, r4, 0 - adds r2, r5, 0 - bl npc_coords_set - movs r1, 0x10 - ldrsh r0, [r6, r1] - movs r2, 0x12 - ldrsh r1, [r6, r2] - adds r2, r7, 0 - adds r2, 0x20 - adds r3, r7, 0 - adds r3, 0x22 - bl sub_8093038 - mov r1, r8 - ldrh r0, [r1, 0x8] - lsls r0, 16 - asrs r0, 17 - negs r0, r0 - adds r1, r7, 0 - adds r1, 0x28 - strb r0, [r1] - mov r2, r8 - ldrh r0, [r2, 0xA] - lsls r0, 16 - asrs r0, 17 - negs r0, r0 - adds r2, r7, 0 - adds r2, 0x29 - strb r0, [r2] - ldrh r0, [r7, 0x20] - adds r0, 0x8 - strh r0, [r7, 0x20] - ldrh r1, [r7, 0x22] - adds r1, 0x10 - movs r0, 0 - ldrsb r0, [r2, r0] - adds r0, r1 - strh r0, [r7, 0x22] - adds r0, r6, 0 - bl sub_808E38C - ldrb r0, [r6, 0x1] - lsrs r0, 7 - cmp r0, 0 - beq _0808EB9A - bl CameraObjectReset1 -_0808EB9A: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_808EB08 - thumb_func_start sub_808EBA8 sub_808EBA8: @ 808EBA8 push {r4,r5,lr} diff --git a/include/field_map_obj.h b/include/field_map_obj.h index 4eb6f85d5..b292d200d 100644 --- a/include/field_map_obj.h +++ b/include/field_map_obj.h @@ -45,6 +45,7 @@ void sub_808E78C(u8, u8, u8, u8); void sub_808E75C(s16, s16); void FieldObjectGetLocalIdAndMap(struct MapObject *, u8 *, u8 *, u8 *); void npc_coords_shift(struct MapObject *, s16, s16); +void sub_808EB08(struct MapObject *, s16, s16); // Exported data declarations diff --git a/src/field_map_obj.c b/src/field_map_obj.c index c7d9e32d7..acfbd60a7 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -1242,3 +1242,23 @@ void npc_coords_shift(struct MapObject *mapObject, s16 x, s16 y) mapObject->coords2.y = y; } +void sub_808EB08(struct MapObject *mapObject, s16 x, s16 y) +{ + struct Sprite *sprite; + const struct MapObjectGraphicsInfo *graphicsInfo; + + sprite = &gSprites[mapObject->spriteId]; + graphicsInfo = GetFieldObjectGraphicsInfo(mapObject->graphicsId); + npc_coords_set(mapObject, x, y); + sub_8093038(mapObject->coords2.x, mapObject->coords2.y, &sprite->pos1.x, &sprite->pos1.y); + sprite->centerToCornerVecX = -(graphicsInfo->width >> 1); + sprite->centerToCornerVecY = -(graphicsInfo->height >> 1); + sprite->pos1.x += 8; + sprite->pos1.y += 16 + sprite->centerToCornerVecY; + sub_808E38C(mapObject); + if (mapObject->mapobj_bit_15) + { + CameraObjectReset1(); + } +} + From 1ed1fbab1ca140edebb7ec1ebfabaaaf04f9c054 Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 10 Sep 2017 15:12:48 -0400 Subject: [PATCH 059/191] sub_808EBA8 --- asm/field_map_obj.s | 44 -------------------------------------------- src/field_map_obj.c | 12 ++++++++++++ 2 files changed, 12 insertions(+), 44 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index d61478b62..bb7c95ef4 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,50 +5,6 @@ .text - thumb_func_start sub_808EBA8 -sub_808EBA8: @ 808EBA8 - push {r4,r5,lr} - sub sp, 0x4 - ldr r4, [sp, 0x10] - lsls r0, 24 - lsrs r0, 24 - lsls r1, 24 - lsrs r1, 24 - lsls r2, 24 - lsrs r2, 24 - lsls r3, 16 - lsrs r5, r3, 16 - lsls r4, 16 - lsrs r4, 16 - mov r3, sp - bl TryGetFieldObjectIdByLocalIdAndMap - lsls r0, 24 - cmp r0, 0 - bne _0808EBF0 - lsls r1, r5, 16 - lsls r2, r4, 16 - mov r0, sp - ldrb r3, [r0] - lsls r0, r3, 3 - adds r0, r3 - lsls r0, 2 - ldr r3, =gMapObjects - adds r0, r3 - movs r3, 0xE0 - lsls r3, 11 - adds r1, r3 - asrs r1, 16 - adds r2, r3 - asrs r2, 16 - bl sub_808EB08 -_0808EBF0: - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_808EBA8 - thumb_func_start npc_coords_shift_still @ void npc_coords_shift_still(struct npc_state *fieldObject) npc_coords_shift_still: @ 808EBFC diff --git a/src/field_map_obj.c b/src/field_map_obj.c index acfbd60a7..7465370b9 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -1262,3 +1262,15 @@ void sub_808EB08(struct MapObject *mapObject, s16 x, s16 y) } } +void sub_808EBA8(u8 localId, u8 mapNum, u8 mapGroup, s16 x, s16 y) +{ + u8 mapObjectId; + + if (!TryGetFieldObjectIdByLocalIdAndMap(localId, mapNum, mapGroup, &mapObjectId)) + { + x += 7; + y += 7; + sub_808EB08(&gMapObjects[mapObjectId], x, y); + } +} + From 5bb58867748b91de2c20860d73b1a36896f11dd1 Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 10 Sep 2017 15:14:46 -0400 Subject: [PATCH 060/191] npc_coords_shift_still --- asm/field_map_obj.s | 13 ------------- src/field_map_obj.c | 5 +++++ 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index bb7c95ef4..c15cd3320 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,19 +5,6 @@ .text - thumb_func_start npc_coords_shift_still -@ void npc_coords_shift_still(struct npc_state *fieldObject) -npc_coords_shift_still: @ 808EBFC - push {lr} - movs r2, 0x10 - ldrsh r1, [r0, r2] - movs r3, 0x12 - ldrsh r2, [r0, r3] - bl npc_coords_shift - pop {r0} - bx r0 - thumb_func_end npc_coords_shift_still - thumb_func_start UpdateFieldObjectCoordsForCameraUpdate @ void UpdateFieldObjectCoordsForCameraUpdate() UpdateFieldObjectCoordsForCameraUpdate: @ 808EC10 diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 7465370b9..1a4ab1a74 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -1274,3 +1274,8 @@ void sub_808EBA8(u8 localId, u8 mapNum, u8 mapGroup, s16 x, s16 y) } } +void npc_coords_shift_still(struct MapObject *mapObject) +{ + npc_coords_shift(mapObject, mapObject->coords2.x, mapObject->coords2.y); +} + From 79b19a36b864abb359f7ec2122dea851f8ac5e7b Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 10 Sep 2017 15:35:21 -0400 Subject: [PATCH 061/191] UpdateFieldObjectCoordsForCameraUpdate --- asm/field_effect_helpers.s | 4 +-- asm/field_map_obj.s | 56 -------------------------------------- asm/field_tasks.s | 2 +- asm/fieldmap.s | 14 +++++----- include/global.fieldmap.h | 3 +- src/field_map_obj.c | 25 +++++++++++++++++ sym_ewram.txt | 2 +- 7 files changed, 38 insertions(+), 68 deletions(-) diff --git a/asm/field_effect_helpers.s b/asm/field_effect_helpers.s index cef6287ff..04307fde5 100644 --- a/asm/field_effect_helpers.s +++ b/asm/field_effect_helpers.s @@ -827,7 +827,7 @@ unc_grass_normal: @ 8154550 lsrs r4, r0, 8 lsls r0, 24 lsrs r7, r0, 24 - ldr r3, =gUnknown_02037334 + ldr r3, =gCamera ldrb r1, [r3] movs r0, 0x1 ands r0, r1 @@ -1166,7 +1166,7 @@ unc_grass_tall: @ 8154800 lsrs r7, r0, 8 lsls r0, 24 lsrs r6, r0, 24 - ldr r3, =gUnknown_02037334 + ldr r3, =gCamera ldrb r1, [r3] movs r0, 0x1 ands r0, r1 diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index c15cd3320..927625ff3 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,62 +5,6 @@ .text - thumb_func_start UpdateFieldObjectCoordsForCameraUpdate -@ void UpdateFieldObjectCoordsForCameraUpdate() -UpdateFieldObjectCoordsForCameraUpdate: @ 808EC10 - push {r4,r5,lr} - ldr r2, =gUnknown_02037334 - ldrb r1, [r2] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _0808EC68 - movs r3, 0 - ldr r5, =gMapObjects - movs r0, 0x4 - ldrsh r4, [r2, r0] - movs r0, 0x8 - ldrsh r1, [r2, r0] -_0808EC2A: - lsls r0, r3, 3 - adds r0, r3 - lsls r0, 2 - adds r2, r0, r5 - ldrb r0, [r2] - lsls r0, 31 - cmp r0, 0 - beq _0808EC5E - ldrh r0, [r2, 0xC] - subs r0, r4 - strh r0, [r2, 0xC] - ldrh r0, [r2, 0xE] - subs r0, r1 - strh r0, [r2, 0xE] - ldrh r0, [r2, 0x10] - subs r0, r4 - strh r0, [r2, 0x10] - ldrh r0, [r2, 0x12] - subs r0, r1 - strh r0, [r2, 0x12] - ldrh r0, [r2, 0x14] - subs r0, r4 - strh r0, [r2, 0x14] - ldrh r0, [r2, 0x16] - subs r0, r1 - strh r0, [r2, 0x16] -_0808EC5E: - adds r0, r3, 0x1 - lsls r0, 24 - lsrs r3, r0, 24 - cmp r3, 0xF - bls _0808EC2A -_0808EC68: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end UpdateFieldObjectCoordsForCameraUpdate - thumb_func_start GetFieldObjectIdByXYZ @ u8 GetFieldObjectIdByXYZ(u16 x, u16 y, u8 z) GetFieldObjectIdByXYZ: @ 808EC78 diff --git a/asm/field_tasks.s b/asm/field_tasks.s index fb99bbc0e..d053f565f 100644 --- a/asm/field_tasks.s +++ b/asm/field_tasks.s @@ -1858,7 +1858,7 @@ _0809E6F8: cmp r6, 0xD ble _0809E6F8 _0809E708: - ldr r2, =gUnknown_02037334 + ldr r2, =gCamera ldrb r1, [r2] movs r0, 0x1 ands r0, r1 diff --git a/asm/fieldmap.s b/asm/fieldmap.s index d2416248f..dbb8a3fa3 100644 --- a/asm/fieldmap.s +++ b/asm/fieldmap.s @@ -1508,12 +1508,12 @@ CameraMove: @ 808887C push {r5-r7} mov r10, r0 mov r9, r1 - ldr r1, =gUnknown_02037334 + ldr r1, =gCamera ldrb r0, [r1] movs r1, 0x2 negs r1, r1 ands r1, r0 - ldr r2, =gUnknown_02037334 + ldr r2, =gCamera strb r1, [r2] mov r0, r10 mov r1, r9 @@ -1556,23 +1556,23 @@ _080888C4: ldrb r0, [r4, 0x8] ldrb r1, [r4, 0x9] bl mliX_load_map - ldr r1, =gUnknown_02037334 + ldr r1, =gCamera ldrb r0, [r1] movs r1, 0x1 orrs r0, r1 - ldr r2, =gUnknown_02037334 + ldr r2, =gCamera strb r0, [r2] ldr r0, =gSaveBlock1Ptr ldr r1, [r0] movs r2, 0 ldrsh r0, [r1, r2] subs r5, r0 - ldr r0, =gUnknown_02037334 + ldr r0, =gCamera str r5, [r0, 0x4] movs r2, 0x2 ldrsh r0, [r1, r2] subs r6, r0 - ldr r0, =gUnknown_02037334 + ldr r0, =gCamera str r6, [r0, 0x8] ldrh r0, [r1] add r0, r10 @@ -1583,7 +1583,7 @@ _080888C4: mov r0, r8 bl sub_80885C4 _08088932: - ldr r0, =gUnknown_02037334 + ldr r0, =gCamera ldrb r0, [r0] lsls r0, 31 lsrs r0, 31 diff --git a/include/global.fieldmap.h b/include/global.fieldmap.h index b0a36aa55..5a7a75ccb 100644 --- a/include/global.fieldmap.h +++ b/include/global.fieldmap.h @@ -379,7 +379,7 @@ struct PlayerAvatar /* 0x202E858 */ struct Camera { - bool8 field_0:1; + bool8 active:1; s32 x; s32 y; }; @@ -388,5 +388,6 @@ extern struct MapObject gMapObjects[NUM_FIELD_OBJECTS]; extern u8 gSelectedMapObject; extern struct MapHeader gMapHeader; extern struct PlayerAvatar gPlayerAvatar; +extern struct Camera gCamera; #endif // GUARD_GLOBAL_FIELDMAP_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 1a4ab1a74..ced0ecb27 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -1279,3 +1279,28 @@ void npc_coords_shift_still(struct MapObject *mapObject) npc_coords_shift(mapObject, mapObject->coords2.x, mapObject->coords2.y); } +void UpdateFieldObjectCoordsForCameraUpdate(void) +{ + u8 i; + s16 dx; + s16 dy; + + if (gCamera.active) + { + dx = gCamera.x; + dy = gCamera.y; + for (i = 0; i < NUM_FIELD_OBJECTS; i ++) + { + if (gMapObjects[i].active) + { + gMapObjects[i].coords1.x -= dx; + gMapObjects[i].coords1.y -= dy; + gMapObjects[i].coords2.x -= dx; + gMapObjects[i].coords2.y -= dy; + gMapObjects[i].coords3.x -= dx; + gMapObjects[i].coords3.y -= dy; + } + } + } +} + diff --git a/sym_ewram.txt b/sym_ewram.txt index f1a138b7a..ccbb7f3b6 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -749,7 +749,7 @@ gUnknown_02032318: @ 2032318 gMapHeader: @ 2037318 .space 0x1C -gUnknown_02037334: @ 2037334 +gCamera: @ 2037334 .space 0xC gUnknown_02037340: @ 2037340 From d8e22380869e4e04c2ebbc71fae43cd38ed646a9 Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 10 Sep 2017 15:54:41 -0400 Subject: [PATCH 062/191] FieldObjectDoesZCoordMatch --- asm/field_map_obj.s | 83 --------------------------------------------- src/field_map_obj.c | 25 ++++++++++++++ 2 files changed, 25 insertions(+), 83 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 927625ff3..895607305 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,89 +5,6 @@ .text - thumb_func_start GetFieldObjectIdByXYZ -@ u8 GetFieldObjectIdByXYZ(u16 x, u16 y, u8 z) -GetFieldObjectIdByXYZ: @ 808EC78 - push {r4-r7,lr} - mov r7, r8 - push {r7} - lsls r0, 16 - lsrs r7, r0, 16 - lsls r1, 16 - lsrs r6, r1, 16 - lsls r2, 24 - lsrs r5, r2, 24 - movs r4, 0 - ldr r0, =gMapObjects - mov r8, r0 -_0808EC90: - lsls r0, r4, 3 - adds r0, r4 - lsls r0, 2 - mov r2, r8 - adds r1, r0, r2 - ldrb r0, [r1] - lsls r0, 31 - cmp r0, 0 - beq _0808ECC8 - movs r2, 0x10 - ldrsh r0, [r1, r2] - cmp r0, r7 - bne _0808ECC8 - movs r2, 0x12 - ldrsh r0, [r1, r2] - cmp r0, r6 - bne _0808ECC8 - adds r0, r1, 0 - adds r1, r5, 0 - bl FieldObjectDoesZCoordMatch - lsls r0, 24 - cmp r0, 0 - beq _0808ECC8 - adds r0, r4, 0 - b _0808ECD4 - .pool -_0808ECC8: - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0xF - bls _0808EC90 - movs r0, 0x10 -_0808ECD4: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end GetFieldObjectIdByXYZ - - thumb_func_start FieldObjectDoesZCoordMatch -@ bool8 FieldObjectDoesZCoordMatch(struct npc_state *fieldObject) -FieldObjectDoesZCoordMatch: @ 808ECE0 - push {lr} - lsls r1, 24 - lsrs r1, 24 - ldrb r2, [r0, 0xB] - movs r0, 0xF - ands r0, r2 - cmp r0, 0 - beq _0808ED00 - cmp r1, 0 - beq _0808ED00 - lsls r0, r2, 28 - lsrs r0, 28 - cmp r0, r1 - beq _0808ED00 - movs r0, 0 - b _0808ED02 -_0808ED00: - movs r0, 0x1 -_0808ED02: - pop {r1} - bx r1 - thumb_func_end FieldObjectDoesZCoordMatch - thumb_func_start UpdateFieldObjectsForCameraUpdate @ void UpdateFieldObjectsForCameraUpdate(u16 movingCameraOffsetX, u16 movingCameraOffsetY) UpdateFieldObjectsForCameraUpdate: @ 808ED08 diff --git a/src/field_map_obj.c b/src/field_map_obj.c index ced0ecb27..a48a2506e 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -47,6 +47,7 @@ static void SetPlayerAvatarFieldObjectIdAndObjectId(u8, u8); static u8 sub_808E8F4(const struct SpritePalette *); static u8 FindFieldObjectPaletteIndexByTag(u16); static void sub_808EAB0(u16, u8); +static bool8 FieldObjectDoesZCoordMatch(struct MapObject *, u8); // ROM data @@ -1304,3 +1305,27 @@ void UpdateFieldObjectCoordsForCameraUpdate(void) } } +u8 GetFieldObjectIdByXYZ(u16 x, u16 y, u8 z) +{ + u8 i; + for (i = 0; i < NUM_FIELD_OBJECTS; i ++) + { + if (gMapObjects[i].active) + { + if (gMapObjects[i].coords2.x == x && gMapObjects[i].coords2.y == y && FieldObjectDoesZCoordMatch(&gMapObjects[i], z)) + { + return i; + } + } + } + return NUM_FIELD_OBJECTS; +} + +static bool8 FieldObjectDoesZCoordMatch(struct MapObject *mapObject, u8 z) +{ + if (mapObject->mapobj_unk_0B_0 != 0 && z != 0 && mapObject->mapobj_unk_0B_0 != z) + { + return FALSE; + } + return TRUE; +} From 5a5ea8c740ba17a542c55aa81a576af18cf76b45 Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 10 Sep 2017 15:56:03 -0400 Subject: [PATCH 063/191] UpdateFieldObjectsForCameraUpdate --- asm/field_map_obj.s | 24 ------------------------ src/field_map_obj.c | 7 +++++++ 2 files changed, 7 insertions(+), 24 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 895607305..400fec15a 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,30 +5,6 @@ .text - thumb_func_start UpdateFieldObjectsForCameraUpdate -@ void UpdateFieldObjectsForCameraUpdate(u16 movingCameraOffsetX, u16 movingCameraOffsetY) -UpdateFieldObjectsForCameraUpdate: @ 808ED08 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - lsls r4, 16 - lsrs r4, 16 - lsls r5, 16 - lsrs r5, 16 - bl UpdateFieldObjectCoordsForCameraUpdate - lsls r4, 16 - asrs r4, 16 - lsls r5, 16 - asrs r5, 16 - adds r0, r4, 0 - adds r1, r5, 0 - bl SpawnFieldObjectsInView - bl RemoveFieldObjectsOutsideView - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end UpdateFieldObjectsForCameraUpdate - thumb_func_start AddCameraObject @ u8 AddCameraObject(u8 followedObjectId) AddCameraObject: @ 808ED34 diff --git a/src/field_map_obj.c b/src/field_map_obj.c index a48a2506e..8214c5efa 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -1329,3 +1329,10 @@ static bool8 FieldObjectDoesZCoordMatch(struct MapObject *mapObject, u8 z) } return TRUE; } + +void UpdateFieldObjectsForCameraUpdate(s16 x, s16 y) +{ + UpdateFieldObjectCoordsForCameraUpdate(); + SpawnFieldObjectsInView(x, y); + RemoveFieldObjectsOutsideView(); +} From 9e0a17109840593a034bd42e96ffbcf73bc16b1c Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 10 Sep 2017 16:02:20 -0400 Subject: [PATCH 064/191] AddCameraObject --- asm/field_map_obj.s | 34 ---------------------------------- include/data3.h | 1 + src/field_map_obj.c | 10 ++++++++++ 3 files changed, 11 insertions(+), 34 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 400fec15a..d31a53f78 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,40 +5,6 @@ .text - thumb_func_start AddCameraObject -@ u8 AddCameraObject(u8 followedObjectId) -AddCameraObject: @ 808ED34 - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r0, =gUnknown_084975D4 - movs r1, 0 - movs r2, 0 - movs r3, 0x4 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gSprites - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r2 - movs r2, 0x3E - adds r2, r1 - mov r12, r2 - ldrb r2, [r2] - movs r3, 0x4 - orrs r2, r3 - mov r3, r12 - strb r2, [r3] - strh r4, [r1, 0x2E] - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end AddCameraObject - thumb_func_start ObjectCB_CameraObject @ void ObjectCB_CameraObject(struct obj *object) ObjectCB_CameraObject: @ 808ED78 diff --git a/include/data3.h b/include/data3.h index f44a61263..343f145c0 100644 --- a/include/data3.h +++ b/include/data3.h @@ -14,5 +14,6 @@ extern const struct SpritePalette gUnknown_0850BBC8[]; extern const struct PairedPalettes gUnknown_0850BD00[15]; extern const struct PairedPalettes gUnknown_0850BD78[15]; extern u8 gUnknown_084975C4[0x10]; +extern const struct SpriteTemplate gUnknown_084975D4; #endif //POKEEMERALD_DATA3_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 8214c5efa..933908886 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -1336,3 +1336,13 @@ void UpdateFieldObjectsForCameraUpdate(s16 x, s16 y) SpawnFieldObjectsInView(x, y); RemoveFieldObjectsOutsideView(); } + +u8 AddCameraObject(u8 data0) +{ + u8 spriteId; + + spriteId = CreateSprite(&gUnknown_084975D4, 0, 0, 4); + gSprites[spriteId].invisible = TRUE; + gSprites[spriteId].data0 = data0; + return spriteId; +} From c7b1a8c3daa5183f8e522d6d6fcba1ffea79e72f Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 10 Sep 2017 16:13:19 -0400 Subject: [PATCH 065/191] ObjectCB_CameraObject --- asm/field_map_obj.s | 114 -------------------------------------------- include/data3.h | 1 + src/field_map_obj.c | 45 ++++++++++++++++- 3 files changed, 44 insertions(+), 116 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index d31a53f78..38b328cdc 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,120 +5,6 @@ .text - thumb_func_start ObjectCB_CameraObject -@ void ObjectCB_CameraObject(struct obj *object) -ObjectCB_CameraObject: @ 808ED78 - push {r4,r5,lr} - sub sp, 0xC - mov r2, sp - ldr r1, =gUnknown_084975EC - ldm r1!, {r3-r5} - stm r2!, {r3-r5} - movs r2, 0x30 - ldrsh r1, [r0, r2] - lsls r1, 2 - add r1, sp - ldr r1, [r1] - bl _call_via_r1 - add sp, 0xC - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end ObjectCB_CameraObject - - thumb_func_start CameraObject_0 -@ void CameraObject_0(struct obj *object) -CameraObject_0: @ 808EDA0 - push {lr} - ldr r3, =gSprites - movs r1, 0x2E - ldrsh r2, [r0, r1] - lsls r1, r2, 4 - adds r1, r2 - lsls r1, 2 - adds r1, r3 - ldrh r1, [r1, 0x20] - strh r1, [r0, 0x20] - lsls r1, r2, 4 - adds r1, r2 - lsls r1, 2 - adds r1, r3 - ldrh r1, [r1, 0x22] - strh r1, [r0, 0x22] - adds r3, r0, 0 - adds r3, 0x3E - ldrb r1, [r3] - movs r2, 0x4 - orrs r1, r2 - strb r1, [r3] - movs r1, 0x1 - strh r1, [r0, 0x30] - bl CameraObject_1 - pop {r0} - bx r0 - .pool - thumb_func_end CameraObject_0 - - thumb_func_start CameraObject_1 -@ void CameraObject_1(struct obj *object) -CameraObject_1: @ 808EDDC - push {r4,r5,lr} - ldr r3, =gSprites - movs r1, 0x2E - ldrsh r2, [r0, r1] - lsls r1, r2, 4 - adds r1, r2 - lsls r1, 2 - adds r1, r3 - ldrh r3, [r1, 0x22] - ldrh r2, [r0, 0x20] - ldrh r4, [r1, 0x20] - movs r5, 0x20 - ldrsh r1, [r1, r5] - subs r1, r2 - strh r1, [r0, 0x32] - ldrh r2, [r0, 0x22] - lsls r1, r3, 16 - asrs r1, 16 - subs r1, r2 - strh r1, [r0, 0x34] - strh r4, [r0, 0x20] - strh r3, [r0, 0x22] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end CameraObject_1 - - thumb_func_start CameraObject_2 -@ void CameraObject_2(struct obj *object) -CameraObject_2: @ 808EE14 - push {r4,lr} - ldr r4, =gSprites - movs r1, 0x2E - ldrsh r2, [r0, r1] - lsls r1, r2, 4 - adds r1, r2 - lsls r1, 2 - adds r1, r4 - ldrh r1, [r1, 0x20] - movs r3, 0 - strh r1, [r0, 0x20] - lsls r1, r2, 4 - adds r1, r2 - lsls r1, 2 - adds r1, r4 - ldrh r1, [r1, 0x22] - strh r1, [r0, 0x22] - strh r3, [r0, 0x32] - strh r3, [r0, 0x34] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end CameraObject_2 - thumb_func_start FindCameraObject @ struct obj *FindCameraObject() FindCameraObject: @ 808EE44 diff --git a/include/data3.h b/include/data3.h index 343f145c0..6b1569486 100644 --- a/include/data3.h +++ b/include/data3.h @@ -15,5 +15,6 @@ extern const struct PairedPalettes gUnknown_0850BD00[15]; extern const struct PairedPalettes gUnknown_0850BD78[15]; extern u8 gUnknown_084975C4[0x10]; extern const struct SpriteTemplate gUnknown_084975D4; +extern void (*const gUnknown_084975EC[3])(struct Sprite *); #endif //POKEEMERALD_DATA3_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 933908886..3fc962336 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -48,6 +48,9 @@ static u8 sub_808E8F4(const struct SpritePalette *); static u8 FindFieldObjectPaletteIndexByTag(u16); static void sub_808EAB0(u16, u8); static bool8 FieldObjectDoesZCoordMatch(struct MapObject *, u8); +//static void CameraObject_0(struct Sprite *); +/*static*/ void CameraObject_1(struct Sprite *); +//static void CameraObject_2(struct Sprite *); // ROM data @@ -1337,12 +1340,50 @@ void UpdateFieldObjectsForCameraUpdate(s16 x, s16 y) RemoveFieldObjectsOutsideView(); } -u8 AddCameraObject(u8 data0) +u8 AddCameraObject(u8 linkedSpriteId) { u8 spriteId; spriteId = CreateSprite(&gUnknown_084975D4, 0, 0, 4); gSprites[spriteId].invisible = TRUE; - gSprites[spriteId].data0 = data0; + gSprites[spriteId].data0 = linkedSpriteId; return spriteId; } + +void ObjectCB_CameraObject(struct Sprite *sprite) +{ + void (*callbacks[ARRAY_COUNT(gUnknown_084975EC)])(struct Sprite *); + + memcpy(callbacks, gUnknown_084975EC, sizeof gUnknown_084975EC); + callbacks[sprite->data1](sprite); +} + +/*static*/ void CameraObject_0(struct Sprite *sprite) +{ + sprite->pos1.x = gSprites[sprite->data0].pos1.x; + sprite->pos1.y = gSprites[sprite->data0].pos1.y; + sprite->invisible = TRUE; + sprite->data1 = 1; + CameraObject_1(sprite); +} + +/*static*/ void CameraObject_1(struct Sprite *sprite) +{ + s16 x; + s16 y; + + y = gSprites[sprite->data0].pos1.y; + x = gSprites[sprite->data0].pos1.x; + sprite->data2 = x - sprite->pos1.x; + sprite->data3 = y - sprite->pos1.y; + sprite->pos1.x = x; + sprite->pos1.y = y; +} + +/*static*/ void CameraObject_2(struct Sprite *sprite) +{ + sprite->pos1.x = gSprites[sprite->data0].pos1.x; + sprite->pos1.y = gSprites[sprite->data0].pos1.y; + sprite->data2 = 0; + sprite->data3 = 0; +} From 4dfae8b9e450467942b227895853c37043bee401 Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 10 Sep 2017 16:32:26 -0400 Subject: [PATCH 066/191] FindCameraObject --- asm/field_map_obj.s | 40 ---------------------------------------- src/field_map_obj.c | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 40 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 38b328cdc..912d28077 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,46 +5,6 @@ .text - thumb_func_start FindCameraObject -@ struct obj *FindCameraObject() -FindCameraObject: @ 808EE44 - push {r4,r5,lr} - movs r3, 0 - ldr r4, =gSprites - adds r5, r4, 0 - adds r5, 0x1C -_0808EE4E: - lsls r0, r3, 4 - adds r0, r3 - lsls r1, r0, 2 - adds r2, r1, r4 - adds r0, r2, 0 - adds r0, 0x3E - ldrb r0, [r0] - lsls r0, 31 - cmp r0, 0 - beq _0808EE78 - adds r0, r1, r5 - ldr r1, [r0] - ldr r0, =ObjectCB_CameraObject - cmp r1, r0 - bne _0808EE78 - adds r0, r2, 0 - b _0808EE84 - .pool -_0808EE78: - adds r0, r3, 0x1 - lsls r0, 24 - lsrs r3, r0, 24 - cmp r3, 0x3F - bls _0808EE4E - movs r0, 0 -_0808EE84: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end FindCameraObject - thumb_func_start CameraObjectReset1 @ void CameraObjectReset1() CameraObjectReset1: @ 808EE8C diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 3fc962336..f600db934 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -1387,3 +1387,17 @@ void ObjectCB_CameraObject(struct Sprite *sprite) sprite->data2 = 0; sprite->data3 = 0; } + +/*static*/ struct Sprite *FindCameraObject(void) +{ + u8 spriteId; + + for (spriteId = 0; spriteId < MAX_SPRITES; spriteId ++) + { + if (gSprites[spriteId].inUse && gSprites[spriteId].callback == ObjectCB_CameraObject) + { + return &gSprites[spriteId]; + } + } + return NULL; +} From a89da3ae31144d032f942fb963acc34f23818a91 Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 10 Sep 2017 16:36:19 -0400 Subject: [PATCH 067/191] Functions operating on the camera object --- asm/field_map_obj.s | 64 --------------------------------------------- src/field_map_obj.c | 43 +++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 65 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 912d28077..cdec058de 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,70 +5,6 @@ .text - thumb_func_start CameraObjectReset1 -@ void CameraObjectReset1() -CameraObjectReset1: @ 808EE8C - push {lr} - bl FindCameraObject - adds r2, r0, 0 - cmp r2, 0 - beq _0808EEA4 - movs r0, 0 - strh r0, [r2, 0x30] - ldr r1, [r2, 0x1C] - adds r0, r2, 0 - bl _call_via_r1 -_0808EEA4: - pop {r0} - bx r0 - thumb_func_end CameraObjectReset1 - - thumb_func_start CameraObjectSetFollowedObjectId -@ void CameraObjectSetFollowedObjectId(u8 objectId) -CameraObjectSetFollowedObjectId: @ 808EEA8 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - bl FindCameraObject - cmp r0, 0 - beq _0808EEBC - strh r4, [r0, 0x2E] - bl CameraObjectReset1 -_0808EEBC: - pop {r4} - pop {r0} - bx r0 - thumb_func_end CameraObjectSetFollowedObjectId - - thumb_func_start CameraObjectGetFollowedObjectId -@ u8 CameraObjectGetFollowedObjectId() -CameraObjectGetFollowedObjectId: @ 808EEC4 - push {lr} - bl FindCameraObject - cmp r0, 0 - beq _0808EED6 - ldrh r0, [r0, 0x2E] - lsls r0, 24 - lsrs r0, 24 - b _0808EED8 -_0808EED6: - movs r0, 0x40 -_0808EED8: - pop {r1} - bx r1 - thumb_func_end CameraObjectGetFollowedObjectId - - thumb_func_start CameraObjectReset2 -@ void CameraObjectReset2() -CameraObjectReset2: @ 808EEDC - push {lr} - bl FindCameraObject - movs r1, 0x2 - strh r1, [r0, 0x30] - pop {r0} - bx r0 - thumb_func_end CameraObjectReset2 - thumb_func_start sub_808EEEC sub_808EEEC: @ 808EEEC push {r4-r7,lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index f600db934..40b12b1b3 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -1388,7 +1388,7 @@ void ObjectCB_CameraObject(struct Sprite *sprite) sprite->data3 = 0; } -/*static*/ struct Sprite *FindCameraObject(void) +static struct Sprite *FindCameraObject(void) { u8 spriteId; @@ -1401,3 +1401,44 @@ void ObjectCB_CameraObject(struct Sprite *sprite) } return NULL; } + +void CameraObjectReset1(void) +{ + struct Sprite *cameraObject; + + cameraObject = FindCameraObject(); + if (cameraObject != NULL) + { + cameraObject->data1 = 0; + cameraObject->callback(cameraObject); + } +} + +void CameraObjectSetFollowedObjectId(u8 objectId) +{ + struct Sprite *cameraObject; + + cameraObject = FindCameraObject(); + if (cameraObject != NULL) + { + cameraObject->data0 = objectId; + CameraObjectReset1(); + } +} + +u8 CameraObjectGetFollowedObjectId(void) +{ + struct Sprite *cameraObject; + + cameraObject = FindCameraObject(); + if (cameraObject == NULL) + { + return MAX_SPRITES; + } + return cameraObject->data0; +} + +void CameraObjectReset2(void) +{ + FindCameraObject()->data1 = 2; +} From 251360624a2f4802a607b7a114a6fe5db66623af Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 10 Sep 2017 16:53:08 -0400 Subject: [PATCH 068/191] CopySprite --- asm/field_map_obj.s | 53 --------------------------------------------- src/field_map_obj.c | 18 +++++++++++++++ 2 files changed, 18 insertions(+), 53 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index cdec058de..4b01ef858 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,59 +5,6 @@ .text - thumb_func_start sub_808EEEC -sub_808EEEC: @ 808EEEC - push {r4-r7,lr} - mov r7, r8 - push {r7} - mov r12, r0 - lsls r1, 16 - lsrs r1, 16 - mov r8, r1 - lsls r2, 16 - lsrs r6, r2, 16 - lsls r3, 24 - lsrs r7, r3, 24 - movs r5, 0 - ldr r1, =gSprites -_0808EF06: - lsls r0, r5, 4 - adds r0, r5 - lsls r0, 2 - adds r4, r0, r1 - adds r0, r4, 0 - adds r0, 0x3E - ldrb r0, [r0] - lsls r0, 31 - cmp r0, 0 - bne _0808EF38 - adds r0, r4, 0 - mov r1, r12 - movs r2, 0x44 - bl memcpy - mov r0, r8 - strh r0, [r4, 0x20] - strh r6, [r4, 0x22] - adds r0, r4, 0 - adds r0, 0x43 - strb r7, [r0] - b _0808EF42 - .pool -_0808EF38: - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x3F - bls _0808EF06 -_0808EF42: - adds r0, r5, 0 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_808EEEC - thumb_func_start obj_unfreeze obj_unfreeze: @ 808EF50 push {r4-r7,lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 40b12b1b3..a54444c59 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -1442,3 +1442,21 @@ void CameraObjectReset2(void) { FindCameraObject()->data1 = 2; } + +u8 CopySprite(struct Sprite *sprite, s16 x, s16 y, u8 subpriority) +{ + u8 i; + + for (i = 0; i < MAX_SPRITES; i ++) + { + if (!gSprites[i].inUse) + { + gSprites[i] = *sprite; + gSprites[i].pos1.x = x; + gSprites[i].pos1.y = y; + gSprites[i].subpriority = subpriority; + break; + } + } + return i; +} From 69a1ff984d8673bb3a93c490591866573dde2ac7 Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 10 Sep 2017 16:57:08 -0400 Subject: [PATCH 069/191] obj_unfreeze --- asm/field_map_obj.s | 60 --------------------------------------------- src/field_map_obj.c | 18 ++++++++++++++ 2 files changed, 18 insertions(+), 60 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 4b01ef858..df335a0bf 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,66 +5,6 @@ .text - thumb_func_start obj_unfreeze -obj_unfreeze: @ 808EF50 - push {r4-r7,lr} - mov r7, r8 - push {r7} - mov r12, r0 - lsls r1, 16 - lsrs r1, 16 - mov r8, r1 - lsls r2, 16 - lsrs r6, r2, 16 - lsls r3, 24 - lsrs r7, r3, 24 - movs r5, 0x3F - ldr r3, =gSprites - movs r2, 0x1 - negs r2, r2 -_0808EF6E: - lsls r0, r5, 16 - asrs r1, r0, 16 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r4, r0, r3 - adds r0, r4, 0 - adds r0, 0x3E - ldrb r0, [r0] - lsls r0, 31 - cmp r0, 0 - bne _0808EFA8 - adds r0, r4, 0 - mov r1, r12 - movs r2, 0x44 - bl memcpy - mov r0, r8 - strh r0, [r4, 0x20] - strh r6, [r4, 0x22] - adds r0, r4, 0 - adds r0, 0x43 - strb r7, [r0] - lsls r0, r5, 24 - lsrs r0, 24 - b _0808EFB6 - .pool -_0808EFA8: - subs r0, r1, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - asrs r0, 16 - cmp r0, r2 - bgt _0808EF6E - movs r0, 0x40 -_0808EFB6: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end obj_unfreeze - thumb_func_start FieldObjectSetDirection @ void FieldObjectSetDirection(struct npc_state *fieldObject, u8 direction) FieldObjectSetDirection: @ 808EFC0 diff --git a/src/field_map_obj.c b/src/field_map_obj.c index a54444c59..3d3934aa1 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -1460,3 +1460,21 @@ u8 CopySprite(struct Sprite *sprite, s16 x, s16 y, u8 subpriority) } return i; } + +u8 obj_unfreeze(struct Sprite *sprite, s16 x, s16 y, u8 subpriority) +{ + s16 i; + + for (i = MAX_SPRITES - 1; i > -1; i --) + { + if (!gSprites[i].inUse) + { + gSprites[i] = *sprite; + gSprites[i].pos1.x = x; + gSprites[i].pos1.y = y; + gSprites[i].subpriority = subpriority; + return i; + } + } + return MAX_SPRITES; +} From b263dcc7cf6caab910511caf2d1c2aff9f629476 Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 10 Sep 2017 17:04:37 -0400 Subject: [PATCH 070/191] FieldObjectSetDirection --- asm/field_map_obj.s | 39 --------------------------------------- src/field_map_obj.c | 12 ++++++++++++ 2 files changed, 12 insertions(+), 39 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index df335a0bf..11e93a4ea 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,45 +5,6 @@ .text - thumb_func_start FieldObjectSetDirection -@ void FieldObjectSetDirection(struct npc_state *fieldObject, u8 direction) -FieldObjectSetDirection: @ 808EFC0 - push {r4,lr} - adds r3, r0, 0 - lsls r1, 24 - lsrs r2, r1, 24 - adds r4, r2, 0 - ldrb r0, [r3, 0x18] - lsls r0, 28 - lsrs r0, 28 - adds r1, r3, 0 - adds r1, 0x20 - strb r0, [r1] - ldrb r0, [r3, 0x1] - lsls r0, 30 - cmp r0, 0 - blt _0808EFF0 - movs r0, 0xF - adds r1, r2, 0 - ands r1, r0 - ldrb r2, [r3, 0x18] - movs r0, 0x10 - negs r0, r0 - ands r0, r2 - orrs r0, r1 - strb r0, [r3, 0x18] -_0808EFF0: - lsls r2, r4, 4 - ldrb r1, [r3, 0x18] - movs r0, 0xF - ands r0, r1 - orrs r0, r2 - strb r0, [r3, 0x18] - pop {r4} - pop {r0} - bx r0 - thumb_func_end FieldObjectSetDirection - thumb_func_start GetFieldObjectScriptPointerByLocalIdAndMap @ u32 GetFieldObjectScriptPointerByLocalIdAndMap(u8 localId, u8 mapId, u8 mapGroupId) GetFieldObjectScriptPointerByLocalIdAndMap: @ 808F004 diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 3d3934aa1..d5481c573 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -1478,3 +1478,15 @@ u8 obj_unfreeze(struct Sprite *sprite, s16 x, s16 y, u8 subpriority) } return MAX_SPRITES; } + +void FieldObjectSetDirection(struct MapObject *mapObject, u8 direction) +{ + s8 d2; + mapObject->mapobj_unk_20 = mapObject->mapobj_unk_18; + if (!mapObject->mapobj_bit_9) + { + d2 = direction; + mapObject->mapobj_unk_18 = d2; + } + mapObject->placeholder18 = direction; +} From 84569918376aa346cbb94925a70d64569821a4ac Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 10 Sep 2017 17:11:03 -0400 Subject: [PATCH 071/191] Functions for retrieving flag and script pointer given map object id --- asm/field_map_obj.s | 74 --------------------------------------------- src/field_map_obj.c | 20 ++++++++++++ 2 files changed, 20 insertions(+), 74 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 11e93a4ea..6571f40bc 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,80 +5,6 @@ .text - thumb_func_start GetFieldObjectScriptPointerByLocalIdAndMap -@ u32 GetFieldObjectScriptPointerByLocalIdAndMap(u8 localId, u8 mapId, u8 mapGroupId) -GetFieldObjectScriptPointerByLocalIdAndMap: @ 808F004 - push {lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, 24 - lsrs r1, 24 - lsls r2, 24 - lsrs r2, 24 - bl GetFieldObjectTemplateByLocalIdAndMap - ldr r0, [r0, 0x10] - pop {r1} - bx r1 - thumb_func_end GetFieldObjectScriptPointerByLocalIdAndMap - - thumb_func_start GetFieldObjectScriptPointerByFieldObjectId -@ u32 GetFieldObjectScriptPointerByFieldObjectId(u8 fieldObjectId) -GetFieldObjectScriptPointerByFieldObjectId: @ 808F01C - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gMapObjects - lsls r2, r0, 3 - adds r2, r0 - lsls r2, 2 - adds r2, r1 - ldrb r0, [r2, 0x8] - ldrb r1, [r2, 0x9] - ldrb r2, [r2, 0xA] - bl GetFieldObjectScriptPointerByLocalIdAndMap - pop {r1} - bx r1 - .pool - thumb_func_end GetFieldObjectScriptPointerByFieldObjectId - - thumb_func_start GetFieldObjectFlagIdByLocalIdAndMap -@ u16 GetFieldObjectFlagIdByLocalIdAndMap(u8 localId, u8 mapId, u8 mapGroupId) -GetFieldObjectFlagIdByLocalIdAndMap: @ 808F040 - push {lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, 24 - lsrs r1, 24 - lsls r2, 24 - lsrs r2, 24 - bl GetFieldObjectTemplateByLocalIdAndMap - ldrh r0, [r0, 0x14] - pop {r1} - bx r1 - thumb_func_end GetFieldObjectFlagIdByLocalIdAndMap - - thumb_func_start GetFieldObjectFlagIdByFieldObjectId -@ u16 GetFieldObjectFlagIdByFieldObjectId(u8 fieldObjectId) -GetFieldObjectFlagIdByFieldObjectId: @ 808F058 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gMapObjects - lsls r2, r0, 3 - adds r2, r0 - lsls r2, 2 - adds r2, r1 - ldrb r0, [r2, 0x8] - ldrb r1, [r2, 0x9] - ldrb r2, [r2, 0xA] - bl GetFieldObjectFlagIdByLocalIdAndMap - lsls r0, 16 - lsrs r0, 16 - pop {r1} - bx r1 - .pool - thumb_func_end GetFieldObjectFlagIdByFieldObjectId - thumb_func_start sub_808F080 sub_808F080: @ 808F080 push {lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index d5481c573..42769ed13 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -1490,3 +1490,23 @@ void FieldObjectSetDirection(struct MapObject *mapObject, u8 direction) } mapObject->placeholder18 = direction; } + +static const u8 *GetFieldObjectScriptPointerByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup) +{ + return GetFieldObjectTemplateByLocalIdAndMap(localId, mapNum, mapGroup)->script; +} + +const u8 *GetFieldObjectScriptPointerByFieldObjectId(u8 mapObjectId) +{ + return GetFieldObjectScriptPointerByLocalIdAndMap(gMapObjects[mapObjectId].localId, gMapObjects[mapObjectId].mapNum, gMapObjects[mapObjectId].mapGroup); +} + +static u16 GetFieldObjectFlagIdByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup) +{ + return GetFieldObjectTemplateByLocalIdAndMap(localId, mapNum, mapGroup)->flagId; +} + +u16 GetFieldObjectFlagIdByFieldObjectId(u8 mapObjectId) +{ + return GetFieldObjectFlagIdByLocalIdAndMap(gMapObjects[mapObjectId].localId, gMapObjects[mapObjectId].mapNum, gMapObjects[mapObjectId].mapGroup); +} From bcf844f965912cac05b6cfb26f430b2ede75f743 Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 10 Sep 2017 17:47:37 -0400 Subject: [PATCH 072/191] sub_808F080 --- asm/field_map_obj.s | 33 --------------------------------- src/field_map_obj.c | 11 +++++++++++ 2 files changed, 11 insertions(+), 33 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 6571f40bc..3ef34cfd6 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,39 +5,6 @@ .text - thumb_func_start sub_808F080 -sub_808F080: @ 808F080 - push {lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r0, 24 - lsls r1, 24 - lsrs r1, 24 - lsls r2, 24 - lsrs r2, 24 - mov r3, sp - bl TryGetFieldObjectIdByLocalIdAndMap - lsls r0, 24 - cmp r0, 0 - bne _0808F0B4 - ldr r2, =gMapObjects - mov r0, sp - ldrb r1, [r0] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r0, [r0, 0x7] - b _0808F0B6 - .pool -_0808F0B4: - movs r0, 0xFF -_0808F0B6: - add sp, 0x4 - pop {r1} - bx r1 - thumb_func_end sub_808F080 - thumb_func_start sub_808F0BC sub_808F0BC: @ 808F0BC lsls r0, 24 diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 42769ed13..b33332661 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -1510,3 +1510,14 @@ u16 GetFieldObjectFlagIdByFieldObjectId(u8 mapObjectId) { return GetFieldObjectFlagIdByLocalIdAndMap(gMapObjects[mapObjectId].localId, gMapObjects[mapObjectId].mapNum, gMapObjects[mapObjectId].mapGroup); } + +u8 sub_808F080(u8 localId, u8 mapNum, u8 mapGroup) +{ + u8 mapObjectId; + + if (TryGetFieldObjectIdByLocalIdAndMap(localId, mapNum, mapGroup, &mapObjectId)) + { + return 0xFF; + } + return gMapObjects[mapObjectId].trainerType; +} From bd9b81546f4eedae24278b54b02301b8184112a4 Mon Sep 17 00:00:00 2001 From: scnorton Date: Mon, 11 Sep 2017 10:19:03 -0400 Subject: [PATCH 073/191] through FieldObjectGetBerryTreeId --- asm/field_map_obj.s | 62 --------------------------------------------- src/field_map_obj.c | 22 ++++++++++++++++ 2 files changed, 22 insertions(+), 62 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 3ef34cfd6..5cf4550c3 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,68 +5,6 @@ .text - thumb_func_start sub_808F0BC -sub_808F0BC: @ 808F0BC - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gMapObjects - lsls r1, r0, 3 - adds r1, r0 - lsls r1, 2 - adds r1, r2 - ldrb r0, [r1, 0x7] - bx lr - .pool - thumb_func_end sub_808F0BC - - thumb_func_start sub_808F0D4 -sub_808F0D4: @ 808F0D4 - push {lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r0, 24 - lsls r1, 24 - lsrs r1, 24 - lsls r2, 24 - lsrs r2, 24 - mov r3, sp - bl TryGetFieldObjectIdByLocalIdAndMap - lsls r0, 24 - cmp r0, 0 - bne _0808F108 - ldr r2, =gMapObjects - mov r0, sp - ldrb r1, [r0] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r0, [r0, 0x1D] - b _0808F10A - .pool -_0808F108: - movs r0, 0xFF -_0808F10A: - add sp, 0x4 - pop {r1} - bx r1 - thumb_func_end sub_808F0D4 - - thumb_func_start FieldObjectGetBerryTreeId -@ u8 FieldObjectGetBerryTreeId(u8 fieldObjectId) -FieldObjectGetBerryTreeId: @ 808F110 - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gMapObjects - lsls r1, r0, 3 - adds r1, r0 - lsls r1, 2 - adds r1, r2 - ldrb r0, [r1, 0x1D] - bx lr - .pool - thumb_func_end FieldObjectGetBerryTreeId - thumb_func_start GetFieldObjectTemplateByLocalIdAndMap @ struct FieldObjectTemplate *GetFieldObjectTemplateByLocalIdAndMap(u8 localId, u8 mapId, u8 mapGroupId) GetFieldObjectTemplateByLocalIdAndMap: @ 808F128 diff --git a/src/field_map_obj.c b/src/field_map_obj.c index b33332661..d4f724079 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -1521,3 +1521,25 @@ u8 sub_808F080(u8 localId, u8 mapNum, u8 mapGroup) } return gMapObjects[mapObjectId].trainerType; } + +u8 sub_808F0BC(u8 mapObjectId) +{ + return gMapObjects[mapObjectId].trainerType; +} + +u8 sub_808F0D4(u8 localId, u8 mapNum, u8 mapGroup) +{ + u8 mapObjectId; + + if (TryGetFieldObjectIdByLocalIdAndMap(localId, mapNum, mapGroup, &mapObjectId)) + { + return 0xFF; + } + return gMapObjects[mapObjectId].trainerRange_berryTreeId; +} + +u8 FieldObjectGetBerryTreeId(u8 mapObjectId) +{ + return gMapObjects[mapObjectId].trainerRange_berryTreeId; +} + From 5ad282c82c79205045fce2e8d7db993846d86b17 Mon Sep 17 00:00:00 2001 From: scnorton Date: Mon, 11 Sep 2017 10:29:00 -0400 Subject: [PATCH 074/191] GetFieldObjectTemplateByLocalIdAndMap --- asm/field_map_obj.s | 42 ------------------------------------------ include/rom4.h | 1 + src/field_map_obj.c | 21 +++++++++++++++++++++ 3 files changed, 22 insertions(+), 42 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 5cf4550c3..f3c2929fd 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,48 +5,6 @@ .text - thumb_func_start GetFieldObjectTemplateByLocalIdAndMap -@ struct FieldObjectTemplate *GetFieldObjectTemplateByLocalIdAndMap(u8 localId, u8 mapId, u8 mapGroupId) -GetFieldObjectTemplateByLocalIdAndMap: @ 808F128 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - lsls r1, 24 - lsrs r3, r1, 24 - lsls r2, 24 - lsrs r2, 24 - ldr r0, =gSaveBlock1Ptr - ldr r1, [r0] - movs r0, 0x5 - ldrsb r0, [r1, r0] - cmp r0, r3 - bne _0808F160 - movs r0, 0x4 - ldrsb r0, [r1, r0] - cmp r0, r2 - bne _0808F160 - movs r0, 0xC7 - lsls r0, 4 - adds r1, r0 - ldr r0, =gMapHeader - ldr r0, [r0, 0x4] - b _0808F16C - .pool -_0808F160: - adds r0, r2, 0 - adds r1, r3, 0 - bl get_mapheader_by_bank_and_number - ldr r0, [r0, 0x4] - ldr r1, [r0, 0x4] -_0808F16C: - ldrb r2, [r0] - adds r0, r4, 0 - bl FindFieldObjectTemplateInArrayByLocalId - pop {r4} - pop {r1} - bx r1 - thumb_func_end GetFieldObjectTemplateByLocalIdAndMap - thumb_func_start FindFieldObjectTemplateInArrayByLocalId @ struct FieldObjectTemplate *FindFieldObjectTemplateInArrayByLocalId(u8 localId, struct FieldObjectTemplate *templates, u8 numTemplates) FindFieldObjectTemplateInArrayByLocalId: @ 808F17C diff --git a/include/rom4.h b/include/rom4.h index 655ce3fde..0c7b87353 100644 --- a/include/rom4.h +++ b/include/rom4.h @@ -25,5 +25,6 @@ struct UCoords32 extern struct LinkPlayerMapObject gLinkPlayerMapObjects[4]; void strange_npc_table_clear(void); +const struct MapHeader *get_mapheader_by_bank_and_number(u8, u8); #endif //POKEEMERALD_ROM4_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index d4f724079..78269fd58 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -51,6 +51,7 @@ static bool8 FieldObjectDoesZCoordMatch(struct MapObject *, u8); //static void CameraObject_0(struct Sprite *); /*static*/ void CameraObject_1(struct Sprite *); //static void CameraObject_2(struct Sprite *); +/*static*/ struct MapObjectTemplate *FindFieldObjectTemplateInArrayByLocalId(u8 localId, struct MapObjectTemplate *templates, u8 count); // ROM data @@ -1543,3 +1544,23 @@ u8 FieldObjectGetBerryTreeId(u8 mapObjectId) return gMapObjects[mapObjectId].trainerRange_berryTreeId; } +struct MapObjectTemplate *GetFieldObjectTemplateByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup) +{ + struct MapObjectTemplate *templates; + const struct MapHeader *mapHeader; + u8 count; + + if (gSaveBlock1Ptr->location.mapNum == mapNum && gSaveBlock1Ptr->location.mapGroup == mapGroup) + { + templates = gSaveBlock1Ptr->mapObjectTemplates; + count = gMapHeader.events->mapObjectCount; + } + else + { + mapHeader = get_mapheader_by_bank_and_number(mapGroup, mapNum); + templates = mapHeader->events->mapObjects; + count = mapHeader->events->mapObjectCount; + } + return FindFieldObjectTemplateInArrayByLocalId(localId, templates, count); +} + From 7c40186e35a35f4cf84612af5c9326b7879342f2 Mon Sep 17 00:00:00 2001 From: scnorton Date: Mon, 11 Sep 2017 10:31:09 -0400 Subject: [PATCH 075/191] FindFieldObjectTemplateInArrayByLocalId --- asm/field_map_obj.s | 36 ------------------------------------ src/field_map_obj.c | 13 +++++++++++++ 2 files changed, 13 insertions(+), 36 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index f3c2929fd..a0bf5fa69 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,42 +5,6 @@ .text - thumb_func_start FindFieldObjectTemplateInArrayByLocalId -@ struct FieldObjectTemplate *FindFieldObjectTemplateInArrayByLocalId(u8 localId, struct FieldObjectTemplate *templates, u8 numTemplates) -FindFieldObjectTemplateInArrayByLocalId: @ 808F17C - push {r4,r5,lr} - adds r5, r1, 0 - lsls r0, 24 - lsrs r4, r0, 24 - lsls r2, 24 - lsrs r2, 24 - movs r1, 0 - cmp r1, r2 - bcs _0808F1AA -_0808F18E: - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 3 - adds r3, r0, r5 - ldrb r0, [r3] - cmp r0, r4 - bne _0808F1A0 - adds r0, r3, 0 - b _0808F1AC -_0808F1A0: - adds r0, r1, 0x1 - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, r2 - bcc _0808F18E -_0808F1AA: - movs r0, 0 -_0808F1AC: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end FindFieldObjectTemplateInArrayByLocalId - thumb_func_start sub_808F1B4 @ int sub_808F1B4(struct npc_state *fieldObject) sub_808F1B4: @ 808F1B4 diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 78269fd58..86ac6a00f 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -1564,3 +1564,16 @@ struct MapObjectTemplate *GetFieldObjectTemplateByLocalIdAndMap(u8 localId, u8 m return FindFieldObjectTemplateInArrayByLocalId(localId, templates, count); } +struct MapObjectTemplate *FindFieldObjectTemplateInArrayByLocalId(u8 localId, struct MapObjectTemplate *templates, u8 count) +{ + u8 i; + + for (i = 0; i < count; i ++) + { + if (templates[i].localId == localId) + { + return &templates[i]; + } + } + return NULL; +} From 2b9b75a8245c32467d97ffeef280003c4fe0bb66 Mon Sep 17 00:00:00 2001 From: scnorton Date: Mon, 11 Sep 2017 10:40:34 -0400 Subject: [PATCH 076/191] sub_808F1B4 --- asm/field_map_obj.s | 50 --------------------------------------------- src/field_map_obj.c | 18 ++++++++++++++++ 2 files changed, 18 insertions(+), 50 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index a0bf5fa69..5c8754ac0 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,56 +5,6 @@ .text - thumb_func_start sub_808F1B4 -@ int sub_808F1B4(struct npc_state *fieldObject) -sub_808F1B4: @ 808F1B4 - push {r4,r5,lr} - adds r3, r0, 0 - ldrb r0, [r3, 0x9] - ldr r1, =gSaveBlock1Ptr - ldr r2, [r1] - movs r1, 0x5 - ldrsb r1, [r2, r1] - cmp r0, r1 - bne _0808F200 - ldrb r1, [r3, 0xA] - movs r0, 0x4 - ldrsb r0, [r2, r0] - cmp r1, r0 - beq _0808F1E2 - b _0808F200 - .pool -_0808F1D8: - movs r1, 0xC7 - lsls r1, 4 - adds r0, r1 - adds r0, r4, r0 - b _0808F202 -_0808F1E2: - movs r1, 0 - adds r4, r2, 0 - ldrb r3, [r3, 0x8] - movs r5, 0xC7 - lsls r5, 4 - adds r2, r4, r5 - movs r0, 0 -_0808F1F0: - ldrb r5, [r2] - cmp r3, r5 - beq _0808F1D8 - adds r2, 0x18 - adds r0, 0x18 - adds r1, 0x1 - cmp r1, 0x3F - ble _0808F1F0 -_0808F200: - movs r0, 0 -_0808F202: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_808F1B4 - thumb_func_start sub_808F208 @ void sub_808F208(struct npc_state *fieldObject) sub_808F208: @ 808F208 diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 86ac6a00f..56c5dee85 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -1577,3 +1577,21 @@ struct MapObjectTemplate *FindFieldObjectTemplateInArrayByLocalId(u8 localId, st } return NULL; } + +struct MapObjectTemplate *sub_808F1B4(struct MapObject *mapObject) +{ + int i; + + if (mapObject->mapNum != gSaveBlock1Ptr->location.mapNum || mapObject->mapGroup != gSaveBlock1Ptr->location.mapGroup) + { + return NULL; + } + for (i = 0; i < 64; i ++) // Using ARRAY_COUNT here results in the wrong conditional branch instruction (bls instead of ble) + { + if (mapObject->localId == gSaveBlock1Ptr->mapObjectTemplates[i].localId) + { + return &gSaveBlock1Ptr->mapObjectTemplates[i]; + } + } + return NULL; +} From 9306122359968579b27b9a41e3cfd082860a4231 Mon Sep 17 00:00:00 2001 From: scnorton Date: Mon, 11 Sep 2017 10:46:26 -0400 Subject: [PATCH 077/191] through sub_808F23C --- asm/field_map_obj.s | 50 --------------------------------------- include/global.fieldmap.h | 2 +- src/field_map_obj.c | 36 +++++++++++++++++++++++++++- 3 files changed, 36 insertions(+), 52 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 5c8754ac0..243e96c75 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,56 +5,6 @@ .text - thumb_func_start sub_808F208 -@ void sub_808F208(struct npc_state *fieldObject) -sub_808F208: @ 808F208 - push {r4,lr} - adds r4, r0, 0 - bl sub_808F1B4 - adds r1, r0, 0 - cmp r1, 0 - beq _0808F222 - ldrh r0, [r4, 0x10] - subs r0, 0x7 - strh r0, [r1, 0x4] - ldrh r0, [r4, 0x12] - subs r0, 0x7 - strh r0, [r1, 0x6] -_0808F222: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_808F208 - - thumb_func_start sub_808F228 -sub_808F228: @ 808F228 - push {r4,lr} - adds r4, r1, 0 - bl sub_808F1B4 - cmp r0, 0 - beq _0808F236 - str r4, [r0, 0x10] -_0808F236: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_808F228 - - thumb_func_start sub_808F23C -sub_808F23C: @ 808F23C - push {r4,lr} - lsls r1, 24 - lsrs r4, r1, 24 - bl sub_808F1B4 - cmp r0, 0 - beq _0808F24C - strb r4, [r0, 0x9] -_0808F24C: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_808F23C - thumb_func_start sub_808F254 @ void sub_808F254(u8 localId, u8 mapId, u8 mapGroupId) sub_808F254: @ 808F254 diff --git a/include/global.fieldmap.h b/include/global.fieldmap.h index 5a7a75ccb..f8955b9fd 100644 --- a/include/global.fieldmap.h +++ b/include/global.fieldmap.h @@ -86,7 +86,7 @@ struct MapObjectTemplate ///*0x0B*/ u8 fillerB[1]; /*0x0C*/ u16 unkC; /*0x0E*/ u16 unkE; - /*0x10*/ u8 *script; + /*0x10*/ const u8 *script; /*0x14*/ u16 flagId; /*0x16*/ u8 filler_16[2]; }; /*size = 0x18*/ diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 56c5dee85..59f8d35a1 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -1578,7 +1578,7 @@ struct MapObjectTemplate *FindFieldObjectTemplateInArrayByLocalId(u8 localId, st return NULL; } -struct MapObjectTemplate *sub_808F1B4(struct MapObject *mapObject) +struct MapObjectTemplate *sub_808F1B4(const struct MapObject *mapObject) { int i; @@ -1595,3 +1595,37 @@ struct MapObjectTemplate *sub_808F1B4(struct MapObject *mapObject) } return NULL; } + +void sub_808F208(const struct MapObject *mapObject) +{ + struct MapObjectTemplate *mapObjectTemplate; + + mapObjectTemplate = sub_808F1B4(mapObject); + if (mapObjectTemplate != NULL) + { + mapObjectTemplate->x = mapObject->coords2.x - 7; + mapObjectTemplate->y = mapObject->coords2.y - 7; + } +} + +void sub_808F228(const struct MapObject *mapObject, const u8 *script) +{ + struct MapObjectTemplate *mapObjectTemplate; + + mapObjectTemplate = sub_808F1B4(mapObject); + if (mapObjectTemplate != NULL) + { + mapObjectTemplate->script = script; + } +} + +void sub_808F23C(const struct MapObject *mapObject, u8 movementType) +{ + struct MapObjectTemplate *mapObjectTemplate; + + mapObjectTemplate = sub_808F1B4(mapObject); + if (mapObjectTemplate != NULL) + { + mapObjectTemplate->movementType = movementType; + } +} From c6ef3442621227562f15017441aa6fb7709e7187 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Tue, 12 Sep 2017 16:17:52 -0400 Subject: [PATCH 078/191] sub_808F254 --- asm/field_map_obj.s | 31 ------------------------------- include/field_map_obj.h | 1 + src/field_map_obj.c | 10 ++++++++++ 3 files changed, 11 insertions(+), 31 deletions(-) mode change 100644 => 100755 asm/field_map_obj.s mode change 100644 => 100755 include/field_map_obj.h mode change 100644 => 100755 src/field_map_obj.c diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s old mode 100644 new mode 100755 index 243e96c75..ef9e6a2e8 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,37 +5,6 @@ .text - thumb_func_start sub_808F254 -@ void sub_808F254(u8 localId, u8 mapId, u8 mapGroupId) -sub_808F254: @ 808F254 - push {lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r0, 24 - lsls r1, 24 - lsrs r1, 24 - lsls r2, 24 - lsrs r2, 24 - mov r3, sp - bl TryGetFieldObjectIdByLocalIdAndMap - lsls r0, 24 - cmp r0, 0 - bne _0808F282 - mov r0, sp - ldrb r1, [r0] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, =gMapObjects - adds r0, r1 - bl sub_808F208 -_0808F282: - add sp, 0x4 - pop {r0} - bx r0 - .pool - thumb_func_end sub_808F254 - thumb_func_start sub_808F28C sub_808F28C: @ 808F28C push {r4,lr} diff --git a/include/field_map_obj.h b/include/field_map_obj.h old mode 100644 new mode 100755 index b292d200d..ec28df643 --- a/include/field_map_obj.h +++ b/include/field_map_obj.h @@ -46,6 +46,7 @@ void sub_808E75C(s16, s16); void FieldObjectGetLocalIdAndMap(struct MapObject *, u8 *, u8 *, u8 *); void npc_coords_shift(struct MapObject *, s16, s16); void sub_808EB08(struct MapObject *, s16, s16); +void sub_808F254(u8, u8, u8); // Exported data declarations diff --git a/src/field_map_obj.c b/src/field_map_obj.c old mode 100644 new mode 100755 index 59f8d35a1..af36d95f7 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -1629,3 +1629,13 @@ void sub_808F23C(const struct MapObject *mapObject, u8 movementType) mapObjectTemplate->movementType = movementType; } } + +void sub_808F254(u8 localId, u8 mapNum, u8 mapGroup) +{ + u8 mapObjectId; + + if (!TryGetFieldObjectIdByLocalIdAndMap(localId, mapNum, mapGroup, &mapObjectId)) + { + sub_808F208(&gMapObjects[mapObjectId]); + } +} From 9286c93c8afd9505259487481e45db6956444004 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Tue, 12 Sep 2017 16:47:51 -0400 Subject: [PATCH 079/191] npc_paltag_set_load --- asm/field_map_obj.s | 96 ----------------------------------------- include/data3.h | 7 +-- include/event_scripts.h | 11 +++++ src/field_map_obj.c | 37 +++++++++++++++- 4 files changed, 51 insertions(+), 100 deletions(-) mode change 100644 => 100755 include/data3.h create mode 100755 include/event_scripts.h diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index ef9e6a2e8..8da48cd1a 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,102 +5,6 @@ .text - thumb_func_start sub_808F28C -sub_808F28C: @ 808F28C - push {r4,lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r0, 24 - lsls r1, 24 - lsrs r1, 24 - lsls r2, 24 - lsrs r2, 24 - lsls r3, 24 - lsrs r4, r3, 24 - mov r3, sp - bl TryGetFieldObjectIdByLocalIdAndMap - lsls r0, 24 - cmp r0, 0 - bne _0808F2E8 - cmp r4, 0x6 - beq _0808F2B6 - cmp r4, 0x7 - beq _0808F2D4 - b _0808F2E8 -_0808F2B6: - mov r0, sp - ldrb r1, [r0] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, =gMapObjects - adds r0, r1 - ldr r1, =gUnknown_082766A2 - bl sub_808F228 - b _0808F2E8 - .pool -_0808F2D4: - mov r0, sp - ldrb r1, [r0] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, =gMapObjects - adds r0, r1 - ldr r1, =gUnknown_082766A6 - bl sub_808F228 -_0808F2E8: - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_808F28C - - thumb_func_start npc_paltag_set_load -npc_paltag_set_load: @ 808F2F8 - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - bl gpu_pal_allocator_reset__manage_upper_four - ldr r1, =gUnknown_020375B6 - ldr r2, =0x000011ff - adds r0, r2, 0 - strh r0, [r1] - ldr r2, =gUnknown_020375B4 - strb r4, [r2] - cmp r4, 0x1 - bne _0808F344 - ldr r1, =gUnknown_0850BE38 - ldrb r0, [r2] - lsls r0, 2 - adds r0, r1 - ldr r0, [r0] - movs r1, 0 - movs r2, 0x6 - bl pal_patch_for_npc_range - ldr r1, =gReservedSpritePaletteCount - movs r0, 0x8 - strb r0, [r1] - b _0808F356 - .pool -_0808F344: - ldr r0, =gUnknown_0850BE38 - ldrb r1, [r2] - lsls r1, 2 - adds r1, r0 - ldr r0, [r1] - movs r1, 0 - movs r2, 0xA - bl pal_patch_for_npc_range -_0808F356: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end npc_paltag_set_load - thumb_func_start npc_paltag_by_palslot npc_paltag_by_palslot: @ 808F360 push {r4-r6,lr} diff --git a/include/data3.h b/include/data3.h old mode 100644 new mode 100755 index 6b1569486..29b1acc34 --- a/include/data3.h +++ b/include/data3.h @@ -10,11 +10,12 @@ struct PairedPalettes { const u16 *data; }; -extern const struct SpritePalette gUnknown_0850BBC8[]; -extern const struct PairedPalettes gUnknown_0850BD00[15]; -extern const struct PairedPalettes gUnknown_0850BD78[15]; extern u8 gUnknown_084975C4[0x10]; extern const struct SpriteTemplate gUnknown_084975D4; extern void (*const gUnknown_084975EC[3])(struct Sprite *); +extern const struct SpritePalette gUnknown_0850BBC8[]; +extern const struct PairedPalettes gUnknown_0850BD00[15]; +extern const struct PairedPalettes gUnknown_0850BD78[15]; +extern const u16 *const gUnknown_0850BE38[2]; #endif //POKEEMERALD_DATA3_H diff --git a/include/event_scripts.h b/include/event_scripts.h new file mode 100755 index 000000000..967bc196a --- /dev/null +++ b/include/event_scripts.h @@ -0,0 +1,11 @@ +// +// Created by scott on 9/12/2017. +// + +#ifndef POKEEMERALD_EVENT_SCRIPTS_H +#define POKEEMERALD_EVENT_SCRIPTS_H + +extern const u8 gUnknown_082766A2[]; +extern const u8 gUnknown_082766A6[]; + +#endif //POKEEMERALD_EVENT_SCRIPTS_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index af36d95f7..b4617cd5a 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -5,6 +5,7 @@ #include "sprite.h" #include "rom4.h" #include "data3.h" +#include "event_scripts.h" #include "berry.h" #include "palette.h" #include "field_player_avatar.h" @@ -1163,7 +1164,7 @@ void pal_patch_for_npc(u16 paletteTag, u8 paletteSlot) LoadPalette(gUnknown_0850BBC8[paletteIdx].data, 16 * paletteSlot + 256, 0x20); } -void pal_patch_for_npc_range(u16 *paletteTags, u8 minSlot, u8 maxSlot) +void pal_patch_for_npc_range(const u16 *paletteTags, u8 minSlot, u8 maxSlot) { while (minSlot < maxSlot) { @@ -1639,3 +1640,37 @@ void sub_808F254(u8 localId, u8 mapNum, u8 mapGroup) sub_808F208(&gMapObjects[mapObjectId]); } } + +void sub_808F28C(u8 localId, u8 mapNum, u8 mapGroup, u8 action) +{ + u8 mapObjectId; + + if (!TryGetFieldObjectIdByLocalIdAndMap(localId, mapNum, mapGroup, &mapObjectId)) + { + switch (action) + { + case 6: + sub_808F228(&gMapObjects[mapObjectId], gUnknown_082766A2); + break; + case 7: + sub_808F228(&gMapObjects[mapObjectId], gUnknown_082766A6); + break; + } + } +} + +void npc_paltag_set_load(u8 a0) +{ + gpu_pal_allocator_reset__manage_upper_four(); + gUnknown_020375B6 = 0x11ff; + gUnknown_020375B4 = a0; + if (a0 == 1) + { + pal_patch_for_npc_range(gUnknown_0850BE38[gUnknown_020375B4], 0, 6); + gReservedSpritePaletteCount = 8; + } + else + { + pal_patch_for_npc_range(gUnknown_0850BE38[gUnknown_020375B4], 0, 10); + } +} From c8696f15528add1c1a4a195c5fc02192c3f04a77 Mon Sep 17 00:00:00 2001 From: scnorton Date: Tue, 12 Sep 2017 17:35:08 -0400 Subject: [PATCH 080/191] npc_paltag_by_palslot --- asm/field_map_obj.s | 63 --------------------------------------------- src/field_map_obj.c | 24 ++++++++++++++--- 2 files changed, 21 insertions(+), 66 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 8da48cd1a..b8fce16f1 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,69 +5,6 @@ .text - thumb_func_start npc_paltag_by_palslot -npc_paltag_by_palslot: @ 808F360 - push {r4-r6,lr} - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x9 - bhi _0808F39C - ldr r1, =gUnknown_0850BE38 - ldr r0, =gUnknown_020375B4 - ldrb r0, [r0] - lsls r0, 2 - adds r0, r1 - ldr r1, [r0] - lsls r0, r2, 1 - b _0808F390 - .pool -_0808F384: - adds r1, r4, 0x4 - adds r1, r2, r1 - ldr r0, =gUnknown_020375B4 - ldrb r0, [r0] - ldr r1, [r1] - lsls r0, 1 -_0808F390: - adds r0, r1 - ldrh r0, [r0] - b _0808F3CE - .pool -_0808F39C: - movs r3, 0 - ldr r0, =gUnknown_0850BD78 - ldrh r1, [r0] - ldr r2, =0x000011ff - adds r4, r0, 0 - cmp r1, r2 - beq _0808F3CC - adds r6, r4, 0 - ldr r0, =gUnknown_020375B6 - ldrh r1, [r0] - adds r5, r2, 0 -_0808F3B2: - lsls r2, r3, 3 - adds r0, r2, r6 - ldrh r0, [r0] - cmp r0, r1 - beq _0808F384 - adds r0, r3, 0x1 - lsls r0, 24 - lsrs r3, r0, 24 - lsls r0, r3, 3 - adds r0, r4 - ldrh r0, [r0] - cmp r0, r5 - bne _0808F3B2 -_0808F3CC: - ldr r0, =0x000011ff -_0808F3CE: - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end npc_paltag_by_palslot - thumb_func_start FieldObjectCB_NoMovement1 FieldObjectCB_NoMovement1: @ 808F3E0 push {lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index b4617cd5a..e142a35d6 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -1659,12 +1659,12 @@ void sub_808F28C(u8 localId, u8 mapNum, u8 mapGroup, u8 action) } } -void npc_paltag_set_load(u8 a0) +void npc_paltag_set_load(u8 palSlot) { gpu_pal_allocator_reset__manage_upper_four(); gUnknown_020375B6 = 0x11ff; - gUnknown_020375B4 = a0; - if (a0 == 1) + gUnknown_020375B4 = palSlot; + if (palSlot == 1) { pal_patch_for_npc_range(gUnknown_0850BE38[gUnknown_020375B4], 0, 6); gReservedSpritePaletteCount = 8; @@ -1674,3 +1674,21 @@ void npc_paltag_set_load(u8 a0) pal_patch_for_npc_range(gUnknown_0850BE38[gUnknown_020375B4], 0, 10); } } + +u16 npc_paltag_by_palslot(u8 palSlot) +{ + u8 i; + + if (palSlot < 10) + { + return gUnknown_0850BE38[gUnknown_020375B4][palSlot]; + } + for (i = 0; gUnknown_0850BD78[i].tag != 0x11ff; i ++) + { + if (gUnknown_0850BD78[i].tag == gUnknown_020375B6) + { + return gUnknown_0850BD78[i].data[gUnknown_020375B4]; + } + } + return 0x11ff; +} From 28b272bf52e32374a3d0e493b47953bfad8e9cac Mon Sep 17 00:00:00 2001 From: scnorton Date: Wed, 13 Sep 2017 09:41:11 -0400 Subject: [PATCH 081/191] NoMovement1, GoRandomDirections --- asm/field_map_obj.s | 60 ----------------------------------------- include/field_map_obj.h | 1 + src/field_map_obj.c | 28 +++++++++++++++++++ 3 files changed, 29 insertions(+), 60 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index b8fce16f1..f17d25eba 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,66 +5,6 @@ .text - thumb_func_start FieldObjectCB_NoMovement1 -FieldObjectCB_NoMovement1: @ 808F3E0 - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =FieldObjectCB2_NoMovement1 - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_NoMovement1 - - thumb_func_start FieldObjectCB2_NoMovement1 -FieldObjectCB2_NoMovement1: @ 808F404 - movs r0, 0 - bx lr - thumb_func_end FieldObjectCB2_NoMovement1 - - thumb_func_start FieldObjectCB_GoRandomDirections -FieldObjectCB_GoRandomDirections: @ 808F408 - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =FieldObjectCB2_GoRandomDirections - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_GoRandomDirections - - thumb_func_start FieldObjectCB2_GoRandomDirections -FieldObjectCB2_GoRandomDirections: @ 808F42C - push {r4,lr} - ldr r3, =gUnknown_0850D6F4 - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end FieldObjectCB2_GoRandomDirections - thumb_func_start sub_808F44C sub_808F44C: @ 808F44C push {r4,lr} diff --git a/include/field_map_obj.h b/include/field_map_obj.h index ec28df643..f91b8f9e3 100755 --- a/include/field_map_obj.h +++ b/include/field_map_obj.h @@ -47,6 +47,7 @@ void FieldObjectGetLocalIdAndMap(struct MapObject *, u8 *, u8 *, u8 *); void npc_coords_shift(struct MapObject *, s16, s16); void sub_808EB08(struct MapObject *, s16, s16); void sub_808F254(u8, u8, u8); +void FieldObjectStep(struct MapObject *, struct Sprite *, bool8(struct MapObject *, struct Sprite *)); // Exported data declarations diff --git a/src/field_map_obj.c b/src/field_map_obj.c index e142a35d6..3dd47d540 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -20,6 +20,29 @@ #define NUM_FIELD_MAP_OBJECT_TEMPLATES 0x51 +#define null_object_step(name, retval) \ +static bool8 FieldObjectCB2_##name(struct MapObject *, struct Sprite *);\ +void FieldObjectCB_##name(struct Sprite *sprite)\ +{\ + FieldObjectStep(&gMapObjects[sprite->data0], sprite, FieldObjectCB2_##name);\ +}\ +static bool8 FieldObjectCB2_##name(struct MapObject *mapObject, struct Sprite *sprite)\ +{\ + return (retval);\ +} + +#define field_object_step(name, table) \ +extern bool8 (*const (table)[])(struct MapObject *, struct Sprite *);\ +static bool8 FieldObjectCB2_##name(struct MapObject *, struct Sprite *);\ +void FieldObjectCB_##name(struct Sprite *sprite)\ +{\ + FieldObjectStep(&gMapObjects[sprite->data0], sprite, FieldObjectCB2_##name);\ +}\ +static bool8 FieldObjectCB2_##name(struct MapObject *mapObject, struct Sprite *sprite)\ +{\ + return (table)[sprite->data1](mapObject, sprite);\ +} + // Static struct declarations // Static RAM declarations @@ -1692,3 +1715,8 @@ u16 npc_paltag_by_palslot(u8 palSlot) } return 0x11ff; } + +null_object_step(NoMovement1, FALSE) + +field_object_step(GoRandomDirections, gUnknown_0850D6F4) + From e26501f130ed84b160f80232db642ec49722025f Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 13 Sep 2017 10:59:25 -0400 Subject: [PATCH 082/191] Support functions for GoRandomDirections --- asm/field_map_obj.s | 174 -------------------------------------------- include/data3.h | 2 + include/global.h | 2 +- src/field_map_obj.c | 79 ++++++++++++++++++++ 4 files changed, 82 insertions(+), 175 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index f17d25eba..8a4931322 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,180 +5,6 @@ .text - thumb_func_start sub_808F44C -sub_808F44C: @ 808F44C - push {r4,lr} - adds r4, r1, 0 - bl npc_reset - movs r0, 0x1 - strh r0, [r4, 0x30] - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_808F44C - - thumb_func_start sub_808F460 -sub_808F460: @ 808F460 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - ldrb r0, [r4, 0x18] - lsls r0, 28 - lsrs r0, 28 - bl GetFaceDirectionAnimId - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r1, r5, 0 - bl FieldObjectSetRegularAnim - movs r0, 0x2 - strh r0, [r5, 0x30] - movs r0, 0x1 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_808F460 - - thumb_func_start sub_808F48C -sub_808F48C: @ 808F48C - push {r4-r6,lr} - adds r6, r1, 0 - bl FieldObjectExecRegularAnim - lsls r0, 24 - cmp r0, 0 - beq _0808F4C0 - ldr r5, =gUnknown_0850D6DC - bl Random - movs r4, 0x3 - adds r1, r4, 0 - ands r1, r0 - lsls r1, 1 - adds r1, r5 - movs r0, 0 - ldrsh r1, [r1, r0] - adds r0, r6, 0 - bl sub_8097978 - strh r4, [r6, 0x30] - movs r0, 0x1 - b _0808F4C2 - .pool -_0808F4C0: - movs r0, 0 -_0808F4C2: - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end sub_808F48C - - thumb_func_start sub_808F4C8 -sub_808F4C8: @ 808F4C8 - push {r4,lr} - adds r4, r1, 0 - adds r0, r4, 0 - bl sub_809797C - lsls r0, 24 - cmp r0, 0 - bne _0808F4DC - movs r0, 0 - b _0808F4E2 -_0808F4DC: - movs r0, 0x4 - strh r0, [r4, 0x30] - movs r0, 0x1 -_0808F4E2: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_808F4C8 - - thumb_func_start sub_808F4E8 -sub_808F4E8: @ 808F4E8 - push {r4-r6,lr} - sub sp, 0x4 - adds r5, r0, 0 - adds r6, r1, 0 - ldr r1, =gUnknown_0850D710 - mov r0, sp - movs r2, 0x4 - bl memcpy - bl Random - movs r1, 0x3 - ands r1, r0 - mov r2, sp - adds r0, r2, r1 - ldrb r4, [r0] - adds r0, r5, 0 - adds r1, r4, 0 - bl FieldObjectSetDirection - movs r0, 0x5 - strh r0, [r6, 0x30] - adds r0, r5, 0 - adds r1, r4, 0 - bl sub_8092B88 - lsls r0, 24 - cmp r0, 0 - beq _0808F526 - movs r0, 0x1 - strh r0, [r6, 0x30] -_0808F526: - movs r0, 0x1 - add sp, 0x4 - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end sub_808F4E8 - - thumb_func_start sub_808F534 -sub_808F534: @ 808F534 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - ldrb r0, [r4, 0x18] - lsrs r0, 4 - bl GetGoSpeed0AnimId - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r1, r5, 0 - bl FieldObjectSetRegularAnim - ldrb r0, [r4] - movs r1, 0x2 - orrs r0, r1 - strb r0, [r4] - movs r0, 0x6 - strh r0, [r5, 0x30] - movs r0, 0x1 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_808F534 - - thumb_func_start sub_808F564 -sub_808F564: @ 808F564 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl FieldObjectExecRegularAnim - lsls r0, 24 - cmp r0, 0 - beq _0808F582 - ldrb r0, [r4] - movs r1, 0x3 - negs r1, r1 - ands r1, r0 - strb r1, [r4] - movs r0, 0x1 - strh r0, [r5, 0x30] -_0808F582: - movs r0, 0 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_808F564 - thumb_func_start FieldObjectIsTrainerAndCloseToPlayer @ bool8 FieldObjectIsTrainerAndCloseToPlayer(struct npc_state *fieldObject) FieldObjectIsTrainerAndCloseToPlayer: @ 808F58C diff --git a/include/data3.h b/include/data3.h index 29b1acc34..35dba5942 100755 --- a/include/data3.h +++ b/include/data3.h @@ -17,5 +17,7 @@ extern const struct SpritePalette gUnknown_0850BBC8[]; extern const struct PairedPalettes gUnknown_0850BD00[15]; extern const struct PairedPalettes gUnknown_0850BD78[15]; extern const u16 *const gUnknown_0850BE38[2]; +extern const s16 gUnknown_0850D6DC[4]; +extern const u8 gUnknown_0850D710[4]; #endif //POKEEMERALD_DATA3_H diff --git a/include/global.h b/include/global.h index c406c507f..a006e8591 100644 --- a/include/global.h +++ b/include/global.h @@ -10,7 +10,7 @@ #define asm_comment(x) asm volatile("@ -- " x " -- ") #define asm_unified(x) asm(".syntax unified\n" x "\n.syntax divided") -#ifdef __APPLE__ +#if defined (__APPLE__) || defined (__CYGWIN__) void memset(void *, int, size_t); void memcpy(void *, const void *, size_t); #endif // __APPLE__ diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 3dd47d540..90b2f0302 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -4,6 +4,7 @@ #include "malloc.h" #include "sprite.h" #include "rom4.h" +#include "rng.h" #include "data3.h" #include "event_scripts.h" #include "berry.h" @@ -76,6 +77,14 @@ static bool8 FieldObjectDoesZCoordMatch(struct MapObject *, u8); /*static*/ void CameraObject_1(struct Sprite *); //static void CameraObject_2(struct Sprite *); /*static*/ struct MapObjectTemplate *FindFieldObjectTemplateInArrayByLocalId(u8 localId, struct MapObjectTemplate *templates, u8 count); +void npc_reset(struct MapObject *, struct Sprite *); +void FieldObjectSetRegularAnim(struct MapObject *, struct Sprite *, u8); +u8 GetFaceDirectionAnimId(u8); +bool8 FieldObjectExecRegularAnim(struct MapObject *, struct Sprite *); +void sub_8097978(struct Sprite *, s16); +bool8 sub_809797C(struct Sprite *); +bool8 sub_8092B88(struct MapObject *, u8); +u8 GetGoSpeed0AnimId(u8); // ROM data @@ -1716,7 +1725,77 @@ u16 npc_paltag_by_palslot(u8 palSlot) return 0x11ff; } +// Map Object Step Callbacks + null_object_step(NoMovement1, FALSE) field_object_step(GoRandomDirections, gUnknown_0850D6F4) +bool8 sub_808F44C(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + sprite->data1 = 1; + return TRUE; +} + +bool8 sub_808F460(struct MapObject *mapObject, struct Sprite *sprite) +{ + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(mapObject->mapobj_unk_18)); + sprite->data1 = 2; + return TRUE; +} + +bool8 sub_808F48C(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (!FieldObjectExecRegularAnim(mapObject, sprite)) + { + return FALSE; + } + sub_8097978(sprite, gUnknown_0850D6DC[Random() & 0x03]); + sprite->data1 = 3; + return TRUE; +} + +bool8 sub_808F4C8(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_809797C(sprite)) + { + sprite->data1 = 4; + return TRUE; + } + return FALSE; +} + +bool8 sub_808F4E8(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 directions[4]; + u8 chosenDirection; + + memcpy(directions, gUnknown_0850D710, sizeof directions); + chosenDirection = directions[Random() & 0x03]; + FieldObjectSetDirection(mapObject, chosenDirection); + sprite->data1 = 5; + if (sub_8092B88(mapObject, chosenDirection)) + { + sprite->data1 = 1; + } + return TRUE; +} + +bool8 sub_808F534(struct MapObject *mapObject, struct Sprite *sprite) +{ + FieldObjectSetRegularAnim(mapObject, sprite, GetGoSpeed0AnimId(mapObject->placeholder18)); + mapObject->mapobj_bit_1 = TRUE; + sprite->data1 = 6; + return TRUE; +} + +bool8 sub_808F564(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite)) + { + mapObject->mapobj_bit_1 = FALSE; + sprite->data1 = 1; + } + return FALSE; +} From d72231379bd5b113744cf28c7fe9c9d6784e0174 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 13 Sep 2017 19:13:44 -0400 Subject: [PATCH 083/191] FieldObjectIsTrainerAndCloseToPlayer --- asm/field_map_obj.s | 68 ----------------------------------- include/field_player_avatar.h | 2 ++ src/field_map_obj.c | 33 +++++++++++++++++ 3 files changed, 35 insertions(+), 68 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 8a4931322..0f021ac94 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,74 +5,6 @@ .text - thumb_func_start FieldObjectIsTrainerAndCloseToPlayer -@ bool8 FieldObjectIsTrainerAndCloseToPlayer(struct npc_state *fieldObject) -FieldObjectIsTrainerAndCloseToPlayer: @ 808F58C - push {r4-r7,lr} - sub sp, 0x4 - adds r5, r0, 0 - movs r0, 0x80 - bl TestPlayerAvatarFlags - lsls r0, 24 - cmp r0, 0 - beq _0808F5F8 - ldrb r0, [r5, 0x7] - cmp r0, 0x1 - beq _0808F5A8 - cmp r0, 0x3 - bne _0808F5F8 -_0808F5A8: - mov r7, sp - adds r7, 0x2 - mov r0, sp - adds r1, r7, 0 - bl PlayerGetDestCoords - ldrh r2, [r5, 0x10] - ldrh r4, [r5, 0x12] - ldrb r1, [r5, 0x1D] - subs r3, r2, r1 - subs r0, r4, r1 - lsls r0, 16 - lsrs r5, r0, 16 - adds r2, r1, r2 - lsls r2, 16 - lsrs r2, 16 - adds r1, r4 - lsls r1, 16 - lsrs r6, r1, 16 - mov r0, sp - lsls r3, 16 - asrs r3, 16 - movs r1, 0 - ldrsh r4, [r0, r1] - cmp r3, r4 - bgt _0808F5F8 - lsls r0, r2, 16 - asrs r0, 16 - cmp r0, r4 - blt _0808F5F8 - lsls r0, r5, 16 - asrs r0, 16 - movs r2, 0 - ldrsh r1, [r7, r2] - cmp r0, r1 - bgt _0808F5F8 - lsls r0, r6, 16 - asrs r0, 16 - cmp r0, r1 - bge _0808F5FC -_0808F5F8: - movs r0, 0 - b _0808F5FE -_0808F5FC: - movs r0, 0x1 -_0808F5FE: - add sp, 0x4 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end FieldObjectIsTrainerAndCloseToPlayer - thumb_func_start sub_808F608 sub_808F608: @ 808F608 push {r4,lr} diff --git a/include/field_player_avatar.h b/include/field_player_avatar.h index 5e2f0822c..3a74b3b10 100644 --- a/include/field_player_avatar.h +++ b/include/field_player_avatar.h @@ -8,5 +8,7 @@ void ClearPlayerAvatarInfo(void); void SetPlayerAvatarExtraStateTransition(u8, u8); u8 GetPlayerAvatarGenderByGraphicsId(u8); +bool8 TestPlayerAvatarFlags(u8); +void PlayerGetDestCoords(s16 *, s16 *); #endif //POKEEMERALD_FIELD_PLAYER_AVATAR_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 90b2f0302..f86e544a8 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -1799,3 +1799,36 @@ bool8 sub_808F564(struct MapObject *mapObject, struct Sprite *sprite) } return FALSE; } + +bool8 FieldObjectIsTrainerAndCloseToPlayer(struct MapObject *mapObject) +{ + s16 playerX; + s16 playerY; + s16 objX; + s16 objY; + s16 minX; + s16 maxX; + s16 minY; + s16 maxY; + + if (!TestPlayerAvatarFlags(0x80)) + { + return FALSE; + } + if (mapObject->trainerType != 1 && mapObject->trainerType != 3) + { + return FALSE; + } + PlayerGetDestCoords(&playerX, &playerY); + objX = mapObject->coords2.x; + objY = mapObject->coords2.y; + minX = objX - mapObject->trainerRange_berryTreeId; + minY = objY - mapObject->trainerRange_berryTreeId; + maxX = objX + mapObject->trainerRange_berryTreeId; + maxY = objY + mapObject->trainerRange_berryTreeId; + if (minX > playerX || maxX < playerX || minY > playerY || maxY < playerY) + { + return FALSE; + } + return TRUE; +} From c2e31f0618e19a1edad6bfface74901c8cd405f7 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 13 Sep 2017 19:21:05 -0400 Subject: [PATCH 084/191] sub_808F608 --- asm/field_map_obj.s | 30 ------------------------------ src/field_map_obj.c | 23 +++++++++++++++++++++++ 2 files changed, 23 insertions(+), 30 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 0f021ac94..3abd53321 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,36 +5,6 @@ .text - thumb_func_start sub_808F608 -sub_808F608: @ 808F608 - push {r4,lr} - lsls r0, 16 - lsrs r4, r0, 16 - lsls r1, 16 - lsrs r0, r1, 16 - lsls r2, 16 - lsls r3, 16 - cmp r2, r3 - ble _0808F626 - movs r2, 0x4 - lsls r0, r4, 16 - cmp r0, 0 - bge _0808F630 - movs r2, 0x3 - b _0808F630 -_0808F626: - movs r2, 0x1 - lsls r0, 16 - cmp r0, 0 - bge _0808F630 - movs r2, 0x2 -_0808F630: - adds r0, r2, 0 - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_808F608 - thumb_func_start sub_808F638 sub_808F638: @ 808F638 push {lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index f86e544a8..fd3cc7967 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -1832,3 +1832,26 @@ bool8 FieldObjectIsTrainerAndCloseToPlayer(struct MapObject *mapObject) } return TRUE; } + +u8 sub_808F608(s16 x1, s16 x2, s16 y1, s16 y2) +{ + u8 retval; + + if (y1 > y2) + { + retval = DIR_EAST; + if (x1 < 0) + { + retval = DIR_WEST; + } + } + else + { + retval = DIR_SOUTH; + if (x2 < 0) + { + retval = DIR_NORTH; + } + } + return retval; +} From f9de01dc863fb0b9a7a2d4c4412e213b259eb4c7 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 13 Sep 2017 19:45:59 -0400 Subject: [PATCH 085/191] sub_808F638 and sub_808F648 --- asm/field_map_obj.s | 27 --------------------------- src/field_map_obj.c | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 27 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 3abd53321..972dbbd50 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,33 +5,6 @@ .text - thumb_func_start sub_808F638 -sub_808F638: @ 808F638 - push {lr} - movs r0, 0x1 - lsls r1, 16 - cmp r1, 0 - bge _0808F644 - movs r0, 0x2 -_0808F644: - pop {r1} - bx r1 - thumb_func_end sub_808F638 - - thumb_func_start sub_808F648 -sub_808F648: @ 808F648 - push {lr} - movs r1, 0x4 - lsls r0, 16 - cmp r0, 0 - bge _0808F654 - movs r1, 0x3 -_0808F654: - adds r0, r1, 0 - pop {r1} - bx r1 - thumb_func_end sub_808F648 - thumb_func_start sub_808F65C sub_808F65C: @ 808F65C push {r4-r7,lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index fd3cc7967..0cb73620c 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -1855,3 +1855,27 @@ u8 sub_808F608(s16 x1, s16 x2, s16 y1, s16 y2) } return retval; } + +u8 sub_808F638(s16 x1, s16 x2, s16 y1, s16 y2) +{ + u8 retval; + + retval = DIR_SOUTH; + if (x2 < 0) + { + retval = DIR_NORTH; + } + return retval; +} + +u8 sub_808F648(s16 x1, s16 x2, s16 y1, s16 y2) +{ + u8 retval; + + retval = DIR_EAST; + if (x1 < 0) + { + retval = DIR_WEST; + } + return retval; +} From a04666e2d3f04e0f8158ce2a769042f696846830 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 13 Sep 2017 19:54:43 -0400 Subject: [PATCH 086/191] Running-past facing direction callbacks (North/East restricted) --- asm/field_map_obj.s | 84 +++++++++------------------------------------ src/field_map_obj.c | 68 ++++++++++++++++++++++++------------ 2 files changed, 63 insertions(+), 89 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 972dbbd50..342b98927 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,56 +5,6 @@ .text - thumb_func_start sub_808F65C -sub_808F65C: @ 808F65C - push {r4-r7,lr} - lsls r0, 16 - asrs r4, r0, 16 - lsls r1, 16 - asrs r5, r1, 16 - lsls r2, 16 - asrs r6, r2, 16 - lsls r3, 16 - asrs r7, r3, 16 - adds r0, r4, 0 - adds r1, r5, 0 - adds r2, r6, 0 - adds r3, r7, 0 - bl sub_808F608 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0808F698 - adds r0, r4, 0 - adds r1, r5, 0 - adds r2, r6, 0 - adds r3, r7, 0 - bl sub_808F648 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x4 - bne _0808F6B2 - b _0808F6B0 -_0808F698: - cmp r0, 0x4 - bne _0808F6B2 - adds r0, r4, 0 - adds r1, r5, 0 - adds r2, r6, 0 - adds r3, r7, 0 - bl sub_808F638 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0808F6B2 -_0808F6B0: - movs r0, 0x2 -_0808F6B2: - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_808F65C - thumb_func_start sub_808F6B8 sub_808F6B8: @ 808F6B8 push {r4-r7,lr} @@ -70,7 +20,7 @@ sub_808F6B8: @ 808F6B8 adds r1, r5, 0 adds r2, r6, 0 adds r3, r7, 0 - bl sub_808F608 + bl GetRegularRunningPastFacingDirection lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -79,7 +29,7 @@ sub_808F6B8: @ 808F6B8 adds r1, r5, 0 adds r2, r6, 0 adds r3, r7, 0 - bl sub_808F648 + bl GetEastWestRunningPastFacingDirection lsls r0, 24 lsrs r0, 24 cmp r0, 0x3 @@ -92,7 +42,7 @@ _0808F6F4: adds r1, r5, 0 adds r2, r6, 0 adds r3, r7, 0 - bl sub_808F638 + bl GetNorthSouthRunningPastFacingDirection lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -120,7 +70,7 @@ sub_808F714: @ 808F714 adds r1, r5, 0 adds r2, r6, 0 adds r3, r7, 0 - bl sub_808F608 + bl GetRegularRunningPastFacingDirection lsls r0, 24 lsrs r0, 24 cmp r0, 0x2 @@ -129,7 +79,7 @@ sub_808F714: @ 808F714 adds r1, r5, 0 adds r2, r6, 0 adds r3, r7, 0 - bl sub_808F648 + bl GetEastWestRunningPastFacingDirection lsls r0, 24 lsrs r0, 24 cmp r0, 0x4 @@ -142,7 +92,7 @@ _0808F750: adds r1, r5, 0 adds r2, r6, 0 adds r3, r7, 0 - bl sub_808F638 + bl GetNorthSouthRunningPastFacingDirection lsls r0, 24 lsrs r0, 24 cmp r0, 0x2 @@ -170,7 +120,7 @@ sub_808F770: @ 808F770 adds r1, r5, 0 adds r2, r6, 0 adds r3, r7, 0 - bl sub_808F608 + bl GetRegularRunningPastFacingDirection lsls r0, 24 lsrs r0, 24 cmp r0, 0x2 @@ -179,7 +129,7 @@ sub_808F770: @ 808F770 adds r1, r5, 0 adds r2, r6, 0 adds r3, r7, 0 - bl sub_808F648 + bl GetEastWestRunningPastFacingDirection lsls r0, 24 lsrs r0, 24 cmp r0, 0x3 @@ -192,7 +142,7 @@ _0808F7AC: adds r1, r5, 0 adds r2, r6, 0 adds r3, r7, 0 - bl sub_808F638 + bl GetNorthSouthRunningPastFacingDirection lsls r0, 24 lsrs r0, 24 cmp r0, 0x2 @@ -220,7 +170,7 @@ sub_808F7CC: @ 808F7CC adds r1, r6, 0 adds r2, r5, 0 adds r3, r4, 0 - bl sub_808F608 + bl GetRegularRunningPastFacingDirection lsls r0, 24 lsrs r0, 24 cmp r0, 0x4 @@ -229,7 +179,7 @@ sub_808F7CC: @ 808F7CC adds r1, r6, 0 adds r2, r5, 0 adds r3, r4, 0 - bl sub_808F638 + bl GetNorthSouthRunningPastFacingDirection lsls r0, 24 lsrs r0, 24 _0808F802: @@ -253,7 +203,7 @@ sub_808F808: @ 808F808 adds r1, r6, 0 adds r2, r5, 0 adds r3, r4, 0 - bl sub_808F608 + bl GetRegularRunningPastFacingDirection lsls r0, 24 lsrs r0, 24 cmp r0, 0x3 @@ -262,7 +212,7 @@ sub_808F808: @ 808F808 adds r1, r6, 0 adds r2, r5, 0 adds r3, r4, 0 - bl sub_808F638 + bl GetNorthSouthRunningPastFacingDirection lsls r0, 24 lsrs r0, 24 _0808F83E: @@ -286,7 +236,7 @@ sub_808F844: @ 808F844 adds r1, r6, 0 adds r2, r5, 0 adds r3, r4, 0 - bl sub_808F608 + bl GetRegularRunningPastFacingDirection lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -295,7 +245,7 @@ sub_808F844: @ 808F844 adds r1, r6, 0 adds r2, r5, 0 adds r3, r4, 0 - bl sub_808F648 + bl GetEastWestRunningPastFacingDirection lsls r0, 24 lsrs r0, 24 _0808F87A: @@ -319,7 +269,7 @@ sub_808F880: @ 808F880 adds r1, r6, 0 adds r2, r5, 0 adds r3, r4, 0 - bl sub_808F608 + bl GetRegularRunningPastFacingDirection lsls r0, 24 lsrs r0, 24 cmp r0, 0x2 @@ -328,7 +278,7 @@ sub_808F880: @ 808F880 adds r1, r6, 0 adds r2, r5, 0 adds r3, r4, 0 - bl sub_808F648 + bl GetEastWestRunningPastFacingDirection lsls r0, 24 lsrs r0, 24 _0808F8B6: diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 0cb73620c..4b92a792d 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -1833,49 +1833,73 @@ bool8 FieldObjectIsTrainerAndCloseToPlayer(struct MapObject *mapObject) return TRUE; } -u8 sub_808F608(s16 x1, s16 x2, s16 y1, s16 y2) +u8 GetRegularRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2) { - u8 retval; + u8 direction; - if (y1 > y2) + if (dx2 > dy2) { - retval = DIR_EAST; - if (x1 < 0) + direction = DIR_EAST; + if (dx1 < 0) { - retval = DIR_WEST; + direction = DIR_WEST; } } else { - retval = DIR_SOUTH; - if (x2 < 0) + direction = DIR_SOUTH; + if (dy1 < 0) { - retval = DIR_NORTH; + direction = DIR_NORTH; } } - return retval; + return direction; } -u8 sub_808F638(s16 x1, s16 x2, s16 y1, s16 y2) +u8 GetNorthSouthRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2) { - u8 retval; + u8 direction; - retval = DIR_SOUTH; - if (x2 < 0) + direction = DIR_SOUTH; + if (dy1 < 0) { - retval = DIR_NORTH; + direction = DIR_NORTH; } - return retval; + return direction; } -u8 sub_808F648(s16 x1, s16 x2, s16 y1, s16 y2) +u8 GetEastWestRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2) { - u8 retval; + u8 direction; - retval = DIR_EAST; - if (x1 < 0) + direction = DIR_EAST; + if (dx1 < 0) { - retval = DIR_WEST; + direction = DIR_WEST; } - return retval; + return direction; +} + +u8 GetNorthEastRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2) +{ + u8 direction; + + direction = GetRegularRunningPastFacingDirection(dx1, dy1, dx2, dy2); + if (direction == DIR_SOUTH) + { + direction = GetEastWestRunningPastFacingDirection(dx1, dy1, dx2, dy2); + if (direction == DIR_EAST) + { + direction = DIR_NORTH; + } + } + else if (direction == DIR_EAST) + { + direction = GetNorthSouthRunningPastFacingDirection(dx1, dy1, dx2, dy2); + if (direction == DIR_SOUTH) + { + direction = DIR_NORTH; + } + } + return direction; } From 6b906d95b986611d148780e8c8fc0be367569ca2 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 13 Sep 2017 20:22:38 -0400 Subject: [PATCH 087/191] Three more running-past-facing-direction callbacks --- asm/field_map_obj.s | 150 -------------------------------------------- src/field_map_obj.c | 72 +++++++++++++++++++++ 2 files changed, 72 insertions(+), 150 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 342b98927..95347c52d 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,156 +5,6 @@ .text - thumb_func_start sub_808F6B8 -sub_808F6B8: @ 808F6B8 - push {r4-r7,lr} - lsls r0, 16 - asrs r4, r0, 16 - lsls r1, 16 - asrs r5, r1, 16 - lsls r2, 16 - asrs r6, r2, 16 - lsls r3, 16 - asrs r7, r3, 16 - adds r0, r4, 0 - adds r1, r5, 0 - adds r2, r6, 0 - adds r3, r7, 0 - bl GetRegularRunningPastFacingDirection - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0808F6F4 - adds r0, r4, 0 - adds r1, r5, 0 - adds r2, r6, 0 - adds r3, r7, 0 - bl GetEastWestRunningPastFacingDirection - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x3 - bne _0808F70E - b _0808F70C -_0808F6F4: - cmp r0, 0x3 - bne _0808F70E - adds r0, r4, 0 - adds r1, r5, 0 - adds r2, r6, 0 - adds r3, r7, 0 - bl GetNorthSouthRunningPastFacingDirection - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0808F70E -_0808F70C: - movs r0, 0x2 -_0808F70E: - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_808F6B8 - - thumb_func_start sub_808F714 -sub_808F714: @ 808F714 - push {r4-r7,lr} - lsls r0, 16 - asrs r4, r0, 16 - lsls r1, 16 - asrs r5, r1, 16 - lsls r2, 16 - asrs r6, r2, 16 - lsls r3, 16 - asrs r7, r3, 16 - adds r0, r4, 0 - adds r1, r5, 0 - adds r2, r6, 0 - adds r3, r7, 0 - bl GetRegularRunningPastFacingDirection - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x2 - bne _0808F750 - adds r0, r4, 0 - adds r1, r5, 0 - adds r2, r6, 0 - adds r3, r7, 0 - bl GetEastWestRunningPastFacingDirection - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x4 - bne _0808F76A - b _0808F768 -_0808F750: - cmp r0, 0x4 - bne _0808F76A - adds r0, r4, 0 - adds r1, r5, 0 - adds r2, r6, 0 - adds r3, r7, 0 - bl GetNorthSouthRunningPastFacingDirection - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x2 - bne _0808F76A -_0808F768: - movs r0, 0x1 -_0808F76A: - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_808F714 - - thumb_func_start sub_808F770 -sub_808F770: @ 808F770 - push {r4-r7,lr} - lsls r0, 16 - asrs r4, r0, 16 - lsls r1, 16 - asrs r5, r1, 16 - lsls r2, 16 - asrs r6, r2, 16 - lsls r3, 16 - asrs r7, r3, 16 - adds r0, r4, 0 - adds r1, r5, 0 - adds r2, r6, 0 - adds r3, r7, 0 - bl GetRegularRunningPastFacingDirection - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x2 - bne _0808F7AC - adds r0, r4, 0 - adds r1, r5, 0 - adds r2, r6, 0 - adds r3, r7, 0 - bl GetEastWestRunningPastFacingDirection - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x3 - bne _0808F7C6 - b _0808F7C4 -_0808F7AC: - cmp r0, 0x3 - bne _0808F7C6 - adds r0, r4, 0 - adds r1, r5, 0 - adds r2, r6, 0 - adds r3, r7, 0 - bl GetNorthSouthRunningPastFacingDirection - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x2 - bne _0808F7C6 -_0808F7C4: - movs r0, 0x1 -_0808F7C6: - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_808F770 - thumb_func_start sub_808F7CC sub_808F7CC: @ 808F7CC push {r4-r7,lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 4b92a792d..00ccb4493 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -1903,3 +1903,75 @@ u8 GetNorthEastRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2) } return direction; } + +u8 GetNorthWestRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2) +{ + u8 direction; + + direction = GetRegularRunningPastFacingDirection(dx1, dy1, dx2, dy2); + if (direction == DIR_SOUTH) + { + direction = GetEastWestRunningPastFacingDirection(dx1, dy1, dx2, dy2); + if (direction == DIR_WEST) + { + direction = DIR_NORTH; + } + } + else if (direction == DIR_WEST) + { + direction = GetNorthSouthRunningPastFacingDirection(dx1, dy1, dx2, dy2); + if (direction == DIR_SOUTH) + { + direction = DIR_NORTH; + } + } + return direction; +} + +u8 GetSouthEastRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2) +{ + u8 direction; + + direction = GetRegularRunningPastFacingDirection(dx1, dy1, dx2, dy2); + if (direction == DIR_NORTH) + { + direction = GetEastWestRunningPastFacingDirection(dx1, dy1, dx2, dy2); + if (direction == DIR_EAST) + { + direction = DIR_SOUTH; + } + } + else if (direction == DIR_EAST) + { + direction = GetNorthSouthRunningPastFacingDirection(dx1, dy1, dx2, dy2); + if (direction == DIR_NORTH) + { + direction = DIR_SOUTH; + } + } + return direction; +} + +u8 GetSouthWestRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2) +{ + u8 direction; + + direction = GetRegularRunningPastFacingDirection(dx1, dy1, dx2, dy2); + if (direction == DIR_NORTH) + { + direction = GetEastWestRunningPastFacingDirection(dx1, dy1, dx2, dy2); + if (direction == DIR_WEST) + { + direction = DIR_SOUTH; + } + } + else if (direction == DIR_WEST) + { + direction = GetNorthSouthRunningPastFacingDirection(dx1, dy1, dx2, dy2); + if (direction == DIR_NORTH) + { + direction = DIR_SOUTH; + } + } + return direction; +} From c1f5183f4033fa29868fdc1c7aa64a51fd939615 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 13 Sep 2017 20:26:08 -0400 Subject: [PATCH 088/191] Three-direction get-running-past-facing callbacks --- asm/field_map_obj.s | 132 -------------------------------------------- src/field_map_obj.c | 48 ++++++++++++++++ 2 files changed, 48 insertions(+), 132 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 95347c52d..914a44500 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,138 +5,6 @@ .text - thumb_func_start sub_808F7CC -sub_808F7CC: @ 808F7CC - push {r4-r7,lr} - lsls r0, 16 - asrs r7, r0, 16 - lsls r1, 16 - asrs r6, r1, 16 - lsls r2, 16 - asrs r5, r2, 16 - lsls r3, 16 - asrs r4, r3, 16 - adds r0, r7, 0 - adds r1, r6, 0 - adds r2, r5, 0 - adds r3, r4, 0 - bl GetRegularRunningPastFacingDirection - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x4 - bne _0808F802 - adds r0, r7, 0 - adds r1, r6, 0 - adds r2, r5, 0 - adds r3, r4, 0 - bl GetNorthSouthRunningPastFacingDirection - lsls r0, 24 - lsrs r0, 24 -_0808F802: - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_808F7CC - - thumb_func_start sub_808F808 -sub_808F808: @ 808F808 - push {r4-r7,lr} - lsls r0, 16 - asrs r7, r0, 16 - lsls r1, 16 - asrs r6, r1, 16 - lsls r2, 16 - asrs r5, r2, 16 - lsls r3, 16 - asrs r4, r3, 16 - adds r0, r7, 0 - adds r1, r6, 0 - adds r2, r5, 0 - adds r3, r4, 0 - bl GetRegularRunningPastFacingDirection - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x3 - bne _0808F83E - adds r0, r7, 0 - adds r1, r6, 0 - adds r2, r5, 0 - adds r3, r4, 0 - bl GetNorthSouthRunningPastFacingDirection - lsls r0, 24 - lsrs r0, 24 -_0808F83E: - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_808F808 - - thumb_func_start sub_808F844 -sub_808F844: @ 808F844 - push {r4-r7,lr} - lsls r0, 16 - asrs r7, r0, 16 - lsls r1, 16 - asrs r6, r1, 16 - lsls r2, 16 - asrs r5, r2, 16 - lsls r3, 16 - asrs r4, r3, 16 - adds r0, r7, 0 - adds r1, r6, 0 - adds r2, r5, 0 - adds r3, r4, 0 - bl GetRegularRunningPastFacingDirection - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0808F87A - adds r0, r7, 0 - adds r1, r6, 0 - adds r2, r5, 0 - adds r3, r4, 0 - bl GetEastWestRunningPastFacingDirection - lsls r0, 24 - lsrs r0, 24 -_0808F87A: - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_808F844 - - thumb_func_start sub_808F880 -sub_808F880: @ 808F880 - push {r4-r7,lr} - lsls r0, 16 - asrs r7, r0, 16 - lsls r1, 16 - asrs r6, r1, 16 - lsls r2, 16 - asrs r5, r2, 16 - lsls r3, 16 - asrs r4, r3, 16 - adds r0, r7, 0 - adds r1, r6, 0 - adds r2, r5, 0 - adds r3, r4, 0 - bl GetRegularRunningPastFacingDirection - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x2 - bne _0808F8B6 - adds r0, r7, 0 - adds r1, r6, 0 - adds r2, r5, 0 - adds r3, r4, 0 - bl GetEastWestRunningPastFacingDirection - lsls r0, 24 - lsrs r0, 24 -_0808F8B6: - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_808F880 - thumb_func_start sub_808F8BC sub_808F8BC: @ 808F8BC push {r4-r6,lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 00ccb4493..48b423d85 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -1975,3 +1975,51 @@ u8 GetSouthWestRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2) } return direction; } + +u8 GetNonEastRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2) +{ + u8 direction; + + direction = GetRegularRunningPastFacingDirection(dx1, dy1, dx2, dy2); + if (direction == DIR_EAST) + { + direction = GetNorthSouthRunningPastFacingDirection(dx1, dy1, dx2, dy2); + } + return direction; +} + +u8 GetNonWestRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2) +{ + u8 direction; + + direction = GetRegularRunningPastFacingDirection(dx1, dy1, dx2, dy2); + if (direction == DIR_WEST) + { + direction = GetNorthSouthRunningPastFacingDirection(dx1, dy1, dx2, dy2); + } + return direction; +} + +u8 GetNonSouthRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2) +{ + u8 direction; + + direction = GetRegularRunningPastFacingDirection(dx1, dy1, dx2, dy2); + if (direction == DIR_SOUTH) + { + direction = GetEastWestRunningPastFacingDirection(dx1, dy1, dx2, dy2); + } + return direction; +} + +u8 GetNonNorthRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2) +{ + u8 direction; + + direction = GetRegularRunningPastFacingDirection(dx1, dy1, dx2, dy2); + if (direction == DIR_NORTH) + { + direction = GetEastWestRunningPastFacingDirection(dx1, dy1, dx2, dy2); + } + return direction; +} From ddf712beac8f166c90c0f97d2a6ccdc97c7f6d08 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 13 Sep 2017 20:34:25 -0400 Subject: [PATCH 089/191] sub_808F8BC --- asm/field_map_obj.s | 72 ------------------------------- src/field_map_obj.c | 100 ++++++++++++++++++++++++++++---------------- 2 files changed, 64 insertions(+), 108 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 914a44500..bf447c447 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,78 +5,6 @@ .text - thumb_func_start sub_808F8BC -sub_808F8BC: @ 808F8BC - push {r4-r6,lr} - sub sp, 0x4 - adds r4, r0, 0 - lsls r1, 24 - lsrs r6, r1, 24 - bl FieldObjectIsTrainerAndCloseToPlayer - lsls r0, 24 - cmp r0, 0 - bne _0808F8D4 - movs r0, 0 - b _0808F938 -_0808F8D4: - mov r5, sp - adds r5, 0x2 - mov r0, sp - adds r1, r5, 0 - bl PlayerGetDestCoords - mov r2, sp - mov r0, sp - ldrh r0, [r0] - ldrh r1, [r4, 0x10] - subs r0, r1 - strh r0, [r2] - ldrh r0, [r5] - ldrh r1, [r4, 0x12] - subs r0, r1 - strh r0, [r5] - mov r0, sp - ldrh r3, [r5] - ldrh r2, [r0] - movs r1, 0 - ldrsh r0, [r0, r1] - cmp r0, 0 - bge _0808F908 - negs r0, r0 - lsls r0, 16 - lsrs r2, r0, 16 -_0808F908: - lsls r0, r3, 16 - asrs r0, 16 - cmp r0, 0 - bge _0808F916 - negs r0, r0 - lsls r0, 16 - lsrs r3, r0, 16 -_0808F916: - ldr r0, =gUnknown_0850D714 - lsls r4, r6, 2 - adds r4, r0 - mov r0, sp - movs r6, 0 - ldrsh r0, [r0, r6] - movs r6, 0 - ldrsh r1, [r5, r6] - lsls r2, 16 - asrs r2, 16 - lsls r3, 16 - asrs r3, 16 - ldr r4, [r4] - bl _call_via_r4 - lsls r0, 24 - lsrs r0, 24 -_0808F938: - add sp, 0x4 - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end sub_808F8BC - thumb_func_start FieldObjectCB_LookRandomDirections FieldObjectCB_LookRandomDirections: @ 808F944 push {lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 48b423d85..24f48db40 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -93,6 +93,7 @@ const u8 gUnknown_0850557C[NUM_FIELD_MAP_OBJECT_TEMPLATES]; const u8 gUnknown_085055CD[NUM_FIELD_MAP_OBJECT_TEMPLATES]; const struct MapObjectGraphicsInfo *const gMauvilleOldManGraphicsInfoPointers[7]; const struct MapObjectGraphicsInfo *const gFieldObjectGraphicsInfoPointers[0xEF]; +u8 (*const gUnknown_0850D714[11])(s16, s16, s16, s16); // Code @@ -1833,14 +1834,14 @@ bool8 FieldObjectIsTrainerAndCloseToPlayer(struct MapObject *mapObject) return TRUE; } -u8 GetRegularRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2) +u8 GetRegularRunningPastFacingDirection(s16 dx, s16 dy, s16 absdx, s16 absdy) { u8 direction; - if (dx2 > dy2) + if (absdx > absdy) { direction = DIR_EAST; - if (dx1 < 0) + if (dx < 0) { direction = DIR_WEST; } @@ -1848,7 +1849,7 @@ u8 GetRegularRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2) else { direction = DIR_SOUTH; - if (dy1 < 0) + if (dy < 0) { direction = DIR_NORTH; } @@ -1856,38 +1857,38 @@ u8 GetRegularRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2) return direction; } -u8 GetNorthSouthRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2) +u8 GetNorthSouthRunningPastFacingDirection(s16 dx, s16 dy, s16 absdx, s16 absdy) { u8 direction; direction = DIR_SOUTH; - if (dy1 < 0) + if (dy < 0) { direction = DIR_NORTH; } return direction; } -u8 GetEastWestRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2) +u8 GetEastWestRunningPastFacingDirection(s16 dx, s16 dy, s16 absdx, s16 absdy) { u8 direction; direction = DIR_EAST; - if (dx1 < 0) + if (dx < 0) { direction = DIR_WEST; } return direction; } -u8 GetNorthEastRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2) +u8 GetNorthEastRunningPastFacingDirection(s16 dx, s16 dy, s16 absdx, s16 absdy) { u8 direction; - direction = GetRegularRunningPastFacingDirection(dx1, dy1, dx2, dy2); + direction = GetRegularRunningPastFacingDirection(dx, dy, absdx, absdy); if (direction == DIR_SOUTH) { - direction = GetEastWestRunningPastFacingDirection(dx1, dy1, dx2, dy2); + direction = GetEastWestRunningPastFacingDirection(dx, dy, absdx, absdy); if (direction == DIR_EAST) { direction = DIR_NORTH; @@ -1895,7 +1896,7 @@ u8 GetNorthEastRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2) } else if (direction == DIR_EAST) { - direction = GetNorthSouthRunningPastFacingDirection(dx1, dy1, dx2, dy2); + direction = GetNorthSouthRunningPastFacingDirection(dx, dy, absdx, absdy); if (direction == DIR_SOUTH) { direction = DIR_NORTH; @@ -1904,14 +1905,14 @@ u8 GetNorthEastRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2) return direction; } -u8 GetNorthWestRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2) +u8 GetNorthWestRunningPastFacingDirection(s16 dx, s16 dy, s16 absdx, s16 absdy) { u8 direction; - direction = GetRegularRunningPastFacingDirection(dx1, dy1, dx2, dy2); + direction = GetRegularRunningPastFacingDirection(dx, dy, absdx, absdy); if (direction == DIR_SOUTH) { - direction = GetEastWestRunningPastFacingDirection(dx1, dy1, dx2, dy2); + direction = GetEastWestRunningPastFacingDirection(dx, dy, absdx, absdy); if (direction == DIR_WEST) { direction = DIR_NORTH; @@ -1919,7 +1920,7 @@ u8 GetNorthWestRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2) } else if (direction == DIR_WEST) { - direction = GetNorthSouthRunningPastFacingDirection(dx1, dy1, dx2, dy2); + direction = GetNorthSouthRunningPastFacingDirection(dx, dy, absdx, absdy); if (direction == DIR_SOUTH) { direction = DIR_NORTH; @@ -1928,14 +1929,14 @@ u8 GetNorthWestRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2) return direction; } -u8 GetSouthEastRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2) +u8 GetSouthEastRunningPastFacingDirection(s16 dx, s16 dy, s16 absdx, s16 absdy) { u8 direction; - direction = GetRegularRunningPastFacingDirection(dx1, dy1, dx2, dy2); + direction = GetRegularRunningPastFacingDirection(dx, dy, absdx, absdy); if (direction == DIR_NORTH) { - direction = GetEastWestRunningPastFacingDirection(dx1, dy1, dx2, dy2); + direction = GetEastWestRunningPastFacingDirection(dx, dy, absdx, absdy); if (direction == DIR_EAST) { direction = DIR_SOUTH; @@ -1943,7 +1944,7 @@ u8 GetSouthEastRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2) } else if (direction == DIR_EAST) { - direction = GetNorthSouthRunningPastFacingDirection(dx1, dy1, dx2, dy2); + direction = GetNorthSouthRunningPastFacingDirection(dx, dy, absdx, absdy); if (direction == DIR_NORTH) { direction = DIR_SOUTH; @@ -1952,14 +1953,14 @@ u8 GetSouthEastRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2) return direction; } -u8 GetSouthWestRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2) +u8 GetSouthWestRunningPastFacingDirection(s16 dx, s16 dy, s16 absdx, s16 absdy) { u8 direction; - direction = GetRegularRunningPastFacingDirection(dx1, dy1, dx2, dy2); + direction = GetRegularRunningPastFacingDirection(dx, dy, absdx, absdy); if (direction == DIR_NORTH) { - direction = GetEastWestRunningPastFacingDirection(dx1, dy1, dx2, dy2); + direction = GetEastWestRunningPastFacingDirection(dx, dy, absdx, absdy); if (direction == DIR_WEST) { direction = DIR_SOUTH; @@ -1967,7 +1968,7 @@ u8 GetSouthWestRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2) } else if (direction == DIR_WEST) { - direction = GetNorthSouthRunningPastFacingDirection(dx1, dy1, dx2, dy2); + direction = GetNorthSouthRunningPastFacingDirection(dx, dy, absdx, absdy); if (direction == DIR_NORTH) { direction = DIR_SOUTH; @@ -1976,50 +1977,77 @@ u8 GetSouthWestRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2) return direction; } -u8 GetNonEastRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2) +u8 GetNonEastRunningPastFacingDirection(s16 dx, s16 dy, s16 absdx, s16 absdy) { u8 direction; - direction = GetRegularRunningPastFacingDirection(dx1, dy1, dx2, dy2); + direction = GetRegularRunningPastFacingDirection(dx, dy, absdx, absdy); if (direction == DIR_EAST) { - direction = GetNorthSouthRunningPastFacingDirection(dx1, dy1, dx2, dy2); + direction = GetNorthSouthRunningPastFacingDirection(dx, dy, absdx, absdy); } return direction; } -u8 GetNonWestRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2) +u8 GetNonWestRunningPastFacingDirection(s16 dx, s16 dy, s16 absdx, s16 absdy) { u8 direction; - direction = GetRegularRunningPastFacingDirection(dx1, dy1, dx2, dy2); + direction = GetRegularRunningPastFacingDirection(dx, dy, absdx, absdy); if (direction == DIR_WEST) { - direction = GetNorthSouthRunningPastFacingDirection(dx1, dy1, dx2, dy2); + direction = GetNorthSouthRunningPastFacingDirection(dx, dy, absdx, absdy); } return direction; } -u8 GetNonSouthRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2) +u8 GetNonSouthRunningPastFacingDirection(s16 dx, s16 dy, s16 absdx, s16 absdy) { u8 direction; - direction = GetRegularRunningPastFacingDirection(dx1, dy1, dx2, dy2); + direction = GetRegularRunningPastFacingDirection(dx, dy, absdx, absdy); if (direction == DIR_SOUTH) { - direction = GetEastWestRunningPastFacingDirection(dx1, dy1, dx2, dy2); + direction = GetEastWestRunningPastFacingDirection(dx, dy, absdx, absdy); } return direction; } -u8 GetNonNorthRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2) +u8 GetNonNorthRunningPastFacingDirection(s16 dx, s16 dy, s16 absdx, s16 absdy) { u8 direction; - direction = GetRegularRunningPastFacingDirection(dx1, dy1, dx2, dy2); + direction = GetRegularRunningPastFacingDirection(dx, dy, absdx, absdy); if (direction == DIR_NORTH) { - direction = GetEastWestRunningPastFacingDirection(dx1, dy1, dx2, dy2); + direction = GetEastWestRunningPastFacingDirection(dx, dy, absdx, absdy); } return direction; } + +u8 sub_808F8BC(struct MapObject *mapObject, u8 movementType) +{ + s16 dx; + s16 dy; + s16 absdx; + s16 absdy; + + if (!FieldObjectIsTrainerAndCloseToPlayer(mapObject)) + { + return 0; + } + PlayerGetDestCoords(&dx, &dy); + dx -= mapObject->coords2.x; + dy -= mapObject->coords2.y; + absdx = dx; + absdy = dy; + if (absdx < 0) + { + absdx = -absdx; + } + if (absdy < 0) + { + absdy = -absdy; + } + return gUnknown_0850D714[movementType](dx, dy, absdx, absdy); +} From 2895765964014d241808ee936293d255a6578daa Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 13 Sep 2017 20:36:58 -0400 Subject: [PATCH 090/191] LookRandomDirections --- asm/field_map_obj.s | 37 ------------------------------------- src/field_map_obj.c | 2 ++ 2 files changed, 2 insertions(+), 37 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index bf447c447..62cc02fb7 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,43 +5,6 @@ .text - thumb_func_start FieldObjectCB_LookRandomDirections -FieldObjectCB_LookRandomDirections: @ 808F944 - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =FieldObjectCB2_LookRandomDirections - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_LookRandomDirections - - thumb_func_start FieldObjectCB2_LookRandomDirections -@ bool8 FieldObjectCB2_LookRandomDirections(struct npc_state *fieldObject, struct obj *object) -FieldObjectCB2_LookRandomDirections: @ 808F968 - push {r4,lr} - ldr r3, =gUnknown_0850D740 - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end FieldObjectCB2_LookRandomDirections - thumb_func_start sub_808F988 @ bool8 sub_808F988(struct npc_state *fieldObject, struct obj *object) sub_808F988: @ 808F988 diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 24f48db40..9fd533f60 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -2051,3 +2051,5 @@ u8 sub_808F8BC(struct MapObject *mapObject, u8 movementType) } return gUnknown_0850D714[movementType](dx, dy, absdx, absdy); } + +field_object_step(LookRandomDirections, gUnknown_0850D740) From c1c12981fe5d89c85750a477229b3b31f2e6f2ee Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 13 Sep 2017 21:11:59 -0400 Subject: [PATCH 091/191] LookRandomDirections helpers --- asm/field_map_obj.s | 137 -------------------------------------------- src/field_map_obj.c | 51 +++++++++++++++++ 2 files changed, 51 insertions(+), 137 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 62cc02fb7..147f5e65c 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,143 +5,6 @@ .text - thumb_func_start sub_808F988 -@ bool8 sub_808F988(struct npc_state *fieldObject, struct obj *object) -sub_808F988: @ 808F988 - push {r4,lr} - adds r4, r1, 0 - bl npc_reset - movs r0, 0x1 - strh r0, [r4, 0x30] - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_808F988 - - thumb_func_start sub_808F99C -@ bool8 sub_808F99C(struct npc_state *fieldObject, struct obj *object) -sub_808F99C: @ 808F99C - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - ldrb r0, [r4, 0x18] - lsls r0, 28 - lsrs r0, 28 - bl GetFaceDirectionAnimId - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r1, r5, 0 - bl FieldObjectSetRegularAnim - movs r0, 0x2 - strh r0, [r5, 0x30] - movs r0, 0x1 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_808F99C - - thumb_func_start sub_808F9C8 -@ bool8 sub_808F9C8(struct npc_state *fieldObject, struct obj *object) -sub_808F9C8: @ 808F9C8 - push {r4-r7,lr} - adds r6, r0, 0 - adds r7, r1, 0 - bl FieldObjectExecRegularAnim - lsls r0, 24 - cmp r0, 0 - beq _0808F9FE - ldr r4, =gUnknown_0850D6DC - bl Random - movs r5, 0x3 - adds r1, r5, 0 - ands r1, r0 - lsls r1, 1 - adds r1, r4 - movs r0, 0 - ldrsh r1, [r1, r0] - adds r0, r7, 0 - bl sub_8097978 - ldrb r1, [r6] - movs r0, 0x3 - negs r0, r0 - ands r0, r1 - strb r0, [r6] - strh r5, [r7, 0x30] -_0808F9FE: - movs r0, 0 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_808F9C8 - - thumb_func_start sub_808FA0C -@ bool8 sub_808FA0C(struct npc_state *fieldObject, struct obj *object) -sub_808FA0C: @ 808FA0C - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - adds r0, r5, 0 - bl sub_809797C - lsls r0, 24 - cmp r0, 0 - bne _0808FA2A - adds r0, r4, 0 - bl FieldObjectIsTrainerAndCloseToPlayer - lsls r0, 24 - cmp r0, 0 - beq _0808FA32 -_0808FA2A: - movs r0, 0x4 - strh r0, [r5, 0x30] - movs r0, 0x1 - b _0808FA34 -_0808FA32: - movs r0, 0 -_0808FA34: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_808FA0C - - thumb_func_start sub_808FA3C -@ bool8 sub_808FA3C(struct npc_state *fieldObject, struct obj *object) -sub_808FA3C: @ 808FA3C - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - ldr r1, =gUnknown_0850D710 - mov r0, sp - movs r2, 0x4 - bl memcpy - adds r0, r4, 0 - movs r1, 0 - bl sub_808F8BC - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0 - bne _0808FA6C - bl Random - movs r1, 0x3 - ands r1, r0 - mov r2, sp - adds r0, r2, r1 - ldrb r1, [r0] -_0808FA6C: - adds r0, r4, 0 - bl FieldObjectSetDirection - movs r0, 0x1 - strh r0, [r5, 0x30] - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_808FA3C - thumb_func_start FieldObjectCB_RandomlyGoNorthOrSouth FieldObjectCB_RandomlyGoNorthOrSouth: @ 808FA84 push {lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 9fd533f60..40129cc3f 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -2053,3 +2053,54 @@ u8 sub_808F8BC(struct MapObject *mapObject, u8 movementType) } field_object_step(LookRandomDirections, gUnknown_0850D740) + +bool8 sub_808F988(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + sprite->data1 = 1; + return TRUE; +} + +bool8 sub_808F99C(struct MapObject *mapObject, struct Sprite *sprite) +{ + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(mapObject->mapobj_unk_18)); + sprite->data1 = 2; + return TRUE; +} + +bool8 sub_808F9C8(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite)) + { + sub_8097978(sprite, gUnknown_0850D6DC[Random() & 0x03]); + mapObject->mapobj_bit_1 = FALSE; + sprite->data1 = 3; + } + return FALSE; +} + +bool8 sub_808FA0C(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_809797C(sprite) || FieldObjectIsTrainerAndCloseToPlayer(mapObject)) + { + sprite->data1 = 4; + return TRUE; + } + return FALSE; +} + +bool8 sub_808FA3C(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 directions[4]; + u8 direction; + + memcpy(directions, gUnknown_0850D710, sizeof directions); + direction = sub_808F8BC(mapObject, 0); + if (direction == 0) + { + direction = directions[Random() & 0x03]; + } + FieldObjectSetDirection(mapObject, direction); + sprite->data1 = 1; + return TRUE; +} From 0ae3347e472686be8c7c21862afe4a62222cdcd1 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 14 Sep 2017 08:38:21 -0400 Subject: [PATCH 092/191] Rename some functions --- asm/field_map_obj.s | 88 +++++++++++++++++++++---------------------- asm/map_obj_8097404.s | 16 ++++---- include/data3.h | 4 +- src/field_map_obj.c | 16 ++++---- 4 files changed, 62 insertions(+), 62 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 147f5e65c..9f61afc76 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -95,7 +95,7 @@ sub_808FB08: @ 808FB08 movs r0, 0 ldrsh r1, [r1, r0] adds r0, r6, 0 - bl sub_8097978 + bl SetFieldObjectStepTimer strh r4, [r6, 0x30] movs r0, 0x1 b _0808FB3E @@ -114,7 +114,7 @@ sub_808FB44: @ 808FB44 push {r4,lr} adds r4, r1, 0 adds r0, r4, 0 - bl sub_809797C + bl RunFieldObjectStepTimer lsls r0, 24 cmp r0, 0 bne _0808FB58 @@ -307,7 +307,7 @@ sub_808FC8C: @ 808FC8C movs r0, 0 ldrsh r1, [r1, r0] adds r0, r6, 0 - bl sub_8097978 + bl SetFieldObjectStepTimer strh r4, [r6, 0x30] movs r0, 0x1 b _0808FCC2 @@ -325,7 +325,7 @@ sub_808FCC8: @ 808FCC8 push {r4,lr} adds r4, r1, 0 adds r0, r4, 0 - bl sub_809797C + bl RunFieldObjectStepTimer lsls r0, 24 cmp r0, 0 bne _0808FCDC @@ -910,7 +910,7 @@ sub_80900D4: @ 80900D4 movs r0, 0 ldrsh r1, [r1, r0] adds r0, r7, 0 - bl sub_8097978 + bl SetFieldObjectStepTimer ldrb r1, [r6] movs r0, 0x3 negs r0, r0 @@ -931,7 +931,7 @@ sub_8090118: @ 8090118 adds r4, r0, 0 adds r5, r1, 0 adds r0, r5, 0 - bl sub_809797C + bl RunFieldObjectStepTimer lsls r0, 24 cmp r0, 0 bne _08090136 @@ -965,7 +965,7 @@ sub_8090148: @ 8090148 bl memcpy adds r0, r4, 0 movs r1, 0x1 - bl sub_808F8BC + bl GetRunningPastFacingDirection lsls r0, 24 lsrs r1, r0, 24 cmp r1, 0 @@ -1078,7 +1078,7 @@ sub_8090214: @ 8090214 movs r0, 0 ldrsh r1, [r1, r0] adds r0, r7, 0 - bl sub_8097978 + bl SetFieldObjectStepTimer ldrb r1, [r6] movs r0, 0x3 negs r0, r0 @@ -1099,7 +1099,7 @@ sub_8090258: @ 8090258 adds r4, r0, 0 adds r5, r1, 0 adds r0, r5, 0 - bl sub_809797C + bl RunFieldObjectStepTimer lsls r0, 24 cmp r0, 0 bne _08090276 @@ -1133,7 +1133,7 @@ sub_8090288: @ 8090288 bl memcpy adds r0, r4, 0 movs r1, 0x2 - bl sub_808F8BC + bl GetRunningPastFacingDirection lsls r0, 24 lsrs r1, r0, 24 cmp r1, 0 @@ -1246,7 +1246,7 @@ sub_8090354: @ 8090354 movs r0, 0 ldrsh r1, [r1, r0] adds r0, r7, 0 - bl sub_8097978 + bl SetFieldObjectStepTimer ldrb r1, [r6] movs r0, 0x3 negs r0, r0 @@ -1267,7 +1267,7 @@ sub_8090398: @ 8090398 adds r4, r0, 0 adds r5, r1, 0 adds r0, r5, 0 - bl sub_809797C + bl RunFieldObjectStepTimer lsls r0, 24 cmp r0, 0 bne _080903B6 @@ -1301,7 +1301,7 @@ sub_80903C8: @ 80903C8 bl memcpy adds r0, r4, 0 movs r1, 0x3 - bl sub_808F8BC + bl GetRunningPastFacingDirection lsls r0, 24 lsrs r1, r0, 24 cmp r1, 0 @@ -1414,7 +1414,7 @@ sub_8090494: @ 8090494 movs r0, 0 ldrsh r1, [r1, r0] adds r0, r7, 0 - bl sub_8097978 + bl SetFieldObjectStepTimer ldrb r1, [r6] movs r0, 0x3 negs r0, r0 @@ -1435,7 +1435,7 @@ sub_80904D8: @ 80904D8 adds r4, r0, 0 adds r5, r1, 0 adds r0, r5, 0 - bl sub_809797C + bl RunFieldObjectStepTimer lsls r0, 24 cmp r0, 0 bne _080904F6 @@ -1469,7 +1469,7 @@ sub_8090508: @ 8090508 bl memcpy adds r0, r4, 0 movs r1, 0x4 - bl sub_808F8BC + bl GetRunningPastFacingDirection lsls r0, 24 lsrs r1, r0, 24 cmp r1, 0 @@ -1582,7 +1582,7 @@ sub_80905D4: @ 80905D4 movs r0, 0 ldrsh r1, [r1, r0] adds r0, r7, 0 - bl sub_8097978 + bl SetFieldObjectStepTimer ldrb r1, [r6] movs r0, 0x3 negs r0, r0 @@ -1603,7 +1603,7 @@ sub_8090618: @ 8090618 adds r4, r0, 0 adds r5, r1, 0 adds r0, r5, 0 - bl sub_809797C + bl RunFieldObjectStepTimer lsls r0, 24 cmp r0, 0 bne _08090636 @@ -1637,7 +1637,7 @@ sub_8090648: @ 8090648 bl memcpy adds r0, r4, 0 movs r1, 0x5 - bl sub_808F8BC + bl GetRunningPastFacingDirection lsls r0, 24 lsrs r1, r0, 24 cmp r1, 0 @@ -1750,7 +1750,7 @@ sub_8090714: @ 8090714 movs r0, 0 ldrsh r1, [r1, r0] adds r0, r7, 0 - bl sub_8097978 + bl SetFieldObjectStepTimer ldrb r1, [r6] movs r0, 0x3 negs r0, r0 @@ -1771,7 +1771,7 @@ sub_8090758: @ 8090758 adds r4, r0, 0 adds r5, r1, 0 adds r0, r5, 0 - bl sub_809797C + bl RunFieldObjectStepTimer lsls r0, 24 cmp r0, 0 bne _08090776 @@ -1805,7 +1805,7 @@ sub_8090788: @ 8090788 bl memcpy adds r0, r4, 0 movs r1, 0x6 - bl sub_808F8BC + bl GetRunningPastFacingDirection lsls r0, 24 lsrs r1, r0, 24 cmp r1, 0 @@ -1918,7 +1918,7 @@ sub_8090854: @ 8090854 movs r0, 0 ldrsh r1, [r1, r0] adds r0, r7, 0 - bl sub_8097978 + bl SetFieldObjectStepTimer ldrb r1, [r6] movs r0, 0x3 negs r0, r0 @@ -1939,7 +1939,7 @@ sub_8090898: @ 8090898 adds r4, r0, 0 adds r5, r1, 0 adds r0, r5, 0 - bl sub_809797C + bl RunFieldObjectStepTimer lsls r0, 24 cmp r0, 0 bne _080908B6 @@ -1973,7 +1973,7 @@ sub_80908C8: @ 80908C8 bl memcpy adds r0, r4, 0 movs r1, 0x7 - bl sub_808F8BC + bl GetRunningPastFacingDirection lsls r0, 24 lsrs r1, r0, 24 cmp r1, 0 @@ -2086,7 +2086,7 @@ sub_8090994: @ 8090994 movs r0, 0 ldrsh r1, [r1, r0] adds r0, r7, 0 - bl sub_8097978 + bl SetFieldObjectStepTimer ldrb r1, [r6] movs r0, 0x3 negs r0, r0 @@ -2107,7 +2107,7 @@ sub_80909D8: @ 80909D8 adds r4, r0, 0 adds r5, r1, 0 adds r0, r5, 0 - bl sub_809797C + bl RunFieldObjectStepTimer lsls r0, 24 cmp r0, 0 bne _080909F6 @@ -2141,7 +2141,7 @@ sub_8090A08: @ 8090A08 bl memcpy adds r0, r4, 0 movs r1, 0x8 - bl sub_808F8BC + bl GetRunningPastFacingDirection lsls r0, 24 lsrs r1, r0, 24 cmp r1, 0 @@ -2254,7 +2254,7 @@ sub_8090AD4: @ 8090AD4 movs r0, 0 ldrsh r1, [r1, r0] adds r0, r7, 0 - bl sub_8097978 + bl SetFieldObjectStepTimer ldrb r1, [r6] movs r0, 0x3 negs r0, r0 @@ -2275,7 +2275,7 @@ sub_8090B18: @ 8090B18 adds r4, r0, 0 adds r5, r1, 0 adds r0, r5, 0 - bl sub_809797C + bl RunFieldObjectStepTimer lsls r0, 24 cmp r0, 0 bne _08090B36 @@ -2309,7 +2309,7 @@ sub_8090B48: @ 8090B48 bl memcpy adds r0, r4, 0 movs r1, 0x9 - bl sub_808F8BC + bl GetRunningPastFacingDirection lsls r0, 24 lsrs r1, r0, 24 cmp r1, 0 @@ -2422,7 +2422,7 @@ sub_8090C14: @ 8090C14 movs r0, 0 ldrsh r1, [r1, r0] adds r0, r7, 0 - bl sub_8097978 + bl SetFieldObjectStepTimer ldrb r1, [r6] movs r0, 0x3 negs r0, r0 @@ -2443,7 +2443,7 @@ sub_8090C58: @ 8090C58 adds r4, r0, 0 adds r5, r1, 0 adds r0, r5, 0 - bl sub_809797C + bl RunFieldObjectStepTimer lsls r0, 24 cmp r0, 0 bne _08090C76 @@ -2477,7 +2477,7 @@ sub_8090C88: @ 8090C88 bl memcpy adds r0, r4, 0 movs r1, 0xA - bl sub_808F8BC + bl GetRunningPastFacingDirection lsls r0, 24 lsrs r1, r0, 24 cmp r1, 0 @@ -2569,7 +2569,7 @@ sub_8090D40: @ 8090D40 beq _08090D5A adds r0, r4, 0 movs r1, 0x30 - bl sub_8097978 + bl SetFieldObjectStepTimer movs r0, 0x2 strh r0, [r4, 0x30] _08090D5A: @@ -2585,7 +2585,7 @@ sub_8090D64: @ 8090D64 adds r4, r0, 0 adds r5, r1, 0 adds r0, r5, 0 - bl sub_809797C + bl RunFieldObjectStepTimer lsls r0, 24 cmp r0, 0 bne _08090D82 @@ -2617,7 +2617,7 @@ sub_8090D90: @ 8090D90 bl memcpy adds r0, r4, 0 movs r1, 0 - bl sub_808F8BC + bl GetRunningPastFacingDirection lsls r0, 24 lsrs r1, r0, 24 cmp r1, 0 @@ -2709,7 +2709,7 @@ sub_8090E44: @ 8090E44 beq _08090E5E adds r0, r4, 0 movs r1, 0x30 - bl sub_8097978 + bl SetFieldObjectStepTimer movs r0, 0x2 strh r0, [r4, 0x30] _08090E5E: @@ -2725,7 +2725,7 @@ sub_8090E68: @ 8090E68 adds r4, r0, 0 adds r5, r1, 0 adds r0, r5, 0 - bl sub_809797C + bl RunFieldObjectStepTimer lsls r0, 24 cmp r0, 0 bne _08090E86 @@ -2756,7 +2756,7 @@ sub_8090E94: @ 8090E94 bl memcpy adds r0, r4, 0 movs r1, 0 - bl sub_808F8BC + bl GetRunningPastFacingDirection lsls r0, 24 lsrs r1, r0, 24 cmp r1, 0 @@ -12667,7 +12667,7 @@ sub_80955C8: @ 80955C8 beq _080955E4 adds r0, r4, 0 movs r1, 0x20 - bl sub_8097978 + bl SetFieldObjectStepTimer movs r0, 0x2 strh r0, [r4, 0x32] _080955E4: @@ -12693,7 +12693,7 @@ sub_80955EC: @ 80955EC orrs r0, r1 strb r0, [r4, 0x1] adds r0, r5, 0 - bl sub_809797C + bl RunFieldObjectStepTimer lsls r0, 24 cmp r0, 0 beq _0809561E @@ -12737,7 +12737,7 @@ sub_8095644: @ 8095644 beq _08095660 adds r0, r4, 0 movs r1, 0x20 - bl sub_8097978 + bl SetFieldObjectStepTimer movs r0, 0x2 strh r0, [r4, 0x32] _08095660: @@ -12763,7 +12763,7 @@ sub_8095668: @ 8095668 orrs r0, r1 strb r0, [r4, 0x1] adds r0, r5, 0 - bl sub_809797C + bl RunFieldObjectStepTimer lsls r0, 24 cmp r0, 0 beq _0809569A diff --git a/asm/map_obj_8097404.s b/asm/map_obj_8097404.s index 6bc74d0e5..1bbf3eff2 100644 --- a/asm/map_obj_8097404.s +++ b/asm/map_obj_8097404.s @@ -769,16 +769,16 @@ _08097964: .pool thumb_func_end sub_80978E4 - thumb_func_start sub_8097978 -@ void sub_8097978(struct obj *object, u16 a2) -sub_8097978: @ 8097978 + thumb_func_start SetFieldObjectStepTimer +@ void SetFieldObjectStepTimer(struct obj *object, u16 a2) +SetFieldObjectStepTimer: @ 8097978 strh r1, [r0, 0x34] bx lr - thumb_func_end sub_8097978 + thumb_func_end SetFieldObjectStepTimer - thumb_func_start sub_809797C -@ bool8 sub_809797C(struct obj *object) -sub_809797C: @ 809797C + thumb_func_start RunFieldObjectStepTimer +@ bool8 RunFieldObjectStepTimer(struct obj *object) +RunFieldObjectStepTimer: @ 809797C push {lr} ldrh r1, [r0, 0x34] subs r1, 0x1 @@ -793,7 +793,7 @@ _0809798E: _08097990: pop {r1} bx r1 - thumb_func_end sub_809797C + thumb_func_end RunFieldObjectStepTimer thumb_func_start obj_anim_image_set_and_seek obj_anim_image_set_and_seek: @ 8097994 diff --git a/include/data3.h b/include/data3.h index 35dba5942..3c1d34759 100755 --- a/include/data3.h +++ b/include/data3.h @@ -17,7 +17,7 @@ extern const struct SpritePalette gUnknown_0850BBC8[]; extern const struct PairedPalettes gUnknown_0850BD00[15]; extern const struct PairedPalettes gUnknown_0850BD78[15]; extern const u16 *const gUnknown_0850BE38[2]; -extern const s16 gUnknown_0850D6DC[4]; -extern const u8 gUnknown_0850D710[4]; +extern const s16 gUnknown_0850D6DC[4]; // {0x20, 0x40, 0x60, 0x80} +extern const u8 gUnknown_0850D710[4]; // {DIR_SOUTH, DIR_NORTH, DIR_WEST, DIR_EAST} #endif //POKEEMERALD_DATA3_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 40129cc3f..cf11e675d 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -81,8 +81,8 @@ void npc_reset(struct MapObject *, struct Sprite *); void FieldObjectSetRegularAnim(struct MapObject *, struct Sprite *, u8); u8 GetFaceDirectionAnimId(u8); bool8 FieldObjectExecRegularAnim(struct MapObject *, struct Sprite *); -void sub_8097978(struct Sprite *, s16); -bool8 sub_809797C(struct Sprite *); +void SetFieldObjectStepTimer(struct Sprite *, s16); +bool8 RunFieldObjectStepTimer(struct Sprite *); bool8 sub_8092B88(struct MapObject *, u8); u8 GetGoSpeed0AnimId(u8); @@ -1752,14 +1752,14 @@ bool8 sub_808F48C(struct MapObject *mapObject, struct Sprite *sprite) { return FALSE; } - sub_8097978(sprite, gUnknown_0850D6DC[Random() & 0x03]); + SetFieldObjectStepTimer(sprite, gUnknown_0850D6DC[Random() & 0x03]); sprite->data1 = 3; return TRUE; } bool8 sub_808F4C8(struct MapObject *mapObject, struct Sprite *sprite) { - if (sub_809797C(sprite)) + if (RunFieldObjectStepTimer(sprite)) { sprite->data1 = 4; return TRUE; @@ -2025,7 +2025,7 @@ u8 GetNonNorthRunningPastFacingDirection(s16 dx, s16 dy, s16 absdx, s16 absdy) return direction; } -u8 sub_808F8BC(struct MapObject *mapObject, u8 movementType) +u8 GetRunningPastFacingDirection(struct MapObject *mapObject, u8 movementType) { s16 dx; s16 dy; @@ -2072,7 +2072,7 @@ bool8 sub_808F9C8(struct MapObject *mapObject, struct Sprite *sprite) { if (FieldObjectExecRegularAnim(mapObject, sprite)) { - sub_8097978(sprite, gUnknown_0850D6DC[Random() & 0x03]); + SetFieldObjectStepTimer(sprite, gUnknown_0850D6DC[Random() & 0x03]); mapObject->mapobj_bit_1 = FALSE; sprite->data1 = 3; } @@ -2081,7 +2081,7 @@ bool8 sub_808F9C8(struct MapObject *mapObject, struct Sprite *sprite) bool8 sub_808FA0C(struct MapObject *mapObject, struct Sprite *sprite) { - if (sub_809797C(sprite) || FieldObjectIsTrainerAndCloseToPlayer(mapObject)) + if (RunFieldObjectStepTimer(sprite) || FieldObjectIsTrainerAndCloseToPlayer(mapObject)) { sprite->data1 = 4; return TRUE; @@ -2095,7 +2095,7 @@ bool8 sub_808FA3C(struct MapObject *mapObject, struct Sprite *sprite) u8 direction; memcpy(directions, gUnknown_0850D710, sizeof directions); - direction = sub_808F8BC(mapObject, 0); + direction = GetRunningPastFacingDirection(mapObject, 0); if (direction == 0) { direction = directions[Random() & 0x03]; From 4a1383d77bb1da701290848020b5ebf942182283 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 14 Sep 2017 21:22:14 -0400 Subject: [PATCH 093/191] RandomlyGoNorthOrSouth --- asm/field_map_obj.s | 229 ++------------------------------------------ include/data3.h | 1 + src/field_map_obj.c | 75 ++++++++++++++- 3 files changed, 82 insertions(+), 223 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 9f61afc76..cef03345c 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,219 +5,6 @@ .text - thumb_func_start FieldObjectCB_RandomlyGoNorthOrSouth -FieldObjectCB_RandomlyGoNorthOrSouth: @ 808FA84 - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =FieldObjectCB2_RandomlyGoNorthOrSouth - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_RandomlyGoNorthOrSouth - - thumb_func_start FieldObjectCB2_RandomlyGoNorthOrSouth -FieldObjectCB2_RandomlyGoNorthOrSouth: @ 808FAA8 - push {r4,lr} - ldr r3, =gUnknown_0850D754 - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end FieldObjectCB2_RandomlyGoNorthOrSouth - - thumb_func_start sub_808FAC8 -sub_808FAC8: @ 808FAC8 - push {r4,lr} - adds r4, r1, 0 - bl npc_reset - movs r0, 0x1 - strh r0, [r4, 0x30] - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_808FAC8 - - thumb_func_start sub_808FADC -sub_808FADC: @ 808FADC - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - ldrb r0, [r4, 0x18] - lsls r0, 28 - lsrs r0, 28 - bl GetFaceDirectionAnimId - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r1, r5, 0 - bl FieldObjectSetRegularAnim - movs r0, 0x2 - strh r0, [r5, 0x30] - movs r0, 0x1 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_808FADC - - thumb_func_start sub_808FB08 -@ bool8 sub_808FB08(struct npc_state *fieldObject, struct obj *object) -sub_808FB08: @ 808FB08 - push {r4-r6,lr} - adds r6, r1, 0 - bl FieldObjectExecRegularAnim - lsls r0, 24 - cmp r0, 0 - beq _0808FB3C - ldr r5, =gUnknown_0850D6DC - bl Random - movs r4, 0x3 - adds r1, r4, 0 - ands r1, r0 - lsls r1, 1 - adds r1, r5 - movs r0, 0 - ldrsh r1, [r1, r0] - adds r0, r6, 0 - bl SetFieldObjectStepTimer - strh r4, [r6, 0x30] - movs r0, 0x1 - b _0808FB3E - .pool -_0808FB3C: - movs r0, 0 -_0808FB3E: - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end sub_808FB08 - - thumb_func_start sub_808FB44 -@ bool8 sub_808FB44(struct npc_state *fieldObject, struct obj *object) -sub_808FB44: @ 808FB44 - push {r4,lr} - adds r4, r1, 0 - adds r0, r4, 0 - bl RunFieldObjectStepTimer - lsls r0, 24 - cmp r0, 0 - bne _0808FB58 - movs r0, 0 - b _0808FB5E -_0808FB58: - movs r0, 0x4 - strh r0, [r4, 0x30] - movs r0, 0x1 -_0808FB5E: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_808FB44 - - thumb_func_start sub_808FB64 -@ bool8 sub_808FB64(struct npc_state *fieldObject, struct obj *object) -sub_808FB64: @ 808FB64 - push {r4-r7,lr} - sub sp, 0x4 - adds r5, r0, 0 - adds r6, r1, 0 - ldr r1, =gUnknown_0850D770 - mov r0, sp - movs r2, 0x2 - bl memcpy - bl Random - movs r7, 0x1 - adds r1, r7, 0 - ands r1, r0 - mov r2, sp - adds r0, r2, r1 - ldrb r4, [r0] - adds r0, r5, 0 - adds r1, r4, 0 - bl FieldObjectSetDirection - movs r0, 0x5 - strh r0, [r6, 0x30] - adds r0, r5, 0 - adds r1, r4, 0 - bl sub_8092B88 - lsls r0, 24 - cmp r0, 0 - beq _0808FBA2 - strh r7, [r6, 0x30] -_0808FBA2: - movs r0, 0x1 - add sp, 0x4 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_808FB64 - - thumb_func_start sub_808FBB0 -sub_808FBB0: @ 808FBB0 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - ldrb r0, [r4, 0x18] - lsrs r0, 4 - bl GetGoSpeed0AnimId - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r1, r5, 0 - bl FieldObjectSetRegularAnim - ldrb r0, [r4] - movs r1, 0x2 - orrs r0, r1 - strb r0, [r4] - movs r0, 0x6 - strh r0, [r5, 0x30] - movs r0, 0x1 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_808FBB0 - - thumb_func_start sub_808FBE0 -sub_808FBE0: @ 808FBE0 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl FieldObjectExecRegularAnim - lsls r0, 24 - cmp r0, 0 - beq _0808FBFE - ldrb r0, [r4] - movs r1, 0x3 - negs r1, r1 - ands r1, r0 - strb r1, [r4] - movs r0, 0x1 - strh r0, [r5, 0x30] -_0808FBFE: - movs r0, 0 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_808FBE0 - thumb_func_start FieldObjectCB_RandomlyGoEastOrWest FieldObjectCB_RandomlyGoEastOrWest: @ 808FC08 push {lr} @@ -365,7 +152,7 @@ sub_808FCE8: @ 808FCE8 strh r0, [r6, 0x30] adds r0, r5, 0 adds r1, r4, 0 - bl sub_8092B88 + bl npc_block_way__next_tile lsls r0, 24 cmp r0, 0 beq _0808FD26 @@ -2887,7 +2674,7 @@ _08090F98: ldrb r1, [r4, 0x18] lsrs r1, 4 adds r0, r4, 0 - bl sub_8092B88 + bl npc_block_way__next_tile lsls r0, 24 lsrs r5, r0, 24 ldrb r0, [r4, 0x18] @@ -2918,7 +2705,7 @@ _08090F98: ldrb r1, [r4, 0x18] lsrs r1, 4 adds r0, r4, 0 - bl sub_8092B88 + bl npc_block_way__next_tile lsls r0, 24 lsrs r5, r0, 24 _08090FEE: @@ -3020,7 +2807,7 @@ _0809107E: ldrb r1, [r4, 0x18] lsrs r1, 4 adds r0, r4, 0 - bl sub_8092B88 + bl npc_block_way__next_tile lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -3041,7 +2828,7 @@ _0809107E: ldrb r1, [r4, 0x18] lsrs r1, 4 adds r0, r4, 0 - bl sub_8092B88 + bl npc_block_way__next_tile lsls r0, 24 lsrs r0, 24 _080910D8: @@ -6629,8 +6416,8 @@ npc_running_behaviour_by_direction: @ 8092B78 .pool thumb_func_end npc_running_behaviour_by_direction - thumb_func_start sub_8092B88 -sub_8092B88: @ 8092B88 + thumb_func_start npc_block_way__next_tile +npc_block_way__next_tile: @ 8092B88 push {r4-r6,lr} sub sp, 0x4 adds r6, r0, 0 @@ -6661,7 +6448,7 @@ sub_8092B88: @ 8092B88 pop {r4-r6} pop {r1} bx r1 - thumb_func_end sub_8092B88 + thumb_func_end npc_block_way__next_tile thumb_func_start npc_block_way @ u8 npc_block_way(struct npc_state *fieldObject, u16 x, u16 y, u8 direction) diff --git a/include/data3.h b/include/data3.h index 3c1d34759..c73a8c991 100755 --- a/include/data3.h +++ b/include/data3.h @@ -19,5 +19,6 @@ extern const struct PairedPalettes gUnknown_0850BD78[15]; extern const u16 *const gUnknown_0850BE38[2]; extern const s16 gUnknown_0850D6DC[4]; // {0x20, 0x40, 0x60, 0x80} extern const u8 gUnknown_0850D710[4]; // {DIR_SOUTH, DIR_NORTH, DIR_WEST, DIR_EAST} +extern const u8 gUnknown_0850D770[2]; // {DIR_SOUTH, DIR_NORTH} #endif //POKEEMERALD_DATA3_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index cf11e675d..5b0916e33 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -83,7 +83,7 @@ u8 GetFaceDirectionAnimId(u8); bool8 FieldObjectExecRegularAnim(struct MapObject *, struct Sprite *); void SetFieldObjectStepTimer(struct Sprite *, s16); bool8 RunFieldObjectStepTimer(struct Sprite *); -bool8 sub_8092B88(struct MapObject *, u8); +bool8 npc_block_way__next_tile(struct MapObject *, u8); u8 GetGoSpeed0AnimId(u8); // ROM data @@ -1776,7 +1776,7 @@ bool8 sub_808F4E8(struct MapObject *mapObject, struct Sprite *sprite) chosenDirection = directions[Random() & 0x03]; FieldObjectSetDirection(mapObject, chosenDirection); sprite->data1 = 5; - if (sub_8092B88(mapObject, chosenDirection)) + if (npc_block_way__next_tile(mapObject, chosenDirection)) { sprite->data1 = 1; } @@ -2104,3 +2104,74 @@ bool8 sub_808FA3C(struct MapObject *mapObject, struct Sprite *sprite) sprite->data1 = 1; return TRUE; } + +field_object_step(RandomlyGoNorthOrSouth, gUnknown_0850D754) + +bool8 sub_808FAC8(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + sprite->data1 = 1; + return TRUE; +} + +bool8 sub_808FADC(struct MapObject *mapObject, struct Sprite *sprite) +{ + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(mapObject->mapobj_unk_18)); + sprite->data1 = 2; + return TRUE; +} + +bool8 sub_808FB08(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (!FieldObjectExecRegularAnim(mapObject, sprite)) + { + return FALSE; + } + SetFieldObjectStepTimer(sprite, gUnknown_0850D6DC[Random() & 0x03]); + sprite->data1 = 3; + return TRUE; +} + +bool8 sub_808FB44(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (RunFieldObjectStepTimer(sprite)) + { + sprite->data1 = 4; + return TRUE; + } + return FALSE; +} + +bool8 sub_808FB64(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 directions[2]; + u8 direction; + + memcpy(directions, gUnknown_0850D770, sizeof directions); + direction = directions[Random() & 0x01]; + FieldObjectSetDirection(mapObject, direction); + sprite->data1 = 5; + if (npc_block_way__next_tile(mapObject, direction)) + { + sprite->data1 = 1; + } + return TRUE; +} + +bool8 sub_808FBB0(struct MapObject *mapObject, struct Sprite *sprite) +{ + FieldObjectSetRegularAnim(mapObject, sprite, GetGoSpeed0AnimId(mapObject->placeholder18)); + mapObject->mapobj_bit_1 = TRUE; + sprite->data1 = 6; + return TRUE; +} + +bool8 sub_808FBE0(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite)) + { + mapObject->mapobj_bit_1 = FALSE; + sprite->data1 = 1; + } + return FALSE; +} From 68c62595f569e9b6ccca1596776330ce31d9d805 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 14 Sep 2017 21:25:30 -0400 Subject: [PATCH 094/191] RandomlyGoEastOrWest --- asm/field_map_obj.s | 210 -------------------------------------------- include/data3.h | 1 + src/field_map_obj.c | 71 +++++++++++++++ 3 files changed, 72 insertions(+), 210 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index cef03345c..eca11aafd 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,216 +5,6 @@ .text - thumb_func_start FieldObjectCB_RandomlyGoEastOrWest -FieldObjectCB_RandomlyGoEastOrWest: @ 808FC08 - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =FieldObjectCB2_RandomlyGoEastOrWest - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_RandomlyGoEastOrWest - - thumb_func_start FieldObjectCB2_RandomlyGoEastOrWest -FieldObjectCB2_RandomlyGoEastOrWest: @ 808FC2C - push {r4,lr} - ldr r3, =gUnknown_0850D774 - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end FieldObjectCB2_RandomlyGoEastOrWest - - thumb_func_start sub_808FC4C -sub_808FC4C: @ 808FC4C - push {r4,lr} - adds r4, r1, 0 - bl npc_reset - movs r0, 0x1 - strh r0, [r4, 0x30] - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_808FC4C - - thumb_func_start sub_808FC60 -sub_808FC60: @ 808FC60 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - ldrb r0, [r4, 0x18] - lsls r0, 28 - lsrs r0, 28 - bl GetFaceDirectionAnimId - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r1, r5, 0 - bl FieldObjectSetRegularAnim - movs r0, 0x2 - strh r0, [r5, 0x30] - movs r0, 0x1 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_808FC60 - - thumb_func_start sub_808FC8C -sub_808FC8C: @ 808FC8C - push {r4-r6,lr} - adds r6, r1, 0 - bl FieldObjectExecRegularAnim - lsls r0, 24 - cmp r0, 0 - beq _0808FCC0 - ldr r5, =gUnknown_0850D6DC - bl Random - movs r4, 0x3 - adds r1, r4, 0 - ands r1, r0 - lsls r1, 1 - adds r1, r5 - movs r0, 0 - ldrsh r1, [r1, r0] - adds r0, r6, 0 - bl SetFieldObjectStepTimer - strh r4, [r6, 0x30] - movs r0, 0x1 - b _0808FCC2 - .pool -_0808FCC0: - movs r0, 0 -_0808FCC2: - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end sub_808FC8C - - thumb_func_start sub_808FCC8 -sub_808FCC8: @ 808FCC8 - push {r4,lr} - adds r4, r1, 0 - adds r0, r4, 0 - bl RunFieldObjectStepTimer - lsls r0, 24 - cmp r0, 0 - bne _0808FCDC - movs r0, 0 - b _0808FCE2 -_0808FCDC: - movs r0, 0x4 - strh r0, [r4, 0x30] - movs r0, 0x1 -_0808FCE2: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_808FCC8 - - thumb_func_start sub_808FCE8 -sub_808FCE8: @ 808FCE8 - push {r4-r7,lr} - sub sp, 0x4 - adds r5, r0, 0 - adds r6, r1, 0 - ldr r1, =gUnknown_0850D790 - mov r0, sp - movs r2, 0x2 - bl memcpy - bl Random - movs r7, 0x1 - adds r1, r7, 0 - ands r1, r0 - mov r2, sp - adds r0, r2, r1 - ldrb r4, [r0] - adds r0, r5, 0 - adds r1, r4, 0 - bl FieldObjectSetDirection - movs r0, 0x5 - strh r0, [r6, 0x30] - adds r0, r5, 0 - adds r1, r4, 0 - bl npc_block_way__next_tile - lsls r0, 24 - cmp r0, 0 - beq _0808FD26 - strh r7, [r6, 0x30] -_0808FD26: - movs r0, 0x1 - add sp, 0x4 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_808FCE8 - - thumb_func_start sub_808FD34 -sub_808FD34: @ 808FD34 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - ldrb r0, [r4, 0x18] - lsrs r0, 4 - bl GetGoSpeed0AnimId - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r1, r5, 0 - bl FieldObjectSetRegularAnim - ldrb r0, [r4] - movs r1, 0x2 - orrs r0, r1 - strb r0, [r4] - movs r0, 0x6 - strh r0, [r5, 0x30] - movs r0, 0x1 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_808FD34 - - thumb_func_start sub_808FD64 -sub_808FD64: @ 808FD64 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl FieldObjectExecRegularAnim - lsls r0, 24 - cmp r0, 0 - beq _0808FD82 - ldrb r0, [r4] - movs r1, 0x3 - negs r1, r1 - ands r1, r0 - strb r1, [r4] - movs r0, 0x1 - strh r0, [r5, 0x30] -_0808FD82: - movs r0, 0 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_808FD64 - thumb_func_start FieldObjectCB_FaceFixedDirection FieldObjectCB_FaceFixedDirection: @ 808FD8C push {lr} diff --git a/include/data3.h b/include/data3.h index c73a8c991..63be33381 100755 --- a/include/data3.h +++ b/include/data3.h @@ -20,5 +20,6 @@ extern const u16 *const gUnknown_0850BE38[2]; extern const s16 gUnknown_0850D6DC[4]; // {0x20, 0x40, 0x60, 0x80} extern const u8 gUnknown_0850D710[4]; // {DIR_SOUTH, DIR_NORTH, DIR_WEST, DIR_EAST} extern const u8 gUnknown_0850D770[2]; // {DIR_SOUTH, DIR_NORTH} +extern const u8 gUnknown_0850D790[2]; // {DIR_WEST, DIR_EAST} #endif //POKEEMERALD_DATA3_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 5b0916e33..edd16b6a8 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -2175,3 +2175,74 @@ bool8 sub_808FBE0(struct MapObject *mapObject, struct Sprite *sprite) } return FALSE; } + +field_object_step(RandomlyGoEastOrWest, gUnknown_0850D774) + +bool8 sub_808FC4C(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + sprite->data1 = 1; + return TRUE; +} + +bool8 sub_808FC60(struct MapObject *mapObject, struct Sprite *sprite) +{ + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(mapObject->mapobj_unk_18)); + sprite->data1 = 2; + return TRUE; +} + +bool8 sub_808FC8C(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (!FieldObjectExecRegularAnim(mapObject, sprite)) + { + return FALSE; + } + SetFieldObjectStepTimer(sprite, gUnknown_0850D6DC[Random() & 0x03]); + sprite->data1 = 3; + return TRUE; +} + +bool8 sub_808FCC8(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (RunFieldObjectStepTimer(sprite)) + { + sprite->data1 = 4; + return TRUE; + } + return FALSE; +} + +bool8 sub_808FCE8(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 directions[2]; + u8 direction; + + memcpy(directions, gUnknown_0850D790, sizeof directions); + direction = directions[Random() & 0x01]; + FieldObjectSetDirection(mapObject, direction); + sprite->data1 = 5; + if (npc_block_way__next_tile(mapObject, direction)) + { + sprite->data1 = 1; + } + return TRUE; +} + +bool8 sub_808FD34(struct MapObject *mapObject, struct Sprite *sprite) +{ + FieldObjectSetRegularAnim(mapObject, sprite, GetGoSpeed0AnimId(mapObject->placeholder18)); + mapObject->mapobj_bit_1 = TRUE; + sprite->data1 = 6; + return TRUE; +} + +bool8 sub_808FD64(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite)) + { + mapObject->mapobj_bit_1 = FALSE; + sprite->data1 = 1; + } + return FALSE; +} From 9a13b1f34e8ccb2b4c868a5c7d06ff86210125f2 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 14 Sep 2017 21:30:14 -0400 Subject: [PATCH 095/191] FaceFixedDirection --- asm/field_map_obj.s | 94 --------------------------------------------- src/field_map_obj.c | 26 +++++++++++++ 2 files changed, 26 insertions(+), 94 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index eca11aafd..f67a70ef0 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,100 +5,6 @@ .text - thumb_func_start FieldObjectCB_FaceFixedDirection -FieldObjectCB_FaceFixedDirection: @ 808FD8C - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =FieldObjectCB2_FaceFixedDirection - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_FaceFixedDirection - - thumb_func_start FieldObjectCB2_FaceFixedDirection -@ bool8 FieldObjectCB2_FaceFixedDirection(struct npc_state *fieldObject, struct obj *object) -FieldObjectCB2_FaceFixedDirection: @ 808FDB0 - push {r4,lr} - ldr r3, =gUnknown_0850D794 - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end FieldObjectCB2_FaceFixedDirection - - thumb_func_start sub_808FDD0 -@ bool8 sub_808FDD0(struct npc_state *fieldObject, struct obj *object) -sub_808FDD0: @ 808FDD0 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl npc_reset - ldrb r0, [r4, 0x18] - lsls r0, 28 - lsrs r0, 28 - bl GetFaceDirectionAnimId - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r1, r5, 0 - bl FieldObjectSetRegularAnim - movs r0, 0x1 - strh r0, [r5, 0x30] - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_808FDD0 - - thumb_func_start sub_808FDFC -@ bool8 sub_808FDFC(struct npc_state *fieldObject, struct obj *object) -sub_808FDFC: @ 808FDFC - push {r4,lr} - adds r4, r1, 0 - bl FieldObjectExecRegularAnim - lsls r0, 24 - cmp r0, 0 - bne _0808FE0E - movs r0, 0 - b _0808FE14 -_0808FE0E: - movs r0, 0x2 - strh r0, [r4, 0x30] - movs r0, 0x1 -_0808FE14: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_808FDFC - - thumb_func_start sub_808FE1C -@ bool8 sub_808FE1C(struct npc_state *fieldObject, struct obj *object) -sub_808FE1C: @ 808FE1C - ldrb r2, [r0] - movs r1, 0x3 - negs r1, r1 - ands r1, r2 - strb r1, [r0] - movs r0, 0 - bx lr - thumb_func_end sub_808FE1C - thumb_func_start FieldObjectCB_BerryTree FieldObjectCB_BerryTree: @ 808FE2C push {r4,r5,lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index edd16b6a8..04b207d96 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -2246,3 +2246,29 @@ bool8 sub_808FD64(struct MapObject *mapObject, struct Sprite *sprite) } return FALSE; } + +field_object_step(FaceFixedDirection, gUnknown_0850D794) + +bool8 sub_808FDD0(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(mapObject->mapobj_unk_18)); + sprite->data1 = 1; + return TRUE; +} + +bool8 sub_808FDFC(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite)) + { + sprite->data1 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_808FE1C(struct MapObject *mapObject, struct Sprite *sprite) +{ + mapObject->mapobj_bit_1 = FALSE; + return FALSE; +} From 9f6a4be9f05a46031d20ed7a48398147def2643c Mon Sep 17 00:00:00 2001 From: scnorton Date: Fri, 15 Sep 2017 14:26:01 -0400 Subject: [PATCH 096/191] BerryTree --- asm/battle_transition.s | 4 +- asm/braille_puzzles.s | 4 +- asm/field_effect.s | 40 ++--- asm/field_effect_helpers.s | 56 +++---- asm/field_ground_effect.s | 24 +-- asm/field_map_obj.s | 308 +------------------------------------ asm/field_player_avatar.s | 4 +- asm/fldeff_80F9BCC.s | 32 ++-- asm/fldeff_emotion.s | 2 +- asm/fldeff_strength.s | 4 +- asm/fldeff_sweetscent.s | 4 +- asm/fldeff_teleport.s | 2 +- asm/map_obj_8097404.s | 4 +- asm/rom6.s | 10 +- asm/rom_80C6FA0.s | 4 +- asm/rom_818E9AC.s | 10 +- asm/scrcmd.s | 2 +- asm/trainer_see.s | 4 +- include/field_effect.h | 80 ++++++++++ src/field_map_obj.c | 110 ++++++++++++- sym_ewram.txt | 2 +- 21 files changed, 300 insertions(+), 410 deletions(-) create mode 100644 include/field_effect.h diff --git a/asm/battle_transition.s b/asm/battle_transition.s index 9709fb54f..6406a3f24 100644 --- a/asm/battle_transition.s +++ b/asm/battle_transition.s @@ -2151,7 +2151,7 @@ sub_8147018: @ 8147018 ands r5, r0 movs r1, 0 mov r8, r4 - ldr r6, =gUnknown_02038C08 + ldr r6, =gFieldEffectSpawnParams _08147046: lsls r5, 16 asrs r5, 16 @@ -2221,7 +2221,7 @@ _081470C4: sub_81470D0: @ 81470D0 push {r4,r5,lr} ldr r0, =gUnknown_085C8E68 - ldr r5, =gUnknown_02038C08 + ldr r5, =gFieldEffectSpawnParams movs r2, 0 ldrsh r1, [r5, r2] movs r3, 0x4 diff --git a/asm/braille_puzzles.s b/asm/braille_puzzles.s index ceaddbdf0..095b1b793 100644 --- a/asm/braille_puzzles.s +++ b/asm/braille_puzzles.s @@ -271,7 +271,7 @@ _0817982E: sub_8179834: @ 8179834 push {lr} bl brm_get_pokemon_selection - ldr r1, =gUnknown_02038C08 + ldr r1, =gFieldEffectSpawnParams lsls r0, 24 lsrs r0, 24 str r0, [r1] @@ -367,7 +367,7 @@ _08179912: sub_8179918: @ 8179918 push {lr} bl brm_get_pokemon_selection - ldr r1, =gUnknown_02038C08 + ldr r1, =gFieldEffectSpawnParams lsls r0, 24 lsrs r0, 24 str r0, [r1] diff --git a/asm/field_effect.s b/asm/field_effect.s index 6277c127b..08670f556 100644 --- a/asm/field_effect.s +++ b/asm/field_effect.s @@ -1989,7 +1989,7 @@ task00_8084310: @ 80B6A24 cmp r0, 0 beq _080B6A8A bl brm_get_pokemon_selection - ldr r1, =gUnknown_02038C08 + ldr r1, =gFieldEffectSpawnParams lsls r0, 24 lsrs r0, 24 str r0, [r1] @@ -3111,7 +3111,7 @@ oei_waterfall: @ 80B734C adds r1, r0 lsls r1, 3 adds r1, r2 - ldr r2, =gUnknown_02038C08 + ldr r2, =gFieldEffectSpawnParams ldr r2, [r2] strh r2, [r1, 0xA] bl _call_via_r4 @@ -3188,7 +3188,7 @@ waterfall_1_do_anim_probably: @ 80B73F0 bne _080B7420 adds r0, r5, 0 bl FieldObjectClearAnimIfSpecialAnimFinished - ldr r1, =gUnknown_02038C08 + ldr r1, =gFieldEffectSpawnParams movs r2, 0xA ldrsh r0, [r4, r2] str r0, [r1] @@ -3304,7 +3304,7 @@ sub_80B74D0: @ 80B74D0 adds r1, r0 lsls r1, 3 adds r1, r2 - ldr r3, =gUnknown_02038C08 + ldr r3, =gFieldEffectSpawnParams ldr r2, [r3] strh r2, [r1, 0x26] ldr r2, [r3, 0x4] @@ -3363,7 +3363,7 @@ dive_2_unknown: @ 80B7558 push {r4,lr} adds r4, r0, 0 bl ScriptContext2_Enable - ldr r1, =gUnknown_02038C08 + ldr r1, =gFieldEffectSpawnParams movs r2, 0x26 ldrsh r0, [r4, r2] str r0, [r1] @@ -3536,7 +3536,7 @@ sub_80B76B8: @ 80B76B8 strh r0, [r2, 0x26] movs r0, 0x1 strh r0, [r4, 0xE] - ldr r3, =gUnknown_02038C08 + ldr r3, =gFieldEffectSpawnParams movs r5, 0x10 ldrsh r0, [r1, r5] str r0, [r3] @@ -3835,7 +3835,7 @@ sub_80B791C: @ 80B791C lsls r0, 24 cmp r0, 0 beq _080B795C - ldr r1, =gUnknown_02038C08 + ldr r1, =gFieldEffectSpawnParams movs r2, 0x10 ldrsh r0, [r5, r2] str r0, [r1] @@ -3935,7 +3935,7 @@ _080B79E6: thumb_func_start sub_80B79F4 sub_80B79F4: @ 80B79F4 push {r4,lr} - ldr r4, =gUnknown_02038C08 + ldr r4, =gFieldEffectSpawnParams adds r1, r4, 0x4 adds r0, r4, 0 movs r2, 0x8 @@ -4090,7 +4090,7 @@ sub_80B7B18: @ 80B7B18 ldrsh r0, [r5, r2] cmp r0, 0x3 ble _080B7B6C - ldr r1, =gUnknown_02038C08 + ldr r1, =gFieldEffectSpawnParams movs r2, 0x10 ldrsh r0, [r4, r2] str r0, [r1] @@ -4222,7 +4222,7 @@ _080B7C2C: thumb_func_start sub_80B7C48 sub_80B7C48: @ 80B7C48 push {r4,lr} - ldr r4, =gUnknown_02038C08 + ldr r4, =gFieldEffectSpawnParams adds r1, r4, 0x4 adds r0, r4, 0 movs r2, 0x8 @@ -5229,7 +5229,7 @@ _080B84BE: bl CreateTask lsls r0, 24 lsrs r4, r0, 24 - ldr r2, =gUnknown_02038C08 + ldr r2, =gFieldEffectSpawnParams ldr r0, [r2] ldr r1, [r2, 0x4] ldr r2, [r2, 0x8] @@ -5252,7 +5252,7 @@ _080B84BE: thumb_func_start sub_80B84F8 sub_80B84F8: @ 80B84F8 push {r4-r6,lr} - ldr r5, =gUnknown_02038C08 + ldr r5, =gFieldEffectSpawnParams ldr r0, [r5] movs r6, 0x80 lsls r6, 24 @@ -6292,7 +6292,7 @@ sub_80B8D44: @ 80B8D44 adds r1, r0 lsls r1, 3 adds r1, r2 - ldr r0, =gUnknown_02038C08 + ldr r0, =gFieldEffectSpawnParams ldr r0, [r0] strh r0, [r1, 0x26] bl sav1_reset_battle_music_maybe @@ -6421,7 +6421,7 @@ sub_80B8E60: @ 80B8E60 lsls r0, 24 cmp r0, 0 beq _080B8E96 - ldr r2, =gUnknown_02038C08 + ldr r2, =gFieldEffectSpawnParams movs r1, 0x26 ldrsh r0, [r4, r1] movs r1, 0x80 @@ -6473,7 +6473,7 @@ sub_80B8EA8: @ 80B8EA8 lsrs r1, 24 adds r0, r4, 0 bl FieldObjectSetSpecialAnim - ldr r1, =gUnknown_02038C08 + ldr r1, =gFieldEffectSpawnParams movs r2, 0xA ldrsh r0, [r6, r2] str r0, [r1] @@ -6704,7 +6704,7 @@ sub_80B90CC: @ 80B90CC strb r0, [r2, 0x5] ldr r0, =sub_80B9128 str r0, [r2, 0x1C] - ldr r0, =gUnknown_02038C08 + ldr r0, =gFieldEffectSpawnParams ldr r0, [r0] strh r0, [r2, 0x30] movs r0, 0x9E @@ -6793,7 +6793,7 @@ sub_80B91A4: @ 80B91A4 adds r1, r0 lsls r1, 3 adds r1, r2 - ldr r0, =gUnknown_02038C08 + ldr r0, =gFieldEffectSpawnParams ldr r0, [r0] strh r0, [r1, 0xA] movs r0, 0 @@ -6884,7 +6884,7 @@ sub_80B925C: @ 80B925C ldrh r0, [r4, 0x8] adds r0, 0x1 strh r0, [r4, 0x8] - ldr r1, =gUnknown_02038C08 + ldr r1, =gFieldEffectSpawnParams movs r2, 0xA ldrsh r0, [r4, r2] str r0, [r1] @@ -7922,7 +7922,7 @@ _080B9ACA: sub_80B9ADC: @ 80B9ADC push {r4,lr} sub sp, 0x4 - ldr r4, =gUnknown_02038C08 + ldr r4, =gFieldEffectSpawnParams ldrb r0, [r4] ldrb r1, [r4, 0x4] ldrb r2, [r4, 0x8] @@ -8343,7 +8343,7 @@ _080B9E24: sub_80B9E28: @ 80B9E28 push {r4-r7,lr} sub sp, 0x4 - ldr r7, =gUnknown_02038C08 + ldr r7, =gFieldEffectSpawnParams ldrb r0, [r7] ldrb r1, [r7, 0x4] ldrb r2, [r7, 0x8] diff --git a/asm/field_effect_helpers.s b/asm/field_effect_helpers.s index 04307fde5..76ba35fd2 100644 --- a/asm/field_effect_helpers.s +++ b/asm/field_effect_helpers.s @@ -574,7 +574,7 @@ _0815432E: thumb_func_start oei_shadow oei_shadow: @ 8154340 push {r4,r5,lr} - ldr r5, =gUnknown_02038C08 + ldr r5, =gFieldEffectSpawnParams ldrb r0, [r5] ldrb r1, [r5, 0x4] ldrb r2, [r5, 0x8] @@ -742,7 +742,7 @@ _08154498: oei_grass_normal: @ 81544AC push {r4,r5,lr} sub sp, 0x4 - ldr r5, =gUnknown_02038C08 + ldr r5, =gFieldEffectSpawnParams ldrh r1, [r5] mov r0, sp strh r1, [r0] @@ -951,7 +951,7 @@ _08154648: thumb_func_start sub_8154658 sub_8154658: @ 8154658 push {r4,lr} - ldr r4, =gUnknown_02038C08 + ldr r4, =gFieldEffectSpawnParams adds r1, r4, 0x4 adds r0, r4, 0 movs r2, 0x8 @@ -1080,7 +1080,7 @@ _0815474C: sub_8154758: @ 8154758 push {r4,r5,lr} sub sp, 0x4 - ldr r5, =gUnknown_02038C08 + ldr r5, =gFieldEffectSpawnParams ldrh r1, [r5] mov r0, sp strh r1, [r0] @@ -1282,7 +1282,7 @@ _081548EA: thumb_func_start sub_81548FC sub_81548FC: @ 81548FC push {r4,lr} - ldr r4, =gUnknown_02038C08 + ldr r4, =gFieldEffectSpawnParams adds r1, r4, 0x4 adds r0, r4, 0 movs r2, 0x8 @@ -1336,7 +1336,7 @@ _08154958: thumb_func_start sub_815496C sub_815496C: @ 815496C push {r4-r6,lr} - ldr r6, =gUnknown_02038C08 + ldr r6, =gFieldEffectSpawnParams ldrb r0, [r6] ldrb r1, [r6, 0x4] ldrb r2, [r6, 0x8] @@ -1537,7 +1537,7 @@ _08154AF2: thumb_func_start sub_8154B04 sub_8154B04: @ 8154B04 push {r4,lr} - ldr r4, =gUnknown_02038C08 + ldr r4, =gFieldEffectSpawnParams adds r1, r4, 0x4 adds r0, r4, 0 movs r2, 0x8 @@ -1591,7 +1591,7 @@ _08154B62: thumb_func_start sub_8154B78 sub_8154B78: @ 8154B78 push {r4,r5,lr} - ldr r4, =gUnknown_02038C08 + ldr r4, =gFieldEffectSpawnParams adds r1, r4, 0x4 adds r0, r4, 0 movs r2, 0x8 @@ -1646,7 +1646,7 @@ _08154BD8: thumb_func_start sub_8154BEC sub_8154BEC: @ 8154BEC push {r4,r5,lr} - ldr r4, =gUnknown_02038C08 + ldr r4, =gFieldEffectSpawnParams adds r1, r4, 0x4 adds r0, r4, 0 movs r2, 0x8 @@ -1777,7 +1777,7 @@ _08154CE4: thumb_func_start sub_8154CEC sub_8154CEC: @ 8154CEC push {r4-r6,lr} - ldr r6, =gUnknown_02038C08 + ldr r6, =gFieldEffectSpawnParams ldrb r0, [r6] ldrb r1, [r6, 0x4] ldrb r2, [r6, 0x8] @@ -1922,7 +1922,7 @@ _08154E0A: thumb_func_start sub_8154E1C sub_8154E1C: @ 8154E1C push {r4,lr} - ldr r4, =gUnknown_02038C08 + ldr r4, =gFieldEffectSpawnParams adds r1, r4, 0x4 adds r0, r4, 0 movs r2, 0x8 @@ -1976,7 +1976,7 @@ _08154E78: thumb_func_start oei_water_drop_tall oei_water_drop_tall: @ 8154E8C push {r4,lr} - ldr r4, =gUnknown_02038C08 + ldr r4, =gFieldEffectSpawnParams adds r1, r4, 0x4 adds r0, r4, 0 movs r2, 0x8 @@ -2030,7 +2030,7 @@ _08154EE8: thumb_func_start sub_8154EFC sub_8154EFC: @ 8154EFC push {r4-r7,lr} - ldr r7, =gUnknown_02038C08 + ldr r7, =gFieldEffectSpawnParams ldrb r0, [r7] ldrb r1, [r7, 0x4] ldrb r2, [r7, 0x8] @@ -2193,7 +2193,7 @@ oei_ripples: @ 8155054 push {r4,lr} ldr r0, =gFieldEffectObjectTemplatePointers ldr r0, [r0, 0x14] - ldr r4, =gUnknown_02038C08 + ldr r4, =gFieldEffectSpawnParams movs r2, 0 ldrsh r1, [r4, r2] movs r3, 0x4 @@ -2238,7 +2238,7 @@ _081550A0: thumb_func_start sub_81550B4 sub_81550B4: @ 81550B4 push {r4-r6,lr} - ldr r6, =gUnknown_02038C08 + ldr r6, =gFieldEffectSpawnParams ldrb r0, [r6] ldrb r1, [r6, 0x4] ldrb r2, [r6, 0x8] @@ -2393,7 +2393,7 @@ _081551E4: thumb_func_start sub_81551F0 sub_81551F0: @ 81551F0 push {r4,lr} - ldr r4, =gUnknown_02038C08 + ldr r4, =gFieldEffectSpawnParams adds r1, r4, 0x4 adds r0, r4, 0 movs r2, 0x8 @@ -2445,7 +2445,7 @@ _08155248: thumb_func_start sub_815525C sub_815525C: @ 815525C push {r4,lr} - ldr r4, =gUnknown_02038C08 + ldr r4, =gFieldEffectSpawnParams adds r1, r4, 0x4 adds r0, r4, 0 movs r2, 0x8 @@ -2497,7 +2497,7 @@ _081552B4: thumb_func_start sub_81552C8 sub_81552C8: @ 81552C8 push {r4,lr} - ldr r4, =gUnknown_02038C08 + ldr r4, =gFieldEffectSpawnParams adds r1, r4, 0x4 adds r0, r4, 0 movs r2, 0x8 @@ -2549,7 +2549,7 @@ _08155320: thumb_func_start sub_8155334 sub_8155334: @ 8155334 push {r4,lr} - ldr r4, =gUnknown_02038C08 + ldr r4, =gFieldEffectSpawnParams adds r1, r4, 0x4 adds r0, r4, 0 movs r2, 0x8 @@ -2603,7 +2603,7 @@ ash: @ 81553A0 push {r4,lr} lsls r2, 16 lsrs r2, 16 - ldr r4, =gUnknown_02038C08 + ldr r4, =gFieldEffectSpawnParams lsls r0, 16 asrs r0, 16 str r0, [r4] @@ -2630,7 +2630,7 @@ ash: @ 81553A0 oei_ash: @ 81553D4 push {r4,r5,lr} sub sp, 0x4 - ldr r5, =gUnknown_02038C08 + ldr r5, =gFieldEffectSpawnParams ldrh r1, [r5] mov r0, sp strh r1, [r0] @@ -2809,7 +2809,7 @@ _0815552C: thumb_func_start sub_8155534 sub_8155534: @ 8155534 push {r4,r5,lr} - ldr r4, =gUnknown_02038C08 + ldr r4, =gFieldEffectSpawnParams adds r1, r4, 0x4 adds r0, r4, 0 movs r2, 0x8 @@ -3261,7 +3261,7 @@ _08155888: thumb_func_start sub_8155890 sub_8155890: @ 8155890 push {r4,lr} - ldr r4, =gUnknown_02038C08 + ldr r4, =gFieldEffectSpawnParams adds r1, r4, 0x4 adds r0, r4, 0 movs r2, 0x8 @@ -3315,7 +3315,7 @@ _081558EC: thumb_func_start sub_8155900 sub_8155900: @ 8155900 push {r4-r7,lr} - ldr r7, =gUnknown_02038C08 + ldr r7, =gFieldEffectSpawnParams ldrb r0, [r7] ldrb r1, [r7, 0x4] ldrb r2, [r7, 0x8] @@ -3505,7 +3505,7 @@ _08155A76: thumb_func_start sub_8155A88 sub_8155A88: @ 8155A88 push {r4,lr} - ldr r4, =gUnknown_02038C08 + ldr r4, =gFieldEffectSpawnParams adds r1, r4, 0x4 adds r0, r4, 0 movs r2, 0x8 @@ -3586,7 +3586,7 @@ _08155B20: thumb_func_start sub_8155B2C sub_8155B2C: @ 8155B2C push {r4,lr} - ldr r4, =gUnknown_02038C08 + ldr r4, =gFieldEffectSpawnParams adds r1, r4, 0x4 adds r0, r4, 0 movs r2, 0x8 @@ -3689,7 +3689,7 @@ ShowDisguiseFieldEffect: @ 8155BD0 lsrs r6, r1, 24 lsls r2, 24 lsrs r7, r2, 24 - ldr r5, =gUnknown_02038C08 + ldr r5, =gFieldEffectSpawnParams ldrb r0, [r5] ldrb r1, [r5, 0x4] ldrb r2, [r5, 0x8] @@ -3950,7 +3950,7 @@ _08155DD8: thumb_func_start sub_8155DDC sub_8155DDC: @ 8155DDC push {r4,lr} - ldr r4, =gUnknown_02038C08 + ldr r4, =gFieldEffectSpawnParams ldr r0, [r4] adds r0, 0x7 str r0, [r4] diff --git a/asm/field_ground_effect.s b/asm/field_ground_effect.s index e4c6631d4..7d05dbd98 100644 --- a/asm/field_ground_effect.s +++ b/asm/field_ground_effect.s @@ -1166,7 +1166,7 @@ _08096E8C: @ void GroundEffect_SpawnOnTallGrass(struct npc_state *fieldObject, struct obj *object) GroundEffect_SpawnOnTallGrass: @ 8096E90 push {lr} - ldr r3, =gUnknown_02038C08 + ldr r3, =gFieldEffectSpawnParams movs r2, 0x10 ldrsh r1, [r0, r2] str r1, [r3] @@ -1205,7 +1205,7 @@ GroundEffect_SpawnOnTallGrass: @ 8096E90 @ void GroundEffect_StepOnTallGrass(struct npc_state *fieldObject, struct obj *object) GroundEffect_StepOnTallGrass: @ 8096EDC push {lr} - ldr r3, =gUnknown_02038C08 + ldr r3, =gFieldEffectSpawnParams movs r2, 0x10 ldrsh r1, [r0, r2] str r1, [r3] @@ -1244,7 +1244,7 @@ GroundEffect_StepOnTallGrass: @ 8096EDC @ void GroundEffect_SpawnOnLongGrass(struct npc_state *fieldObject, struct obj *object) GroundEffect_SpawnOnLongGrass: @ 8096F28 push {lr} - ldr r3, =gUnknown_02038C08 + ldr r3, =gFieldEffectSpawnParams movs r2, 0x10 ldrsh r1, [r0, r2] str r1, [r3] @@ -1283,7 +1283,7 @@ GroundEffect_SpawnOnLongGrass: @ 8096F28 @ void GroundEffect_StepOnLongGrass(struct npc_state *fieldObject, struct obj *object) GroundEffect_StepOnLongGrass: @ 8096F74 push {lr} - ldr r3, =gUnknown_02038C08 + ldr r3, =gFieldEffectSpawnParams movs r2, 0x10 ldrsh r1, [r0, r2] str r1, [r3] @@ -1413,7 +1413,7 @@ DoTracksGroundEffect_Footprints: @ 8097044 mov r0, sp movs r2, 0x4 bl memcpy - ldr r1, =gUnknown_02038C08 + ldr r1, =gFieldEffectSpawnParams movs r2, 0x14 ldrsh r0, [r5, r2] str r0, [r1] @@ -1449,7 +1449,7 @@ DoTracksGroundEffect_BikeTireTracks: @ 8097094 ldr r0, [r4, 0x14] cmp r1, r0 beq _080970D6 - ldr r2, =gUnknown_02038C08 + ldr r2, =gFieldEffectSpawnParams movs r1, 0x14 ldrsh r0, [r4, r1] str r0, [r2] @@ -1520,7 +1520,7 @@ GroundEffect_JumpOnTallGrass: @ 8097110 sub sp, 0x4 adds r5, r0, 0 adds r6, r1, 0 - ldr r1, =gUnknown_02038C08 + ldr r1, =gFieldEffectSpawnParams movs r2, 0x10 ldrsh r0, [r5, r2] str r0, [r1] @@ -1562,7 +1562,7 @@ _0809715A: @ void GroundEffect_JumpOnLongGrass(struct npc_state *fieldObject, struct obj *object) GroundEffect_JumpOnLongGrass: @ 8097168 push {lr} - ldr r2, =gUnknown_02038C08 + ldr r2, =gFieldEffectSpawnParams movs r3, 0x10 ldrsh r1, [r0, r3] str r1, [r2] @@ -1585,7 +1585,7 @@ GroundEffect_JumpOnLongGrass: @ 8097168 @ void GroundEffect_JumpOnShallowWater(struct npc_state *fieldObject, struct obj *object) GroundEffect_JumpOnShallowWater: @ 8097190 push {r4,lr} - ldr r3, =gUnknown_02038C08 + ldr r3, =gFieldEffectSpawnParams movs r4, 0x10 ldrsh r2, [r0, r4] str r2, [r3] @@ -1611,7 +1611,7 @@ GroundEffect_JumpOnShallowWater: @ 8097190 @ void GroundEffect_JumpOnWater(struct npc_state *fieldObject, struct obj *object) GroundEffect_JumpOnWater: @ 80971C0 push {r4,lr} - ldr r3, =gUnknown_02038C08 + ldr r3, =gFieldEffectSpawnParams movs r4, 0x10 ldrsh r2, [r0, r4] str r2, [r3] @@ -1637,7 +1637,7 @@ GroundEffect_JumpOnWater: @ 80971C0 @ void GroundEffect_JumpLandingDust(struct npc_state *fieldObject, struct obj *object) GroundEffect_JumpLandingDust: @ 80971F0 push {r4,lr} - ldr r3, =gUnknown_02038C08 + ldr r3, =gFieldEffectSpawnParams movs r4, 0x10 ldrsh r2, [r0, r4] str r2, [r3] @@ -1685,7 +1685,7 @@ GroundEffect_HotSprings: @ 8097230 @ void GroundEffect_Seaweed(struct npc_state *fieldObject, struct obj *object) GroundEffect_Seaweed: @ 8097240 push {lr} - ldr r2, =gUnknown_02038C08 + ldr r2, =gFieldEffectSpawnParams movs r3, 0x10 ldrsh r1, [r0, r3] str r1, [r2] diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index f67a70ef0..6d2de17b9 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,304 +5,6 @@ .text - thumb_func_start FieldObjectCB_BerryTree -FieldObjectCB_BerryTree: @ 808FE2C - push {r4,r5,lr} - adds r4, r0, 0 - movs r0, 0x2E - ldrsh r1, [r4, r0] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, =gMapObjects - adds r5, r0, r1 - ldrh r1, [r4, 0x3C] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - bne _0808FE58 - adds r0, r5, 0 - adds r1, r4, 0 - bl get_berry_tree_graphics - ldrh r1, [r4, 0x3C] - movs r0, 0x1 - orrs r0, r1 - strh r0, [r4, 0x3C] -_0808FE58: - ldr r2, =FieldObjectCB2_BerryTree - adds r0, r5, 0 - adds r1, r4, 0 - bl FieldObjectStep - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_BerryTree - - thumb_func_start FieldObjectCB2_BerryTree -FieldObjectCB2_BerryTree: @ 808FE70 - push {r4,lr} - ldr r3, =gUnknown_0850D7A0 - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end FieldObjectCB2_BerryTree - - thumb_func_start do_berry_tree_growth_sparkle_1 -@ bool8 do_berry_tree_growth_sparkle_1(struct npc_state *fieldObject, struct obj *object) -do_berry_tree_growth_sparkle_1: @ 808FE90 - push {r4-r7,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl npc_reset - ldrb r0, [r4, 0x1] - movs r1, 0x20 - orrs r0, r1 - strb r0, [r4, 0x1] - adds r6, r5, 0 - adds r6, 0x3E - ldrb r0, [r6] - movs r1, 0x4 - orrs r0, r1 - strb r0, [r6] - ldrb r0, [r4, 0x1D] - bl GetStageByBerryTreeId - lsls r0, 24 - lsrs r7, r0, 24 - cmp r7, 0 - bne _0808FF00 - ldrh r1, [r5, 0x3C] - movs r0, 0x4 - ands r0, r1 - cmp r0, 0 - bne _0808FEF6 - subs r6, 0x14 - ldrb r0, [r6] - cmp r0, 0x4 - bne _0808FEF6 - ldr r1, =gUnknown_02038C08 - movs r2, 0x10 - ldrsh r0, [r4, r2] - str r0, [r1] - movs r2, 0x12 - ldrsh r0, [r4, r2] - str r0, [r1, 0x4] - adds r0, r5, 0 - adds r0, 0x43 - ldrb r0, [r0] - subs r0, 0x1 - str r0, [r1, 0x8] - ldrb r0, [r5, 0x5] - lsls r0, 28 - lsrs r0, 30 - str r0, [r1, 0xC] - movs r0, 0x17 - bl FieldEffectStart - strb r7, [r6] -_0808FEF6: - movs r0, 0 - b _0808FF42 - .pool -_0808FF00: - ldrb r1, [r4, 0x1] - movs r0, 0x21 - negs r0, r0 - ands r0, r1 - strb r0, [r4, 0x1] - ldrb r1, [r6] - movs r0, 0x5 - negs r0, r0 - ands r0, r1 - strb r0, [r6] - subs r0, r7, 0x1 - lsls r0, 24 - lsrs r7, r0, 24 - adds r0, r5, 0 - adds r0, 0x2A - ldrb r0, [r0] - cmp r0, r7 - bne _0808FF3C - adds r0, r4, 0 - adds r1, r5, 0 - bl get_berry_tree_graphics - adds r0, r4, 0 - adds r1, r5, 0 - movs r2, 0x39 - bl FieldObjectSetRegularAnim - movs r0, 0x1 - strh r0, [r5, 0x30] - b _0808FF42 -_0808FF3C: - movs r0, 0x2 - strh r0, [r5, 0x30] - movs r0, 0x1 -_0808FF42: - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end do_berry_tree_growth_sparkle_1 - - thumb_func_start sub_808FF48 -@ bool8 sub_808FF48(struct npc_state *fieldObject, struct obj *object) -sub_808FF48: @ 808FF48 - push {r4,lr} - adds r4, r1, 0 - bl FieldObjectExecRegularAnim - lsls r0, 24 - cmp r0, 0 - bne _0808FF5A - movs r0, 0 - b _0808FF60 -_0808FF5A: - movs r0, 0 - strh r0, [r4, 0x30] - movs r0, 0x1 -_0808FF60: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_808FF48 - - thumb_func_start do_berry_tree_growth_sparkle_2 -@ bool8 do_berry_tree_growth_sparkle_2(struct npc_state *fieldObject, struct obj *object) -do_berry_tree_growth_sparkle_2: @ 808FF68 - push {r4,lr} - ldrb r2, [r0] - movs r3, 0x2 - orrs r2, r3 - strb r2, [r0] - movs r3, 0 - movs r2, 0x3 - strh r2, [r1, 0x30] - strh r3, [r1, 0x32] - ldrh r3, [r1, 0x3C] - movs r2, 0x2 - orrs r2, r3 - strh r2, [r1, 0x3C] - ldr r3, =gUnknown_02038C08 - movs r4, 0x10 - ldrsh r2, [r0, r4] - str r2, [r3] - movs r2, 0x12 - ldrsh r0, [r0, r2] - str r0, [r3, 0x4] - adds r0, r1, 0 - adds r0, 0x43 - ldrb r0, [r0] - subs r0, 0x1 - str r0, [r3, 0x8] - ldrb r0, [r1, 0x5] - lsls r0, 28 - lsrs r0, 30 - str r0, [r3, 0xC] - movs r0, 0x17 - bl FieldEffectStart - movs r0, 0x1 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end do_berry_tree_growth_sparkle_2 - - thumb_func_start sub_808FFB4 -@ bool8 sub_808FFB4(struct npc_state *fieldObject, struct obj *object) -sub_808FFB4: @ 808FFB4 - push {r4,lr} - adds r3, r0, 0 - adds r4, r1, 0 - ldrh r1, [r4, 0x32] - adds r1, 0x1 - strh r1, [r4, 0x32] - movs r0, 0x2 - ands r1, r0 - lsls r1, 16 - lsrs r1, 17 - lsls r1, 5 - ldrb r2, [r3, 0x1] - subs r0, 0x23 - ands r0, r2 - orrs r0, r1 - strb r0, [r3, 0x1] - adds r2, r4, 0 - adds r2, 0x2C - ldrb r0, [r2] - movs r1, 0x40 - orrs r0, r1 - strb r0, [r2] - movs r1, 0x32 - ldrsh r0, [r4, r1] - cmp r0, 0x40 - bgt _0808FFEC - movs r0, 0 - b _0808FFFE -_0808FFEC: - adds r0, r3, 0 - adds r1, r4, 0 - bl get_berry_tree_graphics - movs r0, 0x4 - strh r0, [r4, 0x30] - movs r0, 0 - strh r0, [r4, 0x32] - movs r0, 0x1 -_0808FFFE: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_808FFB4 - - thumb_func_start sub_8090004 -@ bool8 sub_8090004(struct npc_state *fieldObject, struct obj *object) -sub_8090004: @ 8090004 - push {r4,lr} - adds r4, r1, 0 - ldrh r2, [r4, 0x32] - adds r2, 0x1 - strh r2, [r4, 0x32] - movs r1, 0x2 - ands r2, r1 - lsls r2, 16 - lsrs r2, 17 - lsls r2, 5 - ldrb r3, [r0, 0x1] - subs r1, 0x23 - ands r1, r3 - orrs r1, r2 - strb r1, [r0, 0x1] - adds r2, r4, 0 - adds r2, 0x2C - ldrb r0, [r2] - movs r1, 0x40 - orrs r0, r1 - strb r0, [r2] - movs r1, 0x32 - ldrsh r0, [r4, r1] - cmp r0, 0x40 - bgt _0809003A - movs r0, 0 - b _08090048 -_0809003A: - movs r0, 0 - strh r0, [r4, 0x30] - ldrh r1, [r4, 0x3C] - subs r0, 0x3 - ands r0, r1 - strh r0, [r4, 0x3C] - movs r0, 0x1 -_08090048: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8090004 - thumb_func_start FieldObjectCB_RandomlyLookNorthOrSouth FieldObjectCB_RandomlyLookNorthOrSouth: @ 8090050 push {lr} @@ -5217,7 +4919,7 @@ FieldObjectCB_TreeDisguise: @ 809253C cmp r0, 0 bne _08092584 _08092564: - ldr r1, =gUnknown_02038C08 + ldr r1, =gFieldEffectSpawnParams adds r2, r1, 0x4 adds r3, r1, 0 adds r3, 0x8 @@ -5280,7 +4982,7 @@ FieldObjectCB_MountainDisguise: @ 80925B8 cmp r0, 0 bne _08092600 _080925E0: - ldr r1, =gUnknown_02038C08 + ldr r1, =gFieldEffectSpawnParams adds r2, r1, 0x4 adds r3, r1, 0 adds r3, 0x8 @@ -12012,7 +11714,7 @@ sub_80954CC: @ 80954CC do_exclamation_mark_bubble_1: @ 80954DC push {r4,lr} adds r4, r1, 0 - ldr r1, =gUnknown_02038C08 + ldr r1, =gFieldEffectSpawnParams adds r2, r1, 0x4 adds r3, r1, 0 adds r3, 0x8 @@ -12031,7 +11733,7 @@ do_exclamation_mark_bubble_1: @ 80954DC do_exclamation_mark_bubble_2: @ 8095500 push {r4,lr} adds r4, r1, 0 - ldr r1, =gUnknown_02038C08 + ldr r1, =gFieldEffectSpawnParams adds r2, r1, 0x4 adds r3, r1, 0 adds r3, 0x8 @@ -12050,7 +11752,7 @@ do_exclamation_mark_bubble_2: @ 8095500 do_heart_bubble: @ 8095524 push {r4,lr} adds r4, r1, 0 - ldr r1, =gUnknown_02038C08 + ldr r1, =gFieldEffectSpawnParams adds r2, r1, 0x4 adds r3, r1, 0 adds r3, 0x8 diff --git a/asm/field_player_avatar.s b/asm/field_player_avatar.s index f21fdacae..3cf5a70da 100644 --- a/asm/field_player_avatar.s +++ b/asm/field_player_avatar.s @@ -1522,7 +1522,7 @@ PlayerAvatarTransition_Surfing: @ 808B4D8 bl FieldObjectTurn movs r0, 0x8 bl SetPlayerAvatarStateMask - ldr r1, =gUnknown_02038C08 + ldr r1, =gFieldEffectSpawnParams movs r2, 0x10 ldrsh r0, [r4, r2] str r0, [r1] @@ -3517,7 +3517,7 @@ _0808C3F0: lsrs r1, 24 adds r0, r4, 0 bl FieldObjectSetSpecialAnim - ldr r2, =gUnknown_02038C08 + ldr r2, =gFieldEffectSpawnParams movs r1, 0x10 ldrsh r0, [r4, r1] str r0, [r2] diff --git a/asm/fldeff_80F9BCC.s b/asm/fldeff_80F9BCC.s index e332a8841..784da5b1f 100644 --- a/asm/fldeff_80F9BCC.s +++ b/asm/fldeff_80F9BCC.s @@ -486,7 +486,7 @@ sub_80F9F78: @ 80F9F78 ands r0, r1 cmp r0, 0 beq _080F9FC0 - ldr r1, =gUnknown_02038C08 + ldr r1, =gFieldEffectSpawnParams ldr r0, [r1, 0x4] cmp r0, 0x2 beq _080F9FAE @@ -517,7 +517,7 @@ _080F9FB6: movs r0, 0x18 b _080F9FFC _080F9FC0: - ldr r1, =gUnknown_02038C08 + ldr r1, =gFieldEffectSpawnParams ldr r0, [r1, 0x4] cmp r0, 0x2 beq _080F9FEA @@ -643,7 +643,7 @@ _080FA0C4: sub_80FA0DC: @ 80FA0DC push {lr} bl brm_get_pokemon_selection - ldr r1, =gUnknown_02038C08 + ldr r1, =gFieldEffectSpawnParams lsls r0, 24 lsrs r0, 24 str r0, [r1] @@ -701,7 +701,7 @@ sub_80FA13C: @ 80FA13C ldrh r1, [r2, 0x2] lsls r1, 23 lsrs r1, 23 - ldr r4, =gUnknown_02038C08 + ldr r4, =gFieldEffectSpawnParams ldr r3, [r4, 0x14] adds r1, r3 lsls r1, 16 @@ -778,7 +778,7 @@ sub_80FA1D8: @ 80FA1D8 sub_80FA1E8: @ 80FA1E8 push {lr} bl brm_get_pokemon_selection - ldr r1, =gUnknown_02038C08 + ldr r1, =gFieldEffectSpawnParams lsls r0, 24 lsrs r0, 24 str r0, [r1] @@ -836,13 +836,13 @@ sub_80FA248: @ 80FA248 ands r2, r0 cmp r2, 0x96 bne _080FA26A - ldr r1, =gUnknown_02038C08 + ldr r1, =gFieldEffectSpawnParams movs r0, 0 str r0, [r1, 0x1C] _080FA26A: cmp r2, 0x9C bne _080FA274 - ldr r1, =gUnknown_02038C08 + ldr r1, =gFieldEffectSpawnParams movs r0, 0x2 str r0, [r1, 0x1C] _080FA274: @@ -858,7 +858,7 @@ _080FA274: ldrh r1, [r2, 0x2] lsls r1, 23 lsrs r1, 23 - ldr r4, =gUnknown_02038C08 + ldr r4, =gFieldEffectSpawnParams ldr r3, [r4, 0x14] adds r1, r3 lsls r1, 16 @@ -891,7 +891,7 @@ sub_80FA2D8: @ 80FA2D8 adds r4, r0, 0 movs r0, 0x9B bl PlaySE - ldr r0, =gUnknown_02038C08 + ldr r0, =gFieldEffectSpawnParams ldr r1, [r0, 0x1C] adds r2, r4, 0 adds r2, 0x2A @@ -917,7 +917,7 @@ sub_80FA304: @ 80FA304 asrs r0, 16 cmp r0, 0x27 ble _080FA32E - ldr r0, =gUnknown_02038C08 + ldr r0, =gFieldEffectSpawnParams ldr r0, [r0, 0x1C] cmp r0, 0 beq _080FA322 @@ -951,7 +951,7 @@ sub_80FA33C: @ 80FA33C sub_80FA34C: @ 80FA34C push {lr} bl brm_get_pokemon_selection - ldr r1, =gUnknown_02038C08 + ldr r1, =gFieldEffectSpawnParams lsls r0, 24 lsrs r0, 24 str r0, [r1] @@ -1009,7 +1009,7 @@ sub_80FA3AC: @ 80FA3AC ldrh r1, [r2, 0x2] lsls r1, 23 lsrs r1, 23 - ldr r4, =gUnknown_02038C08 + ldr r4, =gFieldEffectSpawnParams ldr r3, [r4, 0x14] adds r1, r3 lsls r1, 16 @@ -1807,7 +1807,7 @@ sub_80FAA7C: @ 80FAA7C mov r0, sp adds r1, r4, 0 bl GetXYCoordsOneStepInFrontOfPlayer - ldr r1, =gUnknown_02038C08 + ldr r1, =gFieldEffectSpawnParams mov r0, sp movs r2, 0 ldrsh r0, [r0, r2] @@ -1930,7 +1930,7 @@ door_restore_tilemap: @ 80FABA4 adds r5, r0, 0 movs r0, 0x83 bl PlaySE - ldr r4, =gUnknown_02038C08 + ldr r4, =gFieldEffectSpawnParams ldr r0, [r4, 0x14] ldr r1, [r4, 0x18] subs r1, 0x1 @@ -1953,7 +1953,7 @@ _080FABDC: lsls r2, 2 bl MapGridSetMetatileIdAt _080FABEA: - ldr r4, =gUnknown_02038C08 + ldr r4, =gFieldEffectSpawnParams ldr r0, [r4, 0x14] ldr r1, [r4, 0x18] ldr r2, =0x0000020a @@ -1988,7 +1988,7 @@ sub_80FAC24: @ 80FAC24 strh r0, [r5, 0x2E] b _080FAC54 _080FAC38: - ldr r4, =gUnknown_02038C08 + ldr r4, =gFieldEffectSpawnParams ldr r0, [r4, 0x14] ldr r1, [r4, 0x18] ldr r2, =0x00000e8c diff --git a/asm/fldeff_emotion.s b/asm/fldeff_emotion.s index dce540074..37096a438 100644 --- a/asm/fldeff_emotion.s +++ b/asm/fldeff_emotion.s @@ -115,7 +115,7 @@ sub_80B46D8: @ 80B46D8 orrs r3, r4 mov r4, r12 strb r3, [r4] - ldr r4, =gUnknown_02038C08 + ldr r4, =gFieldEffectSpawnParams ldr r3, [r4] strh r3, [r0, 0x2E] ldr r3, [r4, 0x4] diff --git a/asm/fldeff_strength.s b/asm/fldeff_strength.s index 3dc64467e..98764625e 100644 --- a/asm/fldeff_strength.s +++ b/asm/fldeff_strength.s @@ -40,7 +40,7 @@ _08145DF2: sub_8145E0C: @ 8145E0C push {lr} bl brm_get_pokemon_selection - ldr r1, =gUnknown_02038C08 + ldr r1, =gFieldEffectSpawnParams lsls r0, 24 lsrs r0, 24 str r0, [r1] @@ -66,7 +66,7 @@ sub_8145E2C: @ 8145E2C lsrs r0, r2, 16 strh r0, [r1, 0x18] strh r2, [r1, 0x1A] - ldr r0, =gUnknown_02038C08 + ldr r0, =gFieldEffectSpawnParams ldr r1, [r0] movs r0, 0x64 muls r0, r1 diff --git a/asm/fldeff_sweetscent.s b/asm/fldeff_sweetscent.s index a297dd41d..5c83b455d 100644 --- a/asm/fldeff_sweetscent.s +++ b/asm/fldeff_sweetscent.s @@ -24,7 +24,7 @@ hm2_sweet_scent: @ 8159F10 movs r0, 0x33 bl FieldEffectStart bl brm_get_pokemon_selection - ldr r1, =gUnknown_02038C08 + ldr r1, =gFieldEffectSpawnParams lsls r0, 24 lsrs r0, 24 str r0, [r1] @@ -217,4 +217,4 @@ _0815A0BE: thumb_func_end sub_815A090 .align 2, 0 @ Don't pad with nop. - \ No newline at end of file + diff --git a/asm/fldeff_teleport.s b/asm/fldeff_teleport.s index f3dc3ec9b..e4f4bce42 100644 --- a/asm/fldeff_teleport.s +++ b/asm/fldeff_teleport.s @@ -39,7 +39,7 @@ hm_teleport_run_dp02scr: @ 817C8FC movs r0, 0x3F bl FieldEffectStart bl brm_get_pokemon_selection - ldr r1, =gUnknown_02038C08 + ldr r1, =gFieldEffectSpawnParams lsls r0, 24 lsrs r0, 24 str r0, [r1] diff --git a/asm/map_obj_8097404.s b/asm/map_obj_8097404.s index 1bbf3eff2..4ed8e3bcd 100644 --- a/asm/map_obj_8097404.s +++ b/asm/map_obj_8097404.s @@ -1396,7 +1396,7 @@ oe_exec_and_other_stuff: @ 8097DD0 adds r0, r1, 0 lsls r4, 24 lsrs r4, 24 - ldr r1, =gUnknown_02038C08 + ldr r1, =gFieldEffectSpawnParams adds r2, r1, 0x4 adds r3, r1, 0 adds r3, 0x8 @@ -1434,7 +1434,7 @@ DoRippleFieldEffect: @ 8097E14 adds r4, r1, 0 ldrb r0, [r0, 0x5] bl GetFieldObjectGraphicsInfo - ldr r2, =gUnknown_02038C08 + ldr r2, =gFieldEffectSpawnParams movs r3, 0x20 ldrsh r1, [r4, r3] str r1, [r2] diff --git a/asm/rom6.s b/asm/rom6.s index 18de40366..31d385fa9 100644 --- a/asm/rom6.s +++ b/asm/rom6.s @@ -167,7 +167,7 @@ sub_8135578: @ 8135578 cmp r4, 0 bne _081355FC bl player_get_direction_lower_nybble - ldr r6, =gUnknown_02038C08 + ldr r6, =gFieldEffectSpawnParams lsls r0, 24 lsrs r0, 24 str r0, [r6, 0x4] @@ -303,7 +303,7 @@ _081356AC: sub_81356C4: @ 81356C4 push {lr} bl brm_get_pokemon_selection - ldr r1, =gUnknown_02038C08 + ldr r1, =gFieldEffectSpawnParams lsls r0, 24 lsrs r0, 24 str r0, [r1] @@ -380,7 +380,7 @@ hm2_dig: @ 8135760 movs r0, 0x26 bl FieldEffectStart bl brm_get_pokemon_selection - ldr r1, =gUnknown_02038C08 + ldr r1, =gFieldEffectSpawnParams lsls r0, 24 lsrs r0, 24 str r0, [r1] @@ -3381,7 +3381,7 @@ hm2_flash: @ 8137178 lsls r4, 24 lsrs r4, 24 bl brm_get_pokemon_selection - ldr r1, =gUnknown_02038C08 + ldr r1, =gFieldEffectSpawnParams lsls r0, 24 lsrs r0, 24 str r0, [r1] @@ -11039,7 +11039,7 @@ _0813B0F8: ldr r0, =sub_813B160 movs r1, 0x8 bl CreateTask - ldr r3, =gUnknown_02038C08 + ldr r3, =gFieldEffectSpawnParams movs r0, 0x1 str r0, [r3] movs r0, 0x3A diff --git a/asm/rom_80C6FA0.s b/asm/rom_80C6FA0.s index 4c3ada218..d6d3bb375 100644 --- a/asm/rom_80C6FA0.s +++ b/asm/rom_80C6FA0.s @@ -24444,7 +24444,7 @@ hm2_ruin_valley: @ 80D3A50 movs r0, 0x1 bl FieldEffectStart bl brm_get_pokemon_selection - ldr r1, =gUnknown_02038C08 + ldr r1, =gFieldEffectSpawnParams lsls r0, 24 lsrs r0, 24 str r0, [r1] @@ -24480,7 +24480,7 @@ sub_80D3A6C: @ 80D3A6C sub_80D3A9C: @ 80D3A9C push {lr} bl brm_get_pokemon_selection - ldr r1, =gUnknown_02038C08 + ldr r1, =gFieldEffectSpawnParams lsls r0, 24 lsrs r0, 24 str r0, [r1] diff --git a/asm/rom_818E9AC.s b/asm/rom_818E9AC.s index 8363e1308..0ee8404a6 100644 --- a/asm/rom_818E9AC.s +++ b/asm/rom_818E9AC.s @@ -74313,7 +74313,7 @@ task_launch_hm_phase_2: @ 81B5750 cmp r0, 0x1 bne _081B577C bl brm_get_selected_species - ldr r1, =gUnknown_02038C08 + ldr r1, =gFieldEffectSpawnParams lsls r0, 16 lsrs r0, 16 str r0, [r1] @@ -74397,7 +74397,7 @@ _081B57FE: hm_surf_run_dp02scr: @ 81B5804 push {lr} bl brm_get_pokemon_selection - ldr r1, =gUnknown_02038C08 + ldr r1, =gFieldEffectSpawnParams lsls r0, 24 lsrs r0, 24 str r0, [r1] @@ -74501,7 +74501,7 @@ sub_81B58A8: @ 81B58A8 hm2_waterfall: @ 81B58D4 push {lr} bl brm_get_pokemon_selection - ldr r1, =gUnknown_02038C08 + ldr r1, =gFieldEffectSpawnParams lsls r0, 24 lsrs r0, 24 str r0, [r1] @@ -74561,7 +74561,7 @@ _081B594E: sub_81B5958: @ 81B5958 push {lr} bl brm_get_pokemon_selection - ldr r1, =gUnknown_02038C08 + ldr r1, =gFieldEffectSpawnParams lsls r0, 24 lsrs r0, 24 str r0, [r1] @@ -74576,7 +74576,7 @@ sub_81B5958: @ 81B5958 sub_81B5974: @ 81B5974 push {lr} bl sub_809D1E8 - ldr r1, =gUnknown_02038C08 + ldr r1, =gFieldEffectSpawnParams lsls r0, 24 lsrs r0, 24 str r0, [r1, 0x4] diff --git a/asm/scrcmd.s b/asm/scrcmd.s index ccfa0074a..6d531821c 100644 --- a/asm/scrcmd.s +++ b/asm/scrcmd.s @@ -4874,7 +4874,7 @@ s9D_set_HM_animation_data: @ 809B7F4 lsls r0, 16 lsrs r0, 16 bl VarGet - ldr r1, =gUnknown_02038C08 + ldr r1, =gFieldEffectSpawnParams lsls r4, 2 adds r4, r1 lsls r0, 16 diff --git a/asm/trainer_see.s b/asm/trainer_see.s index ac2528cd8..d57ad1815 100644 --- a/asm/trainer_see.s +++ b/asm/trainer_see.s @@ -734,7 +734,7 @@ sub_80B417C: @ 80B417C push {r4,r5,lr} adds r5, r1, 0 adds r4, r2, 0 - ldr r1, =gUnknown_02038C08 + ldr r1, =gFieldEffectSpawnParams adds r2, r1, 0x4 adds r3, r1, 0 adds r3, 0x8 @@ -1050,7 +1050,7 @@ sub_80B43E0: @ 80B43E0 lsls r0, 24 cmp r0, 0 beq _080B4426 - ldr r2, =gUnknown_02038C08 + ldr r2, =gFieldEffectSpawnParams movs r1, 0x10 ldrsh r0, [r4, r1] str r0, [r2] diff --git a/include/field_effect.h b/include/field_effect.h new file mode 100644 index 000000000..8cf866725 --- /dev/null +++ b/include/field_effect.h @@ -0,0 +1,80 @@ +// +// Created by Scott Norton on 9/15/17. +// + +#ifndef POKEEMERALD_FIELD_EFFECTS_H +#define POKEEMERALD_FIELD_EFFECTS_H + +enum FieldEffectScriptIdx +{ + FLDEFF_EXCLAMATION_MARK_ICON_1, + FLDEFF_USE_CUT_ON_GRASS, + FLDEFF_USE_CUT_ON_TREE, + FLDEFF_SHADOW, + FLDEFF_TALL_GRASS, + FLDEFF_RIPPLE, + FLDEFF_FIELD_MOVE_SHOW_MON, + FLDEFF_ASH, + FLDEFF_SURF_BLOB, + FLDEFF_USE_SURF, + FLDEFF_DUST, + FLDEFF_USE_SECRET_POWER_CAVE, + FLDEFF_JUMP_TALL_GRASS, + FLDEFF_SAND_FOOTPRINTS, + FLDEFF_JUMP_BIG_SPLASH, + FLDEFF_SPLASH, + FLDEFF_JUMP_SMALL_SPLASH, + FLDEFF_LONG_GRASS, + FLDEFF_JUMP_LONG_GRASS, + FLDEFF_UNKNOWN_19, + FLDEFF_UNKNOWN_20, + FLDEFF_UNKNOWN_21, + FLDEFF_UNKNOWN_22, + FLDEFF_BERRY_TREE_GROWTH_SPARKLE, + FLDEFF_DEEP_SAND_FOOTPRINTS, + FLDEFF_POKECENTER_HEAL, + FLDEFF_USE_SECRET_POWER_TREE, + FLDEFF_USE_SECRET_POWER_SHRUB, + FLDEFF_TREE_DISGUISE, + FLDEFF_MOUNTAIN_DISGUISE, + FLDEFF_NPCFLY_OUT, + FLDEFF_USE_FLY, + FLDEFF_FLY_IN, + FLDEFF_EXCLAMATION_MARK_ICON_2, + FLDEFF_FEET_IN_FLOWING_WATER, + FLDEFF_BIKE_TIRE_TRACKS, + FLDEFF_SAND_DISGUISE, + FLDEFF_USE_ROCK_SMASH, + FLDEFF_USE_DIG, + FLDEFF_SAND_PILE, + FLDEFF_USE_STRENGTH, + FLDEFF_SHORT_GRASS, + FLDEFF_HOT_SPRINGS_WATER, + FLDEFF_USE_WATERFALL, + FLDEFF_USE_DIVE, + FLDEFF_POKEBALL, + FLDEFF_HEART_ICON, + FLDEFF_NOP_47, + FLDEFF_NOP_48, + FLDEFF_POP_OUT_OF_ASH, + FLDEFF_LAVARIDGE_GYM_WARP, + FLDEFF_SWEET_SCENT, + FLDEFF_SAND_PILLAR, + FLDEFF_BUBBLES, + FLDEFF_SPARKLE, + FLDEFF_SECRET_POWER_CAVE, + FLDEFF_SECRET_POWER_TREE, + FLDEFF_SECRET_POWER_SHRUB, + FLDEFF_CUT_GRASS, + FLDEFF_FIELD_MOVE_SHOW_MON_INIT, + FLDEFF_USE_FLY_ANCIENT_TOMB, + FLDEFF_PCTURN_ON, + FLDEFF_HALL_OF_FAME_RECORD, + FLDEFF_USE_TELEPORT +}; + +extern u32 gFieldEffectSpawnParams[8]; + +u8 FieldEffectStart(u8); + +#endif //POKEEMERALD_FIELD_EFFECTS_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 04b207d96..16a9e5851 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -16,6 +16,7 @@ #include "field_ground_effect.h" #include "map_obj_8097404.h" #include "mauville_old_man.h" +#include "field_effect.h" #include "field_effect_helpers.h" #include "field_map_obj.h" @@ -1884,7 +1885,7 @@ u8 GetEastWestRunningPastFacingDirection(s16 dx, s16 dy, s16 absdx, s16 absdy) u8 GetNorthEastRunningPastFacingDirection(s16 dx, s16 dy, s16 absdx, s16 absdy) { u8 direction; - + direction = GetRegularRunningPastFacingDirection(dx, dy, absdx, absdy); if (direction == DIR_SOUTH) { @@ -2272,3 +2273,110 @@ bool8 sub_808FE1C(struct MapObject *mapObject, struct Sprite *sprite) mapObject->mapobj_bit_1 = FALSE; return FALSE; } + +static bool8 FieldObjectCB2_BerryTree(struct MapObject *mapObject, struct Sprite *sprite); +extern bool8 (*const gUnknown_0850D7A0[])(struct MapObject *mapObject, struct Sprite *sprite); +void FieldObjectCB_BerryTree(struct Sprite *sprite) +{ + struct MapObject *mapObject; + + mapObject = &gMapObjects[sprite->data0]; + if (!(sprite->data7 & 0x0001)) + { + get_berry_tree_graphics(mapObject, sprite); + sprite->data7 |= 0x0001; + } + FieldObjectStep(mapObject, sprite, FieldObjectCB2_BerryTree); +} +static bool8 FieldObjectCB2_BerryTree(struct MapObject *mapObject, struct Sprite *sprite) +{ + return gUnknown_0850D7A0[sprite->data1](mapObject, sprite); +} + +bool8 do_berry_tree_growth_sparkle_1 (struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 berryStage; + + npc_reset(mapObject, sprite); + mapObject->mapobj_bit_13 = TRUE; + sprite->invisible = TRUE; + berryStage = GetStageByBerryTreeId(mapObject->trainerRange_berryTreeId); + if (berryStage == 0) + { + if (!(sprite->data7 & 0x0004) && sprite->animNum == 4) + { + gFieldEffectSpawnParams[0] = mapObject->coords2.x; + gFieldEffectSpawnParams[1] = mapObject->coords2.y; + gFieldEffectSpawnParams[2] = sprite->subpriority - 1; + gFieldEffectSpawnParams[3] = sprite->oam.priority; + FieldEffectStart(FLDEFF_BERRY_TREE_GROWTH_SPARKLE); + sprite->animNum = berryStage; + } + return FALSE; + } + mapObject->mapobj_bit_13 = FALSE; + sprite->invisible = FALSE; + berryStage --; + if (sprite->animNum != berryStage) + { + sprite->data1 = 2; + return TRUE; + } + get_berry_tree_graphics(mapObject, sprite); + FieldObjectSetRegularAnim(mapObject, sprite, 0x39); + sprite->data1 = 1; + return TRUE; +} + +bool8 sub_808FF48 (struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite)) + { + sprite->data1 = 0; + return TRUE; + } + return FALSE; +} + +bool8 do_berry_tree_growth_sparkle_2 (struct MapObject *mapObject, struct Sprite *sprite) +{ + mapObject->mapobj_bit_1 = TRUE; + sprite->data1 = 3; + sprite->data2 = 0; + sprite->data7 |= 0x0002; + gFieldEffectSpawnParams[0] = mapObject->coords2.x; + gFieldEffectSpawnParams[1] = mapObject->coords2.y; + gFieldEffectSpawnParams[2] = sprite->subpriority - 1; + gFieldEffectSpawnParams[3] = sprite->oam.priority; + FieldEffectStart(FLDEFF_BERRY_TREE_GROWTH_SPARKLE); + return TRUE; +} + +bool8 sub_808FFB4 (struct MapObject *mapObject, struct Sprite *sprite) +{ + sprite->data2 ++; + mapObject->mapobj_bit_13 = (sprite->data2 & 0x02) >> 1; + sprite->animPaused = TRUE; + if (sprite->data2 > 64) + { + get_berry_tree_graphics(mapObject, sprite); + sprite->data1 = 4; + sprite->data2 = 0; + return TRUE; + } + return FALSE; +} + +bool8 sub_8090004 (struct MapObject *mapObject, struct Sprite *sprite) +{ + sprite->data2 ++; + mapObject->mapobj_bit_13 = (sprite->data2 & 0x02) >> 1; + sprite->animPaused = TRUE; + if (sprite->data2 > 64) + { + sprite->data1 = 0; + sprite->data7 &= ~0x0002; + return TRUE; + } + return FALSE; +} diff --git a/sym_ewram.txt b/sym_ewram.txt index b9d1f6650..582518bf3 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -902,7 +902,7 @@ gUnknown_02038C00: @ 2038C00 gUnknown_02038C04: @ 2038C04 .space 0x4 -gUnknown_02038C08: @ 2038C08 +gFieldEffectSpawnParams: @ 2038C08 .space 0x20 gUnknown_02038C28: @ 2038C28 From 7440bba1b19eb8fbd4fa91bc0ad2e722fa1e3c4c Mon Sep 17 00:00:00 2001 From: scnorton Date: Fri, 15 Sep 2017 14:36:54 -0400 Subject: [PATCH 097/191] RandomlyLookNorthOrSouth --- asm/field_map_obj.s | 168 -------------------------------------------- src/field_map_obj.c | 53 ++++++++++++++ 2 files changed, 53 insertions(+), 168 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 6d2de17b9..623146ed3 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,174 +5,6 @@ .text - thumb_func_start FieldObjectCB_RandomlyLookNorthOrSouth -FieldObjectCB_RandomlyLookNorthOrSouth: @ 8090050 - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =FieldObjectCB2_RandomlyLookNorthOrSouth - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_RandomlyLookNorthOrSouth - - thumb_func_start FieldObjectCB2_RandomlyLookNorthOrSouth -FieldObjectCB2_RandomlyLookNorthOrSouth: @ 8090074 - push {r4,lr} - ldr r3, =gUnknown_0850D7B4 - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end FieldObjectCB2_RandomlyLookNorthOrSouth - - thumb_func_start sub_8090094 -sub_8090094: @ 8090094 - push {r4,lr} - adds r4, r1, 0 - bl npc_reset - movs r0, 0x1 - strh r0, [r4, 0x30] - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8090094 - - thumb_func_start sub_80900A8 -sub_80900A8: @ 80900A8 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - ldrb r0, [r4, 0x18] - lsls r0, 28 - lsrs r0, 28 - bl GetFaceDirectionAnimId - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r1, r5, 0 - bl FieldObjectSetRegularAnim - movs r0, 0x2 - strh r0, [r5, 0x30] - movs r0, 0x1 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80900A8 - - thumb_func_start sub_80900D4 -sub_80900D4: @ 80900D4 - push {r4-r7,lr} - adds r6, r0, 0 - adds r7, r1, 0 - bl FieldObjectExecRegularAnim - lsls r0, 24 - cmp r0, 0 - beq _0809010A - ldr r4, =gUnknown_0850D6DC - bl Random - movs r5, 0x3 - adds r1, r5, 0 - ands r1, r0 - lsls r1, 1 - adds r1, r4 - movs r0, 0 - ldrsh r1, [r1, r0] - adds r0, r7, 0 - bl SetFieldObjectStepTimer - ldrb r1, [r6] - movs r0, 0x3 - negs r0, r0 - ands r0, r1 - strb r0, [r6] - strh r5, [r7, 0x30] -_0809010A: - movs r0, 0 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80900D4 - - thumb_func_start sub_8090118 -sub_8090118: @ 8090118 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - adds r0, r5, 0 - bl RunFieldObjectStepTimer - lsls r0, 24 - cmp r0, 0 - bne _08090136 - adds r0, r4, 0 - bl FieldObjectIsTrainerAndCloseToPlayer - lsls r0, 24 - cmp r0, 0 - beq _0809013E -_08090136: - movs r0, 0x4 - strh r0, [r5, 0x30] - movs r0, 0x1 - b _08090140 -_0809013E: - movs r0, 0 -_08090140: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8090118 - - thumb_func_start sub_8090148 -sub_8090148: @ 8090148 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - ldr r1, =gUnknown_0850D770 - mov r0, sp - movs r2, 0x2 - bl memcpy - adds r0, r4, 0 - movs r1, 0x1 - bl GetRunningPastFacingDirection - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0 - bne _08090178 - bl Random - movs r1, 0x1 - ands r1, r0 - mov r2, sp - adds r0, r2, r1 - ldrb r1, [r0] -_08090178: - adds r0, r4, 0 - bl FieldObjectSetDirection - movs r0, 0x1 - strh r0, [r5, 0x30] - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8090148 - thumb_func_start FieldObjectCB_RandomlyLookEastOrWest FieldObjectCB_RandomlyLookEastOrWest: @ 8090190 push {lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 16a9e5851..88b4ab9b7 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -2380,3 +2380,56 @@ bool8 sub_8090004 (struct MapObject *mapObject, struct Sprite *sprite) } return FALSE; } + +field_object_step(RandomlyLookNorthOrSouth, gUnknown_0850D7B4) + +bool8 sub_8090094 (struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + sprite->data1 = 1; + return TRUE; +} + +bool8 sub_80900A8 (struct MapObject *mapObject, struct Sprite *sprite) +{ + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(mapObject->mapobj_unk_18)); + sprite->data1 = 2; + return TRUE; +} + +bool8 sub_80900D4 (struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite)) + { + SetFieldObjectStepTimer(sprite, gUnknown_0850D6DC[Random() & 0x03]); + mapObject->mapobj_bit_1 = FALSE; + sprite->data1 = 3; + } + return FALSE; +} + +bool8 sub_8090118 (struct MapObject *mapObject, struct Sprite *sprite) +{ + if (RunFieldObjectStepTimer(sprite) || FieldObjectIsTrainerAndCloseToPlayer(mapObject)) + { + sprite->data1 = 4; + return TRUE; + } + return FALSE; +} + +bool8 sub_8090148 (struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 directions[2]; + u8 direction; + + memcpy(directions, gUnknown_0850D770, sizeof gUnknown_0850D770); + direction = GetRunningPastFacingDirection(mapObject, 1); + if (direction == 0) + { + direction = directions[Random() & 0x01]; + } + FieldObjectSetDirection(mapObject, direction); + sprite->data1 = 1; + return TRUE; +} From bf101743c2d965c97ade9925ff6db17a35de31fc Mon Sep 17 00:00:00 2001 From: scnorton Date: Fri, 15 Sep 2017 14:42:54 -0400 Subject: [PATCH 098/191] RandomlyLookEastOrWest --- asm/field_map_obj.s | 168 -------------------------------------------- src/field_map_obj.c | 53 ++++++++++++++ 2 files changed, 53 insertions(+), 168 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 623146ed3..12b1cf7b4 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,174 +5,6 @@ .text - thumb_func_start FieldObjectCB_RandomlyLookEastOrWest -FieldObjectCB_RandomlyLookEastOrWest: @ 8090190 - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =FieldObjectCB2_RandomlyLookEastOrWest - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_RandomlyLookEastOrWest - - thumb_func_start FieldObjectCB2_RandomlyLookEastOrWest -FieldObjectCB2_RandomlyLookEastOrWest: @ 80901B4 - push {r4,lr} - ldr r3, =gUnknown_0850D7C8 - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end FieldObjectCB2_RandomlyLookEastOrWest - - thumb_func_start sub_80901D4 -sub_80901D4: @ 80901D4 - push {r4,lr} - adds r4, r1, 0 - bl npc_reset - movs r0, 0x1 - strh r0, [r4, 0x30] - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_80901D4 - - thumb_func_start sub_80901E8 -sub_80901E8: @ 80901E8 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - ldrb r0, [r4, 0x18] - lsls r0, 28 - lsrs r0, 28 - bl GetFaceDirectionAnimId - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r1, r5, 0 - bl FieldObjectSetRegularAnim - movs r0, 0x2 - strh r0, [r5, 0x30] - movs r0, 0x1 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80901E8 - - thumb_func_start sub_8090214 -sub_8090214: @ 8090214 - push {r4-r7,lr} - adds r6, r0, 0 - adds r7, r1, 0 - bl FieldObjectExecRegularAnim - lsls r0, 24 - cmp r0, 0 - beq _0809024A - ldr r4, =gUnknown_0850D6DC - bl Random - movs r5, 0x3 - adds r1, r5, 0 - ands r1, r0 - lsls r1, 1 - adds r1, r4 - movs r0, 0 - ldrsh r1, [r1, r0] - adds r0, r7, 0 - bl SetFieldObjectStepTimer - ldrb r1, [r6] - movs r0, 0x3 - negs r0, r0 - ands r0, r1 - strb r0, [r6] - strh r5, [r7, 0x30] -_0809024A: - movs r0, 0 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8090214 - - thumb_func_start sub_8090258 -sub_8090258: @ 8090258 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - adds r0, r5, 0 - bl RunFieldObjectStepTimer - lsls r0, 24 - cmp r0, 0 - bne _08090276 - adds r0, r4, 0 - bl FieldObjectIsTrainerAndCloseToPlayer - lsls r0, 24 - cmp r0, 0 - beq _0809027E -_08090276: - movs r0, 0x4 - strh r0, [r5, 0x30] - movs r0, 0x1 - b _08090280 -_0809027E: - movs r0, 0 -_08090280: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8090258 - - thumb_func_start sub_8090288 -sub_8090288: @ 8090288 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - ldr r1, =gUnknown_0850D790 - mov r0, sp - movs r2, 0x2 - bl memcpy - adds r0, r4, 0 - movs r1, 0x2 - bl GetRunningPastFacingDirection - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0 - bne _080902B8 - bl Random - movs r1, 0x1 - ands r1, r0 - mov r2, sp - adds r0, r2, r1 - ldrb r1, [r0] -_080902B8: - adds r0, r4, 0 - bl FieldObjectSetDirection - movs r0, 0x1 - strh r0, [r5, 0x30] - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8090288 - thumb_func_start FieldObjectCB_RandomlyLookNorthOrWest FieldObjectCB_RandomlyLookNorthOrWest: @ 80902D0 push {lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 88b4ab9b7..7c99c8a97 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -2433,3 +2433,56 @@ bool8 sub_8090148 (struct MapObject *mapObject, struct Sprite *sprite) sprite->data1 = 1; return TRUE; } + +field_object_step(RandomlyLookEastOrWest, gUnknown_0850D7C8) + +bool8 sub_80901D4 (struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + sprite->data1 = 1; + return TRUE; +} + +bool8 sub_80901E8 (struct MapObject *mapObject, struct Sprite *sprite) +{ + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(mapObject->mapobj_unk_18)); + sprite->data1 = 2; + return TRUE; +} + +bool8 sub_8090214 (struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite)) + { + SetFieldObjectStepTimer(sprite, gUnknown_0850D6DC[Random() & 0x03]); + mapObject->mapobj_bit_1 = FALSE; + sprite->data1 = 3; + } + return FALSE; +} + +bool8 sub_8090258 (struct MapObject *mapObject, struct Sprite *sprite) +{ + if (RunFieldObjectStepTimer(sprite) || FieldObjectIsTrainerAndCloseToPlayer(mapObject)) + { + sprite->data1 = 4; + return TRUE; + } + return FALSE; +} + +bool8 sub_8090288 (struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 directions[2]; + u8 direction; + + memcpy(directions, gUnknown_0850D790, sizeof gUnknown_0850D790); + direction = GetRunningPastFacingDirection(mapObject, 2); + if (direction == 0) + { + direction = directions[Random() & 0x01]; + } + FieldObjectSetDirection(mapObject, direction); + sprite->data1 = 1; + return TRUE; +} From 0571056955121d57f7ea691b40f807c8f80ef7b2 Mon Sep 17 00:00:00 2001 From: scnorton Date: Fri, 15 Sep 2017 15:26:51 -0400 Subject: [PATCH 099/191] RandomlyLookNorthOrWest --- asm/field_map_obj.s | 168 -------------------------------------------- include/data3.h | 2 + src/field_map_obj.c | 53 ++++++++++++++ 3 files changed, 55 insertions(+), 168 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 12b1cf7b4..75035836f 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,174 +5,6 @@ .text - thumb_func_start FieldObjectCB_RandomlyLookNorthOrWest -FieldObjectCB_RandomlyLookNorthOrWest: @ 80902D0 - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =FieldObjectCB2_RandomlyLookNorthOrWest - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_RandomlyLookNorthOrWest - - thumb_func_start FieldObjectCB2_RandomlyLookNorthOrWest -FieldObjectCB2_RandomlyLookNorthOrWest: @ 80902F4 - push {r4,lr} - ldr r3, =gUnknown_0850D7DC - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end FieldObjectCB2_RandomlyLookNorthOrWest - - thumb_func_start sub_8090314 -sub_8090314: @ 8090314 - push {r4,lr} - adds r4, r1, 0 - bl npc_reset - movs r0, 0x1 - strh r0, [r4, 0x30] - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8090314 - - thumb_func_start sub_8090328 -sub_8090328: @ 8090328 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - ldrb r0, [r4, 0x18] - lsls r0, 28 - lsrs r0, 28 - bl GetFaceDirectionAnimId - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r1, r5, 0 - bl FieldObjectSetRegularAnim - movs r0, 0x2 - strh r0, [r5, 0x30] - movs r0, 0x1 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8090328 - - thumb_func_start sub_8090354 -sub_8090354: @ 8090354 - push {r4-r7,lr} - adds r6, r0, 0 - adds r7, r1, 0 - bl FieldObjectExecRegularAnim - lsls r0, 24 - cmp r0, 0 - beq _0809038A - ldr r4, =gUnknown_0850D6EC - bl Random - movs r5, 0x3 - adds r1, r5, 0 - ands r1, r0 - lsls r1, 1 - adds r1, r4 - movs r0, 0 - ldrsh r1, [r1, r0] - adds r0, r7, 0 - bl SetFieldObjectStepTimer - ldrb r1, [r6] - movs r0, 0x3 - negs r0, r0 - ands r0, r1 - strb r0, [r6] - strh r5, [r7, 0x30] -_0809038A: - movs r0, 0 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8090354 - - thumb_func_start sub_8090398 -sub_8090398: @ 8090398 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - adds r0, r5, 0 - bl RunFieldObjectStepTimer - lsls r0, 24 - cmp r0, 0 - bne _080903B6 - adds r0, r4, 0 - bl FieldObjectIsTrainerAndCloseToPlayer - lsls r0, 24 - cmp r0, 0 - beq _080903BE -_080903B6: - movs r0, 0x4 - strh r0, [r5, 0x30] - movs r0, 0x1 - b _080903C0 -_080903BE: - movs r0, 0 -_080903C0: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8090398 - - thumb_func_start sub_80903C8 -sub_80903C8: @ 80903C8 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - ldr r1, =gUnknown_0850D7F0 - mov r0, sp - movs r2, 0x2 - bl memcpy - adds r0, r4, 0 - movs r1, 0x3 - bl GetRunningPastFacingDirection - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0 - bne _080903F8 - bl Random - movs r1, 0x1 - ands r1, r0 - mov r2, sp - adds r0, r2, r1 - ldrb r1, [r0] -_080903F8: - adds r0, r4, 0 - bl FieldObjectSetDirection - movs r0, 0x1 - strh r0, [r5, 0x30] - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80903C8 - thumb_func_start FieldObjectCB_RandomlyLookNorthOrEast FieldObjectCB_RandomlyLookNorthOrEast: @ 8090410 push {lr} diff --git a/include/data3.h b/include/data3.h index 63be33381..9ab32e8ce 100755 --- a/include/data3.h +++ b/include/data3.h @@ -18,8 +18,10 @@ extern const struct PairedPalettes gUnknown_0850BD00[15]; extern const struct PairedPalettes gUnknown_0850BD78[15]; extern const u16 *const gUnknown_0850BE38[2]; extern const s16 gUnknown_0850D6DC[4]; // {0x20, 0x40, 0x60, 0x80} +extern const s16 gUnknown_0850D6EC[4]; extern const u8 gUnknown_0850D710[4]; // {DIR_SOUTH, DIR_NORTH, DIR_WEST, DIR_EAST} extern const u8 gUnknown_0850D770[2]; // {DIR_SOUTH, DIR_NORTH} extern const u8 gUnknown_0850D790[2]; // {DIR_WEST, DIR_EAST} +extern const u8 gUnknown_0850D7F0[2]; // {DIR_NORTH, DIR_WEST} #endif //POKEEMERALD_DATA3_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 7c99c8a97..014001d93 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -2486,3 +2486,56 @@ bool8 sub_8090288 (struct MapObject *mapObject, struct Sprite *sprite) sprite->data1 = 1; return TRUE; } + +field_object_step(RandomlyLookNorthOrWest, gUnknown_0850D7DC) + +bool8 sub_8090314 (struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + sprite->data1 = 1; + return TRUE; +} + +bool8 sub_8090328 (struct MapObject *mapObject, struct Sprite *sprite) +{ + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(mapObject->mapobj_unk_18)); + sprite->data1 = 2; + return TRUE; +} + +bool8 sub_8090354 (struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite)) + { + SetFieldObjectStepTimer(sprite, gUnknown_0850D6EC[Random() & 0x03]); + mapObject->mapobj_bit_1 = FALSE; + sprite->data1 = 3; + } + return FALSE; +} + +bool8 sub_8090398 (struct MapObject *mapObject, struct Sprite *sprite) +{ + if (RunFieldObjectStepTimer(sprite) || FieldObjectIsTrainerAndCloseToPlayer(mapObject)) + { + sprite->data1 = 4; + return TRUE; + } + return FALSE; +} + +bool8 sub_80903C8 (struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 directions[2]; + u8 direction; + + memcpy(directions, gUnknown_0850D7F0, sizeof gUnknown_0850D7F0); + direction = GetRunningPastFacingDirection(mapObject, 3); + if (direction == 0) + { + direction = directions[Random() & 0x01]; + } + FieldObjectSetDirection(mapObject, direction); + sprite->data1 = 1; + return TRUE; +} From 8c6367f997f4c53dfb1819d2cc42953fb7a82eb5 Mon Sep 17 00:00:00 2001 From: scnorton Date: Fri, 15 Sep 2017 15:53:07 -0400 Subject: [PATCH 100/191] RandomlyLookNorthOrEast --- asm/field_map_obj.s | 168 ---------------------------------------- include/data3.h | 1 + include/field_map_obj.h | 14 ++++ src/field_map_obj.c | 61 ++++++++++++++- 4 files changed, 72 insertions(+), 172 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 75035836f..1675489e1 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,174 +5,6 @@ .text - thumb_func_start FieldObjectCB_RandomlyLookNorthOrEast -FieldObjectCB_RandomlyLookNorthOrEast: @ 8090410 - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =sub_8090434 - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_RandomlyLookNorthOrEast - - thumb_func_start sub_8090434 -sub_8090434: @ 8090434 - push {r4,lr} - ldr r3, =gUnknown_0850D7F4 - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8090434 - - thumb_func_start sub_8090454 -sub_8090454: @ 8090454 - push {r4,lr} - adds r4, r1, 0 - bl npc_reset - movs r0, 0x1 - strh r0, [r4, 0x30] - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8090454 - - thumb_func_start sub_8090468 -sub_8090468: @ 8090468 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - ldrb r0, [r4, 0x18] - lsls r0, 28 - lsrs r0, 28 - bl GetFaceDirectionAnimId - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r1, r5, 0 - bl FieldObjectSetRegularAnim - movs r0, 0x2 - strh r0, [r5, 0x30] - movs r0, 0x1 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8090468 - - thumb_func_start sub_8090494 -sub_8090494: @ 8090494 - push {r4-r7,lr} - adds r6, r0, 0 - adds r7, r1, 0 - bl FieldObjectExecRegularAnim - lsls r0, 24 - cmp r0, 0 - beq _080904CA - ldr r4, =gUnknown_0850D6EC - bl Random - movs r5, 0x3 - adds r1, r5, 0 - ands r1, r0 - lsls r1, 1 - adds r1, r4 - movs r0, 0 - ldrsh r1, [r1, r0] - adds r0, r7, 0 - bl SetFieldObjectStepTimer - ldrb r1, [r6] - movs r0, 0x3 - negs r0, r0 - ands r0, r1 - strb r0, [r6] - strh r5, [r7, 0x30] -_080904CA: - movs r0, 0 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8090494 - - thumb_func_start sub_80904D8 -sub_80904D8: @ 80904D8 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - adds r0, r5, 0 - bl RunFieldObjectStepTimer - lsls r0, 24 - cmp r0, 0 - bne _080904F6 - adds r0, r4, 0 - bl FieldObjectIsTrainerAndCloseToPlayer - lsls r0, 24 - cmp r0, 0 - beq _080904FE -_080904F6: - movs r0, 0x4 - strh r0, [r5, 0x30] - movs r0, 0x1 - b _08090500 -_080904FE: - movs r0, 0 -_08090500: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80904D8 - - thumb_func_start sub_8090508 -sub_8090508: @ 8090508 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - ldr r1, =gUnknown_0850D808 - mov r0, sp - movs r2, 0x2 - bl memcpy - adds r0, r4, 0 - movs r1, 0x4 - bl GetRunningPastFacingDirection - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0 - bne _08090538 - bl Random - movs r1, 0x1 - ands r1, r0 - mov r2, sp - adds r0, r2, r1 - ldrb r1, [r0] -_08090538: - adds r0, r4, 0 - bl FieldObjectSetDirection - movs r0, 0x1 - strh r0, [r5, 0x30] - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8090508 - thumb_func_start FieldObjectCB_RandomlyLookSouthOrWest FieldObjectCB_RandomlyLookSouthOrWest: @ 8090550 push {lr} diff --git a/include/data3.h b/include/data3.h index 9ab32e8ce..debca9b73 100755 --- a/include/data3.h +++ b/include/data3.h @@ -23,5 +23,6 @@ extern const u8 gUnknown_0850D710[4]; // {DIR_SOUTH, DIR_NORTH, DIR_WEST, DIR_EA extern const u8 gUnknown_0850D770[2]; // {DIR_SOUTH, DIR_NORTH} extern const u8 gUnknown_0850D790[2]; // {DIR_WEST, DIR_EAST} extern const u8 gUnknown_0850D7F0[2]; // {DIR_NORTH, DIR_WEST} +extern const u8 gUnknown_0850D808[2]; // {DIR_NORTH, DIR_EAST} #endif //POKEEMERALD_DATA3_H diff --git a/include/field_map_obj.h b/include/field_map_obj.h index f91b8f9e3..43446ea84 100755 --- a/include/field_map_obj.h +++ b/include/field_map_obj.h @@ -6,6 +6,20 @@ // Exported struct declarations +enum SpinnerRunnerFollowPatterns { + RUNFOLLOW_ANY, + RUNFOLLOW_NORTH_SOUTH, + RUNFOLLOW_EAST_WEST, + RUNFOLLOW_NORTH_WEST, + RUNFOLLOW_NORTH_EAST, + RUNFOLLOW_SOUTH_WEST, + RUNFOLLOW_SOUTH_EAST, + RUNFOLLOW_NORTH_SOUTH_WEST, + RUNFOLLOW_NORTH_SOUTH_EAST, + RUNFOLLOW_NORTH_EAST_WEST, + RUNFOLLOW_SOUTH_EAST_WEST +}; + // Exported RAM declarations // Exported ROM declarations diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 014001d93..1228d93be 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -2096,7 +2096,7 @@ bool8 sub_808FA3C(struct MapObject *mapObject, struct Sprite *sprite) u8 direction; memcpy(directions, gUnknown_0850D710, sizeof directions); - direction = GetRunningPastFacingDirection(mapObject, 0); + direction = GetRunningPastFacingDirection(mapObject, RUNFOLLOW_ANY); if (direction == 0) { direction = directions[Random() & 0x03]; @@ -2424,7 +2424,7 @@ bool8 sub_8090148 (struct MapObject *mapObject, struct Sprite *sprite) u8 direction; memcpy(directions, gUnknown_0850D770, sizeof gUnknown_0850D770); - direction = GetRunningPastFacingDirection(mapObject, 1); + direction = GetRunningPastFacingDirection(mapObject, RUNFOLLOW_NORTH_SOUTH); if (direction == 0) { direction = directions[Random() & 0x01]; @@ -2477,7 +2477,7 @@ bool8 sub_8090288 (struct MapObject *mapObject, struct Sprite *sprite) u8 direction; memcpy(directions, gUnknown_0850D790, sizeof gUnknown_0850D790); - direction = GetRunningPastFacingDirection(mapObject, 2); + direction = GetRunningPastFacingDirection(mapObject, RUNFOLLOW_EAST_WEST); if (direction == 0) { direction = directions[Random() & 0x01]; @@ -2530,7 +2530,60 @@ bool8 sub_80903C8 (struct MapObject *mapObject, struct Sprite *sprite) u8 direction; memcpy(directions, gUnknown_0850D7F0, sizeof gUnknown_0850D7F0); - direction = GetRunningPastFacingDirection(mapObject, 3); + direction = GetRunningPastFacingDirection(mapObject, RUNFOLLOW_NORTH_WEST); + if (direction == 0) + { + direction = directions[Random() & 0x01]; + } + FieldObjectSetDirection(mapObject, direction); + sprite->data1 = 1; + return TRUE; +} + +field_object_step(RandomlyLookNorthOrEast, gUnknown_0850D7F4) + +bool8 sub_8090454 (struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + sprite->data1 = 1; + return TRUE; +} + +bool8 sub_8090468 (struct MapObject *mapObject, struct Sprite *sprite) +{ + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(mapObject->mapobj_unk_18)); + sprite->data1 = 2; + return TRUE; +} + +bool8 sub_8090494 (struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite)) + { + SetFieldObjectStepTimer(sprite, gUnknown_0850D6EC[Random() & 0x03]); + mapObject->mapobj_bit_1 = FALSE; + sprite->data1 = 3; + } + return FALSE; +} + +bool8 sub_80904D8 (struct MapObject *mapObject, struct Sprite *sprite) +{ + if (RunFieldObjectStepTimer(sprite) || FieldObjectIsTrainerAndCloseToPlayer(mapObject)) + { + sprite->data1 = 4; + return TRUE; + } + return FALSE; +} + +bool8 sub_8090508 (struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 directions[2]; + u8 direction; + + memcpy(directions, gUnknown_0850D808, sizeof gUnknown_0850D808); + direction = GetRunningPastFacingDirection(mapObject, RUNFOLLOW_NORTH_EAST); if (direction == 0) { direction = directions[Random() & 0x01]; From b269048369afcb0a4bf5a5f251d9ff7506a3f588 Mon Sep 17 00:00:00 2001 From: scnorton Date: Fri, 15 Sep 2017 15:57:38 -0400 Subject: [PATCH 101/191] RandomlyLookSouthOrWest --- asm/field_map_obj.s | 168 -------------------------------------------- include/data3.h | 1 + src/field_map_obj.c | 53 ++++++++++++++ 3 files changed, 54 insertions(+), 168 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 1675489e1..f128ba9a4 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,174 +5,6 @@ .text - thumb_func_start FieldObjectCB_RandomlyLookSouthOrWest -FieldObjectCB_RandomlyLookSouthOrWest: @ 8090550 - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =sub_8090574 - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_RandomlyLookSouthOrWest - - thumb_func_start sub_8090574 -sub_8090574: @ 8090574 - push {r4,lr} - ldr r3, =gUnknown_0850D80C - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8090574 - - thumb_func_start sub_8090594 -sub_8090594: @ 8090594 - push {r4,lr} - adds r4, r1, 0 - bl npc_reset - movs r0, 0x1 - strh r0, [r4, 0x30] - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8090594 - - thumb_func_start sub_80905A8 -sub_80905A8: @ 80905A8 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - ldrb r0, [r4, 0x18] - lsls r0, 28 - lsrs r0, 28 - bl GetFaceDirectionAnimId - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r1, r5, 0 - bl FieldObjectSetRegularAnim - movs r0, 0x2 - strh r0, [r5, 0x30] - movs r0, 0x1 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80905A8 - - thumb_func_start sub_80905D4 -sub_80905D4: @ 80905D4 - push {r4-r7,lr} - adds r6, r0, 0 - adds r7, r1, 0 - bl FieldObjectExecRegularAnim - lsls r0, 24 - cmp r0, 0 - beq _0809060A - ldr r4, =gUnknown_0850D6EC - bl Random - movs r5, 0x3 - adds r1, r5, 0 - ands r1, r0 - lsls r1, 1 - adds r1, r4 - movs r0, 0 - ldrsh r1, [r1, r0] - adds r0, r7, 0 - bl SetFieldObjectStepTimer - ldrb r1, [r6] - movs r0, 0x3 - negs r0, r0 - ands r0, r1 - strb r0, [r6] - strh r5, [r7, 0x30] -_0809060A: - movs r0, 0 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80905D4 - - thumb_func_start sub_8090618 -sub_8090618: @ 8090618 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - adds r0, r5, 0 - bl RunFieldObjectStepTimer - lsls r0, 24 - cmp r0, 0 - bne _08090636 - adds r0, r4, 0 - bl FieldObjectIsTrainerAndCloseToPlayer - lsls r0, 24 - cmp r0, 0 - beq _0809063E -_08090636: - movs r0, 0x4 - strh r0, [r5, 0x30] - movs r0, 0x1 - b _08090640 -_0809063E: - movs r0, 0 -_08090640: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8090618 - - thumb_func_start sub_8090648 -sub_8090648: @ 8090648 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - ldr r1, =gUnknown_0850D820 - mov r0, sp - movs r2, 0x2 - bl memcpy - adds r0, r4, 0 - movs r1, 0x5 - bl GetRunningPastFacingDirection - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0 - bne _08090678 - bl Random - movs r1, 0x1 - ands r1, r0 - mov r2, sp - adds r0, r2, r1 - ldrb r1, [r0] -_08090678: - adds r0, r4, 0 - bl FieldObjectSetDirection - movs r0, 0x1 - strh r0, [r5, 0x30] - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8090648 - thumb_func_start FieldObjectCB_RandomlyLookSouthOrEast FieldObjectCB_RandomlyLookSouthOrEast: @ 8090690 push {lr} diff --git a/include/data3.h b/include/data3.h index debca9b73..a1aa86279 100755 --- a/include/data3.h +++ b/include/data3.h @@ -24,5 +24,6 @@ extern const u8 gUnknown_0850D770[2]; // {DIR_SOUTH, DIR_NORTH} extern const u8 gUnknown_0850D790[2]; // {DIR_WEST, DIR_EAST} extern const u8 gUnknown_0850D7F0[2]; // {DIR_NORTH, DIR_WEST} extern const u8 gUnknown_0850D808[2]; // {DIR_NORTH, DIR_EAST} +extern const u8 gUnknown_0850D820[2]; // {DIR_SOUTH, DIR_WEST} #endif //POKEEMERALD_DATA3_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 1228d93be..639267890 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -2592,3 +2592,56 @@ bool8 sub_8090508 (struct MapObject *mapObject, struct Sprite *sprite) sprite->data1 = 1; return TRUE; } + +field_object_step(RandomlyLookSouthOrWest, gUnknown_0850D80C) + +bool8 sub_8090594 (struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + sprite->data1 = 1; + return TRUE; +} + +bool8 sub_80905A8 (struct MapObject *mapObject, struct Sprite *sprite) +{ + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(mapObject->mapobj_unk_18)); + sprite->data1 = 2; + return TRUE; +} + +bool8 sub_80905D4 (struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite)) + { + SetFieldObjectStepTimer(sprite, gUnknown_0850D6EC[Random() & 0x03]); + mapObject->mapobj_bit_1 = FALSE; + sprite->data1 = 3; + } + return FALSE; +} + +bool8 sub_8090618 (struct MapObject *mapObject, struct Sprite *sprite) +{ + if (RunFieldObjectStepTimer(sprite) || FieldObjectIsTrainerAndCloseToPlayer(mapObject)) + { + sprite->data1 = 4; + return TRUE; + } + return FALSE; +} + +bool8 sub_8090648 (struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 directions[2]; + u8 direction; + + memcpy(directions, gUnknown_0850D820, sizeof gUnknown_0850D820); + direction = GetRunningPastFacingDirection(mapObject, RUNFOLLOW_SOUTH_WEST); + if (direction == 0) + { + direction = directions[Random() & 0x01]; + } + FieldObjectSetDirection(mapObject, direction); + sprite->data1 = 1; + return TRUE; +} From f6840ba7e7783cb961f6b6afb7ac7eb45717a13f Mon Sep 17 00:00:00 2001 From: scnorton Date: Fri, 15 Sep 2017 16:00:39 -0400 Subject: [PATCH 102/191] RandomlyLookSouthOrEast --- asm/field_map_obj.s | 168 -------------------------------------------- include/data3.h | 1 + src/field_map_obj.c | 53 ++++++++++++++ 3 files changed, 54 insertions(+), 168 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index f128ba9a4..83913eaf9 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,174 +5,6 @@ .text - thumb_func_start FieldObjectCB_RandomlyLookSouthOrEast -FieldObjectCB_RandomlyLookSouthOrEast: @ 8090690 - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =sub_80906B4 - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_RandomlyLookSouthOrEast - - thumb_func_start sub_80906B4 -sub_80906B4: @ 80906B4 - push {r4,lr} - ldr r3, =gUnknown_0850D824 - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80906B4 - - thumb_func_start sub_80906D4 -sub_80906D4: @ 80906D4 - push {r4,lr} - adds r4, r1, 0 - bl npc_reset - movs r0, 0x1 - strh r0, [r4, 0x30] - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_80906D4 - - thumb_func_start sub_80906E8 -sub_80906E8: @ 80906E8 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - ldrb r0, [r4, 0x18] - lsls r0, 28 - lsrs r0, 28 - bl GetFaceDirectionAnimId - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r1, r5, 0 - bl FieldObjectSetRegularAnim - movs r0, 0x2 - strh r0, [r5, 0x30] - movs r0, 0x1 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80906E8 - - thumb_func_start sub_8090714 -sub_8090714: @ 8090714 - push {r4-r7,lr} - adds r6, r0, 0 - adds r7, r1, 0 - bl FieldObjectExecRegularAnim - lsls r0, 24 - cmp r0, 0 - beq _0809074A - ldr r4, =gUnknown_0850D6EC - bl Random - movs r5, 0x3 - adds r1, r5, 0 - ands r1, r0 - lsls r1, 1 - adds r1, r4 - movs r0, 0 - ldrsh r1, [r1, r0] - adds r0, r7, 0 - bl SetFieldObjectStepTimer - ldrb r1, [r6] - movs r0, 0x3 - negs r0, r0 - ands r0, r1 - strb r0, [r6] - strh r5, [r7, 0x30] -_0809074A: - movs r0, 0 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8090714 - - thumb_func_start sub_8090758 -sub_8090758: @ 8090758 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - adds r0, r5, 0 - bl RunFieldObjectStepTimer - lsls r0, 24 - cmp r0, 0 - bne _08090776 - adds r0, r4, 0 - bl FieldObjectIsTrainerAndCloseToPlayer - lsls r0, 24 - cmp r0, 0 - beq _0809077E -_08090776: - movs r0, 0x4 - strh r0, [r5, 0x30] - movs r0, 0x1 - b _08090780 -_0809077E: - movs r0, 0 -_08090780: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8090758 - - thumb_func_start sub_8090788 -sub_8090788: @ 8090788 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - ldr r1, =gUnknown_0850D838 - mov r0, sp - movs r2, 0x2 - bl memcpy - adds r0, r4, 0 - movs r1, 0x6 - bl GetRunningPastFacingDirection - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0 - bne _080907B8 - bl Random - movs r1, 0x1 - ands r1, r0 - mov r2, sp - adds r0, r2, r1 - ldrb r1, [r0] -_080907B8: - adds r0, r4, 0 - bl FieldObjectSetDirection - movs r0, 0x1 - strh r0, [r5, 0x30] - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8090788 - thumb_func_start FieldObjectCB_RandomlyLookNorthOrSouthOrWest FieldObjectCB_RandomlyLookNorthOrSouthOrWest: @ 80907D0 push {lr} diff --git a/include/data3.h b/include/data3.h index a1aa86279..9aa8bc469 100755 --- a/include/data3.h +++ b/include/data3.h @@ -25,5 +25,6 @@ extern const u8 gUnknown_0850D790[2]; // {DIR_WEST, DIR_EAST} extern const u8 gUnknown_0850D7F0[2]; // {DIR_NORTH, DIR_WEST} extern const u8 gUnknown_0850D808[2]; // {DIR_NORTH, DIR_EAST} extern const u8 gUnknown_0850D820[2]; // {DIR_SOUTH, DIR_WEST} +extern const u8 gUnknown_0850D838[2]; // {DIR_SOUTH, DIR_EAST} #endif //POKEEMERALD_DATA3_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 639267890..f4092265c 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -2645,3 +2645,56 @@ bool8 sub_8090648 (struct MapObject *mapObject, struct Sprite *sprite) sprite->data1 = 1; return TRUE; } + +field_object_step(RandomlyLookSouthOrEast, gUnknown_0850D824) + +bool8 sub_80906D4 (struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + sprite->data1 = 1; + return TRUE; +} + +bool8 sub_80906E8 (struct MapObject *mapObject, struct Sprite *sprite) +{ + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(mapObject->mapobj_unk_18)); + sprite->data1 = 2; + return TRUE; +} + +bool8 sub_8090714 (struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite)) + { + SetFieldObjectStepTimer(sprite, gUnknown_0850D6EC[Random() & 0x03]); + mapObject->mapobj_bit_1 = FALSE; + sprite->data1 = 3; + } + return FALSE; +} + +bool8 sub_8090758 (struct MapObject *mapObject, struct Sprite *sprite) +{ + if (RunFieldObjectStepTimer(sprite) || FieldObjectIsTrainerAndCloseToPlayer(mapObject)) + { + sprite->data1 = 4; + return TRUE; + } + return FALSE; +} + +bool8 sub_8090788 (struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 directions[2]; + u8 direction; + + memcpy(directions, gUnknown_0850D838, sizeof gUnknown_0850D838); + direction = GetRunningPastFacingDirection(mapObject, RUNFOLLOW_SOUTH_EAST); + if (direction == 0) + { + direction = directions[Random() & 0x01]; + } + FieldObjectSetDirection(mapObject, direction); + sprite->data1 = 1; + return TRUE; +} From 2e1ecdb87711172b1916f3e102315867c5b65d18 Mon Sep 17 00:00:00 2001 From: scnorton Date: Fri, 15 Sep 2017 16:08:01 -0400 Subject: [PATCH 103/191] Tridirectional spinners --- asm/field_map_obj.s | 672 -------------------------------------------- include/data3.h | 4 + src/field_map_obj.c | 212 ++++++++++++++ 3 files changed, 216 insertions(+), 672 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 83913eaf9..4d01b95f8 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,678 +5,6 @@ .text - thumb_func_start FieldObjectCB_RandomlyLookNorthOrSouthOrWest -FieldObjectCB_RandomlyLookNorthOrSouthOrWest: @ 80907D0 - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =sub_80907F4 - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_RandomlyLookNorthOrSouthOrWest - - thumb_func_start sub_80907F4 -sub_80907F4: @ 80907F4 - push {r4,lr} - ldr r3, =gUnknown_0850D83C - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80907F4 - - thumb_func_start sub_8090814 -sub_8090814: @ 8090814 - push {r4,lr} - adds r4, r1, 0 - bl npc_reset - movs r0, 0x1 - strh r0, [r4, 0x30] - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8090814 - - thumb_func_start sub_8090828 -sub_8090828: @ 8090828 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - ldrb r0, [r4, 0x18] - lsls r0, 28 - lsrs r0, 28 - bl GetFaceDirectionAnimId - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r1, r5, 0 - bl FieldObjectSetRegularAnim - movs r0, 0x2 - strh r0, [r5, 0x30] - movs r0, 0x1 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8090828 - - thumb_func_start sub_8090854 -sub_8090854: @ 8090854 - push {r4-r7,lr} - adds r6, r0, 0 - adds r7, r1, 0 - bl FieldObjectExecRegularAnim - lsls r0, 24 - cmp r0, 0 - beq _0809088A - ldr r4, =gUnknown_0850D6EC - bl Random - movs r5, 0x3 - adds r1, r5, 0 - ands r1, r0 - lsls r1, 1 - adds r1, r4 - movs r0, 0 - ldrsh r1, [r1, r0] - adds r0, r7, 0 - bl SetFieldObjectStepTimer - ldrb r1, [r6] - movs r0, 0x3 - negs r0, r0 - ands r0, r1 - strb r0, [r6] - strh r5, [r7, 0x30] -_0809088A: - movs r0, 0 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8090854 - - thumb_func_start sub_8090898 -sub_8090898: @ 8090898 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - adds r0, r5, 0 - bl RunFieldObjectStepTimer - lsls r0, 24 - cmp r0, 0 - bne _080908B6 - adds r0, r4, 0 - bl FieldObjectIsTrainerAndCloseToPlayer - lsls r0, 24 - cmp r0, 0 - beq _080908BE -_080908B6: - movs r0, 0x4 - strh r0, [r5, 0x30] - movs r0, 0x1 - b _080908C0 -_080908BE: - movs r0, 0 -_080908C0: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8090898 - - thumb_func_start sub_80908C8 -sub_80908C8: @ 80908C8 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - ldr r1, =gUnknown_0850D850 - mov r0, sp - movs r2, 0x4 - bl memcpy - adds r0, r4, 0 - movs r1, 0x7 - bl GetRunningPastFacingDirection - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0 - bne _080908F8 - bl Random - movs r1, 0x3 - ands r1, r0 - mov r2, sp - adds r0, r2, r1 - ldrb r1, [r0] -_080908F8: - adds r0, r4, 0 - bl FieldObjectSetDirection - movs r0, 0x1 - strh r0, [r5, 0x30] - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80908C8 - - thumb_func_start FieldObjectCB_RandomlyLookNorthOrSouthOrEast -FieldObjectCB_RandomlyLookNorthOrSouthOrEast: @ 8090910 - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =sub_8090934 - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_RandomlyLookNorthOrSouthOrEast - - thumb_func_start sub_8090934 -sub_8090934: @ 8090934 - push {r4,lr} - ldr r3, =gUnknown_0850D854 - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8090934 - - thumb_func_start sub_8090954 -sub_8090954: @ 8090954 - push {r4,lr} - adds r4, r1, 0 - bl npc_reset - movs r0, 0x1 - strh r0, [r4, 0x30] - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8090954 - - thumb_func_start sub_8090968 -sub_8090968: @ 8090968 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - ldrb r0, [r4, 0x18] - lsls r0, 28 - lsrs r0, 28 - bl GetFaceDirectionAnimId - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r1, r5, 0 - bl FieldObjectSetRegularAnim - movs r0, 0x2 - strh r0, [r5, 0x30] - movs r0, 0x1 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8090968 - - thumb_func_start sub_8090994 -sub_8090994: @ 8090994 - push {r4-r7,lr} - adds r6, r0, 0 - adds r7, r1, 0 - bl FieldObjectExecRegularAnim - lsls r0, 24 - cmp r0, 0 - beq _080909CA - ldr r4, =gUnknown_0850D6EC - bl Random - movs r5, 0x3 - adds r1, r5, 0 - ands r1, r0 - lsls r1, 1 - adds r1, r4 - movs r0, 0 - ldrsh r1, [r1, r0] - adds r0, r7, 0 - bl SetFieldObjectStepTimer - ldrb r1, [r6] - movs r0, 0x3 - negs r0, r0 - ands r0, r1 - strb r0, [r6] - strh r5, [r7, 0x30] -_080909CA: - movs r0, 0 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8090994 - - thumb_func_start sub_80909D8 -sub_80909D8: @ 80909D8 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - adds r0, r5, 0 - bl RunFieldObjectStepTimer - lsls r0, 24 - cmp r0, 0 - bne _080909F6 - adds r0, r4, 0 - bl FieldObjectIsTrainerAndCloseToPlayer - lsls r0, 24 - cmp r0, 0 - beq _080909FE -_080909F6: - movs r0, 0x4 - strh r0, [r5, 0x30] - movs r0, 0x1 - b _08090A00 -_080909FE: - movs r0, 0 -_08090A00: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80909D8 - - thumb_func_start sub_8090A08 -sub_8090A08: @ 8090A08 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - ldr r1, =gUnknown_0850D868 - mov r0, sp - movs r2, 0x4 - bl memcpy - adds r0, r4, 0 - movs r1, 0x8 - bl GetRunningPastFacingDirection - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0 - bne _08090A38 - bl Random - movs r1, 0x3 - ands r1, r0 - mov r2, sp - adds r0, r2, r1 - ldrb r1, [r0] -_08090A38: - adds r0, r4, 0 - bl FieldObjectSetDirection - movs r0, 0x1 - strh r0, [r5, 0x30] - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8090A08 - - thumb_func_start FieldObjectCB_RandomlyLookNorthOrEastOrWest -FieldObjectCB_RandomlyLookNorthOrEastOrWest: @ 8090A50 - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =sub_8090A74 - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_RandomlyLookNorthOrEastOrWest - - thumb_func_start sub_8090A74 -sub_8090A74: @ 8090A74 - push {r4,lr} - ldr r3, =gUnknown_0850D86C - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8090A74 - - thumb_func_start sub_8090A94 -sub_8090A94: @ 8090A94 - push {r4,lr} - adds r4, r1, 0 - bl npc_reset - movs r0, 0x1 - strh r0, [r4, 0x30] - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8090A94 - - thumb_func_start sub_8090AA8 -sub_8090AA8: @ 8090AA8 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - ldrb r0, [r4, 0x18] - lsls r0, 28 - lsrs r0, 28 - bl GetFaceDirectionAnimId - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r1, r5, 0 - bl FieldObjectSetRegularAnim - movs r0, 0x2 - strh r0, [r5, 0x30] - movs r0, 0x1 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8090AA8 - - thumb_func_start sub_8090AD4 -sub_8090AD4: @ 8090AD4 - push {r4-r7,lr} - adds r6, r0, 0 - adds r7, r1, 0 - bl FieldObjectExecRegularAnim - lsls r0, 24 - cmp r0, 0 - beq _08090B0A - ldr r4, =gUnknown_0850D6EC - bl Random - movs r5, 0x3 - adds r1, r5, 0 - ands r1, r0 - lsls r1, 1 - adds r1, r4 - movs r0, 0 - ldrsh r1, [r1, r0] - adds r0, r7, 0 - bl SetFieldObjectStepTimer - ldrb r1, [r6] - movs r0, 0x3 - negs r0, r0 - ands r0, r1 - strb r0, [r6] - strh r5, [r7, 0x30] -_08090B0A: - movs r0, 0 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8090AD4 - - thumb_func_start sub_8090B18 -sub_8090B18: @ 8090B18 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - adds r0, r5, 0 - bl RunFieldObjectStepTimer - lsls r0, 24 - cmp r0, 0 - bne _08090B36 - adds r0, r4, 0 - bl FieldObjectIsTrainerAndCloseToPlayer - lsls r0, 24 - cmp r0, 0 - beq _08090B3E -_08090B36: - movs r0, 0x4 - strh r0, [r5, 0x30] - movs r0, 0x1 - b _08090B40 -_08090B3E: - movs r0, 0 -_08090B40: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8090B18 - - thumb_func_start sub_8090B48 -sub_8090B48: @ 8090B48 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - ldr r1, =gUnknown_0850D880 - mov r0, sp - movs r2, 0x4 - bl memcpy - adds r0, r4, 0 - movs r1, 0x9 - bl GetRunningPastFacingDirection - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0 - bne _08090B78 - bl Random - movs r1, 0x3 - ands r1, r0 - mov r2, sp - adds r0, r2, r1 - ldrb r1, [r0] -_08090B78: - adds r0, r4, 0 - bl FieldObjectSetDirection - movs r0, 0x1 - strh r0, [r5, 0x30] - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8090B48 - - thumb_func_start FieldObjectCB_RandomlyLookSouthOrEastOrWest -FieldObjectCB_RandomlyLookSouthOrEastOrWest: @ 8090B90 - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =sub_8090BB4 - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_RandomlyLookSouthOrEastOrWest - - thumb_func_start sub_8090BB4 -sub_8090BB4: @ 8090BB4 - push {r4,lr} - ldr r3, =gUnknown_0850D884 - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8090BB4 - - thumb_func_start sub_8090BD4 -sub_8090BD4: @ 8090BD4 - push {r4,lr} - adds r4, r1, 0 - bl npc_reset - movs r0, 0x1 - strh r0, [r4, 0x30] - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8090BD4 - - thumb_func_start sub_8090BE8 -sub_8090BE8: @ 8090BE8 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - ldrb r0, [r4, 0x18] - lsls r0, 28 - lsrs r0, 28 - bl GetFaceDirectionAnimId - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r1, r5, 0 - bl FieldObjectSetRegularAnim - movs r0, 0x2 - strh r0, [r5, 0x30] - movs r0, 0x1 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8090BE8 - - thumb_func_start sub_8090C14 -sub_8090C14: @ 8090C14 - push {r4-r7,lr} - adds r6, r0, 0 - adds r7, r1, 0 - bl FieldObjectExecRegularAnim - lsls r0, 24 - cmp r0, 0 - beq _08090C4A - ldr r4, =gUnknown_0850D6EC - bl Random - movs r5, 0x3 - adds r1, r5, 0 - ands r1, r0 - lsls r1, 1 - adds r1, r4 - movs r0, 0 - ldrsh r1, [r1, r0] - adds r0, r7, 0 - bl SetFieldObjectStepTimer - ldrb r1, [r6] - movs r0, 0x3 - negs r0, r0 - ands r0, r1 - strb r0, [r6] - strh r5, [r7, 0x30] -_08090C4A: - movs r0, 0 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8090C14 - - thumb_func_start sub_8090C58 -sub_8090C58: @ 8090C58 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - adds r0, r5, 0 - bl RunFieldObjectStepTimer - lsls r0, 24 - cmp r0, 0 - bne _08090C76 - adds r0, r4, 0 - bl FieldObjectIsTrainerAndCloseToPlayer - lsls r0, 24 - cmp r0, 0 - beq _08090C7E -_08090C76: - movs r0, 0x4 - strh r0, [r5, 0x30] - movs r0, 0x1 - b _08090C80 -_08090C7E: - movs r0, 0 -_08090C80: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8090C58 - - thumb_func_start sub_8090C88 -sub_8090C88: @ 8090C88 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - ldr r1, =gUnknown_0850D898 - mov r0, sp - movs r2, 0x4 - bl memcpy - adds r0, r4, 0 - movs r1, 0xA - bl GetRunningPastFacingDirection - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0 - bne _08090CB8 - bl Random - movs r1, 0x3 - ands r1, r0 - mov r2, sp - adds r0, r2, r1 - ldrb r1, [r0] -_08090CB8: - adds r0, r4, 0 - bl FieldObjectSetDirection - movs r0, 0x1 - strh r0, [r5, 0x30] - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8090C88 - thumb_func_start FieldObjectCB_LookAroundCounterclockwise FieldObjectCB_LookAroundCounterclockwise: @ 8090CD0 push {lr} diff --git a/include/data3.h b/include/data3.h index 9aa8bc469..98d22566e 100755 --- a/include/data3.h +++ b/include/data3.h @@ -26,5 +26,9 @@ extern const u8 gUnknown_0850D7F0[2]; // {DIR_NORTH, DIR_WEST} extern const u8 gUnknown_0850D808[2]; // {DIR_NORTH, DIR_EAST} extern const u8 gUnknown_0850D820[2]; // {DIR_SOUTH, DIR_WEST} extern const u8 gUnknown_0850D838[2]; // {DIR_SOUTH, DIR_EAST} +extern const u8 gUnknown_0850D850[4]; +extern const u8 gUnknown_0850D868[4]; +extern const u8 gUnknown_0850D880[4]; +extern const u8 gUnknown_0850D898[4]; #endif //POKEEMERALD_DATA3_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index f4092265c..0ccf6039f 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -2698,3 +2698,215 @@ bool8 sub_8090788 (struct MapObject *mapObject, struct Sprite *sprite) sprite->data1 = 1; return TRUE; } + +field_object_step(RandomlyLookNorthOrSouthOrWest, gUnknown_0850D83C) + +bool8 sub_8090814 (struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + sprite->data1 = 1; + return TRUE; +} + +bool8 sub_8090828 (struct MapObject *mapObject, struct Sprite *sprite) +{ + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(mapObject->mapobj_unk_18)); + sprite->data1 = 2; + return TRUE; +} + +bool8 sub_8090854 (struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite)) + { + SetFieldObjectStepTimer(sprite, gUnknown_0850D6EC[Random() & 0x03]); + mapObject->mapobj_bit_1 = FALSE; + sprite->data1 = 3; + } + return FALSE; +} + +bool8 sub_8090898 (struct MapObject *mapObject, struct Sprite *sprite) +{ + if (RunFieldObjectStepTimer(sprite) || FieldObjectIsTrainerAndCloseToPlayer(mapObject)) + { + sprite->data1 = 4; + return TRUE; + } + return FALSE; +} + +bool8 sub_80908C8 (struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 directions[4]; + u8 direction; + + memcpy(directions, gUnknown_0850D850, sizeof gUnknown_0850D850); + direction = GetRunningPastFacingDirection(mapObject, RUNFOLLOW_NORTH_SOUTH_WEST); + if (direction == 0) + { + direction = directions[Random() & 0x03]; + } + FieldObjectSetDirection(mapObject, direction); + sprite->data1 = 1; + return TRUE; +} + +field_object_step(RandomlyLookNorthOrSouthOrEast, gUnknown_0850D854) + +bool8 sub_8090954 (struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + sprite->data1 = 1; + return TRUE; +} + +bool8 sub_8090968 (struct MapObject *mapObject, struct Sprite *sprite) +{ + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(mapObject->mapobj_unk_18)); + sprite->data1 = 2; + return TRUE; +} + +bool8 sub_8090994 (struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite)) + { + SetFieldObjectStepTimer(sprite, gUnknown_0850D6EC[Random() & 0x03]); + mapObject->mapobj_bit_1 = FALSE; + sprite->data1 = 3; + } + return FALSE; +} + +bool8 sub_80909D8 (struct MapObject *mapObject, struct Sprite *sprite) +{ + if (RunFieldObjectStepTimer(sprite) || FieldObjectIsTrainerAndCloseToPlayer(mapObject)) + { + sprite->data1 = 4; + return TRUE; + } + return FALSE; +} + +bool8 sub_8090A08 (struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 directions[4]; + u8 direction; + + memcpy(directions, gUnknown_0850D868, sizeof gUnknown_0850D868); + direction = GetRunningPastFacingDirection(mapObject, RUNFOLLOW_NORTH_SOUTH_EAST); + if (direction == 0) + { + direction = directions[Random() & 0x03]; + } + FieldObjectSetDirection(mapObject, direction); + sprite->data1 = 1; + return TRUE; +} + +field_object_step(RandomlyLookNorthOrEastOrWest, gUnknown_0850D86C) + +bool8 sub_8090A94 (struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + sprite->data1 = 1; + return TRUE; +} + +bool8 sub_8090AA8 (struct MapObject *mapObject, struct Sprite *sprite) +{ + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(mapObject->mapobj_unk_18)); + sprite->data1 = 2; + return TRUE; +} + +bool8 sub_8090AD4 (struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite)) + { + SetFieldObjectStepTimer(sprite, gUnknown_0850D6EC[Random() & 0x03]); + mapObject->mapobj_bit_1 = FALSE; + sprite->data1 = 3; + } + return FALSE; +} + +bool8 sub_8090B18 (struct MapObject *mapObject, struct Sprite *sprite) +{ + if (RunFieldObjectStepTimer(sprite) || FieldObjectIsTrainerAndCloseToPlayer(mapObject)) + { + sprite->data1 = 4; + return TRUE; + } + return FALSE; +} + +bool8 sub_8090B48 (struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 directions[4]; + u8 direction; + + memcpy(directions, gUnknown_0850D880, sizeof gUnknown_0850D880); + direction = GetRunningPastFacingDirection(mapObject, RUNFOLLOW_NORTH_EAST_WEST); + if (direction == 0) + { + direction = directions[Random() & 0x03]; + } + FieldObjectSetDirection(mapObject, direction); + sprite->data1 = 1; + return TRUE; +} + +field_object_step(RandomlyLookSouthOrEastOrWest, gUnknown_0850D884) + +bool8 sub_8090BD4 (struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + sprite->data1 = 1; + return TRUE; +} + +bool8 sub_8090BE8 (struct MapObject *mapObject, struct Sprite *sprite) +{ + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(mapObject->mapobj_unk_18)); + sprite->data1 = 2; + return TRUE; +} + +bool8 sub_8090C14 (struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite)) + { + SetFieldObjectStepTimer(sprite, gUnknown_0850D6EC[Random() & 0x03]); + mapObject->mapobj_bit_1 = FALSE; + sprite->data1 = 3; + } + return FALSE; +} + +bool8 sub_8090C58 (struct MapObject *mapObject, struct Sprite *sprite) +{ + if (RunFieldObjectStepTimer(sprite) || FieldObjectIsTrainerAndCloseToPlayer(mapObject)) + { + sprite->data1 = 4; + return TRUE; + } + return FALSE; +} + +bool8 sub_8090C88 (struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 directions[4]; + u8 direction; + + memcpy(directions, gUnknown_0850D898, sizeof gUnknown_0850D898); + direction = GetRunningPastFacingDirection(mapObject, RUNFOLLOW_SOUTH_EAST_WEST); + if (direction == 0) + { + direction = directions[Random() & 0x03]; + } + FieldObjectSetDirection(mapObject, direction); + sprite->data1 = 1; + return TRUE; +} From 1c6177f67895a20c99d7dfafd43afd83cf3bfff2 Mon Sep 17 00:00:00 2001 From: scnorton Date: Fri, 15 Sep 2017 16:34:03 -0400 Subject: [PATCH 104/191] Rotatoes --- asm/field_map_obj.s | 279 -------------------------------------------- include/data3.h | 2 + src/field_map_obj.c | 90 ++++++++++++++ 3 files changed, 92 insertions(+), 279 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 4d01b95f8..03453a503 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,285 +5,6 @@ .text - thumb_func_start FieldObjectCB_LookAroundCounterclockwise -FieldObjectCB_LookAroundCounterclockwise: @ 8090CD0 - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =sub_8090CF4 - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_LookAroundCounterclockwise - - thumb_func_start sub_8090CF4 -sub_8090CF4: @ 8090CF4 - push {r4,lr} - ldr r3, =gUnknown_0850D89C - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8090CF4 - - thumb_func_start sub_8090D14 -sub_8090D14: @ 8090D14 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl npc_reset - ldrb r0, [r4, 0x18] - lsls r0, 28 - lsrs r0, 28 - bl GetFaceDirectionAnimId - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r1, r5, 0 - bl FieldObjectSetRegularAnim - movs r0, 0x1 - strh r0, [r5, 0x30] - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8090D14 - - thumb_func_start sub_8090D40 -sub_8090D40: @ 8090D40 - push {r4,lr} - adds r4, r1, 0 - bl FieldObjectExecRegularAnim - lsls r0, 24 - cmp r0, 0 - beq _08090D5A - adds r0, r4, 0 - movs r1, 0x30 - bl SetFieldObjectStepTimer - movs r0, 0x2 - strh r0, [r4, 0x30] -_08090D5A: - movs r0, 0 - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8090D40 - - thumb_func_start sub_8090D64 -sub_8090D64: @ 8090D64 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - adds r0, r5, 0 - bl RunFieldObjectStepTimer - lsls r0, 24 - cmp r0, 0 - bne _08090D82 - adds r0, r4, 0 - bl FieldObjectIsTrainerAndCloseToPlayer - lsls r0, 24 - cmp r0, 0 - beq _08090D86 -_08090D82: - movs r0, 0x3 - strh r0, [r5, 0x30] -_08090D86: - movs r0, 0 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8090D64 - - thumb_func_start sub_8090D90 -@ bool8 sub_8090D90(struct npc_state *fieldObject, struct obj *object) -sub_8090D90: @ 8090D90 - push {r4,r5,lr} - sub sp, 0x8 - adds r4, r0, 0 - adds r5, r1, 0 - ldr r1, =gUnknown_0850D8AC - mov r0, sp - movs r2, 0x5 - bl memcpy - adds r0, r4, 0 - movs r1, 0 - bl GetRunningPastFacingDirection - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0 - bne _08090DBC - ldrb r0, [r4, 0x18] - lsls r0, 28 - lsrs r0, 28 - add r0, sp - ldrb r1, [r0] -_08090DBC: - adds r0, r4, 0 - bl FieldObjectSetDirection - movs r0, 0 - strh r0, [r5, 0x30] - movs r0, 0x1 - add sp, 0x8 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8090D90 - - thumb_func_start FieldObjectCB_LookAroundClockwise -FieldObjectCB_LookAroundClockwise: @ 8090DD4 - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =sub_8090DF8 - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_LookAroundClockwise - - thumb_func_start sub_8090DF8 -sub_8090DF8: @ 8090DF8 - push {r4,lr} - ldr r3, =gUnknown_0850D8B4 - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8090DF8 - - thumb_func_start sub_8090E18 -sub_8090E18: @ 8090E18 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl npc_reset - ldrb r0, [r4, 0x18] - lsls r0, 28 - lsrs r0, 28 - bl GetFaceDirectionAnimId - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r1, r5, 0 - bl FieldObjectSetRegularAnim - movs r0, 0x1 - strh r0, [r5, 0x30] - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8090E18 - - thumb_func_start sub_8090E44 -sub_8090E44: @ 8090E44 - push {r4,lr} - adds r4, r1, 0 - bl FieldObjectExecRegularAnim - lsls r0, 24 - cmp r0, 0 - beq _08090E5E - adds r0, r4, 0 - movs r1, 0x30 - bl SetFieldObjectStepTimer - movs r0, 0x2 - strh r0, [r4, 0x30] -_08090E5E: - movs r0, 0 - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8090E44 - - thumb_func_start sub_8090E68 -sub_8090E68: @ 8090E68 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - adds r0, r5, 0 - bl RunFieldObjectStepTimer - lsls r0, 24 - cmp r0, 0 - bne _08090E86 - adds r0, r4, 0 - bl FieldObjectIsTrainerAndCloseToPlayer - lsls r0, 24 - cmp r0, 0 - beq _08090E8A -_08090E86: - movs r0, 0x3 - strh r0, [r5, 0x30] -_08090E8A: - movs r0, 0 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8090E68 - - thumb_func_start sub_8090E94 -sub_8090E94: @ 8090E94 - push {r4,r5,lr} - sub sp, 0x8 - adds r4, r0, 0 - adds r5, r1, 0 - ldr r1, =gUnknown_0850D8C4 - mov r0, sp - movs r2, 0x5 - bl memcpy - adds r0, r4, 0 - movs r1, 0 - bl GetRunningPastFacingDirection - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0 - bne _08090EC0 - ldrb r0, [r4, 0x18] - lsls r0, 28 - lsrs r0, 28 - add r0, sp - ldrb r1, [r0] -_08090EC0: - adds r0, r4, 0 - bl FieldObjectSetDirection - movs r0, 0 - strh r0, [r5, 0x30] - movs r0, 0x1 - add sp, 0x8 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8090E94 - thumb_func_start FieldObjectCB_AlternatelyGoInOppositeDirections FieldObjectCB_AlternatelyGoInOppositeDirections: @ 8090ED8 push {lr} diff --git a/include/data3.h b/include/data3.h index 98d22566e..3cbdcc9ce 100755 --- a/include/data3.h +++ b/include/data3.h @@ -30,5 +30,7 @@ extern const u8 gUnknown_0850D850[4]; extern const u8 gUnknown_0850D868[4]; extern const u8 gUnknown_0850D880[4]; extern const u8 gUnknown_0850D898[4]; +extern const u8 gUnknown_0850D8AC[5]; +extern const u8 gUnknown_0850D8C4[5]; #endif //POKEEMERALD_DATA3_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 0ccf6039f..0ba4cc052 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -2910,3 +2910,93 @@ bool8 sub_8090C88 (struct MapObject *mapObject, struct Sprite *sprite) sprite->data1 = 1; return TRUE; } + +field_object_step(LookAroundCounterclockwise, gUnknown_0850D89C) + +bool8 sub_8090D14 (struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(mapObject->mapobj_unk_18)); + sprite->data1 = 1; + return TRUE; +} + +bool8 sub_8090D40 (struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite)) + { + SetFieldObjectStepTimer(sprite, 48); + sprite->data1 = 2; + } + return FALSE; +} + +bool8 sub_8090D64 (struct MapObject *mapObject, struct Sprite *sprite) +{ + if (RunFieldObjectStepTimer(sprite) || FieldObjectIsTrainerAndCloseToPlayer(mapObject)) + { + sprite->data1 = 3; + } + return FALSE; +} + +bool8 sub_8090D90 (struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 directions[5]; + u8 direction; + + memcpy(directions, gUnknown_0850D8AC, sizeof gUnknown_0850D8AC); + direction = GetRunningPastFacingDirection(mapObject, RUNFOLLOW_ANY); + if (direction == 0) + { + direction = directions[mapObject->mapobj_unk_18]; + } + FieldObjectSetDirection(mapObject, direction); + sprite->data1 = 0; + return TRUE; +} + +field_object_step(LookAroundClockwise, gUnknown_0850D8B4) + +bool8 sub_8090E18 (struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(mapObject->mapobj_unk_18)); + sprite->data1 = 1; + return TRUE; +} + +bool8 sub_8090E44 (struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite)) + { + SetFieldObjectStepTimer(sprite, 48); + sprite->data1 = 2; + } + return FALSE; +} + +bool8 sub_8090E68 (struct MapObject *mapObject, struct Sprite *sprite) +{ + if (RunFieldObjectStepTimer(sprite) || FieldObjectIsTrainerAndCloseToPlayer(mapObject)) + { + sprite->data1 = 3; + } + return FALSE; +} + +bool8 sub_8090E94 (struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 directions[5]; + u8 direction; + + memcpy(directions, gUnknown_0850D8C4, sizeof gUnknown_0850D8C4); + direction = GetRunningPastFacingDirection(mapObject, RUNFOLLOW_ANY); + if (direction == 0) + { + direction = directions[mapObject->mapobj_unk_18]; + } + FieldObjectSetDirection(mapObject, direction); + sprite->data1 = 0; + return TRUE; +} From 79e8235701de373e7d7cb84162343c487c7e1a5e Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Fri, 15 Sep 2017 21:26:56 -0400 Subject: [PATCH 105/191] AlternatelyGoInOppositeDirections --- asm/field_map_obj.s | 192 ---------------------------------------- include/field_map_obj.h | 2 + src/field_map_obj.c | 62 +++++++++++++ 3 files changed, 64 insertions(+), 192 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 03453a503..f9992ae3b 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,198 +5,6 @@ .text - thumb_func_start FieldObjectCB_AlternatelyGoInOppositeDirections -FieldObjectCB_AlternatelyGoInOppositeDirections: @ 8090ED8 - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =sub_8090EFC - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_AlternatelyGoInOppositeDirections - - thumb_func_start sub_8090EFC -sub_8090EFC: @ 8090EFC - push {r4,lr} - ldr r3, =gUnknown_0850D8CC - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8090EFC - - thumb_func_start sub_8090F1C -sub_8090F1C: @ 8090F1C - push {r4,lr} - adds r4, r1, 0 - bl npc_reset - movs r0, 0x1 - strh r0, [r4, 0x30] - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8090F1C - - thumb_func_start sub_8090F30 -@ bool8 sub_8090F30(struct npc_state *fieldObject, struct obj *object) -sub_8090F30: @ 8090F30 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - ldr r0, =gUnknown_085055CD - ldrb r1, [r4, 0x6] - adds r1, r0 - ldrb r1, [r1] - adds r0, r4, 0 - adds r0, 0x21 - ldrb r0, [r0] - cmp r0, 0 - beq _08090F52 - adds r0, r1, 0 - bl GetOppositeDirection - lsls r0, 24 - lsrs r1, r0, 24 -_08090F52: - adds r0, r4, 0 - bl FieldObjectSetDirection - movs r0, 0x2 - strh r0, [r5, 0x30] - movs r0, 0x1 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8090F30 - - thumb_func_start sub_8090F68 -@ bool8 sub_8090F68(struct npc_state *fieldObject, struct obj *object) -sub_8090F68: @ 8090F68 - push {r4-r7,lr} - adds r4, r0, 0 - adds r7, r1, 0 - adds r2, r4, 0 - adds r2, 0x21 - ldrb r0, [r2] - cmp r0, 0 - beq _08090F98 - ldr r1, [r4, 0xC] - ldr r0, [r4, 0x10] - cmp r1, r0 - bne _08090F98 - movs r0, 0 - strb r0, [r2] - ldrb r0, [r4, 0x18] - lsrs r0, 4 - bl GetOppositeDirection - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 24 - adds r0, r4, 0 - bl FieldObjectSetDirection -_08090F98: - ldrb r1, [r4, 0x18] - lsrs r1, 4 - adds r0, r4, 0 - bl npc_block_way__next_tile - lsls r0, 24 - lsrs r5, r0, 24 - ldrb r0, [r4, 0x18] - lsrs r0, 4 - bl GetGoSpeed0AnimId - lsls r0, 24 - lsrs r6, r0, 24 - cmp r5, 0x1 - bne _08090FEE - adds r1, r4, 0 - adds r1, 0x21 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - ldrb r0, [r4, 0x18] - lsrs r0, 4 - bl GetOppositeDirection - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 24 - adds r0, r4, 0 - bl FieldObjectSetDirection - ldrb r0, [r4, 0x18] - lsrs r0, 4 - bl GetGoSpeed0AnimId - lsls r0, 24 - lsrs r6, r0, 24 - ldrb r1, [r4, 0x18] - lsrs r1, 4 - adds r0, r4, 0 - bl npc_block_way__next_tile - lsls r0, 24 - lsrs r5, r0, 24 -_08090FEE: - cmp r5, 0 - beq _08091000 - ldrb r0, [r4, 0x18] - lsls r0, 28 - lsrs r0, 28 - bl GetStepInPlaceDelay16AnimId - lsls r0, 24 - lsrs r6, r0, 24 -_08091000: - adds r0, r4, 0 - adds r1, r7, 0 - adds r2, r6, 0 - bl FieldObjectSetRegularAnim - ldrb r0, [r4] - movs r1, 0x2 - orrs r0, r1 - strb r0, [r4] - movs r0, 0x3 - strh r0, [r7, 0x30] - movs r0, 0x1 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_8090F68 - - thumb_func_start sub_8091020 -@ bool8 sub_8091020(struct npc_state *fieldObject, struct obj *object) -sub_8091020: @ 8091020 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl FieldObjectExecRegularAnim - lsls r0, 24 - cmp r0, 0 - beq _0809103E - ldrb r0, [r4] - movs r1, 0x3 - negs r1, r1 - ands r1, r0 - strb r1, [r4] - movs r0, 0x1 - strh r0, [r5, 0x30] -_0809103E: - movs r0, 0 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8091020 - thumb_func_start sub_8091048 @ bool8 sub_8091048(struct npc_state *fieldObject, struct obj *object) sub_8091048: @ 8091048 diff --git a/include/field_map_obj.h b/include/field_map_obj.h index 43446ea84..db1ed233f 100755 --- a/include/field_map_obj.h +++ b/include/field_map_obj.h @@ -62,6 +62,8 @@ void npc_coords_shift(struct MapObject *, s16, s16); void sub_808EB08(struct MapObject *, s16, s16); void sub_808F254(u8, u8, u8); void FieldObjectStep(struct MapObject *, struct Sprite *, bool8(struct MapObject *, struct Sprite *)); +u8 GetOppositeDirection(u8); +u8 GetStepInPlaceDelay16AnimId(u8); // Exported data declarations diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 0ba4cc052..91856d1ee 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -3000,3 +3000,65 @@ bool8 sub_8090E94 (struct MapObject *mapObject, struct Sprite *sprite) sprite->data1 = 0; return TRUE; } + +field_object_step(AlternatelyGoInOppositeDirections, gUnknown_0850D8CC) + +bool8 sub_8090F1C (struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + sprite->data1 = 1; + return TRUE; +} + +bool8 sub_8090F30 (struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 direction; + + direction = gUnknown_085055CD[mapObject->animPattern]; + if (mapObject->mapobj_unk_21) + { + direction = GetOppositeDirection(direction); + } + FieldObjectSetDirection(mapObject, direction); + sprite->data1 = 2; + return TRUE; +} + +bool8 sub_8090F68 (struct MapObject *mapObject, struct Sprite *sprite) +{ + bool8 blockingWay; + u8 animId; + + if (mapObject->mapobj_unk_21 && mapObject->coords1.x == mapObject->coords2.x && mapObject->coords1.y == mapObject->coords2.y) + { + mapObject->mapobj_unk_21 = 0; + FieldObjectSetDirection(mapObject, GetOppositeDirection(mapObject->placeholder18)); + } + blockingWay = npc_block_way__next_tile(mapObject, mapObject->placeholder18); + animId = GetGoSpeed0AnimId(mapObject->placeholder18); + if (blockingWay == TRUE) + { + mapObject->mapobj_unk_21 ++; + FieldObjectSetDirection(mapObject, GetOppositeDirection(mapObject->placeholder18)); + animId = GetGoSpeed0AnimId(mapObject->placeholder18); + blockingWay = npc_block_way__next_tile(mapObject, mapObject->placeholder18); + } + if (blockingWay) + { + animId = GetStepInPlaceDelay16AnimId(mapObject->mapobj_unk_18); + } + FieldObjectSetRegularAnim(mapObject, sprite, animId); + mapObject->mapobj_bit_1 = TRUE; + sprite->data1 = 3; + return TRUE; +} + +bool8 sub_8091020 (struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite)) + { + mapObject->mapobj_bit_1 = FALSE; + sprite->data1 = 1; + } + return FALSE; +} From 3e9e4b13ec977cc4f5dd696d2dc8d362f58317dc Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Fri, 15 Sep 2017 21:39:24 -0400 Subject: [PATCH 106/191] MoveFieldObjectInNextDirectionInSequence --- asm/field_map_obj.s | 102 -------------------------------------------- src/field_map_obj.c | 36 ++++++++++++++++ 2 files changed, 36 insertions(+), 102 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index f9992ae3b..fc8efe4c8 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,108 +5,6 @@ .text - thumb_func_start sub_8091048 -@ bool8 sub_8091048(struct npc_state *fieldObject, struct obj *object) -sub_8091048: @ 8091048 - push {r4,lr} - adds r4, r1, 0 - bl npc_reset - movs r0, 0x1 - strh r0, [r4, 0x30] - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8091048 - - thumb_func_start MoveFieldObjectInNextDirectionInSequence -@ bool8 MoveFieldObjectInNextDirectionInSequence(struct npc_state *fieldObject, struct obj *object, u8 *directions) -MoveFieldObjectInNextDirectionInSequence: @ 809105C - push {r4-r7,lr} - mov r7, r8 - push {r7} - adds r4, r0, 0 - mov r8, r1 - adds r7, r2, 0 - adds r2, r4, 0 - adds r2, 0x21 - ldrb r0, [r2] - cmp r0, 0x3 - bne _0809107E - ldr r1, [r4, 0xC] - ldr r0, [r4, 0x10] - cmp r1, r0 - bne _0809107E - movs r0, 0 - strb r0, [r2] -_0809107E: - adds r5, r4, 0 - adds r5, 0x21 - ldrb r0, [r5] - adds r0, r7, r0 - ldrb r1, [r0] - adds r0, r4, 0 - bl FieldObjectSetDirection - ldrb r0, [r4, 0x18] - lsrs r0, 4 - bl GetGoSpeed0AnimId - lsls r0, 24 - lsrs r6, r0, 24 - ldrb r1, [r4, 0x18] - lsrs r1, 4 - adds r0, r4, 0 - bl npc_block_way__next_tile - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _080910D8 - ldrb r0, [r5] - adds r0, 0x1 - strb r0, [r5] - ldrb r0, [r5] - adds r0, r7, r0 - ldrb r1, [r0] - adds r0, r4, 0 - bl FieldObjectSetDirection - ldrb r0, [r4, 0x18] - lsrs r0, 4 - bl GetGoSpeed0AnimId - lsls r0, 24 - lsrs r6, r0, 24 - ldrb r1, [r4, 0x18] - lsrs r1, 4 - adds r0, r4, 0 - bl npc_block_way__next_tile - lsls r0, 24 - lsrs r0, 24 -_080910D8: - cmp r0, 0 - beq _080910EA - ldrb r0, [r4, 0x18] - lsls r0, 28 - lsrs r0, 28 - bl GetStepInPlaceDelay16AnimId - lsls r0, 24 - lsrs r6, r0, 24 -_080910EA: - adds r0, r4, 0 - mov r1, r8 - adds r2, r6, 0 - bl FieldObjectSetRegularAnim - ldrb r0, [r4] - movs r1, 0x2 - orrs r0, r1 - strb r0, [r4] - movs r0, 0x2 - mov r1, r8 - strh r0, [r1, 0x30] - movs r0, 0x1 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end MoveFieldObjectInNextDirectionInSequence - thumb_func_start sub_8091110 @ bool8 sub_8091110(struct npc_state *fieldObject, struct obj *object) sub_8091110: @ 8091110 diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 91856d1ee..cfe04f395 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -3062,3 +3062,39 @@ bool8 sub_8091020 (struct MapObject *mapObject, struct Sprite *sprite) } return FALSE; } + +bool8 sub_8091048(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + sprite->data1 = 1; + return TRUE; +} + +bool8 MoveFieldObjectInNextDirectionInSequence(struct MapObject *mapObject, struct Sprite *sprite, u8 *route) +{ + u8 blockingWay; + u8 animId; + + if (mapObject->mapobj_unk_21 == 3 && mapObject->coords1.x == mapObject->coords2.x && mapObject->coords1.y == mapObject->coords2.y) + { + mapObject->mapobj_unk_21 = 0; + } + FieldObjectSetDirection(mapObject, route[mapObject->mapobj_unk_21]); + animId = GetGoSpeed0AnimId(mapObject->placeholder18); + blockingWay = npc_block_way__next_tile(mapObject, mapObject->placeholder18); + if (blockingWay == TRUE) + { + mapObject->mapobj_unk_21 ++; + FieldObjectSetDirection(mapObject, route[mapObject->mapobj_unk_21]); + animId = GetGoSpeed0AnimId(mapObject->placeholder18); + blockingWay = npc_block_way__next_tile(mapObject, mapObject->placeholder18); + } + if (blockingWay) + { + animId = GetStepInPlaceDelay16AnimId(mapObject->mapobj_unk_18); + } + FieldObjectSetRegularAnim(mapObject, sprite, animId); + mapObject->mapobj_bit_1 = TRUE; + sprite->data1 = 2; + return TRUE; +} From a082f9258148831bfa35d925e4d0fd05e7479e6f Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 16 Sep 2017 08:13:37 -0400 Subject: [PATCH 107/191] sub_8091110 --- asm/field_map_obj.s | 24 ------------------------ src/field_map_obj.c | 10 ++++++++++ 2 files changed, 10 insertions(+), 24 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index fc8efe4c8..7a6d08ea3 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,30 +5,6 @@ .text - thumb_func_start sub_8091110 -@ bool8 sub_8091110(struct npc_state *fieldObject, struct obj *object) -sub_8091110: @ 8091110 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl FieldObjectExecRegularAnim - lsls r0, 24 - cmp r0, 0 - beq _0809112E - ldrb r0, [r4] - movs r1, 0x3 - negs r1, r1 - ands r1, r0 - strb r1, [r4] - movs r0, 0x1 - strh r0, [r5, 0x30] -_0809112E: - movs r0, 0 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8091110 - thumb_func_start FieldObjectCB_GoInDirectionSequence1 FieldObjectCB_GoInDirectionSequence1: @ 8091138 push {lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index cfe04f395..0c6397730 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -3098,3 +3098,13 @@ bool8 MoveFieldObjectInNextDirectionInSequence(struct MapObject *mapObject, stru sprite->data1 = 2; return TRUE; } + +bool8 sub_8091110(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite)) + { + mapObject->mapobj_bit_1 = FALSE; + sprite->data1 = 1; + } + return FALSE; +} From 86df6d10736e1b680e874d7440f478fe5ddf8105 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 16 Sep 2017 08:44:43 -0400 Subject: [PATCH 108/191] Field object path movement --- asm/field_map_obj.s | 1753 ------------------------------------------- include/data3.h | 1 + src/field_map_obj.c | 39 + 3 files changed, 40 insertions(+), 1753 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 7a6d08ea3..fbe6aa8d8 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,1759 +5,6 @@ .text - thumb_func_start FieldObjectCB_GoInDirectionSequence1 -FieldObjectCB_GoInDirectionSequence1: @ 8091138 - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =sub_809115C - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_GoInDirectionSequence1 - - thumb_func_start sub_809115C -sub_809115C: @ 809115C - push {r4,lr} - ldr r3, =gUnknown_0850D8DC - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_809115C - - thumb_func_start sub_809117C -sub_809117C: @ 809117C - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - ldr r1, =gUnknown_0850D8E8 - mov r0, sp - movs r2, 0x4 - bl memcpy - adds r2, r4, 0 - adds r2, 0x21 - ldrb r0, [r2] - cmp r0, 0x2 - bne _080911A8 - movs r0, 0xC - ldrsh r1, [r4, r0] - movs r3, 0x10 - ldrsh r0, [r4, r3] - cmp r1, r0 - bne _080911A8 - movs r0, 0x3 - strb r0, [r2] -_080911A8: - adds r0, r4, 0 - adds r1, r5, 0 - mov r2, sp - bl MoveFieldObjectInNextDirectionInSequence - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_809117C - - thumb_func_start FieldObjectCB_GoInDirectionSequence2 -FieldObjectCB_GoInDirectionSequence2: @ 80911C4 - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =sub_80911E8 - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_GoInDirectionSequence2 - - thumb_func_start sub_80911E8 -sub_80911E8: @ 80911E8 - push {r4,lr} - ldr r3, =gUnknown_0850D8EC - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80911E8 - - thumb_func_start sub_8091208 -sub_8091208: @ 8091208 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - ldr r1, =gUnknown_0850D8F8 - mov r0, sp - movs r2, 0x4 - bl memcpy - adds r2, r4, 0 - adds r2, 0x21 - ldrb r0, [r2] - cmp r0, 0x1 - bne _08091234 - movs r0, 0xC - ldrsh r1, [r4, r0] - movs r3, 0x10 - ldrsh r0, [r4, r3] - cmp r1, r0 - bne _08091234 - movs r0, 0x2 - strb r0, [r2] -_08091234: - adds r0, r4, 0 - adds r1, r5, 0 - mov r2, sp - bl MoveFieldObjectInNextDirectionInSequence - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8091208 - - thumb_func_start FieldObjectCB_GoInDirectionSequence3 -FieldObjectCB_GoInDirectionSequence3: @ 8091250 - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =sub_8091274 - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_GoInDirectionSequence3 - - thumb_func_start sub_8091274 -sub_8091274: @ 8091274 - push {r4,lr} - ldr r3, =gUnknown_0850D8FC - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8091274 - - thumb_func_start sub_8091294 -sub_8091294: @ 8091294 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - ldr r1, =gUnknown_0850D908 - mov r0, sp - movs r2, 0x4 - bl memcpy - adds r2, r4, 0 - adds r2, 0x21 - ldrb r0, [r2] - cmp r0, 0x1 - bne _080912C0 - movs r0, 0xE - ldrsh r1, [r4, r0] - movs r3, 0x12 - ldrsh r0, [r4, r3] - cmp r1, r0 - bne _080912C0 - movs r0, 0x2 - strb r0, [r2] -_080912C0: - adds r0, r4, 0 - adds r1, r5, 0 - mov r2, sp - bl MoveFieldObjectInNextDirectionInSequence - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8091294 - - thumb_func_start FieldObjectCB_GoInDirectionSequence4 -FieldObjectCB_GoInDirectionSequence4: @ 80912DC - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =sub_8091300 - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_GoInDirectionSequence4 - - thumb_func_start sub_8091300 -sub_8091300: @ 8091300 - push {r4,lr} - ldr r3, =gUnknown_0850D90C - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8091300 - - thumb_func_start sub_8091320 -sub_8091320: @ 8091320 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - ldr r1, =gUnknown_0850D918 - mov r0, sp - movs r2, 0x4 - bl memcpy - adds r2, r4, 0 - adds r2, 0x21 - ldrb r0, [r2] - cmp r0, 0x2 - bne _0809134C - movs r0, 0xE - ldrsh r1, [r4, r0] - movs r3, 0x12 - ldrsh r0, [r4, r3] - cmp r1, r0 - bne _0809134C - movs r0, 0x3 - strb r0, [r2] -_0809134C: - adds r0, r4, 0 - adds r1, r5, 0 - mov r2, sp - bl MoveFieldObjectInNextDirectionInSequence - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8091320 - - thumb_func_start FieldObjectCB_GoInDirectionSequence5 -FieldObjectCB_GoInDirectionSequence5: @ 8091368 - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =sub_809138C - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_GoInDirectionSequence5 - - thumb_func_start sub_809138C -sub_809138C: @ 809138C - push {r4,lr} - ldr r3, =gUnknown_0850D91C - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_809138C - - thumb_func_start sub_80913AC -@ bool8 sub_80913AC(struct npc_state *fieldObject, struct obj *object) -sub_80913AC: @ 80913AC - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - ldr r1, =gUnknown_0850D928 - mov r0, sp - movs r2, 0x4 - bl memcpy - adds r2, r4, 0 - adds r2, 0x21 - ldrb r0, [r2] - cmp r0, 0x2 - bne _080913D8 - movs r0, 0xC - ldrsh r1, [r4, r0] - movs r3, 0x10 - ldrsh r0, [r4, r3] - cmp r1, r0 - bne _080913D8 - movs r0, 0x3 - strb r0, [r2] -_080913D8: - adds r0, r4, 0 - adds r1, r5, 0 - mov r2, sp - bl MoveFieldObjectInNextDirectionInSequence - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80913AC - - thumb_func_start FieldObjectCB_GoInDirectionSequence6 -FieldObjectCB_GoInDirectionSequence6: @ 80913F4 - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =sub_8091418 - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_GoInDirectionSequence6 - - thumb_func_start sub_8091418 -sub_8091418: @ 8091418 - push {r4,lr} - ldr r3, =gUnknown_0850D92C - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8091418 - - thumb_func_start sub_8091438 -sub_8091438: @ 8091438 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - ldr r1, =gUnknown_0850D938 - mov r0, sp - movs r2, 0x4 - bl memcpy - adds r2, r4, 0 - adds r2, 0x21 - ldrb r0, [r2] - cmp r0, 0x1 - bne _08091464 - movs r0, 0xC - ldrsh r1, [r4, r0] - movs r3, 0x10 - ldrsh r0, [r4, r3] - cmp r1, r0 - bne _08091464 - movs r0, 0x2 - strb r0, [r2] -_08091464: - adds r0, r4, 0 - adds r1, r5, 0 - mov r2, sp - bl MoveFieldObjectInNextDirectionInSequence - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8091438 - - thumb_func_start FieldObjectCB_GoInDirectionSequence7 -FieldObjectCB_GoInDirectionSequence7: @ 8091480 - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =sub_80914A4 - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_GoInDirectionSequence7 - - thumb_func_start sub_80914A4 -sub_80914A4: @ 80914A4 - push {r4,lr} - ldr r3, =gUnknown_0850D93C - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80914A4 - - thumb_func_start sub_80914C4 -sub_80914C4: @ 80914C4 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - ldr r1, =gUnknown_0850D710 - mov r0, sp - movs r2, 0x4 - bl memcpy - adds r2, r4, 0 - adds r2, 0x21 - ldrb r0, [r2] - cmp r0, 0x1 - bne _080914F0 - movs r0, 0xE - ldrsh r1, [r4, r0] - movs r3, 0x12 - ldrsh r0, [r4, r3] - cmp r1, r0 - bne _080914F0 - movs r0, 0x2 - strb r0, [r2] -_080914F0: - adds r0, r4, 0 - adds r1, r5, 0 - mov r2, sp - bl MoveFieldObjectInNextDirectionInSequence - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80914C4 - - thumb_func_start FieldObjectCB_GoInDirectionSequence8 -FieldObjectCB_GoInDirectionSequence8: @ 809150C - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =sub_8091530 - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_GoInDirectionSequence8 - - thumb_func_start sub_8091530 -sub_8091530: @ 8091530 - push {r4,lr} - ldr r3, =gUnknown_0850D948 - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8091530 - - thumb_func_start sub_8091550 -sub_8091550: @ 8091550 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - ldr r1, =gUnknown_0850D954 - mov r0, sp - movs r2, 0x4 - bl memcpy - adds r2, r4, 0 - adds r2, 0x21 - ldrb r0, [r2] - cmp r0, 0x2 - bne _0809157C - movs r0, 0xE - ldrsh r1, [r4, r0] - movs r3, 0x12 - ldrsh r0, [r4, r3] - cmp r1, r0 - bne _0809157C - movs r0, 0x3 - strb r0, [r2] -_0809157C: - adds r0, r4, 0 - adds r1, r5, 0 - mov r2, sp - bl MoveFieldObjectInNextDirectionInSequence - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8091550 - - thumb_func_start FieldObjectCB_GoInDirectionSequence9 -FieldObjectCB_GoInDirectionSequence9: @ 8091598 - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =sub_80915BC - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_GoInDirectionSequence9 - - thumb_func_start sub_80915BC -sub_80915BC: @ 80915BC - push {r4,lr} - ldr r3, =gUnknown_0850D958 - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80915BC - - thumb_func_start sub_80915DC -sub_80915DC: @ 80915DC - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - ldr r1, =gUnknown_0850D964 - mov r0, sp - movs r2, 0x4 - bl memcpy - adds r2, r4, 0 - adds r2, 0x21 - ldrb r0, [r2] - cmp r0, 0x2 - bne _08091608 - movs r0, 0xE - ldrsh r1, [r4, r0] - movs r3, 0x12 - ldrsh r0, [r4, r3] - cmp r1, r0 - bne _08091608 - movs r0, 0x3 - strb r0, [r2] -_08091608: - adds r0, r4, 0 - adds r1, r5, 0 - mov r2, sp - bl MoveFieldObjectInNextDirectionInSequence - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80915DC - - thumb_func_start FieldObjectCB_GoInDirectionSequence10 -FieldObjectCB_GoInDirectionSequence10: @ 8091624 - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =sub_8091648 - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_GoInDirectionSequence10 - - thumb_func_start sub_8091648 -sub_8091648: @ 8091648 - push {r4,lr} - ldr r3, =gUnknown_0850D968 - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8091648 - - thumb_func_start sub_8091668 -sub_8091668: @ 8091668 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - ldr r1, =gUnknown_0850D974 - mov r0, sp - movs r2, 0x4 - bl memcpy - adds r2, r4, 0 - adds r2, 0x21 - ldrb r0, [r2] - cmp r0, 0x1 - bne _08091694 - movs r0, 0xE - ldrsh r1, [r4, r0] - movs r3, 0x12 - ldrsh r0, [r4, r3] - cmp r1, r0 - bne _08091694 - movs r0, 0x2 - strb r0, [r2] -_08091694: - adds r0, r4, 0 - adds r1, r5, 0 - mov r2, sp - bl MoveFieldObjectInNextDirectionInSequence - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8091668 - - thumb_func_start FieldObjectCB_GoInDirectionSequence11 -FieldObjectCB_GoInDirectionSequence11: @ 80916B0 - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =sub_80916D4 - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_GoInDirectionSequence11 - - thumb_func_start sub_80916D4 -sub_80916D4: @ 80916D4 - push {r4,lr} - ldr r3, =gUnknown_0850D978 - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80916D4 - - thumb_func_start sub_80916F4 -sub_80916F4: @ 80916F4 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - ldr r1, =gUnknown_0850D984 - mov r0, sp - movs r2, 0x4 - bl memcpy - adds r2, r4, 0 - adds r2, 0x21 - ldrb r0, [r2] - cmp r0, 0x1 - bne _08091720 - movs r0, 0xC - ldrsh r1, [r4, r0] - movs r3, 0x10 - ldrsh r0, [r4, r3] - cmp r1, r0 - bne _08091720 - movs r0, 0x2 - strb r0, [r2] -_08091720: - adds r0, r4, 0 - adds r1, r5, 0 - mov r2, sp - bl MoveFieldObjectInNextDirectionInSequence - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80916F4 - - thumb_func_start FieldObjectCB_GoInDirectionSequence12 -FieldObjectCB_GoInDirectionSequence12: @ 809173C - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =sub_8091760 - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_GoInDirectionSequence12 - - thumb_func_start sub_8091760 -sub_8091760: @ 8091760 - push {r4,lr} - ldr r3, =gUnknown_0850D988 - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8091760 - - thumb_func_start sub_8091780 -sub_8091780: @ 8091780 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - ldr r1, =gUnknown_0850D994 - mov r0, sp - movs r2, 0x4 - bl memcpy - adds r2, r4, 0 - adds r2, 0x21 - ldrb r0, [r2] - cmp r0, 0x2 - bne _080917AC - movs r0, 0xC - ldrsh r1, [r4, r0] - movs r3, 0x10 - ldrsh r0, [r4, r3] - cmp r1, r0 - bne _080917AC - movs r0, 0x3 - strb r0, [r2] -_080917AC: - adds r0, r4, 0 - adds r1, r5, 0 - mov r2, sp - bl MoveFieldObjectInNextDirectionInSequence - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8091780 - - thumb_func_start FieldObjectCB_GoInDirectionSequence13 -FieldObjectCB_GoInDirectionSequence13: @ 80917C8 - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =sub_80917EC - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_GoInDirectionSequence13 - - thumb_func_start sub_80917EC -sub_80917EC: @ 80917EC - push {r4,lr} - ldr r3, =gUnknown_0850D998 - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80917EC - - thumb_func_start sub_809180C -sub_809180C: @ 809180C - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - ldr r1, =gUnknown_0850D9A4 - mov r0, sp - movs r2, 0x4 - bl memcpy - adds r2, r4, 0 - adds r2, 0x21 - ldrb r0, [r2] - cmp r0, 0x2 - bne _08091838 - movs r0, 0xE - ldrsh r1, [r4, r0] - movs r3, 0x12 - ldrsh r0, [r4, r3] - cmp r1, r0 - bne _08091838 - movs r0, 0x3 - strb r0, [r2] -_08091838: - adds r0, r4, 0 - adds r1, r5, 0 - mov r2, sp - bl MoveFieldObjectInNextDirectionInSequence - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_809180C - - thumb_func_start FieldObjectCB_GoInDirectionSequence14 -FieldObjectCB_GoInDirectionSequence14: @ 8091854 - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =sub_8091878 - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_GoInDirectionSequence14 - - thumb_func_start sub_8091878 -sub_8091878: @ 8091878 - push {r4,lr} - ldr r3, =gUnknown_0850D9A8 - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8091878 - - thumb_func_start sub_8091898 -sub_8091898: @ 8091898 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - ldr r1, =gUnknown_0850D9B4 - mov r0, sp - movs r2, 0x4 - bl memcpy - adds r2, r4, 0 - adds r2, 0x21 - ldrb r0, [r2] - cmp r0, 0x1 - bne _080918C4 - movs r0, 0xE - ldrsh r1, [r4, r0] - movs r3, 0x12 - ldrsh r0, [r4, r3] - cmp r1, r0 - bne _080918C4 - movs r0, 0x2 - strb r0, [r2] -_080918C4: - adds r0, r4, 0 - adds r1, r5, 0 - mov r2, sp - bl MoveFieldObjectInNextDirectionInSequence - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8091898 - - thumb_func_start FieldObjectCB_GoInDirectionSequence15 -FieldObjectCB_GoInDirectionSequence15: @ 80918E0 - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =sub_8091904 - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_GoInDirectionSequence15 - - thumb_func_start sub_8091904 -sub_8091904: @ 8091904 - push {r4,lr} - ldr r3, =gUnknown_0850D9B8 - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8091904 - - thumb_func_start sub_8091924 -sub_8091924: @ 8091924 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - ldr r1, =gUnknown_0850D9C4 - mov r0, sp - movs r2, 0x4 - bl memcpy - adds r2, r4, 0 - adds r2, 0x21 - ldrb r0, [r2] - cmp r0, 0x1 - bne _08091950 - movs r0, 0xC - ldrsh r1, [r4, r0] - movs r3, 0x10 - ldrsh r0, [r4, r3] - cmp r1, r0 - bne _08091950 - movs r0, 0x2 - strb r0, [r2] -_08091950: - adds r0, r4, 0 - adds r1, r5, 0 - mov r2, sp - bl MoveFieldObjectInNextDirectionInSequence - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8091924 - - thumb_func_start FieldObjectCB_GoInDirectionSequence16 -FieldObjectCB_GoInDirectionSequence16: @ 809196C - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =sub_8091990 - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_GoInDirectionSequence16 - - thumb_func_start sub_8091990 -sub_8091990: @ 8091990 - push {r4,lr} - ldr r3, =gUnknown_0850D9C8 - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8091990 - - thumb_func_start sub_80919B0 -sub_80919B0: @ 80919B0 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - ldr r1, =gUnknown_0850D9D4 - mov r0, sp - movs r2, 0x4 - bl memcpy - adds r2, r4, 0 - adds r2, 0x21 - ldrb r0, [r2] - cmp r0, 0x2 - bne _080919DC - movs r0, 0xC - ldrsh r1, [r4, r0] - movs r3, 0x10 - ldrsh r0, [r4, r3] - cmp r1, r0 - bne _080919DC - movs r0, 0x3 - strb r0, [r2] -_080919DC: - adds r0, r4, 0 - adds r1, r5, 0 - mov r2, sp - bl MoveFieldObjectInNextDirectionInSequence - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80919B0 - - thumb_func_start FieldObjectCB_GoInDirectionSequence17 -FieldObjectCB_GoInDirectionSequence17: @ 80919F8 - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =sub_8091A1C - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_GoInDirectionSequence17 - - thumb_func_start sub_8091A1C -sub_8091A1C: @ 8091A1C - push {r4,lr} - ldr r3, =gUnknown_0850D9D8 - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8091A1C - - thumb_func_start sub_8091A3C -sub_8091A3C: @ 8091A3C - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - ldr r1, =gUnknown_0850D9E4 - mov r0, sp - movs r2, 0x4 - bl memcpy - adds r2, r4, 0 - adds r2, 0x21 - ldrb r0, [r2] - cmp r0, 0x2 - bne _08091A68 - movs r0, 0xE - ldrsh r1, [r4, r0] - movs r3, 0x12 - ldrsh r0, [r4, r3] - cmp r1, r0 - bne _08091A68 - movs r0, 0x3 - strb r0, [r2] -_08091A68: - adds r0, r4, 0 - adds r1, r5, 0 - mov r2, sp - bl MoveFieldObjectInNextDirectionInSequence - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8091A3C - - thumb_func_start FieldObjectCB_GoInDirectionSequence18 -FieldObjectCB_GoInDirectionSequence18: @ 8091A84 - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =sub_8091AA8 - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_GoInDirectionSequence18 - - thumb_func_start sub_8091AA8 -sub_8091AA8: @ 8091AA8 - push {r4,lr} - ldr r3, =gUnknown_0850D9E8 - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8091AA8 - - thumb_func_start sub_8091AC8 -sub_8091AC8: @ 8091AC8 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - ldr r1, =gUnknown_0850D9F4 - mov r0, sp - movs r2, 0x4 - bl memcpy - adds r2, r4, 0 - adds r2, 0x21 - ldrb r0, [r2] - cmp r0, 0x2 - bne _08091AF4 - movs r0, 0xE - ldrsh r1, [r4, r0] - movs r3, 0x12 - ldrsh r0, [r4, r3] - cmp r1, r0 - bne _08091AF4 - movs r0, 0x3 - strb r0, [r2] -_08091AF4: - adds r0, r4, 0 - adds r1, r5, 0 - mov r2, sp - bl MoveFieldObjectInNextDirectionInSequence - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8091AC8 - - thumb_func_start FieldObjectCB_GoInDirectionSequence19 -FieldObjectCB_GoInDirectionSequence19: @ 8091B10 - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =sub_8091B34 - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_GoInDirectionSequence19 - - thumb_func_start sub_8091B34 -sub_8091B34: @ 8091B34 - push {r4,lr} - ldr r3, =gUnknown_0850D9F8 - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8091B34 - - thumb_func_start sub_8091B54 -sub_8091B54: @ 8091B54 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - ldr r1, =gUnknown_0850DA04 - mov r0, sp - movs r2, 0x4 - bl memcpy - adds r2, r4, 0 - adds r2, 0x21 - ldrb r0, [r2] - cmp r0, 0x2 - bne _08091B80 - movs r0, 0xC - ldrsh r1, [r4, r0] - movs r3, 0x10 - ldrsh r0, [r4, r3] - cmp r1, r0 - bne _08091B80 - movs r0, 0x3 - strb r0, [r2] -_08091B80: - adds r0, r4, 0 - adds r1, r5, 0 - mov r2, sp - bl MoveFieldObjectInNextDirectionInSequence - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8091B54 - - thumb_func_start FieldObjectCB_GoInDirectionSequence20 -FieldObjectCB_GoInDirectionSequence20: @ 8091B9C - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =sub_8091BC0 - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_GoInDirectionSequence20 - - thumb_func_start sub_8091BC0 -sub_8091BC0: @ 8091BC0 - push {r4,lr} - ldr r3, =gUnknown_0850DA08 - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8091BC0 - - thumb_func_start sub_8091BE0 -sub_8091BE0: @ 8091BE0 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - ldr r1, =gUnknown_0850DA14 - mov r0, sp - movs r2, 0x4 - bl memcpy - adds r2, r4, 0 - adds r2, 0x21 - ldrb r0, [r2] - cmp r0, 0x2 - bne _08091C0C - movs r0, 0xC - ldrsh r1, [r4, r0] - movs r3, 0x10 - ldrsh r0, [r4, r3] - cmp r1, r0 - bne _08091C0C - movs r0, 0x3 - strb r0, [r2] -_08091C0C: - adds r0, r4, 0 - adds r1, r5, 0 - mov r2, sp - bl MoveFieldObjectInNextDirectionInSequence - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8091BE0 - - thumb_func_start FieldObjectCB_GoInDirectionSequence21 -FieldObjectCB_GoInDirectionSequence21: @ 8091C28 - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =sub_8091C4C - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_GoInDirectionSequence21 - - thumb_func_start sub_8091C4C -sub_8091C4C: @ 8091C4C - push {r4,lr} - ldr r3, =gUnknown_0850DA18 - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8091C4C - - thumb_func_start sub_8091C6C -sub_8091C6C: @ 8091C6C - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - ldr r1, =gUnknown_0850DA24 - mov r0, sp - movs r2, 0x4 - bl memcpy - adds r2, r4, 0 - adds r2, 0x21 - ldrb r0, [r2] - cmp r0, 0x2 - bne _08091C98 - movs r0, 0xE - ldrsh r1, [r4, r0] - movs r3, 0x12 - ldrsh r0, [r4, r3] - cmp r1, r0 - bne _08091C98 - movs r0, 0x3 - strb r0, [r2] -_08091C98: - adds r0, r4, 0 - adds r1, r5, 0 - mov r2, sp - bl MoveFieldObjectInNextDirectionInSequence - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8091C6C - - thumb_func_start FieldObjectCB_GoInDirectionSequence22 -FieldObjectCB_GoInDirectionSequence22: @ 8091CB4 - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =sub_8091CD8 - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_GoInDirectionSequence22 - - thumb_func_start sub_8091CD8 -sub_8091CD8: @ 8091CD8 - push {r4,lr} - ldr r3, =gUnknown_0850DA28 - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8091CD8 - - thumb_func_start sub_8091CF8 -sub_8091CF8: @ 8091CF8 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - ldr r1, =gUnknown_0850DA34 - mov r0, sp - movs r2, 0x4 - bl memcpy - adds r2, r4, 0 - adds r2, 0x21 - ldrb r0, [r2] - cmp r0, 0x2 - bne _08091D24 - movs r0, 0xE - ldrsh r1, [r4, r0] - movs r3, 0x12 - ldrsh r0, [r4, r3] - cmp r1, r0 - bne _08091D24 - movs r0, 0x3 - strb r0, [r2] -_08091D24: - adds r0, r4, 0 - adds r1, r5, 0 - mov r2, sp - bl MoveFieldObjectInNextDirectionInSequence - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8091CF8 - - thumb_func_start FieldObjectCB_GoInDirectionSequence23 -FieldObjectCB_GoInDirectionSequence23: @ 8091D40 - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =sub_8091D64 - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_GoInDirectionSequence23 - - thumb_func_start sub_8091D64 -sub_8091D64: @ 8091D64 - push {r4,lr} - ldr r3, =gUnknown_0850DA38 - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8091D64 - - thumb_func_start sub_8091D84 -sub_8091D84: @ 8091D84 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - ldr r1, =gUnknown_0850DA44 - mov r0, sp - movs r2, 0x4 - bl memcpy - adds r2, r4, 0 - adds r2, 0x21 - ldrb r0, [r2] - cmp r0, 0x2 - bne _08091DB0 - movs r0, 0xC - ldrsh r1, [r4, r0] - movs r3, 0x10 - ldrsh r0, [r4, r3] - cmp r1, r0 - bne _08091DB0 - movs r0, 0x3 - strb r0, [r2] -_08091DB0: - adds r0, r4, 0 - adds r1, r5, 0 - mov r2, sp - bl MoveFieldObjectInNextDirectionInSequence - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8091D84 - - thumb_func_start FieldObjectCB_GoInDirectionSequence24 -FieldObjectCB_GoInDirectionSequence24: @ 8091DCC - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =sub_8091DF0 - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_GoInDirectionSequence24 - - thumb_func_start sub_8091DF0 -sub_8091DF0: @ 8091DF0 - push {r4,lr} - ldr r3, =gUnknown_0850DA48 - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8091DF0 - - thumb_func_start sub_8091E10 -sub_8091E10: @ 8091E10 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - ldr r1, =gUnknown_0850DA54 - mov r0, sp - movs r2, 0x4 - bl memcpy - adds r2, r4, 0 - adds r2, 0x21 - ldrb r0, [r2] - cmp r0, 0x2 - bne _08091E3C - movs r0, 0xC - ldrsh r1, [r4, r0] - movs r3, 0x10 - ldrsh r0, [r4, r3] - cmp r1, r0 - bne _08091E3C - movs r0, 0x3 - strb r0, [r2] -_08091E3C: - adds r0, r4, 0 - adds r1, r5, 0 - mov r2, sp - bl MoveFieldObjectInNextDirectionInSequence - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8091E10 - thumb_func_start FieldObjectCB_CopyPlayer1 FieldObjectCB_CopyPlayer1: @ 8091E58 push {lr} diff --git a/include/data3.h b/include/data3.h index 3cbdcc9ce..a5ec3d08f 100755 --- a/include/data3.h +++ b/include/data3.h @@ -32,5 +32,6 @@ extern const u8 gUnknown_0850D880[4]; extern const u8 gUnknown_0850D898[4]; extern const u8 gUnknown_0850D8AC[5]; extern const u8 gUnknown_0850D8C4[5]; +extern const u8 gUnknown_0850D8E8[4]; #endif //POKEEMERALD_DATA3_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 0c6397730..99d417ae2 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -45,6 +45,20 @@ static bool8 FieldObjectCB2_##name(struct MapObject *mapObject, struct Sprite *s return (table)[sprite->data1](mapObject, sprite);\ } +#define field_object_path(idx, table, sub, path, catch, coord)\ +field_object_step(GoInDirectionSequence##idx, table)\ +extern const u8 path[4];\ +bool8 sub(struct MapObject *mapObject, struct Sprite *sprite)\ +{\ + u8 route[sizeof(path)];\ + memcpy(route, path, sizeof(path));\ + if (mapObject->mapobj_unk_21 == (catch) && mapObject->coords1.coord == mapObject->coords2.coord)\ + {\ + mapObject->mapobj_unk_21 = (catch) + 1;\ + }\ + return MoveFieldObjectInNextDirectionInSequence(mapObject, sprite, route);\ +}\ + // Static struct declarations // Static RAM declarations @@ -3108,3 +3122,28 @@ bool8 sub_8091110(struct MapObject *mapObject, struct Sprite *sprite) } return FALSE; } + +field_object_path( 1, gUnknown_0850D8DC, sub_809117C, gUnknown_0850D8E8, 2, x) +field_object_path( 2, gUnknown_0850D8EC, sub_8091208, gUnknown_0850D8F8, 1, x) +field_object_path( 3, gUnknown_0850D8FC, sub_8091294, gUnknown_0850D908, 1, y) +field_object_path( 4, gUnknown_0850D90C, sub_8091320, gUnknown_0850D918, 2, y) +field_object_path( 5, gUnknown_0850D91C, sub_80913AC, gUnknown_0850D928, 2, x) +field_object_path( 6, gUnknown_0850D92C, sub_8091438, gUnknown_0850D938, 1, x) +field_object_path( 7, gUnknown_0850D93C, sub_80914C4, gUnknown_0850D710, 1, y) +field_object_path( 8, gUnknown_0850D948, sub_8091550, gUnknown_0850D954, 2, y) +field_object_path( 9, gUnknown_0850D958, sub_80915DC, gUnknown_0850D964, 2, y) +field_object_path(10, gUnknown_0850D968, sub_8091668, gUnknown_0850D974, 1, y) +field_object_path(11, gUnknown_0850D978, sub_80916F4, gUnknown_0850D984, 1, x) +field_object_path(12, gUnknown_0850D988, sub_8091780, gUnknown_0850D994, 2, x) +field_object_path(13, gUnknown_0850D998, sub_809180C, gUnknown_0850D9A4, 2, y) +field_object_path(14, gUnknown_0850D9A8, sub_8091898, gUnknown_0850D9B4, 1, y) +field_object_path(15, gUnknown_0850D9B8, sub_8091924, gUnknown_0850D9C4, 1, x) +field_object_path(16, gUnknown_0850D9C8, sub_80919B0, gUnknown_0850D9D4, 2, x) +field_object_path(17, gUnknown_0850D9D8, sub_8091A3C, gUnknown_0850D9E4, 2, y) +field_object_path(18, gUnknown_0850D9E8, sub_8091AC8, gUnknown_0850D9F4, 2, y) +field_object_path(19, gUnknown_0850D9F8, sub_8091B54, gUnknown_0850DA04, 2, x) +field_object_path(20, gUnknown_0850DA08, sub_8091BE0, gUnknown_0850DA14, 2, x) +field_object_path(21, gUnknown_0850DA18, sub_8091C6C, gUnknown_0850DA24, 2, y) +field_object_path(22, gUnknown_0850DA28, sub_8091CF8, gUnknown_0850DA34, 2, y) +field_object_path(23, gUnknown_0850DA38, sub_8091D84, gUnknown_0850DA44, 2, x) +field_object_path(24, gUnknown_0850DA48, sub_8091E10, gUnknown_0850DA54, 2, x) From ee3dc1edda08ae6e2bab34b8555ec410f1a930a9 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 16 Sep 2017 09:43:49 -0400 Subject: [PATCH 109/191] Some more functions, including some swiss-cheesing that got out of hand --- asm/field_map_obj.s | 303 +--------------------------------- include/data3.h | 4 + include/field_player_avatar.h | 3 + ld_script.txt | 2 + src/field_map_obj.c | 123 +++++++++++++- 5 files changed, 132 insertions(+), 303 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index fbe6aa8d8..596107f53 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,175 +5,6 @@ .text - thumb_func_start FieldObjectCB_CopyPlayer1 -FieldObjectCB_CopyPlayer1: @ 8091E58 - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =sub_8091E7C - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_CopyPlayer1 - - thumb_func_start sub_8091E7C -sub_8091E7C: @ 8091E7C - push {r4,lr} - ldr r3, =gUnknown_0850DA58 - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8091E7C - - thumb_func_start mss_npc_reset_oampriv3_1_unk2_unk3 -@ bool8 mss_npc_reset_oampriv3_1_unk2_unk3(struct npc_state *fieldObject, struct obj *object) -mss_npc_reset_oampriv3_1_unk2_unk3: @ 8091E9C - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl npc_reset - adds r4, 0x21 - ldrb r0, [r4] - cmp r0, 0 - bne _08091EB4 - bl player_get_direction_lower_nybble - strb r0, [r4] -_08091EB4: - movs r0, 0x1 - strh r0, [r5, 0x30] - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end mss_npc_reset_oampriv3_1_unk2_unk3 - - thumb_func_start sub_8091EC0 -@ bool8 sub_8091EC0(struct npc_state *fieldObject, struct obj *object) -sub_8091EC0: @ 8091EC0 - push {r4-r7,lr} - adds r6, r0, 0 - adds r7, r1, 0 - ldr r2, =gMapObjects - ldr r3, =gPlayerAvatar - ldrb r1, [r3, 0x5] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r0, [r0, 0x1C] - cmp r0, 0xFF - beq _08091EE0 - ldrb r0, [r3, 0x3] - cmp r0, 0x2 - bne _08091EEC -_08091EE0: - movs r0, 0 - b _08091F14 - .pool -_08091EEC: - ldr r5, =gUnknown_0850DA64 - bl player_get_x22 - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 22 - adds r4, r5 - bl player_get_direction_upper_nybble - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - ldr r4, [r4] - adds r0, r6, 0 - adds r1, r7, 0 - movs r3, 0 - bl _call_via_r4 - lsls r0, 24 - lsrs r0, 24 -_08091F14: - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8091EC0 - - thumb_func_start sub_8091F20 -sub_8091F20: @ 8091F20 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl FieldObjectExecRegularAnim - lsls r0, 24 - cmp r0, 0 - beq _08091F3E - ldrb r0, [r4] - movs r1, 0x3 - negs r1, r1 - ands r1, r0 - strb r1, [r4] - movs r0, 0x1 - strh r0, [r5, 0x30] -_08091F3E: - movs r0, 0 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8091F20 - - thumb_func_start sub_8091F48 -sub_8091F48: @ 8091F48 - movs r0, 0 - bx lr - thumb_func_end sub_8091F48 - - thumb_func_start sub_8091F4C -sub_8091F4C: @ 8091F4C - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - lsls r2, 24 - lsrs r2, 24 - ldr r1, =gUnknown_085055CD - ldrb r0, [r4, 0x6] - adds r0, r1 - ldrb r0, [r0] - adds r1, r4, 0 - adds r1, 0x21 - ldrb r1, [r1] - bl state_to_direction - bl GetFaceDirectionAnimId - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r1, r5, 0 - bl FieldObjectSetRegularAnim - ldrb r0, [r4] - movs r1, 0x2 - orrs r0, r1 - strb r0, [r4] - movs r0, 0x2 - strh r0, [r5, 0x30] - movs r0, 0x1 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8091F4C - thumb_func_start sub_8091F94 sub_8091F94: @ 8091F94 push {r4-r7,lr} @@ -2742,139 +2573,7 @@ FieldObjectClearAnim: @ 809323C .pool thumb_func_end FieldObjectClearAnim - thumb_func_start FieldObjectCheckIfSpecialAnimFinishedOrInactive -@ u8 FieldObjectCheckIfSpecialAnimFinishedOrInactive(struct npc_state *fieldObject) -FieldObjectCheckIfSpecialAnimFinishedOrInactive: @ 8093270 - push {lr} - ldrb r1, [r0] - lsls r0, r1, 25 - cmp r0, 0 - blt _0809327E - movs r0, 0x10 - b _08093280 -_0809327E: - lsrs r0, r1, 7 -_08093280: - pop {r1} - bx r1 - thumb_func_end FieldObjectCheckIfSpecialAnimFinishedOrInactive - - thumb_func_start FieldObjectClearAnimIfSpecialAnimFinished -@ u8 FieldObjectClearAnimIfSpecialAnimFinished(struct npc_state *fieldObject) -FieldObjectClearAnimIfSpecialAnimFinished: @ 8093284 - push {r4,r5,lr} - adds r5, r0, 0 - bl FieldObjectCheckIfSpecialAnimFinishedOrInactive - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0 - beq _0809329E - cmp r4, 0x10 - beq _0809329E - adds r0, r5, 0 - bl FieldObjectClearAnimIfSpecialAnimActive -_0809329E: - adds r0, r4, 0 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end FieldObjectClearAnimIfSpecialAnimFinished - - thumb_func_start FieldObjectGetSpecialAnim -@ u8 FieldObjectGetSpecialAnim(struct npc_state *fieldObject) -FieldObjectGetSpecialAnim: @ 80932A8 - push {lr} - adds r1, r0, 0 - ldrb r0, [r1] - lsls r0, 25 - cmp r0, 0 - blt _080932B8 - movs r0, 0xFF - b _080932BA -_080932B8: - ldrb r0, [r1, 0x1C] -_080932BA: - pop {r1} - bx r1 - thumb_func_end FieldObjectGetSpecialAnim - - thumb_func_start FieldObjectStep -@ void FieldObjectStep(struct npc_state *fieldObject, struct obj *object, bool8 ( *callback)(struct npc_state *fieldObject, struct obj *object)) -FieldObjectStep: @ 80932C0 - push {r4-r6,lr} - adds r4, r0, 0 - adds r5, r1, 0 - adds r6, r2, 0 - bl DoGroundEffects_OnSpawn - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_80964E8 - adds r0, r4, 0 - bl FieldObjectIsSpecialAnimActive - lsls r0, 24 - cmp r0, 0 - beq _080932EA - adds r0, r4, 0 - adds r1, r5, 0 - bl FieldObjectExecSpecialAnim - b _08093300 -_080932EA: - ldrb r0, [r4, 0x1] - lsls r0, 31 - cmp r0, 0 - bne _08093300 -_080932F2: - adds r0, r4, 0 - adds r1, r5, 0 - bl _call_via_r6 - lsls r0, 24 - cmp r0, 0 - bne _080932F2 -_08093300: - adds r0, r4, 0 - adds r1, r5, 0 - bl DoGroundEffects_OnBeginStep - adds r0, r4, 0 - adds r1, r5, 0 - bl DoGroundEffects_OnFinishStep - adds r0, r4, 0 - adds r1, r5, 0 - bl npc_obj_transfer_image_anim_pause_flag - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8096518 - adds r0, r4, 0 - adds r1, r5, 0 - bl FieldObjectUpdateSubpriority - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end FieldObjectStep - - thumb_func_start GetFaceDirectionAnimId -@ u8 GetFaceDirectionAnimId(u8 direction) -GetFaceDirectionAnimId: @ 8093330 - push {r4,lr} - sub sp, 0x8 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, =gUnknown_0850DBA0 - mov r0, sp - movs r2, 0x5 - bl memcpy - cmp r4, 0x4 - bls _08093348 - movs r4, 0 -_08093348: - mov r1, sp - adds r0, r1, r4 - ldrb r0, [r0] - add sp, 0x8 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end GetFaceDirectionAnimId + .section .text.get_simple_go_anim_id thumb_func_start GetSimpleGoAnimId @ u8 GetSimpleGoAnimId(u8 direction) diff --git a/include/data3.h b/include/data3.h index a5ec3d08f..f5efab3b7 100755 --- a/include/data3.h +++ b/include/data3.h @@ -33,5 +33,9 @@ extern const u8 gUnknown_0850D898[4]; extern const u8 gUnknown_0850D8AC[5]; extern const u8 gUnknown_0850D8C4[5]; extern const u8 gUnknown_0850D8E8[4]; +extern bool8 (*const gUnknown_0850DA64[])(struct MapObject *, struct Sprite *, u8, u8); + + +extern const u8 gUnknown_0850DBA0[5]; #endif //POKEEMERALD_DATA3_H diff --git a/include/field_player_avatar.h b/include/field_player_avatar.h index 3a74b3b10..cd00832d5 100644 --- a/include/field_player_avatar.h +++ b/include/field_player_avatar.h @@ -10,5 +10,8 @@ void SetPlayerAvatarExtraStateTransition(u8, u8); u8 GetPlayerAvatarGenderByGraphicsId(u8); bool8 TestPlayerAvatarFlags(u8); void PlayerGetDestCoords(s16 *, s16 *); +u8 player_get_direction_lower_nybble(void); +u8 player_get_direction_upper_nybble(void); +u8 player_get_x22(void); #endif //POKEEMERALD_FIELD_PLAYER_AVATAR_H diff --git a/ld_script.txt b/ld_script.txt index 702c51ec2..1e2e72f67 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -95,6 +95,8 @@ SECTIONS { asm/field_player_avatar.o(.text); src/field_map_obj.o(.text); asm/field_map_obj.o(.text); + src/field_map_obj.o(.text.get_face_direction_anim_id); + asm/field_map_obj.o(.text.get_simple_go_anim_id); asm/field_ground_effect.o(.text); asm/map_obj_8097404.o(.text); asm/field_message_box.o(.text); diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 99d417ae2..77c2a8068 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -94,12 +94,21 @@ static bool8 FieldObjectDoesZCoordMatch(struct MapObject *, u8); /*static*/ struct MapObjectTemplate *FindFieldObjectTemplateInArrayByLocalId(u8 localId, struct MapObjectTemplate *templates, u8 count); void npc_reset(struct MapObject *, struct Sprite *); void FieldObjectSetRegularAnim(struct MapObject *, struct Sprite *, u8); -u8 GetFaceDirectionAnimId(u8); +u8 GetFaceDirectionAnimId(u32); bool8 FieldObjectExecRegularAnim(struct MapObject *, struct Sprite *); void SetFieldObjectStepTimer(struct Sprite *, s16); bool8 RunFieldObjectStepTimer(struct Sprite *); bool8 npc_block_way__next_tile(struct MapObject *, u8); u8 GetGoSpeed0AnimId(u8); +u32 state_to_direction(u8, u8, u8); +void DoGroundEffects_OnSpawn(struct MapObject *, struct Sprite *); +void sub_80964E8(struct MapObject *, struct Sprite *); +bool8 FieldObjectIsSpecialAnimActive(struct MapObject *); +void FieldObjectExecSpecialAnim(struct MapObject *, struct Sprite *); +void DoGroundEffects_OnBeginStep(struct MapObject *, struct Sprite *); +void DoGroundEffects_OnFinishStep(struct MapObject *, struct Sprite *); +void npc_obj_transfer_image_anim_pause_flag(struct MapObject *, struct Sprite *); +void FieldObjectUpdateSubpriority(struct MapObject *, struct Sprite *); // ROM data @@ -3147,3 +3156,115 @@ field_object_path(21, gUnknown_0850DA18, sub_8091C6C, gUnknown_0850DA24, 2, y) field_object_path(22, gUnknown_0850DA28, sub_8091CF8, gUnknown_0850DA34, 2, y) field_object_path(23, gUnknown_0850DA38, sub_8091D84, gUnknown_0850DA44, 2, x) field_object_path(24, gUnknown_0850DA48, sub_8091E10, gUnknown_0850DA54, 2, x) + +field_object_step(CopyPlayer1, gUnknown_0850DA58) + +bool8 mss_npc_reset_oampriv3_1_unk2_unk3(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + if (mapObject->mapobj_unk_21 == 0) + { + mapObject->mapobj_unk_21 = player_get_direction_lower_nybble(); + } + sprite->data1 = 1; + return TRUE; +} + +bool8 sub_8091EC0(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (gMapObjects[gPlayerAvatar.mapObjectId].mapobj_unk_1C == 0xFF || gPlayerAvatar.running1 == 2) + { + return FALSE; + } + return gUnknown_0850DA64[player_get_x22()](mapObject, sprite, player_get_direction_upper_nybble(), 0); +} + +bool8 sub_8091F20(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite)) + { + mapObject->mapobj_bit_1 = FALSE; + sprite->data1 = 1; + } + return FALSE; +} + +bool8 sub_8091F48(struct MapObject *mapObject, struct Sprite *sprite, u8 playerDirection, u8 a3) +{ + return FALSE; +} + +bool8 sub_8091F4C(struct MapObject *mapObject, struct Sprite *sprite, u8 playerDirection, u8 a3) +{ + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(state_to_direction(gUnknown_085055CD[mapObject->animPattern], mapObject->mapobj_unk_21, playerDirection))); + mapObject->mapobj_bit_1 = TRUE; + sprite->data1 = 2; + return TRUE; +} + +asm(".section .text.get_face_direction_anim_id"); + +void FieldObjectClearAnimIfSpecialAnimActive(struct MapObject *); + +u8 FieldObjectCheckIfSpecialAnimFinishedOrInactive(struct MapObject *mapObject) +{ + if (mapObject->mapobj_bit_6) + { + return mapObject->mapobj_bit_7; + } + return 0x10; +} + +u8 FieldObjectClearAnimIfSpecialAnimFinished(struct MapObject *mapObject) +{ + u8 specialAnimState; + + specialAnimState = FieldObjectCheckIfSpecialAnimFinishedOrInactive(mapObject); + if (specialAnimState != 0 && specialAnimState != 16) + { + FieldObjectClearAnimIfSpecialAnimActive(mapObject); + } + return specialAnimState; +} + +u8 FieldObjectGetSpecialAnim(struct MapObject *mapObject) +{ + if (mapObject->mapobj_bit_6) + { + return mapObject->mapobj_unk_1C; + } + return 0xFF; +} + +void FieldObjectStep(struct MapObject *mapObject, struct Sprite *sprite, bool8 (*callback)(struct MapObject *, struct Sprite *)) +{ + DoGroundEffects_OnSpawn(mapObject, sprite); + sub_80964E8(mapObject, sprite); + if (FieldObjectIsSpecialAnimActive(mapObject)) + { + FieldObjectExecSpecialAnim(mapObject, sprite); + } + else if (!mapObject->mapobj_bit_8) + { + while (callback(mapObject, sprite)); + } + DoGroundEffects_OnBeginStep(mapObject, sprite); + DoGroundEffects_OnFinishStep(mapObject, sprite); + npc_obj_transfer_image_anim_pause_flag(mapObject, sprite); + sub_8096518(mapObject, sprite); + FieldObjectUpdateSubpriority(mapObject, sprite); +} + +u8 GetFaceDirectionAnimId(u32 direction) +{ + u8 dirn2; + u8 animIds[sizeof gUnknown_0850DBA0]; + + dirn2 = direction; + memcpy(animIds, gUnknown_0850DBA0, sizeof gUnknown_0850DBA0); + if (dirn2 > DIR_EAST) + { + dirn2 = 0; + } + return animIds[dirn2]; +} From 66fbc9753fa8411d715fdad1067eb98c68ace27a Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 16 Sep 2017 13:54:33 -0400 Subject: [PATCH 110/191] sub_8091F94 --- asm/field_map_obj.s | 126 ---------------------------------------- include/data3.h | 2 +- include/field_map_obj.h | 1 + include/fieldmap.h | 15 +++++ include/rom4.h | 1 + include/rom_81BE66C.h | 2 + src/field_map_obj.c | 47 +++++++++++++-- 7 files changed, 62 insertions(+), 132 deletions(-) create mode 100644 include/fieldmap.h diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 596107f53..9910d3f42 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,132 +5,6 @@ .text - thumb_func_start sub_8091F94 -sub_8091F94: @ 8091F94 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x4 - adds r4, r0, 0 - adds r7, r1, 0 - mov r8, r3 - lsls r2, 24 - lsrs r5, r2, 24 - adds r6, r5, 0 - bl FieldObjectIsFarawayIslandMew - lsls r0, 24 - cmp r0, 0 - beq _08091FFC - bl sub_81D427C - adds r5, r0, 0 - cmp r5, 0 - bne _08092012 - adds r5, r6, 0 - ldr r1, =gUnknown_085055CD - ldrb r0, [r4, 0x6] - adds r0, r1 - ldrb r0, [r0] - adds r1, r4, 0 - adds r1, 0x21 - ldrb r1, [r1] - adds r2, r5, 0 - bl state_to_direction - adds r5, r0, 0 - mov r3, sp - adds r3, 0x2 - adds r0, r4, 0 - adds r1, r5, 0 - mov r2, sp - bl FieldObjectMoveDestCoords - adds r0, r5, 0 - bl GetFaceDirectionAnimId - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r1, r7, 0 - bl FieldObjectSetRegularAnim - b _08092084 - .pool -_08091FFC: - ldr r1, =gUnknown_085055CD - ldrb r0, [r4, 0x6] - adds r0, r1 - ldrb r0, [r0] - adds r1, r4, 0 - adds r1, 0x21 - ldrb r1, [r1] - adds r2, r5, 0 - bl state_to_direction - adds r5, r0, 0 -_08092012: - mov r6, sp - adds r6, 0x2 - adds r0, r4, 0 - adds r1, r5, 0 - mov r2, sp - adds r3, r6, 0 - bl FieldObjectMoveDestCoords - adds r0, r5, 0 - bl GetGoSpeed0AnimId - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r1, r7, 0 - bl FieldObjectSetRegularAnim - mov r0, sp - movs r2, 0 - ldrsh r1, [r0, r2] - movs r0, 0 - ldrsh r2, [r6, r0] - adds r0, r4, 0 - adds r3, r5, 0 - bl npc_block_way - lsls r0, 24 - cmp r0, 0 - bne _08092070 - mov r1, r8 - cmp r1, 0 - beq _08092084 - mov r0, sp - movs r2, 0 - ldrsh r0, [r0, r2] - movs r2, 0 - ldrsh r1, [r6, r2] - bl MapGridGetMetatileBehaviorAt - lsls r0, 24 - lsrs r0, 24 - bl _call_via_r8 - lsls r0, 24 - cmp r0, 0 - bne _08092084 -_08092070: - adds r0, r5, 0 - bl GetFaceDirectionAnimId - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r1, r7, 0 - bl FieldObjectSetRegularAnim -_08092084: - ldrb r0, [r4] - movs r1, 0x2 - orrs r0, r1 - strb r0, [r4] - movs r0, 0x2 - strh r0, [r7, 0x30] - movs r0, 0x1 - add sp, 0x4 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8091F94 - thumb_func_start sub_80920A4 sub_80920A4: @ 80920A4 push {r4-r7,lr} diff --git a/include/data3.h b/include/data3.h index f5efab3b7..2b5cc1bc5 100755 --- a/include/data3.h +++ b/include/data3.h @@ -33,7 +33,7 @@ extern const u8 gUnknown_0850D898[4]; extern const u8 gUnknown_0850D8AC[5]; extern const u8 gUnknown_0850D8C4[5]; extern const u8 gUnknown_0850D8E8[4]; -extern bool8 (*const gUnknown_0850DA64[])(struct MapObject *, struct Sprite *, u8, u8); +extern bool8 (*const gUnknown_0850DA64[])(struct MapObject *, struct Sprite *, u8, bool8(u8)); extern const u8 gUnknown_0850DBA0[5]; diff --git a/include/field_map_obj.h b/include/field_map_obj.h index db1ed233f..536d9d1a4 100755 --- a/include/field_map_obj.h +++ b/include/field_map_obj.h @@ -64,6 +64,7 @@ void sub_808F254(u8, u8, u8); void FieldObjectStep(struct MapObject *, struct Sprite *, bool8(struct MapObject *, struct Sprite *)); u8 GetOppositeDirection(u8); u8 GetStepInPlaceDelay16AnimId(u8); +u8 npc_block_way(struct MapObject *, s16, s16, u32); // Exported data declarations diff --git a/include/fieldmap.h b/include/fieldmap.h new file mode 100644 index 000000000..7057fe889 --- /dev/null +++ b/include/fieldmap.h @@ -0,0 +1,15 @@ +// +// Created by scott on 9/16/2017. +// + +#ifndef POKEEMERALD_FIELDMAP_H +#define POKEEMERALD_FIELDMAP_H + +// Exported type declarations + +// Exported RAM declarations + +// Exported ROM declarations +u8 MapGridGetMetatileBehaviorAt(s16, s16); + +#endif //POKEEMERALD_FIELDMAP_H diff --git a/include/rom4.h b/include/rom4.h index 0c7b87353..78dca24c4 100644 --- a/include/rom4.h +++ b/include/rom4.h @@ -26,5 +26,6 @@ extern struct LinkPlayerMapObject gLinkPlayerMapObjects[4]; void strange_npc_table_clear(void); const struct MapHeader *get_mapheader_by_bank_and_number(u8, u8); +void FieldObjectMoveDestCoords(struct MapObject *, u32, s16 *, s16 *); #endif //POKEEMERALD_ROM4_H diff --git a/include/rom_81BE66C.h b/include/rom_81BE66C.h index d92c500d6..e4e39fb08 100644 --- a/include/rom_81BE66C.h +++ b/include/rom_81BE66C.h @@ -6,5 +6,7 @@ #define POKEEMERALD_ROM_81BE66C_H bool32 InTrainerHill(void); +bool8 FieldObjectIsFarawayIslandMew(struct MapObject *); +u32 sub_81D427C(void); #endif //POKEEMERALD_ROM_81BE66C_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 77c2a8068..cdf4006de 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -10,6 +10,7 @@ #include "berry.h" #include "palette.h" #include "field_player_avatar.h" +#include "fieldmap.h" #include "event_data.h" #include "rom_818CFC8.h" #include "rom_81BE66C.h" @@ -95,12 +96,12 @@ static bool8 FieldObjectDoesZCoordMatch(struct MapObject *, u8); void npc_reset(struct MapObject *, struct Sprite *); void FieldObjectSetRegularAnim(struct MapObject *, struct Sprite *, u8); u8 GetFaceDirectionAnimId(u32); +u8 GetGoSpeed0AnimId(u32); bool8 FieldObjectExecRegularAnim(struct MapObject *, struct Sprite *); void SetFieldObjectStepTimer(struct Sprite *, s16); bool8 RunFieldObjectStepTimer(struct Sprite *); bool8 npc_block_way__next_tile(struct MapObject *, u8); -u8 GetGoSpeed0AnimId(u8); -u32 state_to_direction(u8, u8, u8); +u32 state_to_direction(u8, u8, u32); void DoGroundEffects_OnSpawn(struct MapObject *, struct Sprite *); void sub_80964E8(struct MapObject *, struct Sprite *); bool8 FieldObjectIsSpecialAnimActive(struct MapObject *); @@ -3176,7 +3177,7 @@ bool8 sub_8091EC0(struct MapObject *mapObject, struct Sprite *sprite) { return FALSE; } - return gUnknown_0850DA64[player_get_x22()](mapObject, sprite, player_get_direction_upper_nybble(), 0); + return gUnknown_0850DA64[player_get_x22()](mapObject, sprite, player_get_direction_upper_nybble(), NULL); } bool8 sub_8091F20(struct MapObject *mapObject, struct Sprite *sprite) @@ -3189,12 +3190,12 @@ bool8 sub_8091F20(struct MapObject *mapObject, struct Sprite *sprite) return FALSE; } -bool8 sub_8091F48(struct MapObject *mapObject, struct Sprite *sprite, u8 playerDirection, u8 a3) +bool8 sub_8091F48(struct MapObject *mapObject, struct Sprite *sprite, u8 playerDirection, bool8 tileCB(u8)) { return FALSE; } -bool8 sub_8091F4C(struct MapObject *mapObject, struct Sprite *sprite, u8 playerDirection, u8 a3) +bool8 sub_8091F4C(struct MapObject *mapObject, struct Sprite *sprite, u8 playerDirection, bool8 tileCB(u8)) { FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(state_to_direction(gUnknown_085055CD[mapObject->animPattern], mapObject->mapobj_unk_21, playerDirection))); mapObject->mapobj_bit_1 = TRUE; @@ -3202,6 +3203,42 @@ bool8 sub_8091F4C(struct MapObject *mapObject, struct Sprite *sprite, u8 playerD return TRUE; } +bool8 sub_8091F94(struct MapObject *mapObject, struct Sprite *sprite, u8 playerDirection, bool8 tileCB(u8)) +{ + u32 direction; + s16 x; + s16 y; + + direction = playerDirection; + if (FieldObjectIsFarawayIslandMew(mapObject)) + { + direction = sub_81D427C(); + if (direction == 0) + { + direction = playerDirection; + direction = state_to_direction(gUnknown_085055CD[mapObject->animPattern], mapObject->mapobj_unk_21, direction); + FieldObjectMoveDestCoords(mapObject, direction, &x, &y); + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(direction)); + mapObject->mapobj_bit_1 = TRUE; + sprite->data1 = 2; + return TRUE; + } + } + else + { + direction = state_to_direction(gUnknown_085055CD[mapObject->animPattern], mapObject->mapobj_unk_21, direction); + } + FieldObjectMoveDestCoords(mapObject, direction, &x, &y); + FieldObjectSetRegularAnim(mapObject, sprite, GetGoSpeed0AnimId(direction)); + if (npc_block_way(mapObject, x, y, direction) || (tileCB != NULL && !tileCB(MapGridGetMetatileBehaviorAt(x, y)))) + { + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(direction)); + } + mapObject->mapobj_bit_1 = TRUE; + sprite->data1 = 2; + return TRUE; +} + asm(".section .text.get_face_direction_anim_id"); void FieldObjectClearAnimIfSpecialAnimActive(struct MapObject *); From 18e06b480b13143b8870675a763fb2f9854f9679 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 16 Sep 2017 15:13:06 -0400 Subject: [PATCH 111/191] Fix header guards --- include/data3.h | 6 +++--- include/event_scripts.h | 6 +++--- include/field_effect.h | 6 +++--- include/field_effect_helpers.h | 6 +++--- include/field_ground_effect.h | 6 +++--- include/field_map_obj.h | 6 +++--- include/field_player_avatar.h | 6 +++--- include/fieldmap.h | 6 +++--- include/map_obj_8097404.h | 6 +++--- include/rom4.h | 6 +++--- include/rom_818CFC8.h | 6 +++--- include/rom_81BE66C.h | 6 +++--- 12 files changed, 36 insertions(+), 36 deletions(-) diff --git a/include/data3.h b/include/data3.h index 2b5cc1bc5..b2b19b050 100755 --- a/include/data3.h +++ b/include/data3.h @@ -2,8 +2,8 @@ // Created by Scott Norton on 9/8/17. // -#ifndef POKEEMERALD_DATA3_H -#define POKEEMERALD_DATA3_H +#ifndef GUARD_DATA3_H +#define GUARD_DATA3_H struct PairedPalettes { u16 tag; @@ -38,4 +38,4 @@ extern bool8 (*const gUnknown_0850DA64[])(struct MapObject *, struct Sprite *, u extern const u8 gUnknown_0850DBA0[5]; -#endif //POKEEMERALD_DATA3_H +#endif //GUARD_DATA3_H diff --git a/include/event_scripts.h b/include/event_scripts.h index 967bc196a..f1abdd6f6 100755 --- a/include/event_scripts.h +++ b/include/event_scripts.h @@ -2,10 +2,10 @@ // Created by scott on 9/12/2017. // -#ifndef POKEEMERALD_EVENT_SCRIPTS_H -#define POKEEMERALD_EVENT_SCRIPTS_H +#ifndef GUARD_EVENT_SCRIPTS_H +#define GUARD_EVENT_SCRIPTS_H extern const u8 gUnknown_082766A2[]; extern const u8 gUnknown_082766A6[]; -#endif //POKEEMERALD_EVENT_SCRIPTS_H +#endif //GUARD_EVENT_SCRIPTS_H diff --git a/include/field_effect.h b/include/field_effect.h index 8cf866725..7ec26b3d7 100644 --- a/include/field_effect.h +++ b/include/field_effect.h @@ -2,8 +2,8 @@ // Created by Scott Norton on 9/15/17. // -#ifndef POKEEMERALD_FIELD_EFFECTS_H -#define POKEEMERALD_FIELD_EFFECTS_H +#ifndef GUARD_FIELD_EFFECTS_H +#define GUARD_FIELD_EFFECTS_H enum FieldEffectScriptIdx { @@ -77,4 +77,4 @@ extern u32 gFieldEffectSpawnParams[8]; u8 FieldEffectStart(u8); -#endif //POKEEMERALD_FIELD_EFFECTS_H +#endif //GUARD_FIELD_EFFECTS_H diff --git a/include/field_effect_helpers.h b/include/field_effect_helpers.h index 673d59139..6504a84f1 100644 --- a/include/field_effect_helpers.h +++ b/include/field_effect_helpers.h @@ -2,8 +2,8 @@ // Created by scott on 9/7/2017. // -#ifndef POKEEMERALD_FIELD_EFFECT_HELPERS_H -#define POKEEMERALD_FIELD_EFFECT_HELPERS_H +#ifndef GUARD_FIELD_EFFECT_HELPERS_H +#define GUARD_FIELD_EFFECT_HELPERS_H // Exported type declarations @@ -12,4 +12,4 @@ // Exported ROM declarations u8 sub_8154228(void); -#endif //POKEEMERALD_FIELD_EFFECT_HELPERS_H +#endif //GUARD_FIELD_EFFECT_HELPERS_H diff --git a/include/field_ground_effect.h b/include/field_ground_effect.h index 0c90f50dc..e2dc3a00f 100644 --- a/include/field_ground_effect.h +++ b/include/field_ground_effect.h @@ -2,8 +2,8 @@ // Created by scott on 9/6/2017. // -#ifndef POKEEMERALD_FIELD_GROUND_EFFECT_H -#define POKEEMERALD_FIELD_GROUND_EFFECT_H +#ifndef GUARD_FIELD_GROUND_EFFECT_H +#define GUARD_FIELD_GROUND_EFFECT_H // Exported type declarations @@ -13,4 +13,4 @@ void SetObjectSubpriorityByZCoord(u8, struct Sprite *, u8); void InitObjectPriorityByZCoord(struct Sprite *, u8); -#endif //POKEEMERALD_FIELD_GROUND_EFFECT_H +#endif //GUARD_FIELD_GROUND_EFFECT_H diff --git a/include/field_map_obj.h b/include/field_map_obj.h index 536d9d1a4..f603e9a8e 100755 --- a/include/field_map_obj.h +++ b/include/field_map_obj.h @@ -1,5 +1,5 @@ -#ifndef POKEEMERALD_FIELD_MAP_OBJ_H -#define POKEEMERALD_FIELD_MAP_OBJ_H +#ifndef GUARD_FIELD_MAP_OBJ_H +#define GUARD_FIELD_MAP_OBJ_H #define NUM_OBJECT_GRAPHICS_INFO 239 #define SPRITE_VAR 240 @@ -70,4 +70,4 @@ u8 npc_block_way(struct MapObject *, s16, s16, u32); extern const struct SpriteTemplate *const gFieldEffectObjectTemplatePointers[]; -#endif //POKEEMERALD_FIELD_MAP_OBJ_H +#endif //GUARD_FIELD_MAP_OBJ_H diff --git a/include/field_player_avatar.h b/include/field_player_avatar.h index cd00832d5..a787cf805 100644 --- a/include/field_player_avatar.h +++ b/include/field_player_avatar.h @@ -2,8 +2,8 @@ // Created by Scott Norton on 9/6/17. // -#ifndef POKEEMERALD_FIELD_PLAYER_AVATAR_H -#define POKEEMERALD_FIELD_PLAYER_AVATAR_H +#ifndef GUARD_FIELD_PLAYER_AVATAR_H +#define GUARD_FIELD_PLAYER_AVATAR_H void ClearPlayerAvatarInfo(void); void SetPlayerAvatarExtraStateTransition(u8, u8); @@ -14,4 +14,4 @@ u8 player_get_direction_lower_nybble(void); u8 player_get_direction_upper_nybble(void); u8 player_get_x22(void); -#endif //POKEEMERALD_FIELD_PLAYER_AVATAR_H +#endif //GUARD_FIELD_PLAYER_AVATAR_H diff --git a/include/fieldmap.h b/include/fieldmap.h index 7057fe889..4c75c3f40 100644 --- a/include/fieldmap.h +++ b/include/fieldmap.h @@ -2,8 +2,8 @@ // Created by scott on 9/16/2017. // -#ifndef POKEEMERALD_FIELDMAP_H -#define POKEEMERALD_FIELDMAP_H +#ifndef GUARD_FIELDMAP_H +#define GUARD_FIELDMAP_H // Exported type declarations @@ -12,4 +12,4 @@ // Exported ROM declarations u8 MapGridGetMetatileBehaviorAt(s16, s16); -#endif //POKEEMERALD_FIELDMAP_H +#endif //GUARD_FIELDMAP_H diff --git a/include/map_obj_8097404.h b/include/map_obj_8097404.h index 6296febe4..e3b2b1efc 100644 --- a/include/map_obj_8097404.h +++ b/include/map_obj_8097404.h @@ -2,8 +2,8 @@ // Created by scott on 9/7/2017. // -#ifndef POKEEMERALD_MAP_OBJ_8097404_H -#define POKEEMERALD_MAP_OBJ_8097404_H +#ifndef GUARD_MAP_OBJ_8097404_H +#define GUARD_MAP_OBJ_8097404_H // Exported type declarations @@ -12,4 +12,4 @@ // Exported ROM declarations void sub_8097AC8(struct Sprite *); -#endif //POKEEMERALD_MAP_OBJ_8097404_H +#endif //GUARD_MAP_OBJ_8097404_H diff --git a/include/rom4.h b/include/rom4.h index 78dca24c4..d4ece109e 100644 --- a/include/rom4.h +++ b/include/rom4.h @@ -1,6 +1,6 @@ -#ifndef POKEEMERALD_ROM4_H -#define POKEEMERALD_ROM4_H +#ifndef GUARD_ROM4_H +#define GUARD_ROM4_H struct UnkPlayerStruct { @@ -28,4 +28,4 @@ void strange_npc_table_clear(void); const struct MapHeader *get_mapheader_by_bank_and_number(u8, u8); void FieldObjectMoveDestCoords(struct MapObject *, u32, s16 *, s16 *); -#endif //POKEEMERALD_ROM4_H +#endif //GUARD_ROM4_H diff --git a/include/rom_818CFC8.h b/include/rom_818CFC8.h index 9b6f96893..1d0626b2b 100644 --- a/include/rom_818CFC8.h +++ b/include/rom_818CFC8.h @@ -2,10 +2,10 @@ // Created by Scott Norton on 9/6/17. // -#ifndef POKEEMERALD_ROM_818CFC8_H -#define POKEEMERALD_ROM_818CFC8_H +#ifndef GUARD_ROM_818CFC8_H +#define GUARD_ROM_818CFC8_H bool8 InBattlePyramid(void); u8 sub_81AAA40(void); -#endif //POKEEMERALD_ROM_818CFC8_H +#endif //GUARD_ROM_818CFC8_H diff --git a/include/rom_81BE66C.h b/include/rom_81BE66C.h index e4e39fb08..5b4f80249 100644 --- a/include/rom_81BE66C.h +++ b/include/rom_81BE66C.h @@ -2,11 +2,11 @@ // Created by Scott Norton on 9/6/17. // -#ifndef POKEEMERALD_ROM_81BE66C_H -#define POKEEMERALD_ROM_81BE66C_H +#ifndef GUARD_ROM_81BE66C_H +#define GUARD_ROM_81BE66C_H bool32 InTrainerHill(void); bool8 FieldObjectIsFarawayIslandMew(struct MapObject *); u32 sub_81D427C(void); -#endif //POKEEMERALD_ROM_81BE66C_H +#endif //GUARD_ROM_81BE66C_H From c7f28f034c4a86b6373b45941f47e5a231392ad0 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 16 Sep 2017 15:16:39 -0400 Subject: [PATCH 112/191] Change type of state_to_direction argument 1 to match pokeruby --- src/field_map_obj.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/field_map_obj.c b/src/field_map_obj.c index cdf4006de..cd330a18d 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -101,7 +101,7 @@ bool8 FieldObjectExecRegularAnim(struct MapObject *, struct Sprite *); void SetFieldObjectStepTimer(struct Sprite *, s16); bool8 RunFieldObjectStepTimer(struct Sprite *); bool8 npc_block_way__next_tile(struct MapObject *, u8); -u32 state_to_direction(u8, u8, u32); +u32 state_to_direction(u8, u32, u32); void DoGroundEffects_OnSpawn(struct MapObject *, struct Sprite *); void sub_80964E8(struct MapObject *, struct Sprite *); bool8 FieldObjectIsSpecialAnimActive(struct MapObject *); From c6bb13939e39bfae41ebaa8f1ea63295ddb050e1 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 16 Sep 2017 16:10:55 -0400 Subject: [PATCH 113/191] state_to_direction memes --- asm/field_map_obj.s | 482 -------------------------------------------- src/field_map_obj.c | 145 +++++++++++-- 2 files changed, 133 insertions(+), 494 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 9910d3f42..333621879 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,488 +5,6 @@ .text - thumb_func_start sub_80920A4 -sub_80920A4: @ 80920A4 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x4 - adds r4, r0, 0 - adds r7, r1, 0 - mov r8, r3 - lsls r2, 24 - lsrs r6, r2, 24 - ldr r1, =gUnknown_085055CD - ldrb r0, [r4, 0x6] - adds r0, r1 - ldrb r0, [r0] - adds r1, r4, 0 - adds r1, 0x21 - ldrb r1, [r1] - adds r2, r6, 0 - bl state_to_direction - adds r6, r0, 0 - mov r5, sp - adds r5, 0x2 - adds r0, r4, 0 - adds r1, r6, 0 - mov r2, sp - adds r3, r5, 0 - bl FieldObjectMoveDestCoords - adds r0, r6, 0 - bl GetGoSpeed1AnimId - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r1, r7, 0 - bl FieldObjectSetRegularAnim - mov r0, sp - movs r2, 0 - ldrsh r1, [r0, r2] - movs r0, 0 - ldrsh r2, [r5, r0] - adds r0, r4, 0 - adds r3, r6, 0 - bl npc_block_way - lsls r0, 24 - cmp r0, 0 - bne _0809212A - mov r1, r8 - cmp r1, 0 - beq _0809213E - mov r0, sp - movs r2, 0 - ldrsh r0, [r0, r2] - movs r2, 0 - ldrsh r1, [r5, r2] - bl MapGridGetMetatileBehaviorAt - lsls r0, 24 - lsrs r0, 24 - bl _call_via_r8 - lsls r0, 24 - cmp r0, 0 - bne _0809213E -_0809212A: - adds r0, r6, 0 - bl GetFaceDirectionAnimId - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r1, r7, 0 - bl FieldObjectSetRegularAnim -_0809213E: - ldrb r0, [r4] - movs r1, 0x2 - orrs r0, r1 - strb r0, [r4] - movs r0, 0x2 - strh r0, [r7, 0x30] - movs r0, 0x1 - add sp, 0x4 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80920A4 - - thumb_func_start sub_809215C -sub_809215C: @ 809215C - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x4 - adds r4, r0, 0 - adds r7, r1, 0 - mov r8, r3 - lsls r2, 24 - lsrs r6, r2, 24 - ldr r1, =gUnknown_085055CD - ldrb r0, [r4, 0x6] - adds r0, r1 - ldrb r0, [r0] - adds r1, r4, 0 - adds r1, 0x21 - ldrb r1, [r1] - adds r2, r6, 0 - bl state_to_direction - adds r6, r0, 0 - mov r5, sp - adds r5, 0x2 - adds r0, r4, 0 - adds r1, r6, 0 - mov r2, sp - adds r3, r5, 0 - bl FieldObjectMoveDestCoords - adds r0, r6, 0 - bl GetGoSpeed3AnimId - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r1, r7, 0 - bl FieldObjectSetRegularAnim - mov r0, sp - movs r2, 0 - ldrsh r1, [r0, r2] - movs r0, 0 - ldrsh r2, [r5, r0] - adds r0, r4, 0 - adds r3, r6, 0 - bl npc_block_way - lsls r0, 24 - cmp r0, 0 - bne _080921E2 - mov r1, r8 - cmp r1, 0 - beq _080921F6 - mov r0, sp - movs r2, 0 - ldrsh r0, [r0, r2] - movs r2, 0 - ldrsh r1, [r5, r2] - bl MapGridGetMetatileBehaviorAt - lsls r0, 24 - lsrs r0, 24 - bl _call_via_r8 - lsls r0, 24 - cmp r0, 0 - bne _080921F6 -_080921E2: - adds r0, r6, 0 - bl GetFaceDirectionAnimId - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r1, r7, 0 - bl FieldObjectSetRegularAnim -_080921F6: - ldrb r0, [r4] - movs r1, 0x2 - orrs r0, r1 - strb r0, [r4] - movs r0, 0x2 - strh r0, [r7, 0x30] - movs r0, 0x1 - add sp, 0x4 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_809215C - - thumb_func_start sub_8092214 -sub_8092214: @ 8092214 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x4 - adds r4, r0, 0 - adds r7, r1, 0 - mov r8, r3 - lsls r2, 24 - lsrs r6, r2, 24 - ldr r1, =gUnknown_085055CD - ldrb r0, [r4, 0x6] - adds r0, r1 - ldrb r0, [r0] - adds r1, r4, 0 - adds r1, 0x21 - ldrb r1, [r1] - adds r2, r6, 0 - bl state_to_direction - adds r6, r0, 0 - mov r5, sp - adds r5, 0x2 - adds r0, r4, 0 - adds r1, r6, 0 - mov r2, sp - adds r3, r5, 0 - bl FieldObjectMoveDestCoords - adds r0, r6, 0 - bl sub_8093438 - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r1, r7, 0 - bl FieldObjectSetRegularAnim - mov r0, sp - movs r2, 0 - ldrsh r1, [r0, r2] - movs r0, 0 - ldrsh r2, [r5, r0] - adds r0, r4, 0 - adds r3, r6, 0 - bl npc_block_way - lsls r0, 24 - cmp r0, 0 - bne _0809229A - mov r1, r8 - cmp r1, 0 - beq _080922AE - mov r0, sp - movs r2, 0 - ldrsh r0, [r0, r2] - movs r2, 0 - ldrsh r1, [r5, r2] - bl MapGridGetMetatileBehaviorAt - lsls r0, 24 - lsrs r0, 24 - bl _call_via_r8 - lsls r0, 24 - cmp r0, 0 - bne _080922AE -_0809229A: - adds r0, r6, 0 - bl GetFaceDirectionAnimId - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r1, r7, 0 - bl FieldObjectSetRegularAnim -_080922AE: - ldrb r0, [r4] - movs r1, 0x2 - orrs r0, r1 - strb r0, [r4] - movs r0, 0x2 - strh r0, [r7, 0x30] - movs r0, 0x1 - add sp, 0x4 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8092214 - - thumb_func_start cph_IM_DIFFERENT -cph_IM_DIFFERENT: @ 80922CC - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - lsls r2, 24 - lsrs r2, 24 - ldr r1, =gUnknown_085055CD - ldrb r0, [r4, 0x6] - adds r0, r1 - ldrb r0, [r0] - adds r1, r4, 0 - adds r1, 0x21 - ldrb r1, [r1] - bl state_to_direction - bl sub_80934BC - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r1, r5, 0 - bl FieldObjectSetRegularAnim - ldrb r0, [r4] - movs r1, 0x2 - orrs r0, r1 - strb r0, [r4] - movs r0, 0x2 - strh r0, [r5, 0x30] - movs r0, 0x1 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end cph_IM_DIFFERENT - - thumb_func_start sub_8092314 -sub_8092314: @ 8092314 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x4 - adds r4, r0, 0 - adds r7, r1, 0 - mov r8, r3 - lsls r2, 24 - lsrs r6, r2, 24 - ldr r1, =gUnknown_085055CD - ldrb r0, [r4, 0x6] - adds r0, r1 - ldrb r0, [r0] - adds r1, r4, 0 - adds r1, 0x21 - ldrb r1, [r1] - adds r2, r6, 0 - bl state_to_direction - adds r6, r0, 0 - mov r5, sp - adds r5, 0x2 - adds r0, r4, 0 - adds r1, r6, 0 - mov r2, sp - adds r3, r5, 0 - bl FieldObjectMoveDestCoords - adds r0, r6, 0 - bl sub_8093514 - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r1, r7, 0 - bl FieldObjectSetRegularAnim - mov r0, sp - movs r2, 0 - ldrsh r1, [r0, r2] - movs r0, 0 - ldrsh r2, [r5, r0] - adds r0, r4, 0 - adds r3, r6, 0 - bl npc_block_way - lsls r0, 24 - cmp r0, 0 - bne _0809239A - mov r1, r8 - cmp r1, 0 - beq _080923AE - mov r0, sp - movs r2, 0 - ldrsh r0, [r0, r2] - movs r2, 0 - ldrsh r1, [r5, r2] - bl MapGridGetMetatileBehaviorAt - lsls r0, 24 - lsrs r0, 24 - bl _call_via_r8 - lsls r0, 24 - cmp r0, 0 - bne _080923AE -_0809239A: - adds r0, r6, 0 - bl GetFaceDirectionAnimId - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r1, r7, 0 - bl FieldObjectSetRegularAnim -_080923AE: - ldrb r0, [r4] - movs r1, 0x2 - orrs r0, r1 - strb r0, [r4] - movs r0, 0x2 - strh r0, [r7, 0x30] - movs r0, 0x1 - add sp, 0x4 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8092314 - - thumb_func_start oac_hopping -oac_hopping: @ 80923CC - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x8 - adds r4, r0, 0 - adds r7, r1, 0 - mov r8, r3 - lsls r2, 24 - lsrs r6, r2, 24 - ldr r1, =gUnknown_085055CD - ldrb r0, [r4, 0x6] - adds r0, r1 - ldrb r0, [r0] - adds r1, r4, 0 - adds r1, 0x21 - ldrb r1, [r1] - adds r2, r6, 0 - bl state_to_direction - adds r6, r0, 0 - ldrh r1, [r4, 0x10] - add r0, sp, 0x4 - strh r1, [r0] - ldrh r0, [r4, 0x12] - mov r5, sp - adds r5, 0x6 - strh r0, [r5] - movs r0, 0x2 - str r0, [sp] - adds r0, r6, 0 - add r1, sp, 0x4 - adds r2, r5, 0 - movs r3, 0x2 - bl sub_8092F88 - adds r0, r6, 0 - bl GetJumpLedgeAnimId - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r1, r7, 0 - bl FieldObjectSetRegularAnim - add r0, sp, 0x4 - movs r2, 0 - ldrsh r1, [r0, r2] - movs r0, 0 - ldrsh r2, [r5, r0] - adds r0, r4, 0 - adds r3, r6, 0 - bl npc_block_way - lsls r0, 24 - cmp r0, 0 - bne _08092460 - mov r1, r8 - cmp r1, 0 - beq _08092474 - add r0, sp, 0x4 - movs r2, 0 - ldrsh r0, [r0, r2] - movs r2, 0 - ldrsh r1, [r5, r2] - bl MapGridGetMetatileBehaviorAt - lsls r0, 24 - lsrs r0, 24 - bl _call_via_r8 - lsls r0, 24 - cmp r0, 0 - bne _08092474 -_08092460: - adds r0, r6, 0 - bl GetFaceDirectionAnimId - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r1, r7, 0 - bl FieldObjectSetRegularAnim -_08092474: - ldrb r0, [r4] - movs r1, 0x2 - orrs r0, r1 - strb r0, [r4] - movs r0, 0x2 - strh r0, [r7, 0x30] - movs r0, 0x1 - add sp, 0x8 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end oac_hopping - thumb_func_start FieldObjectCB_CopyPlayer2 FieldObjectCB_CopyPlayer2: @ 8092494 push {lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index cd330a18d..42b18a1ac 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -95,8 +95,17 @@ static bool8 FieldObjectDoesZCoordMatch(struct MapObject *, u8); /*static*/ struct MapObjectTemplate *FindFieldObjectTemplateInArrayByLocalId(u8 localId, struct MapObjectTemplate *templates, u8 count); void npc_reset(struct MapObject *, struct Sprite *); void FieldObjectSetRegularAnim(struct MapObject *, struct Sprite *, u8); + u8 GetFaceDirectionAnimId(u32); u8 GetGoSpeed0AnimId(u32); +u8 GetGoSpeed1AnimId(u32); +u8 GetGoSpeed3AnimId(u32); +u8 sub_8093438(u32); +u8 sub_80934BC(u32); +u8 sub_8093514(u32); +u8 GetJumpLedgeAnimId(u32); +void sub_8092F88(u32, s16 *, s16 *, s16, s16); + bool8 FieldObjectExecRegularAnim(struct MapObject *, struct Sprite *); void SetFieldObjectStepTimer(struct Sprite *, s16); bool8 RunFieldObjectStepTimer(struct Sprite *); @@ -3239,6 +3248,115 @@ bool8 sub_8091F94(struct MapObject *mapObject, struct Sprite *sprite, u8 playerD return TRUE; } +bool8 sub_80920A4(struct MapObject *mapObject, struct Sprite *sprite, u8 playerDirection, bool8 tileCB(u8)) +{ + u32 direction; + s16 x; + s16 y; + + direction = playerDirection; + direction = state_to_direction(gUnknown_085055CD[mapObject->animPattern], mapObject->mapobj_unk_21, direction); + FieldObjectMoveDestCoords(mapObject, direction, &x, &y); + FieldObjectSetRegularAnim(mapObject, sprite, GetGoSpeed1AnimId(direction)); + if (npc_block_way(mapObject, x, y, direction) || (tileCB != NULL && !tileCB(MapGridGetMetatileBehaviorAt(x, y)))) + { + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(direction)); + } + mapObject->mapobj_bit_1 = TRUE; + sprite->data1 = 2; + return TRUE; +} + +bool8 sub_809215C(struct MapObject *mapObject, struct Sprite *sprite, u8 playerDirection, bool8 tileCB(u8)) +{ + u32 direction; + s16 x; + s16 y; + + direction = playerDirection; + direction = state_to_direction(gUnknown_085055CD[mapObject->animPattern], mapObject->mapobj_unk_21, direction); + FieldObjectMoveDestCoords(mapObject, direction, &x, &y); + FieldObjectSetRegularAnim(mapObject, sprite, GetGoSpeed3AnimId(direction)); + if (npc_block_way(mapObject, x, y, direction) || (tileCB != NULL && !tileCB(MapGridGetMetatileBehaviorAt(x, y)))) + { + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(direction)); + } + mapObject->mapobj_bit_1 = TRUE; + sprite->data1 = 2; + return TRUE; +} + +bool8 sub_8092214(struct MapObject *mapObject, struct Sprite *sprite, u8 playerDirection, bool8 tileCB(u8)) +{ + u32 direction; + s16 x; + s16 y; + + direction = playerDirection; + direction = state_to_direction(gUnknown_085055CD[mapObject->animPattern], mapObject->mapobj_unk_21, direction); + FieldObjectMoveDestCoords(mapObject, direction, &x, &y); + FieldObjectSetRegularAnim(mapObject, sprite, sub_8093438(direction)); + if (npc_block_way(mapObject, x, y, direction) || (tileCB != NULL && !tileCB(MapGridGetMetatileBehaviorAt(x, y)))) + { + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(direction)); + } + mapObject->mapobj_bit_1 = TRUE; + sprite->data1 = 2; + return TRUE; +} + +bool8 cph_IM_DIFFERENT(struct MapObject *mapObject, struct Sprite *sprite, u8 playerDirection, bool8 tileCB(u8)) +{ + u32 direction; + + direction = playerDirection; + direction = state_to_direction(gUnknown_085055CD[mapObject->animPattern], mapObject->mapobj_unk_21, direction); + FieldObjectSetRegularAnim(mapObject, sprite, sub_80934BC(direction)); + mapObject->mapobj_bit_1 = TRUE; + sprite->data1 = 2; + return TRUE; +} + +bool8 sub_8092314(struct MapObject *mapObject, struct Sprite *sprite, u8 playerDirection, bool8 tileCB(u8)) +{ + u32 direction; + s16 x; + s16 y; + + direction = playerDirection; + direction = state_to_direction(gUnknown_085055CD[mapObject->animPattern], mapObject->mapobj_unk_21, direction); + FieldObjectMoveDestCoords(mapObject, direction, &x, &y); + FieldObjectSetRegularAnim(mapObject, sprite, sub_8093514(direction)); + if (npc_block_way(mapObject, x, y, direction) || (tileCB != NULL && !tileCB(MapGridGetMetatileBehaviorAt(x, y)))) + { + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(direction)); + } + mapObject->mapobj_bit_1 = TRUE; + sprite->data1 = 2; + return TRUE; +} + +bool8 oac_hopping(struct MapObject *mapObject, struct Sprite *sprite, u8 playerDirection, bool8 tileCB(u8)) +{ + u32 direction; + s16 x; + s16 y; + + direction = playerDirection; + direction = state_to_direction(gUnknown_085055CD[mapObject->animPattern], mapObject->mapobj_unk_21, direction); + x = mapObject->coords2.x; + y = mapObject->coords2.y; + sub_8092F88(direction, &x, &y, 2, 2); + FieldObjectSetRegularAnim(mapObject, sprite, GetJumpLedgeAnimId(direction)); + if (npc_block_way(mapObject, x, y, direction) || (tileCB != NULL && !tileCB(MapGridGetMetatileBehaviorAt(x, y)))) + { + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(direction)); + } + mapObject->mapobj_bit_1 = TRUE; + sprite->data1 = 2; + return TRUE; +} + asm(".section .text.get_face_direction_anim_id"); void FieldObjectClearAnimIfSpecialAnimActive(struct MapObject *); @@ -3292,16 +3410,19 @@ void FieldObjectStep(struct MapObject *mapObject, struct Sprite *sprite, bool8 ( FieldObjectUpdateSubpriority(mapObject, sprite); } -u8 GetFaceDirectionAnimId(u32 direction) -{ - u8 dirn2; - u8 animIds[sizeof gUnknown_0850DBA0]; - - dirn2 = direction; - memcpy(animIds, gUnknown_0850DBA0, sizeof gUnknown_0850DBA0); - if (dirn2 > DIR_EAST) - { - dirn2 = 0; - } - return animIds[dirn2]; +#define dirn2anim(name, table) \ +extern const u8 table[5]; \ +u8 name(u32 direction) \ +{ \ + u8 dirn2; \ + u8 animIds[5]; \ + dirn2 = direction; \ + memcpy(animIds, table, 5); \ + if (dirn2 > DIR_EAST) \ + { \ + dirn2 = 0; \ + } \ + return animIds[dirn2]; \ } + +dirn2anim(GetFaceDirectionAnimId, gUnknown_0850DBA0); From 12885ca371f0b89d7df6decc133a14452ab567e0 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 16 Sep 2017 16:40:00 -0400 Subject: [PATCH 114/191] CopyPlayer2 --- asm/field_map_obj.s | 83 ------------------------------------- include/metatile_behavior.h | 11 +++++ src/field_map_obj.c | 12 ++++++ 3 files changed, 23 insertions(+), 83 deletions(-) create mode 100644 include/metatile_behavior.h diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 333621879..1da91d1f5 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,89 +5,6 @@ .text - thumb_func_start FieldObjectCB_CopyPlayer2 -FieldObjectCB_CopyPlayer2: @ 8092494 - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =sub_80924B8 - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_CopyPlayer2 - - thumb_func_start sub_80924B8 -sub_80924B8: @ 80924B8 - push {r4,lr} - ldr r3, =gUnknown_0850DA90 - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80924B8 - - thumb_func_start mss_08062EA4 -mss_08062EA4: @ 80924D8 - push {r4-r7,lr} - adds r6, r0, 0 - adds r7, r1, 0 - ldr r2, =gMapObjects - ldr r3, =gPlayerAvatar - ldrb r1, [r3, 0x5] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r0, [r0, 0x1C] - cmp r0, 0xFF - beq _080924F8 - ldrb r0, [r3, 0x3] - cmp r0, 0x2 - bne _08092504 -_080924F8: - movs r0, 0 - b _0809252C - .pool -_08092504: - ldr r5, =gUnknown_0850DA64 - bl player_get_x22 - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 22 - adds r4, r5 - bl player_get_direction_upper_nybble - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - ldr r3, =sub_8088E64 - ldr r4, [r4] - adds r0, r6, 0 - adds r1, r7, 0 - bl _call_via_r4 - lsls r0, 24 - lsrs r0, 24 -_0809252C: - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end mss_08062EA4 - thumb_func_start FieldObjectCB_TreeDisguise @ void FieldObjectCB_TreeDisguise(struct obj *object) FieldObjectCB_TreeDisguise: @ 809253C diff --git a/include/metatile_behavior.h b/include/metatile_behavior.h new file mode 100644 index 000000000..5ed36c690 --- /dev/null +++ b/include/metatile_behavior.h @@ -0,0 +1,11 @@ +#ifndef GUARD_METATILE_BEHAVIOR_H +#define GUARD_METATILE_BEHAVIOR_H + +// Exported type declarations + +// Exported RAM declarations + +// Exported ROM declarations +bool8 sub_8088E64(u8); + +#endif //GUARD_METATILE_BEHAVIOR_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 42b18a1ac..c35105b44 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -17,6 +17,7 @@ #include "field_ground_effect.h" #include "map_obj_8097404.h" #include "mauville_old_man.h" +#include "metatile_behavior.h" #include "field_effect.h" #include "field_effect_helpers.h" #include "field_map_obj.h" @@ -3357,6 +3358,17 @@ bool8 oac_hopping(struct MapObject *mapObject, struct Sprite *sprite, u8 playerD return TRUE; } +field_object_step(CopyPlayer2, gUnknown_0850DA90) + +bool8 mss_08062EA4(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (gMapObjects[gPlayerAvatar.mapObjectId].mapobj_unk_1C == 0xFF || gPlayerAvatar.running1 == 2) + { + return FALSE; + } + return gUnknown_0850DA64[player_get_x22()](mapObject, sprite, player_get_direction_upper_nybble(), sub_8088E64); +} + asm(".section .text.get_face_direction_anim_id"); void FieldObjectClearAnimIfSpecialAnimActive(struct MapObject *); From 6247fe742c095885fa0938d8e91ee222e25a6354 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 16 Sep 2017 16:53:55 -0400 Subject: [PATCH 115/191] Tree and Mountain Disguise FOCB --- asm/field_map_obj.s | 118 -------------------------------------------- src/field_map_obj.c | 38 ++++++++++++++ 2 files changed, 38 insertions(+), 118 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 1da91d1f5..12941a438 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,124 +5,6 @@ .text - thumb_func_start FieldObjectCB_TreeDisguise -@ void FieldObjectCB_TreeDisguise(struct obj *object) -FieldObjectCB_TreeDisguise: @ 809253C - push {r4-r6,lr} - adds r5, r0, 0 - movs r1, 0x2E - ldrsh r0, [r5, r1] - lsls r1, r0, 3 - adds r1, r0 - lsls r1, 2 - ldr r0, =gMapObjects - adds r4, r1, r0 - adds r6, r4, 0 - adds r6, 0x21 - ldrb r0, [r6] - cmp r0, 0 - beq _08092564 - cmp r0, 0x1 - bne _08092584 - movs r1, 0x3C - ldrsh r0, [r5, r1] - cmp r0, 0 - bne _08092584 -_08092564: - ldr r1, =gFieldEffectSpawnParams - adds r2, r1, 0x4 - adds r3, r1, 0 - adds r3, 0x8 - adds r0, r4, 0 - bl FieldObjectGetLocalIdAndMap - movs r0, 0x1C - bl FieldEffectStart - strb r0, [r4, 0x1A] - movs r0, 0x1 - strb r0, [r6] - ldrh r0, [r5, 0x3C] - adds r0, 0x1 - strh r0, [r5, 0x3C] -_08092584: - movs r0, 0x2E - ldrsh r1, [r5, r0] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, =gMapObjects - adds r0, r1 - ldr r2, =sub_80925AC - adds r1, r5, 0 - bl FieldObjectStep - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_TreeDisguise - - thumb_func_start sub_80925AC -sub_80925AC: @ 80925AC - push {lr} - bl npc_reset - movs r0, 0 - pop {r1} - bx r1 - thumb_func_end sub_80925AC - - thumb_func_start FieldObjectCB_MountainDisguise -FieldObjectCB_MountainDisguise: @ 80925B8 - push {r4-r6,lr} - adds r5, r0, 0 - movs r1, 0x2E - ldrsh r0, [r5, r1] - lsls r1, r0, 3 - adds r1, r0 - lsls r1, 2 - ldr r0, =gMapObjects - adds r4, r1, r0 - adds r6, r4, 0 - adds r6, 0x21 - ldrb r0, [r6] - cmp r0, 0 - beq _080925E0 - cmp r0, 0x1 - bne _08092600 - movs r1, 0x3C - ldrsh r0, [r5, r1] - cmp r0, 0 - bne _08092600 -_080925E0: - ldr r1, =gFieldEffectSpawnParams - adds r2, r1, 0x4 - adds r3, r1, 0 - adds r3, 0x8 - adds r0, r4, 0 - bl FieldObjectGetLocalIdAndMap - movs r0, 0x1D - bl FieldEffectStart - strb r0, [r4, 0x1A] - movs r0, 0x1 - strb r0, [r6] - ldrh r0, [r5, 0x3C] - adds r0, 0x1 - strh r0, [r5, 0x3C] -_08092600: - movs r0, 0x2E - ldrsh r1, [r5, r0] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, =gMapObjects - adds r0, r1 - ldr r2, =sub_80925AC - adds r1, r5, 0 - bl FieldObjectStep - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_MountainDisguise - thumb_func_start FieldObjectCB_Hidden1 @ void FieldObjectCB_Hidden1(struct obj *object) FieldObjectCB_Hidden1: @ 8092628 diff --git a/src/field_map_obj.c b/src/field_map_obj.c index c35105b44..7b62e6d05 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -3369,6 +3369,44 @@ bool8 mss_08062EA4(struct MapObject *mapObject, struct Sprite *sprite) return gUnknown_0850DA64[player_get_x22()](mapObject, sprite, player_get_direction_upper_nybble(), sub_8088E64); } +bool8 sub_80925AC(struct MapObject *, struct Sprite *); + +void FieldObjectCB_TreeDisguise(struct Sprite *sprite) +{ + struct MapObject *mapObject; + + mapObject = &gMapObjects[sprite->data0]; + if (mapObject->mapobj_unk_21 == 0 || (mapObject->mapobj_unk_21 == 1 && !sprite->data7)) + { + FieldObjectGetLocalIdAndMap(mapObject, (u8 *)&gFieldEffectSpawnParams[0], (u8 *)&gFieldEffectSpawnParams[1], (u8 *)&gFieldEffectSpawnParams[2]); + mapObject->mapobj_unk_1A = FieldEffectStart(FLDEFF_TREE_DISGUISE); + mapObject->mapobj_unk_21 = 1; + sprite->data7 ++; + } + FieldObjectStep(&gMapObjects[sprite->data0], sprite, sub_80925AC); +} + +bool8 sub_80925AC(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + return FALSE; +} + +void FieldObjectCB_MountainDisguise(struct Sprite *sprite) +{ + struct MapObject *mapObject; + + mapObject = &gMapObjects[sprite->data0]; + if (mapObject->mapobj_unk_21 == 0 || (mapObject->mapobj_unk_21 == 1 && !sprite->data7)) + { + FieldObjectGetLocalIdAndMap(mapObject, (u8 *)&gFieldEffectSpawnParams[0], (u8 *)&gFieldEffectSpawnParams[1], (u8 *)&gFieldEffectSpawnParams[2]); + mapObject->mapobj_unk_1A = FieldEffectStart(FLDEFF_MOUNTAIN_DISGUISE); + mapObject->mapobj_unk_21 = 1; + sprite->data7 ++; + } + FieldObjectStep(&gMapObjects[sprite->data0], sprite, sub_80925AC); +} + asm(".section .text.get_face_direction_anim_id"); void FieldObjectClearAnimIfSpecialAnimActive(struct MapObject *); From 15aba9a07633092ad340a5f11df962e2aaf6703d Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 16 Sep 2017 17:24:26 -0400 Subject: [PATCH 116/191] Hidden1 --- asm/field_map_obj.s | 96 --------------------------------------------- src/field_map_obj.c | 34 ++++++++++++++++ 2 files changed, 34 insertions(+), 96 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 12941a438..92b6022f6 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,102 +5,6 @@ .text - thumb_func_start FieldObjectCB_Hidden1 -@ void FieldObjectCB_Hidden1(struct obj *object) -FieldObjectCB_Hidden1: @ 8092628 - push {r4,lr} - adds r3, r0, 0 - movs r1, 0x3C - ldrsh r0, [r3, r1] - ldr r4, =gMapObjects - cmp r0, 0 - bne _08092668 - movs r0, 0x2E - ldrsh r1, [r3, r0] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - ldrb r1, [r0, 0x3] - movs r2, 0x4 - orrs r1, r2 - strb r1, [r0, 0x3] - adds r2, r3, 0 - adds r2, 0x42 - ldrb r1, [r2] - movs r0, 0x3F - ands r0, r1 - movs r1, 0x80 - orrs r0, r1 - strb r0, [r2] - ldrb r0, [r3, 0x5] - movs r1, 0xC - orrs r0, r1 - strb r0, [r3, 0x5] - ldrh r0, [r3, 0x3C] - adds r0, 0x1 - strh r0, [r3, 0x3C] -_08092668: - movs r0, 0x2E - ldrsh r1, [r3, r0] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - ldr r2, =sub_809268C - adds r1, r3, 0 - bl FieldObjectStep - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_Hidden1 - - thumb_func_start sub_809268C -sub_809268C: @ 809268C - push {r4,lr} - ldr r3, =gUnknown_0850DA9C - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_809268C - - thumb_func_start sub_80926AC -sub_80926AC: @ 80926AC - push {lr} - bl npc_reset - movs r0, 0 - pop {r1} - bx r1 - thumb_func_end sub_80926AC - - thumb_func_start sub_80926B8 -@ bool8 sub_80926B8(struct npc_state *fieldObject, struct obj *object) -sub_80926B8: @ 80926B8 - push {r4,lr} - adds r4, r1, 0 - bl FieldObjectExecRegularAnim - lsls r0, 24 - cmp r0, 0 - beq _080926CA - movs r0, 0 - strh r0, [r4, 0x30] -_080926CA: - movs r0, 0 - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_80926B8 - thumb_func_start FieldObjectCB_WalkInPlace1 FieldObjectCB_WalkInPlace1: @ 80926D4 push {lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 7b62e6d05..80c376a2f 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -3407,6 +3407,40 @@ void FieldObjectCB_MountainDisguise(struct Sprite *sprite) FieldObjectStep(&gMapObjects[sprite->data0], sprite, sub_80925AC); } +extern bool8 (*const gUnknown_0850DA9C[])(struct MapObject *, struct Sprite *); +bool8 sub_809268C(struct MapObject *, struct Sprite *); + +void FieldObjectCB_Hidden1(struct Sprite *sprite) +{ + if (!sprite->data7) + { + gMapObjects[sprite->data0].mapobj_bit_26 = TRUE; + sprite->subspriteMode = 2; + sprite->oam.priority = 3; + sprite->data7 ++; + } + FieldObjectStep(&gMapObjects[sprite->data0], sprite, sub_809268C); +} + +bool8 sub_809268C(struct MapObject *mapObject, struct Sprite *sprite) +{ + return gUnknown_0850DA9C[sprite->data1](mapObject, sprite); +} + +bool8 sub_80926AC (struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + return FALSE; +} +bool8 sub_80926B8 (struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite)) + { + sprite->data1 = 0; + } + return FALSE; +} + asm(".section .text.get_face_direction_anim_id"); void FieldObjectClearAnimIfSpecialAnimActive(struct MapObject *); From 34950dbd13f9ec9e4616b3cb33a9b1aae912eee2 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 16 Sep 2017 17:34:41 -0400 Subject: [PATCH 117/191] remaining field object step callbacks --- asm/field_map_obj.s | 331 ---------------------------------------- include/field_map_obj.h | 5 +- src/field_map_obj.c | 66 ++++++++ 3 files changed, 70 insertions(+), 332 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 92b6022f6..8ea5a8b76 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,337 +5,6 @@ .text - thumb_func_start FieldObjectCB_WalkInPlace1 -FieldObjectCB_WalkInPlace1: @ 80926D4 - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =sub_80926F8 - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_WalkInPlace1 - - thumb_func_start sub_80926F8 -sub_80926F8: @ 80926F8 - push {r4,lr} - ldr r3, =gUnknown_0850DAA0 - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80926F8 - - thumb_func_start sub_8092718 -sub_8092718: @ 8092718 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl npc_reset - ldrb r0, [r4, 0x18] - lsls r0, 28 - lsrs r0, 28 - bl GetStepInPlaceDelay16AnimId - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r1, r5, 0 - bl FieldObjectSetRegularAnim - movs r0, 0x1 - strh r0, [r5, 0x30] - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8092718 - - thumb_func_start FieldObjectCB_WalkInPlace4 -FieldObjectCB_WalkInPlace4: @ 8092744 - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =sub_8092768 - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_WalkInPlace4 - - thumb_func_start sub_8092768 -sub_8092768: @ 8092768 - push {r4,lr} - ldr r3, =gUnknown_0850DAA8 - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8092768 - - thumb_func_start sub_8092788 -sub_8092788: @ 8092788 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl npc_reset - ldrb r0, [r4, 0x18] - lsls r0, 28 - lsrs r0, 28 - bl GetStepInPlaceDelay32AnimId - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r1, r5, 0 - bl FieldObjectSetRegularAnim - movs r0, 0x1 - strh r0, [r5, 0x30] - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8092788 - - thumb_func_start FieldObjectCB_WalkInPlace2 -FieldObjectCB_WalkInPlace2: @ 80927B4 - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =sub_80927D8 - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_WalkInPlace2 - - thumb_func_start sub_80927D8 -sub_80927D8: @ 80927D8 - push {r4,lr} - ldr r3, =gUnknown_0850DAB0 - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80927D8 - - thumb_func_start sub_80927F8 -@ bool8 sub_80927F8(struct npc_state *fieldObject, struct obj *object) -sub_80927F8: @ 80927F8 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl npc_reset - ldrb r0, [r4, 0x18] - lsls r0, 28 - lsrs r0, 28 - bl GetStepInPlaceDelay8AnimId - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r1, r5, 0 - bl FieldObjectSetRegularAnim - movs r0, 0x1 - strh r0, [r5, 0x30] - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80927F8 - - thumb_func_start FieldObjectCB_WalkInPlace3 -FieldObjectCB_WalkInPlace3: @ 8092824 - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =sub_8092848 - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_WalkInPlace3 - - thumb_func_start sub_8092848 -sub_8092848: @ 8092848 - push {r4,lr} - ldr r3, =gUnknown_0850DAB8 - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8092848 - - thumb_func_start sub_8092868 -sub_8092868: @ 8092868 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl npc_reset - ldrb r0, [r4, 0x18] - lsls r0, 28 - lsrs r0, 28 - bl GetStepInPlaceDelay4AnimId - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r1, r5, 0 - bl FieldObjectSetRegularAnim - movs r0, 0x1 - strh r0, [r5, 0x30] - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8092868 - - thumb_func_start FieldObjectCB_Hidden2 -FieldObjectCB_Hidden2: @ 8092894 - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =sub_80928B8 - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_Hidden2 - - thumb_func_start sub_80928B8 -sub_80928B8: @ 80928B8 - push {r4,lr} - ldr r3, =gUnknown_0850DAC0 - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80928B8 - - thumb_func_start sub_80928D8 -sub_80928D8: @ 80928D8 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl npc_reset - ldrb r0, [r4, 0x18] - lsls r0, 28 - lsrs r0, 28 - bl GetFaceDirectionAnimId - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r1, r5, 0 - bl FieldObjectSetRegularAnim - ldrb r0, [r4, 0x1] - movs r1, 0x20 - orrs r0, r1 - strb r0, [r4, 0x1] - movs r0, 0x1 - strh r0, [r5, 0x30] - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80928D8 - - thumb_func_start sub_809290C -sub_809290C: @ 809290C - push {r4,lr} - adds r4, r1, 0 - bl FieldObjectExecRegularAnim - lsls r0, 24 - cmp r0, 0 - bne _0809291E - movs r0, 0 - b _08092924 -_0809291E: - movs r0, 0x2 - strh r0, [r4, 0x30] - movs r0, 0x1 -_08092924: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_809290C - - thumb_func_start sub_809292C -sub_809292C: @ 809292C - ldrb r2, [r0] - movs r1, 0x3 - negs r1, r1 - ands r1, r2 - strb r1, [r0] - movs r0, 0 - bx lr - thumb_func_end sub_809292C - thumb_func_start npc_reset @ void npc_reset(struct npc_state *fieldObject, struct obj *object) npc_reset: @ 809293C diff --git a/include/field_map_obj.h b/include/field_map_obj.h index f603e9a8e..03ba36e87 100755 --- a/include/field_map_obj.h +++ b/include/field_map_obj.h @@ -63,7 +63,10 @@ void sub_808EB08(struct MapObject *, s16, s16); void sub_808F254(u8, u8, u8); void FieldObjectStep(struct MapObject *, struct Sprite *, bool8(struct MapObject *, struct Sprite *)); u8 GetOppositeDirection(u8); -u8 GetStepInPlaceDelay16AnimId(u8); +u8 GetStepInPlaceDelay4AnimId(u32); +u8 GetStepInPlaceDelay8AnimId(u32); +u8 GetStepInPlaceDelay16AnimId(u32); +u8 GetStepInPlaceDelay32AnimId(u32); u8 npc_block_way(struct MapObject *, s16, s16, u32); // Exported data declarations diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 80c376a2f..5d5747be9 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -3441,6 +3441,72 @@ bool8 sub_80926B8 (struct MapObject *mapObject, struct Sprite *sprite) return FALSE; } +field_object_step(WalkInPlace1, gUnknown_0850DAA0) + +bool8 sub_8092718(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + FieldObjectSetRegularAnim(mapObject, sprite, GetStepInPlaceDelay16AnimId(mapObject->mapobj_unk_18)); + sprite->data1 = 1; + return TRUE; +} + +field_object_step(WalkInPlace4, gUnknown_0850DAA8) + +bool8 sub_8092788(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + FieldObjectSetRegularAnim(mapObject, sprite, GetStepInPlaceDelay32AnimId(mapObject->mapobj_unk_18)); + sprite->data1 = 1; + return TRUE; +} + +field_object_step(WalkInPlace2, gUnknown_0850DAB0) + +bool8 sub_80927F8(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + FieldObjectSetRegularAnim(mapObject, sprite, GetStepInPlaceDelay8AnimId(mapObject->mapobj_unk_18)); + sprite->data1 = 1; + return TRUE; +} + +field_object_step(WalkInPlace3, gUnknown_0850DAB8) + +bool8 sub_8092868(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + FieldObjectSetRegularAnim(mapObject, sprite, GetStepInPlaceDelay4AnimId(mapObject->mapobj_unk_18)); + sprite->data1 = 1; + return TRUE; +} + +field_object_step(Hidden2, gUnknown_0850DAC0) + +bool8 sub_80928D8(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(mapObject->mapobj_unk_18)); + mapObject->mapobj_bit_13 = TRUE; + sprite->data1 = 1; + return TRUE; +} +bool8 sub_809290C(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite)) + { + sprite->data1 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_809292C(struct MapObject *mapObject, struct Sprite *sprite) +{ + mapObject->mapobj_bit_1 = FALSE; + return FALSE; +} + asm(".section .text.get_face_direction_anim_id"); void FieldObjectClearAnimIfSpecialAnimActive(struct MapObject *); From fa436fca4dd0878eb1fdd905dec48e8c2cd310d2 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 16 Sep 2017 17:41:46 -0400 Subject: [PATCH 118/191] a block of direction-based anim num fns --- asm/field_map_obj.s | 186 -------------------------------------------- src/field_map_obj.c | 36 ++++++++- 2 files changed, 34 insertions(+), 188 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 8ea5a8b76..0a043682b 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,192 +5,6 @@ .text - thumb_func_start npc_reset -@ void npc_reset(struct npc_state *fieldObject, struct obj *object) -npc_reset: @ 809293C - ldrb r3, [r0] - movs r2, 0x3 - negs r2, r2 - ands r2, r3 - movs r3, 0x41 - negs r3, r3 - ands r2, r3 - movs r3, 0x7F - ands r2, r3 - strb r2, [r0] - movs r2, 0xFF - strb r2, [r0, 0x1C] - movs r0, 0 - strh r0, [r1, 0x30] - bx lr - thumb_func_end npc_reset - - thumb_func_start FieldObjectDirectionToImageAnimId -@ u8 FieldObjectDirectionToImageAnimId(u8 direction) -FieldObjectDirectionToImageAnimId: @ 809295C - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_0850DACC - adds r0, r1 - ldrb r0, [r0] - bx lr - .pool - thumb_func_end FieldObjectDirectionToImageAnimId - - thumb_func_start get_go_image_anim_num -get_go_image_anim_num: @ 809296C - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_0850DAD5 - adds r0, r1 - ldrb r0, [r0] - bx lr - .pool - thumb_func_end get_go_image_anim_num - - thumb_func_start get_go_fast_image_anim_num -get_go_fast_image_anim_num: @ 809297C - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_0850DADE - adds r0, r1 - ldrb r0, [r0] - bx lr - .pool - thumb_func_end get_go_fast_image_anim_num - - thumb_func_start get_go_faster_image_anim_num -get_go_faster_image_anim_num: @ 809298C - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_0850DAE7 - adds r0, r1 - ldrb r0, [r0] - bx lr - .pool - thumb_func_end get_go_faster_image_anim_num - - thumb_func_start get_go_fastest_image_anim_num -get_go_fastest_image_anim_num: @ 809299C - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_0850DAF0 - adds r0, r1 - ldrb r0, [r0] - bx lr - .pool - thumb_func_end get_go_fastest_image_anim_num - - thumb_func_start sub_80929AC -sub_80929AC: @ 80929AC - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_0850DAF9 - adds r0, r1 - ldrb r0, [r0] - bx lr - .pool - thumb_func_end sub_80929AC - - thumb_func_start sub_80929BC -sub_80929BC: @ 80929BC - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_0850DB02 - adds r0, r1 - ldrb r0, [r0] - bx lr - .pool - thumb_func_end sub_80929BC - - thumb_func_start sub_80929CC -sub_80929CC: @ 80929CC - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_0850DB0B - adds r0, r1 - ldrb r0, [r0] - bx lr - .pool - thumb_func_end sub_80929CC - - thumb_func_start sub_80929DC -sub_80929DC: @ 80929DC - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_0850DB14 - adds r0, r1 - ldrb r0, [r0] - bx lr - .pool - thumb_func_end sub_80929DC - - thumb_func_start sub_80929EC -sub_80929EC: @ 80929EC - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_0850DB1D - adds r0, r1 - ldrb r0, [r0] - bx lr - .pool - thumb_func_end sub_80929EC - - thumb_func_start sub_80929FC -sub_80929FC: @ 80929FC - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_0850DB26 - adds r0, r1 - ldrb r0, [r0] - bx lr - .pool - thumb_func_end sub_80929FC - - thumb_func_start sub_8092A0C -sub_8092A0C: @ 8092A0C - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_0850DB2F - adds r0, r1 - ldrb r0, [r0] - bx lr - .pool - thumb_func_end sub_8092A0C - - thumb_func_start sub_8092A1C -sub_8092A1C: @ 8092A1C - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_0850DB38 - adds r0, r1 - ldrb r0, [r0] - bx lr - .pool - thumb_func_end sub_8092A1C - - thumb_func_start sub_8092A2C -sub_8092A2C: @ 8092A2C - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_0850DB41 - adds r0, r1 - ldrb r0, [r0] - bx lr - .pool - thumb_func_end sub_8092A2C - - thumb_func_start get_run_image_anim_num -get_run_image_anim_num: @ 8092A3C - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_0850DB4A - adds r0, r1 - ldrb r0, [r0] - bx lr - .pool - thumb_func_end get_run_image_anim_num - thumb_func_start sub_8092A4C sub_8092A4C: @ 8092A4C push {lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 5d5747be9..8bb20abb4 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -3507,6 +3507,38 @@ bool8 sub_809292C(struct MapObject *mapObject, struct Sprite *sprite) return FALSE; } +void npc_reset(struct MapObject *mapObject, struct Sprite *sprite) +{ + mapObject->mapobj_bit_1 = FALSE; + mapObject->mapobj_bit_6 = FALSE; + mapObject->mapobj_bit_7 = FALSE; + mapObject->mapobj_unk_1C = 0xFF; + sprite->data1 = 0; +} + +#define dirn2anim(name, table)\ +extern const u8 table[4];\ +u8 name(u8 direction)\ +{\ + return table[direction];\ +} + +dirn2anim(FieldObjectDirectionToImageAnimId, gUnknown_0850DACC) +dirn2anim(get_go_image_anim_num, gUnknown_0850DAD5) +dirn2anim(get_go_fast_image_anim_num, gUnknown_0850DADE) +dirn2anim(get_go_faster_image_anim_num, gUnknown_0850DAE7) +dirn2anim(get_go_fastest_image_anim_num, gUnknown_0850DAF0) +dirn2anim(sub_80929AC, gUnknown_0850DAF9) +dirn2anim(sub_80929BC, gUnknown_0850DB02) +dirn2anim(sub_80929CC, gUnknown_0850DB0B) +dirn2anim(sub_80929DC, gUnknown_0850DB14) +dirn2anim(sub_80929EC, gUnknown_0850DB1D) +dirn2anim(sub_80929FC, gUnknown_0850DB26) +dirn2anim(sub_8092A0C, gUnknown_0850DB2F) +dirn2anim(sub_8092A1C, gUnknown_0850DB38) +dirn2anim(sub_8092A2C, gUnknown_0850DB41) +dirn2anim(get_run_image_anim_num, gUnknown_0850DB4A) + asm(".section .text.get_face_direction_anim_id"); void FieldObjectClearAnimIfSpecialAnimActive(struct MapObject *); @@ -3560,7 +3592,7 @@ void FieldObjectStep(struct MapObject *mapObject, struct Sprite *sprite, bool8 ( FieldObjectUpdateSubpriority(mapObject, sprite); } -#define dirn2anim(name, table) \ +#define dirn2anim_2(name, table) \ extern const u8 table[5]; \ u8 name(u32 direction) \ { \ @@ -3575,4 +3607,4 @@ u8 name(u32 direction) \ return animIds[dirn2]; \ } -dirn2anim(GetFaceDirectionAnimId, gUnknown_0850DBA0); +dirn2anim_2(GetFaceDirectionAnimId, gUnknown_0850DBA0); From 119c0e96b58b33c0b72ad2a209b42e7aa93cdf19 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 16 Sep 2017 18:04:26 -0400 Subject: [PATCH 119/191] sub_8092A4C --- asm/field_map_obj.s | 25 ------------------------- src/field_map_obj.c | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 0a043682b..06c18eb2c 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,31 +5,6 @@ .text - thumb_func_start sub_8092A4C -sub_8092A4C: @ 8092A4C - push {lr} - adds r2, r0, 0 - ldr r1, =gUnknown_085094AC - b _08092A64 - .pool -_08092A58: - ldr r0, [r1] - cmp r0, r2 - bne _08092A62 - adds r0, r1, 0 - b _08092A6C -_08092A62: - adds r1, 0x8 -_08092A64: - ldr r0, [r1] - cmp r0, 0 - bne _08092A58 - movs r0, 0 -_08092A6C: - pop {r1} - bx r1 - thumb_func_end sub_8092A4C - thumb_func_start npc_apply_anim_looping @ void npc_apply_anim_looping(struct npc_state *fieldObject, struct obj *object, u8 anim) npc_apply_anim_looping: @ 8092A70 diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 8bb20abb4..7caa6d03d 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -3539,6 +3539,27 @@ dirn2anim(sub_8092A1C, gUnknown_0850DB38) dirn2anim(sub_8092A2C, gUnknown_0850DB41) dirn2anim(get_run_image_anim_num, gUnknown_0850DB4A) +struct UnkStruct_085094AC { + const union AnimCmd **unk00; + u8 unk04[4]; +}; + +extern const struct UnkStruct_085094AC gUnknown_085094AC[]; + +const struct UnkStruct_085094AC *sub_8092A4C(const union AnimCmd **a0) +{ + const struct UnkStruct_085094AC *retval; + + for (retval = gUnknown_085094AC; retval->unk00 != NULL; retval ++) + { + if (retval->unk00 == a0) + { + return retval; + } + } + return NULL; +} + asm(".section .text.get_face_direction_anim_id"); void FieldObjectClearAnimIfSpecialAnimActive(struct MapObject *); From 589c34e30aa30236b13b7f6621808aca581675c3 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 16 Sep 2017 18:18:34 -0400 Subject: [PATCH 120/191] obj_npc_animation_step, npc_apply_anim_looping --- asm/field_map_obj.s | 79 --------------------------------------------- src/field_map_obj.c | 55 ++++++++++++++++++++++++++++--- 2 files changed, 50 insertions(+), 84 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 06c18eb2c..1c4b5a145 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,85 +5,6 @@ .text - thumb_func_start npc_apply_anim_looping -@ void npc_apply_anim_looping(struct npc_state *fieldObject, struct obj *object, u8 anim) -npc_apply_anim_looping: @ 8092A70 - push {r4,lr} - adds r4, r1, 0 - lsls r2, 24 - lsrs r2, 24 - ldrb r0, [r0, 0x1] - lsls r0, 27 - cmp r0, 0 - blt _08092AB2 - adds r0, r4, 0 - adds r0, 0x2A - strb r2, [r0] - ldr r0, [r4, 0x8] - bl sub_8092A4C - adds r1, r4, 0 - adds r1, 0x2B - cmp r0, 0 - beq _08092AAA - ldrb r2, [r1] - ldrb r3, [r0, 0x4] - cmp r2, r3 - bne _08092AA0 - ldrb r0, [r0, 0x7] - b _08092AA8 -_08092AA0: - ldrb r3, [r0, 0x5] - cmp r2, r3 - bne _08092AAA - ldrb r0, [r0, 0x6] -_08092AA8: - strb r0, [r1] -_08092AAA: - ldrb r1, [r1] - adds r0, r4, 0 - bl SeekSpriteAnim -_08092AB2: - pop {r4} - pop {r0} - bx r0 - thumb_func_end npc_apply_anim_looping - - thumb_func_start obj_npc_animation_step -@ void obj_npc_animation_step(struct npc_state *fieldObject, struct obj *object, u8 anim) -obj_npc_animation_step: @ 8092AB8 - push {r4,lr} - adds r4, r1, 0 - lsls r2, 24 - lsrs r2, 24 - ldrb r0, [r0, 0x1] - lsls r0, 27 - cmp r0, 0 - blt _08092AF0 - adds r0, r4, 0 - adds r0, 0x2A - strb r2, [r0] - ldr r0, [r4, 0x8] - bl sub_8092A4C - adds r2, r0, 0 - cmp r2, 0 - beq _08092AF0 - ldrb r1, [r2, 0x5] - adds r0, r4, 0 - adds r0, 0x2B - ldrb r0, [r0] - ldrb r3, [r2, 0x4] - cmp r0, r3 - bhi _08092AEA - ldrb r1, [r2, 0x4] -_08092AEA: - adds r0, r4, 0 - bl SeekSpriteAnim -_08092AF0: - pop {r4} - pop {r0} - bx r0 - thumb_func_end obj_npc_animation_step - thumb_func_start sub_8092AF8 sub_8092AF8: @ 8092AF8 push {lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 7caa6d03d..f47639a9e 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -3540,19 +3540,19 @@ dirn2anim(sub_8092A2C, gUnknown_0850DB41) dirn2anim(get_run_image_anim_num, gUnknown_0850DB4A) struct UnkStruct_085094AC { - const union AnimCmd **unk00; - u8 unk04[4]; + const union AnimCmd *const *anims; + u8 animPos[4]; }; extern const struct UnkStruct_085094AC gUnknown_085094AC[]; -const struct UnkStruct_085094AC *sub_8092A4C(const union AnimCmd **a0) +static const struct UnkStruct_085094AC *sub_8092A4C(const union AnimCmd *const *anims) { const struct UnkStruct_085094AC *retval; - for (retval = gUnknown_085094AC; retval->unk00 != NULL; retval ++) + for (retval = gUnknown_085094AC; retval->anims != NULL; retval ++) { - if (retval->unk00 == a0) + if (retval->anims == anims) { return retval; } @@ -3560,6 +3560,51 @@ const struct UnkStruct_085094AC *sub_8092A4C(const union AnimCmd **a0) return NULL; } +void npc_apply_anim_looping(struct MapObject *mapObject, struct Sprite *sprite, u8 animNum) +{ + const struct UnkStruct_085094AC *unk85094AC; + + if (!mapObject->mapobj_bit_12) + { + sprite->animNum = animNum; + unk85094AC = sub_8092A4C(sprite->anims); + if (unk85094AC != NULL) + { + if (sprite->animCmdIndex == unk85094AC->animPos[0]) + { + sprite->animCmdIndex = unk85094AC->animPos[3]; + } + else if (sprite->animCmdIndex == unk85094AC->animPos[1]) + { + sprite->animCmdIndex = unk85094AC->animPos[2]; + } + } + SeekSpriteAnim(sprite, sprite->animCmdIndex); + } +} + +void obj_npc_animation_step(struct MapObject *mapObject, struct Sprite *sprite, u8 animNum) +{ + const struct UnkStruct_085094AC *unk85094AC; + + if (!mapObject->mapobj_bit_12) + { + u8 animPos; + + sprite->animNum = animNum; + unk85094AC = sub_8092A4C(sprite->anims); + if (unk85094AC != NULL) + { + animPos = unk85094AC->animPos[1]; + if (sprite->animCmdIndex <= unk85094AC->animPos[0]) + { + animPos = unk85094AC->animPos[0]; + } + SeekSpriteAnim(sprite, animPos); + } + } +} + asm(".section .text.get_face_direction_anim_id"); void FieldObjectClearAnimIfSpecialAnimActive(struct MapObject *); From edd5c81a8ee249625dbd015c80e0e0442776bde9 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 16 Sep 2017 18:24:58 -0400 Subject: [PATCH 121/191] sub_8092AF8 --- asm/field_map_obj.s | 34 ---------------------------------- src/field_map_obj.c | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 34 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 1c4b5a145..9a8294ab2 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,40 +5,6 @@ .text - thumb_func_start sub_8092AF8 -sub_8092AF8: @ 8092AF8 - push {lr} - lsls r1, 16 - lsrs r1, 16 - lsls r3, 16 - lsrs r3, 16 - lsls r0, 16 - asrs r0, 16 - lsls r2, 16 - asrs r2, 16 - cmp r0, r2 - ble _08092B12 - movs r0, 0x3 - b _08092B28 -_08092B12: - cmp r0, r2 - bge _08092B1A - movs r0, 0x4 - b _08092B28 -_08092B1A: - lsls r1, 16 - lsls r0, r3, 16 - cmp r1, r0 - bgt _08092B26 - movs r0, 0x1 - b _08092B28 -_08092B26: - movs r0, 0x2 -_08092B28: - pop {r1} - bx r1 - thumb_func_end sub_8092AF8 - thumb_func_start npc_set_running_behaviour_etc npc_set_running_behaviour_etc: @ 8092B2C push {r4,lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index f47639a9e..2987c09ee 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -3539,6 +3539,8 @@ dirn2anim(sub_8092A1C, gUnknown_0850DB38) dirn2anim(sub_8092A2C, gUnknown_0850DB41) dirn2anim(get_run_image_anim_num, gUnknown_0850DB4A) +// file boundary? + struct UnkStruct_085094AC { const union AnimCmd *const *anims; u8 animPos[4]; @@ -3605,6 +3607,25 @@ void obj_npc_animation_step(struct MapObject *mapObject, struct Sprite *sprite, } } +// file boundary? + +u8 sub_8092AF8(s16 x1, s16 y1, s16 x2, s16 y2) +{ + if (x1 > x2) + { + return DIR_WEST; + } + if (x1 < x2) + { + return DIR_EAST; + } + if (y1 > y2) + { + return DIR_NORTH; + } + return DIR_SOUTH; +} + asm(".section .text.get_face_direction_anim_id"); void FieldObjectClearAnimIfSpecialAnimActive(struct MapObject *); From ca88036ebe4441a2afc7267da1fda2a4b68820a8 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 16 Sep 2017 18:29:14 -0400 Subject: [PATCH 122/191] npc_set_running_behaviour_etc --- asm/field_map_obj.s | 39 --------------------------------------- include/global.fieldmap.h | 1 + src/field_map_obj.c | 9 +++++++++ 3 files changed, 10 insertions(+), 39 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 9a8294ab2..a6333af8f 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,45 +5,6 @@ .text - thumb_func_start npc_set_running_behaviour_etc -npc_set_running_behaviour_etc: @ 8092B2C - push {r4,lr} - mov r12, r0 - lsls r1, 24 - lsrs r1, 24 - movs r3, 0 - strb r1, [r0, 0x6] - adds r0, 0x21 - strb r3, [r0] - adds r0, 0x1 - strb r3, [r0] - ldr r4, =gSprites - mov r0, r12 - ldrb r2, [r0, 0x4] - lsls r0, r2, 4 - adds r0, r2 - lsls r0, 2 - adds r2, r4, 0 - adds r2, 0x1C - adds r0, r2 - ldr r2, =gUnknown_08505438 - lsls r1, 2 - adds r1, r2 - ldr r1, [r1] - str r1, [r0] - mov r0, r12 - ldrb r1, [r0, 0x4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - strh r3, [r0, 0x30] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end npc_set_running_behaviour_etc - thumb_func_start npc_running_behaviour_by_direction npc_running_behaviour_by_direction: @ 8092B78 lsls r0, 24 diff --git a/include/global.fieldmap.h b/include/global.fieldmap.h index f8955b9fd..4a587cf57 100644 --- a/include/global.fieldmap.h +++ b/include/global.fieldmap.h @@ -299,6 +299,7 @@ struct MapObject2 /*0x1F*/ u8 mapobj_unk_1F; /*0x20*/ u8 mapobj_unk_20; /*0x21*/ u8 mapobj_unk_21; + /*0x22*/ u8 animId; /*size = 0x24*/ }; diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 2987c09ee..06fd36be3 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -3626,6 +3626,15 @@ u8 sub_8092AF8(s16 x1, s16 y1, s16 x2, s16 y2) return DIR_SOUTH; } +void npc_set_running_behaviour_etc(struct MapObject *mapObject, u8 animPattern) +{ + mapObject->animPattern = animPattern; + mapObject->mapobj_unk_21 = 0; + mapObject->animId = 0; + gSprites[mapObject->spriteId].callback = gUnknown_08505438[animPattern]; + gSprites[mapObject->spriteId].data1 = 0; +} + asm(".section .text.get_face_direction_anim_id"); void FieldObjectClearAnimIfSpecialAnimActive(struct MapObject *); From 5812bc4ebe83bb80294bbb40846ae6fb1c76e5bf Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 16 Sep 2017 18:33:38 -0400 Subject: [PATCH 123/191] npc_block_way__next_tile --- asm/field_map_obj.s | 45 ----------------------------------------- include/data3.h | 1 - include/field_map_obj.h | 1 + src/field_map_obj.c | 13 ++++++++++++ 4 files changed, 14 insertions(+), 46 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index a6333af8f..e772aa178 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,51 +5,6 @@ .text - thumb_func_start npc_running_behaviour_by_direction -npc_running_behaviour_by_direction: @ 8092B78 - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_0850DB53 - adds r0, r1 - ldrb r0, [r0] - bx lr - .pool - thumb_func_end npc_running_behaviour_by_direction - - thumb_func_start npc_block_way__next_tile -npc_block_way__next_tile: @ 8092B88 - push {r4-r6,lr} - sub sp, 0x4 - adds r6, r0, 0 - lsls r5, r1, 24 - lsrs r5, 24 - ldrh r1, [r6, 0x10] - mov r0, sp - strh r1, [r0] - ldrh r0, [r6, 0x12] - mov r4, sp - adds r4, 0x2 - strh r0, [r4] - adds r0, r5, 0 - mov r1, sp - adds r2, r4, 0 - bl MoveCoords - mov r0, sp - movs r2, 0 - ldrsh r1, [r0, r2] - movs r0, 0 - ldrsh r2, [r4, r0] - adds r0, r6, 0 - adds r3, r5, 0 - bl npc_block_way - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end npc_block_way__next_tile - thumb_func_start npc_block_way @ u8 npc_block_way(struct npc_state *fieldObject, u16 x, u16 y, u8 direction) npc_block_way: @ 8092BC8 diff --git a/include/data3.h b/include/data3.h index b2b19b050..6d9bbd084 100755 --- a/include/data3.h +++ b/include/data3.h @@ -35,7 +35,6 @@ extern const u8 gUnknown_0850D8C4[5]; extern const u8 gUnknown_0850D8E8[4]; extern bool8 (*const gUnknown_0850DA64[])(struct MapObject *, struct Sprite *, u8, bool8(u8)); - extern const u8 gUnknown_0850DBA0[5]; #endif //GUARD_DATA3_H diff --git a/include/field_map_obj.h b/include/field_map_obj.h index 03ba36e87..a952cfac6 100755 --- a/include/field_map_obj.h +++ b/include/field_map_obj.h @@ -68,6 +68,7 @@ u8 GetStepInPlaceDelay8AnimId(u32); u8 GetStepInPlaceDelay16AnimId(u32); u8 GetStepInPlaceDelay32AnimId(u32); u8 npc_block_way(struct MapObject *, s16, s16, u32); +void MoveCoords(u8, s16 *, s16 *); // Exported data declarations diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 06fd36be3..93baccf36 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -3635,6 +3635,19 @@ void npc_set_running_behaviour_etc(struct MapObject *mapObject, u8 animPattern) gSprites[mapObject->spriteId].data1 = 0; } +dirn2anim(npc_running_behaviour_by_direction, gUnknown_0850DB53) + +bool8 npc_block_way__next_tile(struct MapObject *mapObject, u8 direction) +{ + s16 x; + s16 y; + + x = mapObject->coords2.x; + y = mapObject->coords2.y; + MoveCoords(direction, &x, &y); + return npc_block_way(mapObject, x, y, direction); +} + asm(".section .text.get_face_direction_anim_id"); void FieldObjectClearAnimIfSpecialAnimActive(struct MapObject *); From fedbcd7bb7202f37f4a3a017a2f4c1fe296a6ae3 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 16 Sep 2017 18:42:35 -0400 Subject: [PATCH 124/191] npc_block_way --- asm/field_map_obj.s | 102 ---------------------------------- include/field_ground_effect.h | 1 + include/fieldmap.h | 3 + src/field_map_obj.c | 24 +++++++- 4 files changed, 27 insertions(+), 103 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index e772aa178..2c9418165 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,108 +5,6 @@ .text - thumb_func_start npc_block_way -@ u8 npc_block_way(struct npc_state *fieldObject, u16 x, u16 y, u8 direction) -npc_block_way: @ 8092BC8 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - adds r6, r0, 0 - lsls r1, 16 - lsls r2, 16 - lsls r3, 24 - lsrs r7, r3, 24 - mov r8, r7 - lsrs r0, r1, 16 - mov r9, r0 - asrs r5, r1, 16 - lsrs r0, r2, 16 - mov r10, r0 - asrs r4, r2, 16 - adds r0, r6, 0 - adds r1, r5, 0 - adds r2, r4, 0 - bl IsCoordOutsideFieldObjectMovementRect - lsls r0, 24 - cmp r0, 0 - beq _08092BFE - movs r0, 0x1 - b _08092C7E -_08092BFE: - adds r0, r5, 0 - adds r1, r4, 0 - bl MapGridIsImpassableAt - lsls r0, 24 - cmp r0, 0 - bne _08092C40 - adds r0, r5, 0 - adds r1, r4, 0 - bl GetMapBorderIdAt - movs r1, 0x1 - negs r1, r1 - cmp r0, r1 - beq _08092C40 - adds r0, r6, 0 - adds r1, r5, 0 - adds r2, r4, 0 - adds r3, r7, 0 - bl IsMetatileDirectionallyImpassable - lsls r0, 24 - cmp r0, 0 - bne _08092C40 - ldrb r0, [r6, 0x1] - lsrs r0, 7 - cmp r0, 0 - beq _08092C44 - mov r0, r8 - bl CanCameraMoveInDirection - cmp r0, 0 - bne _08092C44 -_08092C40: - movs r0, 0x2 - b _08092C7E -_08092C44: - ldrb r0, [r6, 0xB] - lsls r0, 28 - lsrs r0, 28 - mov r2, r9 - lsls r1, r2, 16 - asrs r5, r1, 16 - mov r2, r10 - lsls r1, r2, 16 - asrs r4, r1, 16 - adds r1, r5, 0 - adds r2, r4, 0 - bl IsZCoordMismatchAt - lsls r0, 24 - cmp r0, 0 - beq _08092C68 - movs r0, 0x3 - b _08092C7E -_08092C68: - adds r0, r6, 0 - adds r1, r5, 0 - adds r2, r4, 0 - bl CheckForCollisionBetweenFieldObjects - lsls r0, 24 - cmp r0, 0 - bne _08092C7C - movs r0, 0 - b _08092C7E -_08092C7C: - movs r0, 0x4 -_08092C7E: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end npc_block_way - thumb_func_start sub_8092C8C sub_8092C8C: @ 8092C8C push {r4-r7,lr} diff --git a/include/field_ground_effect.h b/include/field_ground_effect.h index e2dc3a00f..398265b87 100644 --- a/include/field_ground_effect.h +++ b/include/field_ground_effect.h @@ -12,5 +12,6 @@ // Exported ROM declarations void SetObjectSubpriorityByZCoord(u8, struct Sprite *, u8); void InitObjectPriorityByZCoord(struct Sprite *, u8); +bool8 IsZCoordMismatchAt(u8, s16, s16); #endif //GUARD_FIELD_GROUND_EFFECT_H diff --git a/include/fieldmap.h b/include/fieldmap.h index 511c1061f..7174d98cc 100644 --- a/include/fieldmap.h +++ b/include/fieldmap.h @@ -12,5 +12,8 @@ // Exported ROM declarations u8 MapGridGetMetatileBehaviorAt(s16, s16); void GetCameraCoords(u16*, u16*); +bool8 MapGridIsImpassableAt(s16, s16); +s32 GetMapBorderIdAt(s16, s16); +bool32 CanCameraMoveInDirection(u8); #endif //GUARD_FIELDMAP_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 93baccf36..5ec5e68f4 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -121,6 +121,10 @@ void DoGroundEffects_OnFinishStep(struct MapObject *, struct Sprite *); void npc_obj_transfer_image_anim_pause_flag(struct MapObject *, struct Sprite *); void FieldObjectUpdateSubpriority(struct MapObject *, struct Sprite *); +bool8 IsCoordOutsideFieldObjectMovementRect(struct MapObject *fieldObject, s16 x, s16 y); +bool8 IsMetatileDirectionallyImpassable(struct MapObject *, s16, s16, u8); +bool8 CheckForCollisionBetweenFieldObjects(struct MapObject *, s16, s16); + // ROM data void (*const gUnknown_08505438[NUM_FIELD_MAP_OBJECT_TEMPLATES])(struct Sprite *); @@ -3637,7 +3641,7 @@ void npc_set_running_behaviour_etc(struct MapObject *mapObject, u8 animPattern) dirn2anim(npc_running_behaviour_by_direction, gUnknown_0850DB53) -bool8 npc_block_way__next_tile(struct MapObject *mapObject, u8 direction) +u8 npc_block_way__next_tile(struct MapObject *mapObject, u8 direction) { s16 x; s16 y; @@ -3648,6 +3652,24 @@ bool8 npc_block_way__next_tile(struct MapObject *mapObject, u8 direction) return npc_block_way(mapObject, x, y, direction); } +u8 npc_block_way(struct MapObject *mapObject, s16 x, s16 y, u32 dirn) +{ + u8 direction; + + direction = dirn; + if (IsCoordOutsideFieldObjectMovementRect(mapObject, x, y)) + return 1; + else if (MapGridIsImpassableAt(x, y) || GetMapBorderIdAt(x, y) == -1 || IsMetatileDirectionallyImpassable(mapObject, x, y, direction)) + return 2; + else if (mapObject->mapobj_bit_15 && !CanCameraMoveInDirection(direction)) + return 2; + else if (IsZCoordMismatchAt(mapObject->mapobj_unk_0B_0, x, y)) + return 3; + else if (CheckForCollisionBetweenFieldObjects(mapObject, x, y)) + return 4; + return 0; +} + asm(".section .text.get_face_direction_anim_id"); void FieldObjectClearAnimIfSpecialAnimActive(struct MapObject *); From 7d58ce75ad421762f9820492d77b6b05c632f60b Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 16 Sep 2017 18:52:20 -0400 Subject: [PATCH 125/191] sub_8092C8C --- asm/field_map_obj.s | 103 -------------------------------------------- src/field_map_obj.c | 42 ++++++++++++++++-- 2 files changed, 38 insertions(+), 107 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 2c9418165..166383b24 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,109 +5,6 @@ .text - thumb_func_start sub_8092C8C -sub_8092C8C: @ 8092C8C - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - adds r7, r0, 0 - lsls r1, 16 - lsls r2, 16 - lsls r3, 24 - lsrs r3, 24 - mov r8, r3 - lsrs r0, r1, 16 - mov r9, r0 - asrs r6, r1, 16 - lsrs r0, r2, 16 - mov r10, r0 - asrs r5, r2, 16 - adds r0, r7, 0 - adds r1, r6, 0 - adds r2, r5, 0 - bl IsCoordOutsideFieldObjectMovementRect - lsls r0, 24 - lsrs r0, 24 - negs r1, r0 - orrs r1, r0 - lsrs r4, r1, 31 - adds r0, r6, 0 - adds r1, r5, 0 - bl MapGridIsImpassableAt - lsls r0, 24 - cmp r0, 0 - bne _08092D04 - adds r0, r6, 0 - adds r1, r5, 0 - bl GetMapBorderIdAt - movs r1, 0x1 - negs r1, r1 - cmp r0, r1 - beq _08092D04 - adds r0, r7, 0 - adds r1, r6, 0 - adds r2, r5, 0 - mov r3, r8 - bl IsMetatileDirectionallyImpassable - lsls r0, 24 - cmp r0, 0 - bne _08092D04 - ldrb r0, [r7, 0x1] - lsrs r0, 7 - cmp r0, 0 - beq _08092D08 - mov r0, r8 - bl CanCameraMoveInDirection - cmp r0, 0 - bne _08092D08 -_08092D04: - movs r0, 0x2 - orrs r4, r0 -_08092D08: - ldrb r0, [r7, 0xB] - lsls r0, 28 - lsrs r0, 28 - mov r2, r9 - lsls r1, r2, 16 - asrs r6, r1, 16 - mov r2, r10 - lsls r1, r2, 16 - asrs r5, r1, 16 - adds r1, r6, 0 - adds r2, r5, 0 - bl IsZCoordMismatchAt - lsls r0, 24 - cmp r0, 0 - beq _08092D30 - movs r0, 0x4 - orrs r4, r0 - lsls r0, r4, 24 - lsrs r4, r0, 24 -_08092D30: - adds r0, r7, 0 - adds r1, r6, 0 - adds r2, r5, 0 - bl CheckForCollisionBetweenFieldObjects - lsls r0, 24 - cmp r0, 0 - beq _08092D48 - movs r0, 0x8 - orrs r4, r0 - lsls r0, r4, 24 - lsrs r4, r0, 24 -_08092D48: - adds r0, r4, 0 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_8092C8C - thumb_func_start IsCoordOutsideFieldObjectMovementRect @ bool8 IsCoordOutsideFieldObjectMovementRect(struct npc_state *fieldObject, u16 x, u16 y) IsCoordOutsideFieldObjectMovementRect: @ 8092D58 diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 5ec5e68f4..a876797a4 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -3658,18 +3658,52 @@ u8 npc_block_way(struct MapObject *mapObject, s16 x, s16 y, u32 dirn) direction = dirn; if (IsCoordOutsideFieldObjectMovementRect(mapObject, x, y)) + { return 1; - else if (MapGridIsImpassableAt(x, y) || GetMapBorderIdAt(x, y) == -1 || IsMetatileDirectionallyImpassable(mapObject, x, y, direction)) + } + if (MapGridIsImpassableAt(x, y) || GetMapBorderIdAt(x, y) == -1 || IsMetatileDirectionallyImpassable(mapObject, x, y, direction)) + { return 2; - else if (mapObject->mapobj_bit_15 && !CanCameraMoveInDirection(direction)) + } + if (mapObject->mapobj_bit_15 && !CanCameraMoveInDirection(direction)) + { return 2; - else if (IsZCoordMismatchAt(mapObject->mapobj_unk_0B_0, x, y)) + } + if (IsZCoordMismatchAt(mapObject->mapobj_unk_0B_0, x, y)) + { return 3; - else if (CheckForCollisionBetweenFieldObjects(mapObject, x, y)) + } + if (CheckForCollisionBetweenFieldObjects(mapObject, x, y)) + { return 4; + } return 0; } +u8 sub_8092C8C(struct MapObject *mapObject, s16 x, s16 y, u8 direction) +{ + u8 retval; + + retval = 0x00; + if (IsCoordOutsideFieldObjectMovementRect(mapObject, x, y)) + { + retval |= 1; + } + if (MapGridIsImpassableAt(x, y) || GetMapBorderIdAt(x, y) == -1 || IsMetatileDirectionallyImpassable(mapObject, x, y, direction) || (mapObject->mapobj_bit_15 && !CanCameraMoveInDirection(direction))) + { + retval |= 2; + } + if (IsZCoordMismatchAt(mapObject->mapobj_unk_0B_0, x, y)) + { + retval |= 4; + } + if (CheckForCollisionBetweenFieldObjects(mapObject, x, y)) + { + retval |= 8; + } + return retval; +} + asm(".section .text.get_face_direction_anim_id"); void FieldObjectClearAnimIfSpecialAnimActive(struct MapObject *); From 3e472ccc8b9231d3b447fdfdb706a3da5773546b Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 16 Sep 2017 21:04:52 -0400 Subject: [PATCH 126/191] IsCoordOutsideFieldObjectMovementRect --- asm/field_map_obj.s | 65 --------------------------------------------- src/field_map_obj.c | 34 +++++++++++++++++++++--- 2 files changed, 31 insertions(+), 68 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 166383b24..ee67bde5d 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,71 +5,6 @@ .text - thumb_func_start IsCoordOutsideFieldObjectMovementRect -@ bool8 IsCoordOutsideFieldObjectMovementRect(struct npc_state *fieldObject, u16 x, u16 y) -IsCoordOutsideFieldObjectMovementRect: @ 8092D58 - push {r4,r5,lr} - adds r4, r0, 0 - lsls r1, 16 - lsrs r3, r1, 16 - lsls r2, 16 - lsrs r5, r2, 16 - ldrb r1, [r4, 0x19] - movs r0, 0xF - ands r0, r1 - cmp r0, 0 - beq _08092D90 - lsls r1, 28 - lsrs r2, r1, 28 - ldrh r0, [r4, 0xC] - subs r2, r0, r2 - lsrs r1, 28 - adds r0, r1 - lsls r0, 16 - lsrs r1, r0, 16 - lsls r2, 16 - lsls r0, r3, 16 - asrs r3, r0, 16 - cmp r2, r0 - bgt _08092DBC - lsls r0, r1, 16 - asrs r0, 16 - cmp r0, r3 - blt _08092DBC -_08092D90: - ldrb r1, [r4, 0x19] - movs r0, 0xF0 - ands r0, r1 - cmp r0, 0 - beq _08092DC0 - lsls r1, 24 - lsrs r2, r1, 28 - ldrh r0, [r4, 0xE] - subs r2, r0, r2 - lsrs r1, 28 - adds r0, r1 - lsls r0, 16 - lsrs r1, r0, 16 - lsls r2, 16 - lsls r0, r5, 16 - asrs r3, r0, 16 - cmp r2, r0 - bgt _08092DBC - lsls r0, r1, 16 - asrs r0, 16 - cmp r0, r3 - bge _08092DC0 -_08092DBC: - movs r0, 0x1 - b _08092DC2 -_08092DC0: - movs r0, 0 -_08092DC2: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end IsCoordOutsideFieldObjectMovementRect - thumb_func_start IsMetatileDirectionallyImpassable @ bool8 IsMetatileDirectionallyImpassable(struct npc_state *fieldObject, u16 x, u16 y, u8 direction) IsMetatileDirectionallyImpassable: @ 8092DC8 diff --git a/src/field_map_obj.c b/src/field_map_obj.c index a876797a4..cc81bcb29 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -121,7 +121,7 @@ void DoGroundEffects_OnFinishStep(struct MapObject *, struct Sprite *); void npc_obj_transfer_image_anim_pause_flag(struct MapObject *, struct Sprite *); void FieldObjectUpdateSubpriority(struct MapObject *, struct Sprite *); -bool8 IsCoordOutsideFieldObjectMovementRect(struct MapObject *fieldObject, s16 x, s16 y); +bool8 IsCoordOutsideFieldObjectMovementRect(struct MapObject2 *fieldObject, s16 x, s16 y); bool8 IsMetatileDirectionallyImpassable(struct MapObject *, s16, s16, u8); bool8 CheckForCollisionBetweenFieldObjects(struct MapObject *, s16, s16); @@ -3657,7 +3657,7 @@ u8 npc_block_way(struct MapObject *mapObject, s16 x, s16 y, u32 dirn) u8 direction; direction = dirn; - if (IsCoordOutsideFieldObjectMovementRect(mapObject, x, y)) + if (IsCoordOutsideFieldObjectMovementRect((struct MapObject2 *)mapObject, x, y)) { return 1; } @@ -3685,7 +3685,7 @@ u8 sub_8092C8C(struct MapObject *mapObject, s16 x, s16 y, u8 direction) u8 retval; retval = 0x00; - if (IsCoordOutsideFieldObjectMovementRect(mapObject, x, y)) + if (IsCoordOutsideFieldObjectMovementRect((struct MapObject2 *)mapObject, x, y)) { retval |= 1; } @@ -3704,6 +3704,34 @@ u8 sub_8092C8C(struct MapObject *mapObject, s16 x, s16 y, u8 direction) return retval; } +bool8 IsCoordOutsideFieldObjectMovementRect(struct MapObject2 *mapObject, s16 x, s16 y) +{ + s16 left; + s16 right; + s16 top; + s16 bottom; + + if (mapObject->mapobj_unk_19 != 0) + { + left = mapObject->coords1.x - mapObject->mapobj_unk_19; + right = mapObject->coords1.x + mapObject->mapobj_unk_19; + if (left > x || right < x) + { + return TRUE; + } + } + if (mapObject->mapobj_unk_19b != 0) + { + top = mapObject->coords1.y - mapObject->mapobj_unk_19b; + bottom = mapObject->coords1.y + mapObject->mapobj_unk_19b; + if (top > y || bottom < y) + { + return TRUE; + } + } + return FALSE; +} + asm(".section .text.get_face_direction_anim_id"); void FieldObjectClearAnimIfSpecialAnimActive(struct MapObject *); From c98299386077d8a0c34150405ab0458f52fc2015 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 16 Sep 2017 21:08:44 -0400 Subject: [PATCH 127/191] IsMetatileDirectionallyImpassable --- asm/field_map_obj.s | 45 --------------------------------------------- include/data3.h | 2 ++ src/field_map_obj.c | 9 +++++++++ 3 files changed, 11 insertions(+), 45 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index ee67bde5d..7ad4c2818 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,51 +5,6 @@ .text - thumb_func_start IsMetatileDirectionallyImpassable -@ bool8 IsMetatileDirectionallyImpassable(struct npc_state *fieldObject, u16 x, u16 y, u8 direction) -IsMetatileDirectionallyImpassable: @ 8092DC8 - push {r4-r7,lr} - lsls r1, 16 - lsrs r6, r1, 16 - lsls r2, 16 - lsrs r7, r2, 16 - lsls r3, 24 - ldr r1, =gUnknown_0850DB5C - lsrs r3, 22 - subs r5, r3, 0x4 - adds r1, r5, r1 - ldrb r0, [r0, 0x1E] - ldr r1, [r1] - bl _call_via_r1 - lsls r0, 24 - cmp r0, 0 - bne _08092E0A - ldr r4, =gUnknown_0850DB6C - adds r4, r5, r4 - lsls r0, r6, 16 - asrs r0, 16 - lsls r1, r7, 16 - asrs r1, 16 - bl MapGridGetMetatileBehaviorAt - lsls r0, 24 - lsrs r0, 24 - ldr r1, [r4] - bl _call_via_r1 - lsls r0, 24 - cmp r0, 0 - beq _08092E18 -_08092E0A: - movs r0, 0x1 - b _08092E1A - .pool -_08092E18: - movs r0, 0 -_08092E1A: - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end IsMetatileDirectionallyImpassable - thumb_func_start CheckForCollisionBetweenFieldObjects @ bool8 CheckForCollisionBetweenFieldObjects(struct npc_state *fieldObject, u16 x, u16 y) CheckForCollisionBetweenFieldObjects: @ 8092E20 diff --git a/include/data3.h b/include/data3.h index 6d9bbd084..0c7de1272 100755 --- a/include/data3.h +++ b/include/data3.h @@ -34,6 +34,8 @@ extern const u8 gUnknown_0850D8AC[5]; extern const u8 gUnknown_0850D8C4[5]; extern const u8 gUnknown_0850D8E8[4]; extern bool8 (*const gUnknown_0850DA64[])(struct MapObject *, struct Sprite *, u8, bool8(u8)); +extern bool8 (*const gUnknown_0850DB5C[])(u8); +extern bool8 (*const gUnknown_0850DB6C[])(u8); extern const u8 gUnknown_0850DBA0[5]; diff --git a/src/field_map_obj.c b/src/field_map_obj.c index cc81bcb29..74c71333c 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -3732,6 +3732,15 @@ bool8 IsCoordOutsideFieldObjectMovementRect(struct MapObject2 *mapObject, s16 x, return FALSE; } +bool8 IsMetatileDirectionallyImpassable(struct MapObject *mapObject, s16 x, s16 y, u8 direction) +{ + if (gUnknown_0850DB5C[direction - 1](mapObject->mapobj_unk_1E) || gUnknown_0850DB6C[direction - 1](MapGridGetMetatileBehaviorAt(x, y))) + { + return TRUE; + } + return FALSE; +} + asm(".section .text.get_face_direction_anim_id"); void FieldObjectClearAnimIfSpecialAnimActive(struct MapObject *); From 951acc8c31029327775e90e21ba6c92c24ff8b3b Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 16 Sep 2017 21:29:04 -0400 Subject: [PATCH 128/191] CheckForCollisionBetweenFieldObjects --- asm/field_map_obj.s | 68 ----------------------------------- include/field_ground_effect.h | 1 + src/field_map_obj.c | 22 ++++++++++++ 3 files changed, 23 insertions(+), 68 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 7ad4c2818..58060b539 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,74 +5,6 @@ .text - thumb_func_start CheckForCollisionBetweenFieldObjects -@ bool8 CheckForCollisionBetweenFieldObjects(struct npc_state *fieldObject, u16 x, u16 y) -CheckForCollisionBetweenFieldObjects: @ 8092E20 - push {r4-r7,lr} - adds r6, r0, 0 - lsls r1, 16 - lsrs r7, r1, 16 - movs r4, 0 - lsls r2, 16 - asrs r5, r2, 16 -_08092E2E: - lsls r0, r4, 3 - adds r0, r4 - lsls r0, 2 - ldr r1, =gMapObjects - adds r2, r0, r1 - ldrb r0, [r2] - lsls r0, 31 - cmp r0, 0 - beq _08092E88 - cmp r2, r6 - beq _08092E88 - movs r0, 0x10 - ldrsh r1, [r2, r0] - lsls r0, r7, 16 - asrs r3, r0, 16 - cmp r1, r3 - bne _08092E58 - movs r1, 0x12 - ldrsh r0, [r2, r1] - cmp r0, r5 - beq _08092E68 -_08092E58: - movs r1, 0x14 - ldrsh r0, [r2, r1] - cmp r0, r3 - bne _08092E88 - movs r1, 0x16 - ldrsh r0, [r2, r1] - cmp r0, r5 - bne _08092E88 -_08092E68: - ldrb r0, [r6, 0xB] - lsls r0, 28 - lsrs r0, 28 - ldrb r1, [r2, 0xB] - lsls r1, 28 - lsrs r1, 28 - bl AreZCoordsCompatible - lsls r0, 24 - cmp r0, 0 - beq _08092E88 - movs r0, 0x1 - b _08092E94 - .pool -_08092E88: - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0xF - bls _08092E2E - movs r0, 0 -_08092E94: - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end CheckForCollisionBetweenFieldObjects - thumb_func_start sub_8092E9C sub_8092E9C: @ 8092E9C push {lr} diff --git a/include/field_ground_effect.h b/include/field_ground_effect.h index 398265b87..b7242ee7c 100644 --- a/include/field_ground_effect.h +++ b/include/field_ground_effect.h @@ -13,5 +13,6 @@ void SetObjectSubpriorityByZCoord(u8, struct Sprite *, u8); void InitObjectPriorityByZCoord(struct Sprite *, u8); bool8 IsZCoordMismatchAt(u8, s16, s16); +bool8 AreZCoordsCompatible(u8, u8); #endif //GUARD_FIELD_GROUND_EFFECT_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 74c71333c..9855321d3 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -3741,6 +3741,28 @@ bool8 IsMetatileDirectionallyImpassable(struct MapObject *mapObject, s16 x, s16 return FALSE; } +bool8 CheckForCollisionBetweenFieldObjects(struct MapObject *mapObject, s16 x, s16 y) +{ + u8 i; + struct MapObject *curObject; + + for (i = 0; i < NUM_FIELD_OBJECTS; i ++) + { + curObject = &gMapObjects[i]; + if (curObject->active && curObject != mapObject) + { + if ((curObject->coords2.x == x && curObject->coords2.y == y) || (curObject->coords3.x == x && curObject->coords3.y == y)) + { + if (AreZCoordsCompatible(mapObject->mapobj_unk_0B_0, curObject->mapobj_unk_0B_0)) + { + return TRUE; + } + } + } + } + return FALSE; +} + asm(".section .text.get_face_direction_anim_id"); void FieldObjectClearAnimIfSpecialAnimActive(struct MapObject *); From 996d9f4b4204396395e67e33a61ffd7111117fc2 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 16 Sep 2017 21:31:37 -0400 Subject: [PATCH 129/191] sub_8092E9C --- asm/field_map_obj.s | 44 -------------------------------------------- src/field_map_obj.c | 11 +++++++++++ 2 files changed, 11 insertions(+), 44 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 58060b539..68ec24489 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,50 +5,6 @@ .text - thumb_func_start sub_8092E9C -sub_8092E9C: @ 8092E9C - push {lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r0, 24 - lsls r1, 24 - lsrs r1, 24 - lsls r2, 24 - lsrs r2, 24 - mov r3, sp - bl TryGetFieldObjectIdByLocalIdAndMap - lsls r0, 24 - cmp r0, 0 - bne _08092EE8 - ldr r3, =gSprites - ldr r2, =gMapObjects - mov r0, sp - ldrb r1, [r0] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r1, [r0, 0x4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - ldrh r1, [r0, 0x3C] - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _08092EE8 - movs r0, 0x1 - b _08092EEA - .pool -_08092EE8: - movs r0, 0 -_08092EEA: - add sp, 0x4 - pop {r1} - bx r1 - thumb_func_end sub_8092E9C - thumb_func_start sub_8092EF0 sub_8092EF0: @ 8092EF0 push {lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 9855321d3..954088edc 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -3763,6 +3763,17 @@ bool8 CheckForCollisionBetweenFieldObjects(struct MapObject *mapObject, s16 x, s return FALSE; } +bool8 sub_8092E9C(u8 localId, u8 mapNum, u8 mapGroup) +{ + u8 mapObjectId; + + if (!TryGetFieldObjectIdByLocalIdAndMap(localId, mapNum, mapGroup, &mapObjectId) && gSprites[gMapObjects[mapObjectId].spriteId].data7 & 0x02) + { + return TRUE; + } + return FALSE; +} + asm(".section .text.get_face_direction_anim_id"); void FieldObjectClearAnimIfSpecialAnimActive(struct MapObject *); From f03c0dc3b4f763c65fefaa8cdf10a06b2fd00dc2 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 16 Sep 2017 21:39:29 -0400 Subject: [PATCH 130/191] MoveCoords --- asm/field_map_obj.s | 61 --------------------------------------------- include/data3.h | 1 + src/field_map_obj.c | 16 ++++++++++++ 3 files changed, 17 insertions(+), 61 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 68ec24489..bb612f3d5 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,67 +5,6 @@ .text - thumb_func_start sub_8092EF0 -sub_8092EF0: @ 8092EF0 - push {lr} - sub sp, 0x4 - lsls r0, 24 - lsrs r0, 24 - lsls r1, 24 - lsrs r1, 24 - lsls r2, 24 - lsrs r2, 24 - mov r3, sp - bl TryGetFieldObjectIdByLocalIdAndMap - lsls r0, 24 - cmp r0, 0 - bne _08092F2E - ldr r3, =gSprites - ldr r2, =gMapObjects - mov r0, sp - ldrb r1, [r0] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r0, [r0, 0x4] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r3 - ldrh r2, [r1, 0x3C] - movs r0, 0x4 - orrs r0, r2 - strh r0, [r1, 0x3C] -_08092F2E: - add sp, 0x4 - pop {r0} - bx r0 - .pool - thumb_func_end sub_8092EF0 - - thumb_func_start MoveCoords -@ void MoveCoords(u8 direction, u16 *x, u16 *y) -MoveCoords: @ 8092F3C - push {r4,lr} - lsls r0, 24 - ldr r3, =gUnknown_0850DB7C - lsrs r0, 22 - adds r0, r3 - ldrh r3, [r0] - ldrh r4, [r1] - adds r3, r4 - strh r3, [r1] - ldrh r0, [r0, 0x2] - ldrh r1, [r2] - adds r0, r1 - strh r0, [r2] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end MoveCoords - thumb_func_start sub_8092F60 sub_8092F60: @ 8092F60 push {r4,lr} diff --git a/include/data3.h b/include/data3.h index 0c7de1272..d5bccf296 100755 --- a/include/data3.h +++ b/include/data3.h @@ -36,6 +36,7 @@ extern const u8 gUnknown_0850D8E8[4]; extern bool8 (*const gUnknown_0850DA64[])(struct MapObject *, struct Sprite *, u8, bool8(u8)); extern bool8 (*const gUnknown_0850DB5C[])(u8); extern bool8 (*const gUnknown_0850DB6C[])(u8); +extern struct Coords16 gUnknown_0850DB7C[4]; extern const u8 gUnknown_0850DBA0[5]; diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 954088edc..56281a10d 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -3774,6 +3774,22 @@ bool8 sub_8092E9C(u8 localId, u8 mapNum, u8 mapGroup) return FALSE; } +void sub_8092EF0(u8 localId, u8 mapNum, u8 mapGroup) +{ + u8 mapObjectId; + + if (!TryGetFieldObjectIdByLocalIdAndMap(localId, mapNum, mapGroup, &mapObjectId)) + { + gSprites[gMapObjects[mapObjectId].spriteId].data7 |= 0x04; + } +} + +void MoveCoords(u8 direction, s16 *x, s16 *y) +{ + *x += gUnknown_0850DB7C[direction].x; + *y += gUnknown_0850DB7C[direction].y; +} + asm(".section .text.get_face_direction_anim_id"); void FieldObjectClearAnimIfSpecialAnimActive(struct MapObject *); From 76b68e039dc6cebee6da0f421be630f96ff75d2d Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 16 Sep 2017 21:45:18 -0400 Subject: [PATCH 131/191] MoveCoordsPixel --- asm/field_map_obj.s | 23 ----------------------- src/field_map_obj.c | 6 ++++++ 2 files changed, 6 insertions(+), 23 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index bb612f3d5..ffc55dd34 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,29 +5,6 @@ .text - thumb_func_start sub_8092F60 -sub_8092F60: @ 8092F60 - push {r4,lr} - lsls r0, 24 - ldr r3, =gUnknown_0850DB7C - lsrs r0, 22 - adds r0, r3 - ldrh r3, [r0] - lsls r3, 4 - ldrh r4, [r1] - adds r3, r4 - strh r3, [r1] - ldrh r0, [r0, 0x2] - lsls r0, 4 - ldrh r1, [r2] - adds r0, r1 - strh r0, [r2] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8092F60 - thumb_func_start sub_8092F88 sub_8092F88: @ 8092F88 push {r4-r7,lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 56281a10d..d52bd86f7 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -3790,6 +3790,12 @@ void MoveCoords(u8 direction, s16 *x, s16 *y) *y += gUnknown_0850DB7C[direction].y; } +void sub_8092F60(u8 direction, s16 *x, s16 *y) +{ + *x += gUnknown_0850DB7C[direction].x << 4; + *y += gUnknown_0850DB7C[direction].y << 4; +} + asm(".section .text.get_face_direction_anim_id"); void FieldObjectClearAnimIfSpecialAnimActive(struct MapObject *); From bd48354207282b2948a2198fec35ae36aaa89f7a Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 16 Sep 2017 21:52:55 -0400 Subject: [PATCH 132/191] sub_8092F88 --- asm/field_map_obj.s | 58 --------------------------------------------- src/field_map_obj.c | 31 ++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 58 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index ffc55dd34..5b5ec4e0d 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,64 +5,6 @@ .text - thumb_func_start sub_8092F88 -sub_8092F88: @ 8092F88 - push {r4-r7,lr} - adds r4, r1, 0 - ldr r1, [sp, 0x14] - lsls r0, 24 - lsls r3, 16 - lsrs r3, 16 - adds r7, r3, 0 - lsls r1, 16 - lsrs r6, r1, 16 - mov r12, r6 - ldr r1, =gUnknown_0850DB7C - lsrs r0, 22 - adds r5, r0, r1 - movs r0, 0 - ldrsh r1, [r5, r0] - cmp r1, 0 - ble _08092FB4 - lsls r0, r3, 16 - asrs r0, 16 - ldrh r3, [r4] - adds r0, r3 - strh r0, [r4] -_08092FB4: - cmp r1, 0 - bge _08092FC2 - ldrh r1, [r4] - lsls r0, r7, 16 - asrs r0, 16 - subs r1, r0 - strh r1, [r4] -_08092FC2: - movs r0, 0x2 - ldrsh r1, [r5, r0] - cmp r1, 0 - ble _08092FD4 - lsls r0, r6, 16 - asrs r0, 16 - ldrh r3, [r2] - adds r0, r3 - strh r0, [r2] -_08092FD4: - cmp r1, 0 - bge _08092FE4 - ldrh r1, [r2] - mov r3, r12 - lsls r0, r3, 16 - asrs r0, 16 - subs r1, r0 - strh r1, [r2] -_08092FE4: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8092F88 - thumb_func_start sub_8092FF0 sub_8092FF0: @ 8092FF0 push {r4,r5,lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index d52bd86f7..4592c4dfe 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -3796,6 +3796,37 @@ void sub_8092F60(u8 direction, s16 *x, s16 *y) *y += gUnknown_0850DB7C[direction].y << 4; } +void sub_8092F88(u32 dirn, s16 *x, s16 *y, s16 dx, s16 dy) +{ + u8 direction; + s16 dx_2; + s16 dy_2; + s16 cur_x; + s16 cur_y; + + direction = dirn; + dx_2 = dx; + dy_2 = dy; + cur_x = gUnknown_0850DB7C[direction].x; + if (cur_x > 0) + { + *x += dx_2; + } + if (cur_x < 0) + { + *x -= dx_2; + } + cur_y = gUnknown_0850DB7C[direction].y; + if (cur_y > 0) + { + *y += dy_2; + } + if (cur_y < 0) + { + *y -= dy_2; + } +} + asm(".section .text.get_face_direction_anim_id"); void FieldObjectClearAnimIfSpecialAnimActive(struct MapObject *); From 3f2c6556cb25c178b29b016dd87bb706a7fb631c Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 16 Sep 2017 21:59:14 -0400 Subject: [PATCH 133/191] sub_8092FF0 --- asm/field_map_obj.s | 34 ---------------------------------- include/field_camera.h | 13 +++++++++++++ src/field_map_obj.c | 9 +++++++++ 3 files changed, 22 insertions(+), 34 deletions(-) create mode 100644 include/field_camera.h diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 5b5ec4e0d..a1d549266 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,40 +5,6 @@ .text - thumb_func_start sub_8092FF0 -sub_8092FF0: @ 8092FF0 - push {r4,r5,lr} - ldr r5, =gSaveBlock1Ptr - ldr r4, [r5] - ldrh r4, [r4] - lsls r0, 16 - asrs r0, 16 - subs r0, r4 - lsls r0, 4 - strh r0, [r2] - ldr r0, [r5] - ldrh r0, [r0, 0x2] - lsls r1, 16 - asrs r1, 16 - subs r1, r0 - lsls r1, 4 - strh r1, [r3] - ldr r1, =gUnknown_03005DEC - ldrh r0, [r2] - ldrh r1, [r1] - subs r0, r1 - strh r0, [r2] - ldr r1, =gUnknown_03005DE8 - ldrh r0, [r3] - ldrh r1, [r1] - subs r0, r1 - strh r0, [r3] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8092FF0 - thumb_func_start sub_8093038 sub_8093038: @ 8093038 push {r4-r7,lr} diff --git a/include/field_camera.h b/include/field_camera.h new file mode 100644 index 000000000..48c182c8e --- /dev/null +++ b/include/field_camera.h @@ -0,0 +1,13 @@ +#ifndef GUARD_FIELD_CAMERA_H +#define GUARD_FIELD_CAMERA_H + +// Exported type declarations + +// Exported RAM declarations + +extern u16 gUnknown_03005DEC; +extern u16 gUnknown_03005DE8; + +// Exported ROM declarations + +#endif //GUARD_FIELD_CAMERA_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 4592c4dfe..b8be79d73 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -20,6 +20,7 @@ #include "metatile_behavior.h" #include "field_effect.h" #include "field_effect_helpers.h" +#include "field_camera.h" #include "field_map_obj.h" #define NUM_FIELD_MAP_OBJECT_TEMPLATES 0x51 @@ -3827,6 +3828,14 @@ void sub_8092F88(u32 dirn, s16 *x, s16 *y, s16 dx, s16 dy) } } +void sub_8092FF0(s16 x, s16 y, s16 *dest_x, s16 *dest_y) +{ + *dest_x = (x - gSaveBlock1Ptr->pos.x) << 4; + *dest_y = (y - gSaveBlock1Ptr->pos.y) << 4; + *dest_x -= gUnknown_03005DEC; + *dest_y -= gUnknown_03005DE8; +} + asm(".section .text.get_face_direction_anim_id"); void FieldObjectClearAnimIfSpecialAnimActive(struct MapObject *); From 44e590add0b4f630397b9f9e206a9a66d1a41ccc Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 16 Sep 2017 22:15:54 -0400 Subject: [PATCH 134/191] sub_8093038 --- asm/field_map_obj.s | 82 ------------------------------------------ include/field_camera.h | 12 +++++++ src/field_map_obj.c | 27 ++++++++++++++ 3 files changed, 39 insertions(+), 82 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index a1d549266..d01dce512 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,88 +5,6 @@ .text - thumb_func_start sub_8093038 -sub_8093038: @ 8093038 - push {r4-r7,lr} - adds r7, r2, 0 - mov r12, r3 - lsls r0, 16 - lsrs r5, r0, 16 - lsls r1, 16 - lsrs r6, r1, 16 - ldr r0, =gUnknown_03005DEC - ldrh r0, [r0] - negs r0, r0 - ldr r1, =gUnknown_03005DD0 - ldr r2, [r1, 0x10] - subs r0, r2 - lsls r0, 16 - lsrs r3, r0, 16 - ldr r0, =gUnknown_03005DE8 - ldrh r0, [r0] - negs r0, r0 - ldr r1, [r1, 0x14] - subs r0, r1 - lsls r0, 16 - lsrs r4, r0, 16 - cmp r2, 0 - ble _08093072 - lsls r0, r3, 16 - movs r3, 0x80 - lsls r3, 13 - adds r0, r3 - lsrs r3, r0, 16 -_08093072: - cmp r2, 0 - bge _0809307E - lsls r0, r3, 16 - ldr r2, =0xfff00000 - adds r0, r2 - lsrs r3, r0, 16 -_0809307E: - cmp r1, 0 - ble _0809308C - lsls r0, r4, 16 - movs r2, 0x80 - lsls r2, 13 - adds r0, r2 - lsrs r4, r0, 16 -_0809308C: - cmp r1, 0 - bge _08093098 - lsls r0, r4, 16 - ldr r1, =0xfff00000 - adds r0, r1 - lsrs r4, r0, 16 -_08093098: - ldr r2, =gSaveBlock1Ptr - ldr r0, [r2] - ldrh r1, [r0] - lsls r0, r5, 16 - asrs r0, 16 - subs r0, r1 - lsls r0, 4 - lsls r1, r3, 16 - asrs r1, 16 - adds r1, r0 - strh r1, [r7] - ldr r0, [r2] - ldrh r1, [r0, 0x2] - lsls r0, r6, 16 - asrs r0, 16 - subs r0, r1 - lsls r0, 4 - lsls r1, r4, 16 - asrs r1, 16 - adds r1, r0 - mov r2, r12 - strh r1, [r2] - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8093038 - thumb_func_start sub_80930E0 sub_80930E0: @ 80930E0 push {r4-r6,lr} diff --git a/include/field_camera.h b/include/field_camera.h index 48c182c8e..9fbaac6a2 100644 --- a/include/field_camera.h +++ b/include/field_camera.h @@ -3,6 +3,18 @@ // Exported type declarations +struct CameraObject +{ + void (*callback)(struct CameraObject *); + u32 unk4; + s32 unk8; + s32 unkC; + s32 x; + s32 y; +}; + +extern struct CameraObject gUnknown_03005DD0; + // Exported RAM declarations extern u16 gUnknown_03005DEC; diff --git a/src/field_map_obj.c b/src/field_map_obj.c index b8be79d73..d4793b0a7 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -3836,6 +3836,33 @@ void sub_8092FF0(s16 x, s16 y, s16 *dest_x, s16 *dest_y) *dest_y -= gUnknown_03005DE8; } +void sub_8093038(s16 x, s16 y, s16 *dest_x, s16 *dest_y) +{ + s16 dx; + s16 dy; + + dx = -gUnknown_03005DEC - gUnknown_03005DD0.x; + dy = -gUnknown_03005DE8 - gUnknown_03005DD0.y; + if (gUnknown_03005DD0.x > 0) + { + dx += 0x10; + } + if (gUnknown_03005DD0.x < 0) + { + dx -= 0x10; + } + if (gUnknown_03005DD0.y > 0) + { + dy += 0x10; + } + if (gUnknown_03005DD0.y < 0) + { + dy -= 0x10; + } + *dest_x = ((x - gSaveBlock1Ptr->pos.x) << 4) + dx; + *dest_y = ((y - gSaveBlock1Ptr->pos.y) << 4) + dy; +} + asm(".section .text.get_face_direction_anim_id"); void FieldObjectClearAnimIfSpecialAnimActive(struct MapObject *); From 812ad017e892ff3d93b3df8310335287a556e871 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 16 Sep 2017 22:19:23 -0400 Subject: [PATCH 135/191] sub_80930E0 --- asm/field_map_obj.s | 40 ---------------------------------------- include/field_map_obj.h | 2 +- src/field_map_obj.c | 7 +++++++ 3 files changed, 8 insertions(+), 41 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index d01dce512..941c3e7f5 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,46 +5,6 @@ .text - thumb_func_start sub_80930E0 -sub_80930E0: @ 80930E0 - push {r4-r6,lr} - mov r6, r8 - push {r6} - adds r6, r0, 0 - mov r8, r1 - adds r4, r2, 0 - adds r5, r3, 0 - lsls r4, 16 - lsrs r4, 16 - lsls r5, 16 - lsrs r5, 16 - movs r1, 0 - ldrsh r0, [r6, r1] - mov r2, r8 - movs r3, 0 - ldrsh r1, [r2, r3] - adds r2, r6, 0 - mov r3, r8 - bl sub_8093038 - lsls r4, 16 - asrs r4, 16 - ldrh r0, [r6] - adds r4, r0 - strh r4, [r6] - lsls r5, 16 - asrs r5, 16 - mov r1, r8 - ldrh r1, [r1] - adds r5, r1 - mov r2, r8 - strh r5, [r2] - pop {r3} - mov r8, r3 - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_80930E0 - thumb_func_start GetFieldObjectMovingCameraOffset @ void GetFieldObjectMovingCameraOffset(s16 *x, s16 *y) GetFieldObjectMovingCameraOffset: @ 809312C diff --git a/include/field_map_obj.h b/include/field_map_obj.h index a952cfac6..23749c91a 100755 --- a/include/field_map_obj.h +++ b/include/field_map_obj.h @@ -37,7 +37,7 @@ void pal_patch_for_npc(u16, u8); void sub_808E16C(s16, s16); void sub_8092FF0(s16, s16, s16 *, s16 *); u8 FieldObjectDirectionToImageAnimId(u8); -void sub_80930E0(s16 *, s16 *, u8, u8); +void sub_80930E0(s16 *, s16 *, s16, s16); void FieldObjectClearAnim(struct MapObject *); void SpawnFieldObjectsInView(s16, s16); u8 sprite_new(u8, u8, s16, s16, u8, u8); diff --git a/src/field_map_obj.c b/src/field_map_obj.c index d4793b0a7..eb9ed2129 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -3863,6 +3863,13 @@ void sub_8093038(s16 x, s16 y, s16 *dest_x, s16 *dest_y) *dest_y = ((y - gSaveBlock1Ptr->pos.y) << 4) + dy; } +void sub_80930E0(s16 *x, s16 *y, s16 dx, s16 dy) +{ + sub_8093038(*x, *y, x, y); + *x += dx; + *y += dy; +} + asm(".section .text.get_face_direction_anim_id"); void FieldObjectClearAnimIfSpecialAnimActive(struct MapObject *); From eb41c57ecdd008de76b2aa0ad4849a27ea222007 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 16 Sep 2017 22:23:48 -0400 Subject: [PATCH 136/191] GetFieldObjectMovingCameraOffset --- asm/field_map_obj.s | 40 ---------------------------------------- src/field_map_obj.c | 22 ++++++++++++++++++++++ 2 files changed, 22 insertions(+), 40 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 941c3e7f5..79786b208 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,46 +5,6 @@ .text - thumb_func_start GetFieldObjectMovingCameraOffset -@ void GetFieldObjectMovingCameraOffset(s16 *x, s16 *y) -GetFieldObjectMovingCameraOffset: @ 809312C - push {lr} - adds r2, r0, 0 - movs r0, 0 - strh r0, [r2] - strh r0, [r1] - ldr r3, =gUnknown_03005DD0 - ldr r0, [r3, 0x10] - cmp r0, 0 - ble _08093142 - movs r0, 0x1 - strh r0, [r2] -_08093142: - ldr r0, [r3, 0x10] - cmp r0, 0 - bge _0809314E - ldrh r0, [r2] - subs r0, 0x1 - strh r0, [r2] -_0809314E: - ldr r2, [r3, 0x14] - cmp r2, 0 - ble _0809315A - ldrh r0, [r1] - adds r0, 0x1 - strh r0, [r1] -_0809315A: - cmp r2, 0 - bge _08093164 - ldrh r0, [r1] - subs r0, 0x1 - strh r0, [r1] -_08093164: - pop {r0} - bx r0 - .pool - thumb_func_end GetFieldObjectMovingCameraOffset - thumb_func_start FieldObjectMoveDestCoords @ void FieldObjectMoveDestCoords(struct npc_state *fieldObject, u8 direction) FieldObjectMoveDestCoords: @ 809316C diff --git a/src/field_map_obj.c b/src/field_map_obj.c index eb9ed2129..de72478cf 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -3870,6 +3870,28 @@ void sub_80930E0(s16 *x, s16 *y, s16 dx, s16 dy) *y += dy; } +void GetFieldObjectMovingCameraOffset(s16 *x, s16 *y) +{ + *x = 0; + *y = 0; + if (gUnknown_03005DD0.x > 0) + { + (*x) ++; + } + if (gUnknown_03005DD0.x < 0) + { + (*x) --; + } + if (gUnknown_03005DD0.y > 0) + { + (*y) ++; + } + if (gUnknown_03005DD0.y < 0) + { + (*y) --; + } +} + asm(".section .text.get_face_direction_anim_id"); void FieldObjectClearAnimIfSpecialAnimActive(struct MapObject *); From 64d3a67b0c1750d4ff6f1011b62c0525c335f88e Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 16 Sep 2017 22:27:04 -0400 Subject: [PATCH 137/191] FieldObjectMoveDestCoords --- asm/field_map_obj.s | 19 ------------------- src/field_map_obj.c | 10 ++++++++++ 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 79786b208..f0bb2ed2e 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,25 +5,6 @@ .text - thumb_func_start FieldObjectMoveDestCoords -@ void FieldObjectMoveDestCoords(struct npc_state *fieldObject, u8 direction) -FieldObjectMoveDestCoords: @ 809316C - push {r4,lr} - lsls r1, 24 - lsrs r1, 24 - ldrh r4, [r0, 0x10] - strh r4, [r2] - ldrh r0, [r0, 0x12] - strh r0, [r3] - adds r0, r1, 0 - adds r1, r2, 0 - adds r2, r3, 0 - bl MoveCoords - pop {r4} - pop {r0} - bx r0 - thumb_func_end FieldObjectMoveDestCoords - thumb_func_start FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive @ bool8 FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive(struct npc_state *fieldObject) FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive: @ 809318C diff --git a/src/field_map_obj.c b/src/field_map_obj.c index de72478cf..fd03082fb 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -3892,6 +3892,16 @@ void GetFieldObjectMovingCameraOffset(s16 *x, s16 *y) } } +void FieldObjectMoveDestCoords(struct MapObject *mapObject, u32 dirn, s16 *x, s16 *y) +{ + u8 direction; + + direction = dirn; + *x = mapObject->coords2.x; + *y = mapObject->coords2.y; + MoveCoords(direction, x, y); +} + asm(".section .text.get_face_direction_anim_id"); void FieldObjectClearAnimIfSpecialAnimActive(struct MapObject *); From eb7e52d2a89d0d491722bcccaf28bfd7709bf371 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 16 Sep 2017 22:44:47 -0400 Subject: [PATCH 138/191] Deswiss the cheese --- asm/field_map_obj.s | 142 -------------------------------------- include/map_obj_8097404.h | 1 + ld_script.txt | 2 - src/field_map_obj.c | 59 +++++++++++++++- 4 files changed, 58 insertions(+), 146 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index f0bb2ed2e..b433e1aa0 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,148 +5,6 @@ .text - thumb_func_start FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive -@ bool8 FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive(struct npc_state *fieldObject) -FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive: @ 809318C - push {lr} - ldrb r1, [r0] - movs r0, 0x42 - ands r0, r1 - cmp r0, 0 - bne _0809319C - movs r0, 0 - b _0809319E -_0809319C: - movs r0, 0x1 -_0809319E: - pop {r1} - bx r1 - thumb_func_end FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive - - thumb_func_start FieldObjectIsSpecialAnimActive -@ bool8 FieldObjectIsSpecialAnimActive(struct npc_state *fieldObject) -FieldObjectIsSpecialAnimActive: @ 80931A4 - push {lr} - adds r1, r0, 0 - ldrb r0, [r1] - lsls r0, 25 - cmp r0, 0 - bge _080931BA - ldrb r0, [r1, 0x1C] - cmp r0, 0xFF - beq _080931BA - movs r0, 0x1 - b _080931BC -_080931BA: - movs r0, 0 -_080931BC: - pop {r1} - bx r1 - thumb_func_end FieldObjectIsSpecialAnimActive - - thumb_func_start FieldObjectSetSpecialAnim -@ bool8 FieldObjectSetSpecialAnim(struct npc_state *fieldObject, u8 animId) -FieldObjectSetSpecialAnim: @ 80931C0 - push {r4-r6,lr} - adds r4, r0, 0 - lsls r1, 24 - lsrs r5, r1, 24 - bl FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive - lsls r0, 24 - lsrs r6, r0, 24 - cmp r6, 0 - bne _08093200 - adds r0, r4, 0 - bl npc_sync_anim_pause_bits - strb r5, [r4, 0x1C] - ldrb r0, [r4] - movs r1, 0x40 - orrs r0, r1 - movs r1, 0x7F - ands r0, r1 - strb r0, [r4] - ldr r2, =gSprites - ldrb r1, [r4, 0x4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - strh r6, [r0, 0x32] - movs r0, 0 - b _08093202 - .pool -_08093200: - movs r0, 0x1 -_08093202: - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end FieldObjectSetSpecialAnim - - thumb_func_start FieldObjectForceSetSpecialAnim -@ void FieldObjectForceSetSpecialAnim(struct npc_state *fieldObject, u8 animId) -FieldObjectForceSetSpecialAnim: @ 8093208 - push {r4,r5,lr} - adds r5, r0, 0 - lsls r4, r1, 24 - lsrs r4, 24 - bl FieldObjectClearAnimIfSpecialAnimActive - adds r0, r5, 0 - adds r1, r4, 0 - bl FieldObjectSetSpecialAnim - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end FieldObjectForceSetSpecialAnim - - thumb_func_start FieldObjectClearAnimIfSpecialAnimActive -@ void FieldObjectClearAnimIfSpecialAnimActive(struct npc_state *fieldObject) -FieldObjectClearAnimIfSpecialAnimActive: @ 8093224 - push {lr} - adds r1, r0, 0 - ldrb r0, [r1] - lsls r0, 25 - cmp r0, 0 - bge _08093236 - adds r0, r1, 0 - bl FieldObjectClearAnim -_08093236: - pop {r0} - bx r0 - thumb_func_end FieldObjectClearAnimIfSpecialAnimActive - - thumb_func_start FieldObjectClearAnim -@ void FieldObjectClearAnim(struct npc_state *fieldObject) -FieldObjectClearAnim: @ 809323C - movs r1, 0xFF - strb r1, [r0, 0x1C] - ldrb r2, [r0] - movs r1, 0x41 - negs r1, r1 - ands r1, r2 - movs r2, 0x7F - ands r1, r2 - strb r1, [r0] - ldr r3, =gSprites - ldrb r2, [r0, 0x4] - lsls r1, r2, 4 - adds r1, r2 - lsls r1, 2 - adds r1, r3 - movs r2, 0 - strh r2, [r1, 0x30] - ldrb r1, [r0, 0x4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - strh r2, [r0, 0x32] - bx lr - .pool - thumb_func_end FieldObjectClearAnim - - .section .text.get_simple_go_anim_id - thumb_func_start GetSimpleGoAnimId @ u8 GetSimpleGoAnimId(u8 direction) GetSimpleGoAnimId: @ 809335C diff --git a/include/map_obj_8097404.h b/include/map_obj_8097404.h index e3b2b1efc..851739114 100644 --- a/include/map_obj_8097404.h +++ b/include/map_obj_8097404.h @@ -11,5 +11,6 @@ // Exported ROM declarations void sub_8097AC8(struct Sprite *); +void npc_sync_anim_pause_bits(struct MapObject *); #endif //GUARD_MAP_OBJ_8097404_H diff --git a/ld_script.txt b/ld_script.txt index 0217fe0fb..2c5eb31a9 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -96,8 +96,6 @@ SECTIONS { asm/field_player_avatar.o(.text); src/field_map_obj.o(.text); asm/field_map_obj.o(.text); - src/field_map_obj.o(.text.get_face_direction_anim_id); - asm/field_map_obj.o(.text.get_simple_go_anim_id); asm/field_ground_effect.o(.text); asm/map_obj_8097404.o(.text); asm/field_message_box.o(.text); diff --git a/src/field_map_obj.c b/src/field_map_obj.c index fd03082fb..2fd6f57e5 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -125,6 +125,8 @@ void FieldObjectUpdateSubpriority(struct MapObject *, struct Sprite *); bool8 IsCoordOutsideFieldObjectMovementRect(struct MapObject2 *fieldObject, s16 x, s16 y); bool8 IsMetatileDirectionallyImpassable(struct MapObject *, s16, s16, u8); bool8 CheckForCollisionBetweenFieldObjects(struct MapObject *, s16, s16); +void FieldObjectClearAnimIfSpecialAnimActive(struct MapObject *); +void FieldObjectClearAnim(struct MapObject *); // ROM data @@ -3902,9 +3904,62 @@ void FieldObjectMoveDestCoords(struct MapObject *mapObject, u32 dirn, s16 *x, s1 MoveCoords(direction, x, y); } -asm(".section .text.get_face_direction_anim_id"); +// file boundary? -void FieldObjectClearAnimIfSpecialAnimActive(struct MapObject *); +bool8 FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive(struct MapObject *mapObject) +{ + if (mapObject->mapobj_bit_1 || mapObject->mapobj_bit_6) + { + return TRUE; + } + return FALSE; +} + +bool8 FieldObjectIsSpecialAnimActive(struct MapObject *mapObject) +{ + if (mapObject->mapobj_bit_6 && mapObject->mapobj_unk_1C != 0xFF) + { + return TRUE; + } + return FALSE; +} + +bool8 FieldObjectSetSpecialAnim(struct MapObject *mapObject, u8 specialAnimId) +{ + if (FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive(mapObject)) + { + return TRUE; + } + npc_sync_anim_pause_bits(mapObject); + mapObject->mapobj_unk_1C = specialAnimId; + mapObject->mapobj_bit_6 = TRUE; + mapObject->mapobj_bit_7 = FALSE; + gSprites[mapObject->spriteId].data2 = 0; + return FALSE; +} + +void FieldObjectForceSetSpecialAnim(struct MapObject *mapObject, u8 specialAnimId) +{ + FieldObjectClearAnimIfSpecialAnimActive(mapObject); + FieldObjectSetSpecialAnim(mapObject, specialAnimId); +} + +void FieldObjectClearAnimIfSpecialAnimActive(struct MapObject *mapObject) +{ + if (mapObject->mapobj_bit_6) + { + FieldObjectClearAnim(mapObject); + } +} + +void FieldObjectClearAnim(struct MapObject *mapObject) +{ + mapObject->mapobj_unk_1C = 0xFF; + mapObject->mapobj_bit_6 = FALSE; + mapObject->mapobj_bit_7 = FALSE; + gSprites[mapObject->spriteId].data1 = 0; + gSprites[mapObject->spriteId].data2 = 0; +} u8 FieldObjectCheckIfSpecialAnimFinishedOrInactive(struct MapObject *mapObject) { From d1666473d3a45b5407d5ca3514185d965394e0ed Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 16 Sep 2017 22:48:19 -0400 Subject: [PATCH 139/191] Another block of functions for getting anim IDs from directions --- asm/field_map_obj.s | 400 -------------------------------------------- src/field_map_obj.c | 16 ++ 2 files changed, 16 insertions(+), 400 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index b433e1aa0..6cabf2933 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,406 +5,6 @@ .text - thumb_func_start GetSimpleGoAnimId -@ u8 GetSimpleGoAnimId(u8 direction) -GetSimpleGoAnimId: @ 809335C - push {r4,lr} - sub sp, 0x8 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, =gUnknown_0850DBA5 - mov r0, sp - movs r2, 0x5 - bl memcpy - cmp r4, 0x4 - bls _08093374 - movs r4, 0 -_08093374: - mov r1, sp - adds r0, r1, r4 - ldrb r0, [r0] - add sp, 0x8 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end GetSimpleGoAnimId - - thumb_func_start GetGoSpeed0AnimId -@ u8 GetGoSpeed0AnimId(u8 direction) -GetGoSpeed0AnimId: @ 8093388 - push {r4,lr} - sub sp, 0x8 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, =gUnknown_0850DBAA - mov r0, sp - movs r2, 0x5 - bl memcpy - cmp r4, 0x4 - bls _080933A0 - movs r4, 0 -_080933A0: - mov r1, sp - adds r0, r1, r4 - ldrb r0, [r0] - add sp, 0x8 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end GetGoSpeed0AnimId - - thumb_func_start GetGoSpeed1AnimId -@ u8 GetGoSpeed1AnimId(u8 direction) -GetGoSpeed1AnimId: @ 80933B4 - push {r4,lr} - sub sp, 0x8 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, =gUnknown_0850DBAF - mov r0, sp - movs r2, 0x5 - bl memcpy - cmp r4, 0x4 - bls _080933CC - movs r4, 0 -_080933CC: - mov r1, sp - adds r0, r1, r4 - ldrb r0, [r0] - add sp, 0x8 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end GetGoSpeed1AnimId - - thumb_func_start GetGoSpeed2AnimId -@ u8 GetGoSpeed2AnimId(u8 direction) -GetGoSpeed2AnimId: @ 80933E0 - push {r4,lr} - sub sp, 0x8 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, =gUnknown_0850DBB4 - mov r0, sp - movs r2, 0x5 - bl memcpy - cmp r4, 0x4 - bls _080933F8 - movs r4, 0 -_080933F8: - mov r1, sp - adds r0, r1, r4 - ldrb r0, [r0] - add sp, 0x8 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end GetGoSpeed2AnimId - - thumb_func_start GetGoSpeed3AnimId -@ u8 GetGoSpeed3AnimId(u8 direction) -GetGoSpeed3AnimId: @ 809340C - push {r4,lr} - sub sp, 0x8 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, =gUnknown_0850DBB9 - mov r0, sp - movs r2, 0x5 - bl memcpy - cmp r4, 0x4 - bls _08093424 - movs r4, 0 -_08093424: - mov r1, sp - adds r0, r1, r4 - ldrb r0, [r0] - add sp, 0x8 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end GetGoSpeed3AnimId - - thumb_func_start sub_8093438 -@ u8 sub_8093438(u8 direction) -sub_8093438: @ 8093438 - push {r4,lr} - sub sp, 0x8 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, =gUnknown_0850DBBE - mov r0, sp - movs r2, 0x5 - bl memcpy - cmp r4, 0x4 - bls _08093450 - movs r4, 0 -_08093450: - mov r1, sp - adds r0, r1, r4 - ldrb r0, [r0] - add sp, 0x8 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8093438 - - thumb_func_start GetRunAnimId -@ u8 GetRunAnimId(u8 direction) -GetRunAnimId: @ 8093464 - push {r4,lr} - sub sp, 0x8 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, =gUnknown_0850DBC3 - mov r0, sp - movs r2, 0x5 - bl memcpy - cmp r4, 0x4 - bls _0809347C - movs r4, 0 -_0809347C: - mov r1, sp - adds r0, r1, r4 - ldrb r0, [r0] - add sp, 0x8 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end GetRunAnimId - - thumb_func_start GetJumpLedgeAnimId -@ u8 GetJumpLedgeAnimId(u8 direction) -GetJumpLedgeAnimId: @ 8093490 - push {r4,lr} - sub sp, 0x8 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, =gUnknown_0850DBC8 - mov r0, sp - movs r2, 0x5 - bl memcpy - cmp r4, 0x4 - bls _080934A8 - movs r4, 0 -_080934A8: - mov r1, sp - adds r0, r1, r4 - ldrb r0, [r0] - add sp, 0x8 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end GetJumpLedgeAnimId - - thumb_func_start sub_80934BC -@ u8 sub_80934BC(u8 direction) -sub_80934BC: @ 80934BC - push {r4,lr} - sub sp, 0x8 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, =gUnknown_0850DBCD - mov r0, sp - movs r2, 0x5 - bl memcpy - cmp r4, 0x4 - bls _080934D4 - movs r4, 0 -_080934D4: - mov r1, sp - adds r0, r1, r4 - ldrb r0, [r0] - add sp, 0x8 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80934BC - - thumb_func_start sub_80934E8 -@ u8 sub_80934E8(u8 direction) -sub_80934E8: @ 80934E8 - push {r4,lr} - sub sp, 0x8 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, =gUnknown_0850DBD2 - mov r0, sp - movs r2, 0x5 - bl memcpy - cmp r4, 0x4 - bls _08093500 - movs r4, 0 -_08093500: - mov r1, sp - adds r0, r1, r4 - ldrb r0, [r0] - add sp, 0x8 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80934E8 - - thumb_func_start sub_8093514 -@ u8 sub_8093514(u8 direction) -sub_8093514: @ 8093514 - push {r4,lr} - sub sp, 0x8 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, =gUnknown_0850DBD7 - mov r0, sp - movs r2, 0x5 - bl memcpy - cmp r4, 0x4 - bls _0809352C - movs r4, 0 -_0809352C: - mov r1, sp - adds r0, r1, r4 - ldrb r0, [r0] - add sp, 0x8 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8093514 - - thumb_func_start sub_8093540 -@ u8 sub_8093540(u8 direction) -sub_8093540: @ 8093540 - push {r4,lr} - sub sp, 0x8 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, =gUnknown_0850DBDC - mov r0, sp - movs r2, 0x5 - bl memcpy - cmp r4, 0x4 - bls _08093558 - movs r4, 0 -_08093558: - mov r1, sp - adds r0, r1, r4 - ldrb r0, [r0] - add sp, 0x8 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8093540 - - thumb_func_start GetStepInPlaceDelay32AnimId -@ u8 GetStepInPlaceDelay32AnimId(u8 direction) -GetStepInPlaceDelay32AnimId: @ 809356C - push {r4,lr} - sub sp, 0x8 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, =gUnknown_0850DBE1 - mov r0, sp - movs r2, 0x5 - bl memcpy - cmp r4, 0x4 - bls _08093584 - movs r4, 0 -_08093584: - mov r1, sp - adds r0, r1, r4 - ldrb r0, [r0] - add sp, 0x8 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end GetStepInPlaceDelay32AnimId - - thumb_func_start GetStepInPlaceDelay16AnimId -@ u8 GetStepInPlaceDelay16AnimId(u8 direction) -GetStepInPlaceDelay16AnimId: @ 8093598 - push {r4,lr} - sub sp, 0x8 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, =gUnknown_0850DBE6 - mov r0, sp - movs r2, 0x5 - bl memcpy - cmp r4, 0x4 - bls _080935B0 - movs r4, 0 -_080935B0: - mov r1, sp - adds r0, r1, r4 - ldrb r0, [r0] - add sp, 0x8 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end GetStepInPlaceDelay16AnimId - - thumb_func_start GetStepInPlaceDelay8AnimId -@ u8 GetStepInPlaceDelay8AnimId(u8 direction) -GetStepInPlaceDelay8AnimId: @ 80935C4 - push {r4,lr} - sub sp, 0x8 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, =gUnknown_0850DBEB - mov r0, sp - movs r2, 0x5 - bl memcpy - cmp r4, 0x4 - bls _080935DC - movs r4, 0 -_080935DC: - mov r1, sp - adds r0, r1, r4 - ldrb r0, [r0] - add sp, 0x8 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end GetStepInPlaceDelay8AnimId - - thumb_func_start GetStepInPlaceDelay4AnimId -@ u8 GetStepInPlaceDelay4AnimId(u8 direction) -GetStepInPlaceDelay4AnimId: @ 80935F0 - push {r4,lr} - sub sp, 0x8 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, =gUnknown_0850DBF0 - mov r0, sp - movs r2, 0x5 - bl memcpy - cmp r4, 0x4 - bls _08093608 - movs r4, 0 -_08093608: - mov r1, sp - adds r0, r1, r4 - ldrb r0, [r0] - add sp, 0x8 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end GetStepInPlaceDelay4AnimId - thumb_func_start FieldObjectFaceOppositeDirection @ bool8 FieldObjectFaceOppositeDirection(struct npc_state *fieldObject, u8 direction) FieldObjectFaceOppositeDirection: @ 809361C diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 2fd6f57e5..a1eccc9cb 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -4026,3 +4026,19 @@ u8 name(u32 direction) \ } dirn2anim_2(GetFaceDirectionAnimId, gUnknown_0850DBA0); +dirn2anim_2(GetSimpleGoAnimId, gUnknown_0850DBA5); +dirn2anim_2(GetGoSpeed0AnimId, gUnknown_0850DBAA); +dirn2anim_2(GetGoSpeed1AnimId, gUnknown_0850DBAF); +dirn2anim_2(GetGoSpeed2AnimId, gUnknown_0850DBB4); +dirn2anim_2(GetGoSpeed3AnimId, gUnknown_0850DBB9); +dirn2anim_2(sub_8093438, gUnknown_0850DBBE); +dirn2anim_2(GetRunAnimId, gUnknown_0850DBC3); +dirn2anim_2(GetJumpLedgeAnimId, gUnknown_0850DBC8); +dirn2anim_2(sub_80934BC, gUnknown_0850DBCD); +dirn2anim_2(sub_80934E8, gUnknown_0850DBD2); +dirn2anim_2(sub_8093514, gUnknown_0850DBD7); +dirn2anim_2(sub_8093540, gUnknown_0850DBDC); +dirn2anim_2(GetStepInPlaceDelay32AnimId, gUnknown_0850DBE1); +dirn2anim_2(GetStepInPlaceDelay16AnimId, gUnknown_0850DBE6); +dirn2anim_2(GetStepInPlaceDelay8AnimId, gUnknown_0850DBEB); +dirn2anim_2(GetStepInPlaceDelay4AnimId, gUnknown_0850DBF0); From 08cb777fd788fd7cfc44d0d41d7b2ba697a4ed9e Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 16 Sep 2017 22:54:15 -0400 Subject: [PATCH 140/191] FieldObjectFaceOppositeDirection --- asm/field_map_obj.s | 23 ----------------------- src/field_map_obj.c | 5 +++++ 2 files changed, 5 insertions(+), 23 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 6cabf2933..681bb1707 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,29 +5,6 @@ .text - thumb_func_start FieldObjectFaceOppositeDirection -@ bool8 FieldObjectFaceOppositeDirection(struct npc_state *fieldObject, u8 direction) -FieldObjectFaceOppositeDirection: @ 809361C - push {r4,lr} - adds r4, r0, 0 - lsls r0, r1, 24 - lsrs r0, 24 - bl GetOppositeDirection - lsls r0, 24 - lsrs r0, 24 - bl GetFaceDirectionAnimId - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 24 - adds r0, r4, 0 - bl FieldObjectSetSpecialAnim - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - thumb_func_end FieldObjectFaceOppositeDirection - thumb_func_start sub_8093648 sub_8093648: @ 8093648 push {r4,lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index a1eccc9cb..6e2512000 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -4042,3 +4042,8 @@ dirn2anim_2(GetStepInPlaceDelay32AnimId, gUnknown_0850DBE1); dirn2anim_2(GetStepInPlaceDelay16AnimId, gUnknown_0850DBE6); dirn2anim_2(GetStepInPlaceDelay8AnimId, gUnknown_0850DBEB); dirn2anim_2(GetStepInPlaceDelay4AnimId, gUnknown_0850DBF0); + +bool8 FieldObjectFaceOppositeDirection(struct MapObject *mapObject, u8 direction) +{ + return FieldObjectSetSpecialAnim(mapObject, GetFaceDirectionAnimId(GetOppositeDirection(direction))); +} From 95142069690b3d2ef30d759f99c0b3710eeab26a Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 16 Sep 2017 22:58:17 -0400 Subject: [PATCH 141/191] Another block of functions for getting anim ids given direction --- asm/field_map_obj.s | 240 -------------------------------------------- src/field_map_obj.c | 11 ++ 2 files changed, 11 insertions(+), 240 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 681bb1707..5a7c4061b 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,246 +5,6 @@ .text - thumb_func_start sub_8093648 -sub_8093648: @ 8093648 - push {r4,lr} - sub sp, 0x8 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, =gUnknown_0850DBF5 - mov r0, sp - movs r2, 0x5 - bl memcpy - cmp r4, 0x4 - bls _08093660 - movs r4, 0 -_08093660: - mov r1, sp - adds r0, r1, r4 - ldrb r0, [r0] - add sp, 0x8 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8093648 - - thumb_func_start sub_8093674 -sub_8093674: @ 8093674 - push {r4,lr} - sub sp, 0x8 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, =gUnknown_0850DBFA - mov r0, sp - movs r2, 0x5 - bl memcpy - cmp r4, 0x4 - bls _0809368C - movs r4, 0 -_0809368C: - mov r1, sp - adds r0, r1, r4 - ldrb r0, [r0] - add sp, 0x8 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8093674 - - thumb_func_start sub_80936A0 -sub_80936A0: @ 80936A0 - push {r4,lr} - sub sp, 0x8 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, =gUnknown_0850DBFF - mov r0, sp - movs r2, 0x5 - bl memcpy - cmp r4, 0x4 - bls _080936B8 - movs r4, 0 -_080936B8: - mov r1, sp - adds r0, r1, r4 - ldrb r0, [r0] - add sp, 0x8 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80936A0 - - thumb_func_start sub_80936CC -sub_80936CC: @ 80936CC - push {r4,lr} - sub sp, 0x8 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, =gUnknown_0850DC04 - mov r0, sp - movs r2, 0x5 - bl memcpy - cmp r4, 0x4 - bls _080936E4 - movs r4, 0 -_080936E4: - mov r1, sp - adds r0, r1, r4 - ldrb r0, [r0] - add sp, 0x8 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80936CC - - thumb_func_start sub_80936F8 -sub_80936F8: @ 80936F8 - push {r4,lr} - sub sp, 0x8 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, =gUnknown_0850DC09 - mov r0, sp - movs r2, 0x5 - bl memcpy - cmp r4, 0x4 - bls _08093710 - movs r4, 0 -_08093710: - mov r1, sp - adds r0, r1, r4 - ldrb r0, [r0] - add sp, 0x8 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80936F8 - - thumb_func_start sub_8093724 -sub_8093724: @ 8093724 - push {r4,lr} - sub sp, 0x8 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, =gUnknown_0850DC0E - mov r0, sp - movs r2, 0x5 - bl memcpy - cmp r4, 0x4 - bls _0809373C - movs r4, 0 -_0809373C: - mov r1, sp - adds r0, r1, r4 - ldrb r0, [r0] - add sp, 0x8 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8093724 - - thumb_func_start sub_8093750 -sub_8093750: @ 8093750 - push {r4,lr} - sub sp, 0x8 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, =gUnknown_0850DC13 - mov r0, sp - movs r2, 0x5 - bl memcpy - cmp r4, 0x4 - bls _08093768 - movs r4, 0 -_08093768: - mov r1, sp - adds r0, r1, r4 - ldrb r0, [r0] - add sp, 0x8 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8093750 - - thumb_func_start sub_809377C -sub_809377C: @ 809377C - push {r4,lr} - sub sp, 0x8 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, =gUnknown_0850DC18 - mov r0, sp - movs r2, 0x5 - bl memcpy - cmp r4, 0x4 - bls _08093794 - movs r4, 0 -_08093794: - mov r1, sp - adds r0, r1, r4 - ldrb r0, [r0] - add sp, 0x8 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_809377C - - thumb_func_start sub_80937A8 -sub_80937A8: @ 80937A8 - push {r4,lr} - sub sp, 0x8 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, =gUnknown_0850DC1D - mov r0, sp - movs r2, 0x5 - bl memcpy - cmp r4, 0x4 - bls _080937C0 - movs r4, 0 -_080937C0: - mov r1, sp - adds r0, r1, r4 - ldrb r0, [r0] - add sp, 0x8 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80937A8 - - thumb_func_start d2s_08064034 -d2s_08064034: @ 80937D4 - push {r4,lr} - sub sp, 0x8 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, =gUnknown_0850DC22 - mov r0, sp - movs r2, 0x5 - bl memcpy - cmp r4, 0x4 - bls _080937EC - movs r4, 0 -_080937EC: - mov r1, sp - adds r0, r1, r4 - ldrb r0, [r0] - add sp, 0x8 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end d2s_08064034 - thumb_func_start GetOppositeDirection @ u8 GetOppositeDirection(u8 direction) GetOppositeDirection: @ 8093800 diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 6e2512000..d0673fdbe 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -4047,3 +4047,14 @@ bool8 FieldObjectFaceOppositeDirection(struct MapObject *mapObject, u8 direction { return FieldObjectSetSpecialAnim(mapObject, GetFaceDirectionAnimId(GetOppositeDirection(direction))); } + +dirn2anim_2(sub_8093648, gUnknown_0850DBF5); +dirn2anim_2(sub_8093674, gUnknown_0850DBFA); +dirn2anim_2(sub_80936A0, gUnknown_0850DBFF); +dirn2anim_2(sub_80936CC, gUnknown_0850DC04); +dirn2anim_2(sub_80936F8, gUnknown_0850DC09); +dirn2anim_2(sub_8093724, gUnknown_0850DC0E); +dirn2anim_2(sub_8093750, gUnknown_0850DC13); +dirn2anim_2(sub_809377C, gUnknown_0850DC18); +dirn2anim_2(sub_80937A8, gUnknown_0850DC1D); +dirn2anim_2(d2s_08064034, gUnknown_0850DC22); From 0e3dbf32350d41ff871bffcdb4700dc635b243b7 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 16 Sep 2017 23:03:04 -0400 Subject: [PATCH 142/191] GetOppositeDirection --- asm/field_map_obj.s | 30 ------------------------------ src/field_map_obj.c | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 30 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 5a7c4061b..8066cfd1a 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,36 +5,6 @@ .text - thumb_func_start GetOppositeDirection -@ u8 GetOppositeDirection(u8 direction) -GetOppositeDirection: @ 8093800 - push {r4,lr} - sub sp, 0x8 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, =gUnknown_0850DC27 - mov r0, sp - movs r2, 0x8 - bl memcpy - subs r1, r4, 0x1 - lsls r0, r1, 24 - lsrs r0, 24 - cmp r0, 0x7 - bhi _08093828 - mov r2, sp - adds r0, r2, r1 - ldrb r0, [r0] - b _0809382A - .pool -_08093828: - adds r0, r4, 0 -_0809382A: - add sp, 0x8 - pop {r4} - pop {r1} - bx r1 - thumb_func_end GetOppositeDirection - thumb_func_start zffu_offset_calc zffu_offset_calc: @ 8093834 lsls r0, 24 diff --git a/src/field_map_obj.c b/src/field_map_obj.c index d0673fdbe..d17f77c1b 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -4058,3 +4058,17 @@ dirn2anim_2(sub_8093750, gUnknown_0850DC13); dirn2anim_2(sub_809377C, gUnknown_0850DC18); dirn2anim_2(sub_80937A8, gUnknown_0850DC1D); dirn2anim_2(d2s_08064034, gUnknown_0850DC22); + +extern const u8 gUnknown_0850DC27[8]; + +u8 GetOppositeDirection(u8 direction) +{ + u8 directions[sizeof gUnknown_0850DC27]; + + memcpy(directions, gUnknown_0850DC27, sizeof gUnknown_0850DC27); + if (direction < 1 || direction > (sizeof gUnknown_0850DC27)) + { + return direction; + } + return directions[direction - 1]; +} From 5f189fa53b6791c5d0e24b85228797606f719bdc Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 16 Sep 2017 23:05:53 -0400 Subject: [PATCH 143/191] state_to_direction memes --- asm/field_map_obj.s | 52 --------------------------------------------- include/data3.h | 4 +++- src/field_map_obj.c | 18 ++++++++++++++++ 3 files changed, 21 insertions(+), 53 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 8066cfd1a..c81ef0b06 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,58 +5,6 @@ .text - thumb_func_start zffu_offset_calc -zffu_offset_calc: @ 8093834 - lsls r0, 24 - lsls r1, 24 - lsrs r1, 24 - ldr r2, =gUnknown_0850DC2F - lsrs r0, 22 - subs r0, 0x5 - adds r1, r0 - adds r1, r2 - ldrb r0, [r1] - bx lr - .pool - thumb_func_end zffu_offset_calc - - thumb_func_start state_to_direction -state_to_direction: @ 809384C - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - lsls r1, 24 - lsrs r1, 24 - adds r0, r1, 0 - lsls r2, 24 - lsrs r2, 24 - cmp r1, 0 - beq _0809386C - cmp r2, 0 - beq _0809386C - cmp r1, 0x4 - bhi _0809386C - cmp r2, 0x4 - bls _08093870 -_0809386C: - movs r0, 0 - b _08093882 -_08093870: - adds r1, r2, 0 - bl zffu_offset_calc - ldr r2, =gUnknown_0850DC3F - lsls r1, r4, 2 - subs r1, 0x5 - adds r0, r1 - adds r0, r2 - ldrb r0, [r0] -_08093882: - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end state_to_direction - thumb_func_start FieldObjectExecSpecialAnim @ void FieldObjectExecSpecialAnim(struct npc_state *fieldObject, struct obj *object) FieldObjectExecSpecialAnim: @ 809388C diff --git a/include/data3.h b/include/data3.h index d5bccf296..a19aa6fe8 100755 --- a/include/data3.h +++ b/include/data3.h @@ -36,7 +36,9 @@ extern const u8 gUnknown_0850D8E8[4]; extern bool8 (*const gUnknown_0850DA64[])(struct MapObject *, struct Sprite *, u8, bool8(u8)); extern bool8 (*const gUnknown_0850DB5C[])(u8); extern bool8 (*const gUnknown_0850DB6C[])(u8); -extern struct Coords16 gUnknown_0850DB7C[4]; +extern const struct Coords16 gUnknown_0850DB7C[4]; +extern const u8 gUnknown_0850DC2F[4][4]; +extern const u8 gUnknown_0850DC3F[4][4]; extern const u8 gUnknown_0850DBA0[5]; diff --git a/src/field_map_obj.c b/src/field_map_obj.c index d17f77c1b..ba207e2bd 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -4072,3 +4072,21 @@ u8 GetOppositeDirection(u8 direction) } return directions[direction - 1]; } + +u32 zffu_offset_calc(u8 a0, u8 a1) +{ + return gUnknown_0850DC2F[a0 - 1][a1 - 1]; +} + +u32 state_to_direction(u8 a0, u32 a1, u32 a2) +{ + u32 zffuOffset; + u8 a1_2 = a1; + u8 a2_2 = a2; + if (a1_2 == 0 || a2_2 == 0 || a1_2 > DIR_EAST || a2_2 > DIR_EAST) + { + return 0; + } + zffuOffset = zffu_offset_calc(a1_2, a2); + return gUnknown_0850DC3F[a0 - 1][zffuOffset - 1]; +} From 4e22f1e55fd43ebfd4c94dc7c22aa6b403249370 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 16 Sep 2017 23:11:09 -0400 Subject: [PATCH 144/191] MapObjectExec***Anim --- asm/field_map_obj.s | 68 --------------------------------------------- include/data3.h | 2 ++ src/field_map_obj.c | 26 +++++++++++++++-- 3 files changed, 26 insertions(+), 70 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index c81ef0b06..c4da7b242 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,74 +5,6 @@ .text - thumb_func_start FieldObjectExecSpecialAnim -@ void FieldObjectExecSpecialAnim(struct npc_state *fieldObject, struct obj *object) -FieldObjectExecSpecialAnim: @ 809388C - push {r4,lr} - adds r4, r0, 0 - ldr r2, =gUnknown_0850DC50 - ldrb r0, [r4, 0x1C] - lsls r0, 2 - adds r0, r2 - movs r3, 0x32 - ldrsh r2, [r1, r3] - ldr r0, [r0] - lsls r2, 2 - adds r2, r0 - ldr r2, [r2] - adds r0, r4, 0 - bl _call_via_r2 - lsls r0, 24 - cmp r0, 0 - beq _080938B8 - ldrb r0, [r4] - movs r1, 0x80 - orrs r0, r1 - strb r0, [r4] -_080938B8: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectExecSpecialAnim - - thumb_func_start FieldObjectExecRegularAnim -@ bool8 FieldObjectExecRegularAnim(struct npc_state *fieldObject, struct obj *object) -FieldObjectExecRegularAnim: @ 80938C4 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - ldr r1, =gUnknown_0850DC50 - ldrb r0, [r4, 0x1C] - lsls r0, 2 - adds r0, r1 - movs r2, 0x32 - ldrsh r1, [r5, r2] - ldr r0, [r0] - lsls r1, 2 - adds r1, r0 - ldr r2, [r1] - adds r0, r4, 0 - adds r1, r5, 0 - bl _call_via_r2 - lsls r0, 24 - cmp r0, 0 - bne _080938F4 - movs r0, 0 - b _080938FE - .pool -_080938F4: - movs r0, 0xFF - strb r0, [r4, 0x1C] - movs r0, 0 - strh r0, [r5, 0x32] - movs r0, 0x1 -_080938FE: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end FieldObjectExecRegularAnim - thumb_func_start FieldObjectSetRegularAnim @ void FieldObjectSetRegularAnim(struct npc_state *fieldObject, struct obj *object, u8 animState) FieldObjectSetRegularAnim: @ 8093904 diff --git a/include/data3.h b/include/data3.h index a19aa6fe8..ef6f5193d 100755 --- a/include/data3.h +++ b/include/data3.h @@ -42,4 +42,6 @@ extern const u8 gUnknown_0850DC3F[4][4]; extern const u8 gUnknown_0850DBA0[5]; +extern bool8 (*const *const gUnknown_0850DC50[])(struct MapObject *, struct Sprite *); + #endif //GUARD_DATA3_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index ba207e2bd..9702385e4 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -4081,8 +4081,11 @@ u32 zffu_offset_calc(u8 a0, u8 a1) u32 state_to_direction(u8 a0, u32 a1, u32 a2) { u32 zffuOffset; - u8 a1_2 = a1; - u8 a2_2 = a2; + u8 a1_2; + u8 a2_2; + + a1_2 = a1; + a2_2 = a2; if (a1_2 == 0 || a2_2 == 0 || a1_2 > DIR_EAST || a2_2 > DIR_EAST) { return 0; @@ -4090,3 +4093,22 @@ u32 state_to_direction(u8 a0, u32 a1, u32 a2) zffuOffset = zffu_offset_calc(a1_2, a2); return gUnknown_0850DC3F[a0 - 1][zffuOffset - 1]; } + +void FieldObjectExecSpecialAnim(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (gUnknown_0850DC50[mapObject->mapobj_unk_1C][sprite->data2](mapObject, sprite)) + { + mapObject->mapobj_bit_7 = TRUE; + } +} + +bool8 FieldObjectExecRegularAnim(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (gUnknown_0850DC50[mapObject->mapobj_unk_1C][sprite->data2](mapObject, sprite)) + { + mapObject->mapobj_unk_1C = 0xFF; + sprite->data2 = 0; + return TRUE; + } + return FALSE; +} From 4ef7127561e4f2f60e2cfa6351b97143f08f6acb Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 16 Sep 2017 23:12:35 -0400 Subject: [PATCH 145/191] FieldObjectSetRegularAnim --- asm/field_map_obj.s | 9 --------- src/field_map_obj.c | 6 ++++++ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index c4da7b242..2d2c39ced 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,15 +5,6 @@ .text - thumb_func_start FieldObjectSetRegularAnim -@ void FieldObjectSetRegularAnim(struct npc_state *fieldObject, struct obj *object, u8 animState) -FieldObjectSetRegularAnim: @ 8093904 - movs r3, 0 - strb r2, [r0, 0x1C] - strh r3, [r1, 0x32] - bx lr - thumb_func_end FieldObjectSetRegularAnim - thumb_func_start an_look_any @ void an_look_any(struct npc_state *fieldObject, struct obj *object, u8 direction) an_look_any: @ 809390C diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 9702385e4..0629fd983 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -4112,3 +4112,9 @@ bool8 FieldObjectExecRegularAnim(struct MapObject *mapObject, struct Sprite *spr } return FALSE; } + +void FieldObjectSetRegularAnim(struct MapObject *mapObject, struct Sprite *sprite, u8 animId) +{ + mapObject->mapobj_unk_1C = animId; + sprite->data2 = 0; +} From 8e03a0199c3226ae5426319c0e820e3337840fb8 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 16 Sep 2017 23:20:44 -0400 Subject: [PATCH 146/191] an_look_any simple --- asm/field_map_obj.s | 74 --------------------------------------------- src/field_map_obj.c | 36 ++++++++++++++++++++++ 2 files changed, 36 insertions(+), 74 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 2d2c39ced..61d3ba152 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,80 +5,6 @@ .text - thumb_func_start an_look_any -@ void an_look_any(struct npc_state *fieldObject, struct obj *object, u8 direction) -an_look_any: @ 809390C - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - lsls r1, r2, 24 - lsrs r1, 24 - bl FieldObjectSetDirection - adds r0, r4, 0 - bl npc_coords_shift_still - ldrb r0, [r4, 0x18] - lsls r0, 28 - lsrs r0, 28 - bl get_go_image_anim_num - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r1, r5, 0 - bl obj_npc_animation_step - adds r2, r5, 0 - adds r2, 0x2C - ldrb r0, [r2] - movs r1, 0x40 - orrs r0, r1 - strb r0, [r2] - movs r0, 0x1 - strh r0, [r5, 0x32] - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end an_look_any - - thumb_func_start sub_8093950 -sub_8093950: @ 8093950 - push {lr} - movs r2, 0x1 - bl an_look_any - movs r0, 0x1 - pop {r1} - bx r1 - thumb_func_end sub_8093950 - - thumb_func_start sub_8093960 -sub_8093960: @ 8093960 - push {lr} - movs r2, 0x2 - bl an_look_any - movs r0, 0x1 - pop {r1} - bx r1 - thumb_func_end sub_8093960 - - thumb_func_start sub_8093970 -sub_8093970: @ 8093970 - push {lr} - movs r2, 0x3 - bl an_look_any - movs r0, 0x1 - pop {r1} - bx r1 - thumb_func_end sub_8093970 - - thumb_func_start sub_8093980 -sub_8093980: @ 8093980 - push {lr} - movs r2, 0x4 - bl an_look_any - movs r0, 0x1 - pop {r1} - bx r1 - thumb_func_end sub_8093980 - thumb_func_start npc_apply_direction @ void npc_apply_direction(struct npc_state *fieldObject, struct obj *object, u8 direction, u8 speed) npc_apply_direction: @ 8093990 diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 0629fd983..80f628bb5 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -1769,6 +1769,7 @@ u16 npc_paltag_by_palslot(u8 palSlot) } // Map Object Step Callbacks +// file boundary? null_object_step(NoMovement1, FALSE) @@ -4118,3 +4119,38 @@ void FieldObjectSetRegularAnim(struct MapObject *mapObject, struct Sprite *sprit mapObject->mapobj_unk_1C = animId; sprite->data2 = 0; } + +// file boundary? + +void an_look_any(struct MapObject *mapObject, struct Sprite *sprite, u8 direction) +{ + FieldObjectSetDirection(mapObject, direction); + npc_coords_shift_still(mapObject); + obj_npc_animation_step(mapObject, sprite, get_go_image_anim_num(mapObject->mapobj_unk_18)); + sprite->animPaused = TRUE; + sprite->data2 = 1; +} + +bool8 sub_8093950(struct MapObject *mapObject, struct Sprite *sprite) +{ + an_look_any(mapObject, sprite, DIR_SOUTH); + return TRUE; +} + +bool8 sub_8093960(struct MapObject *mapObject, struct Sprite *sprite) +{ + an_look_any(mapObject, sprite, DIR_NORTH); + return TRUE; +} + +bool8 sub_8093970(struct MapObject *mapObject, struct Sprite *sprite) +{ + an_look_any(mapObject, sprite, DIR_WEST); + return TRUE; +} + +bool8 sub_8093980(struct MapObject *mapObject, struct Sprite *sprite) +{ + an_look_any(mapObject, sprite, DIR_EAST); + return TRUE; +} From 432924e56d99d37eb721a03907b0eab943458b60 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 16 Sep 2017 23:31:43 -0400 Subject: [PATCH 147/191] npc_apply_direction --- asm/field_map_obj.s | 78 --------------------------------------- include/map_obj_8097404.h | 3 ++ src/field_map_obj.c | 20 ++++++++++ 3 files changed, 23 insertions(+), 78 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 61d3ba152..9b2689951 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,84 +5,6 @@ .text - thumb_func_start npc_apply_direction -@ void npc_apply_direction(struct npc_state *fieldObject, struct obj *object, u8 direction, u8 speed) -npc_apply_direction: @ 8093990 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x4 - adds r7, r0, 0 - mov r8, r1 - adds r4, r2, 0 - adds r6, r3, 0 - lsls r4, 24 - lsrs r4, 24 - lsls r6, 24 - lsrs r6, 24 - ldrh r1, [r7, 0x10] - mov r0, sp - strh r1, [r0] - ldrh r0, [r7, 0x12] - mov r5, sp - adds r5, 0x2 - strh r0, [r5] - adds r0, r7, 0 - adds r1, r4, 0 - bl FieldObjectSetDirection - adds r0, r4, 0 - mov r1, sp - adds r2, r5, 0 - bl MoveCoords - mov r0, sp - movs r2, 0 - ldrsh r1, [r0, r2] - movs r0, 0 - ldrsh r2, [r5, r0] - adds r0, r7, 0 - bl npc_coords_shift - mov r0, r8 - adds r1, r4, 0 - adds r2, r6, 0 - bl oamt_npc_ministep_reset - mov r4, r8 - adds r4, 0x2C - ldrb r1, [r4] - movs r0, 0x41 - negs r0, r0 - ands r0, r1 - strb r0, [r4] - ldr r0, =gUnknown_020375B8 - ldr r0, [r0] - cmp r0, 0 - beq _08093A0E - adds r0, r7, 0 - bl sub_8097F78 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x10 - beq _08093A0E - ldrb r0, [r4] - movs r1, 0x40 - orrs r0, r1 - strb r0, [r4] -_08093A0E: - ldrb r0, [r7] - movs r1, 0x4 - orrs r0, r1 - strb r0, [r7] - movs r0, 0x1 - mov r1, r8 - strh r0, [r1, 0x32] - add sp, 0x4 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end npc_apply_direction - thumb_func_start do_go_anim @ void do_go_anim(struct npc_state *fieldObject, struct obj *object, u8 direction, u8 speed) do_go_anim: @ 8093A2C diff --git a/include/map_obj_8097404.h b/include/map_obj_8097404.h index 851739114..afa7a3bae 100644 --- a/include/map_obj_8097404.h +++ b/include/map_obj_8097404.h @@ -8,9 +8,12 @@ // Exported type declarations // Exported RAM declarations +extern void *gUnknown_020375B8; // Exported ROM declarations void sub_8097AC8(struct Sprite *); void npc_sync_anim_pause_bits(struct MapObject *); +void oamt_npc_ministep_reset(struct Sprite *, u8, u8); +u8 sub_8097F78(struct MapObject *); #endif //GUARD_MAP_OBJ_8097404_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 80f628bb5..4f2a359e4 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -4154,3 +4154,23 @@ bool8 sub_8093980(struct MapObject *mapObject, struct Sprite *sprite) an_look_any(mapObject, sprite, DIR_EAST); return TRUE; } + +void npc_apply_direction(struct MapObject *mapObject, struct Sprite *sprite, u8 direction, u8 speed) +{ + s16 x; + s16 y; + + x = mapObject->coords2.x; + y = mapObject->coords2.y; + FieldObjectSetDirection(mapObject, direction); + MoveCoords(direction, &x, &y); + npc_coords_shift(mapObject, x, y); + oamt_npc_ministep_reset(sprite, direction, speed); + sprite->animPaused = FALSE; + if (gUnknown_020375B8 != NULL && sub_8097F78(mapObject) != 0x10) + { + sprite->animPaused = TRUE; + } + mapObject->mapobj_bit_2 = TRUE; + sprite->data2 = 1; +} From 529ccf9a960209333b21aab59b620330370cc791 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 16 Sep 2017 23:49:31 -0400 Subject: [PATCH 148/191] do_go_anim --- asm/field_map_obj.s | 47 --------------------------------------------- include/data3.h | 1 + src/field_map_obj.c | 9 +++++++++ 3 files changed, 10 insertions(+), 47 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 9b2689951..cd7145160 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,53 +5,6 @@ .text - thumb_func_start do_go_anim -@ void do_go_anim(struct npc_state *fieldObject, struct obj *object, u8 direction, u8 speed) -do_go_anim: @ 8093A2C - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x14 - adds r5, r0, 0 - mov r8, r1 - adds r4, r3, 0 - lsls r2, 24 - lsrs r2, 24 - lsls r4, 24 - lsrs r4, 24 - mov r1, sp - ldr r0, =gUnknown_0850DEE8 - ldm r0!, {r3,r6,r7} - stm r1!, {r3,r6,r7} - ldm r0!, {r3,r6} - stm r1!, {r3,r6} - adds r0, r5, 0 - mov r1, r8 - adds r3, r4, 0 - bl npc_apply_direction - lsls r4, 2 - mov r7, sp - adds r1, r7, r4 - ldrb r0, [r5, 0x18] - lsls r0, 28 - lsrs r0, 28 - ldr r1, [r1] - bl _call_via_r1 - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r5, 0 - mov r1, r8 - bl npc_apply_anim_looping - add sp, 0x14 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end do_go_anim - thumb_func_start do_run_anim @ void do_run_anim(struct npc_state *fieldObject, struct obj *object, u8 direction) do_run_anim: @ 8093A88 diff --git a/include/data3.h b/include/data3.h index ef6f5193d..9cd6e2fe1 100755 --- a/include/data3.h +++ b/include/data3.h @@ -43,5 +43,6 @@ extern const u8 gUnknown_0850DC3F[4][4]; extern const u8 gUnknown_0850DBA0[5]; extern bool8 (*const *const gUnknown_0850DC50[])(struct MapObject *, struct Sprite *); +extern u8 (*const gUnknown_0850DEE8[5])(u8); #endif //GUARD_DATA3_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 4f2a359e4..0e9086d33 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -4174,3 +4174,12 @@ void npc_apply_direction(struct MapObject *mapObject, struct Sprite *sprite, u8 mapObject->mapobj_bit_2 = TRUE; sprite->data2 = 1; } + +void do_go_anim(struct MapObject *mapObject, struct Sprite *sprite, u8 direction, u8 speed) +{ + u8 (*functions[ARRAY_COUNT(gUnknown_0850DEE8)])(u8); + + memcpy(functions, gUnknown_0850DEE8, sizeof gUnknown_0850DEE8); + npc_apply_direction(mapObject, sprite, direction, speed); + npc_apply_anim_looping(mapObject, sprite, functions[speed](mapObject->mapobj_unk_18)); +} From 7c8991842f10cce925a5b3a23f3887a0bb41ecb5 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 16 Sep 2017 23:52:50 -0400 Subject: [PATCH 149/191] do_run_anim --- asm/field_map_obj.s | 25 ------------------------- src/field_map_obj.c | 6 ++++++ 2 files changed, 6 insertions(+), 25 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index cd7145160..7aa32c862 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,31 +5,6 @@ .text - thumb_func_start do_run_anim -@ void do_run_anim(struct npc_state *fieldObject, struct obj *object, u8 direction) -do_run_anim: @ 8093A88 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - lsls r2, 24 - lsrs r2, 24 - movs r3, 0x1 - bl npc_apply_direction - ldrb r0, [r4, 0x18] - lsls r0, 28 - lsrs r0, 28 - bl get_run_image_anim_num - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r1, r5, 0 - bl npc_apply_anim_looping - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end do_run_anim - thumb_func_start npc_obj_ministep_stop_on_arrival @ bool8 npc_obj_ministep_stop_on_arrival(struct npc_state *fieldObject, struct obj *object) npc_obj_ministep_stop_on_arrival: @ 8093AB8 diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 0e9086d33..5e32d7330 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -4183,3 +4183,9 @@ void do_go_anim(struct MapObject *mapObject, struct Sprite *sprite, u8 direction npc_apply_direction(mapObject, sprite, direction, speed); npc_apply_anim_looping(mapObject, sprite, functions[speed](mapObject->mapobj_unk_18)); } + +void do_run_anim(struct MapObject *mapObject, struct Sprite *sprite, u8 direction) +{ + npc_apply_direction(mapObject, sprite, direction, 1); + npc_apply_anim_looping(mapObject, sprite, get_run_image_anim_num(mapObject->mapobj_unk_18)); +} From 0582b5cb909298b49e7f0588c042fb20a951be44 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 17 Sep 2017 08:05:33 -0400 Subject: [PATCH 150/191] npc_obj_ministep_stop_on_arrival --- asm/field_map_obj.s | 33 ------------------------- include/field_ground_effect.h | 4 ++++ include/field_map_obj.h | 2 ++ include/map_obj_8097404.h | 1 + src/field_map_obj.c | 45 +++++++++++++++++++---------------- 5 files changed, 32 insertions(+), 53 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 7aa32c862..25ec2cc28 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,39 +5,6 @@ .text - thumb_func_start npc_obj_ministep_stop_on_arrival -@ bool8 npc_obj_ministep_stop_on_arrival(struct npc_state *fieldObject, struct obj *object) -npc_obj_ministep_stop_on_arrival: @ 8093AB8 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - adds r0, r5, 0 - bl obj_npc_ministep - lsls r0, 24 - cmp r0, 0 - bne _08093ACE - movs r0, 0 - b _08093AEA -_08093ACE: - adds r0, r4, 0 - bl npc_coords_shift_still - ldrb r0, [r4] - movs r1, 0x8 - orrs r0, r1 - strb r0, [r4] - adds r2, r5, 0 - adds r2, 0x2C - ldrb r0, [r2] - movs r1, 0x40 - orrs r0, r1 - strb r0, [r2] - movs r0, 0x1 -_08093AEA: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end npc_obj_ministep_stop_on_arrival - thumb_func_start sub_8093AF0 @ void sub_8093AF0(struct npc_state *fieldObject, struct obj *object, u8 direction) sub_8093AF0: @ 8093AF0 diff --git a/include/field_ground_effect.h b/include/field_ground_effect.h index b7242ee7c..63b67ceaf 100644 --- a/include/field_ground_effect.h +++ b/include/field_ground_effect.h @@ -14,5 +14,9 @@ void SetObjectSubpriorityByZCoord(u8, struct Sprite *, u8); void InitObjectPriorityByZCoord(struct Sprite *, u8); bool8 IsZCoordMismatchAt(u8, s16, s16); bool8 AreZCoordsCompatible(u8, u8); +void FieldObjectUpdateSubpriority(struct MapObject *, struct Sprite *); +void DoGroundEffects_OnSpawn(struct MapObject *, struct Sprite *); +void DoGroundEffects_OnBeginStep(struct MapObject *, struct Sprite *); +void DoGroundEffects_OnFinishStep(struct MapObject *, struct Sprite *); #endif //GUARD_FIELD_GROUND_EFFECT_H diff --git a/include/field_map_obj.h b/include/field_map_obj.h index 23749c91a..40cc64054 100755 --- a/include/field_map_obj.h +++ b/include/field_map_obj.h @@ -39,6 +39,7 @@ void sub_8092FF0(s16, s16, s16 *, s16 *); u8 FieldObjectDirectionToImageAnimId(u8); void sub_80930E0(s16 *, s16 *, s16, s16); void FieldObjectClearAnim(struct MapObject *); +void FieldObjectClearAnimIfSpecialAnimActive(struct MapObject *); void SpawnFieldObjectsInView(s16, s16); u8 sprite_new(u8, u8, s16, s16, u8, u8); u8 AddPseudoFieldObject(u16, void (*)(struct Sprite *), s16, s16, u8); @@ -69,6 +70,7 @@ u8 GetStepInPlaceDelay16AnimId(u32); u8 GetStepInPlaceDelay32AnimId(u32); u8 npc_block_way(struct MapObject *, s16, s16, u32); void MoveCoords(u8, s16 *, s16 *); +bool8 FieldObjectIsSpecialAnimActive(struct MapObject *); // Exported data declarations diff --git a/include/map_obj_8097404.h b/include/map_obj_8097404.h index afa7a3bae..e5e6fba70 100644 --- a/include/map_obj_8097404.h +++ b/include/map_obj_8097404.h @@ -15,5 +15,6 @@ void sub_8097AC8(struct Sprite *); void npc_sync_anim_pause_bits(struct MapObject *); void oamt_npc_ministep_reset(struct Sprite *, u8, u8); u8 sub_8097F78(struct MapObject *); +bool8 obj_npc_ministep(struct Sprite *sprite); #endif //GUARD_MAP_OBJ_8097404_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 5e32d7330..cd840ba70 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -112,21 +112,14 @@ bool8 FieldObjectExecRegularAnim(struct MapObject *, struct Sprite *); void SetFieldObjectStepTimer(struct Sprite *, s16); bool8 RunFieldObjectStepTimer(struct Sprite *); bool8 npc_block_way__next_tile(struct MapObject *, u8); -u32 state_to_direction(u8, u32, u32); -void DoGroundEffects_OnSpawn(struct MapObject *, struct Sprite *); -void sub_80964E8(struct MapObject *, struct Sprite *); -bool8 FieldObjectIsSpecialAnimActive(struct MapObject *); -void FieldObjectExecSpecialAnim(struct MapObject *, struct Sprite *); -void DoGroundEffects_OnBeginStep(struct MapObject *, struct Sprite *); -void DoGroundEffects_OnFinishStep(struct MapObject *, struct Sprite *); -void npc_obj_transfer_image_anim_pause_flag(struct MapObject *, struct Sprite *); -void FieldObjectUpdateSubpriority(struct MapObject *, struct Sprite *); +static u32 state_to_direction(u8, u32, u32); +/*static*/ void sub_80964E8(struct MapObject *, struct Sprite *); +static void FieldObjectExecSpecialAnim(struct MapObject *, struct Sprite *); +/*static*/ void npc_obj_transfer_image_anim_pause_flag(struct MapObject *, struct Sprite *); -bool8 IsCoordOutsideFieldObjectMovementRect(struct MapObject2 *fieldObject, s16 x, s16 y); -bool8 IsMetatileDirectionallyImpassable(struct MapObject *, s16, s16, u8); -bool8 CheckForCollisionBetweenFieldObjects(struct MapObject *, s16, s16); -void FieldObjectClearAnimIfSpecialAnimActive(struct MapObject *); -void FieldObjectClearAnim(struct MapObject *); +static bool8 IsCoordOutsideFieldObjectMovementRect(struct MapObject2 *, s16, s16); +static bool8 IsMetatileDirectionallyImpassable(struct MapObject *, s16, s16, u8); +static bool8 CheckForCollisionBetweenFieldObjects(struct MapObject *, s16, s16); // ROM data @@ -3708,7 +3701,7 @@ u8 sub_8092C8C(struct MapObject *mapObject, s16 x, s16 y, u8 direction) return retval; } -bool8 IsCoordOutsideFieldObjectMovementRect(struct MapObject2 *mapObject, s16 x, s16 y) +static bool8 IsCoordOutsideFieldObjectMovementRect(struct MapObject2 *mapObject, s16 x, s16 y) { s16 left; s16 right; @@ -3736,7 +3729,7 @@ bool8 IsCoordOutsideFieldObjectMovementRect(struct MapObject2 *mapObject, s16 x, return FALSE; } -bool8 IsMetatileDirectionallyImpassable(struct MapObject *mapObject, s16 x, s16 y, u8 direction) +static bool8 IsMetatileDirectionallyImpassable(struct MapObject *mapObject, s16 x, s16 y, u8 direction) { if (gUnknown_0850DB5C[direction - 1](mapObject->mapobj_unk_1E) || gUnknown_0850DB6C[direction - 1](MapGridGetMetatileBehaviorAt(x, y))) { @@ -3745,7 +3738,7 @@ bool8 IsMetatileDirectionallyImpassable(struct MapObject *mapObject, s16 x, s16 return FALSE; } -bool8 CheckForCollisionBetweenFieldObjects(struct MapObject *mapObject, s16 x, s16 y) +static bool8 CheckForCollisionBetweenFieldObjects(struct MapObject *mapObject, s16 x, s16 y) { u8 i; struct MapObject *curObject; @@ -4074,12 +4067,12 @@ u8 GetOppositeDirection(u8 direction) return directions[direction - 1]; } -u32 zffu_offset_calc(u8 a0, u8 a1) +static u32 zffu_offset_calc(u8 a0, u8 a1) { return gUnknown_0850DC2F[a0 - 1][a1 - 1]; } -u32 state_to_direction(u8 a0, u32 a1, u32 a2) +static u32 state_to_direction(u8 a0, u32 a1, u32 a2) { u32 zffuOffset; u8 a1_2; @@ -4095,7 +4088,7 @@ u32 state_to_direction(u8 a0, u32 a1, u32 a2) return gUnknown_0850DC3F[a0 - 1][zffuOffset - 1]; } -void FieldObjectExecSpecialAnim(struct MapObject *mapObject, struct Sprite *sprite) +static void FieldObjectExecSpecialAnim(struct MapObject *mapObject, struct Sprite *sprite) { if (gUnknown_0850DC50[mapObject->mapobj_unk_1C][sprite->data2](mapObject, sprite)) { @@ -4189,3 +4182,15 @@ void do_run_anim(struct MapObject *mapObject, struct Sprite *sprite, u8 directio npc_apply_direction(mapObject, sprite, direction, 1); npc_apply_anim_looping(mapObject, sprite, get_run_image_anim_num(mapObject->mapobj_unk_18)); } + +bool8 npc_obj_ministep_stop_on_arrival(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (obj_npc_ministep(sprite)) + { + npc_coords_shift_still(mapObject); + mapObject->mapobj_bit_3 = TRUE; + sprite->animPaused = TRUE; + return TRUE; + } + return FALSE; +} From 6439551e1a1effa0282145627aaef934a1b4b797 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 17 Sep 2017 08:20:42 -0400 Subject: [PATCH 151/191] Another chunk of functions, including some expanded from macros --- asm/field_map_obj.s | 412 -------------------------------------- include/map_obj_8097404.h | 2 + src/field_map_obj.c | 61 ++++++ 3 files changed, 63 insertions(+), 412 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 25ec2cc28..c8fb45942 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,418 +5,6 @@ .text - thumb_func_start sub_8093AF0 -@ void sub_8093AF0(struct npc_state *fieldObject, struct obj *object, u8 direction) -sub_8093AF0: @ 8093AF0 - push {r4-r6,lr} - mov r6, r8 - push {r6} - sub sp, 0x4 - adds r6, r0, 0 - mov r8, r1 - lsls r5, r2, 24 - lsrs r5, 24 - ldrh r1, [r6, 0x10] - mov r0, sp - strh r1, [r0] - ldrh r0, [r6, 0x12] - mov r4, sp - adds r4, 0x2 - strh r0, [r4] - adds r0, r6, 0 - adds r1, r5, 0 - bl FieldObjectSetDirection - adds r0, r5, 0 - mov r1, sp - adds r2, r4, 0 - bl MoveCoords - mov r0, sp - movs r2, 0 - ldrsh r1, [r0, r2] - movs r0, 0 - ldrsh r2, [r4, r0] - adds r0, r6, 0 - bl npc_coords_shift - mov r0, r8 - adds r1, r5, 0 - bl sub_80976DC - mov r2, r8 - adds r2, 0x2C - ldrb r1, [r2] - movs r0, 0x41 - negs r0, r0 - ands r0, r1 - strb r0, [r2] - ldrb r0, [r6] - movs r1, 0x4 - orrs r0, r1 - strb r0, [r6] - movs r0, 0x1 - mov r1, r8 - strh r0, [r1, 0x32] - add sp, 0x4 - pop {r3} - mov r8, r3 - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_8093AF0 - - thumb_func_start sub_8093B60 -@ void sub_8093B60(struct npc_state *fieldObject, struct obj *object, u8 direction) -sub_8093B60: @ 8093B60 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - lsls r2, 24 - lsrs r2, 24 - bl sub_8093AF0 - ldrb r0, [r4, 0x18] - lsls r0, 28 - lsrs r0, 28 - bl get_go_image_anim_num - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r1, r5, 0 - bl npc_apply_anim_looping - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_8093B60 - - thumb_func_start an_walk_any_2 -@ bool8 an_walk_any_2(struct npc_state *fieldObject, struct obj *object) -an_walk_any_2: @ 8093B8C - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - adds r0, r5, 0 - bl sub_80976EC - lsls r0, 24 - cmp r0, 0 - bne _08093BA2 - movs r0, 0 - b _08093BBE -_08093BA2: - adds r0, r4, 0 - bl npc_coords_shift_still - ldrb r0, [r4] - movs r1, 0x8 - orrs r0, r1 - strb r0, [r4] - adds r2, r5, 0 - adds r2, 0x2C - ldrb r0, [r2] - movs r1, 0x40 - orrs r0, r1 - strb r0, [r2] - movs r0, 0x1 -_08093BBE: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end an_walk_any_2 - - thumb_func_start sub_8093BC4 -sub_8093BC4: @ 8093BC4 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x7 - bl sub_8093B60 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8093BE4 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8093BC4 - - thumb_func_start sub_8093BE4 -sub_8093BE4: @ 8093BE4 - push {r4,lr} - adds r4, r1, 0 - bl an_walk_any_2 - lsls r0, 24 - cmp r0, 0 - bne _08093BF6 - movs r0, 0 - b _08093BFC -_08093BF6: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_08093BFC: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8093BE4 - - thumb_func_start sub_8093C04 -sub_8093C04: @ 8093C04 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x8 - bl sub_8093B60 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8093C24 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8093C04 - - thumb_func_start sub_8093C24 -sub_8093C24: @ 8093C24 - push {r4,lr} - adds r4, r1, 0 - bl an_walk_any_2 - lsls r0, 24 - cmp r0, 0 - bne _08093C36 - movs r0, 0 - b _08093C3C -_08093C36: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_08093C3C: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8093C24 - - thumb_func_start sub_8093C44 -sub_8093C44: @ 8093C44 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x5 - bl sub_8093B60 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8093C64 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8093C44 - - thumb_func_start sub_8093C64 -sub_8093C64: @ 8093C64 - push {r4,lr} - adds r4, r1, 0 - bl an_walk_any_2 - lsls r0, 24 - cmp r0, 0 - bne _08093C76 - movs r0, 0 - b _08093C7C -_08093C76: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_08093C7C: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8093C64 - - thumb_func_start sub_8093C84 -sub_8093C84: @ 8093C84 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x6 - bl sub_8093B60 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8093CA4 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8093C84 - - thumb_func_start sub_8093CA4 -sub_8093CA4: @ 8093CA4 - push {r4,lr} - adds r4, r1, 0 - bl an_walk_any_2 - lsls r0, 24 - cmp r0, 0 - bne _08093CB6 - movs r0, 0 - b _08093CBC -_08093CB6: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_08093CBC: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8093CA4 - - thumb_func_start sub_8093CC4 -@ bool8 sub_8093CC4(struct npc_state *fieldObject, struct obj *object) -sub_8093CC4: @ 8093CC4 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x1 - bl sub_8093B60 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8093CE4 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8093CC4 - - thumb_func_start sub_8093CE4 -@ bool8 sub_8093CE4(struct npc_state *fieldObject, struct obj *object) -sub_8093CE4: @ 8093CE4 - push {r4,lr} - adds r4, r1, 0 - bl an_walk_any_2 - lsls r0, 24 - cmp r0, 0 - bne _08093CF6 - movs r0, 0 - b _08093CFC -_08093CF6: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_08093CFC: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8093CE4 - - thumb_func_start sub_8093D04 -sub_8093D04: @ 8093D04 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x2 - bl sub_8093B60 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8093D24 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8093D04 - - thumb_func_start sub_8093D24 -sub_8093D24: @ 8093D24 - push {r4,lr} - adds r4, r1, 0 - bl an_walk_any_2 - lsls r0, 24 - cmp r0, 0 - bne _08093D36 - movs r0, 0 - b _08093D3C -_08093D36: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_08093D3C: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8093D24 - - thumb_func_start sub_8093D44 -sub_8093D44: @ 8093D44 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x3 - bl sub_8093B60 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8093D64 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8093D44 - - thumb_func_start sub_8093D64 -sub_8093D64: @ 8093D64 - push {r4,lr} - adds r4, r1, 0 - bl an_walk_any_2 - lsls r0, 24 - cmp r0, 0 - bne _08093D76 - movs r0, 0 - b _08093D7C -_08093D76: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_08093D7C: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8093D64 - - thumb_func_start sub_8093D84 -sub_8093D84: @ 8093D84 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x4 - bl sub_8093B60 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8093DA4 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8093D84 - - thumb_func_start sub_8093DA4 -sub_8093DA4: @ 8093DA4 - push {r4,lr} - adds r4, r1, 0 - bl an_walk_any_2 - lsls r0, 24 - cmp r0, 0 - bne _08093DB6 - movs r0, 0 - b _08093DBC -_08093DB6: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_08093DBC: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8093DA4 - thumb_func_start sub_8093DC4 sub_8093DC4: @ 8093DC4 push {r4,r5,lr} diff --git a/include/map_obj_8097404.h b/include/map_obj_8097404.h index e5e6fba70..85153f941 100644 --- a/include/map_obj_8097404.h +++ b/include/map_obj_8097404.h @@ -16,5 +16,7 @@ void npc_sync_anim_pause_bits(struct MapObject *); void oamt_npc_ministep_reset(struct Sprite *, u8, u8); u8 sub_8097F78(struct MapObject *); bool8 obj_npc_ministep(struct Sprite *sprite); +bool8 sub_80976EC(struct Sprite *sprite); +void sub_80976DC(struct Sprite *, u8); #endif //GUARD_MAP_OBJ_8097404_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index cd840ba70..bffce24ac 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -4194,3 +4194,64 @@ bool8 npc_obj_ministep_stop_on_arrival(struct MapObject *mapObject, struct Sprit } return FALSE; } + +void sub_8093AF0(struct MapObject *mapObject, struct Sprite *sprite, u8 direction) +{ + s16 x; + s16 y; + + x = mapObject->coords2.x; + y = mapObject->coords2.y; + FieldObjectSetDirection(mapObject, direction); + MoveCoords(direction, &x, &y); + npc_coords_shift(mapObject, x, y); + sub_80976DC(sprite, direction); + sprite->animPaused = FALSE; + mapObject->mapobj_bit_2 = TRUE; + sprite->data2 = 1; +} + +void sub_8093B60(struct MapObject *mapObject, struct Sprite *sprite, u8 direction) +{ + sub_8093AF0(mapObject, sprite, direction); + npc_apply_anim_looping(mapObject, sprite, get_go_image_anim_num(mapObject->mapobj_unk_18)); +} + +bool8 an_walk_any_2(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_80976EC(sprite)) + { + npc_coords_shift_still(mapObject); + mapObject->mapobj_bit_3 = TRUE; + sprite->animPaused = TRUE; + return TRUE; + } + return FALSE; +} + +#define an_walk_any_2_macro(name, dirn) \ +static bool8 name##_2(struct MapObject *, struct Sprite *);\ +bool8 name(struct MapObject *mapObject, struct Sprite *sprite)\ +{\ + sub_8093B60(mapObject, sprite, dirn);\ + return name##_2(mapObject, sprite);\ +}\ +static bool8 name##_2(struct MapObject *mapObject, struct Sprite *sprite)\ +{\ + if (an_walk_any_2(mapObject, sprite))\ + {\ + sprite->data2 = 2;\ + return TRUE;\ + }\ + return FALSE;\ +} + +an_walk_any_2_macro(sub_8093BC4, 7) +an_walk_any_2_macro(sub_8093C04, 8) +an_walk_any_2_macro(sub_8093C44, 5) +an_walk_any_2_macro(sub_8093C84, 6) +an_walk_any_2_macro(sub_8093CC4, 1) +an_walk_any_2_macro(sub_8093D04, 2) +an_walk_any_2_macro(sub_8093D44, 3) +an_walk_any_2_macro(sub_8093D84, 4) + From 501baffc48a505231e650f67576a844f4d0d74c9 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 17 Sep 2017 08:26:27 -0400 Subject: [PATCH 152/191] Yet another chunk of highly similar functions --- asm/field_map_obj.s | 305 -------------------------------------------- src/field_map_obj.c | 25 ++++ 2 files changed, 25 insertions(+), 305 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index c8fb45942..405abb959 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,311 +5,6 @@ .text - thumb_func_start sub_8093DC4 -sub_8093DC4: @ 8093DC4 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x7 - movs r3, 0 - bl do_go_anim - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8093DE4 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8093DC4 - - thumb_func_start sub_8093DE4 -@ bool8 sub_8093DE4(struct npc_state *fieldObject, struct obj *object) -sub_8093DE4: @ 8093DE4 - push {r4,lr} - adds r4, r1, 0 - bl npc_obj_ministep_stop_on_arrival - lsls r0, 24 - cmp r0, 0 - bne _08093DF6 - movs r0, 0 - b _08093DFC -_08093DF6: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_08093DFC: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8093DE4 - - thumb_func_start sub_8093E04 -sub_8093E04: @ 8093E04 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x8 - movs r3, 0 - bl do_go_anim - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8093E24 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8093E04 - - thumb_func_start sub_8093E24 -sub_8093E24: @ 8093E24 - push {r4,lr} - adds r4, r1, 0 - bl npc_obj_ministep_stop_on_arrival - lsls r0, 24 - cmp r0, 0 - bne _08093E36 - movs r0, 0 - b _08093E3C -_08093E36: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_08093E3C: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8093E24 - - thumb_func_start sub_8093E44 -sub_8093E44: @ 8093E44 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x5 - movs r3, 0 - bl do_go_anim - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8093E64 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8093E44 - - thumb_func_start sub_8093E64 -sub_8093E64: @ 8093E64 - push {r4,lr} - adds r4, r1, 0 - bl npc_obj_ministep_stop_on_arrival - lsls r0, 24 - cmp r0, 0 - bne _08093E76 - movs r0, 0 - b _08093E7C -_08093E76: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_08093E7C: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8093E64 - - thumb_func_start sub_8093E84 -sub_8093E84: @ 8093E84 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x6 - movs r3, 0 - bl do_go_anim - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8093EA4 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8093E84 - - thumb_func_start sub_8093EA4 -sub_8093EA4: @ 8093EA4 - push {r4,lr} - adds r4, r1, 0 - bl npc_obj_ministep_stop_on_arrival - lsls r0, 24 - cmp r0, 0 - bne _08093EB6 - movs r0, 0 - b _08093EBC -_08093EB6: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_08093EBC: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8093EA4 - - thumb_func_start sub_8093EC4 -sub_8093EC4: @ 8093EC4 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x1 - movs r3, 0 - bl do_go_anim - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8093EE4 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8093EC4 - - thumb_func_start sub_8093EE4 -sub_8093EE4: @ 8093EE4 - push {r4,lr} - adds r4, r1, 0 - bl npc_obj_ministep_stop_on_arrival - lsls r0, 24 - cmp r0, 0 - bne _08093EF6 - movs r0, 0 - b _08093EFC -_08093EF6: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_08093EFC: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8093EE4 - - thumb_func_start sub_8093F04 -sub_8093F04: @ 8093F04 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x2 - movs r3, 0 - bl do_go_anim - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8093F24 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8093F04 - - thumb_func_start sub_8093F24 -sub_8093F24: @ 8093F24 - push {r4,lr} - adds r4, r1, 0 - bl npc_obj_ministep_stop_on_arrival - lsls r0, 24 - cmp r0, 0 - bne _08093F36 - movs r0, 0 - b _08093F3C -_08093F36: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_08093F3C: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8093F24 - - thumb_func_start sub_8093F44 -sub_8093F44: @ 8093F44 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x3 - movs r3, 0 - bl do_go_anim - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8093F64 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8093F44 - - thumb_func_start sub_8093F64 -sub_8093F64: @ 8093F64 - push {r4,lr} - adds r4, r1, 0 - bl npc_obj_ministep_stop_on_arrival - lsls r0, 24 - cmp r0, 0 - bne _08093F76 - movs r0, 0 - b _08093F7C -_08093F76: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_08093F7C: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8093F64 - - thumb_func_start sub_8093F84 -sub_8093F84: @ 8093F84 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x4 - movs r3, 0 - bl do_go_anim - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8093FA4 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8093F84 - - thumb_func_start sub_8093FA4 -sub_8093FA4: @ 8093FA4 - push {r4,lr} - adds r4, r1, 0 - bl npc_obj_ministep_stop_on_arrival - lsls r0, 24 - cmp r0, 0 - bne _08093FB6 - movs r0, 0 - b _08093FBC -_08093FB6: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_08093FBC: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8093FA4 - thumb_func_start sub_8093FC4 sub_8093FC4: @ 8093FC4 push {r4-r7,lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index bffce24ac..648f6bd46 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -4246,6 +4246,23 @@ static bool8 name##_2(struct MapObject *mapObject, struct Sprite *sprite)\ return FALSE;\ } +#define npc_obj_ministep_stop_on_arrival_macro(name, dirn, speed) \ +static bool8 name##_2(struct MapObject *, struct Sprite *);\ +bool8 name(struct MapObject *mapObject, struct Sprite *sprite)\ +{\ + do_go_anim(mapObject, sprite, dirn, speed);\ + return name##_2(mapObject, sprite);\ +}\ +static bool8 name##_2(struct MapObject *mapObject, struct Sprite *sprite)\ +{\ + if (npc_obj_ministep_stop_on_arrival(mapObject, sprite))\ + {\ + sprite->data2 = 2;\ + return TRUE;\ + }\ + return FALSE;\ +} + an_walk_any_2_macro(sub_8093BC4, 7) an_walk_any_2_macro(sub_8093C04, 8) an_walk_any_2_macro(sub_8093C44, 5) @@ -4254,4 +4271,12 @@ an_walk_any_2_macro(sub_8093CC4, 1) an_walk_any_2_macro(sub_8093D04, 2) an_walk_any_2_macro(sub_8093D44, 3) an_walk_any_2_macro(sub_8093D84, 4) +npc_obj_ministep_stop_on_arrival_macro(sub_8093DC4, 7, 0) +npc_obj_ministep_stop_on_arrival_macro(sub_8093E04, 8, 0) +npc_obj_ministep_stop_on_arrival_macro(sub_8093E44, 5, 0) +npc_obj_ministep_stop_on_arrival_macro(sub_8093E84, 6, 0) +npc_obj_ministep_stop_on_arrival_macro(sub_8093EC4, 1, 0) +npc_obj_ministep_stop_on_arrival_macro(sub_8093F04, 2, 0) +npc_obj_ministep_stop_on_arrival_macro(sub_8093F44, 3, 0) +npc_obj_ministep_stop_on_arrival_macro(sub_8093F84, 4, 0) From ed6e95fbd72e1619fda2de6b96d336f37ef8b300 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 17 Sep 2017 08:30:36 -0400 Subject: [PATCH 153/191] Avoid using duplicate macros --- src/field_map_obj.c | 55 ++++++++++++++++----------------------------- 1 file changed, 19 insertions(+), 36 deletions(-) diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 648f6bd46..9446f5c67 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -4229,16 +4229,16 @@ bool8 an_walk_any_2(struct MapObject *mapObject, struct Sprite *sprite) return FALSE; } -#define an_walk_any_2_macro(name, dirn) \ +#define an_walk_any_2_macro(name, fn1, fn2, ...) \ static bool8 name##_2(struct MapObject *, struct Sprite *);\ bool8 name(struct MapObject *mapObject, struct Sprite *sprite)\ {\ - sub_8093B60(mapObject, sprite, dirn);\ + fn1(mapObject, sprite, __VA_ARGS__);\ return name##_2(mapObject, sprite);\ }\ static bool8 name##_2(struct MapObject *mapObject, struct Sprite *sprite)\ {\ - if (an_walk_any_2(mapObject, sprite))\ + if (fn2(mapObject, sprite))\ {\ sprite->data2 = 2;\ return TRUE;\ @@ -4246,37 +4246,20 @@ static bool8 name##_2(struct MapObject *mapObject, struct Sprite *sprite)\ return FALSE;\ } -#define npc_obj_ministep_stop_on_arrival_macro(name, dirn, speed) \ -static bool8 name##_2(struct MapObject *, struct Sprite *);\ -bool8 name(struct MapObject *mapObject, struct Sprite *sprite)\ -{\ - do_go_anim(mapObject, sprite, dirn, speed);\ - return name##_2(mapObject, sprite);\ -}\ -static bool8 name##_2(struct MapObject *mapObject, struct Sprite *sprite)\ -{\ - if (npc_obj_ministep_stop_on_arrival(mapObject, sprite))\ - {\ - sprite->data2 = 2;\ - return TRUE;\ - }\ - return FALSE;\ -} - -an_walk_any_2_macro(sub_8093BC4, 7) -an_walk_any_2_macro(sub_8093C04, 8) -an_walk_any_2_macro(sub_8093C44, 5) -an_walk_any_2_macro(sub_8093C84, 6) -an_walk_any_2_macro(sub_8093CC4, 1) -an_walk_any_2_macro(sub_8093D04, 2) -an_walk_any_2_macro(sub_8093D44, 3) -an_walk_any_2_macro(sub_8093D84, 4) -npc_obj_ministep_stop_on_arrival_macro(sub_8093DC4, 7, 0) -npc_obj_ministep_stop_on_arrival_macro(sub_8093E04, 8, 0) -npc_obj_ministep_stop_on_arrival_macro(sub_8093E44, 5, 0) -npc_obj_ministep_stop_on_arrival_macro(sub_8093E84, 6, 0) -npc_obj_ministep_stop_on_arrival_macro(sub_8093EC4, 1, 0) -npc_obj_ministep_stop_on_arrival_macro(sub_8093F04, 2, 0) -npc_obj_ministep_stop_on_arrival_macro(sub_8093F44, 3, 0) -npc_obj_ministep_stop_on_arrival_macro(sub_8093F84, 4, 0) +an_walk_any_2_macro(sub_8093BC4, sub_8093B60, an_walk_any_2, 7) +an_walk_any_2_macro(sub_8093C04, sub_8093B60, an_walk_any_2, 8) +an_walk_any_2_macro(sub_8093C44, sub_8093B60, an_walk_any_2, 5) +an_walk_any_2_macro(sub_8093C84, sub_8093B60, an_walk_any_2, 6) +an_walk_any_2_macro(sub_8093CC4, sub_8093B60, an_walk_any_2, 1) +an_walk_any_2_macro(sub_8093D04, sub_8093B60, an_walk_any_2, 2) +an_walk_any_2_macro(sub_8093D44, sub_8093B60, an_walk_any_2, 3) +an_walk_any_2_macro(sub_8093D84, sub_8093B60, an_walk_any_2, 4) +an_walk_any_2_macro(sub_8093DC4, do_go_anim, npc_obj_ministep_stop_on_arrival, 7, 0) +an_walk_any_2_macro(sub_8093E04, do_go_anim, npc_obj_ministep_stop_on_arrival, 8, 0) +an_walk_any_2_macro(sub_8093E44, do_go_anim, npc_obj_ministep_stop_on_arrival, 5, 0) +an_walk_any_2_macro(sub_8093E84, do_go_anim, npc_obj_ministep_stop_on_arrival, 6, 0) +an_walk_any_2_macro(sub_8093EC4, do_go_anim, npc_obj_ministep_stop_on_arrival, 1, 0) +an_walk_any_2_macro(sub_8093F04, do_go_anim, npc_obj_ministep_stop_on_arrival, 2, 0) +an_walk_any_2_macro(sub_8093F44, do_go_anim, npc_obj_ministep_stop_on_arrival, 3, 0) +an_walk_any_2_macro(sub_8093F84, do_go_anim, npc_obj_ministep_stop_on_arrival, 4, 0) From bf9a00250ba8f3d986b4829c0728ba620b58ec1c Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 17 Sep 2017 08:38:00 -0400 Subject: [PATCH 154/191] maybe_shadow_1 which may or may not be a shadow --- asm/field_map_obj.s | 126 -------------------------------------- include/data3.h | 1 + include/map_obj_8097404.h | 2 + src/field_map_obj.c | 25 ++++++++ 4 files changed, 28 insertions(+), 126 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 405abb959..23ee23b72 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,132 +5,6 @@ .text - thumb_func_start sub_8093FC4 -sub_8093FC4: @ 8093FC4 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x10 - adds r7, r0, 0 - mov r10, r1 - adds r4, r2, 0 - mov r8, r3 - ldr r0, [sp, 0x30] - lsls r4, 24 - lsrs r4, 24 - mov r1, r8 - lsls r1, 24 - lsrs r1, 24 - mov r8, r1 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 - ldr r1, =gUnknown_0850DFBC - add r0, sp, 0x4 - movs r2, 0x6 - bl memcpy - add r5, sp, 0xC - movs r0, 0 - strh r0, [r5] - mov r6, sp - adds r6, 0xE - strh r0, [r6] - adds r0, r7, 0 - adds r1, r4, 0 - bl FieldObjectSetDirection - mov r1, r8 - lsls r0, r1, 1 - add r0, sp - adds r0, 0x4 - movs r1, 0 - ldrsh r3, [r0, r1] - str r3, [sp] - adds r0, r4, 0 - adds r1, r5, 0 - adds r2, r6, 0 - bl sub_8092F88 - ldrh r1, [r5] - ldrh r0, [r7, 0x10] - adds r1, r0 - lsls r1, 16 - asrs r1, 16 - ldrh r2, [r6] - ldrh r0, [r7, 0x12] - adds r2, r0 - lsls r2, 16 - asrs r2, 16 - adds r0, r7, 0 - bl npc_coords_shift - mov r0, r10 - adds r1, r4, 0 - mov r2, r8 - mov r3, r9 - bl sub_809783C - movs r0, 0x1 - mov r1, r10 - strh r0, [r1, 0x32] - movs r0, 0x2C - add r10, r0 - mov r0, r10 - ldrb r1, [r0] - movs r0, 0x41 - negs r0, r0 - ands r0, r1 - mov r1, r10 - strb r0, [r1] - ldrb r0, [r7] - movs r1, 0x4 - orrs r0, r1 - movs r1, 0x10 - orrs r0, r1 - strb r0, [r7] - add sp, 0x10 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8093FC4 - - thumb_func_start maybe_shadow_1 -maybe_shadow_1: @ 8094080 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - ldr r0, [sp, 0x10] - lsls r2, 24 - lsrs r2, 24 - lsls r3, 24 - lsrs r3, 24 - lsls r0, 24 - lsrs r0, 24 - str r0, [sp] - adds r0, r4, 0 - bl sub_8093FC4 - ldrb r0, [r4, 0x18] - lsls r0, 28 - lsrs r0, 28 - bl get_go_image_anim_num - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r1, r5, 0 - bl npc_apply_anim_looping - adds r0, r4, 0 - bl DoShadowFieldEffect - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end maybe_shadow_1 - thumb_func_start sub_80940C4 @ int sub_80940C4(int a1, int a2, int a3) sub_80940C4: @ 80940C4 diff --git a/include/data3.h b/include/data3.h index 9cd6e2fe1..b9ddf3e55 100755 --- a/include/data3.h +++ b/include/data3.h @@ -44,5 +44,6 @@ extern const u8 gUnknown_0850DBA0[5]; extern bool8 (*const *const gUnknown_0850DC50[])(struct MapObject *, struct Sprite *); extern u8 (*const gUnknown_0850DEE8[5])(u8); +extern const s16 gUnknown_0850DFBC[3]; #endif //GUARD_DATA3_H diff --git a/include/map_obj_8097404.h b/include/map_obj_8097404.h index 85153f941..707860dbd 100644 --- a/include/map_obj_8097404.h +++ b/include/map_obj_8097404.h @@ -18,5 +18,7 @@ u8 sub_8097F78(struct MapObject *); bool8 obj_npc_ministep(struct Sprite *sprite); bool8 sub_80976EC(struct Sprite *sprite); void sub_80976DC(struct Sprite *, u8); +void sub_809783C(struct Sprite *, u8, u8, u8); +void DoShadowFieldEffect(struct MapObject *); #endif //GUARD_MAP_OBJ_8097404_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 9446f5c67..5852f220c 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -4263,3 +4263,28 @@ an_walk_any_2_macro(sub_8093F04, do_go_anim, npc_obj_ministep_stop_on_arrival, 2 an_walk_any_2_macro(sub_8093F44, do_go_anim, npc_obj_ministep_stop_on_arrival, 3, 0) an_walk_any_2_macro(sub_8093F84, do_go_anim, npc_obj_ministep_stop_on_arrival, 4, 0) +void sub_8093FC4(struct MapObject *mapObject, struct Sprite *sprite, u8 direction, u8 speed, u8 a5) +{ + s16 displacements[ARRAY_COUNT(gUnknown_0850DFBC)]; + s16 x; + s16 y; + + memcpy(displacements, gUnknown_0850DFBC, sizeof gUnknown_0850DFBC); + x = 0; + y = 0; + FieldObjectSetDirection(mapObject, direction); + sub_8092F88(direction, &x, &y, displacements[speed], displacements[speed]); + npc_coords_shift(mapObject, mapObject->coords2.x + x, mapObject->coords2.y + y); + sub_809783C(sprite, direction, speed, a5); + sprite->data2 = 1; + sprite->animPaused = 0; + mapObject->mapobj_bit_2 = 1; + mapObject->mapobj_bit_4 = 1; +} + +void maybe_shadow_1(struct MapObject *mapObject, struct Sprite *sprite, u8 direction, u8 speed, u8 a4) +{ + sub_8093FC4(mapObject, sprite, direction, speed, a4); + npc_apply_anim_looping(mapObject, sprite, get_go_image_anim_num(mapObject->mapobj_unk_18)); + DoShadowFieldEffect(mapObject); +} From 8ee004b9b16f621e2ea9d4dffe5cfb34d3a1c38a Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 17 Sep 2017 08:45:24 -0400 Subject: [PATCH 155/191] sub_80940C4 which may or may not be a meme --- asm/field_map_obj.s | 97 --------------------------------------------- include/data3.h | 1 + src/field_map_obj.c | 28 +++++++++++++ 3 files changed, 29 insertions(+), 97 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 23ee23b72..8acfa8114 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,103 +5,6 @@ .text - thumb_func_start sub_80940C4 -@ int sub_80940C4(int a1, int a2, int a3) -sub_80940C4: @ 80940C4 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x10 - adds r6, r0, 0 - adds r7, r1, 0 - adds r4, r2, 0 - ldr r1, =gUnknown_0850DFC2 - add r0, sp, 0x4 - movs r2, 0x6 - bl memcpy - adds r0, r7, 0 - bl _call_via_r4 - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - cmp r0, 0x1 - bne _08094154 - movs r1, 0x36 - ldrsh r0, [r7, r1] - lsls r0, 1 - add r0, sp - adds r0, 0x4 - movs r2, 0 - ldrsh r0, [r0, r2] - cmp r0, 0 - beq _08094154 - add r4, sp, 0xC - movs r0, 0 - strh r0, [r4] - mov r5, sp - adds r5, 0xE - strh r0, [r5] - ldrb r0, [r6, 0x18] - lsrs r0, 4 - movs r2, 0x36 - ldrsh r1, [r7, r2] - lsls r1, 1 - add r1, sp - adds r1, 0x4 - movs r2, 0 - ldrsh r3, [r1, r2] - str r3, [sp] - adds r1, r4, 0 - adds r2, r5, 0 - bl sub_8092F88 - ldrh r1, [r4] - ldrh r0, [r6, 0x10] - adds r1, r0 - lsls r1, 16 - asrs r1, 16 - ldrh r2, [r5] - ldrh r0, [r6, 0x12] - adds r2, r0 - lsls r2, 16 - asrs r2, 16 - adds r0, r6, 0 - bl npc_coords_shift - ldrb r0, [r6] - movs r1, 0x4 - orrs r0, r1 - movs r1, 0x10 - orrs r0, r1 - strb r0, [r6] - b _08094178 - .pool -_08094154: - mov r1, r8 - cmp r1, 0xFF - bne _08094178 - adds r0, r6, 0 - bl npc_coords_shift_still - ldrb r0, [r6] - movs r1, 0x8 - orrs r0, r1 - movs r1, 0x20 - orrs r0, r1 - strb r0, [r6] - adds r2, r7, 0 - adds r2, 0x2C - ldrb r0, [r2] - movs r1, 0x40 - orrs r0, r1 - strb r0, [r2] -_08094178: - mov r0, r8 - add sp, 0x10 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_80940C4 - thumb_func_start sub_8094188 sub_8094188: @ 8094188 push {lr} diff --git a/include/data3.h b/include/data3.h index b9ddf3e55..8151e418c 100755 --- a/include/data3.h +++ b/include/data3.h @@ -45,5 +45,6 @@ extern const u8 gUnknown_0850DBA0[5]; extern bool8 (*const *const gUnknown_0850DC50[])(struct MapObject *, struct Sprite *); extern u8 (*const gUnknown_0850DEE8[5])(u8); extern const s16 gUnknown_0850DFBC[3]; +extern const s16 gUnknown_0850DFC2[3]; #endif //GUARD_DATA3_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 5852f220c..3e3bbfa6f 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -4288,3 +4288,31 @@ void maybe_shadow_1(struct MapObject *mapObject, struct Sprite *sprite, u8 direc npc_apply_anim_looping(mapObject, sprite, get_go_image_anim_num(mapObject->mapobj_unk_18)); DoShadowFieldEffect(mapObject); } + +u8 sub_80940C4(struct MapObject *mapObject, struct Sprite *sprite, u8 callback(struct Sprite *)) +{ + s16 displacements[ARRAY_COUNT(gUnknown_0850DFC2)]; + s16 x; + s16 y; + u8 result; + + memcpy(displacements, gUnknown_0850DFC2, sizeof gUnknown_0850DFC2); + result = callback(sprite); + if (result == 1 && displacements[sprite->data4] != 0) + { + x = 0; + y = 0; + sub_8092F88(mapObject->placeholder18, &x, &y, displacements[sprite->data4], displacements[sprite->data4]); + npc_coords_shift(mapObject, mapObject->coords2.x + x, mapObject->coords2.y + y); + mapObject->mapobj_bit_2 = TRUE; + mapObject->mapobj_bit_4 = TRUE; + } + else if (result == 0xFF) + { + npc_coords_shift_still(mapObject); + mapObject->mapobj_bit_3 = TRUE; + mapObject->mapobj_bit_5 = TRUE; + sprite->animPaused = TRUE; + } + return result; +} From 9dc7839dd875cc06b582bd78f2263478a0571535 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 17 Sep 2017 09:49:50 -0400 Subject: [PATCH 156/191] callers of sub_80940C4 --- asm/field_map_obj.s | 24 ------------------------ include/map_obj_8097404.h | 2 ++ src/field_map_obj.c | 10 ++++++++++ 3 files changed, 12 insertions(+), 24 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 8acfa8114..980edf29c 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,30 +5,6 @@ .text - thumb_func_start sub_8094188 -sub_8094188: @ 8094188 - push {lr} - ldr r2, =sub_809785C - bl sub_80940C4 - lsls r0, 24 - lsrs r0, 24 - pop {r1} - bx r1 - .pool - thumb_func_end sub_8094188 - - thumb_func_start sub_809419C -sub_809419C: @ 809419C - push {lr} - ldr r2, =sub_80978E4 - bl sub_80940C4 - lsls r0, 24 - lsrs r0, 24 - pop {r1} - bx r1 - .pool - thumb_func_end sub_809419C - thumb_func_start sub_80941B0 sub_80941B0: @ 80941B0 push {lr} diff --git a/include/map_obj_8097404.h b/include/map_obj_8097404.h index 707860dbd..1fc653163 100644 --- a/include/map_obj_8097404.h +++ b/include/map_obj_8097404.h @@ -20,5 +20,7 @@ bool8 sub_80976EC(struct Sprite *sprite); void sub_80976DC(struct Sprite *, u8); void sub_809783C(struct Sprite *, u8, u8, u8); void DoShadowFieldEffect(struct MapObject *); +u8 sub_809785C(struct Sprite *); +u8 sub_80978E4(struct Sprite *); #endif //GUARD_MAP_OBJ_8097404_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 3e3bbfa6f..7ef901eec 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -4316,3 +4316,13 @@ u8 sub_80940C4(struct MapObject *mapObject, struct Sprite *sprite, u8 callback(s } return result; } + +u8 sub_8094188(struct MapObject *mapObject, struct Sprite *sprite) +{ + return sub_80940C4(mapObject, sprite, sub_809785C); +} + +u8 sub_809419C(struct MapObject *mapObject, struct Sprite *sprite) +{ + return sub_80940C4(mapObject, sprite, sub_80978E4); +} From 99e0fe1f241dbdd780f7330ab5891574a8a21080 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 17 Sep 2017 09:52:17 -0400 Subject: [PATCH 157/191] callers of callers of sub_80940C4 --- asm/field_map_obj.s | 34 ---------------------------------- src/field_map_obj.c | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 34 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 980edf29c..a0d55e64c 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,40 +5,6 @@ .text - thumb_func_start sub_80941B0 -sub_80941B0: @ 80941B0 - push {lr} - bl sub_8094188 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0xFF - beq _080941C2 - movs r0, 0 - b _080941C4 -_080941C2: - movs r0, 0x1 -_080941C4: - pop {r1} - bx r1 - thumb_func_end sub_80941B0 - - thumb_func_start sub_80941C8 -sub_80941C8: @ 80941C8 - push {lr} - bl sub_809419C - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0xFF - beq _080941DA - movs r0, 0 - b _080941DC -_080941DA: - movs r0, 0x1 -_080941DC: - pop {r1} - bx r1 - thumb_func_end sub_80941C8 - thumb_func_start sub_80941E0 sub_80941E0: @ 80941E0 push {r4,r5,lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 7ef901eec..bc8c7512d 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -4326,3 +4326,21 @@ u8 sub_809419C(struct MapObject *mapObject, struct Sprite *sprite) { return sub_80940C4(mapObject, sprite, sub_80978E4); } + +bool8 sub_80941B0(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8094188(mapObject, sprite) == 0xFF) + { + return TRUE; + } + return FALSE; +} + +bool8 sub_80941C8(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_809419C(mapObject, sprite) == 0xFF) + { + return TRUE; + } + return FALSE; +} From 3fdb217ba3ba4d30a915fe0e7df85ebe09b226fb Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 17 Sep 2017 09:55:17 -0400 Subject: [PATCH 158/191] sub_80941E0 --- asm/field_map_obj.s | 41 ----------------------------------------- src/field_map_obj.c | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 41 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index a0d55e64c..d318a0a1c 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,47 +5,6 @@ .text - thumb_func_start sub_80941E0 -sub_80941E0: @ 80941E0 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl sub_8094188 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _080941FA - cmp r0, 0xFF - bne _08094226 - movs r0, 0x1 - b _08094228 -_080941FA: - ldrb r0, [r4, 0x18] - lsrs r0, 4 - bl GetOppositeDirection - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 24 - adds r0, r4, 0 - bl FieldObjectSetDirection - ldrb r0, [r4, 0x18] - lsls r0, 28 - lsrs r0, 28 - bl get_go_image_anim_num - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r1, r5, 0 - bl obj_npc_animation_step -_08094226: - movs r0, 0 -_08094228: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80941E0 - thumb_func_start sub_8094230 sub_8094230: @ 8094230 push {r4,r5,lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index bc8c7512d..fb0d1c81b 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -4344,3 +4344,17 @@ bool8 sub_80941C8(struct MapObject *mapObject, struct Sprite *sprite) } return FALSE; } + +bool8 sub_80941E0(struct MapObject *mapObject, struct Sprite *sprite) +{ + switch (sub_8094188(mapObject, sprite)) + { + case 255: + return TRUE; + case 1: + FieldObjectSetDirection(mapObject, GetOppositeDirection(mapObject->placeholder18)); + obj_npc_animation_step(mapObject, sprite, get_go_image_anim_num(mapObject->mapobj_unk_18)); + default: + return FALSE; + } +} From 3a7f771eabc3054029c73828ca3872b1157af01a Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 17 Sep 2017 10:01:27 -0400 Subject: [PATCH 159/191] maybe_shadow_1 might be a meme --- asm/field_map_obj.s | 196 -------------------------------------------- src/field_map_obj.c | 23 ++++++ 2 files changed, 23 insertions(+), 196 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index d318a0a1c..e9a96a6e0 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,202 +5,6 @@ .text - thumb_func_start sub_8094230 -sub_8094230: @ 8094230 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0 - str r0, [sp] - adds r0, r4, 0 - movs r2, 0x1 - movs r3, 0x2 - bl maybe_shadow_1 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_809425C - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8094230 - - thumb_func_start sub_809425C -sub_809425C: @ 809425C - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl sub_80941B0 - lsls r0, 24 - cmp r0, 0 - bne _08094270 - movs r0, 0 - b _08094280 -_08094270: - ldrb r0, [r4, 0x2] - movs r1, 0x41 - negs r1, r1 - ands r1, r0 - strb r1, [r4, 0x2] - movs r0, 0x2 - strh r0, [r5, 0x32] - movs r0, 0x1 -_08094280: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_809425C - - thumb_func_start sub_8094288 -sub_8094288: @ 8094288 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0 - str r0, [sp] - adds r0, r4, 0 - movs r2, 0x2 - movs r3, 0x2 - bl maybe_shadow_1 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_80942B4 - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8094288 - - thumb_func_start sub_80942B4 -sub_80942B4: @ 80942B4 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl sub_80941B0 - lsls r0, 24 - cmp r0, 0 - bne _080942C8 - movs r0, 0 - b _080942D8 -_080942C8: - ldrb r0, [r4, 0x2] - movs r1, 0x41 - negs r1, r1 - ands r1, r0 - strb r1, [r4, 0x2] - movs r0, 0x2 - strh r0, [r5, 0x32] - movs r0, 0x1 -_080942D8: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80942B4 - - thumb_func_start sub_80942E0 -sub_80942E0: @ 80942E0 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0 - str r0, [sp] - adds r0, r4, 0 - movs r2, 0x3 - movs r3, 0x2 - bl maybe_shadow_1 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_809430C - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80942E0 - - thumb_func_start sub_809430C -sub_809430C: @ 809430C - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl sub_80941B0 - lsls r0, 24 - cmp r0, 0 - bne _08094320 - movs r0, 0 - b _08094330 -_08094320: - ldrb r0, [r4, 0x2] - movs r1, 0x41 - negs r1, r1 - ands r1, r0 - strb r1, [r4, 0x2] - movs r0, 0x2 - strh r0, [r5, 0x32] - movs r0, 0x1 -_08094330: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_809430C - - thumb_func_start sub_8094338 -sub_8094338: @ 8094338 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0 - str r0, [sp] - adds r0, r4, 0 - movs r2, 0x4 - movs r3, 0x2 - bl maybe_shadow_1 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8094364 - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8094338 - - thumb_func_start sub_8094364 -sub_8094364: @ 8094364 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl sub_80941B0 - lsls r0, 24 - cmp r0, 0 - bne _08094378 - movs r0, 0 - b _08094388 -_08094378: - ldrb r0, [r4, 0x2] - movs r1, 0x41 - negs r1, r1 - ands r1, r0 - strb r1, [r4, 0x2] - movs r0, 0x2 - strh r0, [r5, 0x32] - movs r0, 0x1 -_08094388: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8094364 - thumb_func_start sub_8094390 sub_8094390: @ 8094390 movs r2, 0x1 diff --git a/src/field_map_obj.c b/src/field_map_obj.c index fb0d1c81b..dcf439b9b 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -4358,3 +4358,26 @@ bool8 sub_80941E0(struct MapObject *mapObject, struct Sprite *sprite) return FALSE; } } + +#define maybe_shadow_1_macro(name, fn1, fn2, ...) \ +static bool8 name##_2(struct MapObject *, struct Sprite *);\ +bool8 name(struct MapObject *mapObject, struct Sprite *sprite)\ +{\ + fn1(mapObject, sprite, __VA_ARGS__);\ + return name##_2(mapObject, sprite);\ +}\ +static bool8 name##_2(struct MapObject *mapObject, struct Sprite *sprite)\ +{\ + if (fn2(mapObject, sprite))\ + {\ + mapObject->mapobj_bit_22 = FALSE;\ + sprite->data2 = 2;\ + return TRUE;\ + }\ + return FALSE;\ +} + +maybe_shadow_1_macro(sub_8094230, maybe_shadow_1, sub_80941B0, 1, 2, 0) +maybe_shadow_1_macro(sub_8094288, maybe_shadow_1, sub_80941B0, 2, 2, 0) +maybe_shadow_1_macro(sub_80942E0, maybe_shadow_1, sub_80941B0, 3, 2, 0) +maybe_shadow_1_macro(sub_8094338, maybe_shadow_1, sub_80941B0, 4, 2, 0) From cd958b1e4376058db61607e1cff4427d8a0175b8 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 17 Sep 2017 10:07:43 -0400 Subject: [PATCH 160/191] special_anim_with_timer --- asm/field_map_obj.s | 118 -------------------------------------------- src/field_map_obj.c | 29 +++++++++++ 2 files changed, 29 insertions(+), 118 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index e9a96a6e0..9a27d4c06 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,124 +5,6 @@ .text - thumb_func_start sub_8094390 -sub_8094390: @ 8094390 - movs r2, 0x1 - strh r2, [r0, 0x32] - strh r1, [r0, 0x34] - bx lr - thumb_func_end sub_8094390 - - thumb_func_start sub_8094398 -sub_8094398: @ 8094398 - push {lr} - ldrh r0, [r1, 0x34] - subs r0, 0x1 - strh r0, [r1, 0x34] - lsls r0, 16 - cmp r0, 0 - beq _080943AA - movs r0, 0 - b _080943B0 -_080943AA: - movs r0, 0x2 - strh r0, [r1, 0x32] - movs r0, 0x1 -_080943B0: - pop {r1} - bx r1 - thumb_func_end sub_8094398 - - thumb_func_start sub_80943B4 -sub_80943B4: @ 80943B4 - push {r4,r5,lr} - adds r5, r0, 0 - adds r4, r1, 0 - adds r0, r4, 0 - movs r1, 0x1 - bl sub_8094390 - adds r0, r5, 0 - adds r1, r4, 0 - bl sub_8094398 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80943B4 - - thumb_func_start sub_80943D4 -sub_80943D4: @ 80943D4 - push {r4,r5,lr} - adds r5, r0, 0 - adds r4, r1, 0 - adds r0, r4, 0 - movs r1, 0x2 - bl sub_8094390 - adds r0, r5, 0 - adds r1, r4, 0 - bl sub_8094398 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80943D4 - - thumb_func_start sub_80943F4 -sub_80943F4: @ 80943F4 - push {r4,r5,lr} - adds r5, r0, 0 - adds r4, r1, 0 - adds r0, r4, 0 - movs r1, 0x4 - bl sub_8094390 - adds r0, r5, 0 - adds r1, r4, 0 - bl sub_8094398 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80943F4 - - thumb_func_start sub_8094414 -sub_8094414: @ 8094414 - push {r4,r5,lr} - adds r5, r0, 0 - adds r4, r1, 0 - adds r0, r4, 0 - movs r1, 0x8 - bl sub_8094390 - adds r0, r5, 0 - adds r1, r4, 0 - bl sub_8094398 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8094414 - - thumb_func_start sub_8094434 -sub_8094434: @ 8094434 - push {r4,r5,lr} - adds r5, r0, 0 - adds r4, r1, 0 - adds r0, r4, 0 - movs r1, 0x10 - bl sub_8094390 - adds r0, r5, 0 - adds r1, r4, 0 - bl sub_8094398 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8094434 - thumb_func_start sub_8094454 sub_8094454: @ 8094454 push {r4,r5,lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index dcf439b9b..9fedc7f0b 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -4381,3 +4381,32 @@ maybe_shadow_1_macro(sub_8094230, maybe_shadow_1, sub_80941B0, 1, 2, 0) maybe_shadow_1_macro(sub_8094288, maybe_shadow_1, sub_80941B0, 2, 2, 0) maybe_shadow_1_macro(sub_80942E0, maybe_shadow_1, sub_80941B0, 3, 2, 0) maybe_shadow_1_macro(sub_8094338, maybe_shadow_1, sub_80941B0, 4, 2, 0) + +void sub_8094390(struct Sprite *sprite, u16 duration) +{ + sprite->data2 = 1; + sprite->data3 = duration; +} + +bool8 sub_8094398(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (-- sprite->data3 == 0) + { + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +#define special_anim_with_timer(name, duration)\ +bool8 name(struct MapObject *mapObject, struct Sprite *sprite)\ +{\ + sub_8094390(sprite, duration);\ + return sub_8094398(mapObject, sprite);\ +} + +special_anim_with_timer(sub_80943B4, 1) +special_anim_with_timer(sub_80943D4, 2) +special_anim_with_timer(sub_80943F4, 4) +special_anim_with_timer(sub_8094414, 8) +special_anim_with_timer(sub_8094434, 16) From 43b3195bc853ac9d88ae93d9a36060de8a2295ac Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 17 Sep 2017 10:23:18 -0400 Subject: [PATCH 161/191] More special anims with timers --- asm/field_map_obj.s | 700 -------------------------------------------- src/field_map_obj.c | 60 ++++ 2 files changed, 60 insertions(+), 700 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 9a27d4c06..3fcc3dfbf 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,706 +5,6 @@ .text - thumb_func_start sub_8094454 -sub_8094454: @ 8094454 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x1 - movs r3, 0x1 - bl do_go_anim - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8094474 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8094454 - - thumb_func_start sub_8094474 -sub_8094474: @ 8094474 - push {r4,lr} - adds r4, r1, 0 - bl npc_obj_ministep_stop_on_arrival - lsls r0, 24 - cmp r0, 0 - bne _08094486 - movs r0, 0 - b _0809448C -_08094486: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_0809448C: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8094474 - - thumb_func_start sub_8094494 -sub_8094494: @ 8094494 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x2 - movs r3, 0x1 - bl do_go_anim - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_80944B4 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8094494 - - thumb_func_start sub_80944B4 -sub_80944B4: @ 80944B4 - push {r4,lr} - adds r4, r1, 0 - bl npc_obj_ministep_stop_on_arrival - lsls r0, 24 - cmp r0, 0 - bne _080944C6 - movs r0, 0 - b _080944CC -_080944C6: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_080944CC: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_80944B4 - - thumb_func_start sub_80944D4 -sub_80944D4: @ 80944D4 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x3 - movs r3, 0x1 - bl do_go_anim - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_80944F4 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80944D4 - - thumb_func_start sub_80944F4 -sub_80944F4: @ 80944F4 - push {r4,lr} - adds r4, r1, 0 - bl npc_obj_ministep_stop_on_arrival - lsls r0, 24 - cmp r0, 0 - bne _08094506 - movs r0, 0 - b _0809450C -_08094506: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_0809450C: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_80944F4 - - thumb_func_start sub_8094514 -sub_8094514: @ 8094514 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x4 - movs r3, 0x1 - bl do_go_anim - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8094534 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8094514 - - thumb_func_start sub_8094534 -sub_8094534: @ 8094534 - push {r4,lr} - adds r4, r1, 0 - bl npc_obj_ministep_stop_on_arrival - lsls r0, 24 - cmp r0, 0 - bne _08094546 - movs r0, 0 - b _0809454C -_08094546: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_0809454C: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8094534 - - thumb_func_start sub_8094554 -sub_8094554: @ 8094554 - push {r4-r6,lr} - mov r6, r8 - push {r6} - mov r8, r0 - adds r6, r1, 0 - adds r1, r2, 0 - adds r4, r3, 0 - ldr r5, [sp, 0x14] - lsls r1, 24 - lsrs r1, 24 - lsls r4, 24 - lsrs r4, 24 - lsls r5, 16 - lsrs r5, 16 - bl FieldObjectSetDirection - mov r0, r8 - adds r1, r6, 0 - adds r2, r4, 0 - bl npc_apply_anim_looping - adds r2, r6, 0 - adds r2, 0x2C - ldrb r1, [r2] - movs r0, 0x41 - negs r0, r0 - ands r0, r1 - strb r0, [r2] - movs r0, 0x1 - strh r0, [r6, 0x32] - strh r5, [r6, 0x34] - pop {r3} - mov r8, r3 - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_8094554 - - thumb_func_start sub_809459C -@ signed int sub_809459C(int a1, obj *a2) -sub_809459C: @ 809459C - push {lr} - ldrh r0, [r1, 0x34] - subs r0, 0x1 - strh r0, [r1, 0x34] - lsls r0, 16 - cmp r0, 0 - beq _080945AE - movs r0, 0 - b _080945C0 -_080945AE: - movs r0, 0x2 - strh r0, [r1, 0x32] - adds r2, r1, 0 - adds r2, 0x2C - ldrb r0, [r2] - movs r1, 0x40 - orrs r0, r1 - strb r0, [r2] - movs r0, 0x1 -_080945C0: - pop {r1} - bx r1 - thumb_func_end sub_809459C - - thumb_func_start sub_80945C4 -@ int sub_80945C4(int a1, obj *a2) -sub_80945C4: @ 80945C4 - push {r4,r5,lr} - adds r5, r0, 0 - adds r4, r1, 0 - ldrh r1, [r4, 0x34] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _080945EE - adds r3, r4, 0 - adds r3, 0x2C - ldrb r2, [r3] - lsls r1, r2, 26 - lsrs r1, 26 - adds r1, 0x1 - movs r0, 0x3F - ands r1, r0 - movs r0, 0x40 - negs r0, r0 - ands r0, r2 - orrs r0, r1 - strb r0, [r3] -_080945EE: - adds r0, r5, 0 - adds r1, r4, 0 - bl sub_809459C - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80945C4 - - thumb_func_start sub_8094600 -sub_8094600: @ 8094600 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0x1 - bl get_go_image_anim_num - adds r3, r0, 0 - lsls r3, 24 - lsrs r3, 24 - movs r0, 0x20 - str r0, [sp] - adds r0, r4, 0 - adds r1, r5, 0 - movs r2, 0x1 - bl sub_8094554 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_80945C4 - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8094600 - - thumb_func_start sub_8094638 -sub_8094638: @ 8094638 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0x2 - bl get_go_image_anim_num - adds r3, r0, 0 - lsls r3, 24 - lsrs r3, 24 - movs r0, 0x20 - str r0, [sp] - adds r0, r4, 0 - adds r1, r5, 0 - movs r2, 0x2 - bl sub_8094554 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_80945C4 - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8094638 - - thumb_func_start sub_8094670 -sub_8094670: @ 8094670 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0x3 - bl get_go_image_anim_num - adds r3, r0, 0 - lsls r3, 24 - lsrs r3, 24 - movs r0, 0x20 - str r0, [sp] - adds r0, r4, 0 - adds r1, r5, 0 - movs r2, 0x3 - bl sub_8094554 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_80945C4 - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8094670 - - thumb_func_start sub_80946A8 -sub_80946A8: @ 80946A8 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0x4 - bl get_go_image_anim_num - adds r3, r0, 0 - lsls r3, 24 - lsrs r3, 24 - movs r0, 0x20 - str r0, [sp] - adds r0, r4, 0 - adds r1, r5, 0 - movs r2, 0x4 - bl sub_8094554 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_80945C4 - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80946A8 - - thumb_func_start sub_80946E0 -sub_80946E0: @ 80946E0 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0x1 - bl get_go_image_anim_num - adds r3, r0, 0 - lsls r3, 24 - lsrs r3, 24 - movs r0, 0x10 - str r0, [sp] - adds r0, r4, 0 - adds r1, r5, 0 - movs r2, 0x1 - bl sub_8094554 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_809459C - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80946E0 - - thumb_func_start sub_8094718 -sub_8094718: @ 8094718 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0x2 - bl get_go_image_anim_num - adds r3, r0, 0 - lsls r3, 24 - lsrs r3, 24 - movs r0, 0x10 - str r0, [sp] - adds r0, r4, 0 - adds r1, r5, 0 - movs r2, 0x2 - bl sub_8094554 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_809459C - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8094718 - - thumb_func_start sub_8094750 -sub_8094750: @ 8094750 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0x3 - bl get_go_image_anim_num - adds r3, r0, 0 - lsls r3, 24 - lsrs r3, 24 - movs r0, 0x10 - str r0, [sp] - adds r0, r4, 0 - adds r1, r5, 0 - movs r2, 0x3 - bl sub_8094554 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_809459C - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8094750 - - thumb_func_start sub_8094788 -sub_8094788: @ 8094788 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0x4 - bl get_go_image_anim_num - adds r3, r0, 0 - lsls r3, 24 - lsrs r3, 24 - movs r0, 0x10 - str r0, [sp] - adds r0, r4, 0 - adds r1, r5, 0 - movs r2, 0x4 - bl sub_8094554 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_809459C - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8094788 - - thumb_func_start sub_80947C0 -sub_80947C0: @ 80947C0 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0x1 - bl get_go_fast_image_anim_num - adds r3, r0, 0 - lsls r3, 24 - lsrs r3, 24 - movs r0, 0x8 - str r0, [sp] - adds r0, r4, 0 - adds r1, r5, 0 - movs r2, 0x1 - bl sub_8094554 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_809459C - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80947C0 - - thumb_func_start sub_80947F8 -sub_80947F8: @ 80947F8 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0x2 - bl get_go_fast_image_anim_num - adds r3, r0, 0 - lsls r3, 24 - lsrs r3, 24 - movs r0, 0x8 - str r0, [sp] - adds r0, r4, 0 - adds r1, r5, 0 - movs r2, 0x2 - bl sub_8094554 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_809459C - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80947F8 - - thumb_func_start sub_8094830 -sub_8094830: @ 8094830 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0x3 - bl get_go_fast_image_anim_num - adds r3, r0, 0 - lsls r3, 24 - lsrs r3, 24 - movs r0, 0x8 - str r0, [sp] - adds r0, r4, 0 - adds r1, r5, 0 - movs r2, 0x3 - bl sub_8094554 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_809459C - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8094830 - - thumb_func_start sub_8094868 -sub_8094868: @ 8094868 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0x4 - bl get_go_fast_image_anim_num - adds r3, r0, 0 - lsls r3, 24 - lsrs r3, 24 - movs r0, 0x8 - str r0, [sp] - adds r0, r4, 0 - adds r1, r5, 0 - movs r2, 0x4 - bl sub_8094554 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_809459C - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8094868 - - thumb_func_start sub_80948A0 -sub_80948A0: @ 80948A0 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0x1 - bl get_go_faster_image_anim_num - adds r3, r0, 0 - lsls r3, 24 - lsrs r3, 24 - movs r0, 0x4 - str r0, [sp] - adds r0, r4, 0 - adds r1, r5, 0 - movs r2, 0x1 - bl sub_8094554 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_809459C - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80948A0 - - thumb_func_start sub_80948D8 -sub_80948D8: @ 80948D8 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0x2 - bl get_go_faster_image_anim_num - adds r3, r0, 0 - lsls r3, 24 - lsrs r3, 24 - movs r0, 0x4 - str r0, [sp] - adds r0, r4, 0 - adds r1, r5, 0 - movs r2, 0x2 - bl sub_8094554 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_809459C - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80948D8 - - thumb_func_start sub_8094910 -sub_8094910: @ 8094910 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0x3 - bl get_go_faster_image_anim_num - adds r3, r0, 0 - lsls r3, 24 - lsrs r3, 24 - movs r0, 0x4 - str r0, [sp] - adds r0, r4, 0 - adds r1, r5, 0 - movs r2, 0x3 - bl sub_8094554 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_809459C - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8094910 - - thumb_func_start sub_8094948 -sub_8094948: @ 8094948 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0x4 - bl get_go_faster_image_anim_num - adds r3, r0, 0 - lsls r3, 24 - lsrs r3, 24 - movs r0, 0x4 - str r0, [sp] - adds r0, r4, 0 - adds r1, r5, 0 - movs r2, 0x4 - bl sub_8094554 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_809459C - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8094948 - thumb_func_start sub_8094980 sub_8094980: @ 8094980 push {r4,r5,lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 9fedc7f0b..e6a4c4181 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -4410,3 +4410,63 @@ special_anim_with_timer(sub_80943D4, 2) special_anim_with_timer(sub_80943F4, 4) special_anim_with_timer(sub_8094414, 8) special_anim_with_timer(sub_8094434, 16) + +an_walk_any_2_macro(sub_8094454, do_go_anim, npc_obj_ministep_stop_on_arrival, 1, 1) +an_walk_any_2_macro(sub_8094494, do_go_anim, npc_obj_ministep_stop_on_arrival, 2, 1) +an_walk_any_2_macro(sub_80944D4, do_go_anim, npc_obj_ministep_stop_on_arrival, 3, 1) +an_walk_any_2_macro(sub_8094514, do_go_anim, npc_obj_ministep_stop_on_arrival, 4, 1) + +void sub_8094554(struct MapObject *mapObject, struct Sprite *sprite, u8 direction, u8 animNum, u16 duration) +{ + FieldObjectSetDirection(mapObject, direction); + npc_apply_anim_looping(mapObject, sprite, animNum); + sprite->animPaused = FALSE; + sprite->data2 = 1; + sprite->data3 = duration; +} + +bool8 sub_809459C(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (-- sprite->data3 == 0) + { + sprite->data2 = 2; + sprite->animPaused = TRUE; + return TRUE; + } + return FALSE; +} + +bool8 sub_80945C4(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sprite->data3 & 1) + { + sprite->animDelayCounter ++; + } + return sub_809459C(mapObject, sprite); +} + +#define special_anim_with_timer_2(name, direction, images, duration, timer) \ +bool8 name(struct MapObject *mapObject, struct Sprite *sprite)\ +{\ + u8 animId;\ + animId = get_##images##_image_anim_num(direction);\ + sub_8094554(mapObject, sprite, direction, animId, duration);\ + return timer(mapObject, sprite);\ +} + +special_anim_with_timer_2(sub_8094600, DIR_SOUTH, go, 32, sub_80945C4) +special_anim_with_timer_2(sub_8094638, DIR_NORTH, go, 32, sub_80945C4) +special_anim_with_timer_2(sub_8094670, DIR_WEST, go, 32, sub_80945C4) +special_anim_with_timer_2(sub_80946A8, DIR_EAST, go, 32, sub_80945C4) +special_anim_with_timer_2(sub_80946E0, DIR_SOUTH, go, 16, sub_809459C) +special_anim_with_timer_2(sub_8094718, DIR_NORTH, go, 16, sub_809459C) +special_anim_with_timer_2(sub_8094750, DIR_WEST, go, 16, sub_809459C) +special_anim_with_timer_2(sub_8094788, DIR_EAST, go, 16, sub_809459C) +special_anim_with_timer_2(sub_80947C0, DIR_SOUTH, go_fast, 8, sub_809459C) +special_anim_with_timer_2(sub_80947F8, DIR_NORTH, go_fast, 8, sub_809459C) +special_anim_with_timer_2(sub_8094830, DIR_WEST, go_fast, 8, sub_809459C) +special_anim_with_timer_2(sub_8094868, DIR_EAST, go_fast, 8, sub_809459C) +special_anim_with_timer_2(sub_80948A0, DIR_SOUTH, go_faster, 4, sub_809459C) +special_anim_with_timer_2(sub_80948D8, DIR_NORTH, go_faster, 4, sub_809459C) +special_anim_with_timer_2(sub_8094910, DIR_WEST, go_faster, 4, sub_809459C) +special_anim_with_timer_2(sub_8094948, DIR_EAST, go_faster, 4, sub_809459C) From f8b08d3ee7f2836f86eed171b064ebb125d43400 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 17 Sep 2017 10:25:48 -0400 Subject: [PATCH 162/191] more an_walk_any_2_macro functions --- asm/field_map_obj.s | 456 -------------------------------------------- src/field_map_obj.c | 13 ++ 2 files changed, 13 insertions(+), 456 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 3fcc3dfbf..d1d4596eb 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,462 +5,6 @@ .text - thumb_func_start sub_8094980 -sub_8094980: @ 8094980 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x1 - movs r3, 0x2 - bl do_go_anim - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_80949A0 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8094980 - - thumb_func_start sub_80949A0 -sub_80949A0: @ 80949A0 - push {r4,lr} - adds r4, r1, 0 - bl npc_obj_ministep_stop_on_arrival - lsls r0, 24 - cmp r0, 0 - bne _080949B2 - movs r0, 0 - b _080949B8 -_080949B2: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_080949B8: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_80949A0 - - thumb_func_start sub_80949C0 -sub_80949C0: @ 80949C0 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x2 - movs r3, 0x2 - bl do_go_anim - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_80949E0 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80949C0 - - thumb_func_start sub_80949E0 -sub_80949E0: @ 80949E0 - push {r4,lr} - adds r4, r1, 0 - bl npc_obj_ministep_stop_on_arrival - lsls r0, 24 - cmp r0, 0 - bne _080949F2 - movs r0, 0 - b _080949F8 -_080949F2: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_080949F8: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_80949E0 - - thumb_func_start sub_8094A00 -sub_8094A00: @ 8094A00 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x3 - movs r3, 0x2 - bl do_go_anim - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8094A20 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8094A00 - - thumb_func_start sub_8094A20 -sub_8094A20: @ 8094A20 - push {r4,lr} - adds r4, r1, 0 - bl npc_obj_ministep_stop_on_arrival - lsls r0, 24 - cmp r0, 0 - bne _08094A32 - movs r0, 0 - b _08094A38 -_08094A32: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_08094A38: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8094A20 - - thumb_func_start sub_8094A40 -sub_8094A40: @ 8094A40 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x4 - movs r3, 0x2 - bl do_go_anim - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8094A60 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8094A40 - - thumb_func_start sub_8094A60 -sub_8094A60: @ 8094A60 - push {r4,lr} - adds r4, r1, 0 - bl npc_obj_ministep_stop_on_arrival - lsls r0, 24 - cmp r0, 0 - bne _08094A72 - movs r0, 0 - b _08094A78 -_08094A72: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_08094A78: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8094A60 - - thumb_func_start sub_8094A80 -sub_8094A80: @ 8094A80 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x1 - movs r3, 0x3 - bl do_go_anim - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8094AA0 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8094A80 - - thumb_func_start sub_8094AA0 -sub_8094AA0: @ 8094AA0 - push {r4,lr} - adds r4, r1, 0 - bl npc_obj_ministep_stop_on_arrival - lsls r0, 24 - cmp r0, 0 - bne _08094AB2 - movs r0, 0 - b _08094AB8 -_08094AB2: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_08094AB8: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8094AA0 - - thumb_func_start sub_8094AC0 -sub_8094AC0: @ 8094AC0 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x2 - movs r3, 0x3 - bl do_go_anim - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8094AE0 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8094AC0 - - thumb_func_start sub_8094AE0 -sub_8094AE0: @ 8094AE0 - push {r4,lr} - adds r4, r1, 0 - bl npc_obj_ministep_stop_on_arrival - lsls r0, 24 - cmp r0, 0 - bne _08094AF2 - movs r0, 0 - b _08094AF8 -_08094AF2: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_08094AF8: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8094AE0 - - thumb_func_start sub_8094B00 -sub_8094B00: @ 8094B00 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x3 - movs r3, 0x3 - bl do_go_anim - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8094B20 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8094B00 - - thumb_func_start sub_8094B20 -sub_8094B20: @ 8094B20 - push {r4,lr} - adds r4, r1, 0 - bl npc_obj_ministep_stop_on_arrival - lsls r0, 24 - cmp r0, 0 - bne _08094B32 - movs r0, 0 - b _08094B38 -_08094B32: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_08094B38: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8094B20 - - thumb_func_start sub_8094B40 -sub_8094B40: @ 8094B40 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x4 - movs r3, 0x3 - bl do_go_anim - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8094B60 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8094B40 - - thumb_func_start sub_8094B60 -sub_8094B60: @ 8094B60 - push {r4,lr} - adds r4, r1, 0 - bl npc_obj_ministep_stop_on_arrival - lsls r0, 24 - cmp r0, 0 - bne _08094B72 - movs r0, 0 - b _08094B78 -_08094B72: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_08094B78: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8094B60 - - thumb_func_start sub_8094B80 -sub_8094B80: @ 8094B80 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x1 - movs r3, 0x4 - bl do_go_anim - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8094BA0 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8094B80 - - thumb_func_start sub_8094BA0 -sub_8094BA0: @ 8094BA0 - push {r4,lr} - adds r4, r1, 0 - bl npc_obj_ministep_stop_on_arrival - lsls r0, 24 - cmp r0, 0 - bne _08094BB2 - movs r0, 0 - b _08094BB8 -_08094BB2: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_08094BB8: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8094BA0 - - thumb_func_start sub_8094BC0 -sub_8094BC0: @ 8094BC0 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x2 - movs r3, 0x4 - bl do_go_anim - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8094BE0 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8094BC0 - - thumb_func_start sub_8094BE0 -sub_8094BE0: @ 8094BE0 - push {r4,lr} - adds r4, r1, 0 - bl npc_obj_ministep_stop_on_arrival - lsls r0, 24 - cmp r0, 0 - bne _08094BF2 - movs r0, 0 - b _08094BF8 -_08094BF2: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_08094BF8: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8094BE0 - - thumb_func_start sub_8094C00 -sub_8094C00: @ 8094C00 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x3 - movs r3, 0x4 - bl do_go_anim - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8094C20 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8094C00 - - thumb_func_start sub_8094C20 -sub_8094C20: @ 8094C20 - push {r4,lr} - adds r4, r1, 0 - bl npc_obj_ministep_stop_on_arrival - lsls r0, 24 - cmp r0, 0 - bne _08094C32 - movs r0, 0 - b _08094C38 -_08094C32: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_08094C38: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8094C20 - - thumb_func_start sub_8094C40 -sub_8094C40: @ 8094C40 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x4 - movs r3, 0x4 - bl do_go_anim - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8094C60 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8094C40 - - thumb_func_start sub_8094C60 -sub_8094C60: @ 8094C60 - push {r4,lr} - adds r4, r1, 0 - bl npc_obj_ministep_stop_on_arrival - lsls r0, 24 - cmp r0, 0 - bne _08094C72 - movs r0, 0 - b _08094C78 -_08094C72: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_08094C78: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8094C60 - thumb_func_start do_run_south_anim @ bool8 do_run_south_anim(struct npc_state *fieldObject, struct obj *object) do_run_south_anim: @ 8094C80 diff --git a/src/field_map_obj.c b/src/field_map_obj.c index e6a4c4181..c4847ae4f 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -4470,3 +4470,16 @@ special_anim_with_timer_2(sub_80948A0, DIR_SOUTH, go_faster, 4, sub_809459C) special_anim_with_timer_2(sub_80948D8, DIR_NORTH, go_faster, 4, sub_809459C) special_anim_with_timer_2(sub_8094910, DIR_WEST, go_faster, 4, sub_809459C) special_anim_with_timer_2(sub_8094948, DIR_EAST, go_faster, 4, sub_809459C) + +an_walk_any_2_macro(sub_8094980, do_go_anim, npc_obj_ministep_stop_on_arrival, 1, 2) +an_walk_any_2_macro(sub_80949C0, do_go_anim, npc_obj_ministep_stop_on_arrival, 2, 2) +an_walk_any_2_macro(sub_8094A00, do_go_anim, npc_obj_ministep_stop_on_arrival, 3, 2) +an_walk_any_2_macro(sub_8094A40, do_go_anim, npc_obj_ministep_stop_on_arrival, 4, 2) +an_walk_any_2_macro(sub_8094A80, do_go_anim, npc_obj_ministep_stop_on_arrival, 1, 3) +an_walk_any_2_macro(sub_8094AC0, do_go_anim, npc_obj_ministep_stop_on_arrival, 2, 3) +an_walk_any_2_macro(sub_8094B00, do_go_anim, npc_obj_ministep_stop_on_arrival, 3, 3) +an_walk_any_2_macro(sub_8094B40, do_go_anim, npc_obj_ministep_stop_on_arrival, 4, 3) +an_walk_any_2_macro(sub_8094B80, do_go_anim, npc_obj_ministep_stop_on_arrival, 1, 4) +an_walk_any_2_macro(sub_8094BC0, do_go_anim, npc_obj_ministep_stop_on_arrival, 2, 4) +an_walk_any_2_macro(sub_8094C00, do_go_anim, npc_obj_ministep_stop_on_arrival, 3, 4) +an_walk_any_2_macro(sub_8094C40, do_go_anim, npc_obj_ministep_stop_on_arrival, 4, 4) From 384ca4658b84168bc836a32ebd8b17ce70279555 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 17 Sep 2017 10:29:57 -0400 Subject: [PATCH 163/191] yet more an_walk_any_2_macro functions --- asm/field_map_obj.s | 150 -------------------------------------------- src/field_map_obj.c | 64 ++++++++++--------- 2 files changed, 34 insertions(+), 180 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index d1d4596eb..7ef8e24c6 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,156 +5,6 @@ .text - thumb_func_start do_run_south_anim -@ bool8 do_run_south_anim(struct npc_state *fieldObject, struct obj *object) -do_run_south_anim: @ 8094C80 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x1 - bl do_run_anim - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8094CA0 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end do_run_south_anim - - thumb_func_start sub_8094CA0 -@ bool8 sub_8094CA0(struct npc_state *fieldObject, struct obj *object) -sub_8094CA0: @ 8094CA0 - push {r4,lr} - adds r4, r1, 0 - bl npc_obj_ministep_stop_on_arrival - lsls r0, 24 - cmp r0, 0 - bne _08094CB2 - movs r0, 0 - b _08094CB8 -_08094CB2: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_08094CB8: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8094CA0 - - thumb_func_start do_run_north_anim -do_run_north_anim: @ 8094CC0 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x2 - bl do_run_anim - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8094CE0 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end do_run_north_anim - - thumb_func_start sub_8094CE0 -sub_8094CE0: @ 8094CE0 - push {r4,lr} - adds r4, r1, 0 - bl npc_obj_ministep_stop_on_arrival - lsls r0, 24 - cmp r0, 0 - bne _08094CF2 - movs r0, 0 - b _08094CF8 -_08094CF2: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_08094CF8: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8094CE0 - - thumb_func_start do_run_west_anim -do_run_west_anim: @ 8094D00 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x3 - bl do_run_anim - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8094D20 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end do_run_west_anim - - thumb_func_start sub_8094D20 -sub_8094D20: @ 8094D20 - push {r4,lr} - adds r4, r1, 0 - bl npc_obj_ministep_stop_on_arrival - lsls r0, 24 - cmp r0, 0 - bne _08094D32 - movs r0, 0 - b _08094D38 -_08094D32: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_08094D38: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8094D20 - - thumb_func_start do_run_east_anim -do_run_east_anim: @ 8094D40 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x4 - bl do_run_anim - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8094D60 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end do_run_east_anim - - thumb_func_start sub_8094D60 -sub_8094D60: @ 8094D60 - push {r4,lr} - adds r4, r1, 0 - bl npc_obj_ministep_stop_on_arrival - lsls r0, 24 - cmp r0, 0 - bne _08094D72 - movs r0, 0 - b _08094D78 -_08094D72: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_08094D78: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8094D60 - thumb_func_start npc_set_direction_and_anim__an_proceed npc_set_direction_and_anim__an_proceed: @ 8094D80 push {r4-r6,lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index c4847ae4f..5fd92199f 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -4449,37 +4449,41 @@ bool8 sub_80945C4(struct MapObject *mapObject, struct Sprite *sprite) bool8 name(struct MapObject *mapObject, struct Sprite *sprite)\ {\ u8 animId;\ - animId = get_##images##_image_anim_num(direction);\ - sub_8094554(mapObject, sprite, direction, animId, duration);\ + animId = get_##images##_image_anim_num(DIR_##direction);\ + sub_8094554(mapObject, sprite, DIR_##direction, animId, duration);\ return timer(mapObject, sprite);\ } -special_anim_with_timer_2(sub_8094600, DIR_SOUTH, go, 32, sub_80945C4) -special_anim_with_timer_2(sub_8094638, DIR_NORTH, go, 32, sub_80945C4) -special_anim_with_timer_2(sub_8094670, DIR_WEST, go, 32, sub_80945C4) -special_anim_with_timer_2(sub_80946A8, DIR_EAST, go, 32, sub_80945C4) -special_anim_with_timer_2(sub_80946E0, DIR_SOUTH, go, 16, sub_809459C) -special_anim_with_timer_2(sub_8094718, DIR_NORTH, go, 16, sub_809459C) -special_anim_with_timer_2(sub_8094750, DIR_WEST, go, 16, sub_809459C) -special_anim_with_timer_2(sub_8094788, DIR_EAST, go, 16, sub_809459C) -special_anim_with_timer_2(sub_80947C0, DIR_SOUTH, go_fast, 8, sub_809459C) -special_anim_with_timer_2(sub_80947F8, DIR_NORTH, go_fast, 8, sub_809459C) -special_anim_with_timer_2(sub_8094830, DIR_WEST, go_fast, 8, sub_809459C) -special_anim_with_timer_2(sub_8094868, DIR_EAST, go_fast, 8, sub_809459C) -special_anim_with_timer_2(sub_80948A0, DIR_SOUTH, go_faster, 4, sub_809459C) -special_anim_with_timer_2(sub_80948D8, DIR_NORTH, go_faster, 4, sub_809459C) -special_anim_with_timer_2(sub_8094910, DIR_WEST, go_faster, 4, sub_809459C) -special_anim_with_timer_2(sub_8094948, DIR_EAST, go_faster, 4, sub_809459C) +special_anim_with_timer_2(sub_8094600, SOUTH, go, 32, sub_80945C4) +special_anim_with_timer_2(sub_8094638, NORTH, go, 32, sub_80945C4) +special_anim_with_timer_2(sub_8094670, WEST, go, 32, sub_80945C4) +special_anim_with_timer_2(sub_80946A8, EAST, go, 32, sub_80945C4) +special_anim_with_timer_2(sub_80946E0, SOUTH, go, 16, sub_809459C) +special_anim_with_timer_2(sub_8094718, NORTH, go, 16, sub_809459C) +special_anim_with_timer_2(sub_8094750, WEST, go, 16, sub_809459C) +special_anim_with_timer_2(sub_8094788, EAST, go, 16, sub_809459C) +special_anim_with_timer_2(sub_80947C0, SOUTH, go_fast, 8, sub_809459C) +special_anim_with_timer_2(sub_80947F8, NORTH, go_fast, 8, sub_809459C) +special_anim_with_timer_2(sub_8094830, WEST, go_fast, 8, sub_809459C) +special_anim_with_timer_2(sub_8094868, EAST, go_fast, 8, sub_809459C) +special_anim_with_timer_2(sub_80948A0, SOUTH, go_faster, 4, sub_809459C) +special_anim_with_timer_2(sub_80948D8, NORTH, go_faster, 4, sub_809459C) +special_anim_with_timer_2(sub_8094910, WEST, go_faster, 4, sub_809459C) +special_anim_with_timer_2(sub_8094948, EAST, go_faster, 4, sub_809459C) -an_walk_any_2_macro(sub_8094980, do_go_anim, npc_obj_ministep_stop_on_arrival, 1, 2) -an_walk_any_2_macro(sub_80949C0, do_go_anim, npc_obj_ministep_stop_on_arrival, 2, 2) -an_walk_any_2_macro(sub_8094A00, do_go_anim, npc_obj_ministep_stop_on_arrival, 3, 2) -an_walk_any_2_macro(sub_8094A40, do_go_anim, npc_obj_ministep_stop_on_arrival, 4, 2) -an_walk_any_2_macro(sub_8094A80, do_go_anim, npc_obj_ministep_stop_on_arrival, 1, 3) -an_walk_any_2_macro(sub_8094AC0, do_go_anim, npc_obj_ministep_stop_on_arrival, 2, 3) -an_walk_any_2_macro(sub_8094B00, do_go_anim, npc_obj_ministep_stop_on_arrival, 3, 3) -an_walk_any_2_macro(sub_8094B40, do_go_anim, npc_obj_ministep_stop_on_arrival, 4, 3) -an_walk_any_2_macro(sub_8094B80, do_go_anim, npc_obj_ministep_stop_on_arrival, 1, 4) -an_walk_any_2_macro(sub_8094BC0, do_go_anim, npc_obj_ministep_stop_on_arrival, 2, 4) -an_walk_any_2_macro(sub_8094C00, do_go_anim, npc_obj_ministep_stop_on_arrival, 3, 4) -an_walk_any_2_macro(sub_8094C40, do_go_anim, npc_obj_ministep_stop_on_arrival, 4, 4) +an_walk_any_2_macro(sub_8094980, do_go_anim, npc_obj_ministep_stop_on_arrival, DIR_SOUTH, 2) +an_walk_any_2_macro(sub_80949C0, do_go_anim, npc_obj_ministep_stop_on_arrival, DIR_NORTH, 2) +an_walk_any_2_macro(sub_8094A00, do_go_anim, npc_obj_ministep_stop_on_arrival, DIR_WEST, 2) +an_walk_any_2_macro(sub_8094A40, do_go_anim, npc_obj_ministep_stop_on_arrival, DIR_EAST, 2) +an_walk_any_2_macro(sub_8094A80, do_go_anim, npc_obj_ministep_stop_on_arrival, DIR_SOUTH, 3) +an_walk_any_2_macro(sub_8094AC0, do_go_anim, npc_obj_ministep_stop_on_arrival, DIR_NORTH, 3) +an_walk_any_2_macro(sub_8094B00, do_go_anim, npc_obj_ministep_stop_on_arrival, DIR_WEST, 3) +an_walk_any_2_macro(sub_8094B40, do_go_anim, npc_obj_ministep_stop_on_arrival, DIR_EAST, 3) +an_walk_any_2_macro(sub_8094B80, do_go_anim, npc_obj_ministep_stop_on_arrival, DIR_SOUTH, 4) +an_walk_any_2_macro(sub_8094BC0, do_go_anim, npc_obj_ministep_stop_on_arrival, DIR_NORTH, 4) +an_walk_any_2_macro(sub_8094C00, do_go_anim, npc_obj_ministep_stop_on_arrival, DIR_WEST, 4) +an_walk_any_2_macro(sub_8094C40, do_go_anim, npc_obj_ministep_stop_on_arrival, DIR_EAST, 4) +an_walk_any_2_macro(sub_8094C80, do_run_anim, npc_obj_ministep_stop_on_arrival, DIR_SOUTH) +an_walk_any_2_macro(sub_8094CC0, do_run_anim, npc_obj_ministep_stop_on_arrival, DIR_NORTH) +an_walk_any_2_macro(sub_8094D00, do_run_anim, npc_obj_ministep_stop_on_arrival, DIR_WEST) +an_walk_any_2_macro(sub_8094D40, do_run_anim, npc_obj_ministep_stop_on_arrival, DIR_EAST) From 9b4c61658a6a5d164ba67d6434be94540601cc83 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 17 Sep 2017 10:58:24 -0400 Subject: [PATCH 164/191] npc_set_direction_and_anim__an_proceed --- asm/field_map_obj.s | 59 --------------------------------------- include/map_obj_8097404.h | 2 ++ src/field_map_obj.c | 23 +++++++++++++++ 3 files changed, 25 insertions(+), 59 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 7ef8e24c6..958e66bd6 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,65 +5,6 @@ .text - thumb_func_start npc_set_direction_and_anim__an_proceed -npc_set_direction_and_anim__an_proceed: @ 8094D80 - push {r4-r6,lr} - adds r6, r0, 0 - adds r5, r1, 0 - adds r4, r2, 0 - adds r1, r3, 0 - lsls r4, 24 - lsrs r4, 24 - lsls r1, 24 - lsrs r1, 24 - adds r0, r5, 0 - movs r2, 0 - bl obj_anim_image_set_and_seek - adds r0, r6, 0 - adds r1, r4, 0 - bl FieldObjectSetDirection - movs r0, 0x1 - strh r0, [r5, 0x32] - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end npc_set_direction_and_anim__an_proceed - - thumb_func_start sub_8094DAC -sub_8094DAC: @ 8094DAC - push {lr} - ldrb r2, [r0, 0x18] - lsrs r2, 4 - adds r3, r1, 0 - adds r3, 0x2A - ldrb r3, [r3] - bl npc_set_direction_and_anim__an_proceed - movs r0, 0 - pop {r1} - bx r1 - thumb_func_end sub_8094DAC - - thumb_func_start sub_8094DC4 -sub_8094DC4: @ 8094DC4 - push {r4,lr} - adds r4, r1, 0 - adds r0, r4, 0 - bl sub_80979BC - lsls r0, 24 - cmp r0, 0 - bne _08094DD8 - movs r0, 0 - b _08094DDE -_08094DD8: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_08094DDE: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8094DC4 - thumb_func_start sub_8094DE4 sub_8094DE4: @ 8094DE4 push {r4,r5,lr} diff --git a/include/map_obj_8097404.h b/include/map_obj_8097404.h index 1fc653163..08b69f49a 100644 --- a/include/map_obj_8097404.h +++ b/include/map_obj_8097404.h @@ -22,5 +22,7 @@ void sub_809783C(struct Sprite *, u8, u8, u8); void DoShadowFieldEffect(struct MapObject *); u8 sub_809785C(struct Sprite *); u8 sub_80978E4(struct Sprite *); +void obj_anim_image_set_and_seek(struct Sprite *, u8, u8); +bool8 sub_80979BC(struct Sprite *); #endif //GUARD_MAP_OBJ_8097404_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 5fd92199f..e1ba386e0 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -4487,3 +4487,26 @@ an_walk_any_2_macro(sub_8094C80, do_run_anim, npc_obj_ministep_stop_on_arrival, an_walk_any_2_macro(sub_8094CC0, do_run_anim, npc_obj_ministep_stop_on_arrival, DIR_NORTH) an_walk_any_2_macro(sub_8094D00, do_run_anim, npc_obj_ministep_stop_on_arrival, DIR_WEST) an_walk_any_2_macro(sub_8094D40, do_run_anim, npc_obj_ministep_stop_on_arrival, DIR_EAST) + +void npc_set_direction_and_anim__an_proceed(struct MapObject *mapObject, struct Sprite *sprite, u8 direction, u8 animNum) +{ + obj_anim_image_set_and_seek(sprite, animNum, 0); + FieldObjectSetDirection(mapObject, direction); + sprite->data2 = 1; +} + +bool8 sub_8094DAC(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_set_direction_and_anim__an_proceed(mapObject, sprite, mapObject->placeholder18, sprite->animNum); + return FALSE; +} + +bool8 sub_8094DC4(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_80979BC(sprite)) + { + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} From 3356a4fb923d73bba9422b564bc1c0ef7e62f47c Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 17 Sep 2017 11:39:49 -0400 Subject: [PATCH 165/191] Failed attempt to fix InitFieldObjectStateFromTemplate, but at least we fixed the weirdness with the double MapObject structs --- include/global.fieldmap.h | 72 ++++----------------------------------- src/field_map_obj.c | 50 ++++++++++++++------------- 2 files changed, 33 insertions(+), 89 deletions(-) diff --git a/include/global.fieldmap.h b/include/global.fieldmap.h index 4a587cf57..ed5054b7d 100644 --- a/include/global.fieldmap.h +++ b/include/global.fieldmap.h @@ -226,71 +226,13 @@ struct MapObject /*0x14*/ struct Coords16 coords3; /*0x18*/ u8 mapobj_unk_18:4; //current direction? /*0x18*/ u8 placeholder18:4; - /*0x19*/ u8 mapobj_unk_19:4; - /*0x19*/ u8 mapobj_unk_19b:4; - /*0x1A*/ u8 mapobj_unk_1A; - /*0x1B*/ u8 mapobj_unk_1B; - /*0x1C*/ u8 mapobj_unk_1C; - /*0x1D*/ u8 trainerRange_berryTreeId; - /*0x1E*/ u8 mapobj_unk_1E; - /*0x1F*/ u8 mapobj_unk_1F; - /*0x20*/ u8 mapobj_unk_20; - /*0x21*/ u8 mapobj_unk_21; - /*0x22*/ u8 animId; - /*size = 0x24*/ -}; - -// THIS IS NEEDED TO MAKE TRAINER_SEE.C MATCH, PLEASE DO NOT REMOVE UNLESS YOU FIX CHECKPATHBETWEENTRAINERANDPLAYER -struct MapObject2 -{ - /*0x00*/ u32 active:1; - u32 mapobj_bit_1:1; - u32 mapobj_bit_2:1; - u32 mapobj_bit_3:1; - u32 mapobj_bit_4:1; - u32 mapobj_bit_5:1; - u32 mapobj_bit_6:1; - u32 mapobj_bit_7:1; - /*0x01*/ u32 mapobj_bit_8:1; - u32 mapobj_bit_9:1; - u32 mapobj_bit_10:1; - u32 mapobj_bit_11:1; - u32 mapobj_bit_12:1; - u32 mapobj_bit_13:1; - u32 mapobj_bit_14:1; - u32 mapobj_bit_15:1; - /*0x02*/ u32 mapobj_bit_16:1; - u32 mapobj_bit_17:1; - u32 mapobj_bit_18:1; - u32 mapobj_bit_19:1; - u32 mapobj_bit_20:1; - u32 mapobj_bit_21:1; - u32 mapobj_bit_22:1; - u32 mapobj_bit_23:1; - /*0x03*/ u32 mapobj_bit_24:1; - u32 mapobj_bit_25:1; - u32 mapobj_bit_26:1; - u32 mapobj_bit_27:1; - u32 mapobj_bit_28:1; - u32 mapobj_bit_29:1; - u32 mapobj_bit_30:1; - u32 mapobj_bit_31:1; - /*0x04*/ u8 spriteId; - /*0x05*/ u8 graphicsId; - /*0x06*/ u8 animPattern; - /*0x07*/ u8 trainerType; - /*0x08*/ u8 localId; - /*0x09*/ u8 mapNum; - /*0x0A*/ u8 mapGroup; - /*0x0B*/ u8 mapobj_unk_0B_0:4; - u8 elevation:4; - /*0x0C*/ struct Coords16 coords1; - /*0x10*/ struct Coords16 coords2; - /*0x14*/ struct Coords16 coords3; - /*0x18*/ u8 mapobj_unk_18:4; - /*0x18*/ u8 placeholder18:4; - /*0x19*/ u8 mapobj_unk_19:4; - /*0x19*/ u8 mapobj_unk_19b:4; + /*0x19*/ union __attribute__((packed)) { + u8 as_byte; + struct __attribute__((packed)) { + u8 x:4; + u8 y:4; + } __attribute__((aligned (1))) as_nybbles; + } __attribute__((aligned (1))) range; /*0x1A*/ u8 mapobj_unk_1A; /*0x1B*/ u8 mapobj_unk_1B; /*0x1C*/ u8 mapobj_unk_1C; diff --git a/src/field_map_obj.c b/src/field_map_obj.c index e1ba386e0..9f01e87df 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -117,7 +117,7 @@ static u32 state_to_direction(u8, u32, u32); static void FieldObjectExecSpecialAnim(struct MapObject *, struct Sprite *); /*static*/ void npc_obj_transfer_image_anim_pause_flag(struct MapObject *, struct Sprite *); -static bool8 IsCoordOutsideFieldObjectMovementRect(struct MapObject2 *, s16, s16); +static bool8 IsCoordOutsideFieldObjectMovementRect(struct MapObject *, s16, s16); static bool8 IsMetatileDirectionallyImpassable(struct MapObject *, s16, s16, u8); static bool8 CheckForCollisionBetweenFieldObjects(struct MapObject *, s16, s16); @@ -253,14 +253,15 @@ static u8 GetFieldObjectIdByLocalId(u8 localId) // This function has the same nonmatching quirk as in Ruby/Sapphire. #ifdef NONMATCHING -static u8 InitFieldObjectStateFromTemplate(struct MapObjectTemplate *template, u8 mapId, u8 mapGroupId) +static u8 InitFieldObjectStateFromTemplate(struct MapObjectTemplate *template, u8 mapNum, u8 mapGroup) { - u8 slot; struct MapObject *mapObject; - u16 x; - u16 y; + s16 x; + s16 y; + u8 slot; - if (GetAvailableFieldObjectSlot(template->localId, mapId, mapGroupId, &slot)) + // mapNum and mapGroup are in the wrong registers (r7/r6 instead of r6/r7) + if (GetAvailableFieldObjectSlot(template->localId, mapNum, mapGroup, &slot)) { return NUM_FIELD_OBJECTS; } @@ -273,8 +274,8 @@ static u8 InitFieldObjectStateFromTemplate(struct MapObjectTemplate *template, u mapObject->graphicsId = template->graphicsId; mapObject->animPattern = template->movementType; mapObject->localId = template->localId; - mapObject->mapNum = mapId; - mapObject->mapGroup = mapGroupId; + mapObject->mapNum = mapNum; + mapObject->mapGroup = mapGroup; mapObject->coords1.x = x; mapObject->coords1.y = y; mapObject->coords2.x = x; @@ -283,24 +284,25 @@ static u8 InitFieldObjectStateFromTemplate(struct MapObjectTemplate *template, u mapObject->coords3.y = y; mapObject->mapobj_unk_0B_0 = template->elevation; mapObject->elevation = template->elevation; - mapObject->mapobj_unk_19 = template->unkA_0; - mapObject->mapobj_unk_19b = template->unkA_4; + // For some reason, 0x0F is placed in r9, to be used later + mapObject->range.as_nybbles.x = template->unkA_0; + mapObject->range.as_nybbles.y = template->unkA_4; mapObject->trainerType = template->unkC; mapObject->trainerRange_berryTreeId = template->unkE; mapObject->mapobj_unk_20 = gUnknown_085055CD[template->movementType]; FieldObjectSetDirection(mapObject, mapObject->mapobj_unk_20); FieldObjectHandleDynamicGraphicsId(mapObject); - // This block is the culprit if (gUnknown_0850557C[mapObject->animPattern]) { - if (mapObject->mapobj_unk_19 == 0) + if ((mapObject->range.as_nybbles.x) == 0) { - mapObject->mapobj_unk_19 ++; + // r9 is invoked here + mapObject->range.as_nybbles.x ++; } - if (mapObject->mapobj_unk_19b == 0) + if ((mapObject->range.as_nybbles.y) == 0) { - mapObject->mapobj_unk_19b ++; + mapObject->range.as_nybbles.y ++; } } return slot; @@ -3654,7 +3656,7 @@ u8 npc_block_way(struct MapObject *mapObject, s16 x, s16 y, u32 dirn) u8 direction; direction = dirn; - if (IsCoordOutsideFieldObjectMovementRect((struct MapObject2 *)mapObject, x, y)) + if (IsCoordOutsideFieldObjectMovementRect(mapObject, x, y)) { return 1; } @@ -3682,7 +3684,7 @@ u8 sub_8092C8C(struct MapObject *mapObject, s16 x, s16 y, u8 direction) u8 retval; retval = 0x00; - if (IsCoordOutsideFieldObjectMovementRect((struct MapObject2 *)mapObject, x, y)) + if (IsCoordOutsideFieldObjectMovementRect(mapObject, x, y)) { retval |= 1; } @@ -3701,26 +3703,26 @@ u8 sub_8092C8C(struct MapObject *mapObject, s16 x, s16 y, u8 direction) return retval; } -static bool8 IsCoordOutsideFieldObjectMovementRect(struct MapObject2 *mapObject, s16 x, s16 y) +static bool8 IsCoordOutsideFieldObjectMovementRect(struct MapObject *mapObject, s16 x, s16 y) { s16 left; s16 right; s16 top; s16 bottom; - if (mapObject->mapobj_unk_19 != 0) + if (mapObject->range.as_nybbles.x != 0) { - left = mapObject->coords1.x - mapObject->mapobj_unk_19; - right = mapObject->coords1.x + mapObject->mapobj_unk_19; + left = mapObject->coords1.x - mapObject->range.as_nybbles.x; + right = mapObject->coords1.x + mapObject->range.as_nybbles.x; if (left > x || right < x) { return TRUE; } } - if (mapObject->mapobj_unk_19b != 0) + if (mapObject->range.as_nybbles.y != 0) { - top = mapObject->coords1.y - mapObject->mapobj_unk_19b; - bottom = mapObject->coords1.y + mapObject->mapobj_unk_19b; + top = mapObject->coords1.y - mapObject->range.as_nybbles.y; + bottom = mapObject->coords1.y + mapObject->range.as_nybbles.y; if (top > y || bottom < y) { return TRUE; From 20152fb0aff7e4e7de34be319f6ce120ae09aaa1 Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 17 Sep 2017 12:19:35 -0400 Subject: [PATCH 166/191] Yet Another Macro Cluster TM --- asm/field_map_obj.s | 194 -------------------------------------------- src/field_map_obj.c | 29 +++++++ 2 files changed, 29 insertions(+), 194 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 958e66bd6..cd3f7022a 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,200 +5,6 @@ .text - thumb_func_start sub_8094DE4 -sub_8094DE4: @ 8094DE4 - push {r4,r5,lr} - sub sp, 0x4 - adds r5, r1, 0 - lsls r4, r2, 24 - lsrs r4, 24 - movs r1, 0 - str r1, [sp] - adds r1, r5, 0 - adds r2, r4, 0 - movs r3, 0x1 - bl sub_8093FC4 - adds r0, r4, 0 - bl sub_80929AC - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 24 - adds r0, r5, 0 - bl StartSpriteAnim - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_8094DE4 - - thumb_func_start sub_8094E18 -sub_8094E18: @ 8094E18 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x1 - bl sub_8094DE4 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8094E38 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8094E18 - - thumb_func_start sub_8094E38 -sub_8094E38: @ 8094E38 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl sub_80941C8 - lsls r0, 24 - cmp r0, 0 - bne _08094E4C - movs r0, 0 - b _08094E5A -_08094E4C: - movs r0, 0x2 - strh r0, [r5, 0x32] - ldrb r1, [r4] - subs r0, 0x23 - ands r0, r1 - strb r0, [r4] - movs r0, 0x1 -_08094E5A: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8094E38 - - thumb_func_start sub_8094E60 -sub_8094E60: @ 8094E60 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x2 - bl sub_8094DE4 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8094E80 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8094E60 - - thumb_func_start sub_8094E80 -sub_8094E80: @ 8094E80 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl sub_80941C8 - lsls r0, 24 - cmp r0, 0 - bne _08094E94 - movs r0, 0 - b _08094EA2 -_08094E94: - movs r0, 0x2 - strh r0, [r5, 0x32] - ldrb r1, [r4] - subs r0, 0x23 - ands r0, r1 - strb r0, [r4] - movs r0, 0x1 -_08094EA2: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8094E80 - - thumb_func_start sub_8094EA8 -sub_8094EA8: @ 8094EA8 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x3 - bl sub_8094DE4 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8094EC8 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8094EA8 - - thumb_func_start sub_8094EC8 -sub_8094EC8: @ 8094EC8 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl sub_80941C8 - lsls r0, 24 - cmp r0, 0 - bne _08094EDC - movs r0, 0 - b _08094EEA -_08094EDC: - movs r0, 0x2 - strh r0, [r5, 0x32] - ldrb r1, [r4] - subs r0, 0x23 - ands r0, r1 - strb r0, [r4] - movs r0, 0x1 -_08094EEA: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8094EC8 - - thumb_func_start sub_8094EF0 -sub_8094EF0: @ 8094EF0 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x4 - bl sub_8094DE4 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8094F10 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8094EF0 - - thumb_func_start sub_8094F10 -sub_8094F10: @ 8094F10 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl sub_80941C8 - lsls r0, 24 - cmp r0, 0 - bne _08094F24 - movs r0, 0 - b _08094F32 -_08094F24: - movs r0, 0x2 - strh r0, [r5, 0x32] - ldrb r1, [r4] - subs r0, 0x23 - ands r0, r1 - strb r0, [r4] - movs r0, 0x1 -_08094F32: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8094F10 - thumb_func_start sub_8094F38 sub_8094F38: @ 8094F38 push {r4-r6,lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 9f01e87df..1d91184ec 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -4512,3 +4512,32 @@ bool8 sub_8094DC4(struct MapObject *mapObject, struct Sprite *sprite) } return FALSE; } + +void sub_8094DE4(struct MapObject *mapObject, struct Sprite *sprite, u8 direction) +{ + sub_8093FC4(mapObject, sprite, direction, 1, 0); + StartSpriteAnim(sprite, sub_80929AC(direction)); +} + +#define unk_macro_8094E18(name, direction)\ +static bool8 name##_2(struct MapObject *, struct Sprite *);\ +bool8 name(struct MapObject *mapObject, struct Sprite *sprite)\ +{\ + sub_8094DE4(mapObject, sprite, direction);\ + return name##_2(mapObject, sprite);\ +}\ +static bool8 name##_2(struct MapObject *mapObject, struct Sprite *sprite)\ +{\ + if (sub_80941C8(mapObject, sprite))\ + {\ + sprite->data2 = 2;\ + mapObject->mapobj_bit_5 = FALSE;\ + return TRUE;\ + }\ + return FALSE;\ +} + +unk_macro_8094E18(sub_8094E18, DIR_SOUTH) +unk_macro_8094E18(sub_8094E60, DIR_NORTH) +unk_macro_8094E18(sub_8094EB8, DIR_WEST) +unk_macro_8094E18(sub_8094710, DIR_EAST) From b06631f6540bc1b08613e08edb0f615ec1d3c28d Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 17 Sep 2017 12:25:27 -0400 Subject: [PATCH 167/191] Functions for facing towards/away from another object? --- asm/field_map_obj.s | 95 --------------------------------------------- src/field_map_obj.c | 24 ++++++++++++ 2 files changed, 24 insertions(+), 95 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index cd3f7022a..5b81fa7b5 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,101 +5,6 @@ .text - thumb_func_start sub_8094F38 -sub_8094F38: @ 8094F38 - push {r4-r6,lr} - sub sp, 0x4 - adds r5, r0, 0 - adds r6, r1, 0 - movs r0, 0xFF - movs r1, 0 - movs r2, 0 - mov r3, sp - bl TryGetFieldObjectIdByLocalIdAndMap - lsls r0, 24 - cmp r0, 0 - bne _08094F82 - movs r1, 0x10 - ldrsh r0, [r5, r1] - movs r2, 0x12 - ldrsh r1, [r5, r2] - ldr r4, =gMapObjects - mov r2, sp - ldrb r2, [r2] - lsls r3, r2, 3 - adds r3, r2 - lsls r3, 2 - adds r3, r4 - movs r4, 0x10 - ldrsh r2, [r3, r4] - movs r4, 0x12 - ldrsh r3, [r3, r4] - bl sub_8092AF8 - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r5, 0 - adds r1, r6, 0 - bl an_look_any -_08094F82: - movs r0, 0x1 - strh r0, [r6, 0x32] - add sp, 0x4 - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8094F38 - - thumb_func_start sub_8094F94 -sub_8094F94: @ 8094F94 - push {r4-r6,lr} - sub sp, 0x4 - adds r5, r0, 0 - adds r6, r1, 0 - movs r0, 0xFF - movs r1, 0 - movs r2, 0 - mov r3, sp - bl TryGetFieldObjectIdByLocalIdAndMap - lsls r0, 24 - cmp r0, 0 - bne _08094FE6 - movs r1, 0x10 - ldrsh r0, [r5, r1] - movs r2, 0x12 - ldrsh r1, [r5, r2] - ldr r4, =gMapObjects - mov r2, sp - ldrb r2, [r2] - lsls r3, r2, 3 - adds r3, r2 - lsls r3, 2 - adds r3, r4 - movs r4, 0x10 - ldrsh r2, [r3, r4] - movs r4, 0x12 - ldrsh r3, [r3, r4] - bl sub_8092AF8 - lsls r0, 24 - lsrs r0, 24 - bl GetOppositeDirection - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r5, 0 - adds r1, r6, 0 - bl an_look_any -_08094FE6: - movs r0, 0x1 - strh r0, [r6, 0x32] - add sp, 0x4 - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8094F94 - thumb_func_start sub_8094FF8 sub_8094FF8: @ 8094FF8 ldrb r2, [r0, 0x1] diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 1d91184ec..c4b1255ad 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -4541,3 +4541,27 @@ unk_macro_8094E18(sub_8094E18, DIR_SOUTH) unk_macro_8094E18(sub_8094E60, DIR_NORTH) unk_macro_8094E18(sub_8094EB8, DIR_WEST) unk_macro_8094E18(sub_8094710, DIR_EAST) + +bool8 sub_8094F38(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 mapObjectId; + + if (!TryGetFieldObjectIdByLocalIdAndMap(0xFF, 0, 0, &mapObjectId)) + { + an_look_any(mapObject, sprite, sub_8092AF8(mapObject->coords2.x, mapObject->coords2.y, gMapObjects[mapObjectId].coords2.x, gMapObjects[mapObjectId].coords2.y)); + } + sprite->data2 = 1; + return TRUE; +} + +bool8 sub_8094F94(struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 mapObjectId; + + if (!TryGetFieldObjectIdByLocalIdAndMap(0xFF, 0, 0, &mapObjectId)) + { + an_look_any(mapObject, sprite, GetOppositeDirection(sub_8092AF8(mapObject->coords2.x, mapObject->coords2.y, gMapObjects[mapObjectId].coords2.x, gMapObjects[mapObjectId].coords2.y))); + } + sprite->data2 = 1; + return TRUE; +} From 92a3f1cb2e2dae3275a595b847d3ffcf05817663 Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 17 Sep 2017 12:57:42 -0400 Subject: [PATCH 168/191] More maybe_shadow_1_macro memes --- asm/field_map_obj.s | 611 -------------------------------------------- src/field_map_obj.c | 27 ++ 2 files changed, 27 insertions(+), 611 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 5b81fa7b5..86baf1b30 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,617 +5,6 @@ .text - thumb_func_start sub_8094FF8 -sub_8094FF8: @ 8094FF8 - ldrb r2, [r0, 0x1] - movs r3, 0x2 - orrs r2, r3 - strb r2, [r0, 0x1] - movs r0, 0x1 - strh r0, [r1, 0x32] - bx lr - thumb_func_end sub_8094FF8 - - thumb_func_start sub_8095008 -sub_8095008: @ 8095008 - ldrb r3, [r0, 0x1] - movs r2, 0x3 - negs r2, r2 - ands r2, r3 - strb r2, [r0, 0x1] - movs r0, 0x1 - strh r0, [r1, 0x32] - bx lr - thumb_func_end sub_8095008 - - thumb_func_start sub_8095018 -sub_8095018: @ 8095018 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0x2 - str r0, [sp] - adds r0, r4, 0 - movs r2, 0x1 - movs r3, 0x1 - bl maybe_shadow_1 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8095044 - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095018 - - thumb_func_start sub_8095044 -sub_8095044: @ 8095044 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl sub_80941B0 - lsls r0, 24 - cmp r0, 0 - bne _08095058 - movs r0, 0 - b _08095068 -_08095058: - ldrb r0, [r4, 0x2] - movs r1, 0x41 - negs r1, r1 - ands r1, r0 - strb r1, [r4, 0x2] - movs r0, 0x2 - strh r0, [r5, 0x32] - movs r0, 0x1 -_08095068: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095044 - - thumb_func_start sub_8095070 -sub_8095070: @ 8095070 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0x2 - str r0, [sp] - adds r0, r4, 0 - movs r2, 0x2 - movs r3, 0x1 - bl maybe_shadow_1 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_809509C - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095070 - - thumb_func_start sub_809509C -sub_809509C: @ 809509C - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl sub_80941B0 - lsls r0, 24 - cmp r0, 0 - bne _080950B0 - movs r0, 0 - b _080950C0 -_080950B0: - ldrb r0, [r4, 0x2] - movs r1, 0x41 - negs r1, r1 - ands r1, r0 - strb r1, [r4, 0x2] - movs r0, 0x2 - strh r0, [r5, 0x32] - movs r0, 0x1 -_080950C0: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_809509C - - thumb_func_start sub_80950C8 -sub_80950C8: @ 80950C8 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0x2 - str r0, [sp] - adds r0, r4, 0 - movs r2, 0x3 - movs r3, 0x1 - bl maybe_shadow_1 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_80950F4 - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80950C8 - - thumb_func_start sub_80950F4 -sub_80950F4: @ 80950F4 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl sub_80941B0 - lsls r0, 24 - cmp r0, 0 - bne _08095108 - movs r0, 0 - b _08095118 -_08095108: - ldrb r0, [r4, 0x2] - movs r1, 0x41 - negs r1, r1 - ands r1, r0 - strb r1, [r4, 0x2] - movs r0, 0x2 - strh r0, [r5, 0x32] - movs r0, 0x1 -_08095118: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80950F4 - - thumb_func_start sub_8095120 -sub_8095120: @ 8095120 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0x2 - str r0, [sp] - adds r0, r4, 0 - movs r2, 0x4 - movs r3, 0x1 - bl maybe_shadow_1 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_809514C - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095120 - - thumb_func_start sub_809514C -sub_809514C: @ 809514C - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl sub_80941B0 - lsls r0, 24 - cmp r0, 0 - bne _08095160 - movs r0, 0 - b _08095170 -_08095160: - ldrb r0, [r4, 0x2] - movs r1, 0x41 - negs r1, r1 - ands r1, r0 - strb r1, [r4, 0x2] - movs r0, 0x2 - strh r0, [r5, 0x32] - movs r0, 0x1 -_08095170: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_809514C - - thumb_func_start sub_8095178 -sub_8095178: @ 8095178 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0 - str r0, [sp] - adds r0, r4, 0 - movs r2, 0x1 - movs r3, 0 - bl maybe_shadow_1 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_80951A4 - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095178 - - thumb_func_start sub_80951A4 -sub_80951A4: @ 80951A4 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl sub_80941B0 - lsls r0, 24 - cmp r0, 0 - bne _080951B8 - movs r0, 0 - b _080951C8 -_080951B8: - ldrb r0, [r4, 0x2] - movs r1, 0x41 - negs r1, r1 - ands r1, r0 - strb r1, [r4, 0x2] - movs r0, 0x2 - strh r0, [r5, 0x32] - movs r0, 0x1 -_080951C8: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80951A4 - - thumb_func_start sub_80951D0 -sub_80951D0: @ 80951D0 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0 - str r0, [sp] - adds r0, r4, 0 - movs r2, 0x2 - movs r3, 0 - bl maybe_shadow_1 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_80951FC - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80951D0 - - thumb_func_start sub_80951FC -sub_80951FC: @ 80951FC - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl sub_80941B0 - lsls r0, 24 - cmp r0, 0 - bne _08095210 - movs r0, 0 - b _08095220 -_08095210: - ldrb r0, [r4, 0x2] - movs r1, 0x41 - negs r1, r1 - ands r1, r0 - strb r1, [r4, 0x2] - movs r0, 0x2 - strh r0, [r5, 0x32] - movs r0, 0x1 -_08095220: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80951FC - - thumb_func_start sub_8095228 -sub_8095228: @ 8095228 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0 - str r0, [sp] - adds r0, r4, 0 - movs r2, 0x3 - movs r3, 0 - bl maybe_shadow_1 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8095254 - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095228 - - thumb_func_start sub_8095254 -sub_8095254: @ 8095254 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl sub_80941B0 - lsls r0, 24 - cmp r0, 0 - bne _08095268 - movs r0, 0 - b _08095278 -_08095268: - ldrb r0, [r4, 0x2] - movs r1, 0x41 - negs r1, r1 - ands r1, r0 - strb r1, [r4, 0x2] - movs r0, 0x2 - strh r0, [r5, 0x32] - movs r0, 0x1 -_08095278: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095254 - - thumb_func_start sub_8095280 -sub_8095280: @ 8095280 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0 - str r0, [sp] - adds r0, r4, 0 - movs r2, 0x4 - movs r3, 0 - bl maybe_shadow_1 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_80952AC - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095280 - - thumb_func_start sub_80952AC -sub_80952AC: @ 80952AC - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl sub_80941B0 - lsls r0, 24 - cmp r0, 0 - bne _080952C0 - movs r0, 0 - b _080952D0 -_080952C0: - ldrb r0, [r4, 0x2] - movs r1, 0x41 - negs r1, r1 - ands r1, r0 - strb r1, [r4, 0x2] - movs r0, 0x2 - strh r0, [r5, 0x32] - movs r0, 0x1 -_080952D0: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80952AC - - thumb_func_start sub_80952D8 -sub_80952D8: @ 80952D8 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0x2 - str r0, [sp] - adds r0, r4, 0 - movs r2, 0x1 - movs r3, 0 - bl maybe_shadow_1 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8095304 - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80952D8 - - thumb_func_start sub_8095304 -sub_8095304: @ 8095304 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl sub_80941E0 - lsls r0, 24 - cmp r0, 0 - bne _08095318 - movs r0, 0 - b _08095328 -_08095318: - ldrb r0, [r4, 0x2] - movs r1, 0x41 - negs r1, r1 - ands r1, r0 - strb r1, [r4, 0x2] - movs r0, 0x2 - strh r0, [r5, 0x32] - movs r0, 0x1 -_08095328: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095304 - - thumb_func_start sub_8095330 -sub_8095330: @ 8095330 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0x2 - str r0, [sp] - adds r0, r4, 0 - movs r2, 0x2 - movs r3, 0 - bl maybe_shadow_1 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_809535C - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095330 - - thumb_func_start sub_809535C -sub_809535C: @ 809535C - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl sub_80941E0 - lsls r0, 24 - cmp r0, 0 - bne _08095370 - movs r0, 0 - b _08095380 -_08095370: - ldrb r0, [r4, 0x2] - movs r1, 0x41 - negs r1, r1 - ands r1, r0 - strb r1, [r4, 0x2] - movs r0, 0x2 - strh r0, [r5, 0x32] - movs r0, 0x1 -_08095380: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_809535C - - thumb_func_start sub_8095388 -sub_8095388: @ 8095388 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0x2 - str r0, [sp] - adds r0, r4, 0 - movs r2, 0x3 - movs r3, 0 - bl maybe_shadow_1 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_80953B4 - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095388 - - thumb_func_start sub_80953B4 -sub_80953B4: @ 80953B4 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl sub_80941E0 - lsls r0, 24 - cmp r0, 0 - bne _080953C8 - movs r0, 0 - b _080953D8 -_080953C8: - ldrb r0, [r4, 0x2] - movs r1, 0x41 - negs r1, r1 - ands r1, r0 - strb r1, [r4, 0x2] - movs r0, 0x2 - strh r0, [r5, 0x32] - movs r0, 0x1 -_080953D8: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80953B4 - - thumb_func_start sub_80953E0 -sub_80953E0: @ 80953E0 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0x2 - str r0, [sp] - adds r0, r4, 0 - movs r2, 0x4 - movs r3, 0 - bl maybe_shadow_1 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_809540C - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80953E0 - - thumb_func_start sub_809540C -sub_809540C: @ 809540C - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl sub_80941E0 - lsls r0, 24 - cmp r0, 0 - bne _08095420 - movs r0, 0 - b _08095430 -_08095420: - ldrb r0, [r4, 0x2] - movs r1, 0x41 - negs r1, r1 - ands r1, r0 - strb r1, [r4, 0x2] - movs r0, 0x2 - strh r0, [r5, 0x32] - movs r0, 0x1 -_08095430: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_809540C - thumb_func_start sub_8095438 sub_8095438: @ 8095438 push {lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index c4b1255ad..db28ce1ca 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -4565,3 +4565,30 @@ bool8 sub_8094F94(struct MapObject *mapObject, struct Sprite *sprite) sprite->data2 = 1; return TRUE; } + +bool8 sub_8094FF8(struct MapObject *mapObject, struct Sprite *sprite) +{ + mapObject->mapobj_bit_9 = TRUE; + sprite->data2 = 1; + return TRUE; +} + +bool8 sub_8095008(struct MapObject *mapObject, struct Sprite *sprite) +{ + mapObject->mapobj_bit_9 = FALSE; + sprite->data2 = 1; + return TRUE; +} + +maybe_shadow_1_macro(sub_8095018, maybe_shadow_1, sub_80941B0, DIR_SOUTH, 1, 2) +maybe_shadow_1_macro(sub_8095070, maybe_shadow_1, sub_80941B0, DIR_NORTH, 1, 2) +maybe_shadow_1_macro(sub_80950C8, maybe_shadow_1, sub_80941B0, DIR_WEST, 1, 2) +maybe_shadow_1_macro(sub_8095120, maybe_shadow_1, sub_80941B0, DIR_EAST, 1, 2) +maybe_shadow_1_macro(sub_8095178, maybe_shadow_1, sub_80941B0, DIR_SOUTH, 0, 0) +maybe_shadow_1_macro(sub_80951D0, maybe_shadow_1, sub_80941B0, DIR_NORTH, 0, 0) +maybe_shadow_1_macro(sub_8095228, maybe_shadow_1, sub_80941B0, DIR_WEST, 0, 0) +maybe_shadow_1_macro(sub_8095280, maybe_shadow_1, sub_80941B0, DIR_EAST, 0, 0) +maybe_shadow_1_macro(sub_80952D8, maybe_shadow_1, sub_80941E0, DIR_SOUTH, 0, 2) +maybe_shadow_1_macro(sub_8095330, maybe_shadow_1, sub_80941E0, DIR_NORTH, 0, 2) +maybe_shadow_1_macro(sub_8095388, maybe_shadow_1, sub_80941E0, DIR_WEST, 0, 2) +maybe_shadow_1_macro(sub_80953E0, maybe_shadow_1, sub_80941E0, DIR_EAST, 0, 2) From 513e3cd9bcd7628b9f2f24ab0e7a5f78763cf44e Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 17 Sep 2017 13:00:43 -0400 Subject: [PATCH 169/191] Five small functions --- asm/field_map_obj.s | 59 --------------------------------------------- src/field_map_obj.c | 33 +++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 59 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 86baf1b30..f560a9372 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,65 +5,6 @@ .text - thumb_func_start sub_8095438 -sub_8095438: @ 8095438 - push {lr} - ldr r3, =gUnknown_085055CD - ldrb r2, [r0, 0x6] - adds r2, r3 - ldrb r2, [r2] - bl an_look_any - movs r0, 0x1 - pop {r1} - bx r1 - .pool - thumb_func_end sub_8095438 - - thumb_func_start sub_8095450 -sub_8095450: @ 8095450 - push {lr} - movs r2, 0x1 - movs r3, 0x14 - bl npc_set_direction_and_anim__an_proceed - movs r0, 0 - pop {r1} - bx r1 - thumb_func_end sub_8095450 - - thumb_func_start sub_8095460 -sub_8095460: @ 8095460 - ldrb r3, [r0, 0x3] - movs r2, 0x3 - negs r2, r2 - ands r2, r3 - strb r2, [r0, 0x3] - movs r0, 0x1 - strh r0, [r1, 0x32] - bx lr - thumb_func_end sub_8095460 - - thumb_func_start sub_8095470 -sub_8095470: @ 8095470 - ldrb r2, [r0, 0x3] - movs r3, 0x2 - orrs r2, r3 - strb r2, [r0, 0x3] - movs r0, 0x1 - strh r0, [r1, 0x32] - bx lr - thumb_func_end sub_8095470 - - thumb_func_start sub_8095480 -sub_8095480: @ 8095480 - ldrb r2, [r0, 0x1] - movs r3, 0x10 - orrs r2, r3 - strb r2, [r0, 0x1] - movs r0, 0x1 - strh r0, [r1, 0x32] - bx lr - thumb_func_end sub_8095480 - thumb_func_start sub_8095490 @ int sub_8095490(npc_state *npcState, int a2) sub_8095490: @ 8095490 diff --git a/src/field_map_obj.c b/src/field_map_obj.c index db28ce1ca..b337349a2 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -4592,3 +4592,36 @@ maybe_shadow_1_macro(sub_80952D8, maybe_shadow_1, sub_80941E0, DIR_SOUTH, 0, 2) maybe_shadow_1_macro(sub_8095330, maybe_shadow_1, sub_80941E0, DIR_NORTH, 0, 2) maybe_shadow_1_macro(sub_8095388, maybe_shadow_1, sub_80941E0, DIR_WEST, 0, 2) maybe_shadow_1_macro(sub_80953E0, maybe_shadow_1, sub_80941E0, DIR_EAST, 0, 2) + +bool8 sub_8095438(struct MapObject *mapObject, struct Sprite *sprite) +{ + an_look_any(mapObject, sprite, gUnknown_085055CD[mapObject->animPattern]); + return TRUE; +} + +bool8 sub_8095450(struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_set_direction_and_anim__an_proceed(mapObject, sprite, DIR_SOUTH, 0x14); + return FALSE; +} + +bool8 sub_8095460(struct MapObject *mapObject, struct Sprite *sprite) +{ + mapObject->mapobj_bit_25 = FALSE; + sprite->data2 = 1; + return TRUE; +} + +bool8 sub_8095470(struct MapObject *mapObject, struct Sprite *sprite) +{ + mapObject->mapobj_bit_25 = TRUE; + sprite->data2 = 1; + return TRUE; +} + +bool8 sub_8095480(struct MapObject *mapObject, struct Sprite *sprite) +{ + mapObject->mapobj_bit_12 = TRUE; + sprite->data2 = 1; + return TRUE; +} From 7af98338830aaeb33be4c28dc26f14cc788f9df7 Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 17 Sep 2017 13:06:03 -0400 Subject: [PATCH 170/191] Additional script object callbacks --- asm/field_map_obj.s | 105 -------------------------------------------- src/field_map_obj.c | 45 +++++++++++++++++++ 2 files changed, 45 insertions(+), 105 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index f560a9372..526b37db6 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,111 +5,6 @@ .text - thumb_func_start sub_8095490 -@ int sub_8095490(npc_state *npcState, int a2) -sub_8095490: @ 8095490 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - ldrb r0, [r4, 0x5] - bl GetFieldObjectGraphicsInfo - ldrb r1, [r0, 0xC] - lsls r1, 25 - lsrs r1, 31 - lsls r1, 4 - ldrb r2, [r4, 0x1] - movs r0, 0x11 - negs r0, r0 - ands r0, r2 - orrs r0, r1 - strb r0, [r4, 0x1] - movs r0, 0x1 - strh r0, [r5, 0x32] - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095490 - - thumb_func_start sub_80954BC -sub_80954BC: @ 80954BC - ldrb r2, [r0, 0x1] - movs r3, 0x20 - orrs r2, r3 - strb r2, [r0, 0x1] - movs r0, 0x1 - strh r0, [r1, 0x32] - bx lr - thumb_func_end sub_80954BC - - thumb_func_start sub_80954CC -sub_80954CC: @ 80954CC - ldrb r3, [r0, 0x1] - movs r2, 0x21 - negs r2, r2 - ands r2, r3 - strb r2, [r0, 0x1] - movs r0, 0x1 - strh r0, [r1, 0x32] - bx lr - thumb_func_end sub_80954CC - - thumb_func_start do_exclamation_mark_bubble_1 -do_exclamation_mark_bubble_1: @ 80954DC - push {r4,lr} - adds r4, r1, 0 - ldr r1, =gFieldEffectSpawnParams - adds r2, r1, 0x4 - adds r3, r1, 0 - adds r3, 0x8 - bl FieldObjectGetLocalIdAndMap - movs r0, 0 - bl FieldEffectStart - movs r0, 0x1 - strh r0, [r4, 0x32] - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end do_exclamation_mark_bubble_1 - - thumb_func_start do_exclamation_mark_bubble_2 -do_exclamation_mark_bubble_2: @ 8095500 - push {r4,lr} - adds r4, r1, 0 - ldr r1, =gFieldEffectSpawnParams - adds r2, r1, 0x4 - adds r3, r1, 0 - adds r3, 0x8 - bl FieldObjectGetLocalIdAndMap - movs r0, 0x21 - bl FieldEffectStart - movs r0, 0x1 - strh r0, [r4, 0x32] - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end do_exclamation_mark_bubble_2 - - thumb_func_start do_heart_bubble -do_heart_bubble: @ 8095524 - push {r4,lr} - adds r4, r1, 0 - ldr r1, =gFieldEffectSpawnParams - adds r2, r1, 0x4 - adds r3, r1, 0 - adds r3, 0x8 - bl FieldObjectGetLocalIdAndMap - movs r0, 0x2E - bl FieldEffectStart - movs r0, 0x1 - strh r0, [r4, 0x32] - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end do_heart_bubble - thumb_func_start sub_8095548 sub_8095548: @ 8095548 push {r4,r5,lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index b337349a2..432eb5b47 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -4625,3 +4625,48 @@ bool8 sub_8095480(struct MapObject *mapObject, struct Sprite *sprite) sprite->data2 = 1; return TRUE; } + +bool8 sub_8095490(struct MapObject *mapObject, struct Sprite *sprite) +{ + mapObject->mapobj_bit_12 = GetFieldObjectGraphicsInfo(mapObject->graphicsId)->inanimate; + sprite->data2 = 1; + return TRUE; +} + +bool8 sub_80954BC(struct MapObject *mapObject, struct Sprite *sprite) +{ + mapObject->mapobj_bit_13 = TRUE; + sprite->data2 = 1; + return TRUE; +} + +bool8 sub_80954CC(struct MapObject *mapObject, struct Sprite *sprite) +{ + mapObject->mapobj_bit_13 = FALSE; + sprite->data2 = 1; + return TRUE; +} + +bool8 do_exclamation_mark_bubble_1(struct MapObject *mapObject, struct Sprite *sprite) +{ + FieldObjectGetLocalIdAndMap(mapObject, (u8 *)&gFieldEffectSpawnParams[0], (u8 *)&gFieldEffectSpawnParams[1], (u8 *)&gFieldEffectSpawnParams[2]); + FieldEffectStart(FLDEFF_EXCLAMATION_MARK_ICON_1); + sprite->data2 = 1; + return TRUE; +} + +bool8 do_exclamation_mark_bubble_2(struct MapObject *mapObject, struct Sprite *sprite) +{ + FieldObjectGetLocalIdAndMap(mapObject, (u8 *)&gFieldEffectSpawnParams[0], (u8 *)&gFieldEffectSpawnParams[1], (u8 *)&gFieldEffectSpawnParams[2]); + FieldEffectStart(FLDEFF_EXCLAMATION_MARK_ICON_2); + sprite->data2 = 1; + return TRUE; +} + +bool8 do_heart_bubble(struct MapObject *mapObject, struct Sprite *sprite) +{ + FieldObjectGetLocalIdAndMap(mapObject, (u8 *)&gFieldEffectSpawnParams[0], (u8 *)&gFieldEffectSpawnParams[1], (u8 *)&gFieldEffectSpawnParams[2]); + FieldEffectStart(FLDEFF_HEART_ICON); + sprite->data2 = 1; + return TRUE; +} From 4b04e92e8b236d91ea5cc45813f914f10a86b748 Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 17 Sep 2017 13:26:17 -0400 Subject: [PATCH 171/191] Ten more functions (remaining function count is 99) --- asm/field_map_obj.s | 221 --------------------------------- include/field_effect_helpers.h | 1 + include/trainer_see.h | 7 ++ src/field_map_obj.c | 99 +++++++++++++++ 4 files changed, 107 insertions(+), 221 deletions(-) create mode 100644 include/trainer_see.h diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 526b37db6..18e4298a0 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,227 +5,6 @@ .text - thumb_func_start sub_8095548 -sub_8095548: @ 8095548 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - ldrb r0, [r4, 0x6] - cmp r0, 0x3F - bne _0809555E - adds r0, r4, 0 - bl sub_80B4578 - movs r0, 0 - b _08095586 -_0809555E: - subs r0, 0x39 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bhi _08095580 - adds r0, r4, 0 - bl sub_8155D78 - movs r0, 0x1 - strh r0, [r5, 0x32] - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_809558C - lsls r0, 24 - lsrs r0, 24 - b _08095586 -_08095580: - movs r0, 0x2 - strh r0, [r5, 0x32] - movs r0, 0x1 -_08095586: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095548 - - thumb_func_start sub_809558C -sub_809558C: @ 809558C - push {r4,lr} - adds r4, r1, 0 - bl sub_8155DA0 - lsls r0, 24 - cmp r0, 0 - bne _0809559E - movs r0, 0 - b _080955A4 -_0809559E: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_080955A4: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_809558C - - thumb_func_start sub_80955AC -sub_80955AC: @ 80955AC - push {r4,lr} - adds r4, r1, 0 - adds r0, r4, 0 - movs r1, 0x1 - movs r2, 0 - bl obj_anim_image_set_and_seek - movs r0, 0x1 - strh r0, [r4, 0x32] - movs r0, 0 - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_80955AC - - thumb_func_start sub_80955C8 -sub_80955C8: @ 80955C8 - push {r4,lr} - adds r4, r1, 0 - adds r0, r4, 0 - bl sub_80979BC - lsls r0, 24 - cmp r0, 0 - beq _080955E4 - adds r0, r4, 0 - movs r1, 0x20 - bl SetFieldObjectStepTimer - movs r0, 0x2 - strh r0, [r4, 0x32] -_080955E4: - movs r0, 0 - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_80955C8 - - thumb_func_start sub_80955EC -sub_80955EC: @ 80955EC - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - ldrb r2, [r4, 0x1] - lsls r1, r2, 26 - lsrs r1, 31 - movs r0, 0x1 - eors r1, r0 - lsls r1, 5 - subs r0, 0x22 - ands r0, r2 - orrs r0, r1 - strb r0, [r4, 0x1] - adds r0, r5, 0 - bl RunFieldObjectStepTimer - lsls r0, 24 - cmp r0, 0 - beq _0809561E - ldrb r0, [r4, 0x1] - movs r1, 0x20 - orrs r0, r1 - strb r0, [r4, 0x1] - movs r0, 0x3 - strh r0, [r5, 0x32] -_0809561E: - movs r0, 0 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80955EC - - thumb_func_start sub_8095628 -sub_8095628: @ 8095628 - push {r4,lr} - adds r4, r1, 0 - adds r0, r4, 0 - movs r1, 0x1 - movs r2, 0 - bl obj_anim_image_set_and_seek - movs r0, 0x1 - strh r0, [r4, 0x32] - movs r0, 0 - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8095628 - - thumb_func_start sub_8095644 -sub_8095644: @ 8095644 - push {r4,lr} - adds r4, r1, 0 - adds r0, r4, 0 - bl sub_80979BC - lsls r0, 24 - cmp r0, 0 - beq _08095660 - adds r0, r4, 0 - movs r1, 0x20 - bl SetFieldObjectStepTimer - movs r0, 0x2 - strh r0, [r4, 0x32] -_08095660: - movs r0, 0 - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8095644 - - thumb_func_start sub_8095668 -sub_8095668: @ 8095668 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - ldrb r2, [r4, 0x1] - lsls r1, r2, 26 - lsrs r1, 31 - movs r0, 0x1 - eors r1, r0 - lsls r1, 5 - subs r0, 0x22 - ands r0, r2 - orrs r0, r1 - strb r0, [r4, 0x1] - adds r0, r5, 0 - bl RunFieldObjectStepTimer - lsls r0, 24 - cmp r0, 0 - beq _0809569A - ldrb r0, [r4, 0x1] - movs r1, 0x20 - orrs r0, r1 - strb r0, [r4, 0x1] - movs r0, 0x3 - strh r0, [r5, 0x32] -_0809569A: - movs r0, 0 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095668 - - thumb_func_start sub_80956A4 -sub_80956A4: @ 80956A4 - ldrb r2, [r0, 0x3] - movs r3, 0x4 - orrs r2, r3 - strb r2, [r0, 0x3] - movs r0, 0x1 - strh r0, [r1, 0x32] - bx lr - thumb_func_end sub_80956A4 - - thumb_func_start sub_80956B4 -sub_80956B4: @ 80956B4 - ldrb r3, [r0, 0x3] - movs r2, 0x5 - negs r2, r2 - ands r2, r3 - strb r2, [r0, 0x3] - movs r0, 0x1 - strh r0, [r1, 0x32] - bx lr - thumb_func_end sub_80956B4 - thumb_func_start sub_80956C4 sub_80956C4: @ 80956C4 push {r4,lr} diff --git a/include/field_effect_helpers.h b/include/field_effect_helpers.h index 6504a84f1..e80daf3bd 100644 --- a/include/field_effect_helpers.h +++ b/include/field_effect_helpers.h @@ -11,5 +11,6 @@ // Exported ROM declarations u8 sub_8154228(void); +bool8 sub_8155DA0(struct MapObject *); #endif //GUARD_FIELD_EFFECT_HELPERS_H diff --git a/include/trainer_see.h b/include/trainer_see.h new file mode 100644 index 000000000..3f39783b8 --- /dev/null +++ b/include/trainer_see.h @@ -0,0 +1,7 @@ +#ifndef GUARD_TRAINER_SEE_H +#define GUARD_TRAINER_SEE_H + +void sub_80B4578(struct MapObject *); +void sub_8155D78(struct MapObject *); + +#endif //GUARD_TRAINER_SEE_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 432eb5b47..cc645751c 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -21,6 +21,7 @@ #include "field_effect.h" #include "field_effect_helpers.h" #include "field_camera.h" +#include "trainer_see.h" #include "field_map_obj.h" #define NUM_FIELD_MAP_OBJECT_TEMPLATES 0x51 @@ -120,6 +121,7 @@ static void FieldObjectExecSpecialAnim(struct MapObject *, struct Sprite *); static bool8 IsCoordOutsideFieldObjectMovementRect(struct MapObject *, s16, s16); static bool8 IsMetatileDirectionallyImpassable(struct MapObject *, s16, s16, u8); static bool8 CheckForCollisionBetweenFieldObjects(struct MapObject *, s16, s16); +static bool8 sub_809558C(struct MapObject *, struct Sprite *); // ROM data @@ -4670,3 +4672,100 @@ bool8 do_heart_bubble(struct MapObject *mapObject, struct Sprite *sprite) sprite->data2 = 1; return TRUE; } + +bool8 sub_8095548(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (mapObject->animPattern == 0x3F) + { + sub_80B4578(mapObject); + return FALSE; + } + if (mapObject->animPattern != 0x39 && mapObject->animPattern != 0x3A) + { + sprite->data2 = 2; + return TRUE; + } + sub_8155D78(mapObject); + sprite->data2 = 1; + return sub_809558C(mapObject, sprite); +} + +static bool8 sub_809558C(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8155DA0(mapObject)) + { + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} + +bool8 sub_80955AC(struct MapObject *mapObject, struct Sprite *sprite) +{ + obj_anim_image_set_and_seek(sprite, 1, 0); + sprite->data2 = 1; + return FALSE; +} + +bool8 sub_80955C8(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_80979BC(sprite)) + { + SetFieldObjectStepTimer(sprite, 32); + sprite->data2 = 2; + } + return FALSE; +} + +bool8 sub_80955EC(struct MapObject *mapObject, struct Sprite *sprite) +{ + mapObject->mapobj_bit_13 ^= TRUE; + if (RunFieldObjectStepTimer(sprite)) + { + mapObject->mapobj_bit_13 = TRUE; + sprite->data2 = 3; + } + return FALSE; +} + +bool8 sub_8095628(struct MapObject *mapObject, struct Sprite *sprite) +{ + obj_anim_image_set_and_seek(sprite, 1, 0); + sprite->data2 = 1; + return FALSE; +} + +bool8 sub_8095644(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_80979BC(sprite)) + { + SetFieldObjectStepTimer(sprite, 32); + sprite->data2 = 2; + } + return FALSE; +} + +bool8 sub_8095668(struct MapObject *mapObject, struct Sprite *sprite) +{ + mapObject->mapobj_bit_13 ^= TRUE; + if (RunFieldObjectStepTimer(sprite)) + { + mapObject->mapobj_bit_13 = TRUE; + sprite->data2 = 3; + } + return FALSE; +} + +bool8 sub_80956A4(struct MapObject *mapObject, struct Sprite *sprite) +{ + mapObject->mapobj_bit_26 = TRUE; + sprite->data2 = 1; + return TRUE; +} + +bool8 sub_80956B4(struct MapObject *mapObject, struct Sprite *sprite) +{ + mapObject->mapobj_bit_26 = FALSE; + sprite->data2 = 1; + return TRUE; +} From 283d9060a78cbf618c2c3807f3fa8e3b4b240c0d Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 17 Sep 2017 13:59:30 -0400 Subject: [PATCH 172/191] Some functions relating to affine animations --- asm/field_map_obj.s | 283 -------------------------------------------- src/field_map_obj.c | 54 +++++++++ 2 files changed, 54 insertions(+), 283 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 18e4298a0..37c85f20f 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,289 +5,6 @@ .text - thumb_func_start sub_80956C4 -sub_80956C4: @ 80956C4 - push {r4,lr} - adds r4, r1, 0 - ldrb r0, [r4, 0x1] - movs r1, 0x3 - orrs r0, r1 - strb r0, [r4, 0x1] - adds r0, r4, 0 - bl InitSpriteAffineAnim - adds r2, r4, 0 - adds r2, 0x2C - ldrb r0, [r2] - movs r1, 0x80 - orrs r0, r1 - strb r0, [r2] - adds r4, 0x42 - ldrb r1, [r4] - movs r0, 0x3F - ands r0, r1 - strb r0, [r4] - movs r0, 0x1 - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_80956C4 - - thumb_func_start sub_80956F4 -sub_80956F4: @ 80956F4 - push {r4,lr} - adds r4, r1, 0 - ldrb r0, [r4, 0x3] - lsls r0, 26 - lsrs r0, 27 - bl FreeOamMatrix - ldrb r0, [r4, 0x1] - movs r1, 0x4 - negs r1, r1 - ands r1, r0 - strb r1, [r4, 0x1] - lsrs r1, 6 - ldrb r2, [r4, 0x3] - lsrs r2, 6 - movs r3, 0 - adds r0, r4, 0 - bl CalcCenterToCornerVec - movs r0, 0x1 - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_80956F4 - - thumb_func_start sub_8095724 -sub_8095724: @ 8095724 - ldrb r1, [r0, 0x3] - movs r2, 0x8 - orrs r1, r2 - strb r1, [r0, 0x3] - movs r0, 0x1 - bx lr - thumb_func_end sub_8095724 - - thumb_func_start sub_8095730 -sub_8095730: @ 8095730 - ldrb r2, [r0, 0x3] - movs r1, 0x9 - negs r1, r1 - ands r1, r2 - strb r1, [r0, 0x3] - movs r0, 0x1 - bx lr - thumb_func_end sub_8095730 - - thumb_func_start sub_8095740 -sub_8095740: @ 8095740 - push {r4,r5,lr} - adds r5, r0, 0 - adds r4, r1, 0 - movs r2, 0x1 - bl sub_8093B60 - adds r2, r4, 0 - adds r2, 0x2C - ldrb r1, [r2] - movs r0, 0x7F - ands r0, r1 - strb r0, [r2] - adds r0, r4, 0 - movs r1, 0 - bl StartSpriteAffineAnimIfDifferent - adds r0, r5, 0 - adds r1, r4, 0 - bl sub_8095774 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095740 - - thumb_func_start sub_8095774 -sub_8095774: @ 8095774 - push {r4,lr} - adds r4, r1, 0 - bl an_walk_any_2 - lsls r0, 24 - cmp r0, 0 - bne _08095786 - movs r0, 0 - b _08095798 -_08095786: - adds r2, r4, 0 - adds r2, 0x2C - ldrb r0, [r2] - movs r1, 0x80 - orrs r0, r1 - strb r0, [r2] - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_08095798: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8095774 - - thumb_func_start sub_80957A0 -sub_80957A0: @ 80957A0 - push {r4,r5,lr} - adds r5, r0, 0 - adds r4, r1, 0 - movs r2, 0x1 - bl sub_8093B60 - adds r2, r4, 0 - adds r2, 0x2C - ldrb r1, [r2] - movs r0, 0x7F - ands r0, r1 - strb r0, [r2] - adds r0, r4, 0 - movs r1, 0x1 - bl ChangeSpriteAffineAnimIfDifferent - adds r0, r5, 0 - adds r1, r4, 0 - bl sub_80957D4 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80957A0 - - thumb_func_start sub_80957D4 -sub_80957D4: @ 80957D4 - push {r4,lr} - adds r4, r1, 0 - bl an_walk_any_2 - lsls r0, 24 - cmp r0, 0 - bne _080957E6 - movs r0, 0 - b _080957F8 -_080957E6: - adds r2, r4, 0 - adds r2, 0x2C - ldrb r0, [r2] - movs r1, 0x80 - orrs r0, r1 - strb r0, [r2] - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_080957F8: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_80957D4 - - thumb_func_start sub_8095800 -sub_8095800: @ 8095800 - push {r4,r5,lr} - adds r5, r0, 0 - adds r4, r1, 0 - movs r2, 0x3 - movs r3, 0x1 - bl do_go_anim - adds r2, r4, 0 - adds r2, 0x2C - ldrb r1, [r2] - movs r0, 0x7F - ands r0, r1 - strb r0, [r2] - adds r0, r4, 0 - movs r1, 0x2 - bl ChangeSpriteAffineAnimIfDifferent - adds r0, r5, 0 - adds r1, r4, 0 - bl sub_8095834 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095800 - - thumb_func_start sub_8095834 -sub_8095834: @ 8095834 - push {r4,lr} - adds r4, r1, 0 - bl npc_obj_ministep_stop_on_arrival - lsls r0, 24 - cmp r0, 0 - bne _08095846 - movs r0, 0 - b _08095858 -_08095846: - adds r2, r4, 0 - adds r2, 0x2C - ldrb r0, [r2] - movs r1, 0x80 - orrs r0, r1 - strb r0, [r2] - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_08095858: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8095834 - - thumb_func_start sub_8095860 -sub_8095860: @ 8095860 - push {r4,r5,lr} - adds r5, r0, 0 - adds r4, r1, 0 - movs r2, 0x4 - movs r3, 0x1 - bl do_go_anim - adds r2, r4, 0 - adds r2, 0x2C - ldrb r1, [r2] - movs r0, 0x7F - ands r0, r1 - strb r0, [r2] - adds r0, r4, 0 - movs r1, 0x3 - bl ChangeSpriteAffineAnimIfDifferent - adds r0, r5, 0 - adds r1, r4, 0 - bl sub_8095894 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095860 - - thumb_func_start sub_8095894 -sub_8095894: @ 8095894 - push {r4,lr} - adds r4, r1, 0 - bl npc_obj_ministep_stop_on_arrival - lsls r0, 24 - cmp r0, 0 - bne _080958A6 - movs r0, 0 - b _080958B8 -_080958A6: - adds r2, r4, 0 - adds r2, 0x2C - ldrb r0, [r2] - movs r1, 0x80 - orrs r0, r1 - strb r0, [r2] - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_080958B8: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8095894 - thumb_func_start sub_80958C0 sub_80958C0: @ 80958C0 push {r4-r6,lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index cc645751c..3e72f538c 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -4769,3 +4769,57 @@ bool8 sub_80956B4(struct MapObject *mapObject, struct Sprite *sprite) sprite->data2 = 1; return TRUE; } + +bool8 sub_80956C4(struct MapObject *mapObject, struct Sprite *sprite) +{ + sprite->oam.affineMode = 3; + InitSpriteAffineAnim(sprite); + sprite->affineAnimPaused = TRUE; + sprite->subspriteMode = 0; + return TRUE; +} + +bool8 sub_80956F4(struct MapObject *mapObject, struct Sprite *sprite) +{ + FreeOamMatrix(sprite->oam.matrixNum); + sprite->oam.affineMode = 0; + CalcCenterToCornerVec(sprite, sprite->oam.shape, sprite->oam.size, sprite->oam.affineMode); + return TRUE; +} + +bool8 sub_8095724(struct MapObject *mapObject, struct Sprite *sprite) +{ + mapObject->mapobj_bit_27 = TRUE; + return TRUE; +} + +bool8 sub_8095730(struct MapObject *mapObject, struct Sprite *sprite) +{ + mapObject->mapobj_bit_27 = FALSE; + return TRUE; +} + +#define affine_an_walk_any_2_macro(name, fn, fn2, action, anim, ...)\ +static bool8 name##_2(struct MapObject *, struct Sprite *);\ +bool8 name(struct MapObject *mapObject, struct Sprite *sprite)\ +{\ + fn(mapObject, sprite, __VA_ARGS__);\ + sprite->affineAnimPaused = FALSE;\ + action(sprite, anim);\ + return name##_2(mapObject, sprite);\ +}\ +static bool8 name##_2(struct MapObject *mapObject, struct Sprite *sprite)\ +{\ + if (fn2(mapObject, sprite))\ + {\ + sprite->affineAnimPaused = TRUE;\ + sprite->data2 = 2;\ + return TRUE;\ + }\ + return FALSE;\ +}\ + +affine_an_walk_any_2_macro(sub_8095740, sub_8093B60, an_walk_any_2, StartSpriteAffineAnimIfDifferent, 0, DIR_SOUTH) +affine_an_walk_any_2_macro(sub_80957A0, sub_8093B60, an_walk_any_2, ChangeSpriteAffineAnimIfDifferent, 1, DIR_SOUTH) +affine_an_walk_any_2_macro(sub_8095800, do_go_anim, npc_obj_ministep_stop_on_arrival, ChangeSpriteAffineAnimIfDifferent, 2, DIR_WEST, 1) +affine_an_walk_any_2_macro(sub_8095860, do_go_anim, npc_obj_ministep_stop_on_arrival, ChangeSpriteAffineAnimIfDifferent, 3, DIR_EAST, 1) From e544d5f8b8704d5ca77de8b1bd8245daad973490 Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 17 Sep 2017 14:02:43 -0400 Subject: [PATCH 173/191] sub_80958C0 and callers --- asm/field_map_obj.s | 72 --------------------------------------------- src/field_map_obj.c | 33 +++++++++++++++++++++ 2 files changed, 33 insertions(+), 72 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 37c85f20f..5831f7213 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,78 +5,6 @@ .text - thumb_func_start sub_80958C0 -sub_80958C0: @ 80958C0 - push {r4-r6,lr} - adds r5, r0, 0 - adds r6, r1, 0 - lsls r4, r2, 24 - lsrs r4, 24 - adds r1, r4, 0 - bl FieldObjectSetDirection - adds r0, r5, 0 - bl npc_coords_shift_still - adds r0, r4, 0 - bl sub_80929FC - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r5, 0 - adds r1, r6, 0 - bl obj_npc_animation_step - adds r2, r6, 0 - adds r2, 0x2C - ldrb r0, [r2] - movs r1, 0x40 - orrs r0, r1 - strb r0, [r2] - movs r0, 0x1 - strh r0, [r6, 0x32] - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_80958C0 - - thumb_func_start sub_8095900 -sub_8095900: @ 8095900 - push {lr} - movs r2, 0x1 - bl sub_80958C0 - movs r0, 0x1 - pop {r1} - bx r1 - thumb_func_end sub_8095900 - - thumb_func_start sub_8095910 -sub_8095910: @ 8095910 - push {lr} - movs r2, 0x2 - bl sub_80958C0 - movs r0, 0x1 - pop {r1} - bx r1 - thumb_func_end sub_8095910 - - thumb_func_start sub_8095920 -sub_8095920: @ 8095920 - push {lr} - movs r2, 0x3 - bl sub_80958C0 - movs r0, 0x1 - pop {r1} - bx r1 - thumb_func_end sub_8095920 - - thumb_func_start sub_8095930 -sub_8095930: @ 8095930 - push {lr} - movs r2, 0x4 - bl sub_80958C0 - movs r0, 0x1 - pop {r1} - bx r1 - thumb_func_end sub_8095930 - thumb_func_start sub_8095940 sub_8095940: @ 8095940 push {r4,r5,lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 3e72f538c..a5c3c013f 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -4823,3 +4823,36 @@ affine_an_walk_any_2_macro(sub_8095740, sub_8093B60, an_walk_any_2, StartSpriteA affine_an_walk_any_2_macro(sub_80957A0, sub_8093B60, an_walk_any_2, ChangeSpriteAffineAnimIfDifferent, 1, DIR_SOUTH) affine_an_walk_any_2_macro(sub_8095800, do_go_anim, npc_obj_ministep_stop_on_arrival, ChangeSpriteAffineAnimIfDifferent, 2, DIR_WEST, 1) affine_an_walk_any_2_macro(sub_8095860, do_go_anim, npc_obj_ministep_stop_on_arrival, ChangeSpriteAffineAnimIfDifferent, 3, DIR_EAST, 1) + +static void sub_80958C0(struct MapObject *mapObject, struct Sprite *sprite, u8 direction) +{ + FieldObjectSetDirection(mapObject, direction); + npc_coords_shift_still(mapObject); + obj_npc_animation_step(mapObject, sprite, sub_80929FC(direction)); + sprite->animPaused = TRUE; + sprite->data2 = 1; +} + +bool8 sub_8095900(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_80958C0(mapObject, sprite, DIR_SOUTH); + return TRUE; +} + +bool8 sub_8095910(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_80958C0(mapObject, sprite, DIR_NORTH); + return TRUE; +} + +bool8 sub_8095920(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_80958C0(mapObject, sprite, DIR_WEST); + return TRUE; +} + +bool8 sub_8095930(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_80958C0(mapObject, sprite, DIR_EAST); + return TRUE; +} From c9699169ad0e07326a3d77b1836681b870ecd618 Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 17 Sep 2017 14:06:43 -0400 Subject: [PATCH 174/191] another block of directional anim functions --- asm/field_map_obj.s | 240 -------------------------------------------- src/field_map_obj.c | 20 ++++ 2 files changed, 20 insertions(+), 240 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 5831f7213..088fd279a 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,246 +5,6 @@ .text - thumb_func_start sub_8095940 -sub_8095940: @ 8095940 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0x1 - bl sub_80929BC - adds r3, r0, 0 - lsls r3, 24 - lsrs r3, 24 - adds r0, r4, 0 - adds r1, r5, 0 - movs r2, 0x1 - bl npc_set_direction_and_anim__an_proceed - movs r0, 0 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095940 - - thumb_func_start sub_8095964 -sub_8095964: @ 8095964 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0x2 - bl sub_80929BC - adds r3, r0, 0 - lsls r3, 24 - lsrs r3, 24 - adds r0, r4, 0 - adds r1, r5, 0 - movs r2, 0x2 - bl npc_set_direction_and_anim__an_proceed - movs r0, 0 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095964 - - thumb_func_start sub_8095988 -sub_8095988: @ 8095988 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0x3 - bl sub_80929BC - adds r3, r0, 0 - lsls r3, 24 - lsrs r3, 24 - adds r0, r4, 0 - adds r1, r5, 0 - movs r2, 0x3 - bl npc_set_direction_and_anim__an_proceed - movs r0, 0 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095988 - - thumb_func_start sub_80959AC -sub_80959AC: @ 80959AC - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0x4 - bl sub_80929BC - adds r3, r0, 0 - lsls r3, 24 - lsrs r3, 24 - adds r0, r4, 0 - adds r1, r5, 0 - movs r2, 0x4 - bl npc_set_direction_and_anim__an_proceed - movs r0, 0 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80959AC - - thumb_func_start sub_80959D0 -sub_80959D0: @ 80959D0 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0x1 - bl sub_80929DC - adds r3, r0, 0 - lsls r3, 24 - lsrs r3, 24 - adds r0, r4, 0 - adds r1, r5, 0 - movs r2, 0x1 - bl npc_set_direction_and_anim__an_proceed - movs r0, 0 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80959D0 - - thumb_func_start sub_80959F4 -sub_80959F4: @ 80959F4 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0x2 - bl sub_80929DC - adds r3, r0, 0 - lsls r3, 24 - lsrs r3, 24 - adds r0, r4, 0 - adds r1, r5, 0 - movs r2, 0x2 - bl npc_set_direction_and_anim__an_proceed - movs r0, 0 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80959F4 - - thumb_func_start sub_8095A18 -sub_8095A18: @ 8095A18 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0x3 - bl sub_80929DC - adds r3, r0, 0 - lsls r3, 24 - lsrs r3, 24 - adds r0, r4, 0 - adds r1, r5, 0 - movs r2, 0x3 - bl npc_set_direction_and_anim__an_proceed - movs r0, 0 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095A18 - - thumb_func_start sub_8095A3C -sub_8095A3C: @ 8095A3C - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0x4 - bl sub_80929DC - adds r3, r0, 0 - lsls r3, 24 - lsrs r3, 24 - adds r0, r4, 0 - adds r1, r5, 0 - movs r2, 0x4 - bl npc_set_direction_and_anim__an_proceed - movs r0, 0 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095A3C - - thumb_func_start sub_8095A60 -sub_8095A60: @ 8095A60 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0x1 - bl sub_80929EC - adds r3, r0, 0 - lsls r3, 24 - lsrs r3, 24 - adds r0, r4, 0 - adds r1, r5, 0 - movs r2, 0x1 - bl npc_set_direction_and_anim__an_proceed - movs r0, 0 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095A60 - - thumb_func_start sub_8095A84 -sub_8095A84: @ 8095A84 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0x2 - bl sub_80929EC - adds r3, r0, 0 - lsls r3, 24 - lsrs r3, 24 - adds r0, r4, 0 - adds r1, r5, 0 - movs r2, 0x2 - bl npc_set_direction_and_anim__an_proceed - movs r0, 0 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095A84 - - thumb_func_start sub_8095AA8 -sub_8095AA8: @ 8095AA8 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0x3 - bl sub_80929EC - adds r3, r0, 0 - lsls r3, 24 - lsrs r3, 24 - adds r0, r4, 0 - adds r1, r5, 0 - movs r2, 0x3 - bl npc_set_direction_and_anim__an_proceed - movs r0, 0 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095AA8 - - thumb_func_start sub_8095ACC -sub_8095ACC: @ 8095ACC - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0x4 - bl sub_80929EC - adds r3, r0, 0 - lsls r3, 24 - lsrs r3, 24 - adds r0, r4, 0 - adds r1, r5, 0 - movs r2, 0x4 - bl npc_set_direction_and_anim__an_proceed - movs r0, 0 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095ACC - thumb_func_start sub_8095AF0 sub_8095AF0: @ 8095AF0 push {r4,lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index a5c3c013f..3e1e3d19e 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -4856,3 +4856,23 @@ bool8 sub_8095930(struct MapObject *mapObject, struct Sprite *sprite) sub_80958C0(mapObject, sprite, DIR_EAST); return TRUE; } + +#define set_dirn_and_anim__an_proceed(name, direction, anims)\ +bool8 name(struct MapObject *mapObject, struct Sprite *sprite)\ +{\ + npc_set_direction_and_anim__an_proceed(mapObject, sprite, direction, anims(direction));\ + return FALSE;\ +} + +set_dirn_and_anim__an_proceed(sub_8095940, DIR_SOUTH, sub_80929BC) +set_dirn_and_anim__an_proceed(sub_8095964, DIR_NORTH, sub_80929BC) +set_dirn_and_anim__an_proceed(sub_8095988, DIR_WEST, sub_80929BC) +set_dirn_and_anim__an_proceed(sub_80959AC, DIR_EAST, sub_80929BC) +set_dirn_and_anim__an_proceed(sub_80959D0, DIR_SOUTH, sub_80929DC) +set_dirn_and_anim__an_proceed(sub_80959F4, DIR_NORTH, sub_80929DC) +set_dirn_and_anim__an_proceed(sub_8095A18, DIR_WEST, sub_80929DC) +set_dirn_and_anim__an_proceed(sub_8095A3C, DIR_EAST, sub_80929DC) +set_dirn_and_anim__an_proceed(sub_8095A60, DIR_SOUTH, sub_80929EC) +set_dirn_and_anim__an_proceed(sub_8095A84, DIR_NORTH, sub_80929EC) +set_dirn_and_anim__an_proceed(sub_8095AA8, DIR_WEST, sub_80929EC) +set_dirn_and_anim__an_proceed(sub_8095ACC, DIR_EAST, sub_80929EC) From b54689b9a37d38ada226504c384054c56310e2dc Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 17 Sep 2017 14:12:32 -0400 Subject: [PATCH 175/191] Another four functions --- asm/field_map_obj.s | 87 --------------------------------------- include/map_obj_8097404.h | 2 + src/field_map_obj.c | 37 +++++++++++++++++ 3 files changed, 39 insertions(+), 87 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 088fd279a..a04e75e80 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,93 +5,6 @@ .text - thumb_func_start sub_8095AF0 -sub_8095AF0: @ 8095AF0 - push {r4,lr} - adds r4, r1, 0 - adds r0, r4, 0 - bl sub_8097750 - adds r4, 0x2C - ldrb r1, [r4] - movs r0, 0x41 - negs r0, r0 - ands r0, r1 - strb r0, [r4] - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_8095AF0 - - thumb_func_start sub_8095B0C -sub_8095B0C: @ 8095B0C - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - adds r0, r5, 0 - bl sub_8097758 - lsls r0, 24 - cmp r0, 0 - bne _08095B22 - movs r0, 0 - b _08095B3E -_08095B22: - adds r0, r4, 0 - bl npc_coords_shift_still - ldrb r0, [r4] - movs r1, 0x8 - orrs r0, r1 - strb r0, [r4] - adds r2, r5, 0 - adds r2, 0x2C - ldrb r0, [r2] - movs r1, 0x40 - orrs r0, r1 - strb r0, [r2] - movs r0, 0x1 -_08095B3E: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095B0C - - thumb_func_start sub_8095B44 -sub_8095B44: @ 8095B44 - push {r4,r5,lr} - adds r5, r0, 0 - adds r4, r1, 0 - bl sub_8095AF0 - movs r0, 0x1 - strh r0, [r4, 0x32] - adds r0, r5, 0 - adds r1, r4, 0 - bl sub_8095B64 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095B44 - - thumb_func_start sub_8095B64 -sub_8095B64: @ 8095B64 - push {r4,lr} - adds r4, r1, 0 - bl sub_8095B0C - lsls r0, 24 - cmp r0, 0 - bne _08095B76 - movs r0, 0 - b _08095B7C -_08095B76: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_08095B7C: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8095B64 - thumb_func_start sub_8095B84 sub_8095B84: @ 8095B84 push {r4-r6,lr} diff --git a/include/map_obj_8097404.h b/include/map_obj_8097404.h index 08b69f49a..fd5616330 100644 --- a/include/map_obj_8097404.h +++ b/include/map_obj_8097404.h @@ -24,5 +24,7 @@ u8 sub_809785C(struct Sprite *); u8 sub_80978E4(struct Sprite *); void obj_anim_image_set_and_seek(struct Sprite *, u8, u8); bool8 sub_80979BC(struct Sprite *); +void sub_8097750(struct Sprite *); +bool8 sub_8097758(struct Sprite *); #endif //GUARD_MAP_OBJ_8097404_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 3e1e3d19e..9092a6089 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -4876,3 +4876,40 @@ set_dirn_and_anim__an_proceed(sub_8095A60, DIR_SOUTH, sub_80929EC) set_dirn_and_anim__an_proceed(sub_8095A84, DIR_NORTH, sub_80929EC) set_dirn_and_anim__an_proceed(sub_8095AA8, DIR_WEST, sub_80929EC) set_dirn_and_anim__an_proceed(sub_8095ACC, DIR_EAST, sub_80929EC) + +void sub_8095AF0(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_8097750(sprite); + sprite->animPaused = FALSE; +} + +bool8 sub_8095B0C(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8097758(sprite)) + { + npc_coords_shift_still(mapObject); + mapObject->mapobj_bit_3 = TRUE; + sprite->animPaused = TRUE; + return TRUE; + } + return FALSE; +} + +static bool8 sub_8095B64(struct MapObject *, struct Sprite *); + +bool8 sub_8095B44(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_8095AF0(mapObject, sprite); + sprite->data2 = 1; + return sub_8095B64(mapObject, sprite); +} + +static bool8 sub_8095B64(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_8095B0C(mapObject, sprite)) + { + sprite->data2 = 2; + return TRUE; + } + return FALSE; +} From 0689afbd865d017171c86c1743d2a3d123abb156 Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 17 Sep 2017 14:51:10 -0400 Subject: [PATCH 176/191] Yet more maybe_shadow_1 memes --- asm/field_map_obj.s | 621 -------------------------------------------- src/field_map_obj.c | 40 ++- 2 files changed, 30 insertions(+), 631 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index a04e75e80..72fe317e4 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,627 +5,6 @@ .text - thumb_func_start sub_8095B84 -sub_8095B84: @ 8095B84 - push {r4-r6,lr} - sub sp, 0x4 - adds r6, r0, 0 - adds r5, r1, 0 - adds r4, r2, 0 - ldr r0, [sp, 0x14] - lsls r4, 24 - lsrs r4, 24 - lsls r3, 24 - lsrs r3, 24 - lsls r0, 24 - lsrs r0, 24 - str r0, [sp] - adds r0, r6, 0 - adds r2, r4, 0 - bl sub_8093FC4 - adds r0, r4, 0 - bl sub_80929BC - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 24 - adds r0, r5, 0 - bl StartSpriteAnimIfDifferent - adds r0, r6, 0 - bl DoShadowFieldEffect - add sp, 0x4 - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_8095B84 - - thumb_func_start sub_8095BC8 -sub_8095BC8: @ 8095BC8 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0x1 - str r0, [sp] - adds r0, r4, 0 - movs r2, 0x1 - movs r3, 0 - bl sub_8095B84 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8095BF4 - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095BC8 - - thumb_func_start sub_8095BF4 -sub_8095BF4: @ 8095BF4 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl sub_80941B0 - lsls r0, 24 - cmp r0, 0 - bne _08095C08 - movs r0, 0 - b _08095C18 -_08095C08: - ldrb r0, [r4, 0x2] - movs r1, 0x41 - negs r1, r1 - ands r1, r0 - strb r1, [r4, 0x2] - movs r0, 0x2 - strh r0, [r5, 0x32] - movs r0, 0x1 -_08095C18: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095BF4 - - thumb_func_start sub_8095C20 -sub_8095C20: @ 8095C20 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0x1 - str r0, [sp] - adds r0, r4, 0 - movs r2, 0x2 - movs r3, 0 - bl sub_8095B84 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8095C4C - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095C20 - - thumb_func_start sub_8095C4C -sub_8095C4C: @ 8095C4C - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl sub_80941B0 - lsls r0, 24 - cmp r0, 0 - bne _08095C60 - movs r0, 0 - b _08095C70 -_08095C60: - ldrb r0, [r4, 0x2] - movs r1, 0x41 - negs r1, r1 - ands r1, r0 - strb r1, [r4, 0x2] - movs r0, 0x2 - strh r0, [r5, 0x32] - movs r0, 0x1 -_08095C70: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095C4C - - thumb_func_start sub_8095C78 -sub_8095C78: @ 8095C78 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0x1 - str r0, [sp] - adds r0, r4, 0 - movs r2, 0x3 - movs r3, 0 - bl sub_8095B84 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8095CA4 - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095C78 - - thumb_func_start sub_8095CA4 -sub_8095CA4: @ 8095CA4 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl sub_80941B0 - lsls r0, 24 - cmp r0, 0 - bne _08095CB8 - movs r0, 0 - b _08095CC8 -_08095CB8: - ldrb r0, [r4, 0x2] - movs r1, 0x41 - negs r1, r1 - ands r1, r0 - strb r1, [r4, 0x2] - movs r0, 0x2 - strh r0, [r5, 0x32] - movs r0, 0x1 -_08095CC8: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095CA4 - - thumb_func_start sub_8095CD0 -sub_8095CD0: @ 8095CD0 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0x1 - str r0, [sp] - adds r0, r4, 0 - movs r2, 0x4 - movs r3, 0 - bl sub_8095B84 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8095CFC - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095CD0 - - thumb_func_start sub_8095CFC -sub_8095CFC: @ 8095CFC - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl sub_80941B0 - lsls r0, 24 - cmp r0, 0 - bne _08095D10 - movs r0, 0 - b _08095D20 -_08095D10: - ldrb r0, [r4, 0x2] - movs r1, 0x41 - negs r1, r1 - ands r1, r0 - strb r1, [r4, 0x2] - movs r0, 0x2 - strh r0, [r5, 0x32] - movs r0, 0x1 -_08095D20: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095CFC - - thumb_func_start sub_8095D28 -sub_8095D28: @ 8095D28 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0x1 - str r0, [sp] - adds r0, r4, 0 - movs r2, 0x1 - movs r3, 0x1 - bl sub_8095B84 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8095D54 - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095D28 - - thumb_func_start sub_8095D54 -sub_8095D54: @ 8095D54 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl sub_80941B0 - lsls r0, 24 - cmp r0, 0 - bne _08095D68 - movs r0, 0 - b _08095D78 -_08095D68: - ldrb r0, [r4, 0x2] - movs r1, 0x41 - negs r1, r1 - ands r1, r0 - strb r1, [r4, 0x2] - movs r0, 0x2 - strh r0, [r5, 0x32] - movs r0, 0x1 -_08095D78: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095D54 - - thumb_func_start sub_8095D80 -sub_8095D80: @ 8095D80 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0x1 - str r0, [sp] - adds r0, r4, 0 - movs r2, 0x2 - movs r3, 0x1 - bl sub_8095B84 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8095DAC - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095D80 - - thumb_func_start sub_8095DAC -sub_8095DAC: @ 8095DAC - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl sub_80941B0 - lsls r0, 24 - cmp r0, 0 - bne _08095DC0 - movs r0, 0 - b _08095DD0 -_08095DC0: - ldrb r0, [r4, 0x2] - movs r1, 0x41 - negs r1, r1 - ands r1, r0 - strb r1, [r4, 0x2] - movs r0, 0x2 - strh r0, [r5, 0x32] - movs r0, 0x1 -_08095DD0: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095DAC - - thumb_func_start sub_8095DD8 -sub_8095DD8: @ 8095DD8 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0x1 - str r0, [sp] - adds r0, r4, 0 - movs r2, 0x3 - movs r3, 0x1 - bl sub_8095B84 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8095E04 - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095DD8 - - thumb_func_start sub_8095E04 -sub_8095E04: @ 8095E04 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl sub_80941B0 - lsls r0, 24 - cmp r0, 0 - bne _08095E18 - movs r0, 0 - b _08095E28 -_08095E18: - ldrb r0, [r4, 0x2] - movs r1, 0x41 - negs r1, r1 - ands r1, r0 - strb r1, [r4, 0x2] - movs r0, 0x2 - strh r0, [r5, 0x32] - movs r0, 0x1 -_08095E28: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095E04 - - thumb_func_start sub_8095E30 -sub_8095E30: @ 8095E30 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0x1 - str r0, [sp] - adds r0, r4, 0 - movs r2, 0x4 - movs r3, 0x1 - bl sub_8095B84 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8095E5C - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095E30 - - thumb_func_start sub_8095E5C -sub_8095E5C: @ 8095E5C - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl sub_80941B0 - lsls r0, 24 - cmp r0, 0 - bne _08095E70 - movs r0, 0 - b _08095E80 -_08095E70: - ldrb r0, [r4, 0x2] - movs r1, 0x41 - negs r1, r1 - ands r1, r0 - strb r1, [r4, 0x2] - movs r0, 0x2 - strh r0, [r5, 0x32] - movs r0, 0x1 -_08095E80: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095E5C - - thumb_func_start sub_8095E88 -sub_8095E88: @ 8095E88 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0 - str r0, [sp] - adds r0, r4, 0 - movs r2, 0x1 - movs r3, 0x2 - bl sub_8095B84 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8095EB4 - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095E88 - - thumb_func_start sub_8095EB4 -sub_8095EB4: @ 8095EB4 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl sub_80941B0 - lsls r0, 24 - cmp r0, 0 - bne _08095EC8 - movs r0, 0 - b _08095ED8 -_08095EC8: - ldrb r0, [r4, 0x2] - movs r1, 0x41 - negs r1, r1 - ands r1, r0 - strb r1, [r4, 0x2] - movs r0, 0x2 - strh r0, [r5, 0x32] - movs r0, 0x1 -_08095ED8: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095EB4 - - thumb_func_start sub_8095EE0 -sub_8095EE0: @ 8095EE0 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0 - str r0, [sp] - adds r0, r4, 0 - movs r2, 0x2 - movs r3, 0x2 - bl sub_8095B84 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8095F0C - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095EE0 - - thumb_func_start sub_8095F0C -sub_8095F0C: @ 8095F0C - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl sub_80941B0 - lsls r0, 24 - cmp r0, 0 - bne _08095F20 - movs r0, 0 - b _08095F30 -_08095F20: - ldrb r0, [r4, 0x2] - movs r1, 0x41 - negs r1, r1 - ands r1, r0 - strb r1, [r4, 0x2] - movs r0, 0x2 - strh r0, [r5, 0x32] - movs r0, 0x1 -_08095F30: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095F0C - - thumb_func_start sub_8095F38 -sub_8095F38: @ 8095F38 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0 - str r0, [sp] - adds r0, r4, 0 - movs r2, 0x3 - movs r3, 0x2 - bl sub_8095B84 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8095F64 - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095F38 - - thumb_func_start sub_8095F64 -sub_8095F64: @ 8095F64 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl sub_80941B0 - lsls r0, 24 - cmp r0, 0 - bne _08095F78 - movs r0, 0 - b _08095F88 -_08095F78: - ldrb r0, [r4, 0x2] - movs r1, 0x41 - negs r1, r1 - ands r1, r0 - strb r1, [r4, 0x2] - movs r0, 0x2 - strh r0, [r5, 0x32] - movs r0, 0x1 -_08095F88: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095F64 - - thumb_func_start sub_8095F90 -sub_8095F90: @ 8095F90 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0 - str r0, [sp] - adds r0, r4, 0 - movs r2, 0x4 - movs r3, 0x2 - bl sub_8095B84 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8095FBC - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095F90 - - thumb_func_start sub_8095FBC -sub_8095FBC: @ 8095FBC - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl sub_80941B0 - lsls r0, 24 - cmp r0, 0 - bne _08095FD0 - movs r0, 0 - b _08095FE0 -_08095FD0: - ldrb r0, [r4, 0x2] - movs r1, 0x41 - negs r1, r1 - ands r1, r0 - strb r1, [r4, 0x2] - movs r0, 0x2 - strh r0, [r5, 0x32] - movs r0, 0x1 -_08095FE0: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095FBC - thumb_func_start sub_8095FE8 sub_8095FE8: @ 8095FE8 push {r4,r5,lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 9092a6089..87ae05ad7 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -4381,10 +4381,10 @@ static bool8 name##_2(struct MapObject *mapObject, struct Sprite *sprite)\ return FALSE;\ } -maybe_shadow_1_macro(sub_8094230, maybe_shadow_1, sub_80941B0, 1, 2, 0) -maybe_shadow_1_macro(sub_8094288, maybe_shadow_1, sub_80941B0, 2, 2, 0) -maybe_shadow_1_macro(sub_80942E0, maybe_shadow_1, sub_80941B0, 3, 2, 0) -maybe_shadow_1_macro(sub_8094338, maybe_shadow_1, sub_80941B0, 4, 2, 0) +maybe_shadow_1_macro(sub_8094230, maybe_shadow_1, sub_80941B0, DIR_SOUTH, 2, 0) +maybe_shadow_1_macro(sub_8094288, maybe_shadow_1, sub_80941B0, DIR_NORTH, 2, 0) +maybe_shadow_1_macro(sub_80942E0, maybe_shadow_1, sub_80941B0, DIR_WEST, 2, 0) +maybe_shadow_1_macro(sub_8094338, maybe_shadow_1, sub_80941B0, DIR_EAST, 2, 0) void sub_8094390(struct Sprite *sprite, u16 duration) { @@ -4584,16 +4584,16 @@ bool8 sub_8095008(struct MapObject *mapObject, struct Sprite *sprite) maybe_shadow_1_macro(sub_8095018, maybe_shadow_1, sub_80941B0, DIR_SOUTH, 1, 2) maybe_shadow_1_macro(sub_8095070, maybe_shadow_1, sub_80941B0, DIR_NORTH, 1, 2) -maybe_shadow_1_macro(sub_80950C8, maybe_shadow_1, sub_80941B0, DIR_WEST, 1, 2) -maybe_shadow_1_macro(sub_8095120, maybe_shadow_1, sub_80941B0, DIR_EAST, 1, 2) +maybe_shadow_1_macro(sub_80950C8, maybe_shadow_1, sub_80941B0, DIR_WEST, 1, 2) +maybe_shadow_1_macro(sub_8095120, maybe_shadow_1, sub_80941B0, DIR_EAST, 1, 2) maybe_shadow_1_macro(sub_8095178, maybe_shadow_1, sub_80941B0, DIR_SOUTH, 0, 0) maybe_shadow_1_macro(sub_80951D0, maybe_shadow_1, sub_80941B0, DIR_NORTH, 0, 0) -maybe_shadow_1_macro(sub_8095228, maybe_shadow_1, sub_80941B0, DIR_WEST, 0, 0) -maybe_shadow_1_macro(sub_8095280, maybe_shadow_1, sub_80941B0, DIR_EAST, 0, 0) +maybe_shadow_1_macro(sub_8095228, maybe_shadow_1, sub_80941B0, DIR_WEST, 0, 0) +maybe_shadow_1_macro(sub_8095280, maybe_shadow_1, sub_80941B0, DIR_EAST, 0, 0) maybe_shadow_1_macro(sub_80952D8, maybe_shadow_1, sub_80941E0, DIR_SOUTH, 0, 2) maybe_shadow_1_macro(sub_8095330, maybe_shadow_1, sub_80941E0, DIR_NORTH, 0, 2) -maybe_shadow_1_macro(sub_8095388, maybe_shadow_1, sub_80941E0, DIR_WEST, 0, 2) -maybe_shadow_1_macro(sub_80953E0, maybe_shadow_1, sub_80941E0, DIR_EAST, 0, 2) +maybe_shadow_1_macro(sub_8095388, maybe_shadow_1, sub_80941E0, DIR_WEST, 0, 2) +maybe_shadow_1_macro(sub_80953E0, maybe_shadow_1, sub_80941E0, DIR_EAST, 0, 2) bool8 sub_8095438(struct MapObject *mapObject, struct Sprite *sprite) { @@ -4913,3 +4913,23 @@ static bool8 sub_8095B64(struct MapObject *mapObject, struct Sprite *sprite) } return FALSE; } + +void sub_8095B84(struct MapObject *mapObject, struct Sprite *sprite, u8 direction, u8 speed, u8 a4) +{ + sub_8093FC4(mapObject, sprite, direction, speed, a4); + StartSpriteAnimIfDifferent(sprite, sub_80929BC(direction)); + DoShadowFieldEffect(mapObject); +} + +maybe_shadow_1_macro(sub_8095BC8, sub_8095B84, sub_80941B0, DIR_SOUTH, 0, 1) +maybe_shadow_1_macro(sub_8095C20, sub_8095B84, sub_80941B0, DIR_NORTH, 0, 1) +maybe_shadow_1_macro(sub_8095C78, sub_8095B84, sub_80941B0, DIR_WEST, 0, 1) +maybe_shadow_1_macro(sub_8095CD0, sub_8095B84, sub_80941B0, DIR_EAST, 0, 1) +maybe_shadow_1_macro(sub_8095D28, sub_8095B84, sub_80941B0, DIR_SOUTH, 1, 1) +maybe_shadow_1_macro(sub_8095D80, sub_8095B84, sub_80941B0, DIR_NORTH, 1, 1) +maybe_shadow_1_macro(sub_8095DD8, sub_8095B84, sub_80941B0, DIR_WEST, 1, 1) +maybe_shadow_1_macro(sub_8095E30, sub_8095B84, sub_80941B0, DIR_EAST, 1, 1) +maybe_shadow_1_macro(sub_8095E88, sub_8095B84, sub_80941B0, DIR_SOUTH, 2, 0) +maybe_shadow_1_macro(sub_8095EE0, sub_8095B84, sub_80941B0, DIR_NORTH, 2, 0) +maybe_shadow_1_macro(sub_8095F38, sub_8095B84, sub_80941B0, DIR_WEST, 2, 0) +maybe_shadow_1_macro(sub_8095F90, sub_8095B84, sub_80941B0, DIR_EAST, 2, 0) From 7bf307e7aee242ddba099d8963b13ad022efb9f1 Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 17 Sep 2017 14:59:52 -0400 Subject: [PATCH 177/191] The memes keep coming --- asm/field_map_obj.s | 112 -------------------------------------------- src/field_map_obj.c | 39 ++++++++------- 2 files changed, 22 insertions(+), 129 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 72fe317e4..ded1a6b97 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,118 +5,6 @@ .text - thumb_func_start sub_8095FE8 -sub_8095FE8: @ 8095FE8 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0x1 - bl sub_80929FC - adds r3, r0, 0 - lsls r3, 24 - lsrs r3, 24 - movs r0, 0x8 - str r0, [sp] - adds r0, r4, 0 - adds r1, r5, 0 - movs r2, 0x1 - bl sub_8094554 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_809459C - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095FE8 - - thumb_func_start sub_8096020 -sub_8096020: @ 8096020 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0x2 - bl sub_80929FC - adds r3, r0, 0 - lsls r3, 24 - lsrs r3, 24 - movs r0, 0x8 - str r0, [sp] - adds r0, r4, 0 - adds r1, r5, 0 - movs r2, 0x2 - bl sub_8094554 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_809459C - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8096020 - - thumb_func_start sub_8096058 -sub_8096058: @ 8096058 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0x3 - bl sub_80929FC - adds r3, r0, 0 - lsls r3, 24 - lsrs r3, 24 - movs r0, 0x8 - str r0, [sp] - adds r0, r4, 0 - adds r1, r5, 0 - movs r2, 0x3 - bl sub_8094554 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_809459C - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8096058 - - thumb_func_start sub_8096090 -sub_8096090: @ 8096090 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - movs r0, 0x4 - bl sub_80929FC - adds r3, r0, 0 - lsls r3, 24 - lsrs r3, 24 - movs r0, 0x8 - str r0, [sp] - adds r0, r4, 0 - adds r1, r5, 0 - movs r2, 0x4 - bl sub_8094554 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_809459C - lsls r0, 24 - lsrs r0, 24 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8096090 - thumb_func_start sub_80960C8 sub_80960C8: @ 80960C8 push {r4,r5,lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 87ae05ad7..f1de23307 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -4453,27 +4453,27 @@ bool8 sub_80945C4(struct MapObject *mapObject, struct Sprite *sprite) bool8 name(struct MapObject *mapObject, struct Sprite *sprite)\ {\ u8 animId;\ - animId = get_##images##_image_anim_num(DIR_##direction);\ + animId = images(DIR_##direction);\ sub_8094554(mapObject, sprite, DIR_##direction, animId, duration);\ return timer(mapObject, sprite);\ } -special_anim_with_timer_2(sub_8094600, SOUTH, go, 32, sub_80945C4) -special_anim_with_timer_2(sub_8094638, NORTH, go, 32, sub_80945C4) -special_anim_with_timer_2(sub_8094670, WEST, go, 32, sub_80945C4) -special_anim_with_timer_2(sub_80946A8, EAST, go, 32, sub_80945C4) -special_anim_with_timer_2(sub_80946E0, SOUTH, go, 16, sub_809459C) -special_anim_with_timer_2(sub_8094718, NORTH, go, 16, sub_809459C) -special_anim_with_timer_2(sub_8094750, WEST, go, 16, sub_809459C) -special_anim_with_timer_2(sub_8094788, EAST, go, 16, sub_809459C) -special_anim_with_timer_2(sub_80947C0, SOUTH, go_fast, 8, sub_809459C) -special_anim_with_timer_2(sub_80947F8, NORTH, go_fast, 8, sub_809459C) -special_anim_with_timer_2(sub_8094830, WEST, go_fast, 8, sub_809459C) -special_anim_with_timer_2(sub_8094868, EAST, go_fast, 8, sub_809459C) -special_anim_with_timer_2(sub_80948A0, SOUTH, go_faster, 4, sub_809459C) -special_anim_with_timer_2(sub_80948D8, NORTH, go_faster, 4, sub_809459C) -special_anim_with_timer_2(sub_8094910, WEST, go_faster, 4, sub_809459C) -special_anim_with_timer_2(sub_8094948, EAST, go_faster, 4, sub_809459C) +special_anim_with_timer_2(sub_8094600, SOUTH, get_go_image_anim_num, 32, sub_80945C4) +special_anim_with_timer_2(sub_8094638, NORTH, get_go_image_anim_num, 32, sub_80945C4) +special_anim_with_timer_2(sub_8094670, WEST, get_go_image_anim_num, 32, sub_80945C4) +special_anim_with_timer_2(sub_80946A8, EAST, get_go_image_anim_num, 32, sub_80945C4) +special_anim_with_timer_2(sub_80946E0, SOUTH, get_go_image_anim_num, 16, sub_809459C) +special_anim_with_timer_2(sub_8094718, NORTH, get_go_image_anim_num, 16, sub_809459C) +special_anim_with_timer_2(sub_8094750, WEST, get_go_image_anim_num, 16, sub_809459C) +special_anim_with_timer_2(sub_8094788, EAST, get_go_image_anim_num, 16, sub_809459C) +special_anim_with_timer_2(sub_80947C0, SOUTH, get_go_fast_image_anim_num, 8, sub_809459C) +special_anim_with_timer_2(sub_80947F8, NORTH, get_go_fast_image_anim_num, 8, sub_809459C) +special_anim_with_timer_2(sub_8094830, WEST, get_go_fast_image_anim_num, 8, sub_809459C) +special_anim_with_timer_2(sub_8094868, EAST, get_go_fast_image_anim_num, 8, sub_809459C) +special_anim_with_timer_2(sub_80948A0, SOUTH, get_go_faster_image_anim_num, 4, sub_809459C) +special_anim_with_timer_2(sub_80948D8, NORTH, get_go_faster_image_anim_num, 4, sub_809459C) +special_anim_with_timer_2(sub_8094910, WEST, get_go_faster_image_anim_num, 4, sub_809459C) +special_anim_with_timer_2(sub_8094948, EAST, get_go_faster_image_anim_num, 4, sub_809459C) an_walk_any_2_macro(sub_8094980, do_go_anim, npc_obj_ministep_stop_on_arrival, DIR_SOUTH, 2) an_walk_any_2_macro(sub_80949C0, do_go_anim, npc_obj_ministep_stop_on_arrival, DIR_NORTH, 2) @@ -4933,3 +4933,8 @@ maybe_shadow_1_macro(sub_8095E88, sub_8095B84, sub_80941B0, DIR_SOUTH, 2, 0) maybe_shadow_1_macro(sub_8095EE0, sub_8095B84, sub_80941B0, DIR_NORTH, 2, 0) maybe_shadow_1_macro(sub_8095F38, sub_8095B84, sub_80941B0, DIR_WEST, 2, 0) maybe_shadow_1_macro(sub_8095F90, sub_8095B84, sub_80941B0, DIR_EAST, 2, 0) + +special_anim_with_timer_2(sub_8095FE8, SOUTH, sub_80929FC, 8, sub_809459C) +special_anim_with_timer_2(sub_8096020, NORTH, sub_80929FC, 8, sub_809459C) +special_anim_with_timer_2(sub_8096058, WEST, sub_80929FC, 8, sub_809459C) +special_anim_with_timer_2(sub_8096090, EAST, sub_80929FC, 8, sub_809459C) From 8d34e9c3970d23832bb5500358fe4a2e250c5124 Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 17 Sep 2017 15:03:47 -0400 Subject: [PATCH 178/191] More an_walk_any_2_macro memes --- asm/field_map_obj.s | 179 -------------------------------------------- src/field_map_obj.c | 12 +++ 2 files changed, 12 insertions(+), 179 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index ded1a6b97..5e0e3de0d 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,185 +5,6 @@ .text - thumb_func_start sub_80960C8 -sub_80960C8: @ 80960C8 - push {r4,r5,lr} - adds r5, r0, 0 - adds r4, r1, 0 - lsls r2, 24 - lsrs r2, 24 - lsls r3, 24 - lsrs r3, 24 - bl npc_apply_direction - ldrb r0, [r5, 0x18] - lsls r0, 28 - lsrs r0, 28 - bl sub_80929BC - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 24 - adds r0, r4, 0 - bl StartSpriteAnim - adds r0, r4, 0 - movs r1, 0 - bl SeekSpriteAnim - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_80960C8 - - thumb_func_start sub_8096100 -sub_8096100: @ 8096100 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x1 - movs r3, 0x1 - bl sub_80960C8 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8096120 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8096100 - - thumb_func_start sub_8096120 -sub_8096120: @ 8096120 - push {r4,lr} - adds r4, r1, 0 - bl npc_obj_ministep_stop_on_arrival - lsls r0, 24 - cmp r0, 0 - bne _08096132 - movs r0, 0 - b _08096138 -_08096132: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_08096138: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8096120 - - thumb_func_start sub_8096140 -sub_8096140: @ 8096140 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x2 - movs r3, 0x1 - bl sub_80960C8 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8096160 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8096140 - - thumb_func_start sub_8096160 -sub_8096160: @ 8096160 - push {r4,lr} - adds r4, r1, 0 - bl npc_obj_ministep_stop_on_arrival - lsls r0, 24 - cmp r0, 0 - bne _08096172 - movs r0, 0 - b _08096178 -_08096172: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_08096178: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8096160 - - thumb_func_start sub_8096180 -sub_8096180: @ 8096180 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x3 - movs r3, 0x1 - bl sub_80960C8 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_80961A0 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8096180 - - thumb_func_start sub_80961A0 -sub_80961A0: @ 80961A0 - push {r4,lr} - adds r4, r1, 0 - bl npc_obj_ministep_stop_on_arrival - lsls r0, 24 - cmp r0, 0 - bne _080961B2 - movs r0, 0 - b _080961B8 -_080961B2: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_080961B8: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_80961A0 - - thumb_func_start sub_80961C0 -sub_80961C0: @ 80961C0 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x4 - movs r3, 0x1 - bl sub_80960C8 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_80961E0 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80961C0 - - thumb_func_start sub_80961E0 -sub_80961E0: @ 80961E0 - push {r4,lr} - adds r4, r1, 0 - bl npc_obj_ministep_stop_on_arrival - lsls r0, 24 - cmp r0, 0 - bne _080961F2 - movs r0, 0 - b _080961F8 -_080961F2: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_080961F8: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_80961E0 - thumb_func_start sub_8096200 sub_8096200: @ 8096200 push {r4,r5,lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index f1de23307..b5f92645d 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -4938,3 +4938,15 @@ special_anim_with_timer_2(sub_8095FE8, SOUTH, sub_80929FC, 8, sub_809459C) special_anim_with_timer_2(sub_8096020, NORTH, sub_80929FC, 8, sub_809459C) special_anim_with_timer_2(sub_8096058, WEST, sub_80929FC, 8, sub_809459C) special_anim_with_timer_2(sub_8096090, EAST, sub_80929FC, 8, sub_809459C) + +void sub_80960C8(struct MapObject *mapObject, struct Sprite *sprite, u8 direction, u8 speed) +{ + npc_apply_direction(mapObject, sprite, direction, speed); + StartSpriteAnim(sprite, sub_80929BC(mapObject->mapobj_unk_18)); + SeekSpriteAnim(sprite, 0); +} + +an_walk_any_2_macro(sub_8096100, sub_80960C8, npc_obj_ministep_stop_on_arrival, DIR_SOUTH, 1) +an_walk_any_2_macro(sub_8096140, sub_80960C8, npc_obj_ministep_stop_on_arrival, DIR_NORTH, 1) +an_walk_any_2_macro(sub_8096180, sub_80960C8, npc_obj_ministep_stop_on_arrival, DIR_WEST, 1) +an_walk_any_2_macro(sub_80961C0, sub_80960C8, npc_obj_ministep_stop_on_arrival, DIR_EAST, 1) From a9d3949c915a6ccb58f0fe6b58af18ae34a60974 Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 17 Sep 2017 15:05:23 -0400 Subject: [PATCH 179/191] More an_walk_any_2_macro memes (again) --- asm/field_map_obj.s | 177 -------------------------------------------- src/field_map_obj.c | 11 +++ 2 files changed, 11 insertions(+), 177 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 5e0e3de0d..6ebef8976 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,183 +5,6 @@ .text - thumb_func_start sub_8096200 -sub_8096200: @ 8096200 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - lsls r2, 24 - lsrs r2, 24 - lsls r3, 24 - lsrs r3, 24 - bl npc_apply_direction - ldrb r0, [r4, 0x18] - lsls r0, 28 - lsrs r0, 28 - bl sub_80929FC - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r1, r5, 0 - bl npc_apply_anim_looping - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_8096200 - - thumb_func_start sub_8096230 -sub_8096230: @ 8096230 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x1 - movs r3, 0x1 - bl sub_8096200 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8096250 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8096230 - - thumb_func_start sub_8096250 -sub_8096250: @ 8096250 - push {r4,lr} - adds r4, r1, 0 - bl npc_obj_ministep_stop_on_arrival - lsls r0, 24 - cmp r0, 0 - bne _08096262 - movs r0, 0 - b _08096268 -_08096262: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_08096268: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8096250 - - thumb_func_start sub_8096270 -sub_8096270: @ 8096270 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x2 - movs r3, 0x1 - bl sub_8096200 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8096290 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8096270 - - thumb_func_start sub_8096290 -sub_8096290: @ 8096290 - push {r4,lr} - adds r4, r1, 0 - bl npc_obj_ministep_stop_on_arrival - lsls r0, 24 - cmp r0, 0 - bne _080962A2 - movs r0, 0 - b _080962A8 -_080962A2: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_080962A8: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8096290 - - thumb_func_start sub_80962B0 -sub_80962B0: @ 80962B0 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x3 - movs r3, 0x1 - bl sub_8096200 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_80962D0 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80962B0 - - thumb_func_start sub_80962D0 -sub_80962D0: @ 80962D0 - push {r4,lr} - adds r4, r1, 0 - bl npc_obj_ministep_stop_on_arrival - lsls r0, 24 - cmp r0, 0 - bne _080962E2 - movs r0, 0 - b _080962E8 -_080962E2: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_080962E8: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_80962D0 - - thumb_func_start sub_80962F0 -sub_80962F0: @ 80962F0 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x4 - movs r3, 0x1 - bl sub_8096200 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8096310 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80962F0 - - thumb_func_start sub_8096310 -sub_8096310: @ 8096310 - push {r4,lr} - adds r4, r1, 0 - bl npc_obj_ministep_stop_on_arrival - lsls r0, 24 - cmp r0, 0 - bne _08096322 - movs r0, 0 - b _08096328 -_08096322: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_08096328: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8096310 - thumb_func_start sub_8096330 sub_8096330: @ 8096330 push {r4,r5,lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index b5f92645d..9769c6a03 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -4950,3 +4950,14 @@ an_walk_any_2_macro(sub_8096100, sub_80960C8, npc_obj_ministep_stop_on_arrival, an_walk_any_2_macro(sub_8096140, sub_80960C8, npc_obj_ministep_stop_on_arrival, DIR_NORTH, 1) an_walk_any_2_macro(sub_8096180, sub_80960C8, npc_obj_ministep_stop_on_arrival, DIR_WEST, 1) an_walk_any_2_macro(sub_80961C0, sub_80960C8, npc_obj_ministep_stop_on_arrival, DIR_EAST, 1) + +void sub_8096200(struct MapObject *mapObject, struct Sprite *sprite, u8 direction, u8 speed) +{ + npc_apply_direction(mapObject, sprite, direction, speed); + npc_apply_anim_looping(mapObject, sprite, sub_80929FC(mapObject->mapobj_unk_18)); +} + +an_walk_any_2_macro(sub_8096230, sub_8096200, npc_obj_ministep_stop_on_arrival, DIR_SOUTH, 1) +an_walk_any_2_macro(sub_8096270, sub_8096200, npc_obj_ministep_stop_on_arrival, DIR_NORTH, 1) +an_walk_any_2_macro(sub_80962B0, sub_8096200, npc_obj_ministep_stop_on_arrival, DIR_WEST, 1) +an_walk_any_2_macro(sub_80962F0, sub_8096200, npc_obj_ministep_stop_on_arrival, DIR_EAST, 1) From fb01dd2e5a6d76974eaceeb6fdaab11abfd4f910 Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 17 Sep 2017 15:06:45 -0400 Subject: [PATCH 180/191] More an_walk_any_2_macro memes (again again) --- asm/field_map_obj.s | 179 -------------------------------------------- src/field_map_obj.c | 11 +++ 2 files changed, 11 insertions(+), 179 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 6ebef8976..f3a044d44 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,185 +5,6 @@ .text - thumb_func_start sub_8096330 -sub_8096330: @ 8096330 - push {r4,r5,lr} - adds r5, r0, 0 - adds r4, r1, 0 - lsls r2, 24 - lsrs r2, 24 - lsls r3, 24 - lsrs r3, 24 - bl npc_apply_direction - ldrb r0, [r5, 0x18] - lsls r0, 28 - lsrs r0, 28 - bl sub_80929DC - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 24 - adds r0, r4, 0 - bl StartSpriteAnim - adds r0, r4, 0 - movs r1, 0 - bl SeekSpriteAnim - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_8096330 - - thumb_func_start sub_8096368 -sub_8096368: @ 8096368 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x1 - movs r3, 0x1 - bl sub_8096330 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8096388 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8096368 - - thumb_func_start sub_8096388 -sub_8096388: @ 8096388 - push {r4,lr} - adds r4, r1, 0 - bl npc_obj_ministep_stop_on_arrival - lsls r0, 24 - cmp r0, 0 - bne _0809639A - movs r0, 0 - b _080963A0 -_0809639A: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_080963A0: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8096388 - - thumb_func_start sub_80963A8 -sub_80963A8: @ 80963A8 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x2 - movs r3, 0x1 - bl sub_8096330 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_80963C8 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80963A8 - - thumb_func_start sub_80963C8 -sub_80963C8: @ 80963C8 - push {r4,lr} - adds r4, r1, 0 - bl npc_obj_ministep_stop_on_arrival - lsls r0, 24 - cmp r0, 0 - bne _080963DA - movs r0, 0 - b _080963E0 -_080963DA: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_080963E0: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_80963C8 - - thumb_func_start sub_80963E8 -sub_80963E8: @ 80963E8 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x3 - movs r3, 0x1 - bl sub_8096330 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8096408 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80963E8 - - thumb_func_start sub_8096408 -sub_8096408: @ 8096408 - push {r4,lr} - adds r4, r1, 0 - bl npc_obj_ministep_stop_on_arrival - lsls r0, 24 - cmp r0, 0 - bne _0809641A - movs r0, 0 - b _08096420 -_0809641A: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_08096420: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8096408 - - thumb_func_start sub_8096428 -sub_8096428: @ 8096428 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x4 - movs r3, 0x1 - bl sub_8096330 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8096448 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8096428 - - thumb_func_start sub_8096448 -sub_8096448: @ 8096448 - push {r4,lr} - adds r4, r1, 0 - bl npc_obj_ministep_stop_on_arrival - lsls r0, 24 - cmp r0, 0 - bne _0809645A - movs r0, 0 - b _08096460 -_0809645A: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_08096460: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8096448 - thumb_func_start sub_8096468 sub_8096468: @ 8096468 push {r4,lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 9769c6a03..d4c00685f 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -4961,3 +4961,14 @@ an_walk_any_2_macro(sub_8096230, sub_8096200, npc_obj_ministep_stop_on_arrival, an_walk_any_2_macro(sub_8096270, sub_8096200, npc_obj_ministep_stop_on_arrival, DIR_NORTH, 1) an_walk_any_2_macro(sub_80962B0, sub_8096200, npc_obj_ministep_stop_on_arrival, DIR_WEST, 1) an_walk_any_2_macro(sub_80962F0, sub_8096200, npc_obj_ministep_stop_on_arrival, DIR_EAST, 1) + +void sub_8096330(struct MapObject *mapObject, struct Sprite *sprite, u8 direction, u8 speed) +{ + npc_apply_direction(mapObject, sprite, direction, speed); + StartSpriteAnim(sprite, sub_80929DC(mapObject->mapobj_unk_18)); + SeekSpriteAnim(sprite, 0); +} +an_walk_any_2_macro(sub_8096368, sub_8096330, npc_obj_ministep_stop_on_arrival, DIR_SOUTH, 1) +an_walk_any_2_macro(sub_80963A8, sub_8096330, npc_obj_ministep_stop_on_arrival, DIR_NORTH, 1) +an_walk_any_2_macro(sub_80963E8, sub_8096330, npc_obj_ministep_stop_on_arrival, DIR_WEST, 1) +an_walk_any_2_macro(sub_8096428, sub_8096330, npc_obj_ministep_stop_on_arrival, DIR_EAST, 1) From 70b1ad485719ce1854020222131a0c0daa5a16cd Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 17 Sep 2017 15:33:26 -0400 Subject: [PATCH 181/191] Remaining functions --- asm/field_map_obj.s | 280 -------------------------------------- include/map_obj_8097404.h | 2 + include/sprite.h | 2 + ld_script.txt | 1 - src/field_map_obj.c | 106 +++++++++++++++ 5 files changed, 110 insertions(+), 281 deletions(-) delete mode 100755 asm/field_map_obj.s diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s deleted file mode 100755 index f3a044d44..000000000 --- a/asm/field_map_obj.s +++ /dev/null @@ -1,280 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start sub_8096468 -sub_8096468: @ 8096468 - push {r4,lr} - adds r4, r1, 0 - bl sub_8097FA4 - movs r0, 0x1 - strh r0, [r4, 0x32] - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8096468 - - thumb_func_start sub_809647C -sub_809647C: @ 809647C - push {r4,lr} - adds r4, r1, 0 - ldrb r0, [r0, 0x1B] - bl sub_8098044 - movs r0, 0 - strh r0, [r4, 0x26] - movs r0, 0x1 - strh r0, [r4, 0x32] - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_809647C - - thumb_func_start sub_8096494 -sub_8096494: @ 8096494 - push {r4,lr} - adds r2, r0, 0 - adds r4, r1, 0 - movs r1, 0x26 - ldrsh r0, [r4, r1] - cmp r0, 0 - beq _080964A6 - movs r0, 0 - b _080964B0 -_080964A6: - ldrb r0, [r2, 0x1B] - bl sub_8098044 - movs r0, 0x1 - strh r0, [r4, 0x32] -_080964B0: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8096494 - - thumb_func_start sub_80964B8 -sub_80964B8: @ 80964B8 - movs r0, 0x1 - bx lr - thumb_func_end sub_80964B8 - - thumb_func_start sub_80964BC -@ bool8 sub_80964BC(struct npc_state *fieldObject, struct obj *object) -sub_80964BC: @ 80964BC - adds r1, 0x2C - ldrb r0, [r1] - movs r2, 0x40 - orrs r0, r2 - strb r0, [r1] - movs r0, 0x1 - bx lr - thumb_func_end sub_80964BC - - thumb_func_start npc_obj_transfer_image_anim_pause_flag -@ void npc_obj_transfer_image_anim_pause_flag(struct npc_state *fieldObject, struct obj *object) -npc_obj_transfer_image_anim_pause_flag: @ 80964CC - push {lr} - ldrb r0, [r0, 0x1] - lsls r0, 29 - cmp r0, 0 - bge _080964E2 - adds r0, r1, 0 - adds r0, 0x2C - ldrb r1, [r0] - movs r2, 0x40 - orrs r1, r2 - strb r1, [r0] -_080964E2: - pop {r0} - bx r0 - thumb_func_end npc_obj_transfer_image_anim_pause_flag - - thumb_func_start sub_80964E8 -@ void sub_80964E8(struct npc_state *fieldObject, struct obj *object) -sub_80964E8: @ 80964E8 - push {r4,lr} - adds r4, r0, 0 - ldrb r3, [r4, 0x1] - lsls r0, r3, 28 - cmp r0, 0 - bge _08096510 - adds r2, r1, 0 - adds r2, 0x2C - ldrb r1, [r2] - movs r0, 0x41 - negs r0, r0 - ands r0, r1 - strb r0, [r2] - movs r0, 0x5 - negs r0, r0 - ands r0, r3 - movs r1, 0x9 - negs r1, r1 - ands r0, r1 - strb r0, [r4, 0x1] -_08096510: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_80964E8 - - thumb_func_start sub_8096518 -@ void sub_8096518(struct npc_state *fieldObject, struct obj *object) -sub_8096518: @ 8096518 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl sub_8096530 - adds r0, r4, 0 - adds r1, r5, 0 - bl npc_update_obj_anim_flag - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_8096518 - - thumb_func_start sub_8096530 -sub_8096530: @ 8096530 - push {r4-r6,lr} - adds r5, r0, 0 - adds r4, r1, 0 - ldrb r1, [r5, 0x1] - movs r0, 0x41 - negs r0, r0 - ands r0, r1 - strb r0, [r5, 0x1] - ldrb r0, [r5, 0x5] - bl GetFieldObjectGraphicsInfo - adds r6, r0, 0 - adds r0, r4, 0 - adds r0, 0x3E - ldrb r1, [r0] - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _08096594 - ldrh r1, [r4, 0x24] - ldrh r0, [r4, 0x20] - adds r1, r0 - adds r0, r4, 0 - adds r0, 0x28 - ldrb r0, [r0] - lsls r0, 24 - asrs r0, 24 - ldr r2, =gSpriteCoordOffsetX - adds r0, r1 - ldrh r2, [r2] - adds r0, r2 - lsls r0, 16 - lsrs r3, r0, 16 - ldrh r1, [r4, 0x26] - ldrh r0, [r4, 0x22] - adds r1, r0 - adds r0, r4, 0 - adds r0, 0x29 - ldrb r0, [r0] - lsls r0, 24 - asrs r0, 24 - ldr r2, =gSpriteCoordOffsetY - adds r0, r1 - ldrh r2, [r2] - adds r0, r2 - b _080965BC - .pool -_08096594: - ldrh r1, [r4, 0x24] - ldrh r0, [r4, 0x20] - adds r1, r0 - adds r0, r4, 0 - adds r0, 0x28 - ldrb r0, [r0] - lsls r0, 24 - asrs r0, 24 - adds r0, r1 - lsls r0, 16 - lsrs r3, r0, 16 - ldrh r1, [r4, 0x26] - ldrh r0, [r4, 0x22] - adds r1, r0 - adds r0, r4, 0 - adds r0, 0x29 - ldrb r0, [r0] - lsls r0, 24 - asrs r0, 24 - adds r0, r1 -_080965BC: - lsls r0, 16 - lsrs r2, r0, 16 - ldrh r0, [r6, 0x8] - adds r0, r3 - lsls r0, 16 - lsrs r1, r0, 16 - ldrh r0, [r6, 0xA] - adds r0, r2 - lsls r0, 16 - lsrs r4, r0, 16 - lsls r0, r3, 16 - asrs r0, 16 - cmp r0, 0xFF - bgt _080965E4 - lsls r0, r1, 16 - asrs r0, 16 - movs r1, 0x10 - negs r1, r1 - cmp r0, r1 - bge _080965EC -_080965E4: - ldrb r0, [r5, 0x1] - movs r1, 0x40 - orrs r0, r1 - strb r0, [r5, 0x1] -_080965EC: - lsls r0, r2, 16 - asrs r0, 16 - cmp r0, 0xAF - bgt _08096600 - lsls r0, r4, 16 - asrs r0, 16 - movs r1, 0x10 - negs r1, r1 - cmp r0, r1 - bge _08096608 -_08096600: - ldrb r0, [r5, 0x1] - movs r1, 0x40 - orrs r0, r1 - strb r0, [r5, 0x1] -_08096608: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_8096530 - - thumb_func_start npc_update_obj_anim_flag -@ void npc_update_obj_anim_flag(struct npc_state *fieldObject, struct obj *object) -npc_update_obj_anim_flag: @ 8096610 - push {lr} - adds r2, r1, 0 - adds r2, 0x3E - ldrb r1, [r2] - movs r3, 0x5 - negs r3, r3 - ands r3, r1 - strb r3, [r2] - ldrb r1, [r0, 0x1] - movs r0, 0x60 - ands r0, r1 - cmp r0, 0 - beq _08096632 - movs r1, 0x4 - adds r0, r3, 0 - orrs r0, r1 - strb r0, [r2] -_08096632: - pop {r0} - bx r0 - thumb_func_end npc_update_obj_anim_flag - - .align 2, 0 @ Don't pad with nop. diff --git a/include/map_obj_8097404.h b/include/map_obj_8097404.h index fd5616330..27ffd18cb 100644 --- a/include/map_obj_8097404.h +++ b/include/map_obj_8097404.h @@ -26,5 +26,7 @@ void obj_anim_image_set_and_seek(struct Sprite *, u8, u8); bool8 sub_80979BC(struct Sprite *); void sub_8097750(struct Sprite *); bool8 sub_8097758(struct Sprite *); +void sub_8097FA4(struct MapObject *); +void sub_8098044(u8); #endif //GUARD_MAP_OBJ_8097404_H diff --git a/include/sprite.h b/include/sprite.h index 7b3c9fb5a..838b0d7c0 100644 --- a/include/sprite.h +++ b/include/sprite.h @@ -240,6 +240,8 @@ struct OamMatrix extern const struct OamData gDummyOamData; extern const union AnimCmd *const gDummySpriteAnimTable[]; extern const union AffineAnimCmd *const gDummySpriteAffineAnimTable[]; +extern s16 gSpriteCoordOffsetX; +extern s16 gSpriteCoordOffsetY; extern struct Sprite gSprites[]; diff --git a/ld_script.txt b/ld_script.txt index 0cff77ca8..81e4fc3ab 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -97,7 +97,6 @@ SECTIONS { asm/field_door.o(.text); asm/field_player_avatar.o(.text); src/field_map_obj.o(.text); - asm/field_map_obj.o(.text); asm/field_ground_effect.o(.text); asm/map_obj_8097404.o(.text); asm/field_message_box.o(.text); diff --git a/src/field_map_obj.c b/src/field_map_obj.c index d4c00685f..a79f78434 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -122,6 +122,8 @@ static bool8 IsCoordOutsideFieldObjectMovementRect(struct MapObject *, s16, s16) static bool8 IsMetatileDirectionallyImpassable(struct MapObject *, s16, s16, u8); static bool8 CheckForCollisionBetweenFieldObjects(struct MapObject *, s16, s16); static bool8 sub_809558C(struct MapObject *, struct Sprite *); +static void sub_8096530(struct MapObject *, struct Sprite *); +static void npc_update_obj_anim_flag(struct MapObject *, struct Sprite *); // ROM data @@ -4972,3 +4974,107 @@ an_walk_any_2_macro(sub_8096368, sub_8096330, npc_obj_ministep_stop_on_arrival, an_walk_any_2_macro(sub_80963A8, sub_8096330, npc_obj_ministep_stop_on_arrival, DIR_NORTH, 1) an_walk_any_2_macro(sub_80963E8, sub_8096330, npc_obj_ministep_stop_on_arrival, DIR_WEST, 1) an_walk_any_2_macro(sub_8096428, sub_8096330, npc_obj_ministep_stop_on_arrival, DIR_EAST, 1) + +bool8 sub_8096468(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_8097FA4(mapObject); + sprite->data2 = 1; + return TRUE; +} + +bool8 sub_809647C(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_8098044(mapObject->mapobj_unk_1B); + sprite->pos2.y = 0; + sprite->data2 = 1; + return TRUE; +} + +bool8 sub_8096494(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sprite->pos2.y == 0) + { + sub_8098044(mapObject->mapobj_unk_1B); + sprite->data2 = 1; + return TRUE; + } + return FALSE; +} + +bool8 sub_80964B8(struct MapObject *mapObject, struct Sprite *sprite) +{ + return TRUE; +} + +bool8 sub_80964BC(struct MapObject *mapObject, struct Sprite *sprite) +{ + sprite->animPaused = TRUE; + return TRUE; +} + +void npc_obj_transfer_image_anim_pause_flag(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (mapObject->mapobj_bit_10) + { + sprite->animPaused = TRUE; + } +} + +void sub_80964E8(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (mapObject->mapobj_bit_11) + { + sprite->animPaused = FALSE; + mapObject->mapobj_bit_10 = FALSE; + mapObject->mapobj_bit_11 = FALSE; + } +} + +void sub_8096518(struct MapObject *mapObject, struct Sprite *sprite) +{ + sub_8096530(mapObject, sprite); + npc_update_obj_anim_flag(mapObject, sprite); +} + +static void sub_8096530(struct MapObject *mapObject, struct Sprite *sprite) +{ + u16 x; + u16 y; + u16 x2; + u16 y2; + const struct MapObjectGraphicsInfo *graphicsInfo; + + mapObject->mapobj_bit_14 = FALSE; + graphicsInfo = GetFieldObjectGraphicsInfo(mapObject->graphicsId); + if (sprite->coordOffsetEnabled) + { + x = sprite->pos1.x + sprite->pos2.x + sprite->centerToCornerVecX + gSpriteCoordOffsetX; + y = sprite->pos1.y + sprite->pos2.y + sprite->centerToCornerVecY + gSpriteCoordOffsetY; + } + else + { + x = sprite->pos1.x + sprite->pos2.x + sprite->centerToCornerVecX; + y = sprite->pos1.y + sprite->pos2.y + sprite->centerToCornerVecY; + } + x2 = graphicsInfo->width; + x2 += x; + y2 = y; + y2 += graphicsInfo->height; + if ((s16)x >= 0x100 || (s16)x2 < -0x10) + { + mapObject->mapobj_bit_14 = TRUE; + } + if ((s16)y >= 0xB0 || (s16)y2 < -0x10) + { + mapObject->mapobj_bit_14 = TRUE; + } +} + +static void npc_update_obj_anim_flag(struct MapObject *mapObject, struct Sprite *sprite) +{ + sprite->invisible = FALSE; + if (mapObject->mapobj_bit_13 || mapObject->mapobj_bit_14) + { + sprite->invisible = TRUE; + } +} From 6106bc93b38e505091fcf17e7e3dfec449583e70 Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 17 Sep 2017 17:33:25 -0400 Subject: [PATCH 182/191] Remove data/field_map_obj.s from data/data3.s --- data/data3.s | 498 +----------------------------------------- data/field_map_obj.s | 499 +++++++++++++++++++++++++++++++++++++++++++ ld_script.txt | 2 + 3 files changed, 504 insertions(+), 495 deletions(-) create mode 100644 data/field_map_obj.s diff --git a/data/data3.s b/data/data3.s index 889b78b6d..70b057884 100644 --- a/data/data3.s +++ b/data/data3.s @@ -634,502 +634,10 @@ gUnknown_084975BC:: @ 84975BC // data/field_map_obj.s -gUnknown_084975C4:: @ 84975C4 - .incbin "baserom.gba", 0x4975c4, 0x10 - -gUnknown_084975D4:: @ 84975D4 - .incbin "baserom.gba", 0x4975d4, 0x18 - -gUnknown_084975EC:: @ 84975EC - .incbin "baserom.gba", 0x4975ec, 0xc - -@ 84975F8 - .include "data/graphics/field_objects/field_object_graphics.inc" - -gUnknown_08505438:: @ 8505438 - .incbin "baserom.gba", 0x505438, 0x144 - -gUnknown_0850557C:: @ 850557C - .incbin "baserom.gba", 0x50557c, 0x51 - -gUnknown_085055CD:: @ 85055CD - .incbin "baserom.gba", 0x5055cd, 0x51 - - .align 2, 0 -@ 8505620 - .include "data/graphics/field_objects/field_object_graphics_info_pointers.inc" - -@ 85059F8 - .include "data/graphics/field_objects/field_effect_object_template_pointers.inc" - -@ 8505A8C - .include "data/graphics/field_objects/field_object_pic_tables.inc" - -@ 85089FC - .include "data/graphics/field_objects/field_object_anims.inc" - -gUnknown_085094AC:: @ 85094AC - .incbin "baserom.gba", 0x5094ac, 0x40 - -@ 85094EC - .include "data/graphics/field_objects/field_object_oam.inc" - -@ 8509954 - .include "data/graphics/field_objects/field_object_graphics_info.inc" - -gUnknown_0850BBC8:: @ 850BBC8 - .incbin "baserom.gba", 0x50bbc8, 0x138 - -gUnknown_0850BD00:: @ 850BD00 - .incbin "baserom.gba", 0x50bd00, 0x78 - -gUnknown_0850BD78:: @ 850BD78 - .incbin "baserom.gba", 0x50bd78, 0xc0 - -gUnknown_0850BE38:: @ 850BE38 - .incbin "baserom.gba", 0x50be38, 0x10 - -@ 850BE48 - .include "data/graphics/field_objects/berry_tree_graphics_tables.inc" - -@ 850C9C0 - .include "data/graphics/field_objects/field_effect_objects.inc" - - .incbin "baserom.gba", 0x50d6d4, 0x8 - -gUnknown_0850D6DC:: @ 850D6DC - .incbin "baserom.gba", 0x50d6dc, 0x10 - -gUnknown_0850D6EC:: @ 850D6EC - .incbin "baserom.gba", 0x50d6ec, 0x8 - -gUnknown_0850D6F4:: @ 850D6F4 - .incbin "baserom.gba", 0x50d6f4, 0x1c - -gUnknown_0850D710:: @ 850D710 - .incbin "baserom.gba", 0x50d710, 0x4 - -gUnknown_0850D714:: @ 850D714 - .incbin "baserom.gba", 0x50d714, 0x2c - -gUnknown_0850D740:: @ 850D740 - .incbin "baserom.gba", 0x50d740, 0x14 - -gUnknown_0850D754:: @ 850D754 - .incbin "baserom.gba", 0x50d754, 0x1c - -gUnknown_0850D770:: @ 850D770 - .incbin "baserom.gba", 0x50d770, 0x4 - -gUnknown_0850D774:: @ 850D774 - .incbin "baserom.gba", 0x50d774, 0x1c - -gUnknown_0850D790:: @ 850D790 - .incbin "baserom.gba", 0x50d790, 0x4 - -gUnknown_0850D794:: @ 850D794 - .incbin "baserom.gba", 0x50d794, 0xc - -gUnknown_0850D7A0:: @ 850D7A0 - .incbin "baserom.gba", 0x50d7a0, 0x14 - -gUnknown_0850D7B4:: @ 850D7B4 - .incbin "baserom.gba", 0x50d7b4, 0x14 - -gUnknown_0850D7C8:: @ 850D7C8 - .incbin "baserom.gba", 0x50d7c8, 0x14 - -gUnknown_0850D7DC:: @ 850D7DC - .incbin "baserom.gba", 0x50d7dc, 0x14 - -gUnknown_0850D7F0:: @ 850D7F0 - .incbin "baserom.gba", 0x50d7f0, 0x4 - -gUnknown_0850D7F4:: @ 850D7F4 - .incbin "baserom.gba", 0x50d7f4, 0x14 - -gUnknown_0850D808:: @ 850D808 - .incbin "baserom.gba", 0x50d808, 0x4 - -gUnknown_0850D80C:: @ 850D80C - .incbin "baserom.gba", 0x50d80c, 0x14 - -gUnknown_0850D820:: @ 850D820 - .incbin "baserom.gba", 0x50d820, 0x4 - -gUnknown_0850D824:: @ 850D824 - .incbin "baserom.gba", 0x50d824, 0x14 - -gUnknown_0850D838:: @ 850D838 - .incbin "baserom.gba", 0x50d838, 0x4 - -gUnknown_0850D83C:: @ 850D83C - .incbin "baserom.gba", 0x50d83c, 0x14 - -gUnknown_0850D850:: @ 850D850 - .incbin "baserom.gba", 0x50d850, 0x4 - -gUnknown_0850D854:: @ 850D854 - .incbin "baserom.gba", 0x50d854, 0x14 - -gUnknown_0850D868:: @ 850D868 - .incbin "baserom.gba", 0x50d868, 0x4 - -gUnknown_0850D86C:: @ 850D86C - .incbin "baserom.gba", 0x50d86c, 0x14 - -gUnknown_0850D880:: @ 850D880 - .incbin "baserom.gba", 0x50d880, 0x4 - -gUnknown_0850D884:: @ 850D884 - .incbin "baserom.gba", 0x50d884, 0x14 - -gUnknown_0850D898:: @ 850D898 - .incbin "baserom.gba", 0x50d898, 0x4 - -gUnknown_0850D89C:: @ 850D89C - .incbin "baserom.gba", 0x50d89c, 0x10 - -gUnknown_0850D8AC:: @ 850D8AC - .incbin "baserom.gba", 0x50d8ac, 0x8 - -gUnknown_0850D8B4:: @ 850D8B4 - .incbin "baserom.gba", 0x50d8b4, 0x10 - -gUnknown_0850D8C4:: @ 850D8C4 - .incbin "baserom.gba", 0x50d8c4, 0x8 - -gUnknown_0850D8CC:: @ 850D8CC - .incbin "baserom.gba", 0x50d8cc, 0x10 - -gUnknown_0850D8DC:: @ 850D8DC - .incbin "baserom.gba", 0x50d8dc, 0xc - -gUnknown_0850D8E8:: @ 850D8E8 - .incbin "baserom.gba", 0x50d8e8, 0x4 - -gUnknown_0850D8EC:: @ 850D8EC - .incbin "baserom.gba", 0x50d8ec, 0xc - -gUnknown_0850D8F8:: @ 850D8F8 - .incbin "baserom.gba", 0x50d8f8, 0x4 - -gUnknown_0850D8FC:: @ 850D8FC - .incbin "baserom.gba", 0x50d8fc, 0xc - -gUnknown_0850D908:: @ 850D908 - .incbin "baserom.gba", 0x50d908, 0x4 - -gUnknown_0850D90C:: @ 850D90C - .incbin "baserom.gba", 0x50d90c, 0xc - -gUnknown_0850D918:: @ 850D918 - .incbin "baserom.gba", 0x50d918, 0x4 - -gUnknown_0850D91C:: @ 850D91C - .incbin "baserom.gba", 0x50d91c, 0xc - -gUnknown_0850D928:: @ 850D928 - .incbin "baserom.gba", 0x50d928, 0x4 - -gUnknown_0850D92C:: @ 850D92C - .incbin "baserom.gba", 0x50d92c, 0xc - -gUnknown_0850D938:: @ 850D938 - .incbin "baserom.gba", 0x50d938, 0x4 - -gUnknown_0850D93C:: @ 850D93C - .incbin "baserom.gba", 0x50d93c, 0xc - -gUnknown_0850D948:: @ 850D948 - .incbin "baserom.gba", 0x50d948, 0xc - -gUnknown_0850D954:: @ 850D954 - .incbin "baserom.gba", 0x50d954, 0x4 - -gUnknown_0850D958:: @ 850D958 - .incbin "baserom.gba", 0x50d958, 0xc - -gUnknown_0850D964:: @ 850D964 - .incbin "baserom.gba", 0x50d964, 0x4 - -gUnknown_0850D968:: @ 850D968 - .incbin "baserom.gba", 0x50d968, 0xc - -gUnknown_0850D974:: @ 850D974 - .incbin "baserom.gba", 0x50d974, 0x4 - -gUnknown_0850D978:: @ 850D978 - .incbin "baserom.gba", 0x50d978, 0xc - -gUnknown_0850D984:: @ 850D984 - .incbin "baserom.gba", 0x50d984, 0x4 - -gUnknown_0850D988:: @ 850D988 - .incbin "baserom.gba", 0x50d988, 0xc - -gUnknown_0850D994:: @ 850D994 - .incbin "baserom.gba", 0x50d994, 0x4 - -gUnknown_0850D998:: @ 850D998 - .incbin "baserom.gba", 0x50d998, 0xc - -gUnknown_0850D9A4:: @ 850D9A4 - .incbin "baserom.gba", 0x50d9a4, 0x4 - -gUnknown_0850D9A8:: @ 850D9A8 - .incbin "baserom.gba", 0x50d9a8, 0xc - -gUnknown_0850D9B4:: @ 850D9B4 - .incbin "baserom.gba", 0x50d9b4, 0x4 - -gUnknown_0850D9B8:: @ 850D9B8 - .incbin "baserom.gba", 0x50d9b8, 0xc - -gUnknown_0850D9C4:: @ 850D9C4 - .incbin "baserom.gba", 0x50d9c4, 0x4 - -gUnknown_0850D9C8:: @ 850D9C8 - .incbin "baserom.gba", 0x50d9c8, 0xc - -gUnknown_0850D9D4:: @ 850D9D4 - .incbin "baserom.gba", 0x50d9d4, 0x4 - -gUnknown_0850D9D8:: @ 850D9D8 - .incbin "baserom.gba", 0x50d9d8, 0xc - -gUnknown_0850D9E4:: @ 850D9E4 - .incbin "baserom.gba", 0x50d9e4, 0x4 - -gUnknown_0850D9E8:: @ 850D9E8 - .incbin "baserom.gba", 0x50d9e8, 0xc - -gUnknown_0850D9F4:: @ 850D9F4 - .incbin "baserom.gba", 0x50d9f4, 0x4 - -gUnknown_0850D9F8:: @ 850D9F8 - .incbin "baserom.gba", 0x50d9f8, 0xc - -gUnknown_0850DA04:: @ 850DA04 - .incbin "baserom.gba", 0x50da04, 0x4 - -gUnknown_0850DA08:: @ 850DA08 - .incbin "baserom.gba", 0x50da08, 0xc - -gUnknown_0850DA14:: @ 850DA14 - .incbin "baserom.gba", 0x50da14, 0x4 - -gUnknown_0850DA18:: @ 850DA18 - .incbin "baserom.gba", 0x50da18, 0xc - -gUnknown_0850DA24:: @ 850DA24 - .incbin "baserom.gba", 0x50da24, 0x4 - -gUnknown_0850DA28:: @ 850DA28 - .incbin "baserom.gba", 0x50da28, 0xc - -gUnknown_0850DA34:: @ 850DA34 - .incbin "baserom.gba", 0x50da34, 0x4 - -gUnknown_0850DA38:: @ 850DA38 - .incbin "baserom.gba", 0x50da38, 0xc - -gUnknown_0850DA44:: @ 850DA44 - .incbin "baserom.gba", 0x50da44, 0x4 - -gUnknown_0850DA48:: @ 850DA48 - .incbin "baserom.gba", 0x50da48, 0xc - -gUnknown_0850DA54:: @ 850DA54 - .incbin "baserom.gba", 0x50da54, 0x4 - -gUnknown_0850DA58:: @ 850DA58 - .incbin "baserom.gba", 0x50da58, 0xc - -gUnknown_0850DA64:: @ 850DA64 - .incbin "baserom.gba", 0x50da64, 0x2c - -gUnknown_0850DA90:: @ 850DA90 - .incbin "baserom.gba", 0x50da90, 0xc - -gUnknown_0850DA9C:: @ 850DA9C - .incbin "baserom.gba", 0x50da9c, 0x4 - -gUnknown_0850DAA0:: @ 850DAA0 - .incbin "baserom.gba", 0x50daa0, 0x8 - -gUnknown_0850DAA8:: @ 850DAA8 - .incbin "baserom.gba", 0x50daa8, 0x8 - -gUnknown_0850DAB0:: @ 850DAB0 - .incbin "baserom.gba", 0x50dab0, 0x8 - -gUnknown_0850DAB8:: @ 850DAB8 - .incbin "baserom.gba", 0x50dab8, 0x8 - -gUnknown_0850DAC0:: @ 850DAC0 - .incbin "baserom.gba", 0x50dac0, 0xc - -gUnknown_0850DACC:: @ 850DACC - .incbin "baserom.gba", 0x50dacc, 0x9 - -gUnknown_0850DAD5:: @ 850DAD5 - .incbin "baserom.gba", 0x50dad5, 0x9 - -gUnknown_0850DADE:: @ 850DADE - .incbin "baserom.gba", 0x50dade, 0x9 - -gUnknown_0850DAE7:: @ 850DAE7 - .incbin "baserom.gba", 0x50dae7, 0x9 - -gUnknown_0850DAF0:: @ 850DAF0 - .incbin "baserom.gba", 0x50daf0, 0x9 - -gUnknown_0850DAF9:: @ 850DAF9 - .incbin "baserom.gba", 0x50daf9, 0x9 - -gUnknown_0850DB02:: @ 850DB02 - .incbin "baserom.gba", 0x50db02, 0x9 - -gUnknown_0850DB0B:: @ 850DB0B - .incbin "baserom.gba", 0x50db0b, 0x9 - -gUnknown_0850DB14:: @ 850DB14 - .incbin "baserom.gba", 0x50db14, 0x9 - -gUnknown_0850DB1D:: @ 850DB1D - .incbin "baserom.gba", 0x50db1d, 0x9 - -gUnknown_0850DB26:: @ 850DB26 - .incbin "baserom.gba", 0x50db26, 0x9 - -gUnknown_0850DB2F:: @ 850DB2F - .incbin "baserom.gba", 0x50db2f, 0x9 - -gUnknown_0850DB38:: @ 850DB38 - .incbin "baserom.gba", 0x50db38, 0x9 - -gUnknown_0850DB41:: @ 850DB41 - .incbin "baserom.gba", 0x50db41, 0x9 - -gUnknown_0850DB4A:: @ 850DB4A - .incbin "baserom.gba", 0x50db4a, 0x9 - -gUnknown_0850DB53:: @ 850DB53 - .incbin "baserom.gba", 0x50db53, 0x9 - -gUnknown_0850DB5C:: @ 850DB5C - .incbin "baserom.gba", 0x50db5c, 0x10 - -gUnknown_0850DB6C:: @ 850DB6C - .incbin "baserom.gba", 0x50db6c, 0x10 - -gUnknown_0850DB7C:: @ 850DB7C - .incbin "baserom.gba", 0x50db7c, 0x24 - -gUnknown_0850DBA0:: @ 850DBA0 - .incbin "baserom.gba", 0x50dba0, 0x5 - -gUnknown_0850DBA5:: @ 850DBA5 - .incbin "baserom.gba", 0x50dba5, 0x5 - -gUnknown_0850DBAA:: @ 850DBAA - .incbin "baserom.gba", 0x50dbaa, 0x5 - -gUnknown_0850DBAF:: @ 850DBAF - .incbin "baserom.gba", 0x50dbaf, 0x5 - -gUnknown_0850DBB4:: @ 850DBB4 - .incbin "baserom.gba", 0x50dbb4, 0x5 - -gUnknown_0850DBB9:: @ 850DBB9 - .incbin "baserom.gba", 0x50dbb9, 0x5 - -gUnknown_0850DBBE:: @ 850DBBE - .incbin "baserom.gba", 0x50dbbe, 0x5 - -gUnknown_0850DBC3:: @ 850DBC3 - .incbin "baserom.gba", 0x50dbc3, 0x5 - -gUnknown_0850DBC8:: @ 850DBC8 - .incbin "baserom.gba", 0x50dbc8, 0x5 - -gUnknown_0850DBCD:: @ 850DBCD - .incbin "baserom.gba", 0x50dbcd, 0x5 - -gUnknown_0850DBD2:: @ 850DBD2 - .incbin "baserom.gba", 0x50dbd2, 0x5 - -gUnknown_0850DBD7:: @ 850DBD7 - .incbin "baserom.gba", 0x50dbd7, 0x5 - -gUnknown_0850DBDC:: @ 850DBDC - .incbin "baserom.gba", 0x50dbdc, 0x5 - -gUnknown_0850DBE1:: @ 850DBE1 - .incbin "baserom.gba", 0x50dbe1, 0x5 - -gUnknown_0850DBE6:: @ 850DBE6 - .incbin "baserom.gba", 0x50dbe6, 0x5 - -gUnknown_0850DBEB:: @ 850DBEB - .incbin "baserom.gba", 0x50dbeb, 0x5 - -gUnknown_0850DBF0:: @ 850DBF0 - .incbin "baserom.gba", 0x50dbf0, 0x5 - -gUnknown_0850DBF5:: @ 850DBF5 - .incbin "baserom.gba", 0x50dbf5, 0x5 - -gUnknown_0850DBFA:: @ 850DBFA - .incbin "baserom.gba", 0x50dbfa, 0x5 - -gUnknown_0850DBFF:: @ 850DBFF - .incbin "baserom.gba", 0x50dbff, 0x5 - -gUnknown_0850DC04:: @ 850DC04 - .incbin "baserom.gba", 0x50dc04, 0x5 - -gUnknown_0850DC09:: @ 850DC09 - .incbin "baserom.gba", 0x50dc09, 0x5 - -gUnknown_0850DC0E:: @ 850DC0E - .incbin "baserom.gba", 0x50dc0e, 0x5 - -gUnknown_0850DC13:: @ 850DC13 - .incbin "baserom.gba", 0x50dc13, 0x5 - -gUnknown_0850DC18:: @ 850DC18 - .incbin "baserom.gba", 0x50dc18, 0x5 - -gUnknown_0850DC1D:: @ 850DC1D - .incbin "baserom.gba", 0x50dc1d, 0x5 - -gUnknown_0850DC22:: @ 850DC22 - .incbin "baserom.gba", 0x50dc22, 0x5 - -gUnknown_0850DC27:: @ 850DC27 - .incbin "baserom.gba", 0x50dc27, 0x8 - -gUnknown_0850DC2F:: @ 850DC2F - .incbin "baserom.gba", 0x50dc2f, 0x10 - -gUnknown_0850DC3F:: @ 850DC3F - .incbin "baserom.gba", 0x50dc3f, 0x11 - -gUnknown_0850DC50:: @ 850DC50 - .incbin "baserom.gba", 0x50dc50, 0x298 - -gUnknown_0850DEE8:: @ 850DEE8 - .incbin "baserom.gba", 0x50dee8, 0xd4 - -gUnknown_0850DFBC:: @ 850DFBC - .incbin "baserom.gba", 0x50dfbc, 0x6 - -gUnknown_0850DFC2:: @ 850DFC2 - .incbin "baserom.gba", 0x50dfc2, 0x61a - // end data/field_map_obj.s + .section .rodata_b + + .incbin "baserom.gba", 0x50dfc8, 0x614 gUnknown_0850E5DC:: @ 850E5DC .incbin "baserom.gba", 0x50e5dc, 0x8 diff --git a/data/field_map_obj.s b/data/field_map_obj.s new file mode 100644 index 000000000..2030ec578 --- /dev/null +++ b/data/field_map_obj.s @@ -0,0 +1,499 @@ + .include "asm/macros.inc" + .include "constants/constants.inc" + + .section .rodata + +gUnknown_084975C4:: @ 84975C4 + .incbin "baserom.gba", 0x4975c4, 0x10 + +gUnknown_084975D4:: @ 84975D4 + .incbin "baserom.gba", 0x4975d4, 0x18 + +gUnknown_084975EC:: @ 84975EC + .incbin "baserom.gba", 0x4975ec, 0xc + +@ 84975F8 + .include "data/graphics/field_objects/field_object_graphics.inc" + +gUnknown_08505438:: @ 8505438 + .incbin "baserom.gba", 0x505438, 0x144 + +gUnknown_0850557C:: @ 850557C + .incbin "baserom.gba", 0x50557c, 0x51 + +gUnknown_085055CD:: @ 85055CD + .incbin "baserom.gba", 0x5055cd, 0x51 + + .align 2, 0 +@ 8505620 + .include "data/graphics/field_objects/field_object_graphics_info_pointers.inc" + +@ 85059F8 + .include "data/graphics/field_objects/field_effect_object_template_pointers.inc" + +@ 8505A8C + .include "data/graphics/field_objects/field_object_pic_tables.inc" + +@ 85089FC + .include "data/graphics/field_objects/field_object_anims.inc" + +gUnknown_085094AC:: @ 85094AC + .incbin "baserom.gba", 0x5094ac, 0x40 + +@ 85094EC + .include "data/graphics/field_objects/field_object_oam.inc" + +@ 8509954 + .include "data/graphics/field_objects/field_object_graphics_info.inc" + +gUnknown_0850BBC8:: @ 850BBC8 + .incbin "baserom.gba", 0x50bbc8, 0x138 + +gUnknown_0850BD00:: @ 850BD00 + .incbin "baserom.gba", 0x50bd00, 0x78 + +gUnknown_0850BD78:: @ 850BD78 + .incbin "baserom.gba", 0x50bd78, 0xc0 + +gUnknown_0850BE38:: @ 850BE38 + .incbin "baserom.gba", 0x50be38, 0x10 + +@ 850BE48 + .include "data/graphics/field_objects/berry_tree_graphics_tables.inc" + +@ 850C9C0 + .include "data/graphics/field_objects/field_effect_objects.inc" + + .incbin "baserom.gba", 0x50d6d4, 0x8 + +gUnknown_0850D6DC:: @ 850D6DC + .incbin "baserom.gba", 0x50d6dc, 0x10 + +gUnknown_0850D6EC:: @ 850D6EC + .incbin "baserom.gba", 0x50d6ec, 0x8 + +gUnknown_0850D6F4:: @ 850D6F4 + .incbin "baserom.gba", 0x50d6f4, 0x1c + +gUnknown_0850D710:: @ 850D710 + .incbin "baserom.gba", 0x50d710, 0x4 + +gUnknown_0850D714:: @ 850D714 + .incbin "baserom.gba", 0x50d714, 0x2c + +gUnknown_0850D740:: @ 850D740 + .incbin "baserom.gba", 0x50d740, 0x14 + +gUnknown_0850D754:: @ 850D754 + .incbin "baserom.gba", 0x50d754, 0x1c + +gUnknown_0850D770:: @ 850D770 + .incbin "baserom.gba", 0x50d770, 0x4 + +gUnknown_0850D774:: @ 850D774 + .incbin "baserom.gba", 0x50d774, 0x1c + +gUnknown_0850D790:: @ 850D790 + .incbin "baserom.gba", 0x50d790, 0x4 + +gUnknown_0850D794:: @ 850D794 + .incbin "baserom.gba", 0x50d794, 0xc + +gUnknown_0850D7A0:: @ 850D7A0 + .incbin "baserom.gba", 0x50d7a0, 0x14 + +gUnknown_0850D7B4:: @ 850D7B4 + .incbin "baserom.gba", 0x50d7b4, 0x14 + +gUnknown_0850D7C8:: @ 850D7C8 + .incbin "baserom.gba", 0x50d7c8, 0x14 + +gUnknown_0850D7DC:: @ 850D7DC + .incbin "baserom.gba", 0x50d7dc, 0x14 + +gUnknown_0850D7F0:: @ 850D7F0 + .incbin "baserom.gba", 0x50d7f0, 0x4 + +gUnknown_0850D7F4:: @ 850D7F4 + .incbin "baserom.gba", 0x50d7f4, 0x14 + +gUnknown_0850D808:: @ 850D808 + .incbin "baserom.gba", 0x50d808, 0x4 + +gUnknown_0850D80C:: @ 850D80C + .incbin "baserom.gba", 0x50d80c, 0x14 + +gUnknown_0850D820:: @ 850D820 + .incbin "baserom.gba", 0x50d820, 0x4 + +gUnknown_0850D824:: @ 850D824 + .incbin "baserom.gba", 0x50d824, 0x14 + +gUnknown_0850D838:: @ 850D838 + .incbin "baserom.gba", 0x50d838, 0x4 + +gUnknown_0850D83C:: @ 850D83C + .incbin "baserom.gba", 0x50d83c, 0x14 + +gUnknown_0850D850:: @ 850D850 + .incbin "baserom.gba", 0x50d850, 0x4 + +gUnknown_0850D854:: @ 850D854 + .incbin "baserom.gba", 0x50d854, 0x14 + +gUnknown_0850D868:: @ 850D868 + .incbin "baserom.gba", 0x50d868, 0x4 + +gUnknown_0850D86C:: @ 850D86C + .incbin "baserom.gba", 0x50d86c, 0x14 + +gUnknown_0850D880:: @ 850D880 + .incbin "baserom.gba", 0x50d880, 0x4 + +gUnknown_0850D884:: @ 850D884 + .incbin "baserom.gba", 0x50d884, 0x14 + +gUnknown_0850D898:: @ 850D898 + .incbin "baserom.gba", 0x50d898, 0x4 + +gUnknown_0850D89C:: @ 850D89C + .incbin "baserom.gba", 0x50d89c, 0x10 + +gUnknown_0850D8AC:: @ 850D8AC + .incbin "baserom.gba", 0x50d8ac, 0x8 + +gUnknown_0850D8B4:: @ 850D8B4 + .incbin "baserom.gba", 0x50d8b4, 0x10 + +gUnknown_0850D8C4:: @ 850D8C4 + .incbin "baserom.gba", 0x50d8c4, 0x8 + +gUnknown_0850D8CC:: @ 850D8CC + .incbin "baserom.gba", 0x50d8cc, 0x10 + +gUnknown_0850D8DC:: @ 850D8DC + .incbin "baserom.gba", 0x50d8dc, 0xc + +gUnknown_0850D8E8:: @ 850D8E8 + .incbin "baserom.gba", 0x50d8e8, 0x4 + +gUnknown_0850D8EC:: @ 850D8EC + .incbin "baserom.gba", 0x50d8ec, 0xc + +gUnknown_0850D8F8:: @ 850D8F8 + .incbin "baserom.gba", 0x50d8f8, 0x4 + +gUnknown_0850D8FC:: @ 850D8FC + .incbin "baserom.gba", 0x50d8fc, 0xc + +gUnknown_0850D908:: @ 850D908 + .incbin "baserom.gba", 0x50d908, 0x4 + +gUnknown_0850D90C:: @ 850D90C + .incbin "baserom.gba", 0x50d90c, 0xc + +gUnknown_0850D918:: @ 850D918 + .incbin "baserom.gba", 0x50d918, 0x4 + +gUnknown_0850D91C:: @ 850D91C + .incbin "baserom.gba", 0x50d91c, 0xc + +gUnknown_0850D928:: @ 850D928 + .incbin "baserom.gba", 0x50d928, 0x4 + +gUnknown_0850D92C:: @ 850D92C + .incbin "baserom.gba", 0x50d92c, 0xc + +gUnknown_0850D938:: @ 850D938 + .incbin "baserom.gba", 0x50d938, 0x4 + +gUnknown_0850D93C:: @ 850D93C + .incbin "baserom.gba", 0x50d93c, 0xc + +gUnknown_0850D948:: @ 850D948 + .incbin "baserom.gba", 0x50d948, 0xc + +gUnknown_0850D954:: @ 850D954 + .incbin "baserom.gba", 0x50d954, 0x4 + +gUnknown_0850D958:: @ 850D958 + .incbin "baserom.gba", 0x50d958, 0xc + +gUnknown_0850D964:: @ 850D964 + .incbin "baserom.gba", 0x50d964, 0x4 + +gUnknown_0850D968:: @ 850D968 + .incbin "baserom.gba", 0x50d968, 0xc + +gUnknown_0850D974:: @ 850D974 + .incbin "baserom.gba", 0x50d974, 0x4 + +gUnknown_0850D978:: @ 850D978 + .incbin "baserom.gba", 0x50d978, 0xc + +gUnknown_0850D984:: @ 850D984 + .incbin "baserom.gba", 0x50d984, 0x4 + +gUnknown_0850D988:: @ 850D988 + .incbin "baserom.gba", 0x50d988, 0xc + +gUnknown_0850D994:: @ 850D994 + .incbin "baserom.gba", 0x50d994, 0x4 + +gUnknown_0850D998:: @ 850D998 + .incbin "baserom.gba", 0x50d998, 0xc + +gUnknown_0850D9A4:: @ 850D9A4 + .incbin "baserom.gba", 0x50d9a4, 0x4 + +gUnknown_0850D9A8:: @ 850D9A8 + .incbin "baserom.gba", 0x50d9a8, 0xc + +gUnknown_0850D9B4:: @ 850D9B4 + .incbin "baserom.gba", 0x50d9b4, 0x4 + +gUnknown_0850D9B8:: @ 850D9B8 + .incbin "baserom.gba", 0x50d9b8, 0xc + +gUnknown_0850D9C4:: @ 850D9C4 + .incbin "baserom.gba", 0x50d9c4, 0x4 + +gUnknown_0850D9C8:: @ 850D9C8 + .incbin "baserom.gba", 0x50d9c8, 0xc + +gUnknown_0850D9D4:: @ 850D9D4 + .incbin "baserom.gba", 0x50d9d4, 0x4 + +gUnknown_0850D9D8:: @ 850D9D8 + .incbin "baserom.gba", 0x50d9d8, 0xc + +gUnknown_0850D9E4:: @ 850D9E4 + .incbin "baserom.gba", 0x50d9e4, 0x4 + +gUnknown_0850D9E8:: @ 850D9E8 + .incbin "baserom.gba", 0x50d9e8, 0xc + +gUnknown_0850D9F4:: @ 850D9F4 + .incbin "baserom.gba", 0x50d9f4, 0x4 + +gUnknown_0850D9F8:: @ 850D9F8 + .incbin "baserom.gba", 0x50d9f8, 0xc + +gUnknown_0850DA04:: @ 850DA04 + .incbin "baserom.gba", 0x50da04, 0x4 + +gUnknown_0850DA08:: @ 850DA08 + .incbin "baserom.gba", 0x50da08, 0xc + +gUnknown_0850DA14:: @ 850DA14 + .incbin "baserom.gba", 0x50da14, 0x4 + +gUnknown_0850DA18:: @ 850DA18 + .incbin "baserom.gba", 0x50da18, 0xc + +gUnknown_0850DA24:: @ 850DA24 + .incbin "baserom.gba", 0x50da24, 0x4 + +gUnknown_0850DA28:: @ 850DA28 + .incbin "baserom.gba", 0x50da28, 0xc + +gUnknown_0850DA34:: @ 850DA34 + .incbin "baserom.gba", 0x50da34, 0x4 + +gUnknown_0850DA38:: @ 850DA38 + .incbin "baserom.gba", 0x50da38, 0xc + +gUnknown_0850DA44:: @ 850DA44 + .incbin "baserom.gba", 0x50da44, 0x4 + +gUnknown_0850DA48:: @ 850DA48 + .incbin "baserom.gba", 0x50da48, 0xc + +gUnknown_0850DA54:: @ 850DA54 + .incbin "baserom.gba", 0x50da54, 0x4 + +gUnknown_0850DA58:: @ 850DA58 + .incbin "baserom.gba", 0x50da58, 0xc + +gUnknown_0850DA64:: @ 850DA64 + .incbin "baserom.gba", 0x50da64, 0x2c + +gUnknown_0850DA90:: @ 850DA90 + .incbin "baserom.gba", 0x50da90, 0xc + +gUnknown_0850DA9C:: @ 850DA9C + .incbin "baserom.gba", 0x50da9c, 0x4 + +gUnknown_0850DAA0:: @ 850DAA0 + .incbin "baserom.gba", 0x50daa0, 0x8 + +gUnknown_0850DAA8:: @ 850DAA8 + .incbin "baserom.gba", 0x50daa8, 0x8 + +gUnknown_0850DAB0:: @ 850DAB0 + .incbin "baserom.gba", 0x50dab0, 0x8 + +gUnknown_0850DAB8:: @ 850DAB8 + .incbin "baserom.gba", 0x50dab8, 0x8 + +gUnknown_0850DAC0:: @ 850DAC0 + .incbin "baserom.gba", 0x50dac0, 0xc + +gUnknown_0850DACC:: @ 850DACC + .incbin "baserom.gba", 0x50dacc, 0x9 + +gUnknown_0850DAD5:: @ 850DAD5 + .incbin "baserom.gba", 0x50dad5, 0x9 + +gUnknown_0850DADE:: @ 850DADE + .incbin "baserom.gba", 0x50dade, 0x9 + +gUnknown_0850DAE7:: @ 850DAE7 + .incbin "baserom.gba", 0x50dae7, 0x9 + +gUnknown_0850DAF0:: @ 850DAF0 + .incbin "baserom.gba", 0x50daf0, 0x9 + +gUnknown_0850DAF9:: @ 850DAF9 + .incbin "baserom.gba", 0x50daf9, 0x9 + +gUnknown_0850DB02:: @ 850DB02 + .incbin "baserom.gba", 0x50db02, 0x9 + +gUnknown_0850DB0B:: @ 850DB0B + .incbin "baserom.gba", 0x50db0b, 0x9 + +gUnknown_0850DB14:: @ 850DB14 + .incbin "baserom.gba", 0x50db14, 0x9 + +gUnknown_0850DB1D:: @ 850DB1D + .incbin "baserom.gba", 0x50db1d, 0x9 + +gUnknown_0850DB26:: @ 850DB26 + .incbin "baserom.gba", 0x50db26, 0x9 + +gUnknown_0850DB2F:: @ 850DB2F + .incbin "baserom.gba", 0x50db2f, 0x9 + +gUnknown_0850DB38:: @ 850DB38 + .incbin "baserom.gba", 0x50db38, 0x9 + +gUnknown_0850DB41:: @ 850DB41 + .incbin "baserom.gba", 0x50db41, 0x9 + +gUnknown_0850DB4A:: @ 850DB4A + .incbin "baserom.gba", 0x50db4a, 0x9 + +gUnknown_0850DB53:: @ 850DB53 + .incbin "baserom.gba", 0x50db53, 0x9 + +gUnknown_0850DB5C:: @ 850DB5C + .incbin "baserom.gba", 0x50db5c, 0x10 + +gUnknown_0850DB6C:: @ 850DB6C + .incbin "baserom.gba", 0x50db6c, 0x10 + +gUnknown_0850DB7C:: @ 850DB7C + .incbin "baserom.gba", 0x50db7c, 0x24 + +gUnknown_0850DBA0:: @ 850DBA0 + .incbin "baserom.gba", 0x50dba0, 0x5 + +gUnknown_0850DBA5:: @ 850DBA5 + .incbin "baserom.gba", 0x50dba5, 0x5 + +gUnknown_0850DBAA:: @ 850DBAA + .incbin "baserom.gba", 0x50dbaa, 0x5 + +gUnknown_0850DBAF:: @ 850DBAF + .incbin "baserom.gba", 0x50dbaf, 0x5 + +gUnknown_0850DBB4:: @ 850DBB4 + .incbin "baserom.gba", 0x50dbb4, 0x5 + +gUnknown_0850DBB9:: @ 850DBB9 + .incbin "baserom.gba", 0x50dbb9, 0x5 + +gUnknown_0850DBBE:: @ 850DBBE + .incbin "baserom.gba", 0x50dbbe, 0x5 + +gUnknown_0850DBC3:: @ 850DBC3 + .incbin "baserom.gba", 0x50dbc3, 0x5 + +gUnknown_0850DBC8:: @ 850DBC8 + .incbin "baserom.gba", 0x50dbc8, 0x5 + +gUnknown_0850DBCD:: @ 850DBCD + .incbin "baserom.gba", 0x50dbcd, 0x5 + +gUnknown_0850DBD2:: @ 850DBD2 + .incbin "baserom.gba", 0x50dbd2, 0x5 + +gUnknown_0850DBD7:: @ 850DBD7 + .incbin "baserom.gba", 0x50dbd7, 0x5 + +gUnknown_0850DBDC:: @ 850DBDC + .incbin "baserom.gba", 0x50dbdc, 0x5 + +gUnknown_0850DBE1:: @ 850DBE1 + .incbin "baserom.gba", 0x50dbe1, 0x5 + +gUnknown_0850DBE6:: @ 850DBE6 + .incbin "baserom.gba", 0x50dbe6, 0x5 + +gUnknown_0850DBEB:: @ 850DBEB + .incbin "baserom.gba", 0x50dbeb, 0x5 + +gUnknown_0850DBF0:: @ 850DBF0 + .incbin "baserom.gba", 0x50dbf0, 0x5 + +gUnknown_0850DBF5:: @ 850DBF5 + .incbin "baserom.gba", 0x50dbf5, 0x5 + +gUnknown_0850DBFA:: @ 850DBFA + .incbin "baserom.gba", 0x50dbfa, 0x5 + +gUnknown_0850DBFF:: @ 850DBFF + .incbin "baserom.gba", 0x50dbff, 0x5 + +gUnknown_0850DC04:: @ 850DC04 + .incbin "baserom.gba", 0x50dc04, 0x5 + +gUnknown_0850DC09:: @ 850DC09 + .incbin "baserom.gba", 0x50dc09, 0x5 + +gUnknown_0850DC0E:: @ 850DC0E + .incbin "baserom.gba", 0x50dc0e, 0x5 + +gUnknown_0850DC13:: @ 850DC13 + .incbin "baserom.gba", 0x50dc13, 0x5 + +gUnknown_0850DC18:: @ 850DC18 + .incbin "baserom.gba", 0x50dc18, 0x5 + +gUnknown_0850DC1D:: @ 850DC1D + .incbin "baserom.gba", 0x50dc1d, 0x5 + +gUnknown_0850DC22:: @ 850DC22 + .incbin "baserom.gba", 0x50dc22, 0x5 + +gUnknown_0850DC27:: @ 850DC27 + .incbin "baserom.gba", 0x50dc27, 0x8 + +gUnknown_0850DC2F:: @ 850DC2F + .incbin "baserom.gba", 0x50dc2f, 0x10 + +gUnknown_0850DC3F:: @ 850DC3F + .incbin "baserom.gba", 0x50dc3f, 0x11 + +gUnknown_0850DC50:: @ 850DC50 + .incbin "baserom.gba", 0x50dc50, 0x298 + +gUnknown_0850DEE8:: @ 850DEE8 + .incbin "baserom.gba", 0x50dee8, 0xd4 + +gUnknown_0850DFBC:: @ 850DFBC + .incbin "baserom.gba", 0x50dfbc, 0x6 + +gUnknown_0850DFC2:: @ 850DFC2 + .incbin "baserom.gba", 0x50dfc2, 0x6 diff --git a/ld_script.txt b/ld_script.txt index 81e4fc3ab..b050d3c51 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -340,6 +340,8 @@ SECTIONS { src/trig.o(.rodata); src/util.o(.rodata); data/data3.o(.rodata); + data/field_map_obj.o(.rodata); + data/data3.o(.rodata_b); src/berry.o(.rodata); data/data3_a1.o(.rodata); src/pokemon_size_record.o(.rodata) From b92b690d2ac893c058b9f2192855833aaf220ad4 Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 17 Sep 2017 17:40:38 -0400 Subject: [PATCH 183/191] never mind, this actually is in field_map_obj.s --- data/data3.s | 3 --- data/field_map_obj.s | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/data/data3.s b/data/data3.s index 70b057884..ec29349bd 100644 --- a/data/data3.s +++ b/data/data3.s @@ -634,11 +634,8 @@ gUnknown_084975BC:: @ 84975BC // data/field_map_obj.s -// end data/field_map_obj.s .section .rodata_b - .incbin "baserom.gba", 0x50dfc8, 0x614 - gUnknown_0850E5DC:: @ 850E5DC .incbin "baserom.gba", 0x50e5dc, 0x8 diff --git a/data/field_map_obj.s b/data/field_map_obj.s index 2030ec578..6a9682574 100644 --- a/data/field_map_obj.s +++ b/data/field_map_obj.s @@ -497,3 +497,6 @@ gUnknown_0850DFBC:: @ 850DFBC gUnknown_0850DFC2:: @ 850DFC2 .incbin "baserom.gba", 0x50dfc2, 0x6 + +gUnknown_0850DFC8:: @ 850DFC8 + .incbin "baserom.gba", 0x50dfc8, 0x614 From 130ba76533e6b87696b8e960eb8a09cb951417ad Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 17 Sep 2017 17:50:07 -0400 Subject: [PATCH 184/191] remove data3.h --- include/data3.h | 50 --------------------------------------------- src/field_map_obj.c | 41 ++++++++++++++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 51 deletions(-) delete mode 100755 include/data3.h diff --git a/include/data3.h b/include/data3.h deleted file mode 100755 index 8151e418c..000000000 --- a/include/data3.h +++ /dev/null @@ -1,50 +0,0 @@ -// -// Created by Scott Norton on 9/8/17. -// - -#ifndef GUARD_DATA3_H -#define GUARD_DATA3_H - -struct PairedPalettes { - u16 tag; - const u16 *data; -}; - -extern u8 gUnknown_084975C4[0x10]; -extern const struct SpriteTemplate gUnknown_084975D4; -extern void (*const gUnknown_084975EC[3])(struct Sprite *); -extern const struct SpritePalette gUnknown_0850BBC8[]; -extern const struct PairedPalettes gUnknown_0850BD00[15]; -extern const struct PairedPalettes gUnknown_0850BD78[15]; -extern const u16 *const gUnknown_0850BE38[2]; -extern const s16 gUnknown_0850D6DC[4]; // {0x20, 0x40, 0x60, 0x80} -extern const s16 gUnknown_0850D6EC[4]; -extern const u8 gUnknown_0850D710[4]; // {DIR_SOUTH, DIR_NORTH, DIR_WEST, DIR_EAST} -extern const u8 gUnknown_0850D770[2]; // {DIR_SOUTH, DIR_NORTH} -extern const u8 gUnknown_0850D790[2]; // {DIR_WEST, DIR_EAST} -extern const u8 gUnknown_0850D7F0[2]; // {DIR_NORTH, DIR_WEST} -extern const u8 gUnknown_0850D808[2]; // {DIR_NORTH, DIR_EAST} -extern const u8 gUnknown_0850D820[2]; // {DIR_SOUTH, DIR_WEST} -extern const u8 gUnknown_0850D838[2]; // {DIR_SOUTH, DIR_EAST} -extern const u8 gUnknown_0850D850[4]; -extern const u8 gUnknown_0850D868[4]; -extern const u8 gUnknown_0850D880[4]; -extern const u8 gUnknown_0850D898[4]; -extern const u8 gUnknown_0850D8AC[5]; -extern const u8 gUnknown_0850D8C4[5]; -extern const u8 gUnknown_0850D8E8[4]; -extern bool8 (*const gUnknown_0850DA64[])(struct MapObject *, struct Sprite *, u8, bool8(u8)); -extern bool8 (*const gUnknown_0850DB5C[])(u8); -extern bool8 (*const gUnknown_0850DB6C[])(u8); -extern const struct Coords16 gUnknown_0850DB7C[4]; -extern const u8 gUnknown_0850DC2F[4][4]; -extern const u8 gUnknown_0850DC3F[4][4]; - -extern const u8 gUnknown_0850DBA0[5]; - -extern bool8 (*const *const gUnknown_0850DC50[])(struct MapObject *, struct Sprite *); -extern u8 (*const gUnknown_0850DEE8[5])(u8); -extern const s16 gUnknown_0850DFBC[3]; -extern const s16 gUnknown_0850DFC2[3]; - -#endif //GUARD_DATA3_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index a79f78434..1ffa0a594 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -5,7 +5,6 @@ #include "sprite.h" #include "rom4.h" #include "rng.h" -#include "data3.h" #include "event_scripts.h" #include "berry.h" #include "palette.h" @@ -134,6 +133,46 @@ const struct MapObjectGraphicsInfo *const gMauvilleOldManGraphicsInfoPointers[7] const struct MapObjectGraphicsInfo *const gFieldObjectGraphicsInfoPointers[0xEF]; u8 (*const gUnknown_0850D714[11])(s16, s16, s16, s16); +struct PairedPalettes { + u16 tag; + const u16 *data; +}; + +u8 gUnknown_084975C4[0x10]; +const struct SpriteTemplate gUnknown_084975D4; +void (*const gUnknown_084975EC[3])(struct Sprite *); +const struct SpritePalette gUnknown_0850BBC8[39]; +const struct PairedPalettes gUnknown_0850BD00[15]; +const struct PairedPalettes gUnknown_0850BD78[15]; +const u16 *const gUnknown_0850BE38[2]; +const s16 gUnknown_0850D6DC[4]; // {0x20, 0x40, 0x60, 0x80} +const s16 gUnknown_0850D6EC[4]; +const u8 gUnknown_0850D710[4]; // {DIR_SOUTH, DIR_NORTH, DIR_WEST, DIR_EAST} +const u8 gUnknown_0850D770[2]; // {DIR_SOUTH, DIR_NORTH} +const u8 gUnknown_0850D790[2]; // {DIR_WEST, DIR_EAST} +const u8 gUnknown_0850D7F0[2]; // {DIR_NORTH, DIR_WEST} +const u8 gUnknown_0850D808[2]; // {DIR_NORTH, DIR_EAST} +const u8 gUnknown_0850D820[2]; // {DIR_SOUTH, DIR_WEST} +const u8 gUnknown_0850D838[2]; // {DIR_SOUTH, DIR_EAST} +const u8 gUnknown_0850D850[4]; +const u8 gUnknown_0850D868[4]; +const u8 gUnknown_0850D880[4]; +const u8 gUnknown_0850D898[4]; +const u8 gUnknown_0850D8AC[5]; +const u8 gUnknown_0850D8C4[5]; +const u8 gUnknown_0850D8E8[4]; +bool8 (*const gUnknown_0850DA64[11])(struct MapObject *, struct Sprite *, u8, bool8(u8)); +bool8 (*const gUnknown_0850DB5C[4])(u8); +bool8 (*const gUnknown_0850DB6C[4])(u8); +const struct Coords16 gUnknown_0850DB7C[4]; +const u8 gUnknown_0850DC2F[4][4]; +const u8 gUnknown_0850DC3F[4][4]; +const u8 gUnknown_0850DBA0[5]; +bool8 (*const *const gUnknown_0850DC50[166])(struct MapObject *, struct Sprite *); +u8 (*const gUnknown_0850DEE8[5])(u8); +const s16 gUnknown_0850DFBC[3]; +const s16 gUnknown_0850DFC2[3]; + // Code static void npc_clear_ids_and_state(struct MapObject *mapObject) From d8dd96fa07e7e40e8f599659deb03ec14081548a Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 17 Sep 2017 18:36:38 -0400 Subject: [PATCH 185/191] Start dumping data --- data/field_map_obj.s | 108 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 101 insertions(+), 7 deletions(-) diff --git a/data/field_map_obj.s b/data/field_map_obj.s index 6a9682574..7b1b1f1d6 100644 --- a/data/field_map_obj.s +++ b/data/field_map_obj.s @@ -4,25 +4,118 @@ .section .rodata gUnknown_084975C4:: @ 84975C4 - .incbin "baserom.gba", 0x4975c4, 0x10 +@ replacing .incbin "baserom.gba", 0x004975c4, 0x10 +.byte 0x01, 0x01, 0x06, 0x07, 0x08, 0x09, 0x06, 0x07, 0x08, 0x09, 0x0b, 0x0b, 0x00, 0x00, 0x00, 0x00 gUnknown_084975D4:: @ 84975D4 - .incbin "baserom.gba", 0x4975d4, 0x18 +@ replacing .incbin "baserom.gba", 0x004975d4, 0x18 + .2byte 0, 65535 + .4byte gDummyOamData, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, ObjectCB_CameraObject gUnknown_084975EC:: @ 84975EC - .incbin "baserom.gba", 0x4975ec, 0xc +@ replacing .incbin "baserom.gba", 0x004975ec, 0xc +.4byte CameraObject_0 +.4byte CameraObject_1 +.4byte CameraObject_2 @ 84975F8 .include "data/graphics/field_objects/field_object_graphics.inc" gUnknown_08505438:: @ 8505438 - .incbin "baserom.gba", 0x505438, 0x144 +@ replacing .incbin "baserom.gba", 0x00505438, 0x144 +.4byte FieldObjectCB_NoMovement1 +.4byte FieldObjectCB_LookRandomDirections +.4byte FieldObjectCB_GoRandomDirections +.4byte FieldObjectCB_RandomlyGoNorthOrSouth +.4byte FieldObjectCB_RandomlyGoNorthOrSouth +.4byte FieldObjectCB_RandomlyGoEastOrWest +.4byte FieldObjectCB_RandomlyGoEastOrWest +.4byte FieldObjectCB_FaceFixedDirection +.4byte FieldObjectCB_FaceFixedDirection +.4byte FieldObjectCB_FaceFixedDirection +.4byte FieldObjectCB_FaceFixedDirection +.4byte FieldObjectCB_NoMovement2 +.4byte FieldObjectCB_BerryTree +.4byte FieldObjectCB_RandomlyLookNorthOrSouth +.4byte FieldObjectCB_RandomlyLookEastOrWest +.4byte FieldObjectCB_RandomlyLookNorthOrWest +.4byte FieldObjectCB_RandomlyLookNorthOrEast +.4byte FieldObjectCB_RandomlyLookSouthOrWest +.4byte FieldObjectCB_RandomlyLookSouthOrEast +.4byte FieldObjectCB_RandomlyLookNorthOrSouthOrWest +.4byte FieldObjectCB_RandomlyLookNorthOrSouthOrEast +.4byte FieldObjectCB_RandomlyLookNorthOrEastOrWest +.4byte FieldObjectCB_RandomlyLookSouthOrEastOrWest +.4byte FieldObjectCB_LookAroundCounterclockwise +.4byte FieldObjectCB_LookAroundClockwise +.4byte FieldObjectCB_AlternatelyGoInOppositeDirections +.4byte FieldObjectCB_AlternatelyGoInOppositeDirections +.4byte FieldObjectCB_AlternatelyGoInOppositeDirections +.4byte FieldObjectCB_AlternatelyGoInOppositeDirections +.4byte FieldObjectCB_GoInDirectionSequence1 +.4byte FieldObjectCB_GoInDirectionSequence2 +.4byte FieldObjectCB_GoInDirectionSequence3 +.4byte FieldObjectCB_GoInDirectionSequence4 +.4byte FieldObjectCB_GoInDirectionSequence5 +.4byte FieldObjectCB_GoInDirectionSequence6 +.4byte FieldObjectCB_GoInDirectionSequence7 +.4byte FieldObjectCB_GoInDirectionSequence8 +.4byte FieldObjectCB_GoInDirectionSequence9 +.4byte FieldObjectCB_GoInDirectionSequence10 +.4byte FieldObjectCB_GoInDirectionSequence11 +.4byte FieldObjectCB_GoInDirectionSequence12 +.4byte FieldObjectCB_GoInDirectionSequence13 +.4byte FieldObjectCB_GoInDirectionSequence14 +.4byte FieldObjectCB_GoInDirectionSequence15 +.4byte FieldObjectCB_GoInDirectionSequence16 +.4byte FieldObjectCB_GoInDirectionSequence17 +.4byte FieldObjectCB_GoInDirectionSequence18 +.4byte FieldObjectCB_GoInDirectionSequence19 +.4byte FieldObjectCB_GoInDirectionSequence20 +.4byte FieldObjectCB_GoInDirectionSequence21 +.4byte FieldObjectCB_GoInDirectionSequence22 +.4byte FieldObjectCB_GoInDirectionSequence23 +.4byte FieldObjectCB_GoInDirectionSequence24 +.4byte FieldObjectCB_CopyPlayer1 +.4byte FieldObjectCB_CopyPlayer1 +.4byte FieldObjectCB_CopyPlayer1 +.4byte FieldObjectCB_CopyPlayer1 +.4byte FieldObjectCB_TreeDisguise +.4byte FieldObjectCB_MountainDisguise +.4byte FieldObjectCB_CopyPlayer2 +.4byte FieldObjectCB_CopyPlayer2 +.4byte FieldObjectCB_CopyPlayer2 +.4byte FieldObjectCB_CopyPlayer2 +.4byte FieldObjectCB_Hidden1 +.4byte FieldObjectCB_WalkInPlace1 +.4byte FieldObjectCB_WalkInPlace1 +.4byte FieldObjectCB_WalkInPlace1 +.4byte FieldObjectCB_WalkInPlace1 +.4byte FieldObjectCB_WalkInPlace2 +.4byte FieldObjectCB_WalkInPlace2 +.4byte FieldObjectCB_WalkInPlace2 +.4byte FieldObjectCB_WalkInPlace2 +.4byte FieldObjectCB_WalkInPlace3 +.4byte FieldObjectCB_WalkInPlace3 +.4byte FieldObjectCB_WalkInPlace3 +.4byte FieldObjectCB_WalkInPlace3 +.4byte FieldObjectCB_Hidden2 +.4byte FieldObjectCB_WalkInPlace4 +.4byte FieldObjectCB_WalkInPlace4 +.4byte FieldObjectCB_WalkInPlace4 +.4byte FieldObjectCB_WalkInPlace4 gUnknown_0850557C:: @ 850557C - .incbin "baserom.gba", 0x50557c, 0x51 +@ replacing .incbin "baserom.gba", 0x0050557c, 0x51 +.byte 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 +.byte 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00 +.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 gUnknown_085055CD:: @ 85055CD - .incbin "baserom.gba", 0x5055cd, 0x51 +@ replacing .incbin "baserom.gba", 0x005055cd, 0x51 +.byte 0x01, 0x01, 0x01, 0x02, 0x01, 0x03, 0x04, 0x02, 0x01, 0x03, 0x04, 0x01, 0x01, 0x01, 0x03, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x03, 0x04, 0x02, 0x04, 0x01 +.byte 0x03, 0x02, 0x03, 0x01, 0x04, 0x03, 0x02, 0x04, 0x01, 0x04, 0x02, 0x03, 0x01, 0x02, 0x01, 0x03, 0x04, 0x02, 0x01, 0x03, 0x04, 0x02, 0x01, 0x03, 0x04, 0x01, 0x01, 0x02, 0x01, 0x03, 0x04, 0x01 +.byte 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x01, 0x02, 0x03, 0x04 .align 2, 0 @ 8505620 @@ -38,7 +131,7 @@ gUnknown_085055CD:: @ 85055CD .include "data/graphics/field_objects/field_object_anims.inc" gUnknown_085094AC:: @ 85094AC - .incbin "baserom.gba", 0x5094ac, 0x40 + .incbin "baserom.gba", 0x005094ac, 0x40 @ 85094EC .include "data/graphics/field_objects/field_object_oam.inc" @@ -500,3 +593,4 @@ gUnknown_0850DFC2:: @ 850DFC2 gUnknown_0850DFC8:: @ 850DFC8 .incbin "baserom.gba", 0x50dfc8, 0x614 + From 88bb0dfc3991d7b64d0df995cd6730df4a869532 Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 17 Sep 2017 18:54:19 -0400 Subject: [PATCH 186/191] More data dism --- data/field_map_obj.s | 142 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 136 insertions(+), 6 deletions(-) diff --git a/data/field_map_obj.s b/data/field_map_obj.s index 7b1b1f1d6..635231d83 100644 --- a/data/field_map_obj.s +++ b/data/field_map_obj.s @@ -9,8 +9,8 @@ gUnknown_084975C4:: @ 84975C4 gUnknown_084975D4:: @ 84975D4 @ replacing .incbin "baserom.gba", 0x004975d4, 0x18 - .2byte 0, 65535 - .4byte gDummyOamData, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, ObjectCB_CameraObject + .2byte 0, 65535 + .4byte gDummyOamData, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, ObjectCB_CameraObject gUnknown_084975EC:: @ 84975EC @ replacing .incbin "baserom.gba", 0x004975ec, 0xc @@ -117,7 +117,7 @@ gUnknown_085055CD:: @ 85055CD .byte 0x03, 0x02, 0x03, 0x01, 0x04, 0x03, 0x02, 0x04, 0x01, 0x04, 0x02, 0x03, 0x01, 0x02, 0x01, 0x03, 0x04, 0x02, 0x01, 0x03, 0x04, 0x02, 0x01, 0x03, 0x04, 0x01, 0x01, 0x02, 0x01, 0x03, 0x04, 0x01 .byte 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x01, 0x02, 0x03, 0x04 - .align 2, 0 + .align 2, 0 @ 8505620 .include "data/graphics/field_objects/field_object_graphics_info_pointers.inc" @@ -131,7 +131,23 @@ gUnknown_085055CD:: @ 85055CD .include "data/graphics/field_objects/field_object_anims.inc" gUnknown_085094AC:: @ 85094AC - .incbin "baserom.gba", 0x005094ac, 0x40 +@ replacing .incbin "baserom.gba", 0x005094ac, 0x40 + .4byte gFieldObjectImageAnimTable_QuintyPlump + .byte 1, 3, 0, 2 + .4byte gFieldObjectImageAnimTable_Standard + .byte 1, 3, 0, 2 + .4byte gFieldObjectImageAnimTable_BrendanMayNormal + .byte 1, 3, 0, 2 + .4byte gFieldObjectImageAnimTable_AcroBike + .byte 1, 3, 0, 2 + .4byte gFieldObjectImageAnimTable_Surfing + .byte 1, 3, 0, 2 + .4byte gFieldObjectImageAnimTable_Nurse + .byte 1, 3, 0, 2 + .4byte gFieldObjectImageAnimTable_Fishing + .byte 1, 3, 0, 2 + .4byte NULL + .byte 0, 0, 0, 0 @ 85094EC .include "data/graphics/field_objects/field_object_oam.inc" @@ -140,7 +156,120 @@ gUnknown_085094AC:: @ 85094AC .include "data/graphics/field_objects/field_object_graphics_info.inc" gUnknown_0850BBC8:: @ 850BBC8 - .incbin "baserom.gba", 0x50bbc8, 0x138 +gUnknown_0850BBC8:: @ 850BBC8 +@ replacing .incbin "baserom.gba", 0x0050bbc8, 0x138 + .align 2, 0 + .4byte gFieldObjectPalette0 + .2byte 4355 + .align 2, 0 + .4byte gFieldObjectPalette1 + .2byte 4356 + .align 2, 0 + .4byte gFieldObjectPalette2 + .2byte 4357 + .align 2, 0 + .4byte gFieldObjectPalette3 + .2byte 4358 + .align 2, 0 + .4byte gFieldObjectPalette4 + .2byte 4359 + .align 2, 0 + .4byte gFieldObjectPalette5 + .2byte 4360 + .align 2, 0 + .4byte gFieldObjectPalette6 + .2byte 4361 + .align 2, 0 + .4byte gFieldObjectPalette7 + .2byte 4362 + .align 2, 0 + .4byte gFieldObjectPalette8 + .2byte 4352 + .align 2, 0 + .4byte gFieldObjectPalette9 + .2byte 4353 + .align 2, 0 + .4byte gFieldObjectPalette10 + .2byte 4354 + .align 2, 0 + .4byte gFieldObjectPalette11 + .2byte 4373 + .align 2, 0 + .4byte gFieldObjectPalette12 + .2byte 4363 + .align 2, 0 + .4byte gFieldObjectPalette13 + .2byte 4364 + .align 2, 0 + .4byte gFieldObjectPalette14 + .2byte 4365 + .align 2, 0 + .4byte gFieldObjectPalette15 + .2byte 4366 + .align 2, 0 + .4byte gFieldObjectPalette16 + .2byte 4367 + .align 2, 0 + .4byte gFieldObjectPalette17 + .2byte 4368 + .align 2, 0 + .4byte gFieldObjectPalette18 + .2byte 4369 + .align 2, 0 + .4byte gFieldObjectPalette19 + .2byte 4370 + .align 2, 0 + .4byte gFieldObjectPalette20 + .2byte 4371 + .align 2, 0 + .4byte gFieldObjectPalette21 + .2byte 4372 + .align 2, 0 + .4byte gFieldObjectPalette22 + .2byte 4374 + .align 2, 0 + .4byte gFieldObjectPalette23 + .2byte 4375 + .align 2, 0 + .4byte gFieldObjectPalette24 + .2byte 4376 + .align 2, 0 + .4byte gFieldObjectPalette25 + .2byte 4377 + .align 2, 0 + .4byte gFieldObjectPalette26 + .2byte 4379 + .align 2, 0 + .4byte gFieldObjectPalette27 + .2byte 4380 + .align 2, 0 + .4byte gFieldObjectPalette28 + .2byte 4381 + .align 2, 0 + .4byte gFieldObjectPalette29 + .2byte 4382 + .align 2, 0 + .4byte gFieldObjectPalette30 + .2byte 4383 + .align 2, 0 + .4byte gFieldObjectPalette31 + .2byte 4384 + .align 2, 0 + .4byte gFieldObjectPalette32 + .2byte 4385 + .align 2, 0 + .4byte gFieldObjectPalette33 + .2byte 4386 + .align 2, 0 + .4byte gFieldObjectPalette34 + .2byte 4387 + .align 2, 0 + .4byte NULL + .2byte 0 + .align 2, 0 + +gUnknown_0850BCE8:: @ 0850BCE8 + .incbin "baserom.gba", 0x50bce8, 0x18 gUnknown_0850BD00:: @ 850BD00 .incbin "baserom.gba", 0x50bd00, 0x78 @@ -589,8 +718,9 @@ gUnknown_0850DFBC:: @ 850DFBC .incbin "baserom.gba", 0x50dfbc, 0x6 gUnknown_0850DFC2:: @ 850DFC2 - .incbin "baserom.gba", 0x50dfc2, 0x6 + .incbin "baserom.gba", 0x50dfc2, 0x6 gUnknown_0850DFC8:: @ 850DFC8 .incbin "baserom.gba", 0x50dfc8, 0x614 + From a23f1a4b11a2d1b5a87898146c7eb0a6ec44da46 Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 17 Sep 2017 19:17:58 -0400 Subject: [PATCH 187/191] hooray, another data dump --- .gitignore | 1 + data/field_map_obj.s | 86 +++++++++++++++++++++++++++++++++++++++++--- src/field_map_obj.c | 4 +-- 3 files changed, 84 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index f450c83f7..e1600820c 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,4 @@ tools/* *.sa* Thumbs.db .DS_Store +*.ddump diff --git a/data/field_map_obj.s b/data/field_map_obj.s index 635231d83..6092e8b26 100644 --- a/data/field_map_obj.s +++ b/data/field_map_obj.s @@ -155,7 +155,6 @@ gUnknown_085094AC:: @ 85094AC @ 8509954 .include "data/graphics/field_objects/field_object_graphics_info.inc" -gUnknown_0850BBC8:: @ 850BBC8 gUnknown_0850BBC8:: @ 850BBC8 @ replacing .incbin "baserom.gba", 0x0050bbc8, 0x138 .align 2, 0 @@ -268,14 +267,91 @@ gUnknown_0850BBC8:: @ 850BBC8 .2byte 0 .align 2, 0 -gUnknown_0850BCE8:: @ 0850BCE8 - .incbin "baserom.gba", 0x50bce8, 0x18 +Unknown_0850BCE8:: @ 0850BCE8 + .incbin "baserom.gba", 0x50bce8, 0x08 + +Unknown_0850BCF0:: @ 0850BCF0 + .incbin "baserom.gba", 0x50bcf0, 0x08 + +Unknown_0850BCF8:: @ 0850BCF8 + .incbin "baserom.gba", 0x50bcf8, 0x08 gUnknown_0850BD00:: @ 850BD00 - .incbin "baserom.gba", 0x50bd00, 0x78 +@ replacing .incbin "baserom.gba", 0x0050bd00, 0x78 + .2byte 4352, 0 + .4byte Unknown_0850BCE8 + .2byte 4368, 0 + .4byte Unknown_0850BCF0 + .2byte 4373, 0 + .4byte Unknown_0850BCF8 + .2byte 4607, 0 + .4byte NULL + +Unknown_0850BD20:: @ 0850BD20 + .incbin "baserom.gba", 0x50bd20, 0x08 + +Unknown_0850BD28:: @ 0x0850bd28 + .incbin "baserom.gba", 0x50bd28, 0x08 + +Unknown_0850BD30:: @ 0x0850bd30 + .incbin "baserom.gba", 0x50bd30, 0x08 + +Unknown_0850BD38:: @ 0x0850bd38 + .incbin "baserom.gba", 0x50bd38, 0x08 + +Unknown_0850BD40:: @ 0x0850bd40 + .incbin "baserom.gba", 0x50bd40, 0x08 + +Unknown_0850BD48:: @ 0x0850bd48 + .incbin "baserom.gba", 0x50bd48, 0x08 + +Unknown_0850BD50:: @ 0x0850bd50 + .incbin "baserom.gba", 0x50bd50, 0x08 + +Unknown_0850BD58:: @ 0x0850bd58 + .incbin "baserom.gba", 0x50bd58, 0x08 + +Unknown_0850BD60:: @ 0x0850bd60 + .incbin "baserom.gba", 0x50bd60, 0x08 + +Unknown_0850BD68:: @ 0x0850bd68 + .incbin "baserom.gba", 0x50bd68, 0x08 + +Unknown_0850BD70:: @ 0x0850bd70 + .incbin "baserom.gba", 0x50bd70, 0x08 gUnknown_0850BD78:: @ 850BD78 - .incbin "baserom.gba", 0x50bd78, 0xc0 +@ replacing .incbin "baserom.gba", 0x0050bd78, 0xc0 + .2byte 4352, 0 + .4byte Unknown_0850BCE8 + .2byte 4368, 0 + .4byte Unknown_0850BCF0 + .2byte 4363, 0 + .4byte Unknown_0850BD20 + .2byte 4365, 0 + .4byte Unknown_0850BD28 + .2byte 4366, 0 + .4byte Unknown_0850BD30 + .2byte 4370, 0 + .4byte Unknown_0850BD38 + .2byte 4371, 0 + .4byte Unknown_0850BD40 + .2byte 4372, 0 + .4byte Unknown_0850BD48 + .2byte 4374, 0 + .4byte Unknown_0850BD58 + .2byte 4376, 0 + .4byte Unknown_0850BD60 + .2byte 4357, 0 + .4byte Unknown_0850BD68 + .2byte 4379, 0 + .4byte Unknown_0850BD50 + .2byte 4381, 0 + .4byte Unknown_0850BD70 + .2byte 4607, 0 + .4byte NULL + + .incbin "baserom.gba", 0x50bde8, 0x50 gUnknown_0850BE38:: @ 850BE38 .incbin "baserom.gba", 0x50be38, 0x10 diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 1ffa0a594..ed51d5fe8 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -142,8 +142,8 @@ u8 gUnknown_084975C4[0x10]; const struct SpriteTemplate gUnknown_084975D4; void (*const gUnknown_084975EC[3])(struct Sprite *); const struct SpritePalette gUnknown_0850BBC8[39]; -const struct PairedPalettes gUnknown_0850BD00[15]; -const struct PairedPalettes gUnknown_0850BD78[15]; +const struct PairedPalettes gUnknown_0850BD00[4]; +const struct PairedPalettes gUnknown_0850BD78[14]; const u16 *const gUnknown_0850BE38[2]; const s16 gUnknown_0850D6DC[4]; // {0x20, 0x40, 0x60, 0x80} const s16 gUnknown_0850D6EC[4]; From c9800706575024da3192360cb3055b90424e7045 Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 17 Sep 2017 19:33:44 -0400 Subject: [PATCH 188/191] More glorious data dumping --- data/field_map_obj.s | 1477 ++++++++++++++++++++++++++++++++++-------- src/field_map_obj.c | 33 +- 2 files changed, 1218 insertions(+), 292 deletions(-) diff --git a/data/field_map_obj.s b/data/field_map_obj.s index 6092e8b26..49fb56a9d 100644 --- a/data/field_map_obj.s +++ b/data/field_map_obj.s @@ -5,7 +5,7 @@ gUnknown_084975C4:: @ 84975C4 @ replacing .incbin "baserom.gba", 0x004975c4, 0x10 -.byte 0x01, 0x01, 0x06, 0x07, 0x08, 0x09, 0x06, 0x07, 0x08, 0x09, 0x0b, 0x0b, 0x00, 0x00, 0x00, 0x00 + .byte 0x01, 0x01, 0x06, 0x07, 0x08, 0x09, 0x06, 0x07, 0x08, 0x09, 0x0b, 0x0b, 0x00, 0x00, 0x00, 0x00 gUnknown_084975D4:: @ 84975D4 @ replacing .incbin "baserom.gba", 0x004975d4, 0x18 @@ -14,108 +14,108 @@ gUnknown_084975D4:: @ 84975D4 gUnknown_084975EC:: @ 84975EC @ replacing .incbin "baserom.gba", 0x004975ec, 0xc -.4byte CameraObject_0 -.4byte CameraObject_1 -.4byte CameraObject_2 + .4byte CameraObject_0 + .4byte CameraObject_1 + .4byte CameraObject_2 @ 84975F8 .include "data/graphics/field_objects/field_object_graphics.inc" gUnknown_08505438:: @ 8505438 @ replacing .incbin "baserom.gba", 0x00505438, 0x144 -.4byte FieldObjectCB_NoMovement1 -.4byte FieldObjectCB_LookRandomDirections -.4byte FieldObjectCB_GoRandomDirections -.4byte FieldObjectCB_RandomlyGoNorthOrSouth -.4byte FieldObjectCB_RandomlyGoNorthOrSouth -.4byte FieldObjectCB_RandomlyGoEastOrWest -.4byte FieldObjectCB_RandomlyGoEastOrWest -.4byte FieldObjectCB_FaceFixedDirection -.4byte FieldObjectCB_FaceFixedDirection -.4byte FieldObjectCB_FaceFixedDirection -.4byte FieldObjectCB_FaceFixedDirection -.4byte FieldObjectCB_NoMovement2 -.4byte FieldObjectCB_BerryTree -.4byte FieldObjectCB_RandomlyLookNorthOrSouth -.4byte FieldObjectCB_RandomlyLookEastOrWest -.4byte FieldObjectCB_RandomlyLookNorthOrWest -.4byte FieldObjectCB_RandomlyLookNorthOrEast -.4byte FieldObjectCB_RandomlyLookSouthOrWest -.4byte FieldObjectCB_RandomlyLookSouthOrEast -.4byte FieldObjectCB_RandomlyLookNorthOrSouthOrWest -.4byte FieldObjectCB_RandomlyLookNorthOrSouthOrEast -.4byte FieldObjectCB_RandomlyLookNorthOrEastOrWest -.4byte FieldObjectCB_RandomlyLookSouthOrEastOrWest -.4byte FieldObjectCB_LookAroundCounterclockwise -.4byte FieldObjectCB_LookAroundClockwise -.4byte FieldObjectCB_AlternatelyGoInOppositeDirections -.4byte FieldObjectCB_AlternatelyGoInOppositeDirections -.4byte FieldObjectCB_AlternatelyGoInOppositeDirections -.4byte FieldObjectCB_AlternatelyGoInOppositeDirections -.4byte FieldObjectCB_GoInDirectionSequence1 -.4byte FieldObjectCB_GoInDirectionSequence2 -.4byte FieldObjectCB_GoInDirectionSequence3 -.4byte FieldObjectCB_GoInDirectionSequence4 -.4byte FieldObjectCB_GoInDirectionSequence5 -.4byte FieldObjectCB_GoInDirectionSequence6 -.4byte FieldObjectCB_GoInDirectionSequence7 -.4byte FieldObjectCB_GoInDirectionSequence8 -.4byte FieldObjectCB_GoInDirectionSequence9 -.4byte FieldObjectCB_GoInDirectionSequence10 -.4byte FieldObjectCB_GoInDirectionSequence11 -.4byte FieldObjectCB_GoInDirectionSequence12 -.4byte FieldObjectCB_GoInDirectionSequence13 -.4byte FieldObjectCB_GoInDirectionSequence14 -.4byte FieldObjectCB_GoInDirectionSequence15 -.4byte FieldObjectCB_GoInDirectionSequence16 -.4byte FieldObjectCB_GoInDirectionSequence17 -.4byte FieldObjectCB_GoInDirectionSequence18 -.4byte FieldObjectCB_GoInDirectionSequence19 -.4byte FieldObjectCB_GoInDirectionSequence20 -.4byte FieldObjectCB_GoInDirectionSequence21 -.4byte FieldObjectCB_GoInDirectionSequence22 -.4byte FieldObjectCB_GoInDirectionSequence23 -.4byte FieldObjectCB_GoInDirectionSequence24 -.4byte FieldObjectCB_CopyPlayer1 -.4byte FieldObjectCB_CopyPlayer1 -.4byte FieldObjectCB_CopyPlayer1 -.4byte FieldObjectCB_CopyPlayer1 -.4byte FieldObjectCB_TreeDisguise -.4byte FieldObjectCB_MountainDisguise -.4byte FieldObjectCB_CopyPlayer2 -.4byte FieldObjectCB_CopyPlayer2 -.4byte FieldObjectCB_CopyPlayer2 -.4byte FieldObjectCB_CopyPlayer2 -.4byte FieldObjectCB_Hidden1 -.4byte FieldObjectCB_WalkInPlace1 -.4byte FieldObjectCB_WalkInPlace1 -.4byte FieldObjectCB_WalkInPlace1 -.4byte FieldObjectCB_WalkInPlace1 -.4byte FieldObjectCB_WalkInPlace2 -.4byte FieldObjectCB_WalkInPlace2 -.4byte FieldObjectCB_WalkInPlace2 -.4byte FieldObjectCB_WalkInPlace2 -.4byte FieldObjectCB_WalkInPlace3 -.4byte FieldObjectCB_WalkInPlace3 -.4byte FieldObjectCB_WalkInPlace3 -.4byte FieldObjectCB_WalkInPlace3 -.4byte FieldObjectCB_Hidden2 -.4byte FieldObjectCB_WalkInPlace4 -.4byte FieldObjectCB_WalkInPlace4 -.4byte FieldObjectCB_WalkInPlace4 -.4byte FieldObjectCB_WalkInPlace4 + .4byte FieldObjectCB_NoMovement1 + .4byte FieldObjectCB_LookRandomDirections + .4byte FieldObjectCB_GoRandomDirections + .4byte FieldObjectCB_RandomlyGoNorthOrSouth + .4byte FieldObjectCB_RandomlyGoNorthOrSouth + .4byte FieldObjectCB_RandomlyGoEastOrWest + .4byte FieldObjectCB_RandomlyGoEastOrWest + .4byte FieldObjectCB_FaceFixedDirection + .4byte FieldObjectCB_FaceFixedDirection + .4byte FieldObjectCB_FaceFixedDirection + .4byte FieldObjectCB_FaceFixedDirection + .4byte FieldObjectCB_NoMovement2 + .4byte FieldObjectCB_BerryTree + .4byte FieldObjectCB_RandomlyLookNorthOrSouth + .4byte FieldObjectCB_RandomlyLookEastOrWest + .4byte FieldObjectCB_RandomlyLookNorthOrWest + .4byte FieldObjectCB_RandomlyLookNorthOrEast + .4byte FieldObjectCB_RandomlyLookSouthOrWest + .4byte FieldObjectCB_RandomlyLookSouthOrEast + .4byte FieldObjectCB_RandomlyLookNorthOrSouthOrWest + .4byte FieldObjectCB_RandomlyLookNorthOrSouthOrEast + .4byte FieldObjectCB_RandomlyLookNorthOrEastOrWest + .4byte FieldObjectCB_RandomlyLookSouthOrEastOrWest + .4byte FieldObjectCB_LookAroundCounterclockwise + .4byte FieldObjectCB_LookAroundClockwise + .4byte FieldObjectCB_AlternatelyGoInOppositeDirections + .4byte FieldObjectCB_AlternatelyGoInOppositeDirections + .4byte FieldObjectCB_AlternatelyGoInOppositeDirections + .4byte FieldObjectCB_AlternatelyGoInOppositeDirections + .4byte FieldObjectCB_GoInDirectionSequence1 + .4byte FieldObjectCB_GoInDirectionSequence2 + .4byte FieldObjectCB_GoInDirectionSequence3 + .4byte FieldObjectCB_GoInDirectionSequence4 + .4byte FieldObjectCB_GoInDirectionSequence5 + .4byte FieldObjectCB_GoInDirectionSequence6 + .4byte FieldObjectCB_GoInDirectionSequence7 + .4byte FieldObjectCB_GoInDirectionSequence8 + .4byte FieldObjectCB_GoInDirectionSequence9 + .4byte FieldObjectCB_GoInDirectionSequence10 + .4byte FieldObjectCB_GoInDirectionSequence11 + .4byte FieldObjectCB_GoInDirectionSequence12 + .4byte FieldObjectCB_GoInDirectionSequence13 + .4byte FieldObjectCB_GoInDirectionSequence14 + .4byte FieldObjectCB_GoInDirectionSequence15 + .4byte FieldObjectCB_GoInDirectionSequence16 + .4byte FieldObjectCB_GoInDirectionSequence17 + .4byte FieldObjectCB_GoInDirectionSequence18 + .4byte FieldObjectCB_GoInDirectionSequence19 + .4byte FieldObjectCB_GoInDirectionSequence20 + .4byte FieldObjectCB_GoInDirectionSequence21 + .4byte FieldObjectCB_GoInDirectionSequence22 + .4byte FieldObjectCB_GoInDirectionSequence23 + .4byte FieldObjectCB_GoInDirectionSequence24 + .4byte FieldObjectCB_CopyPlayer1 + .4byte FieldObjectCB_CopyPlayer1 + .4byte FieldObjectCB_CopyPlayer1 + .4byte FieldObjectCB_CopyPlayer1 + .4byte FieldObjectCB_TreeDisguise + .4byte FieldObjectCB_MountainDisguise + .4byte FieldObjectCB_CopyPlayer2 + .4byte FieldObjectCB_CopyPlayer2 + .4byte FieldObjectCB_CopyPlayer2 + .4byte FieldObjectCB_CopyPlayer2 + .4byte FieldObjectCB_Hidden1 + .4byte FieldObjectCB_WalkInPlace1 + .4byte FieldObjectCB_WalkInPlace1 + .4byte FieldObjectCB_WalkInPlace1 + .4byte FieldObjectCB_WalkInPlace1 + .4byte FieldObjectCB_WalkInPlace2 + .4byte FieldObjectCB_WalkInPlace2 + .4byte FieldObjectCB_WalkInPlace2 + .4byte FieldObjectCB_WalkInPlace2 + .4byte FieldObjectCB_WalkInPlace3 + .4byte FieldObjectCB_WalkInPlace3 + .4byte FieldObjectCB_WalkInPlace3 + .4byte FieldObjectCB_WalkInPlace3 + .4byte FieldObjectCB_Hidden2 + .4byte FieldObjectCB_WalkInPlace4 + .4byte FieldObjectCB_WalkInPlace4 + .4byte FieldObjectCB_WalkInPlace4 + .4byte FieldObjectCB_WalkInPlace4 gUnknown_0850557C:: @ 850557C @ replacing .incbin "baserom.gba", 0x0050557c, 0x51 -.byte 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 -.byte 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00 -.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 + .byte 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 gUnknown_085055CD:: @ 85055CD @ replacing .incbin "baserom.gba", 0x005055cd, 0x51 -.byte 0x01, 0x01, 0x01, 0x02, 0x01, 0x03, 0x04, 0x02, 0x01, 0x03, 0x04, 0x01, 0x01, 0x01, 0x03, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x03, 0x04, 0x02, 0x04, 0x01 -.byte 0x03, 0x02, 0x03, 0x01, 0x04, 0x03, 0x02, 0x04, 0x01, 0x04, 0x02, 0x03, 0x01, 0x02, 0x01, 0x03, 0x04, 0x02, 0x01, 0x03, 0x04, 0x02, 0x01, 0x03, 0x04, 0x01, 0x01, 0x02, 0x01, 0x03, 0x04, 0x01 -.byte 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x01, 0x02, 0x03, 0x04 + .byte 0x01, 0x01, 0x01, 0x02, 0x01, 0x03, 0x04, 0x02, 0x01, 0x03, 0x04, 0x01, 0x01, 0x01, 0x03, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x03, 0x04, 0x02, 0x04, 0x01 + .byte 0x03, 0x02, 0x03, 0x01, 0x04, 0x03, 0x02, 0x04, 0x01, 0x04, 0x02, 0x03, 0x01, 0x02, 0x01, 0x03, 0x04, 0x02, 0x01, 0x03, 0x04, 0x02, 0x01, 0x03, 0x04, 0x01, 0x01, 0x02, 0x01, 0x03, 0x04, 0x01 + .byte 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x01, 0x02, 0x03, 0x04 .align 2, 0 @ 8505620 @@ -278,14 +278,14 @@ Unknown_0850BCF8:: @ 0850BCF8 gUnknown_0850BD00:: @ 850BD00 @ replacing .incbin "baserom.gba", 0x0050bd00, 0x78 - .2byte 4352, 0 - .4byte Unknown_0850BCE8 - .2byte 4368, 0 - .4byte Unknown_0850BCF0 - .2byte 4373, 0 - .4byte Unknown_0850BCF8 - .2byte 4607, 0 - .4byte NULL + .2byte 4352, 0 + .4byte Unknown_0850BCE8 + .2byte 4368, 0 + .4byte Unknown_0850BCF0 + .2byte 4373, 0 + .4byte Unknown_0850BCF8 + .2byte 4607, 0 + .4byte NULL Unknown_0850BD20:: @ 0850BD20 .incbin "baserom.gba", 0x50bd20, 0x08 @@ -322,39 +322,47 @@ Unknown_0850BD70:: @ 0x0850bd70 gUnknown_0850BD78:: @ 850BD78 @ replacing .incbin "baserom.gba", 0x0050bd78, 0xc0 - .2byte 4352, 0 - .4byte Unknown_0850BCE8 - .2byte 4368, 0 - .4byte Unknown_0850BCF0 - .2byte 4363, 0 - .4byte Unknown_0850BD20 - .2byte 4365, 0 - .4byte Unknown_0850BD28 - .2byte 4366, 0 - .4byte Unknown_0850BD30 - .2byte 4370, 0 - .4byte Unknown_0850BD38 - .2byte 4371, 0 - .4byte Unknown_0850BD40 - .2byte 4372, 0 - .4byte Unknown_0850BD48 - .2byte 4374, 0 - .4byte Unknown_0850BD58 - .2byte 4376, 0 - .4byte Unknown_0850BD60 - .2byte 4357, 0 - .4byte Unknown_0850BD68 - .2byte 4379, 0 - .4byte Unknown_0850BD50 - .2byte 4381, 0 - .4byte Unknown_0850BD70 - .2byte 4607, 0 - .4byte NULL + .2byte 4352, 0 + .4byte Unknown_0850BCE8 + .2byte 4368, 0 + .4byte Unknown_0850BCF0 + .2byte 4363, 0 + .4byte Unknown_0850BD20 + .2byte 4365, 0 + .4byte Unknown_0850BD28 + .2byte 4366, 0 + .4byte Unknown_0850BD30 + .2byte 4370, 0 + .4byte Unknown_0850BD38 + .2byte 4371, 0 + .4byte Unknown_0850BD40 + .2byte 4372, 0 + .4byte Unknown_0850BD48 + .2byte 4374, 0 + .4byte Unknown_0850BD58 + .2byte 4376, 0 + .4byte Unknown_0850BD60 + .2byte 4357, 0 + .4byte Unknown_0850BD68 + .2byte 4379, 0 + .4byte Unknown_0850BD50 + .2byte 4381, 0 + .4byte Unknown_0850BD70 + .2byte 4607, 0 + .4byte NULL - .incbin "baserom.gba", 0x50bde8, 0x50 +gUnknown_0850BDE8:: @ 850BDE8 +@ replacing .incbin "baserom.gba", 0x0050bde8, 0x50 + .2byte 0x1100, 0x1101, 0x1103, 0x1104, 0x1105, 0x1106, 0x1107, 0x1108, 0x1109, 0x110a, 0x1100, 0x1101, 0x1103, 0x1104, 0x1105, 0x1106 + .2byte 0x1107, 0x1108, 0x1109, 0x110a, 0x1100, 0x1101, 0x1103, 0x1104, 0x1105, 0x1106, 0x1107, 0x1108, 0x1109, 0x110a, 0x1100, 0x1101 + .2byte 0x1103, 0x1104, 0x1105, 0x1106, 0x1107, 0x1108, 0x1109, 0x110a gUnknown_0850BE38:: @ 850BE38 - .incbin "baserom.gba", 0x50be38, 0x10 +@ replacing .incbin "baserom.gba", 0x0050be38, 0x10 + .4byte 0x850bde8 + .4byte 0x850bdfc + .4byte 0x850be10 + .4byte 0x850be24 @ 850BE48 .include "data/graphics/field_objects/berry_tree_graphics_tables.inc" @@ -362,441 +370,1360 @@ gUnknown_0850BE38:: @ 850BE38 @ 850C9C0 .include "data/graphics/field_objects/field_effect_objects.inc" - .incbin "baserom.gba", 0x50d6d4, 0x8 +@ replacing .incbin "baserom.gba", 0x0050d6d4, 0x8 + .align 2, 0 + .4byte 0x084ad8f8 + .2byte 4113 + .align 2, 0 gUnknown_0850D6DC:: @ 850D6DC - .incbin "baserom.gba", 0x50d6dc, 0x10 +@ replacing .incbin "baserom.gba", 0x0050d6dc, 0x10 + .2byte 0x0020, 0x0040, 0x0060, 0x0080, 0x0020, 0x0040, 0x0080, 0x00c0 gUnknown_0850D6EC:: @ 850D6EC - .incbin "baserom.gba", 0x50d6ec, 0x8 +@ replacing .incbin "baserom.gba", 0x0050d6ec, 0x8 + .2byte 0x0020, 0x0030, 0x0040, 0x0050 gUnknown_0850D6F4:: @ 850D6F4 - .incbin "baserom.gba", 0x50d6f4, 0x1c +@ replacing .incbin "baserom.gba", 0x0050d6f4, 0x1c + .4byte sub_808F44C + .4byte sub_808F460 + .4byte sub_808F48C + .4byte sub_808F4C8 + .4byte sub_808F4E8 + .4byte sub_808F534 + .4byte sub_808F564 gUnknown_0850D710:: @ 850D710 - .incbin "baserom.gba", 0x50d710, 0x4 +@ replacing .incbin "baserom.gba", 0x0050d710, 0x4 + .byte 0x01, 0x02, 0x03, 0x04 gUnknown_0850D714:: @ 850D714 - .incbin "baserom.gba", 0x50d714, 0x2c +@ replacing .incbin "baserom.gba", 0x0050d714, 0x2c + .4byte GetRegularRunningPastFacingDirection + .4byte GetNorthSouthRunningPastFacingDirection + .4byte GetEastWestRunningPastFacingDirection + .4byte GetNorthEastRunningPastFacingDirection + .4byte GetNorthWestRunningPastFacingDirection + .4byte GetSouthEastRunningPastFacingDirection + .4byte GetSouthWestRunningPastFacingDirection + .4byte GetNonEastRunningPastFacingDirection + .4byte GetNonWestRunningPastFacingDirection + .4byte GetNonSouthRunningPastFacingDirection + .4byte GetNonNorthRunningPastFacingDirection gUnknown_0850D740:: @ 850D740 - .incbin "baserom.gba", 0x50d740, 0x14 +@ replacing .incbin "baserom.gba", 0x0050d740, 0x14 + .4byte sub_808F988 + .4byte sub_808F99C + .4byte sub_808F9C8 + .4byte sub_808FA0C + .4byte sub_808FA3C gUnknown_0850D754:: @ 850D754 - .incbin "baserom.gba", 0x50d754, 0x1c +@ replacing .incbin "baserom.gba", 0x0050d754, 0x1c + .4byte sub_808FAC8 + .4byte sub_808FADC + .4byte sub_808FB08 + .4byte sub_808FB44 + .4byte sub_808FB64 + .4byte sub_808FBB0 + .4byte sub_808FBE0 gUnknown_0850D770:: @ 850D770 - .incbin "baserom.gba", 0x50d770, 0x4 +@ replacing .incbin "baserom.gba", 0x0050d770, 0x4 + .byte 0x01, 0x02, 0x00, 0x00 gUnknown_0850D774:: @ 850D774 - .incbin "baserom.gba", 0x50d774, 0x1c +@ replacing .incbin "baserom.gba", 0x0050d774, 0x1c + .4byte sub_808FC4C + .4byte sub_808FC60 + .4byte sub_808FC8C + .4byte sub_808FCC8 + .4byte sub_808FCE8 + .4byte sub_808FD34 + .4byte sub_808FD64 gUnknown_0850D790:: @ 850D790 - .incbin "baserom.gba", 0x50d790, 0x4 +@ replacing .incbin "baserom.gba", 0x0050d790, 0x4 + .byte 0x03, 0x04, 0x00, 0x00 gUnknown_0850D794:: @ 850D794 - .incbin "baserom.gba", 0x50d794, 0xc +@ replacing .incbin "baserom.gba", 0x0050d794, 0xc + .4byte sub_808FDD0 + .4byte sub_808FDFC + .4byte sub_808FE1C gUnknown_0850D7A0:: @ 850D7A0 - .incbin "baserom.gba", 0x50d7a0, 0x14 +@ replacing .incbin "baserom.gba", 0x0050d7a0, 0x14 + .4byte do_berry_tree_growth_sparkle_1 + .4byte sub_808FF48 + .4byte do_berry_tree_growth_sparkle_2 + .4byte sub_808FFB4 + .4byte sub_8090004 gUnknown_0850D7B4:: @ 850D7B4 - .incbin "baserom.gba", 0x50d7b4, 0x14 +@ replacing .incbin "baserom.gba", 0x0050d7b4, 0x14 + .4byte sub_8090094 + .4byte sub_80900A8 + .4byte sub_80900D4 + .4byte sub_8090118 + .4byte sub_8090148 gUnknown_0850D7C8:: @ 850D7C8 - .incbin "baserom.gba", 0x50d7c8, 0x14 +@ replacing .incbin "baserom.gba", 0x0050d7c8, 0x14 + .4byte sub_80901D4 + .4byte sub_80901E8 + .4byte sub_8090214 + .4byte sub_8090258 + .4byte sub_8090288 gUnknown_0850D7DC:: @ 850D7DC - .incbin "baserom.gba", 0x50d7dc, 0x14 +@ replacing .incbin "baserom.gba", 0x0050d7dc, 0x14 + .4byte sub_8090314 + .4byte sub_8090328 + .4byte sub_8090354 + .4byte sub_8090398 + .4byte sub_80903C8 gUnknown_0850D7F0:: @ 850D7F0 - .incbin "baserom.gba", 0x50d7f0, 0x4 +@ replacing .incbin "baserom.gba", 0x0050d7f0, 0x4 + .byte 0x02, 0x03, 0x00, 0x00 gUnknown_0850D7F4:: @ 850D7F4 - .incbin "baserom.gba", 0x50d7f4, 0x14 +@ replacing .incbin "baserom.gba", 0x0050d7f4, 0x14 + .4byte sub_8090454 + .4byte sub_8090468 + .4byte sub_8090494 + .4byte sub_80904D8 + .4byte sub_8090508 gUnknown_0850D808:: @ 850D808 - .incbin "baserom.gba", 0x50d808, 0x4 +@ replacing .incbin "baserom.gba", 0x0050d808, 0x4 + .byte 0x02, 0x04, 0x00, 0x00 gUnknown_0850D80C:: @ 850D80C - .incbin "baserom.gba", 0x50d80c, 0x14 +@ replacing .incbin "baserom.gba", 0x0050d80c, 0x14 + .4byte sub_8090594 + .4byte sub_80905A8 + .4byte sub_80905D4 + .4byte sub_8090618 + .4byte sub_8090648 gUnknown_0850D820:: @ 850D820 - .incbin "baserom.gba", 0x50d820, 0x4 +@ replacing .incbin "baserom.gba", 0x0050d820, 0x4 + .byte 0x01, 0x03, 0x00, 0x00 gUnknown_0850D824:: @ 850D824 - .incbin "baserom.gba", 0x50d824, 0x14 +@ replacing .incbin "baserom.gba", 0x0050d824, 0x14 + .4byte sub_80906D4 + .4byte sub_80906E8 + .4byte sub_8090714 + .4byte sub_8090758 + .4byte sub_8090788 gUnknown_0850D838:: @ 850D838 - .incbin "baserom.gba", 0x50d838, 0x4 +@ replacing .incbin "baserom.gba", 0x0050d838, 0x4 + .byte 0x01, 0x04, 0x00, 0x00 gUnknown_0850D83C:: @ 850D83C - .incbin "baserom.gba", 0x50d83c, 0x14 +@ replacing .incbin "baserom.gba", 0x0050d83c, 0x14 + .4byte sub_8090814 + .4byte sub_8090828 + .4byte sub_8090854 + .4byte sub_8090898 + .4byte sub_80908C8 gUnknown_0850D850:: @ 850D850 - .incbin "baserom.gba", 0x50d850, 0x4 +@ replacing .incbin "baserom.gba", 0x0050d850, 0x4 + .byte 0x02, 0x01, 0x03, 0x01 gUnknown_0850D854:: @ 850D854 - .incbin "baserom.gba", 0x50d854, 0x14 +@ replacing .incbin "baserom.gba", 0x0050d854, 0x14 + .4byte sub_8090954 + .4byte sub_8090968 + .4byte sub_8090994 + .4byte sub_80909D8 + .4byte sub_8090A08 gUnknown_0850D868:: @ 850D868 - .incbin "baserom.gba", 0x50d868, 0x4 +@ replacing .incbin "baserom.gba", 0x0050d868, 0x4 + .byte 0x01, 0x02, 0x04, 0x01 gUnknown_0850D86C:: @ 850D86C - .incbin "baserom.gba", 0x50d86c, 0x14 +@ replacing .incbin "baserom.gba", 0x0050d86c, 0x14 + .4byte sub_8090A94 + .4byte sub_8090AA8 + .4byte sub_8090AD4 + .4byte sub_8090B18 + .4byte sub_8090B48 gUnknown_0850D880:: @ 850D880 - .incbin "baserom.gba", 0x50d880, 0x4 +@ replacing .incbin "baserom.gba", 0x0050d880, 0x4 + .byte 0x02, 0x03, 0x04, 0x02 gUnknown_0850D884:: @ 850D884 - .incbin "baserom.gba", 0x50d884, 0x14 +@ replacing .incbin "baserom.gba", 0x0050d884, 0x14 + .4byte sub_8090BD4 + .4byte sub_8090BE8 + .4byte sub_8090C14 + .4byte sub_8090C58 + .4byte sub_8090C88 gUnknown_0850D898:: @ 850D898 - .incbin "baserom.gba", 0x50d898, 0x4 +@ replacing .incbin "baserom.gba", 0x0050d898, 0x4 + .byte 0x03, 0x04, 0x01, 0x01 gUnknown_0850D89C:: @ 850D89C - .incbin "baserom.gba", 0x50d89c, 0x10 +@ replacing .incbin "baserom.gba", 0x0050d89c, 0x10 + .4byte sub_8090D14 + .4byte sub_8090D40 + .4byte sub_8090D64 + .4byte sub_8090D90 gUnknown_0850D8AC:: @ 850D8AC - .incbin "baserom.gba", 0x50d8ac, 0x8 +@ replacing .incbin "baserom.gba", 0x0050d8ac, 0x8 + .byte 0x01, 0x04, 0x03, 0x01, 0x02, 0x00, 0x00, 0x00 gUnknown_0850D8B4:: @ 850D8B4 - .incbin "baserom.gba", 0x50d8b4, 0x10 +@ replacing .incbin "baserom.gba", 0x0050d8b4, 0x10 + .4byte sub_8090E18 + .4byte sub_8090E44 + .4byte sub_8090E68 + .4byte sub_8090E94 gUnknown_0850D8C4:: @ 850D8C4 - .incbin "baserom.gba", 0x50d8c4, 0x8 +@ replacing .incbin "baserom.gba", 0x0050d8c4, 0x8 + .byte 0x01, 0x03, 0x04, 0x02, 0x01, 0x00, 0x00, 0x00 gUnknown_0850D8CC:: @ 850D8CC - .incbin "baserom.gba", 0x50d8cc, 0x10 +@ replacing .incbin "baserom.gba", 0x0050d8cc, 0x10 + .4byte sub_8090F1C + .4byte sub_8090F30 + .4byte sub_8090F68 + .4byte sub_8091020 gUnknown_0850D8DC:: @ 850D8DC - .incbin "baserom.gba", 0x50d8dc, 0xc +@ replacing .incbin "baserom.gba", 0x0050d8dc, 0xc + .4byte sub_8091048 + .4byte sub_809117C + .4byte sub_8091110 gUnknown_0850D8E8:: @ 850D8E8 - .incbin "baserom.gba", 0x50d8e8, 0x4 +@ replacing .incbin "baserom.gba", 0x0050d8e8, 0x4 + .byte 0x02, 0x04, 0x03, 0x01 gUnknown_0850D8EC:: @ 850D8EC - .incbin "baserom.gba", 0x50d8ec, 0xc +@ replacing .incbin "baserom.gba", 0x0050d8ec, 0xc + .4byte sub_8091048 + .4byte sub_8091208 + .4byte sub_8091110 gUnknown_0850D8F8:: @ 850D8F8 - .incbin "baserom.gba", 0x50d8f8, 0x4 +@ replacing .incbin "baserom.gba", 0x0050d8f8, 0x4 + .byte 0x04, 0x03, 0x01, 0x02 gUnknown_0850D8FC:: @ 850D8FC - .incbin "baserom.gba", 0x50d8fc, 0xc +@ replacing .incbin "baserom.gba", 0x0050d8fc, 0xc + .4byte sub_8091048 + .4byte sub_8091294 + .4byte sub_8091110 gUnknown_0850D908:: @ 850D908 - .incbin "baserom.gba", 0x50d908, 0x4 +@ replacing .incbin "baserom.gba", 0x0050d908, 0x4 + .byte 0x01, 0x02, 0x04, 0x03 gUnknown_0850D90C:: @ 850D90C - .incbin "baserom.gba", 0x50d90c, 0xc +@ replacing .incbin "baserom.gba", 0x0050d90c, 0xc + .4byte sub_8091048 + .4byte sub_8091320 + .4byte sub_8091110 gUnknown_0850D918:: @ 850D918 - .incbin "baserom.gba", 0x50d918, 0x4 +@ replacing .incbin "baserom.gba", 0x0050d918, 0x4 + .byte 0x03, 0x01, 0x02, 0x04 gUnknown_0850D91C:: @ 850D91C - .incbin "baserom.gba", 0x50d91c, 0xc +@ replacing .incbin "baserom.gba", 0x0050d91c, 0xc + .4byte sub_8091048 + .4byte sub_80913AC + .4byte sub_8091110 gUnknown_0850D928:: @ 850D928 - .incbin "baserom.gba", 0x50d928, 0x4 +@ replacing .incbin "baserom.gba", 0x0050d928, 0x4 + .byte 0x02, 0x03, 0x04, 0x01 gUnknown_0850D92C:: @ 850D92C - .incbin "baserom.gba", 0x50d92c, 0xc +@ replacing .incbin "baserom.gba", 0x0050d92c, 0xc + .4byte sub_8091048 + .4byte sub_8091438 + .4byte sub_8091110 gUnknown_0850D938:: @ 850D938 - .incbin "baserom.gba", 0x50d938, 0x4 +@ replacing .incbin "baserom.gba", 0x0050d938, 0x4 + .byte 0x03, 0x04, 0x01, 0x02 gUnknown_0850D93C:: @ 850D93C - .incbin "baserom.gba", 0x50d93c, 0xc +@ replacing .incbin "baserom.gba", 0x0050d93c, 0xc + .4byte sub_8091048 + .4byte sub_80914C4 + .4byte sub_8091110 gUnknown_0850D948:: @ 850D948 - .incbin "baserom.gba", 0x50d948, 0xc +@ replacing .incbin "baserom.gba", 0x0050d948, 0xc + .4byte sub_8091048 + .4byte sub_8091550 + .4byte sub_8091110 gUnknown_0850D954:: @ 850D954 - .incbin "baserom.gba", 0x50d954, 0x4 +@ replacing .incbin "baserom.gba", 0x0050d954, 0x4 + .byte 0x04, 0x01, 0x02, 0x03 gUnknown_0850D958:: @ 850D958 - .incbin "baserom.gba", 0x50d958, 0xc +@ replacing .incbin "baserom.gba", 0x0050d958, 0xc + .4byte sub_8091048 + .4byte sub_80915DC + .4byte sub_8091110 gUnknown_0850D964:: @ 850D964 - .incbin "baserom.gba", 0x50d964, 0x4 +@ replacing .incbin "baserom.gba", 0x0050d964, 0x4 + .byte 0x03, 0x02, 0x01, 0x04 gUnknown_0850D968:: @ 850D968 - .incbin "baserom.gba", 0x50d968, 0xc +@ replacing .incbin "baserom.gba", 0x0050d968, 0xc + .4byte sub_8091048 + .4byte sub_8091668 + .4byte sub_8091110 gUnknown_0850D974:: @ 850D974 - .incbin "baserom.gba", 0x50d974, 0x4 +@ replacing .incbin "baserom.gba", 0x0050d974, 0x4 + .byte 0x02, 0x01, 0x04, 0x03 gUnknown_0850D978:: @ 850D978 - .incbin "baserom.gba", 0x50d978, 0xc +@ replacing .incbin "baserom.gba", 0x0050d978, 0xc + .4byte sub_8091048 + .4byte sub_80916F4 + .4byte sub_8091110 gUnknown_0850D984:: @ 850D984 - .incbin "baserom.gba", 0x50d984, 0x4 +@ replacing .incbin "baserom.gba", 0x0050d984, 0x4 + .byte 0x04, 0x03, 0x02, 0x01 gUnknown_0850D988:: @ 850D988 - .incbin "baserom.gba", 0x50d988, 0xc +@ replacing .incbin "baserom.gba", 0x0050d988, 0xc + .4byte sub_8091048 + .4byte sub_8091780 + .4byte sub_8091110 gUnknown_0850D994:: @ 850D994 - .incbin "baserom.gba", 0x50d994, 0x4 +@ replacing .incbin "baserom.gba", 0x0050d994, 0x4 + .byte 0x01, 0x04, 0x03, 0x02 gUnknown_0850D998:: @ 850D998 - .incbin "baserom.gba", 0x50d998, 0xc +@ replacing .incbin "baserom.gba", 0x0050d998, 0xc + .4byte sub_8091048 + .4byte sub_809180C + .4byte sub_8091110 gUnknown_0850D9A4:: @ 850D9A4 - .incbin "baserom.gba", 0x50d9a4, 0x4 +@ replacing .incbin "baserom.gba", 0x0050d9a4, 0x4 + .byte 0x04, 0x02, 0x01, 0x03 gUnknown_0850D9A8:: @ 850D9A8 - .incbin "baserom.gba", 0x50d9a8, 0xc +@ replacing .incbin "baserom.gba", 0x0050d9a8, 0xc + .4byte sub_8091048 + .4byte sub_8091898 + .4byte sub_8091110 gUnknown_0850D9B4:: @ 850D9B4 - .incbin "baserom.gba", 0x50d9b4, 0x4 +@ replacing .incbin "baserom.gba", 0x0050d9b4, 0x4 + .byte 0x02, 0x01, 0x03, 0x04 gUnknown_0850D9B8:: @ 850D9B8 - .incbin "baserom.gba", 0x50d9b8, 0xc +@ replacing .incbin "baserom.gba", 0x0050d9b8, 0xc + .4byte sub_8091048 + .4byte sub_8091924 + .4byte sub_8091110 gUnknown_0850D9C4:: @ 850D9C4 - .incbin "baserom.gba", 0x50d9c4, 0x4 +@ replacing .incbin "baserom.gba", 0x0050d9c4, 0x4 + .byte 0x03, 0x04, 0x02, 0x01 gUnknown_0850D9C8:: @ 850D9C8 - .incbin "baserom.gba", 0x50d9c8, 0xc +@ replacing .incbin "baserom.gba", 0x0050d9c8, 0xc + .4byte sub_8091048 + .4byte sub_80919B0 + .4byte sub_8091110 gUnknown_0850D9D4:: @ 850D9D4 - .incbin "baserom.gba", 0x50d9d4, 0x4 +@ replacing .incbin "baserom.gba", 0x0050d9d4, 0x4 + .byte 0x01, 0x03, 0x04, 0x02 gUnknown_0850D9D8:: @ 850D9D8 - .incbin "baserom.gba", 0x50d9d8, 0xc +@ replacing .incbin "baserom.gba", 0x0050d9d8, 0xc + .4byte sub_8091048 + .4byte sub_8091A3C + .4byte sub_8091110 gUnknown_0850D9E4:: @ 850D9E4 - .incbin "baserom.gba", 0x50d9e4, 0x4 +@ replacing .incbin "baserom.gba", 0x0050d9e4, 0x4 + .byte 0x02, 0x03, 0x01, 0x04 gUnknown_0850D9E8:: @ 850D9E8 - .incbin "baserom.gba", 0x50d9e8, 0xc +@ replacing .incbin "baserom.gba", 0x0050d9e8, 0xc + .4byte sub_8091048 + .4byte sub_8091AC8 + .4byte sub_8091110 gUnknown_0850D9F4:: @ 850D9F4 - .incbin "baserom.gba", 0x50d9f4, 0x4 +@ replacing .incbin "baserom.gba", 0x0050d9f4, 0x4 + .byte 0x01, 0x04, 0x02, 0x03 gUnknown_0850D9F8:: @ 850D9F8 - .incbin "baserom.gba", 0x50d9f8, 0xc +@ replacing .incbin "baserom.gba", 0x0050d9f8, 0xc + .4byte sub_8091048 + .4byte sub_8091B54 + .4byte sub_8091110 gUnknown_0850DA04:: @ 850DA04 - .incbin "baserom.gba", 0x50da04, 0x4 +@ replacing .incbin "baserom.gba", 0x0050da04, 0x4 + .byte 0x03, 0x01, 0x04, 0x02 gUnknown_0850DA08:: @ 850DA08 - .incbin "baserom.gba", 0x50da08, 0xc +@ replacing .incbin "baserom.gba", 0x0050da08, 0xc + .4byte sub_8091048 + .4byte sub_8091BE0 + .4byte sub_8091110 gUnknown_0850DA14:: @ 850DA14 - .incbin "baserom.gba", 0x50da14, 0x4 +@ replacing .incbin "baserom.gba", 0x0050da14, 0x4 + .byte 0x04, 0x02, 0x03, 0x01 gUnknown_0850DA18:: @ 850DA18 - .incbin "baserom.gba", 0x50da18, 0xc +@ replacing .incbin "baserom.gba", 0x0050da18, 0xc + .4byte sub_8091048 + .4byte sub_8091C6C + .4byte sub_8091110 gUnknown_0850DA24:: @ 850DA24 - .incbin "baserom.gba", 0x50da24, 0x4 +@ replacing .incbin "baserom.gba", 0x0050da24, 0x4 + .byte 0x02, 0x04, 0x01, 0x03 gUnknown_0850DA28:: @ 850DA28 - .incbin "baserom.gba", 0x50da28, 0xc +@ replacing .incbin "baserom.gba", 0x0050da28, 0xc + .4byte sub_8091048 + .4byte sub_8091CF8 + .4byte sub_8091110 gUnknown_0850DA34:: @ 850DA34 - .incbin "baserom.gba", 0x50da34, 0x4 +@ replacing .incbin "baserom.gba", 0x0050da34, 0x4 + .byte 0x01, 0x03, 0x02, 0x04 gUnknown_0850DA38:: @ 850DA38 - .incbin "baserom.gba", 0x50da38, 0xc +@ replacing .incbin "baserom.gba", 0x0050da38, 0xc + .4byte sub_8091048 + .4byte sub_8091D84 + .4byte sub_8091110 gUnknown_0850DA44:: @ 850DA44 - .incbin "baserom.gba", 0x50da44, 0x4 +@ replacing .incbin "baserom.gba", 0x0050da44, 0x4 + .byte 0x03, 0x02, 0x04, 0x01 gUnknown_0850DA48:: @ 850DA48 - .incbin "baserom.gba", 0x50da48, 0xc +@ replacing .incbin "baserom.gba", 0x0050da48, 0xc + .4byte sub_8091048 + .4byte sub_8091E10 + .4byte sub_8091110 gUnknown_0850DA54:: @ 850DA54 - .incbin "baserom.gba", 0x50da54, 0x4 +@ replacing .incbin "baserom.gba", 0x0050da54, 0x4 + .byte 0x04, 0x01, 0x03, 0x02 gUnknown_0850DA58:: @ 850DA58 - .incbin "baserom.gba", 0x50da58, 0xc +@ replacing .incbin "baserom.gba", 0x0050da58, 0xc + .4byte mss_npc_reset_oampriv3_1_unk2_unk3 + .4byte sub_8091EC0 + .4byte sub_8091F20 gUnknown_0850DA64:: @ 850DA64 - .incbin "baserom.gba", 0x50da64, 0x2c +@ replacing .incbin "baserom.gba", 0x0050da64, 0x2c + .4byte sub_8091F48 + .4byte sub_8091F4C + .4byte sub_8091F94 + .4byte sub_80920A4 + .4byte sub_809215C + .4byte sub_8092214 + .4byte cph_IM_DIFFERENT + .4byte sub_8092314 + .4byte oac_hopping + .4byte sub_8091F48 + .4byte sub_8091F48 gUnknown_0850DA90:: @ 850DA90 - .incbin "baserom.gba", 0x50da90, 0xc +@ replacing .incbin "baserom.gba", 0x0050da90, 0xc + .4byte mss_npc_reset_oampriv3_1_unk2_unk3 + .4byte mss_08062EA4 + .4byte sub_8091F20 gUnknown_0850DA9C:: @ 850DA9C - .incbin "baserom.gba", 0x50da9c, 0x4 +@ replacing .incbin "baserom.gba", 0x0050da9c, 0x4 + .4byte sub_80926AC gUnknown_0850DAA0:: @ 850DAA0 - .incbin "baserom.gba", 0x50daa0, 0x8 +@ replacing .incbin "baserom.gba", 0x0050daa0, 0x8 + .4byte sub_8092718 + .4byte sub_80926B8 gUnknown_0850DAA8:: @ 850DAA8 - .incbin "baserom.gba", 0x50daa8, 0x8 +@ replacing .incbin "baserom.gba", 0x0050daa8, 0x8 + .4byte sub_8092788 + .4byte sub_80926B8 gUnknown_0850DAB0:: @ 850DAB0 - .incbin "baserom.gba", 0x50dab0, 0x8 +@ replacing .incbin "baserom.gba", 0x0050dab0, 0x8 + .4byte sub_80927F8 + .4byte sub_80926B8 gUnknown_0850DAB8:: @ 850DAB8 - .incbin "baserom.gba", 0x50dab8, 0x8 +@ replacing .incbin "baserom.gba", 0x0050dab8, 0x8 + .4byte sub_8092868 + .4byte sub_80926B8 gUnknown_0850DAC0:: @ 850DAC0 - .incbin "baserom.gba", 0x50dac0, 0xc +@ replacing .incbin "baserom.gba", 0x0050dac0, 0xc + .4byte sub_80928D8 + .4byte sub_809290C + .4byte sub_809292C gUnknown_0850DACC:: @ 850DACC - .incbin "baserom.gba", 0x50dacc, 0x9 +@ replacing .incbin "baserom.gba", 0x0050dacc, 0x9 + .byte 0x00, 0x00, 0x01, 0x02, 0x03, 0x00, 0x00, 0x01, 0x01 gUnknown_0850DAD5:: @ 850DAD5 - .incbin "baserom.gba", 0x50dad5, 0x9 +@ replacing .incbin "baserom.gba", 0x0050dad5, 0x9 + .byte 0x04, 0x04, 0x05, 0x06, 0x07, 0x04, 0x04, 0x05, 0x05 gUnknown_0850DADE:: @ 850DADE - .incbin "baserom.gba", 0x50dade, 0x9 +@ replacing .incbin "baserom.gba", 0x0050dade, 0x9 + .byte 0x08, 0x08, 0x09, 0x0a, 0x0b, 0x08, 0x08, 0x09, 0x09 gUnknown_0850DAE7:: @ 850DAE7 - .incbin "baserom.gba", 0x50dae7, 0x9 +@ replacing .incbin "baserom.gba", 0x0050dae7, 0x9 + .byte 0x0c, 0x0c, 0x0d, 0x0e, 0x0f, 0x0c, 0x0c, 0x0d, 0x0d gUnknown_0850DAF0:: @ 850DAF0 - .incbin "baserom.gba", 0x50daf0, 0x9 +@ replacing .incbin "baserom.gba", 0x0050daf0, 0x9 + .byte 0x10, 0x10, 0x11, 0x12, 0x13, 0x10, 0x10, 0x11, 0x11 gUnknown_0850DAF9:: @ 850DAF9 - .incbin "baserom.gba", 0x50daf9, 0x9 +@ replacing .incbin "baserom.gba", 0x0050daf9, 0x9 + .byte 0x14, 0x14, 0x15, 0x16, 0x17, 0x14, 0x14, 0x15, 0x15 gUnknown_0850DB02:: @ 850DB02 - .incbin "baserom.gba", 0x50db02, 0x9 +@ replacing .incbin "baserom.gba", 0x0050db02, 0x9 + .byte 0x14, 0x14, 0x15, 0x16, 0x17, 0x14, 0x14, 0x15, 0x15 gUnknown_0850DB0B:: @ 850DB0B - .incbin "baserom.gba", 0x50db0b, 0x9 +@ replacing .incbin "baserom.gba", 0x0050db0b, 0x9 + .byte 0x18, 0x18, 0x19, 0x1a, 0x1b, 0x18, 0x18, 0x19, 0x19 gUnknown_0850DB14:: @ 850DB14 - .incbin "baserom.gba", 0x50db14, 0x9 +@ replacing .incbin "baserom.gba", 0x0050db14, 0x9 + .byte 0x1c, 0x1c, 0x1d, 0x1e, 0x1f, 0x1c, 0x1c, 0x1d, 0x1d gUnknown_0850DB1D:: @ 850DB1D - .incbin "baserom.gba", 0x50db1d, 0x9 +@ replacing .incbin "baserom.gba", 0x0050db1d, 0x9 + .byte 0x20, 0x20, 0x21, 0x22, 0x23, 0x20, 0x20, 0x21, 0x21 gUnknown_0850DB26:: @ 850DB26 - .incbin "baserom.gba", 0x50db26, 0x9 +@ replacing .incbin "baserom.gba", 0x0050db26, 0x9 + .byte 0x24, 0x24, 0x25, 0x26, 0x27, 0x24, 0x24, 0x25, 0x25 gUnknown_0850DB2F:: @ 850DB2F - .incbin "baserom.gba", 0x50db2f, 0x9 +@ replacing .incbin "baserom.gba", 0x0050db2f, 0x9 + .byte 0x00, 0x00, 0x01, 0x02, 0x03, 0x00, 0x00, 0x01, 0x01 gUnknown_0850DB38:: @ 850DB38 - .incbin "baserom.gba", 0x50db38, 0x9 +@ replacing .incbin "baserom.gba", 0x0050db38, 0x9 + .byte 0x04, 0x04, 0x05, 0x06, 0x07, 0x04, 0x04, 0x05, 0x05 gUnknown_0850DB41:: @ 850DB41 - .incbin "baserom.gba", 0x50db41, 0x9 +@ replacing .incbin "baserom.gba", 0x0050db41, 0x9 + .byte 0x08, 0x08, 0x09, 0x0a, 0x0b, 0x08, 0x08, 0x09, 0x09 gUnknown_0850DB4A:: @ 850DB4A - .incbin "baserom.gba", 0x50db4a, 0x9 +@ replacing .incbin "baserom.gba", 0x0050db4a, 0x9 + .byte 0x14, 0x14, 0x15, 0x16, 0x17, 0x14, 0x14, 0x15, 0x15 gUnknown_0850DB53:: @ 850DB53 - .incbin "baserom.gba", 0x50db53, 0x9 +@ replacing .incbin "baserom.gba", 0x0050db53, 0x9 + .byte 0x08, 0x08, 0x07, 0x09, 0x0a, 0x08, 0x08, 0x07, 0x07 + .align 2, 0 gUnknown_0850DB5C:: @ 850DB5C - .incbin "baserom.gba", 0x50db5c, 0x10 +@ replacing .incbin "baserom.gba", 0x0050db5c, 0x10 + .4byte MetatileBehavior_IsSouthBlocked + .4byte MetatileBehavior_IsNorthBlocked + .4byte MetatileBehavior_IsWestBlocked + .4byte MetatileBehavior_IsEastBlocked gUnknown_0850DB6C:: @ 850DB6C - .incbin "baserom.gba", 0x50db6c, 0x10 +@ replacing .incbin "baserom.gba", 0x0050db6c, 0x10 + .4byte MetatileBehavior_IsNorthBlocked + .4byte MetatileBehavior_IsSouthBlocked + .4byte MetatileBehavior_IsEastBlocked + .4byte MetatileBehavior_IsWestBlocked gUnknown_0850DB7C:: @ 850DB7C - .incbin "baserom.gba", 0x50db7c, 0x24 +@ replacing .incbin "baserom.gba", 0x0050db7c, 0x24 + .2byte 0x0000, 0x0000, 0x0000, 0x0001, 0x0000, 0xffff, 0xffff, 0x0000, 0x0001, 0x0000, 0xffff, 0x0001, 0x0001, 0x0001, 0xffff, 0xffff + .2byte 0x0001, 0xffff gUnknown_0850DBA0:: @ 850DBA0 - .incbin "baserom.gba", 0x50dba0, 0x5 +@ replacing .incbin "baserom.gba", 0x0050dba0, 0x5 + .byte 0x00, 0x00, 0x01, 0x02, 0x03 gUnknown_0850DBA5:: @ 850DBA5 - .incbin "baserom.gba", 0x50dba5, 0x5 +@ replacing .incbin "baserom.gba", 0x0050dba5, 0x5 + .byte 0x04, 0x04, 0x05, 0x06, 0x07 gUnknown_0850DBAA:: @ 850DBAA - .incbin "baserom.gba", 0x50dbaa, 0x5 +@ replacing .incbin "baserom.gba", 0x0050dbaa, 0x5 + .byte 0x08, 0x08, 0x09, 0x0a, 0x0b gUnknown_0850DBAF:: @ 850DBAF - .incbin "baserom.gba", 0x50dbaf, 0x5 +@ replacing .incbin "baserom.gba", 0x0050dbaf, 0x5 + .byte 0x15, 0x15, 0x16, 0x17, 0x18 gUnknown_0850DBB4:: @ 850DBB4 - .incbin "baserom.gba", 0x50dbb4, 0x5 +@ replacing .incbin "baserom.gba", 0x0050dbb4, 0x5 + .byte 0x29, 0x29, 0x2a, 0x2b, 0x2c gUnknown_0850DBB9:: @ 850DBB9 - .incbin "baserom.gba", 0x50dbb9, 0x5 +@ replacing .incbin "baserom.gba", 0x0050dbb9, 0x5 + .byte 0x2d, 0x2d, 0x2e, 0x2f, 0x30 gUnknown_0850DBBE:: @ 850DBBE - .incbin "baserom.gba", 0x50dbbe, 0x5 +@ replacing .incbin "baserom.gba", 0x0050dbbe, 0x5 + .byte 0x31, 0x31, 0x32, 0x33, 0x34 gUnknown_0850DBC3:: @ 850DBC3 - .incbin "baserom.gba", 0x50dbc3, 0x5 +@ replacing .incbin "baserom.gba", 0x0050dbc3, 0x5 + .byte 0x35, 0x35, 0x36, 0x37, 0x38 gUnknown_0850DBC8:: @ 850DBC8 - .incbin "baserom.gba", 0x50dbc8, 0x5 +@ replacing .incbin "baserom.gba", 0x0050dbc8, 0x5 + .byte 0x0c, 0x0c, 0x0d, 0x0e, 0x0f gUnknown_0850DBCD:: @ 850DBCD - .incbin "baserom.gba", 0x50dbcd, 0x5 +@ replacing .incbin "baserom.gba", 0x0050dbcd, 0x5 + .byte 0x46, 0x46, 0x47, 0x48, 0x49 gUnknown_0850DBD2:: @ 850DBD2 - .incbin "baserom.gba", 0x50dbd2, 0x5 +@ replacing .incbin "baserom.gba", 0x0050dbd2, 0x5 + .byte 0x4b, 0x4b, 0x4a, 0x4d, 0x4c gUnknown_0850DBD7:: @ 850DBD7 - .incbin "baserom.gba", 0x50dbd7, 0x5 +@ replacing .incbin "baserom.gba", 0x0050dbd7, 0x5 + .byte 0x42, 0x42, 0x43, 0x44, 0x45 gUnknown_0850DBDC:: @ 850DBDC - .incbin "baserom.gba", 0x50dbdc, 0x5 +@ replacing .incbin "baserom.gba", 0x0050dbdc, 0x5 + .byte 0x3a, 0x3a, 0x3b, 0x3c, 0x3d gUnknown_0850DBE1:: @ 850DBE1 - .incbin "baserom.gba", 0x50dbe1, 0x5 +@ replacing .incbin "baserom.gba", 0x0050dbe1, 0x5 + .byte 0x19, 0x19, 0x1a, 0x1b, 0x1c gUnknown_0850DBE6:: @ 850DBE6 - .incbin "baserom.gba", 0x50dbe6, 0x5 +@ replacing .incbin "baserom.gba", 0x0050dbe6, 0x5 + .byte 0x1d, 0x1d, 0x1e, 0x1f, 0x20 gUnknown_0850DBEB:: @ 850DBEB - .incbin "baserom.gba", 0x50dbeb, 0x5 +@ replacing .incbin "baserom.gba", 0x0050dbeb, 0x5 + .byte 0x21, 0x21, 0x22, 0x23, 0x24 gUnknown_0850DBF0:: @ 850DBF0 - .incbin "baserom.gba", 0x50dbf0, 0x5 +@ replacing .incbin "baserom.gba", 0x0050dbf0, 0x5 + .byte 0x25, 0x25, 0x26, 0x27, 0x28 gUnknown_0850DBF5:: @ 850DBF5 - .incbin "baserom.gba", 0x50dbf5, 0x5 +@ replacing .incbin "baserom.gba", 0x0050dbf5, 0x5 + .byte 0x64, 0x64, 0x65, 0x66, 0x67 gUnknown_0850DBFA:: @ 850DBFA - .incbin "baserom.gba", 0x50dbfa, 0x5 +@ replacing .incbin "baserom.gba", 0x0050dbfa, 0x5 + .byte 0x68, 0x68, 0x69, 0x6a, 0x6b gUnknown_0850DBFF:: @ 850DBFF - .incbin "baserom.gba", 0x50dbff, 0x5 +@ replacing .incbin "baserom.gba", 0x0050dbff, 0x5 + .byte 0x6c, 0x6c, 0x6d, 0x6e, 0x6f gUnknown_0850DC04:: @ 850DC04 - .incbin "baserom.gba", 0x50dc04, 0x5 +@ replacing .incbin "baserom.gba", 0x0050dc04, 0x5 + .byte 0x70, 0x70, 0x71, 0x72, 0x73 gUnknown_0850DC09:: @ 850DC09 - .incbin "baserom.gba", 0x50dc09, 0x5 +@ replacing .incbin "baserom.gba", 0x0050dc09, 0x5 + .byte 0x74, 0x74, 0x75, 0x76, 0x77 gUnknown_0850DC0E:: @ 850DC0E - .incbin "baserom.gba", 0x50dc0e, 0x5 +@ replacing .incbin "baserom.gba", 0x0050dc0e, 0x5 + .byte 0x78, 0x78, 0x79, 0x7a, 0x7b gUnknown_0850DC13:: @ 850DC13 - .incbin "baserom.gba", 0x50dc13, 0x5 +@ replacing .incbin "baserom.gba", 0x0050dc13, 0x5 + .byte 0x7c, 0x7c, 0x7d, 0x7e, 0x7f gUnknown_0850DC18:: @ 850DC18 - .incbin "baserom.gba", 0x50dc18, 0x5 +@ replacing .incbin "baserom.gba", 0x0050dc18, 0x5 + .byte 0x80, 0x80, 0x81, 0x82, 0x83 gUnknown_0850DC1D:: @ 850DC1D - .incbin "baserom.gba", 0x50dc1d, 0x5 +@ replacing .incbin "baserom.gba", 0x0050dc1d, 0x5 + .byte 0x84, 0x84, 0x85, 0x86, 0x87 gUnknown_0850DC22:: @ 850DC22 - .incbin "baserom.gba", 0x50dc22, 0x5 +@ replacing .incbin "baserom.gba", 0x0050dc22, 0x5 + .byte 0x88, 0x88, 0x89, 0x8a, 0x8b gUnknown_0850DC27:: @ 850DC27 - .incbin "baserom.gba", 0x50dc27, 0x8 +@ replacing .incbin "baserom.gba", 0x0050dc27, 0x8 + .byte 0x02, 0x01, 0x04, 0x03, 0x08, 0x07, 0x06, 0x05 gUnknown_0850DC2F:: @ 850DC2F - .incbin "baserom.gba", 0x50dc2f, 0x10 +@ replacing .incbin "baserom.gba", 0x0050dc2f, 0x10 + .byte 0x02, 0x01, 0x04, 0x03, 0x01, 0x02, 0x03, 0x04, 0x03, 0x04, 0x02, 0x01, 0x04, 0x03, 0x01, 0x02 gUnknown_0850DC3F:: @ 850DC3F - .incbin "baserom.gba", 0x50dc3f, 0x11 +@ replacing .incbin "baserom.gba", 0x0050dc3f, 0x11 + .byte 0x02, 0x01, 0x04, 0x03, 0x01, 0x02, 0x03, 0x04, 0x04, 0x03, 0x01, 0x02, 0x03, 0x04, 0x02, 0x01, 0x00 + .align 2, 0 gUnknown_0850DC50:: @ 850DC50 - .incbin "baserom.gba", 0x50dc50, 0x298 +@ replacing .incbin "baserom.gba", 0x0050dc50, 0x298 + .4byte gUnknown_0850DC50 + 0x278 + .4byte gUnknown_0850DC50 + 0x280 + .4byte gUnknown_0850DC50 + 0x288 + .4byte gUnknown_0850DC50 + 0x290 + .4byte 0x850df2c + .4byte 0x850df38 + .4byte 0x850df44 + .4byte 0x850df50 + .4byte 0x850df8c + .4byte 0x850df98 + .4byte 0x850dfa4 + .4byte 0x850dfb0 + .4byte gUnknown_0850DFC2 + 0x6 + .4byte 0x850dfd4 + .4byte 0x850dfe0 + .4byte 0x850dfec + .4byte 0x850dff8 + .4byte 0x850e004 + .4byte 0x850e010 + .4byte 0x850e01c + .4byte 0x850e028 + .4byte 0x850e034 + .4byte 0x850e040 + .4byte 0x850e04c + .4byte 0x850e058 + .4byte 0x850e064 + .4byte 0x850e070 + .4byte 0x850e07c + .4byte 0x850e088 + .4byte 0x850e094 + .4byte 0x850e0a0 + .4byte 0x850e0ac + .4byte 0x850e0b8 + .4byte 0x850e0c4 + .4byte 0x850e0d0 + .4byte 0x850e0dc + .4byte 0x850e0e8 + .4byte 0x850e0f4 + .4byte 0x850e100 + .4byte 0x850e10c + .4byte 0x850e118 + .4byte 0x850e124 + .4byte 0x850e130 + .4byte 0x850e13c + .4byte 0x850e148 + .4byte 0x850e154 + .4byte 0x850e160 + .4byte 0x850e16c + .4byte 0x850e178 + .4byte 0x850e184 + .4byte 0x850e190 + .4byte 0x850e19c + .4byte 0x850e1a8 + .4byte 0x850e1b4 + .4byte 0x850e1c0 + .4byte 0x850e1cc + .4byte 0x850e1d8 + .4byte 0x850e1e4 + .4byte 0x850e1f0 + .4byte 0x850e1fc + .4byte 0x850e208 + .4byte 0x850e214 + .4byte 0x850e220 + .4byte 0x850e228 + .4byte 0x850e230 + .4byte 0x850e238 + .4byte 0x850e240 + .4byte 0x850e24c + .4byte 0x850e258 + .4byte 0x850e264 + .4byte 0x850e270 + .4byte 0x850e27c + .4byte 0x850e288 + .4byte 0x850e294 + .4byte 0x850e2a0 + .4byte 0x850e2ac + .4byte 0x850e2b8 + .4byte 0x850e2c4 + .4byte 0x850e2d0 + .4byte 0x850e2d8 + .4byte 0x850e2e4 + .4byte 0x850e2ec + .4byte 0x850e2f4 + .4byte 0x850e2fc + .4byte 0x850e304 + .4byte 0x850e30c + .4byte 0x850e314 + .4byte 0x850e31c + .4byte 0x850e324 + .4byte 0x850e32c + .4byte 0x850e338 + .4byte 0x850e348 + .4byte 0x850e358 + .4byte 0x850e360 + .4byte 0x850e368 + .4byte 0x850e370 + .4byte 0x850e378 + .4byte 0x850e380 + .4byte 0x850e388 + .4byte 0x850e394 + .4byte 0x850e3b8 + .4byte 0x850e3c0 + .4byte 0x850e3c8 + .4byte 0x850e3d0 + .4byte 0x850e3d8 + .4byte 0x850e3e4 + .4byte 0x850e3f0 + .4byte 0x850e3fc + .4byte 0x850e408 + .4byte 0x850e414 + .4byte 0x850e420 + .4byte 0x850e42c + .4byte 0x850e474 + .4byte 0x850e480 + .4byte 0x850e48c + .4byte 0x850e498 + .4byte 0x850e4a4 + .4byte 0x850e4b0 + .4byte 0x850e4bc + .4byte 0x850e4c8 + .4byte 0x850e4d4 + .4byte 0x850e4e0 + .4byte 0x850e4ec + .4byte 0x850e4f8 + .4byte 0x850e504 + .4byte 0x850e510 + .4byte 0x850e51c + .4byte 0x850e528 + .4byte 0x850e534 + .4byte 0x850e540 + .4byte 0x850e54c + .4byte 0x850e558 + .4byte 0x850e564 + .4byte 0x850e570 + .4byte 0x850e57c + .4byte 0x850e588 + .4byte 0x850e594 + .4byte 0x850e5a0 + .4byte 0x850e5ac + .4byte 0x850e5b8 + .4byte 0x850df5c + .4byte 0x850df68 + .4byte 0x850df74 + .4byte 0x850df80 + .4byte 0x850defc + .4byte 0x850df08 + .4byte 0x850df14 + .4byte 0x850df20 + .4byte 0x850e854 + .4byte 0x850e85c + .4byte 0x850e3a0 + .4byte 0x850e3ac + .4byte 0x850e5c4 + .4byte 0x850e5cc + .4byte 0x850e5d4 + .4byte 0x850e468 + .4byte 0x850e864 + .4byte 0x850e870 + .4byte sub_8093950 + .4byte sub_80964BC + .4byte sub_8093960 + .4byte sub_80964BC + .4byte sub_8093970 + .4byte sub_80964BC + .4byte sub_8093980 + .4byte sub_80964BC gUnknown_0850DEE8:: @ 850DEE8 - .incbin "baserom.gba", 0x50dee8, 0xd4 +@ replacing .incbin "baserom.gba", 0x0050dee8, 0xd4 + .4byte get_go_image_anim_num + .4byte get_go_fast_image_anim_num + .4byte get_go_fast_image_anim_num + .4byte get_go_faster_image_anim_num + .4byte get_go_fastest_image_anim_num + .4byte sub_8093BC4 + .4byte sub_8093BC4_2 + .4byte sub_80964BC + .4byte sub_8093C04 + .4byte sub_8093C04_2 + .4byte sub_80964BC + .4byte sub_8093C44 + .4byte sub_8093C44_2 + .4byte sub_80964BC + .4byte sub_8093C84 + .4byte sub_8093C84_2 + .4byte sub_80964BC + .4byte sub_8093CC4 + .4byte sub_8093CC4_2 + .4byte sub_80964BC + .4byte sub_8093D04 + .4byte sub_8093D04_2 + .4byte sub_80964BC + .4byte sub_8093D44 + .4byte sub_8093D44_2 + .4byte sub_80964BC + .4byte sub_8093D84 + .4byte sub_8093D84_2 + .4byte sub_80964BC + .4byte sub_8093DC4 + .4byte sub_8093DC4_2 + .4byte sub_80964BC + .4byte sub_8093E04 + .4byte sub_8093E04_2 + .4byte sub_80964BC + .4byte sub_8093E44 + .4byte sub_8093E44_2 + .4byte sub_80964BC + .4byte sub_8093E84 + .4byte sub_8093E84_2 + .4byte sub_80964BC + .4byte sub_8093EC4 + .4byte sub_8093EC4_2 + .4byte sub_80964BC + .4byte sub_8093F04 + .4byte sub_8093F04_2 + .4byte sub_80964BC + .4byte sub_8093F44 + .4byte sub_8093F44_2 + .4byte sub_80964BC + .4byte sub_8093F84 + .4byte sub_8093F84_2 + .4byte sub_80964BC gUnknown_0850DFBC:: @ 850DFBC - .incbin "baserom.gba", 0x50dfbc, 0x6 +@ replacing .incbin "baserom.gba", 0x0050dfbc, 0x6 + .byte 0x00, 0x00, 0x01, 0x00, 0x01, 0x00 gUnknown_0850DFC2:: @ 850DFC2 - .incbin "baserom.gba", 0x50dfc2, 0x6 +@ replacing .incbin "baserom.gba", 0x0050dfc2, 0x6 + .byte 0x00, 0x00, 0x00, 0x00, 0x01, 0x00 gUnknown_0850DFC8:: @ 850DFC8 - .incbin "baserom.gba", 0x50dfc8, 0x614 +@ replacing .incbin "baserom.gba", 0x0050dfc8, 0x614 + .4byte sub_8094230 + .4byte sub_8094230_2 + .4byte sub_80964BC + .4byte sub_8094288 + .4byte sub_8094288_2 + .4byte sub_80964BC + .4byte sub_80942E0 + .4byte sub_80942E0_2 + .4byte sub_80964BC + .4byte sub_8094338 + .4byte sub_8094338_2 + .4byte sub_80964BC + .4byte sub_80943B4 + .4byte sub_8094398 + .4byte sub_80964B8 + .4byte sub_80943D4 + .4byte sub_8094398 + .4byte sub_80964B8 + .4byte sub_80943F4 + .4byte sub_8094398 + .4byte sub_80964B8 + .4byte sub_8094414 + .4byte sub_8094398 + .4byte sub_80964B8 + .4byte sub_8094434 + .4byte sub_8094398 + .4byte sub_80964B8 + .4byte sub_8094454 + .4byte sub_8094454_2 + .4byte sub_80964BC + .4byte sub_8094494 + .4byte sub_8094494_2 + .4byte sub_80964BC + .4byte sub_80944D4 + .4byte sub_80944D4_2 + .4byte sub_80964BC + .4byte sub_8094514 + .4byte sub_8094514_2 + .4byte sub_80964BC + .4byte sub_8094600 + .4byte sub_80945C4 + .4byte sub_80964BC + .4byte sub_8094638 + .4byte sub_80945C4 + .4byte sub_80964BC + .4byte sub_8094670 + .4byte sub_80945C4 + .4byte sub_80964BC + .4byte sub_80946A8 + .4byte sub_80945C4 + .4byte sub_80964BC + .4byte sub_80946E0 + .4byte sub_809459C + .4byte sub_80964BC + .4byte sub_8094718 + .4byte sub_809459C + .4byte sub_80964BC + .4byte sub_8094750 + .4byte sub_809459C + .4byte sub_80964BC + .4byte sub_8094788 + .4byte sub_809459C + .4byte sub_80964BC + .4byte sub_80947C0 + .4byte sub_809459C + .4byte sub_80964BC + .4byte sub_80947F8 + .4byte sub_809459C + .4byte sub_80964BC + .4byte sub_8094830 + .4byte sub_809459C + .4byte sub_80964BC + .4byte sub_8094868 + .4byte sub_809459C + .4byte sub_80964BC + .4byte sub_80948A0 + .4byte sub_809459C + .4byte sub_80964BC + .4byte sub_80948D8 + .4byte sub_809459C + .4byte sub_80964BC + .4byte sub_8094910 + .4byte sub_809459C + .4byte sub_80964BC + .4byte sub_8094948 + .4byte sub_809459C + .4byte sub_80964BC + .4byte sub_8094980 + .4byte sub_8094980_2 + .4byte sub_80964BC + .4byte sub_80949C0 + .4byte sub_80949C0_2 + .4byte sub_80964BC + .4byte sub_8094A00 + .4byte sub_8094A00_2 + .4byte sub_80964BC + .4byte sub_8094A40 + .4byte sub_8094A40_2 + .4byte sub_80964BC + .4byte sub_8094A80 + .4byte sub_8094A80_2 + .4byte sub_80964BC + .4byte sub_8094AC0 + .4byte sub_8094AC0_2 + .4byte sub_80964BC + .4byte sub_8094B00 + .4byte sub_8094B00_2 + .4byte sub_80964BC + .4byte sub_8094B40 + .4byte sub_8094B40_2 + .4byte sub_80964BC + .4byte sub_8094B80 + .4byte sub_8094B80_2 + .4byte sub_80964BC + .4byte sub_8094BC0 + .4byte sub_8094BC0_2 + .4byte sub_80964BC + .4byte sub_8094C00 + .4byte sub_8094C00_2 + .4byte sub_80964BC + .4byte sub_8094C40 + .4byte sub_8094C40_2 + .4byte sub_80964BC + .4byte sub_8094C80 + .4byte sub_8094C80_2 + .4byte sub_80964BC + .4byte sub_8094CC0 + .4byte sub_8094CC0_2 + .4byte sub_80964BC + .4byte sub_8094D00 + .4byte sub_8094D00_2 + .4byte sub_80964BC + .4byte sub_8094D40 + .4byte sub_8094D40_2 + .4byte sub_80964BC + .4byte sub_8094DAC + .4byte sub_8094DC4 + .4byte sub_80964BC + .4byte sub_8094E18 + .4byte sub_8094E18_2 + .4byte sub_80964BC + .4byte sub_8094E60 + .4byte sub_8094E60_2 + .4byte sub_80964BC + .4byte sub_8094EB8 + .4byte sub_8094EB8_2 + .4byte sub_80964BC + .4byte sub_8094710 + .4byte sub_8094710_2 + .4byte sub_80964BC + .4byte sub_8094F38 + .4byte sub_80964BC + .4byte sub_8094F94 + .4byte sub_80964BC + .4byte sub_8094FF8 + .4byte sub_80964BC + .4byte sub_8095008 + .4byte sub_80964BC + .4byte sub_8095018 + .4byte sub_8095018_2 + .4byte sub_80964BC + .4byte sub_8095070 + .4byte sub_8095070_2 + .4byte sub_80964BC + .4byte sub_80950C8 + .4byte sub_80950C8_2 + .4byte sub_80964BC + .4byte sub_8095120 + .4byte sub_8095120_2 + .4byte sub_80964BC + .4byte sub_8095178 + .4byte sub_8095178_2 + .4byte sub_80964BC + .4byte sub_80951D0 + .4byte sub_80951D0_2 + .4byte sub_80964BC + .4byte sub_8095228 + .4byte sub_8095228_2 + .4byte sub_80964BC + .4byte sub_8095280 + .4byte sub_8095280_2 + .4byte sub_80964BC + .4byte sub_80952D8 + .4byte sub_80952D8_2 + .4byte sub_80964BC + .4byte sub_8095330 + .4byte sub_8095330_2 + .4byte sub_80964BC + .4byte sub_8095388 + .4byte sub_8095388_2 + .4byte sub_80964BC + .4byte sub_80953E0 + .4byte sub_80953E0_2 + .4byte sub_80964BC + .4byte sub_8095438 + .4byte sub_80964BC + .4byte sub_8095450 + .4byte sub_8094DC4 + .4byte sub_80964BC + .4byte sub_8095460 + .4byte sub_80964B8 + .4byte sub_8095470 + .4byte sub_80964B8 + .4byte sub_8095480 + .4byte sub_80964B8 + .4byte sub_8095490 + .4byte sub_80964B8 + .4byte sub_80954BC + .4byte sub_80964B8 + .4byte sub_80954CC + .4byte sub_80964B8 + .4byte do_exclamation_mark_bubble_1 + .4byte sub_80964B8 + .4byte do_exclamation_mark_bubble_2 + .4byte sub_80964B8 + .4byte do_heart_bubble + .4byte sub_80964B8 + .4byte sub_8095548 + .4byte sub_809558C + .4byte sub_80964B8 + .4byte sub_80955AC + .4byte sub_80955C8 + .4byte sub_80955EC + .4byte sub_80964B8 + .4byte sub_8095628 + .4byte sub_8095644 + .4byte sub_8095668 + .4byte sub_80964B8 + .4byte sub_80956A4 + .4byte sub_80964B8 + .4byte sub_80956B4 + .4byte sub_80964B8 + .4byte sub_80956C4 + .4byte sub_80964B8 + .4byte sub_80956F4 + .4byte sub_80964B8 + .4byte sub_8095724 + .4byte sub_80964B8 + .4byte sub_8095730 + .4byte sub_80964B8 + .4byte sub_8095740 + .4byte sub_8095740_2 + .4byte sub_80964BC + .4byte sub_80957A0 + .4byte sub_80957A0_2 + .4byte sub_80964BC + .4byte sub_8095800 + .4byte sub_8095800_2 + .4byte sub_80964BC + .4byte sub_8095860 + .4byte sub_8095860_2 + .4byte sub_80964BC + .4byte sub_8095900 + .4byte sub_80964BC + .4byte sub_8095910 + .4byte sub_80964BC + .4byte sub_8095920 + .4byte sub_80964BC + .4byte sub_8095930 + .4byte sub_80964BC + .4byte sub_8095940 + .4byte sub_8094DC4 + .4byte sub_80964BC + .4byte sub_8095964 + .4byte sub_8094DC4 + .4byte sub_80964BC + .4byte sub_8095988 + .4byte sub_8094DC4 + .4byte sub_80964BC + .4byte sub_80959AC + .4byte sub_8094DC4 + .4byte sub_80964BC + .4byte sub_80959D0 + .4byte sub_8094DC4 + .4byte sub_80964BC + .4byte sub_80959F4 + .4byte sub_8094DC4 + .4byte sub_80964BC + .4byte sub_8095A18 + .4byte sub_8094DC4 + .4byte sub_80964BC + .4byte sub_8095A3C + .4byte sub_8094DC4 + .4byte sub_80964BC + .4byte sub_8095A60 + .4byte sub_8094DC4 + .4byte sub_80964BC + .4byte sub_8095A84 + .4byte sub_8094DC4 + .4byte sub_80964BC + .4byte sub_8095AA8 + .4byte sub_8094DC4 + .4byte sub_80964BC + .4byte sub_8095ACC + .4byte sub_8094DC4 + .4byte sub_80964BC + .4byte sub_8095B44 + .4byte sub_8095B64 + .4byte sub_80964BC + .4byte sub_8095BC8 + .4byte sub_8095BC8_2 + .4byte sub_80964BC + .4byte sub_8095C20 + .4byte sub_8095C20_2 + .4byte sub_80964BC + .4byte sub_8095C78 + .4byte sub_8095C78_2 + .4byte sub_80964BC + .4byte sub_8095CD0 + .4byte sub_8095CD0_2 + .4byte sub_80964BC + .4byte sub_8095D28 + .4byte sub_8095D28_2 + .4byte sub_80964BC + .4byte sub_8095D80 + .4byte sub_8095D80_2 + .4byte sub_80964BC + .4byte sub_8095DD8 + .4byte sub_8095DD8_2 + .4byte sub_80964BC + .4byte sub_8095E30 + .4byte sub_8095E30_2 + .4byte sub_80964BC + .4byte sub_8095E88 + .4byte sub_8095E88_2 + .4byte sub_80964BC + .4byte sub_8095EE0 + .4byte sub_8095EE0_2 + .4byte sub_80964BC + .4byte sub_8095F38 + .4byte sub_8095F38_2 + .4byte sub_80964BC + .4byte sub_8095F90 + .4byte sub_8095F90_2 + .4byte sub_80964BC + .4byte sub_8095FE8 + .4byte sub_809459C + .4byte sub_80964BC + .4byte sub_8096020 + .4byte sub_809459C + .4byte sub_80964BC + .4byte sub_8096058 + .4byte sub_809459C + .4byte sub_80964BC + .4byte sub_8096090 + .4byte sub_809459C + .4byte sub_80964BC + .4byte sub_8096100 + .4byte sub_8096100_2 + .4byte sub_80964BC + .4byte sub_8096140 + .4byte sub_8096140_2 + .4byte sub_80964BC + .4byte sub_8096180 + .4byte sub_8096180_2 + .4byte sub_80964BC + .4byte sub_80961C0 + .4byte sub_80961C0_2 + .4byte sub_80964BC + .4byte sub_8096230 + .4byte sub_8096230_2 + .4byte sub_80964BC + .4byte sub_8096270 + .4byte sub_8096270_2 + .4byte sub_80964BC + .4byte sub_80962B0 + .4byte sub_80962B0_2 + .4byte sub_80964BC + .4byte sub_80962F0 + .4byte sub_80962F0_2 + .4byte sub_80964BC + .4byte sub_8096368 + .4byte sub_8096368_2 + .4byte sub_80964BC + .4byte sub_80963A8 + .4byte sub_80963A8_2 + .4byte sub_80964BC + .4byte sub_80963E8 + .4byte sub_80963E8_2 + .4byte sub_80964BC + .4byte sub_8096428 + .4byte sub_8096428_2 + .4byte sub_80964BC + .4byte sub_8096468 + .4byte sub_80964B8 + .4byte sub_809647C + .4byte sub_80964B8 + .4byte sub_8096494 + .4byte sub_80964B8 + diff --git a/src/field_map_obj.c b/src/field_map_obj.c index ed51d5fe8..60e622f28 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -26,24 +26,24 @@ #define NUM_FIELD_MAP_OBJECT_TEMPLATES 0x51 #define null_object_step(name, retval) \ -static bool8 FieldObjectCB2_##name(struct MapObject *, struct Sprite *);\ +bool8 FieldObjectCB2_##name(struct MapObject *, struct Sprite *);\ void FieldObjectCB_##name(struct Sprite *sprite)\ {\ FieldObjectStep(&gMapObjects[sprite->data0], sprite, FieldObjectCB2_##name);\ }\ -static bool8 FieldObjectCB2_##name(struct MapObject *mapObject, struct Sprite *sprite)\ +bool8 FieldObjectCB2_##name(struct MapObject *mapObject, struct Sprite *sprite)\ {\ return (retval);\ } #define field_object_step(name, table) \ extern bool8 (*const (table)[])(struct MapObject *, struct Sprite *);\ -static bool8 FieldObjectCB2_##name(struct MapObject *, struct Sprite *);\ +bool8 FieldObjectCB2_##name(struct MapObject *, struct Sprite *);\ void FieldObjectCB_##name(struct Sprite *sprite)\ {\ FieldObjectStep(&gMapObjects[sprite->data0], sprite, FieldObjectCB2_##name);\ }\ -static bool8 FieldObjectCB2_##name(struct MapObject *mapObject, struct Sprite *sprite)\ +bool8 FieldObjectCB2_##name(struct MapObject *mapObject, struct Sprite *sprite)\ {\ return (table)[sprite->data1](mapObject, sprite);\ } @@ -120,7 +120,8 @@ static void FieldObjectExecSpecialAnim(struct MapObject *, struct Sprite *); static bool8 IsCoordOutsideFieldObjectMovementRect(struct MapObject *, s16, s16); static bool8 IsMetatileDirectionallyImpassable(struct MapObject *, s16, s16, u8); static bool8 CheckForCollisionBetweenFieldObjects(struct MapObject *, s16, s16); -static bool8 sub_809558C(struct MapObject *, struct Sprite *); +bool8 sub_809558C(struct MapObject *, struct Sprite *); +bool8 sub_8095B64(struct MapObject *, struct Sprite *); static void sub_8096530(struct MapObject *, struct Sprite *); static void npc_update_obj_anim_flag(struct MapObject *, struct Sprite *); @@ -4275,13 +4276,13 @@ bool8 an_walk_any_2(struct MapObject *mapObject, struct Sprite *sprite) } #define an_walk_any_2_macro(name, fn1, fn2, ...) \ -static bool8 name##_2(struct MapObject *, struct Sprite *);\ +bool8 name##_2(struct MapObject *, struct Sprite *);\ bool8 name(struct MapObject *mapObject, struct Sprite *sprite)\ {\ fn1(mapObject, sprite, __VA_ARGS__);\ return name##_2(mapObject, sprite);\ }\ -static bool8 name##_2(struct MapObject *mapObject, struct Sprite *sprite)\ +bool8 name##_2(struct MapObject *mapObject, struct Sprite *sprite)\ {\ if (fn2(mapObject, sprite))\ {\ @@ -4405,13 +4406,13 @@ bool8 sub_80941E0(struct MapObject *mapObject, struct Sprite *sprite) } #define maybe_shadow_1_macro(name, fn1, fn2, ...) \ -static bool8 name##_2(struct MapObject *, struct Sprite *);\ +bool8 name##_2(struct MapObject *, struct Sprite *);\ bool8 name(struct MapObject *mapObject, struct Sprite *sprite)\ {\ fn1(mapObject, sprite, __VA_ARGS__);\ return name##_2(mapObject, sprite);\ }\ -static bool8 name##_2(struct MapObject *mapObject, struct Sprite *sprite)\ +bool8 name##_2(struct MapObject *mapObject, struct Sprite *sprite)\ {\ if (fn2(mapObject, sprite))\ {\ @@ -4563,13 +4564,13 @@ void sub_8094DE4(struct MapObject *mapObject, struct Sprite *sprite, u8 directio } #define unk_macro_8094E18(name, direction)\ -static bool8 name##_2(struct MapObject *, struct Sprite *);\ +bool8 name##_2(struct MapObject *, struct Sprite *);\ bool8 name(struct MapObject *mapObject, struct Sprite *sprite)\ {\ sub_8094DE4(mapObject, sprite, direction);\ return name##_2(mapObject, sprite);\ }\ -static bool8 name##_2(struct MapObject *mapObject, struct Sprite *sprite)\ +bool8 name##_2(struct MapObject *mapObject, struct Sprite *sprite)\ {\ if (sub_80941C8(mapObject, sprite))\ {\ @@ -4731,7 +4732,7 @@ bool8 sub_8095548(struct MapObject *mapObject, struct Sprite *sprite) return sub_809558C(mapObject, sprite); } -static bool8 sub_809558C(struct MapObject *mapObject, struct Sprite *sprite) +bool8 sub_809558C(struct MapObject *mapObject, struct Sprite *sprite) { if (sub_8155DA0(mapObject)) { @@ -4841,7 +4842,7 @@ bool8 sub_8095730(struct MapObject *mapObject, struct Sprite *sprite) } #define affine_an_walk_any_2_macro(name, fn, fn2, action, anim, ...)\ -static bool8 name##_2(struct MapObject *, struct Sprite *);\ +bool8 name##_2(struct MapObject *, struct Sprite *);\ bool8 name(struct MapObject *mapObject, struct Sprite *sprite)\ {\ fn(mapObject, sprite, __VA_ARGS__);\ @@ -4849,7 +4850,7 @@ bool8 name(struct MapObject *mapObject, struct Sprite *sprite)\ action(sprite, anim);\ return name##_2(mapObject, sprite);\ }\ -static bool8 name##_2(struct MapObject *mapObject, struct Sprite *sprite)\ +bool8 name##_2(struct MapObject *mapObject, struct Sprite *sprite)\ {\ if (fn2(mapObject, sprite))\ {\ @@ -4936,8 +4937,6 @@ bool8 sub_8095B0C(struct MapObject *mapObject, struct Sprite *sprite) return FALSE; } -static bool8 sub_8095B64(struct MapObject *, struct Sprite *); - bool8 sub_8095B44(struct MapObject *mapObject, struct Sprite *sprite) { sub_8095AF0(mapObject, sprite); @@ -4945,7 +4944,7 @@ bool8 sub_8095B44(struct MapObject *mapObject, struct Sprite *sprite) return sub_8095B64(mapObject, sprite); } -static bool8 sub_8095B64(struct MapObject *mapObject, struct Sprite *sprite) +bool8 sub_8095B64(struct MapObject *mapObject, struct Sprite *sprite) { if (sub_8095B0C(mapObject, sprite)) { From b7a373e700698f638e8fba46b72ec6138d62937e Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 17 Sep 2017 19:35:09 -0400 Subject: [PATCH 189/191] No more incbins --- data/field_map_obj.s | 45 +++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/data/field_map_obj.s b/data/field_map_obj.s index 49fb56a9d..96551b703 100644 --- a/data/field_map_obj.s +++ b/data/field_map_obj.s @@ -268,13 +268,16 @@ gUnknown_0850BBC8:: @ 850BBC8 .align 2, 0 Unknown_0850BCE8:: @ 0850BCE8 - .incbin "baserom.gba", 0x50bce8, 0x08 +@ replacing .incbin "baserom.gba", 0x0050bce8, 0x8 +.2byte 0x1101, 0x1101, 0x1101, 0x1101 Unknown_0850BCF0:: @ 0850BCF0 - .incbin "baserom.gba", 0x50bcf0, 0x08 +@ replacing .incbin "baserom.gba", 0x0050bcf0, 0x8 +.2byte 0x1111, 0x1111, 0x1111, 0x1111 Unknown_0850BCF8:: @ 0850BCF8 - .incbin "baserom.gba", 0x50bcf8, 0x08 +@ replacing .incbin "baserom.gba", 0x0050bcf8, 0x8 +.2byte 0x1115, 0x1115, 0x1115, 0x1115 gUnknown_0850BD00:: @ 850BD00 @ replacing .incbin "baserom.gba", 0x0050bd00, 0x78 @@ -288,37 +291,48 @@ gUnknown_0850BD00:: @ 850BD00 .4byte NULL Unknown_0850BD20:: @ 0850BD20 - .incbin "baserom.gba", 0x50bd20, 0x08 +@ replacing .incbin "baserom.gba", 0x0050bd20, 0x8 +.2byte 0x110c, 0x110c, 0x110c, 0x110c Unknown_0850BD28:: @ 0x0850bd28 - .incbin "baserom.gba", 0x50bd28, 0x08 +@ replacing .incbin "baserom.gba", 0x0050bd28, 0x8 +.2byte 0x110d, 0x110d, 0x110d, 0x110d Unknown_0850BD30:: @ 0x0850bd30 - .incbin "baserom.gba", 0x50bd30, 0x08 +@ replacing .incbin "baserom.gba", 0x0050bd30, 0x8 +.2byte 0x110e, 0x110e, 0x110e, 0x110e Unknown_0850BD38:: @ 0x0850bd38 - .incbin "baserom.gba", 0x50bd38, 0x08 +@ replacing .incbin "baserom.gba", 0x0050bd38, 0x8 +.2byte 0x1112, 0x1112, 0x1112, 0x1112 Unknown_0850BD40:: @ 0x0850bd40 - .incbin "baserom.gba", 0x50bd40, 0x08 +@ replacing .incbin "baserom.gba", 0x0050bd40, 0x8 +.2byte 0x1113, 0x1113, 0x1113, 0x1113 Unknown_0850BD48:: @ 0x0850bd48 - .incbin "baserom.gba", 0x50bd48, 0x08 +@ replacing .incbin "baserom.gba", 0x0050bd48, 0x8 +.2byte 0x1114, 0x1114, 0x1114, 0x1114 Unknown_0850BD50:: @ 0x0850bd50 - .incbin "baserom.gba", 0x50bd50, 0x08 +@ replacing .incbin "baserom.gba", 0x0050bd50, 0x8 +.2byte 0x111b, 0x111b, 0x111b, 0x111b Unknown_0850BD58:: @ 0x0850bd58 - .incbin "baserom.gba", 0x50bd58, 0x08 +@ replacing .incbin "baserom.gba", 0x0050bd58, 0x8 +.2byte 0x1117, 0x1117, 0x1117, 0x1117 Unknown_0850BD60:: @ 0x0850bd60 - .incbin "baserom.gba", 0x50bd60, 0x08 +@ replacing .incbin "baserom.gba", 0x0050bd60, 0x8 +.2byte 0x1119, 0x1119, 0x1119, 0x1119 Unknown_0850BD68:: @ 0x0850bd68 - .incbin "baserom.gba", 0x50bd68, 0x08 +@ replacing .incbin "baserom.gba", 0x0050bd68, 0x8 +.2byte 0x1109, 0x1109, 0x1109, 0x1109 Unknown_0850BD70:: @ 0x0850bd70 - .incbin "baserom.gba", 0x50bd70, 0x08 +@ replacing .incbin "baserom.gba", 0x0050bd70, 0x8 +.2byte 0x111d, 0x111d, 0x111d, 0x111d gUnknown_0850BD78:: @ 850BD78 @ replacing .incbin "baserom.gba", 0x0050bd78, 0xc0 @@ -1724,6 +1738,3 @@ gUnknown_0850DFC8:: @ 850DFC8 .4byte sub_80964B8 .4byte sub_8096494 .4byte sub_80964B8 - - - From 25c7b4cd9243bb32e7d5ebd90d629acf91706133 Mon Sep 17 00:00:00 2001 From: scnorton Date: Sun, 17 Sep 2017 20:08:29 -0400 Subject: [PATCH 190/191] Remaining pointers --- data/data3.s | 10 +- data/field_map_obj.s | 497 ++++++++++++++++++++++++++++--------------- 2 files changed, 339 insertions(+), 168 deletions(-) diff --git a/data/data3.s b/data/data3.s index ec29349bd..1d4dc544c 100644 --- a/data/data3.s +++ b/data/data3.s @@ -694,7 +694,15 @@ gUnknown_0850E84A:: @ 850E84A .incbin "baserom.gba", 0x50e84a, 0x6 gUnknown_0850E850:: @ 850E850 - .incbin "baserom.gba", 0x50e850, 0x2c + .incbin "baserom.gba", 0x50e850, 0x4 +gUnknown_0850E854:: + .incbin "baserom.gba", 0x50e854, 0x8 +gUnknown_0850E85C:: + .incbin "baserom.gba", 0x50e85C, 0x8 +gUnknown_0850E864:: + .incbin "baserom.gba", 0x50e864, 0xc +gUnknown_0850E870:: + .incbin "baserom.gba", 0x50e870, 0xc gUnknown_0850E87C:: @ 850E87C .incbin "baserom.gba", 0x50e87c, 0x1680 diff --git a/data/field_map_obj.s b/data/field_map_obj.s index 96551b703..52b39f932 100644 --- a/data/field_map_obj.s +++ b/data/field_map_obj.s @@ -367,16 +367,20 @@ gUnknown_0850BD78:: @ 850BD78 gUnknown_0850BDE8:: @ 850BDE8 @ replacing .incbin "baserom.gba", 0x0050bde8, 0x50 - .2byte 0x1100, 0x1101, 0x1103, 0x1104, 0x1105, 0x1106, 0x1107, 0x1108, 0x1109, 0x110a, 0x1100, 0x1101, 0x1103, 0x1104, 0x1105, 0x1106 - .2byte 0x1107, 0x1108, 0x1109, 0x110a, 0x1100, 0x1101, 0x1103, 0x1104, 0x1105, 0x1106, 0x1107, 0x1108, 0x1109, 0x110a, 0x1100, 0x1101 - .2byte 0x1103, 0x1104, 0x1105, 0x1106, 0x1107, 0x1108, 0x1109, 0x110a + .2byte 0x1100, 0x1101, 0x1103, 0x1104, 0x1105, 0x1106, 0x1107, 0x1108, 0x1109, 0x110a +gUnknown_0850BDFC:: + .2byte 0x1100, 0x1101, 0x1103, 0x1104, 0x1105, 0x1106, 0x1107, 0x1108, 0x1109, 0x110a +gUnknown_0850BE10:: + .2byte 0x1100, 0x1101, 0x1103, 0x1104, 0x1105, 0x1106, 0x1107, 0x1108, 0x1109, 0x110a +gUnknown_0850BE24:: + .2byte 0x1100, 0x1101, 0x1103, 0x1104, 0x1105, 0x1106, 0x1107, 0x1108, 0x1109, 0x110a gUnknown_0850BE38:: @ 850BE38 @ replacing .incbin "baserom.gba", 0x0050be38, 0x10 - .4byte 0x850bde8 - .4byte 0x850bdfc - .4byte 0x850be10 - .4byte 0x850be24 + .4byte gUnknown_0850BDE8 + .4byte gUnknown_0850BDFC + .4byte gUnknown_0850BE10 + .4byte gUnknown_0850BE24 @ 850BE48 .include "data/graphics/field_objects/berry_tree_graphics_tables.inc" @@ -386,7 +390,7 @@ gUnknown_0850BE38:: @ 850BE38 @ replacing .incbin "baserom.gba", 0x0050d6d4, 0x8 .align 2, 0 - .4byte 0x084ad8f8 + .4byte gFieldObjectPalette2 .2byte 4113 .align 2, 0 @@ -1115,171 +1119,179 @@ gUnknown_0850DC3F:: @ 850DC3F .align 2, 0 gUnknown_0850DC50:: @ 850DC50 -@ replacing .incbin "baserom.gba", 0x0050dc50, 0x298 - .4byte gUnknown_0850DC50 + 0x278 - .4byte gUnknown_0850DC50 + 0x280 - .4byte gUnknown_0850DC50 + 0x288 - .4byte gUnknown_0850DC50 + 0x290 - .4byte 0x850df2c - .4byte 0x850df38 - .4byte 0x850df44 - .4byte 0x850df50 - .4byte 0x850df8c - .4byte 0x850df98 - .4byte 0x850dfa4 - .4byte 0x850dfb0 - .4byte gUnknown_0850DFC2 + 0x6 - .4byte 0x850dfd4 - .4byte 0x850dfe0 - .4byte 0x850dfec - .4byte 0x850dff8 - .4byte 0x850e004 - .4byte 0x850e010 - .4byte 0x850e01c - .4byte 0x850e028 - .4byte 0x850e034 - .4byte 0x850e040 - .4byte 0x850e04c - .4byte 0x850e058 - .4byte 0x850e064 - .4byte 0x850e070 - .4byte 0x850e07c - .4byte 0x850e088 - .4byte 0x850e094 - .4byte 0x850e0a0 - .4byte 0x850e0ac - .4byte 0x850e0b8 - .4byte 0x850e0c4 - .4byte 0x850e0d0 - .4byte 0x850e0dc - .4byte 0x850e0e8 - .4byte 0x850e0f4 - .4byte 0x850e100 - .4byte 0x850e10c - .4byte 0x850e118 - .4byte 0x850e124 - .4byte 0x850e130 - .4byte 0x850e13c - .4byte 0x850e148 - .4byte 0x850e154 - .4byte 0x850e160 - .4byte 0x850e16c - .4byte 0x850e178 - .4byte 0x850e184 - .4byte 0x850e190 - .4byte 0x850e19c - .4byte 0x850e1a8 - .4byte 0x850e1b4 - .4byte 0x850e1c0 - .4byte 0x850e1cc - .4byte 0x850e1d8 - .4byte 0x850e1e4 - .4byte 0x850e1f0 - .4byte 0x850e1fc - .4byte 0x850e208 - .4byte 0x850e214 - .4byte 0x850e220 - .4byte 0x850e228 - .4byte 0x850e230 - .4byte 0x850e238 - .4byte 0x850e240 - .4byte 0x850e24c - .4byte 0x850e258 - .4byte 0x850e264 - .4byte 0x850e270 - .4byte 0x850e27c - .4byte 0x850e288 - .4byte 0x850e294 - .4byte 0x850e2a0 - .4byte 0x850e2ac - .4byte 0x850e2b8 - .4byte 0x850e2c4 - .4byte 0x850e2d0 - .4byte 0x850e2d8 - .4byte 0x850e2e4 - .4byte 0x850e2ec - .4byte 0x850e2f4 - .4byte 0x850e2fc - .4byte 0x850e304 - .4byte 0x850e30c - .4byte 0x850e314 - .4byte 0x850e31c - .4byte 0x850e324 - .4byte 0x850e32c - .4byte 0x850e338 - .4byte 0x850e348 - .4byte 0x850e358 - .4byte 0x850e360 - .4byte 0x850e368 - .4byte 0x850e370 - .4byte 0x850e378 - .4byte 0x850e380 - .4byte 0x850e388 - .4byte 0x850e394 - .4byte 0x850e3b8 - .4byte 0x850e3c0 - .4byte 0x850e3c8 - .4byte 0x850e3d0 - .4byte 0x850e3d8 - .4byte 0x850e3e4 - .4byte 0x850e3f0 - .4byte 0x850e3fc - .4byte 0x850e408 - .4byte 0x850e414 - .4byte 0x850e420 - .4byte 0x850e42c - .4byte 0x850e474 - .4byte 0x850e480 - .4byte 0x850e48c - .4byte 0x850e498 - .4byte 0x850e4a4 - .4byte 0x850e4b0 - .4byte 0x850e4bc - .4byte 0x850e4c8 - .4byte 0x850e4d4 - .4byte 0x850e4e0 - .4byte 0x850e4ec - .4byte 0x850e4f8 - .4byte 0x850e504 - .4byte 0x850e510 - .4byte 0x850e51c - .4byte 0x850e528 - .4byte 0x850e534 - .4byte 0x850e540 - .4byte 0x850e54c - .4byte 0x850e558 - .4byte 0x850e564 - .4byte 0x850e570 - .4byte 0x850e57c - .4byte 0x850e588 - .4byte 0x850e594 - .4byte 0x850e5a0 - .4byte 0x850e5ac - .4byte 0x850e5b8 - .4byte 0x850df5c - .4byte 0x850df68 - .4byte 0x850df74 - .4byte 0x850df80 - .4byte 0x850defc - .4byte 0x850df08 - .4byte 0x850df14 - .4byte 0x850df20 - .4byte 0x850e854 - .4byte 0x850e85c - .4byte 0x850e3a0 - .4byte 0x850e3ac - .4byte 0x850e5c4 - .4byte 0x850e5cc - .4byte 0x850e5d4 - .4byte 0x850e468 - .4byte 0x850e864 - .4byte 0x850e870 +@ replacing .incbin "baserom.gba", 0x0050dc50, 0x278 +.4byte gUnknown_0850DEC8 +.4byte gUnknown_0850DED0 +.4byte gUnknown_0850DED8 +.4byte gUnknown_0850DEE0 +.4byte gUnknown_0850DF2C +.4byte gUnknown_0850DF38 +.4byte gUnknown_0850DF44 +.4byte gUnknown_0850DF50 +.4byte gUnknown_0850DF8C +.4byte gUnknown_0850DF98 +.4byte gUnknown_0850DFA4 +.4byte gUnknown_0850DFB0 +.4byte gUnknown_0850DFC8 +.4byte gUnknown_0850DFD4 +.4byte gUnknown_0850DFE0 +.4byte gUnknown_0850DFEC +.4byte gUnknown_0850DFF8 +.4byte gUnknown_0850E004 +.4byte gUnknown_0850E010 +.4byte gUnknown_0850E01C +.4byte gUnknown_0850E028 +.4byte gUnknown_0850E034 +.4byte gUnknown_0850E040 +.4byte gUnknown_0850E04C +.4byte gUnknown_0850E058 +.4byte gUnknown_0850E064 +.4byte gUnknown_0850E070 +.4byte gUnknown_0850E07C +.4byte gUnknown_0850E088 +.4byte gUnknown_0850E094 +.4byte gUnknown_0850E0A0 +.4byte gUnknown_0850E0AC +.4byte gUnknown_0850E0B8 +.4byte gUnknown_0850E0C4 +.4byte gUnknown_0850E0D0 +.4byte gUnknown_0850E0DC +.4byte gUnknown_0850E0E8 +.4byte gUnknown_0850E0F4 +.4byte gUnknown_0850E100 +.4byte gUnknown_0850E10C +.4byte gUnknown_0850E118 +.4byte gUnknown_0850E124 +.4byte gUnknown_0850E130 +.4byte gUnknown_0850E13C +.4byte gUnknown_0850E148 +.4byte gUnknown_0850E154 +.4byte gUnknown_0850E160 +.4byte gUnknown_0850E16C +.4byte gUnknown_0850E178 +.4byte gUnknown_0850E184 +.4byte gUnknown_0850E190 +.4byte gUnknown_0850E19C +.4byte gUnknown_0850E1A8 +.4byte gUnknown_0850E1B4 +.4byte gUnknown_0850E1C0 +.4byte gUnknown_0850E1CC +.4byte gUnknown_0850E1D8 +.4byte gUnknown_0850E1E4 +.4byte gUnknown_0850E1F0 +.4byte gUnknown_0850E1FC +.4byte gUnknown_0850E208 +.4byte gUnknown_0850E214 +.4byte gUnknown_0850E220 +.4byte gUnknown_0850E228 +.4byte gUnknown_0850E230 +.4byte gUnknown_0850E238 +.4byte gUnknown_0850E240 +.4byte gUnknown_0850E24C +.4byte gUnknown_0850E258 +.4byte gUnknown_0850E264 +.4byte gUnknown_0850E270 +.4byte gUnknown_0850E27C +.4byte gUnknown_0850E288 +.4byte gUnknown_0850E294 +.4byte gUnknown_0850E2A0 +.4byte gUnknown_0850E2AC +.4byte gUnknown_0850E2B8 +.4byte gUnknown_0850E2C4 +.4byte gUnknown_0850E2D0 +.4byte gUnknown_0850E2D8 +.4byte gUnknown_0850E2E4 +.4byte gUnknown_0850E2EC +.4byte gUnknown_0850E2F4 +.4byte gUnknown_0850E2FC +.4byte gUnknown_0850E304 +.4byte gUnknown_0850E30C +.4byte gUnknown_0850E314 +.4byte gUnknown_0850E31C +.4byte gUnknown_0850E324 +.4byte gUnknown_0850E32C +.4byte gUnknown_0850E338 +.4byte gUnknown_0850E348 +.4byte gUnknown_0850E358 +.4byte gUnknown_0850E360 +.4byte gUnknown_0850E368 +.4byte gUnknown_0850E370 +.4byte gUnknown_0850E378 +.4byte gUnknown_0850E380 +.4byte gUnknown_0850E388 +.4byte gUnknown_0850E394 +.4byte gUnknown_0850E3B8 +.4byte gUnknown_0850E3C0 +.4byte gUnknown_0850E3C8 +.4byte gUnknown_0850E3D0 +.4byte gUnknown_0850E3D8 +.4byte gUnknown_0850E3E4 +.4byte gUnknown_0850E3F0 +.4byte gUnknown_0850E3FC +.4byte gUnknown_0850E408 +.4byte gUnknown_0850E414 +.4byte gUnknown_0850E420 +.4byte gUnknown_0850E42C +.4byte gUnknown_0850E474 +.4byte gUnknown_0850E480 +.4byte gUnknown_0850E48C +.4byte gUnknown_0850E498 +.4byte gUnknown_0850E4A4 +.4byte gUnknown_0850E4B0 +.4byte gUnknown_0850E4BC +.4byte gUnknown_0850E4C8 +.4byte gUnknown_0850E4D4 +.4byte gUnknown_0850E4E0 +.4byte gUnknown_0850E4EC +.4byte gUnknown_0850E4F8 +.4byte gUnknown_0850E504 +.4byte gUnknown_0850E510 +.4byte gUnknown_0850E51C +.4byte gUnknown_0850E528 +.4byte gUnknown_0850E534 +.4byte gUnknown_0850E540 +.4byte gUnknown_0850E54C +.4byte gUnknown_0850E558 +.4byte gUnknown_0850E564 +.4byte gUnknown_0850E570 +.4byte gUnknown_0850E57C +.4byte gUnknown_0850E588 +.4byte gUnknown_0850E594 +.4byte gUnknown_0850E5A0 +.4byte gUnknown_0850E5AC +.4byte gUnknown_0850E5B8 +.4byte gUnknown_0850DF5C +.4byte gUnknown_0850DF68 +.4byte gUnknown_0850DF74 +.4byte gUnknown_0850DF80 +.4byte gUnknown_0850DEFC +.4byte gUnknown_0850DF08 +.4byte gUnknown_0850DF14 +.4byte gUnknown_0850DF20 +.4byte gUnknown_0850E854 +.4byte gUnknown_0850E85C +.4byte gUnknown_0850E3A0 +.4byte gUnknown_0850E3AC +.4byte gUnknown_0850E5C4 +.4byte gUnknown_0850E5CC +.4byte gUnknown_0850E5D4 +.4byte gUnknown_0850E468 +.4byte gUnknown_0850E864 +.4byte gUnknown_0850E870 + +gUnknown_0850DEC8:: @ 850DEC8 .4byte sub_8093950 .4byte sub_80964BC + +gUnknown_0850DED0:: .4byte sub_8093960 .4byte sub_80964BC + +gUnknown_0850DED8:: .4byte sub_8093970 .4byte sub_80964BC + +gUnknown_0850DEE0:: .4byte sub_8093980 .4byte sub_80964BC @@ -1290,51 +1302,68 @@ gUnknown_0850DEE8:: @ 850DEE8 .4byte get_go_fast_image_anim_num .4byte get_go_faster_image_anim_num .4byte get_go_fastest_image_anim_num + +gUnknown_0850DEFC:: .4byte sub_8093BC4 .4byte sub_8093BC4_2 .4byte sub_80964BC +gUnknown_0850DF08:: .4byte sub_8093C04 .4byte sub_8093C04_2 .4byte sub_80964BC +gUnknown_0850DF14:: .4byte sub_8093C44 .4byte sub_8093C44_2 .4byte sub_80964BC +gUnknown_0850DF20:: .4byte sub_8093C84 .4byte sub_8093C84_2 .4byte sub_80964BC +gUnknown_0850DF2C:: .4byte sub_8093CC4 .4byte sub_8093CC4_2 .4byte sub_80964BC +gUnknown_0850DF38:: .4byte sub_8093D04 .4byte sub_8093D04_2 .4byte sub_80964BC +gUnknown_0850DF44:: .4byte sub_8093D44 .4byte sub_8093D44_2 .4byte sub_80964BC +gUnknown_0850DF50:: .4byte sub_8093D84 .4byte sub_8093D84_2 .4byte sub_80964BC +gUnknown_0850DF5C:: .4byte sub_8093DC4 .4byte sub_8093DC4_2 .4byte sub_80964BC +gUnknown_0850DF68:: .4byte sub_8093E04 .4byte sub_8093E04_2 .4byte sub_80964BC +gUnknown_0850DF74:: .4byte sub_8093E44 .4byte sub_8093E44_2 .4byte sub_80964BC +gUnknown_0850DF80:: .4byte sub_8093E84 .4byte sub_8093E84_2 .4byte sub_80964BC +gUnknown_0850DF8C:: .4byte sub_8093EC4 .4byte sub_8093EC4_2 .4byte sub_80964BC +gUnknown_0850DF98:: .4byte sub_8093F04 .4byte sub_8093F04_2 .4byte sub_80964BC +gUnknown_0850DFA4:: .4byte sub_8093F44 .4byte sub_8093F44_2 .4byte sub_80964BC +gUnknown_0850DFB0:: .4byte sub_8093F84 .4byte sub_8093F84_2 .4byte sub_80964BC @@ -1352,284 +1381,385 @@ gUnknown_0850DFC8:: @ 850DFC8 .4byte sub_8094230 .4byte sub_8094230_2 .4byte sub_80964BC +gUnknown_0850DFD4:: .4byte sub_8094288 .4byte sub_8094288_2 .4byte sub_80964BC +gUnknown_0850DFE0:: .4byte sub_80942E0 .4byte sub_80942E0_2 .4byte sub_80964BC +gUnknown_0850DFEC:: .4byte sub_8094338 .4byte sub_8094338_2 .4byte sub_80964BC +gUnknown_0850DFF8:: .4byte sub_80943B4 .4byte sub_8094398 .4byte sub_80964B8 +gUnknown_0850E004:: .4byte sub_80943D4 .4byte sub_8094398 .4byte sub_80964B8 +gUnknown_0850E010:: .4byte sub_80943F4 .4byte sub_8094398 .4byte sub_80964B8 +gUnknown_0850E01C:: .4byte sub_8094414 .4byte sub_8094398 .4byte sub_80964B8 +gUnknown_0850E028:: .4byte sub_8094434 .4byte sub_8094398 .4byte sub_80964B8 +gUnknown_0850E034:: .4byte sub_8094454 .4byte sub_8094454_2 .4byte sub_80964BC +gUnknown_0850E040:: .4byte sub_8094494 .4byte sub_8094494_2 .4byte sub_80964BC +gUnknown_0850E04C:: .4byte sub_80944D4 .4byte sub_80944D4_2 .4byte sub_80964BC +gUnknown_0850E058:: .4byte sub_8094514 .4byte sub_8094514_2 .4byte sub_80964BC +gUnknown_0850E064:: .4byte sub_8094600 .4byte sub_80945C4 .4byte sub_80964BC +gUnknown_0850E070:: .4byte sub_8094638 .4byte sub_80945C4 .4byte sub_80964BC +gUnknown_0850E07C:: .4byte sub_8094670 .4byte sub_80945C4 .4byte sub_80964BC +gUnknown_0850E088:: .4byte sub_80946A8 .4byte sub_80945C4 .4byte sub_80964BC +gUnknown_0850E094:: .4byte sub_80946E0 .4byte sub_809459C .4byte sub_80964BC +gUnknown_0850E0A0:: .4byte sub_8094718 .4byte sub_809459C .4byte sub_80964BC +gUnknown_0850E0AC:: .4byte sub_8094750 .4byte sub_809459C .4byte sub_80964BC +gUnknown_0850E0B8:: .4byte sub_8094788 .4byte sub_809459C .4byte sub_80964BC +gUnknown_0850E0C4:: .4byte sub_80947C0 .4byte sub_809459C .4byte sub_80964BC +gUnknown_0850E0D0:: .4byte sub_80947F8 .4byte sub_809459C .4byte sub_80964BC +gUnknown_0850E0DC:: .4byte sub_8094830 .4byte sub_809459C .4byte sub_80964BC +gUnknown_0850E0E8:: .4byte sub_8094868 .4byte sub_809459C .4byte sub_80964BC +gUnknown_0850E0F4:: .4byte sub_80948A0 .4byte sub_809459C .4byte sub_80964BC +gUnknown_0850E100:: .4byte sub_80948D8 .4byte sub_809459C .4byte sub_80964BC +gUnknown_0850E10C:: .4byte sub_8094910 .4byte sub_809459C .4byte sub_80964BC +gUnknown_0850E118:: .4byte sub_8094948 .4byte sub_809459C .4byte sub_80964BC +gUnknown_0850E124:: .4byte sub_8094980 .4byte sub_8094980_2 .4byte sub_80964BC +gUnknown_0850E130:: .4byte sub_80949C0 .4byte sub_80949C0_2 .4byte sub_80964BC +gUnknown_0850E13C:: .4byte sub_8094A00 .4byte sub_8094A00_2 .4byte sub_80964BC +gUnknown_0850E148:: .4byte sub_8094A40 .4byte sub_8094A40_2 .4byte sub_80964BC +gUnknown_0850E154:: .4byte sub_8094A80 .4byte sub_8094A80_2 .4byte sub_80964BC +gUnknown_0850E160:: .4byte sub_8094AC0 .4byte sub_8094AC0_2 .4byte sub_80964BC +gUnknown_0850E16C:: .4byte sub_8094B00 .4byte sub_8094B00_2 .4byte sub_80964BC +gUnknown_0850E178:: .4byte sub_8094B40 .4byte sub_8094B40_2 .4byte sub_80964BC +gUnknown_0850E184:: .4byte sub_8094B80 .4byte sub_8094B80_2 .4byte sub_80964BC +gUnknown_0850E190:: .4byte sub_8094BC0 .4byte sub_8094BC0_2 .4byte sub_80964BC +gUnknown_0850E19C:: .4byte sub_8094C00 .4byte sub_8094C00_2 .4byte sub_80964BC +gUnknown_0850E1A8:: .4byte sub_8094C40 .4byte sub_8094C40_2 .4byte sub_80964BC +gUnknown_0850E1B4:: .4byte sub_8094C80 .4byte sub_8094C80_2 .4byte sub_80964BC +gUnknown_0850E1C0:: .4byte sub_8094CC0 .4byte sub_8094CC0_2 .4byte sub_80964BC +gUnknown_0850E1CC:: .4byte sub_8094D00 .4byte sub_8094D00_2 .4byte sub_80964BC +gUnknown_0850E1D8:: .4byte sub_8094D40 .4byte sub_8094D40_2 .4byte sub_80964BC +gUnknown_0850E1E4:: .4byte sub_8094DAC .4byte sub_8094DC4 .4byte sub_80964BC +gUnknown_0850E1F0:: .4byte sub_8094E18 .4byte sub_8094E18_2 .4byte sub_80964BC +gUnknown_0850E1FC:: .4byte sub_8094E60 .4byte sub_8094E60_2 .4byte sub_80964BC +gUnknown_0850E208:: .4byte sub_8094EB8 .4byte sub_8094EB8_2 .4byte sub_80964BC +gUnknown_0850E214:: .4byte sub_8094710 .4byte sub_8094710_2 .4byte sub_80964BC +gUnknown_0850E220:: .4byte sub_8094F38 .4byte sub_80964BC +gUnknown_0850E228:: .4byte sub_8094F94 .4byte sub_80964BC +gUnknown_0850E230:: .4byte sub_8094FF8 .4byte sub_80964BC +gUnknown_0850E238:: .4byte sub_8095008 .4byte sub_80964BC +gUnknown_0850E240:: .4byte sub_8095018 .4byte sub_8095018_2 .4byte sub_80964BC +gUnknown_0850E24C:: .4byte sub_8095070 .4byte sub_8095070_2 .4byte sub_80964BC +gUnknown_0850E258:: .4byte sub_80950C8 .4byte sub_80950C8_2 .4byte sub_80964BC +gUnknown_0850E264:: .4byte sub_8095120 .4byte sub_8095120_2 .4byte sub_80964BC +gUnknown_0850E270:: .4byte sub_8095178 .4byte sub_8095178_2 .4byte sub_80964BC +gUnknown_0850E27C:: .4byte sub_80951D0 .4byte sub_80951D0_2 .4byte sub_80964BC +gUnknown_0850E288:: .4byte sub_8095228 .4byte sub_8095228_2 .4byte sub_80964BC +gUnknown_0850E294:: .4byte sub_8095280 .4byte sub_8095280_2 .4byte sub_80964BC +gUnknown_0850E2A0:: .4byte sub_80952D8 .4byte sub_80952D8_2 .4byte sub_80964BC +gUnknown_0850E2AC:: .4byte sub_8095330 .4byte sub_8095330_2 .4byte sub_80964BC +gUnknown_0850E2B8:: .4byte sub_8095388 .4byte sub_8095388_2 .4byte sub_80964BC +gUnknown_0850E2C4:: .4byte sub_80953E0 .4byte sub_80953E0_2 .4byte sub_80964BC +gUnknown_0850E2D0:: .4byte sub_8095438 .4byte sub_80964BC +gUnknown_0850E2D8:: .4byte sub_8095450 .4byte sub_8094DC4 .4byte sub_80964BC +gUnknown_0850E2E4:: .4byte sub_8095460 .4byte sub_80964B8 +gUnknown_0850E2EC:: .4byte sub_8095470 .4byte sub_80964B8 +gUnknown_0850E2F4:: .4byte sub_8095480 .4byte sub_80964B8 +gUnknown_0850E2FC:: .4byte sub_8095490 .4byte sub_80964B8 +gUnknown_0850E304:: .4byte sub_80954BC .4byte sub_80964B8 +gUnknown_0850E30C:: .4byte sub_80954CC .4byte sub_80964B8 +gUnknown_0850E314:: .4byte do_exclamation_mark_bubble_1 .4byte sub_80964B8 +gUnknown_0850E31C:: .4byte do_exclamation_mark_bubble_2 .4byte sub_80964B8 +gUnknown_0850E324:: .4byte do_heart_bubble .4byte sub_80964B8 +gUnknown_0850E32C:: .4byte sub_8095548 .4byte sub_809558C .4byte sub_80964B8 +gUnknown_0850E338:: .4byte sub_80955AC .4byte sub_80955C8 .4byte sub_80955EC .4byte sub_80964B8 +gUnknown_0850E348:: .4byte sub_8095628 .4byte sub_8095644 .4byte sub_8095668 .4byte sub_80964B8 +gUnknown_0850E358:: .4byte sub_80956A4 .4byte sub_80964B8 +gUnknown_0850E360:: .4byte sub_80956B4 .4byte sub_80964B8 +gUnknown_0850E368:: .4byte sub_80956C4 .4byte sub_80964B8 +gUnknown_0850E370:: .4byte sub_80956F4 .4byte sub_80964B8 +gUnknown_0850E378:: .4byte sub_8095724 .4byte sub_80964B8 +gUnknown_0850E380:: .4byte sub_8095730 .4byte sub_80964B8 +gUnknown_0850E388:: .4byte sub_8095740 .4byte sub_8095740_2 .4byte sub_80964BC +gUnknown_0850E394:: .4byte sub_80957A0 .4byte sub_80957A0_2 .4byte sub_80964BC +gUnknown_0850E3A0:: .4byte sub_8095800 .4byte sub_8095800_2 .4byte sub_80964BC +gUnknown_0850E3AC:: .4byte sub_8095860 .4byte sub_8095860_2 .4byte sub_80964BC +gUnknown_0850E3B8:: .4byte sub_8095900 .4byte sub_80964BC +gUnknown_0850E3C0:: .4byte sub_8095910 .4byte sub_80964BC +gUnknown_0850E3C8:: .4byte sub_8095920 .4byte sub_80964BC +gUnknown_0850E3D0:: .4byte sub_8095930 .4byte sub_80964BC +gUnknown_0850E3D8:: .4byte sub_8095940 .4byte sub_8094DC4 .4byte sub_80964BC +gUnknown_0850E3E4:: .4byte sub_8095964 .4byte sub_8094DC4 .4byte sub_80964BC +gUnknown_0850E3F0:: .4byte sub_8095988 .4byte sub_8094DC4 .4byte sub_80964BC +gUnknown_0850E3FC:: .4byte sub_80959AC .4byte sub_8094DC4 .4byte sub_80964BC +gUnknown_0850E408:: .4byte sub_80959D0 .4byte sub_8094DC4 .4byte sub_80964BC +gUnknown_0850E414:: .4byte sub_80959F4 .4byte sub_8094DC4 .4byte sub_80964BC +gUnknown_0850E420:: .4byte sub_8095A18 .4byte sub_8094DC4 .4byte sub_80964BC +gUnknown_0850E42C:: .4byte sub_8095A3C .4byte sub_8094DC4 .4byte sub_80964BC @@ -1645,96 +1775,129 @@ gUnknown_0850DFC8:: @ 850DFC8 .4byte sub_8095ACC .4byte sub_8094DC4 .4byte sub_80964BC +gUnknown_0850E468:: .4byte sub_8095B44 .4byte sub_8095B64 .4byte sub_80964BC +gUnknown_0850E474:: .4byte sub_8095BC8 .4byte sub_8095BC8_2 .4byte sub_80964BC +gUnknown_0850E480:: .4byte sub_8095C20 .4byte sub_8095C20_2 .4byte sub_80964BC +gUnknown_0850E48C:: .4byte sub_8095C78 .4byte sub_8095C78_2 .4byte sub_80964BC +gUnknown_0850E498:: .4byte sub_8095CD0 .4byte sub_8095CD0_2 .4byte sub_80964BC +gUnknown_0850E4A4:: .4byte sub_8095D28 .4byte sub_8095D28_2 .4byte sub_80964BC +gUnknown_0850E4B0:: .4byte sub_8095D80 .4byte sub_8095D80_2 .4byte sub_80964BC +gUnknown_0850E4BC:: .4byte sub_8095DD8 .4byte sub_8095DD8_2 .4byte sub_80964BC +gUnknown_0850E4C8:: .4byte sub_8095E30 .4byte sub_8095E30_2 .4byte sub_80964BC +gUnknown_0850E4D4:: .4byte sub_8095E88 .4byte sub_8095E88_2 .4byte sub_80964BC +gUnknown_0850E4E0:: .4byte sub_8095EE0 .4byte sub_8095EE0_2 .4byte sub_80964BC +gUnknown_0850E4EC:: .4byte sub_8095F38 .4byte sub_8095F38_2 .4byte sub_80964BC +gUnknown_0850E4F8:: .4byte sub_8095F90 .4byte sub_8095F90_2 .4byte sub_80964BC +gUnknown_0850E504:: .4byte sub_8095FE8 .4byte sub_809459C .4byte sub_80964BC +gUnknown_0850E510:: .4byte sub_8096020 .4byte sub_809459C .4byte sub_80964BC +gUnknown_0850E51C:: .4byte sub_8096058 .4byte sub_809459C .4byte sub_80964BC +gUnknown_0850E528:: .4byte sub_8096090 .4byte sub_809459C .4byte sub_80964BC +gUnknown_0850E534:: .4byte sub_8096100 .4byte sub_8096100_2 .4byte sub_80964BC +gUnknown_0850E540:: .4byte sub_8096140 .4byte sub_8096140_2 .4byte sub_80964BC +gUnknown_0850E54C:: .4byte sub_8096180 .4byte sub_8096180_2 .4byte sub_80964BC +gUnknown_0850E558:: .4byte sub_80961C0 .4byte sub_80961C0_2 .4byte sub_80964BC +gUnknown_0850E564:: .4byte sub_8096230 .4byte sub_8096230_2 .4byte sub_80964BC +gUnknown_0850E570:: .4byte sub_8096270 .4byte sub_8096270_2 .4byte sub_80964BC +gUnknown_0850E57C:: .4byte sub_80962B0 .4byte sub_80962B0_2 .4byte sub_80964BC +gUnknown_0850E588:: .4byte sub_80962F0 .4byte sub_80962F0_2 .4byte sub_80964BC +gUnknown_0850E594:: .4byte sub_8096368 .4byte sub_8096368_2 .4byte sub_80964BC +gUnknown_0850E5A0:: .4byte sub_80963A8 .4byte sub_80963A8_2 .4byte sub_80964BC +gUnknown_0850E5AC:: .4byte sub_80963E8 .4byte sub_80963E8_2 .4byte sub_80964BC +gUnknown_0850E5B8:: .4byte sub_8096428 .4byte sub_8096428_2 .4byte sub_80964BC +gUnknown_0850E5C4:: .4byte sub_8096468 .4byte sub_80964B8 +gUnknown_0850E5CC:: .4byte sub_809647C .4byte sub_80964B8 +gUnknown_0850E5D4:: .4byte sub_8096494 .4byte sub_80964B8 + From 8098a209da963bc1654d1139f3f0d885dfff7af3 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 18 Sep 2017 19:30:55 -0400 Subject: [PATCH 191/191] Remove warnings --- src/field_map_obj.c | 80 ++++++++++++++++++++++----------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 60e622f28..26bc513fb 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -127,52 +127,52 @@ static void npc_update_obj_anim_flag(struct MapObject *, struct Sprite *); // ROM data -void (*const gUnknown_08505438[NUM_FIELD_MAP_OBJECT_TEMPLATES])(struct Sprite *); -const u8 gUnknown_0850557C[NUM_FIELD_MAP_OBJECT_TEMPLATES]; -const u8 gUnknown_085055CD[NUM_FIELD_MAP_OBJECT_TEMPLATES]; -const struct MapObjectGraphicsInfo *const gMauvilleOldManGraphicsInfoPointers[7]; -const struct MapObjectGraphicsInfo *const gFieldObjectGraphicsInfoPointers[0xEF]; -u8 (*const gUnknown_0850D714[11])(s16, s16, s16, s16); +extern void (*const gUnknown_08505438[NUM_FIELD_MAP_OBJECT_TEMPLATES])(struct Sprite *); +extern const u8 gUnknown_0850557C[NUM_FIELD_MAP_OBJECT_TEMPLATES]; +extern const u8 gUnknown_085055CD[NUM_FIELD_MAP_OBJECT_TEMPLATES]; +extern const struct MapObjectGraphicsInfo *const gMauvilleOldManGraphicsInfoPointers[7]; +extern const struct MapObjectGraphicsInfo *const gFieldObjectGraphicsInfoPointers[0xEF]; +extern u8 (*const gUnknown_0850D714[11])(s16, s16, s16, s16); struct PairedPalettes { u16 tag; const u16 *data; }; -u8 gUnknown_084975C4[0x10]; -const struct SpriteTemplate gUnknown_084975D4; -void (*const gUnknown_084975EC[3])(struct Sprite *); -const struct SpritePalette gUnknown_0850BBC8[39]; -const struct PairedPalettes gUnknown_0850BD00[4]; -const struct PairedPalettes gUnknown_0850BD78[14]; -const u16 *const gUnknown_0850BE38[2]; -const s16 gUnknown_0850D6DC[4]; // {0x20, 0x40, 0x60, 0x80} -const s16 gUnknown_0850D6EC[4]; -const u8 gUnknown_0850D710[4]; // {DIR_SOUTH, DIR_NORTH, DIR_WEST, DIR_EAST} -const u8 gUnknown_0850D770[2]; // {DIR_SOUTH, DIR_NORTH} -const u8 gUnknown_0850D790[2]; // {DIR_WEST, DIR_EAST} -const u8 gUnknown_0850D7F0[2]; // {DIR_NORTH, DIR_WEST} -const u8 gUnknown_0850D808[2]; // {DIR_NORTH, DIR_EAST} -const u8 gUnknown_0850D820[2]; // {DIR_SOUTH, DIR_WEST} -const u8 gUnknown_0850D838[2]; // {DIR_SOUTH, DIR_EAST} -const u8 gUnknown_0850D850[4]; -const u8 gUnknown_0850D868[4]; -const u8 gUnknown_0850D880[4]; -const u8 gUnknown_0850D898[4]; -const u8 gUnknown_0850D8AC[5]; -const u8 gUnknown_0850D8C4[5]; -const u8 gUnknown_0850D8E8[4]; -bool8 (*const gUnknown_0850DA64[11])(struct MapObject *, struct Sprite *, u8, bool8(u8)); -bool8 (*const gUnknown_0850DB5C[4])(u8); -bool8 (*const gUnknown_0850DB6C[4])(u8); -const struct Coords16 gUnknown_0850DB7C[4]; -const u8 gUnknown_0850DC2F[4][4]; -const u8 gUnknown_0850DC3F[4][4]; -const u8 gUnknown_0850DBA0[5]; -bool8 (*const *const gUnknown_0850DC50[166])(struct MapObject *, struct Sprite *); -u8 (*const gUnknown_0850DEE8[5])(u8); -const s16 gUnknown_0850DFBC[3]; -const s16 gUnknown_0850DFC2[3]; +extern const u8 gUnknown_084975C4[0x10]; +extern const struct SpriteTemplate gUnknown_084975D4; +extern void (*const gUnknown_084975EC[3])(struct Sprite *); +extern const struct SpritePalette gUnknown_0850BBC8[39]; +extern const struct PairedPalettes gUnknown_0850BD00[4]; +extern const struct PairedPalettes gUnknown_0850BD78[14]; +extern const u16 *const gUnknown_0850BE38[2]; +extern const s16 gUnknown_0850D6DC[4]; // {0x20, 0x40, 0x60, 0x80} +extern const s16 gUnknown_0850D6EC[4]; +extern const u8 gUnknown_0850D710[4]; // {DIR_SOUTH, DIR_NORTH, DIR_WEST, DIR_EAST} +extern const u8 gUnknown_0850D770[2]; // {DIR_SOUTH, DIR_NORTH} +extern const u8 gUnknown_0850D790[2]; // {DIR_WEST, DIR_EAST} +extern const u8 gUnknown_0850D7F0[2]; // {DIR_NORTH, DIR_WEST} +extern const u8 gUnknown_0850D808[2]; // {DIR_NORTH, DIR_EAST} +extern const u8 gUnknown_0850D820[2]; // {DIR_SOUTH, DIR_WEST} +extern const u8 gUnknown_0850D838[2]; // {DIR_SOUTH, DIR_EAST} +extern const u8 gUnknown_0850D850[4]; +extern const u8 gUnknown_0850D868[4]; +extern const u8 gUnknown_0850D880[4]; +extern const u8 gUnknown_0850D898[4]; +extern const u8 gUnknown_0850D8AC[5]; +extern const u8 gUnknown_0850D8C4[5]; +extern const u8 gUnknown_0850D8E8[4]; +extern bool8 (*const gUnknown_0850DA64[11])(struct MapObject *, struct Sprite *, u8, bool8(u8)); +extern bool8 (*const gUnknown_0850DB5C[4])(u8); +extern bool8 (*const gUnknown_0850DB6C[4])(u8); +extern const struct Coords16 gUnknown_0850DB7C[4]; +extern const u8 gUnknown_0850DC2F[4][4]; +extern const u8 gUnknown_0850DC3F[4][4]; +extern const u8 gUnknown_0850DBA0[5]; +extern bool8 (*const *const gUnknown_0850DC50[166])(struct MapObject *, struct Sprite *); +extern u8 (*const gUnknown_0850DEE8[5])(u8); +extern const s16 gUnknown_0850DFBC[3]; +extern const s16 gUnknown_0850DFC2[3]; // Code