summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoroctorock <79596758+octorock@users.noreply.github.com>2022-08-19 23:02:55 +0200
committeroctorock <79596758+octorock@users.noreply.github.com>2022-08-19 23:02:55 +0200
commitb2264f562f205ca928889342cff4910ee45ef15b (patch)
treec87d46245380c103110c220d032f51bc6108e172
parent373ab92156ddc4f11c9898ff48d497b4f3a49a23 (diff)
Decompile some functions
-rw-r--r--asm/non_matching/code_0805EC04/UpdatePlayerInput.inc115
-rw-r--r--asm/non_matching/coord/sub_0806FC24.inc23
-rw-r--r--asm/non_matching/demoScreen/sub_080A30AC.inc107
-rw-r--r--asm/non_matching/playerUtils/sub_0807A750.inc184
-rw-r--r--asm/non_matching/playerUtils/sub_0807C5F4.inc96
-rw-r--r--asm/non_matching/pullableMushroom/sub_0808ABC4.inc155
-rw-r--r--include/menu.h1
-rw-r--r--src/code_0805EC04.c84
-rw-r--r--src/demo.c50
-rw-r--r--src/object/pullableMushroom.c51
-rw-r--r--src/physics.c3
-rw-r--r--src/playerUtils.c140
-rw-r--r--src/staffroll.c8
13 files changed, 247 insertions, 770 deletions
diff --git a/asm/non_matching/code_0805EC04/UpdatePlayerInput.inc b/asm/non_matching/code_0805EC04/UpdatePlayerInput.inc
deleted file mode 100644
index 0ace695b..00000000
--- a/asm/non_matching/code_0805EC04/UpdatePlayerInput.inc
+++ /dev/null
@@ -1,115 +0,0 @@
- .syntax unified
- push {r4, lr}
- ldr r2, _0805ED50 @ =gPlayerState
- adds r0, r2, #0
- adds r0, #0x9c
- ldr r0, [r0]
- adds r4, r2, #0
- cmp r0, #0
- beq _0805ED88
- adds r1, r4, #0
- adds r1, #0x90
- ldr r2, [r1, #0xc]
- ldrh r0, [r1, #8]
- cmp r0, #0
- bne _0805ED7E
- movs r4, #0
- b _0805ED62
- .align 2, 0
-_0805ED50: .4byte gPlayerState
-_0805ED54:
- cmp r0, #2
- beq _0805ED5E
- strh r3, [r1, #8]
- ldrh r0, [r2, #2]
- strh r0, [r1, #0xa]
-_0805ED5E:
- adds r2, #4
- b _0805ED7C
-_0805ED62:
- ldrh r3, [r2]
- lsrs r0, r3, #0xe
- cmp r0, #1
- bne _0805ED72
- movs r3, #2
- ldrsh r0, [r2, r3]
- adds r2, r2, r0
- b _0805ED62
-_0805ED72:
- cmp r0, #3
- bne _0805ED54
- strh r4, [r1, #8]
- strh r4, [r1, #0xa]
- movs r2, #0
-_0805ED7C:
- str r2, [r1, #0xc]
-_0805ED7E:
- ldrh r0, [r1, #8]
- subs r0, #1
- strh r0, [r1, #8]
- ldrh r1, [r1, #0xa]
- b _0805EDCA
-_0805ED88:
- adds r0, r4, #0
- adds r0, #0x8b
- ldrb r0, [r0]
- cmp r0, #3
- bgt _0805ED98
- cmp r0, #0
- blt _0805ED98
- movs r1, #0
-_0805ED98:
- adds r2, r4, #0
- adds r2, #0x8b
- ldrb r0, [r2]
- cmp r0, #1
- beq _0805EDB4
- cmp r0, #1
- bgt _0805EDAC
- cmp r0, #0
- beq _0805EDC6
- b _0805EDCA
-_0805EDAC:
- cmp r0, #3
- bgt _0805EDCA
- movs r1, #0
- b _0805EDCA
-_0805EDB4:
- movs r0, #0
- strb r0, [r2]
- ldr r0, _0805EDF8 @ =gInput
- ldrh r0, [r0]
- bl ConvInputToState
- adds r1, r4, #0
- adds r1, #0x90
- strh r0, [r1]
-_0805EDC6:
- ldr r0, _0805EDF8 @ =gInput
- ldrh r1, [r0]
-_0805EDCA:
- adds r0, r1, #0
- bl ConvInputToState
- ldr r3, _0805EDFC @ =gPlayerState
- adds r1, r3, #0
- adds r1, #0x90
- ldrh r2, [r1]
- strh r0, [r1]
- adds r1, r0, #0
- bics r1, r2
- adds r2, r3, #0
- adds r2, #0x92
- strh r1, [r2]
- ldr r2, _0805EE00 @ =gUnk_08109202
- movs r1, #0xf0
- lsls r1, r1, #4
- ands r1, r0
- lsrs r1, r1, #8
- adds r1, r1, r2
- ldrb r0, [r1]
- strb r0, [r3, #0xd]
- pop {r4, pc}
- .align 2, 0
-_0805EDF8: .4byte gInput
-_0805EDFC: .4byte gPlayerState
-_0805EE00: .4byte gUnk_08109202
- .syntax divided
diff --git a/asm/non_matching/coord/sub_0806FC24.inc b/asm/non_matching/coord/sub_0806FC24.inc
deleted file mode 100644
index f2a8adc0..00000000
--- a/asm/non_matching/coord/sub_0806FC24.inc
+++ /dev/null
@@ -1,23 +0,0 @@
- .syntax unified
- push {r4, lr}
- adds r4, r1, #0
- ldr r1, _0806FC44 @ =gUnk_080046A4
- bl sub_08007DD6
- cmp r0, #0
- beq _0806FC4C
- lsls r0, r0, #3
- ldr r1, _0806FC48 @ =gUnk_080047F6
- adds r0, r0, r1
- ldrh r0, [r0]
- asrs r0, r4
- movs r1, #1
- ands r0, r1
- b _0806FC4E
- .align 2, 0
-_0806FC44: .4byte gUnk_080046A4
-_0806FC48: .4byte gUnk_080047F6
-_0806FC4C:
- movs r0, #0
-_0806FC4E:
- pop {r4, pc}
- .syntax divided
diff --git a/asm/non_matching/demoScreen/sub_080A30AC.inc b/asm/non_matching/demoScreen/sub_080A30AC.inc
deleted file mode 100644
index fca71712..00000000
--- a/asm/non_matching/demoScreen/sub_080A30AC.inc
+++ /dev/null
@@ -1,107 +0,0 @@
- .syntax unified
- push {r4, r5, r6, lr}
- mov r6, r8
- push {r6}
- ldr r4, _080A3188 @ =gOamCmd
- movs r1, #0
- movs r0, #0x80
- lsls r0, r0, #6
- strh r0, [r4, #4]
- strh r1, [r4, #6]
- movs r0, #0xc0
- lsls r0, r0, #4
- strh r0, [r4, #8]
- movs r0, #0x40
- strh r0, [r4, #2]
- ldr r0, _080A318C @ =gMenu
- movs r1, #0x10
- ldrsh r6, [r0, r1]
- ldr r1, _080A3190 @ =0xFFFFFED8
- adds r0, r1, #0
- subs r0, r0, r6
- strh r0, [r4]
- ldr r0, _080A3194 @ =0x08A068BF
- mov r8, r0
- ldr r1, [r0]
- mov r5, r8
- subs r5, #0xc
- adds r1, r1, r5
- adds r0, r4, #0
- bl sub_080ADA04
- movs r1, #0xc0
- rsbs r1, r1, #0
- adds r0, r1, #0
- subs r0, r0, r6
- strh r0, [r4]
- ldr r1, [r5, #4]
- adds r1, r1, r5
- adds r0, r4, #0
- bl sub_080ADA04
- movs r1, #0x58
- rsbs r1, r1, #0
- adds r0, r1, #0
- subs r0, r0, r6
- strh r0, [r4]
- ldr r1, [r5, #8]
- adds r1, r1, r5
- adds r0, r4, #0
- bl sub_080ADA04
- movs r0, #0x10
- subs r0, r0, r6
- strh r0, [r4]
- mov r0, r8
- ldr r1, [r0]
- adds r1, r1, r5
- adds r0, r4, #0
- bl sub_080ADA04
- movs r0, #0x78
- subs r0, r0, r6
- strh r0, [r4]
- ldr r1, [r5, #4]
- adds r1, r1, r5
- adds r0, r4, #0
- bl sub_080ADA04
- movs r0, #0xe0
- subs r0, r0, r6
- strh r0, [r4]
- ldr r1, [r5, #8]
- adds r1, r1, r5
- adds r0, r4, #0
- bl sub_080ADA04
- movs r1, #0xa4
- lsls r1, r1, #1
- adds r0, r1, #0
- subs r0, r0, r6
- strh r0, [r4]
- mov r0, r8
- ldr r1, [r0]
- adds r1, r1, r5
- adds r0, r4, #0
- bl sub_080ADA04
- movs r1, #0xd8
- lsls r1, r1, #1
- adds r0, r1, #0
- subs r0, r0, r6
- strh r0, [r4]
- ldr r1, [r5, #4]
- adds r1, r1, r5
- adds r0, r4, #0
- bl sub_080ADA04
- movs r1, #0x86
- lsls r1, r1, #2
- adds r0, r1, #0
- subs r0, r0, r6
- strh r0, [r4]
- ldr r1, [r5, #8]
- adds r1, r1, r5
- adds r0, r4, #0
- bl sub_080ADA04
- pop {r3}
- mov r8, r3
- pop {r4, r5, r6, pc}
- .align 2, 0
-_080A3188: .4byte gOamCmd
-_080A318C: .4byte gMenu
-_080A3190: .4byte 0xFFFFFED8
-_080A3194: .4byte gUnk_08A068BF
- .syntax divided
diff --git a/asm/non_matching/playerUtils/sub_0807A750.inc b/asm/non_matching/playerUtils/sub_0807A750.inc
deleted file mode 100644
index 180645bb..00000000
--- a/asm/non_matching/playerUtils/sub_0807A750.inc
+++ /dev/null
@@ -1,184 +0,0 @@
- .syntax unified
- push {r4, r5, r6, r7, lr}
- mov r7, r8
- push {r7}
- adds r7, r0, #0
- adds r6, r1, #0
- mov r8, r2
- adds r5, r3, #0
- movs r0, #1
- ands r0, r5
- cmp r0, #0
- bne _0807A76C
- movs r4, #0xf
- ands r4, r6
- b _0807A770
-_0807A76C:
- movs r4, #0xf
- ands r4, r7
-_0807A770:
- cmp r4, #0
- bne _0807A776
- b _0807A88E
-_0807A776:
- cmp r4, #0xf
- bne _0807A77C
- b _0807A88E
-_0807A77C:
- lsrs r0, r7, #4
- movs r2, #0x3f
- ands r0, r2
- lsrs r1, r6, #4
- ands r1, r2
- lsls r1, r1, #6
- orrs r0, r1
- ldr r1, _0807A7A8 @ =gPlayerEntity
- adds r1, #0x38
- ldrb r1, [r1]
- bl sub_080B1B44
- adds r1, r0, #0
- cmp r1, #0xf
- bls _0807A7AE
- cmp r1, #0xff
- beq _0807A7AC
- mov r2, r8
- adds r0, r1, r2
- subs r0, #0x10
- ldrb r1, [r0]
- b _0807A7AE
- .align 2, 0
-_0807A7A8: .4byte gPlayerEntity
-_0807A7AC:
- movs r1, #0xf
-_0807A7AE:
- ldr r0, _0807A7D8 @ =gUnk_0800823C
- lsls r1, r1, #2
- adds r1, r1, r0
- ldr r1, [r1]
- movs r0, #1
- ands r0, r5
- cmp r0, #0
- bne _0807A824
- movs r0, #0xf
- ands r0, r7
- movs r2, #0x80
- lsls r2, r2, #8
- asrs r2, r0
- cmp r5, #0
- bne _0807A7F4
- ldr r3, _0807A7DC @ =gPlayerEntity
- cmp r4, #0xe
- bgt _0807A7F0
- lsls r0, r4, #1
- adds r1, r0, r1
- b _0807A7E8
- .align 2, 0
-_0807A7D8: .4byte gUnk_0800823C
-_0807A7DC: .4byte gPlayerEntity
-_0807A7E0:
- adds r1, #2
- adds r4, #1
- cmp r4, #0xe
- bgt _0807A7F0
-_0807A7E8:
- ldrh r0, [r1]
- ands r0, r2
- cmp r0, #0
- bne _0807A7E0
-_0807A7F0:
- subs r4, #1
- b _0807A816
-_0807A7F4:
- ldr r3, _0807A800 @ =gPlayerEntity
- cmp r4, #0
- ble _0807A814
- lsls r0, r4, #1
- adds r1, r0, r1
- b _0807A80C
- .align 2, 0
-_0807A800: .4byte gPlayerEntity
-_0807A804:
- subs r1, #2
- subs r4, #1
- cmp r4, #0
- ble _0807A814
-_0807A80C:
- ldrh r0, [r1]
- ands r0, r2
- cmp r0, #0
- bne _0807A804
-_0807A814:
- adds r4, #1
-_0807A816:
- movs r0, #0xf
- ands r0, r6
- subs r0, r4, r0
- ldrh r1, [r3, #0x32]
- adds r0, r0, r1
- strh r0, [r3, #0x32]
- b _0807A88E
-_0807A824:
- movs r3, #0xf
- ands r6, r3
- lsls r0, r6, #1
- adds r0, r0, r1
- ldrh r2, [r0]
- cmp r5, #1
- bne _0807A85C
- subs r0, r3, r4
- lsrs r2, r0
- ldr r3, _0807A858 @ =gPlayerEntity
- cmp r4, #0
- ble _0807A854
- ands r5, r2
- cmp r5, #0
- beq _0807A854
- movs r1, #1
-_0807A844:
- lsrs r2, r2, #1
- subs r4, #1
- cmp r4, #0
- ble _0807A854
- adds r0, r2, #0
- ands r0, r1
- cmp r0, #0
- bne _0807A844
-_0807A854:
- adds r4, #1
- b _0807A882
- .align 2, 0
-_0807A858: .4byte gPlayerEntity
-_0807A85C:
- lsls r2, r4
- ldr r3, _0807A86C @ =gPlayerEntity
- cmp r4, #0xe
- bgt _0807A880
- movs r1, #0x80
- lsls r1, r1, #8
- b _0807A878
- .align 2, 0
-_0807A86C: .4byte gPlayerEntity
-_0807A870:
- lsls r2, r2, #1
- adds r4, #1
- cmp r4, #0xe
- bgt _0807A880
-_0807A878:
- adds r0, r2, #0
- ands r0, r1
- cmp r0, #0
- bne _0807A870
-_0807A880:
- subs r4, #1
-_0807A882:
- movs r0, #0xf
- ands r0, r7
- subs r0, r4, r0
- ldrh r2, [r3, #0x2e]
- adds r0, r0, r2
- strh r0, [r3, #0x2e]
-_0807A88E:
- pop {r3}
- mov r8, r3
- pop {r4, r5, r6, r7, pc}
- .syntax divided
diff --git a/asm/non_matching/playerUtils/sub_0807C5F4.inc b/asm/non_matching/playerUtils/sub_0807C5F4.inc
deleted file mode 100644
index d0995a9f..00000000
--- a/asm/non_matching/playerUtils/sub_0807C5F4.inc
+++ /dev/null
@@ -1,96 +0,0 @@
- .syntax unified
- push {r4, r5, r6, lr}
- adds r5, r0, #0
- adds r2, r5, #0
- movs r0, #0x20
- ldr r6, _0807C698 @ =gRoomControls
-_0807C5FE:
- movs r3, #0
- subs r4, r0, #1
-_0807C602:
- ldrh r0, [r1]
- strh r0, [r2]
- adds r1, #2
- adds r2, #2
- adds r3, #1
- cmp r3, #0x1f
- bls _0807C602
- adds r2, #0xc0
- adds r0, r4, #0
- cmp r0, #0
- bne _0807C5FE
- ldrh r0, [r6, #0x1e]
- cmp r0, #0xff
- bls _0807C63E
- adds r2, r5, #0
- adds r2, #0x40
- movs r0, #0x20
-_0807C624:
- movs r3, #0
- subs r4, r0, #1
-_0807C628:
- ldrh r0, [r1]
- strh r0, [r2]
- adds r1, #2
- adds r2, #2
- adds r3, #1
- cmp r3, #0x1f
- bls _0807C628
- adds r2, #0xc0
- adds r0, r4, #0
- cmp r0, #0
- bne _0807C624
-_0807C63E:
- ldrh r0, [r6, #0x20]
- cmp r0, #0xff
- bls _0807C666
- movs r0, #0x80
- lsls r0, r0, #6
- adds r2, r5, r0
- movs r0, #0x20
-_0807C64C:
- movs r3, #0
- subs r4, r0, #1
-_0807C650:
- ldrh r0, [r1]
- strh r0, [r2]
- adds r1, #2
- adds r2, #2
- adds r3, #1
- cmp r3, #0x1f
- bls _0807C650
- adds r2, #0xc0
- adds r0, r4, #0
- cmp r0, #0
- bne _0807C64C
-_0807C666:
- ldrh r0, [r6, #0x1e]
- cmp r0, #0xff
- bls _0807C694
- ldrh r0, [r6, #0x20]
- cmp r0, #0xff
- bls _0807C694
- movs r0, #0x81
- lsls r0, r0, #6
- adds r2, r5, r0
- movs r0, #0x20
-_0807C67A:
- movs r3, #0
- subs r4, r0, #1
-_0807C67E:
- ldrh r0, [r1]
- strh r0, [r2]
- adds r1, #2
- adds r2, #2
- adds r3, #1
- cmp r3, #0x1f
- bls _0807C67E
- adds r2, #0xc0
- adds r0, r4, #0
- cmp r0, #0
- bne _0807C67A
-_0807C694:
- pop {r4, r5, r6, pc}
- .align 2, 0
-_0807C698: .4byte gRoomControls
- .syntax divided
diff --git a/asm/non_matching/pullableMushroom/sub_0808ABC4.inc b/asm/non_matching/pullableMushroom/sub_0808ABC4.inc
deleted file mode 100644
index d89258b1..00000000
--- a/asm/non_matching/pullableMushroom/sub_0808ABC4.inc
+++ /dev/null
@@ -1,155 +0,0 @@
- .syntax unified
- push {r4, r5, lr}
- adds r4, r0, #0
- ldr r0, [r4, #0x50]
- ldrh r1, [r0, #0xc]
- ldr r0, _0808AC38 @ =0x00000201
- cmp r1, r0
- bne _0808ABD6
- bl DeleteThisEntity
-_0808ABD6:
- ldr r0, [r4, #0x54]
- ldr r1, [r4, #0x50]
- bl sub_0808B1F0
- adds r2, r0, #0
- cmp r2, #7
- bhi _0808ABE6
- movs r2, #0
-_0808ABE6:
- ldrb r3, [r4, #0x14]
- lsls r1, r3, #2
- ldr r0, _0808AC3C @ =gUnk_081211CC
- adds r5, r1, r0
- cmp r2, #0x1f
- bhi _0808AC5A
- cmp r2, #0
- beq _0808ABF8
- subs r2, #6
-_0808ABF8:
- ldrh r0, [r5]
- str r0, [r4, #0x70]
- ldr r1, [r4, #0x50]
- movs r0, #2
- ldrsb r0, [r5, r0]
- ldrh r3, [r1, #0x2e]
- adds r0, r0, r3
- strh r0, [r4, #0x2e]
- movs r0, #3
- ldrsb r0, [r5, r0]
- ldrh r1, [r1, #0x32]
- adds r0, r0, r1
- strh r0, [r4, #0x32]
- ldrb r1, [r4, #0x14]
- movs r0, #1
- ands r0, r1
- cmp r0, #0
- beq _0808AC40
- lsls r1, r2, #4
- movs r0, #0x80
- lsls r0, r0, #2
- subs r0, r0, r1
- str r0, [r4, #0x74]
- lsls r0, r2, #3
- movs r1, #0x90
- lsls r1, r1, #1
- adds r0, r0, r1
- str r0, [r4, #0x78]
- movs r0, #0xf
- strb r0, [r4, #0x1e]
- b _0808ACDE
- .align 2, 0
-_0808AC38: .4byte 0x00000201
-_0808AC3C: .4byte gUnk_081211CC
-_0808AC40:
- lsls r1, r2, #4
- movs r0, #0x80
- lsls r0, r0, #2
- subs r0, r0, r1
- str r0, [r4, #0x78]
- lsls r0, r2, #3
- movs r3, #0x90
- lsls r3, r3, #1
- adds r0, r0, r3
- str r0, [r4, #0x74]
- movs r0, #0x14
- strb r0, [r4, #0x1e]
- b _0808ACDE
-_0808AC5A:
- movs r0, #1
- ands r3, r0
- cmp r3, #0
- beq _0808AC9E
- adds r1, r2, #0
- subs r1, #0x20
- lsls r1, r1, #2
- adds r0, #0xff
- subs r0, r0, r1
- str r0, [r4, #0x74]
- lsls r0, r2, #3
- movs r1, #0xa0
- lsls r1, r1, #1
- adds r0, r0, r1
- str r0, [r4, #0x78]
- movs r0, #0x10
- strb r0, [r4, #0x1e]
- ldrb r1, [r4, #0x14]
- movs r0, #2
- ands r0, r1
- cmp r0, #0
- beq _0808AC92
- ldr r0, [r4, #0x50]
- lsrs r1, r2, #1
- ldrh r0, [r0, #0x2e]
- subs r0, r0, r1
- strh r0, [r4, #0x2e]
- b _0808ACDE
-_0808AC92:
- ldr r1, [r4, #0x50]
- lsrs r0, r2, #1
- ldrh r1, [r1, #0x2e]
- adds r0, r0, r1
- strh r0, [r4, #0x2e]
- b _0808ACDE
-_0808AC9E:
- adds r1, r2, #0
- subs r1, #0x20
- lsls r1, r1, #2
- movs r0, #0x80
- lsls r0, r0, #1
- subs r0, r0, r1
- str r0, [r4, #0x78]
- lsls r0, r2, #3
- movs r3, #0xa0
- lsls r3, r3, #1
- adds r0, r0, r3
- str r0, [r4, #0x74]
- movs r0, #0x15
- strb r0, [r4, #0x1e]
- ldrb r1, [r4, #0x14]
- movs r0, #2
- ands r0, r1
- cmp r0, #0
- beq _0808ACCE
- ldr r0, [r4, #0x50]
- lsrs r1, r2, #1
- ldrh r0, [r0, #0x32]
- adds r1, r1, r0
- b _0808ACD6
-_0808ACCE:
- ldr r0, [r4, #0x50]
- lsrs r2, r2, #1
- ldrh r1, [r0, #0x32]
- subs r1, r1, r2
-_0808ACD6:
- movs r0, #3
- ldrsb r0, [r5, r0]
- adds r0, r0, r1
- strh r0, [r4, #0x32]
-_0808ACDE:
- ldr r1, [r4, #0x74]
- ldr r2, [r4, #0x78]
- ldr r3, [r4, #0x70]
- adds r0, r4, #0
- bl SetAffineInfo
- pop {r4, r5, pc}
- .syntax divided
diff --git a/include/menu.h b/include/menu.h
index df97c884..04501df6 100644
--- a/include/menu.h
+++ b/include/menu.h
@@ -51,6 +51,7 @@ typedef struct {
/*0x10*/ union {
s32 i;
u16 h[2];
+ s16 sh[2];
u8 a[4];
} unk10;
/*0x12*/ // u8 field_0x12;
diff --git a/src/code_0805EC04.c b/src/code_0805EC04.c
index 7892299d..28301be4 100644
--- a/src/code_0805EC04.c
+++ b/src/code_0805EC04.c
@@ -1,8 +1,11 @@
+#include "common.h"
#include "entity.h"
#include "player.h"
-#include "structures.h"
#include "room.h"
-#include "common.h"
+#include "structures.h"
+
+extern const u8 gUnk_08109202[];
+u32 ConvInputToState(u32 keys);
bool32 sub_0805EC04(Entity* this) {
u32 i = 1;
@@ -64,7 +67,82 @@ void InitPlayerMacro(PlayerMacroEntry* playerMacro) {
gPlayerState.playerInput.playerMacroHeldKeys = 0;
}
-ASM_FUNC("asm/non_matching/code_0805EC04/UpdatePlayerInput.inc", void UpdatePlayerInput())
+void UpdatePlayerInput(void) {
+ u32 flags;
+ u32 state;
+ u32 keys;
+ u32 prevState;
+ PlayerInput* playerInput;
+ PlayerMacroEntry* playerMacro;
+ u32 zero;
+
+ if (gPlayerState.playerInput.playerMacro != NULL) {
+ // Player is controlled by macro.
+ playerInput = &gPlayerState.playerInput;
+ playerMacro = playerInput->playerMacro;
+ if (playerInput->playerMacroWaiting == 0) { // Execute next macro entry.
+ zero = 0;
+ goto code_2;
+ code_0:
+ if (flags != 2) {
+ playerInput->playerMacroWaiting = playerMacro->flags;
+ playerInput->playerMacroHeldKeys = playerMacro->keys;
+ }
+ playerMacro++;
+ playerInput->playerMacro = playerMacro;
+ goto code_4;
+ code_2:
+ do {
+ flags = playerMacro->flags >> 0xe;
+ if (flags != 1) {
+ break;
+ }
+ (u8*)playerMacro += ((s16)playerMacro->keys);
+ } while (TRUE);
+
+ if (flags == 3) {
+ playerInput->playerMacroWaiting = zero;
+ playerInput->playerMacroHeldKeys = zero;
+ playerMacro = NULL;
+ playerInput->playerMacro = playerMacro;
+ } else {
+ goto code_0;
+ }
+ }
+ code_4:
+ playerInput->playerMacroWaiting--;
+ keys = playerInput->playerMacroHeldKeys;
+ } else {
+ // Player has control.
+ switch (gPlayerState.controlMode) {
+ case CONTROL_DISABLED:
+ case CONTROL_1:
+ case CONTROL_2:
+ case CONTROL_ENABLED:
+ keys = 0;
+ break;
+ }
+ switch (gPlayerState.controlMode) {
+ case CONTROL_DISABLED:
+ case CONTROL_2:
+ keys = 0;
+ break;
+ case CONTROL_1:
+ gPlayerState.controlMode = CONTROL_ENABLED;
+ gPlayerState.playerInput.heldInput = ConvInputToState(gInput.heldKeys);
+ // fallthrough
+ case CONTROL_ENABLED:
+ keys = gInput.heldKeys;
+ break;
+ }
+ }
+ state = ConvInputToState(keys);
+ prevState = ~gPlayerState.playerInput.heldInput;
+ gPlayerState.playerInput.heldInput = state;
+ gPlayerState.playerInput.newInput = state & prevState;
+ // Calculate the direction from the currently held input.
+ gPlayerState.direction = gUnk_08109202[(state & PLAYER_INPUT_ANY_DIRECTION) >> 8];
+}
u32 ConvInputToState(u32 keys) {
u32 result;
diff --git a/src/demo.c b/src/demo.c
index fd8f2aaa..2c481990 100644
--- a/src/demo.c
+++ b/src/demo.c
@@ -5,14 +5,16 @@
* @brief Demo task
*/
-#include "global.h"
+#include "common.h"
+#include "fileselect.h"
#include "functions.h"
+#include "game.h"
+#include "global.h"
#include "main.h"
-#include "common.h"
+#include "menu.h"
#include "message.h"
-#include "fileselect.h"
#include "screen.h"
-#include "game.h"
+#include "menu.h"
void sub_080A30AC(void);
void sub_080A2E40(void);
@@ -154,54 +156,42 @@ void sub_080A2FD0(void) {
}
}
-NONMATCH("asm/non_matching/demoScreen/sub_080A30AC.inc", void sub_080A30AC(void)) {
- u32 unk_0x10;
+void sub_080A30AC(void) {
+ s32 unk_0x10;
u8* ptr;
u8* currentPtr;
u32 offset;
- u32 xoffset;
gOamCmd._4 = 0x2000;
gOamCmd._6 = 0;
gOamCmd._8 = 0xc00;
gOamCmd.y = 0x40;
- unk_0x10 = gChooseFileState.unk_0x10;
- gOamCmd.x = 0xFFFFFED8 - unk_0x10;
+ unk_0x10 = (s16)gGenericMenu.unk10.h[0];
+ gOamCmd.x = -0x128 - unk_0x10;
offset = *(u32*)gUnk_08A068BF;
ptr = gUnk_08A068BF - 0xc;
sub_080ADA04(&gOamCmd, ptr + offset);
- // FIX: original assembly uses r1 for xoffset for no apparent reason. Could not make it compile to do the same.
- // Maybe the original code was some sort of loop unrolling.
- xoffset = -0xc0;
- gOamCmd.x = xoffset - unk_0x10;
+ gOamCmd.x = -0xc0 - unk_0x10;
sub_080ADA04(&gOamCmd, ptr + *(u32*)(ptr + 4));
- xoffset = -0x58;
- gOamCmd.x = xoffset - unk_0x10;
+ gOamCmd.x = -0x58 - unk_0x10;
sub_080ADA04(&gOamCmd, ptr + *(u32*)(ptr + 8));
- xoffset = 0x10;
- gOamCmd.x = xoffset - unk_0x10;
+ gOamCmd.x = 0x10 - unk_0x10;
sub_080ADA04(&gOamCmd, ptr + *(u32*)(gUnk_08A068BF));
- xoffset = 0x78;
- gOamCmd.x = xoffset - unk_0x10;
+ gOamCmd.x = 0x78 - unk_0x10;
sub_080ADA04(&gOamCmd, ptr + *(u32*)(ptr + 4));
- xoffset = 0xe0;
- gOamCmd.x = xoffset - unk_0x10;
+ gOamCmd.x = 0xe0 - unk_0x10;
sub_080ADA04(&gOamCmd, ptr + *(u32*)(ptr + 8));
- xoffset = 0xa4 << 1;
- gOamCmd.x = xoffset - unk_0x10;
+ gOamCmd.x = 0x148 - unk_0x10;
sub_080ADA04(&gOamCmd, ptr + *(u32*)(gUnk_08A068BF));
- xoffset = 0xd8 << 1;
- gOamCmd.x = xoffset - unk_0x10;
+ gOamCmd.x = 0x1b0 - unk_0x10;
sub_080ADA04(&gOamCmd, ptr + *(u32*)(ptr + 4));
- xoffset = 0x86 << 2;
- gOamCmd.x = xoffset - unk_0x10;
+ gOamCmd.x = 0x218 - unk_0x10;
sub_080ADA04(&gOamCmd, ptr + *(u32*)(ptr + 8));
}
-END_NONMATCH
void sub_080A3198(u32 param_1, u32 param_2) {
static const Font gUnk_08127C98[] = {
- { gUnk_0203508E, (void*)0x0600d000, (void*)0x02000d00, 0, 0x1080, 0xd0, 1, 0, 0, 1, 9, 0, 0, 1, 1 },
- { gUnk_0203510E, (void*)0x0600d000, (void*)0x02000d00, 0, 0x80, 0xd0, 1, 0, 0, 1, 9, 0, 0, 1, 1 },
+ { gUnk_0203508E, BG_TILE_ADDR(0x1a0), gTextGfxBuffer, 0, 0x1080, 0xd0, 1, 0, 0, 1, 9, 0, 0, 1, 1 },
+ { gUnk_0203510E, BG_TILE_ADDR(0x1a0), gTextGfxBuffer, 0, 0x80, 0xd0, 1, 0, 0, 1, 9, 0, 0, 1, 1 },
};
static const u16 gUnk_08127CC8[4] = {
0x71c,
diff --git a/src/object/pullableMushroom.c b/src/object/pullableMushroom.c
index 22982728..3200afbf 100644
--- a/src/object/pullableMushroom.c
+++ b/src/object/pullableMushroom.c
@@ -126,9 +126,56 @@ void PullableMushroom_Action1_Type1(PullableMushroomEntity* this) {
sub_0808B168(this, 0);
}
}
+void sub_0808ABC4(PullableMushroomEntity* this) {
+ static const s8 gUnk_081211CC[] = { 0, -128, 0, -6, 0, 0, 5, -4, 0, 0, 0, 0, 0, -128, -5, -4 };
+ u32 tmp;
+ const s8* ptr;
-const u16 gUnk_081211CC[] = { 32768, 64000, 0, 64517, 0, 0, 32768, 64763 };
-ASM_FUNC("asm/non_matching/pullableMushroom/sub_0808ABC4.inc", void sub_0808ABC4(PullableMushroomEntity* this))
+ if (super->parent->action == 1 && super->parent->subAction == 2) {
+ DeleteThisEntity();
+ }
+ tmp = sub_0808B1F0((PullableMushroomEntity*)super->child, super->parent);
+ if (tmp < 8) {
+ tmp = 0;
+ }
+ ptr = &gUnk_081211CC[super->animationState * 4];
+ if (tmp < 0x20) {
+ if (tmp != 0) {
+ tmp -= 6;
+ }
+ this->unk_70 = (*(u16*)ptr);
+ super->x.HALF.HI = (s16)ptr[2] + super->parent->x.HALF.HI;
+ super->y.HALF.HI = (s16)ptr[3] + super->parent->y.HALF.HI;
+ if (super->animationState & 1) {
+ this->unk_74 = 0x200 - (tmp << 4);
+ this->unk_78 = (tmp << 3) + 0x120;
+ super->frameIndex = 0x0f;
+ } else {
+ this->unk_78 = 0x200 - (tmp << 4);
+ this->unk_74 = (tmp << 3) + 0x120;
+ super->frameIndex = 0x14;
+ }
+ } else if (super->animationState & 1) {
+ this->unk_74 = 0x100 - 4 * (tmp - 0x20);
+ this->unk_78 = (tmp << 3) + 0x140;
+ super->frameIndex = 0x10;
+ if (super->animationState & 2) {
+ super->x.HALF.HI = (super->parent)->x.HALF.HI - (tmp >> 1);
+ } else {
+ super->x.HALF.HI = (super->parent)->x.HALF.HI + (tmp >> 1);
+ }
+ } else {
+ this->unk_78 = 0x100 - 4 * (tmp - 0x20);
+ this->unk_74 = (tmp << 3) + 0x140;
+ super->frameIndex = 0x15;
+ if (super->animationState & 2) {
+ super->y.HALF.HI = (super->parent)->y.HALF_U.HI + (tmp >> 1) + ptr[3];
+ } else {
+ super->y.HALF.HI = (super->parent)->y.HALF_U.HI - (tmp >> 1) + ptr[3];
+ }
+ }
+ SetAffineInfo(super, this->unk_74, this->unk_78, this->unk_70);
+}
void sub_0808ACEC(PullableMushroomEntity* this) {
if (super->animIndex != 0) {
diff --git a/src/physics.c b/src/physics.c
index dcc2eaa3..9c740228 100644
--- a/src/physics.c
+++ b/src/physics.c
@@ -399,7 +399,7 @@ bool32 CheckPlayerProximity(u32 x, u32 y, u32 distX, u32 DistY) {
return rv;
}
-NONMATCH("asm/non_matching/coord/sub_0806FC24.inc", bool32 sub_0806FC24(u32 param_1, u32 param_2)) {
+bool32 sub_0806FC24(u32 param_1, u32 param_2) {
register u32 rv asm("r0");
u32 val = sub_08007DD6(param_1, gUnk_080046A4);
if (val) {
@@ -409,7 +409,6 @@ NONMATCH("asm/non_matching/coord/sub_0806FC24.inc", bool32 sub_0806FC24(u32 para
}
return rv;
}
-END_NONMATCH
const u16* sub_0806FC50(u32 param_1, u32 param_2) {
const u16* rv;
diff --git a/src/playerUtils.c b/src/playerUtils.c
index bda35fd8..89a538f3 100644
--- a/src/playerUtils.c
+++ b/src/playerUtils.c
@@ -166,6 +166,7 @@ extern s8* gUnk_0811C0B0[];
extern u8 gUnk_0811C01C[];
extern u32 gUnk_02022830[];
+extern u16* gUnk_0800823C[];
void UpdateActiveItems(PlayerEntity* this) {
u32 index;
@@ -2087,7 +2088,74 @@ u32 GetPlayerTilePos(void) {
ASM_FUNC("asm/non_matching/playerUtils/sub_0807A5B8.inc", void sub_0807A5B8(u32 a))
-ASM_FUNC("asm/non_matching/playerUtils/sub_0807A750.inc", void sub_0807A750())
+void sub_0807A750(u32 param_1, u32 param_2, u8* param_3, u32 param_4) {
+ u32 uVar2;
+ u16* ptr;
+ u32 uVar5;
+ s32 index;
+
+ if ((param_4 & 1) == 0) {
+ index = param_2 % 16;
+ } else {
+ index = param_1 % 16;
+ }
+ if ((index != 0) && (index != 0xf)) {
+ uVar2 = sub_080B1B44((param_1 >> 4 & 0x3f) | (param_2 >> 4 & 0x3f) << 6, gPlayerEntity.collisionLayer);
+ if (uVar2 > 0xf) {
+ if (uVar2 != 0xff) {
+ uVar2 = param_3[uVar2 - 0x10];
+ } else {
+ uVar2 = 0xf;
+ }
+ }
+ ptr = gUnk_0800823C[uVar2];
+ if ((param_4 & 1) == 0) {
+ uVar5 = 0x8000 >> (param_1 % 16);
+ if (param_4 == 0) {
+ while (index < 0xf) {
+ if ((ptr[index] & uVar5) == 0) {
+ break;
+ }
+ index++;
+ }
+ index--;
+ } else {
+ while (index > 0) {
+ if ((ptr[index] & uVar5) == 0) {
+ break;
+ }
+ index--;
+ }
+ index++;
+ }
+ gPlayerEntity.y.HALF.HI += index - (param_2 % 16);
+ } else {
+ uVar5 = ptr[param_2 % 16];
+ if (param_4 == 1) {
+ uVar5 = uVar5 >> ((0xf - index));
+ while (index > 0) {
+ if ((uVar5 & 1) == 0) {
+ break;
+ }
+ uVar5 >>= 1;
+ index--;
+ }
+ index++;
+ } else {
+ uVar5 = uVar5 << index;
+ while (index < 0xf) {
+ if ((uVar5 & 0x8000) == 0) {
+ break;
+ }
+ uVar5 <<= 1;
+ index++;
+ }
+ index--;
+ }
+ gPlayerEntity.x.HALF.HI += (index - (param_1 % 16));
+ }
+ }
+}
u32 GetCollisionTileInFront(Entity* this) {
s32 x;
@@ -3226,7 +3294,7 @@ void sub_0807C5B0(void) {
roomControls->scroll_flags |= 2;
}
-NONMATCH("asm/non_matching/playerUtils/sub_0807C5F4.inc", void sub_0807C5F4(u16* param_1, u16* param_2)) {
+void sub_0807C5F4(u16* param_1, u16* param_2) {
s32 iVar1;
u16* puVar2;
u16* puVar3;
@@ -3234,76 +3302,50 @@ NONMATCH("asm/non_matching/playerUtils/sub_0807C5F4.inc", void sub_0807C5F4(u16*
u32 index;
u32 innerIndex;
- /*
- for (index = 0; index < 0x20; index++) {
- for (innerIndex = 0; innerIndex < 0x20; innerIndex++) {
- param_1[index*0x81+innerIndex] = param_2[innerIndex];
- }
- }
-
- */
puVar2 = param_1;
- iVar1 = 0x20;
- do {
- uVar4 = 0;
- iVar1--;
- do {
+ for (iVar1 = 0x20; iVar1 != 0; iVar1--) {
+ for (uVar4 = 0; uVar4 < 0x20; uVar4++) {
*puVar2 = *param_2;
param_2++;
puVar2++;
- uVar4++;
- } while (uVar4 < 0x20);
+ }
puVar2 += 0x60;
- } while (iVar1 != 0);
+ }
- if (0xff < gRoomControls.width) {
+ if (gRoomControls.width > 0xff) {
puVar2 = param_1 + 0x20;
- iVar1 = 0x20;
- do {
- uVar4 = 0;
- iVar1--;
- do {
+ for (iVar1 = 0x20; iVar1 != 0; iVar1--) {
+ for (uVar4 = 0; uVar4 < 0x20; uVar4++) {
*puVar2 = *param_2;
param_2++;
puVar2++;
- uVar4++;
- } while (uVar4 < 0x20);
+ }
puVar2 += 0x60;
- } while (iVar1 != 0);
+ }
}
- if (0xff < gRoomControls.height) {
+ if (gRoomControls.height > 0xff) {
puVar2 = param_1 + 0x1000;
- iVar1 = 0x20;
- do {
- uVar4 = 0;
- iVar1--;
- do {
+ for (iVar1 = 0x20; iVar1 != 0; iVar1--) {
+ for (uVar4 = 0; uVar4 < 0x20; uVar4++) {
*puVar2 = *param_2;
param_2++;
puVar2++;
- uVar4++;
- } while (uVar4 < 0x20);
+ }
puVar2 += 0x60;
- } while (iVar1 != 0);
+ }
}
- if ((0xff < gRoomControls.width) && (0xff < gRoomControls.height)) {
+ if (gRoomControls.width > 0xff && gRoomControls.height > 0xff) {
param_1 += 0x1020;
puVar2 = param_1;
- iVar1 = 0x20;
- do {
- uVar4 = 0;
- iVar1--;
- do {
- *puVar2 = *param_2;
- param_2++;
- puVar2++;
- uVar4++;
- } while (uVar4 < 0x20);
+
+ for (iVar1 = 0x20; iVar1 != 0; iVar1--) {
+ for (uVar4 = 0; uVar4 < 0x20; uVar4++) {
+ *puVar2++ = *param_2++;
+ }
puVar2 += 0x60;
- } while (iVar1 != 0);
+ }
}
}
-END_NONMATCH
void sub_0807C69C(u8* data, u32 width, u32 height) {
u8* ptr1;
diff --git a/src/staffroll.c b/src/staffroll.c
index e5d32e14..0d64b765 100644
--- a/src/staffroll.c
+++ b/src/staffroll.c
@@ -26,16 +26,16 @@ typedef struct {
#define gStaffrollMenu (*(StaffrollMenu*)&gMenu)
const Font gUnk_08127280 = {
- (u16*)0x02021f72, (void*)0x0600c400, gTextGfxBuffer, 0, 61472, 240, 0, 0, 0, 0, 0, 5, 0, 1, 0
+ &gBG1Buffer[0x21], BG_TILE_ADDR(0x188), gTextGfxBuffer, 0, 61472, 240, 0, 0, 0, 0, 0, 5, 0, 1, 0
};
const Font gUnk_08127298 = {
- (u16*)0x02021f90, (void*)0x0600c400, gTextGfxBuffer, 0, 61472, 240, 0, 0, 0, 0, 0, 5, 0, 1, 0
+ &gBG1Buffer[0x30], BG_TILE_ADDR(0x188), gTextGfxBuffer, 0, 61472, 240, 0, 0, 0, 0, 0, 5, 0, 1, 0
};
const Font gUnk_081272B0 = {
- (u16*)0x0202204e, (void*)0x0600c400, gTextGfxBuffer, 0, 61472, 240, 1, 0, 0, 0, 0, 5, 0, 1, 0
+ &gBG1Buffer[0x8f], BG_TILE_ADDR(0x188), gTextGfxBuffer, 0, 61472, 240, 1, 0, 0, 0, 0, 5, 0, 1, 0
};
const Font gUnk_081272C8 = {
- (u16*)0x020222ce, (void*)0x0600c400, gTextGfxBuffer, 0, 61472, 240, 1, 0, 0, 0, 0, 5, 0, 1, 0
+ &gBG1Buffer[0x1cf], BG_TILE_ADDR(0x188), gTextGfxBuffer, 0, 61472, 240, 1, 0, 0, 0, 0, 5, 0, 1, 0
};
const Font* const gUnk_081272E0[] = {