summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchandler <chandlerm2016@yahoo.com>2020-06-12 04:22:06 -0400
committerchandler <chandlerm2016@yahoo.com>2020-06-12 04:22:06 -0400
commita0ff5a93b7403144f2003e6e1de644e1f78aaa24 (patch)
tree8be8b14e57acb3916f79c9fb9f089700e14f3460
parentd5350cd72b50b247e90ee13633700210d5493354 (diff)
well OK
-rw-r--r--asm/well.s79
-rw-r--r--include/entity.h3
-rw-r--r--linker.ld4
-rw-r--r--src/well.c40
4 files changed, 44 insertions, 82 deletions
diff --git a/asm/well.s b/asm/well.s
deleted file mode 100644
index ca4558be..00000000
--- a/asm/well.s
+++ /dev/null
@@ -1,79 +0,0 @@
- .include "asm/macros.inc"
-
- .include "constants/constants.inc"
-
- .syntax unified
-
- .text
-
-
- thumb_func_start sub_080A0E98
-sub_080A0E98: @ 0x080A0E98
- push {lr}
- ldr r2, _080A0EAC @ =gUnk_08124C08
- ldrb r1, [r0, #0xc]
- lsls r1, r1, #2
- adds r1, r1, r2
- ldr r1, [r1]
- bl _call_via_r1
- pop {pc}
- .align 2, 0
-_080A0EAC: .4byte gUnk_08124C08
-
- thumb_func_start sub_080A0EB0
-sub_080A0EB0: @ 0x080A0EB0
- push {r4, r5, lr}
- movs r1, #1
- strb r1, [r0, #0xc]
- movs r1, #0x2e
- ldrsh r2, [r0, r1]
- ldr r3, _080A0EE8 @ =gRoomControls
- ldrh r1, [r3, #6]
- subs r2, r2, r1
- asrs r2, r2, #4
- movs r4, #0x3f
- ands r2, r4
- movs r5, #0x32
- ldrsh r1, [r0, r5]
- ldrh r3, [r3, #8]
- subs r1, r1, r3
- asrs r1, r1, #4
- ands r1, r4
- lsls r1, r1, #6
- orrs r2, r1
- adds r0, #0x80
- strh r2, [r0]
- ldr r2, _080A0EEC @ =0x0000407D
- ldrh r1, [r0]
- adds r0, r2, #0
- movs r2, #1
- bl SetTile
- pop {r4, r5, pc}
- .align 2, 0
-_080A0EE8: .4byte gRoomControls
-_080A0EEC: .4byte 0x0000407D
-
- thumb_func_start sub_080A0EF0
-sub_080A0EF0: @ 0x080A0EF0
- push {r4, lr}
- adds r4, r0, #0
- adds r0, #0x80
- ldrh r0, [r0]
- movs r1, #1
- bl GetTileType
- ldr r1, _080A0F1C @ =0x0000407D
- cmp r0, r1
- beq _080A0F18
- bl sub_08078B48
- ldr r1, _080A0F20 @ =gLinkEntity
- ldr r0, [r4, #0x2c]
- str r0, [r1, #0x2c]
- ldrh r0, [r4, #0x32]
- adds r0, #4
- strh r0, [r1, #0x32]
- bl sub_0805E780
-_080A0F18:
- pop {r4, pc}
- .align 2, 0
-_080A0F1C: .4byte 0x0000407D
-_080A0F20: .4byte gLinkEntity
diff --git a/include/entity.h b/include/entity.h
index 72e7ad59..93d4010c 100644
--- a/include/entity.h
+++ b/include/entity.h
@@ -125,7 +125,8 @@ typedef struct Entity
u8 filler3[2];
u16 itemCooldown;
u32 field_0x7c;
- u32 field_0x80;
+ u16 field_0x80;
+ u16 field_0x82;
u16 cutsceneBeh;
u16 field_0x86;
diff --git a/linker.ld b/linker.ld
index 80b4ccc0..4d0303f3 100644
--- a/linker.ld
+++ b/linker.ld
@@ -761,11 +761,11 @@ SECTIONS {
asm/objectB4.o(.text);
asm/objectB5.o(.text);
asm/objectB6.o(.text);
- asm/well.o(.text);
+ src/well.o(.text);
asm/windTribeTeleporter.o(.text);
asm/objectB9.o(.text);
asm/objectBA.o(.text);
- asm/windCrest.o(.text);
+ asm/windcrest.o(.text);
asm/litArea.o(.text);
asm/objectBD.o(.text);
asm/pinwheel.o(.text);
diff --git a/src/well.c b/src/well.c
new file mode 100644
index 00000000..497771b8
--- /dev/null
+++ b/src/well.c
@@ -0,0 +1,40 @@
+#include "global.h"
+#include "entity.h"
+#include "room.h"
+
+void SetTile(u32 tileIndex, s32 tilePosition, s32 layerIndex);
+s32 GetTileType(s32 tilePosition, s32 layerIndex);
+void sub_08078B48();
+void sub_0805E780();
+
+extern Entity gLinkEntity;
+extern RoomControls gRoomControls;
+extern void (*gUnk_08124C08[])(Entity *);
+
+void sub_080A0E98(Entity* ent)
+{
+ gUnk_08124C08[ent->action](ent);
+}
+
+void sub_080A0EB0(Entity* ent)
+{
+ u32 tilePos;
+
+ ent->action = 1;
+ tilePos = (((ent->x.HALF.HI - gRoomControls.roomOriginX) >> 4) & 0x3F) | ((((ent->y.HALF.HI - gRoomControls.roomOriginY) >> 4) & 0x3F) * 64);
+ ent->field_0x80 = tilePos;
+ SetTile(16509, ent->field_0x80, 1);
+}
+
+void sub_080A0EF0(Entity* ent)
+{
+ s32 tileIndex;
+
+ tileIndex = GetTileType(ent->field_0x80, 1);
+ if (tileIndex != 16509) {
+ sub_08078B48();
+ gLinkEntity.x.WORD = ent->x.WORD;
+ gLinkEntity.y.HALF.HI = ent->y.HALF.HI + 4;
+ sub_0805E780();
+ }
+}