Merge branch 'master' into demo-jp

This commit is contained in:
octorock 2021-10-28 23:27:37 +02:00
commit 78646feecf
49 changed files with 980 additions and 1914 deletions

View File

@ -1,23 +1,24 @@
# The Legend of Zelda: The Minish Cap # The Legend of Zelda: The Minish Cap
**Progress:** [⬛⬛⬛⬛⬛⬛⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜] 30% **Progress:** [⬛⬛⬛⬛⬛⬛⬛⬛⬛⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜] 45%
```diff ```diff
- WARNING! - - WARNING! -
The ROM this repository builds cannot be 'shifted', primarily due to some hardcoded pointers which have yet This repository is a work in progress, and while it can be used to make certain changes, it's still
to be dumped. Thus this repository is currently in an experimental and research phase and cannot yet be used constantly evolving. If you use it for modding purposes in its current state, please be aware that
traditionally as a source code base for general changes. the codebase can drastically change at any time. Also note that some parts of the ROM may not be
'shiftable' yet, so modifying them could be difficult at this point.
``` ```
This is a WIP decompilation of The Legend of Zelda: The Minish Cap. This is a WIP decompilation of The Legend of Zelda: The Minish Cap.
The purpose of the project is to recreate a source code base for the game from scratch, using information found inside the game along with static and/or dynamic analysis. The purpose of the project is to recreate a source code base for the game from scratch, using information found inside the game along with static and/or dynamic analysis.
It builds the following ROMs: It can target the following ROMs:
* [**tmc.gba**](https://datomatic.no-intro.org/index.php?page=show_record&s=23&n=1841) `sha1: b4bd50e4131b027c334547b4524e2dbbd4227130` * [**tmc.gba**](https://datomatic.no-intro.org/index.php?page=show_record&s=23&n=1841) `sha1: b4bd50e4131b027c334547b4524e2dbbd4227130`
* [**tmc_eu.gba**](https://datomatic.no-intro.org/index.php?page=show_record&s=23&n=1734) `sha1: cff199b36ff173fb6faf152653d1bccf87c26fb7`
* [**tmc_jp.gba**](https://datomatic.no-intro.org/index.php?page=show_record&s=23&n=1719) `sha1: 6c5404a1effb17f481f352181d0f1c61a2765c5d` * [**tmc_jp.gba**](https://datomatic.no-intro.org/index.php?page=show_record&s=23&n=1719) `sha1: 6c5404a1effb17f481f352181d0f1c61a2765c5d`
* [**tmc_eu.gba**](https://datomatic.no-intro.org/index.php?page=show_record&s=23&n=1734) `sha1: cff199b36ff173fb6faf152653d1bccf87c26fb7`
* [**tmc_demo_usa.gba**](https://datomatic.no-intro.org/index.php?page=show_record&s=23&n=x051) `sha1: 63fcad218f9047b6a9edbb68c98bd0dec322d7a1` * [**tmc_demo_usa.gba**](https://datomatic.no-intro.org/index.php?page=show_record&s=23&n=x051) `sha1: 63fcad218f9047b6a9edbb68c98bd0dec322d7a1`
* [**tmc_demo_jp.gba**](https://datomatic.no-intro.org/index.php?page=show_record&s=23&n=x430) `sha1: 9cdb56fa79bba13158b81925c1f3641251326412` * [**tmc_demo_jp.gba**](https://datomatic.no-intro.org/index.php?page=show_record&s=23&n=x430) `sha1: 9cdb56fa79bba13158b81925c1f3641251326412`

View File

@ -2299,14 +2299,14 @@ _0801E8BC:
bl sub_0801E810 bl sub_0801E810
cmp r0, #0 cmp r0, #0
bne _0801E93A bne _0801E93A
ldr r1, _0801E8F4 @ =0x080C9A5C ldr r1, _0801E8F4 @ =gUnk_080FC3E4
lsls r0, r4, #3 lsls r0, r4, #3
adds r0, r0, r1 adds r0, r0, r1
ldrb r1, [r0, #4] ldrb r1, [r0, #4]
lsls r0, r1, #2 lsls r0, r1, #2
adds r0, r0, r1 adds r0, r0, r1
lsls r0, r0, #2 lsls r0, r0, #2
ldr r1, _0801E8F8 @ =0x080FDFD0 ldr r1, _0801E8F8 @ =gUnk_080FE320
adds r2, r0, r1 adds r2, r0, r1
ldrb r0, [r2, #0x10] ldrb r0, [r2, #0x10]
cmp r0, #4 cmp r0, #4
@ -2317,8 +2317,8 @@ _0801E8BC:
ldr r0, [r0] ldr r0, [r0]
mov pc, r0 mov pc, r0
.align 2, 0 .align 2, 0
_0801E8F4: .4byte 0x080C9A5C _0801E8F4: .4byte gUnk_080C9CBC
_0801E8F8: .4byte 0x080FDFD0 _0801E8F8: .4byte gUnk_080FE320
_0801E8FC: .4byte _0801E900 _0801E8FC: .4byte _0801E900
_0801E900: @ jump table _0801E900: @ jump table
.4byte _0801E914 @ case 0 .4byte _0801E914 @ case 0

File diff suppressed because it is too large Load Diff

View File

@ -3201,7 +3201,7 @@ sub_080A529C: @ 0x080A529C
str r0, [r1, #0xc] str r0, [r1, #0xc]
ldrb r4, [r1, #3] ldrb r4, [r1, #3]
lsls r1, r4, #3 lsls r1, r4, #3
ldr r0, _080A52D8 @ =gUnk_08128B64 ldr r0, _080A52D8 @ =gItemMenuTable
adds r1, r1, r0 adds r1, r1, r0
ldr r0, _080A52DC @ =gInput ldr r0, _080A52DC @ =gInput
ldrh r2, [r0, #2] ldrh r2, [r0, #2]
@ -3219,7 +3219,7 @@ sub_080A529C: @ 0x080A529C
.align 2, 0 .align 2, 0
_080A52D0: .4byte gMenu _080A52D0: .4byte gMenu
_080A52D4: .4byte gUnk_08128BF4 _080A52D4: .4byte gUnk_08128BF4
_080A52D8: .4byte gUnk_08128B64 _080A52D8: .4byte gItemMenuTable
_080A52DC: .4byte gInput _080A52DC: .4byte gInput
_080A52E0: _080A52E0:
cmp r4, #0x10 cmp r4, #0x10
@ -3358,7 +3358,7 @@ _080A4BC8:
ldrb r0, [r2] ldrb r0, [r2]
cmp r0, #0 cmp r0, #0
beq _080A4C68 beq _080A4C68
ldr r0, _080A4C20 @ =gUnk_08128B64 ldr r0, _080A4C20 @ =gItemMenuTable
adds r1, r6, r0 adds r1, r6, r0
ldrb r0, [r1, #6] ldrb r0, [r1, #6]
ldr r3, _080A4C14EU @ =gOamCmd ldr r3, _080A4C14EU @ =gOamCmd
@ -3395,7 +3395,7 @@ _080A4BF4:
_080A4C14EU: .4byte gOamCmd _080A4C14EU: .4byte gOamCmd
_080A4C18: .4byte gSave _080A4C18: .4byte gSave
_080A4C1C: .4byte gChooseFileState _080A4C1C: .4byte gChooseFileState
_080A4C20: .4byte gUnk_08128B64 _080A4C20: .4byte gItemMenuTable
_080A4C24: .4byte gBombBagSizes _080A4C24: .4byte gBombBagSizes
_080A4C28: _080A4C28:
cmp r3, #0xa cmp r3, #0xa
@ -3453,7 +3453,7 @@ _080A4C68:
movs r1, #0x11 movs r1, #0x11
_080A4C8E: _080A4C8E:
lsls r0, r1, #3 lsls r0, r1, #3
ldr r1, _080A4D54EU @ =gUnk_08128B64 ldr r1, _080A4D54EU @ =gItemMenuTable
mov r8, r1 mov r8, r1
adds r1, r0, r1 adds r1, r0, r1
mov r4, sb mov r4, sb
@ -3545,7 +3545,7 @@ _080A4D44: .4byte gOamCmd
_080A4D48: .4byte gUnk_080FDFD8 _080A4D48: .4byte gUnk_080FDFD8
_080A4D4C: .4byte 0x00000141 _080A4D4C: .4byte 0x00000141
_080A4D50EU: .4byte gChooseFileState _080A4D50EU: .4byte gChooseFileState
_080A4D54EU: .4byte gUnk_08128B64 _080A4D54EU: .4byte gItemMenuTable
_080A4D58: .4byte gMain _080A4D58: .4byte gMain
_080A4D5C: .4byte gSave _080A4D5C: .4byte gSave
.else .else
@ -3580,7 +3580,7 @@ _080A53B4:
ldrb r0, [r2] ldrb r0, [r2]
cmp r0, #0 cmp r0, #0
beq _080A5456 beq _080A5456
ldr r0, _080A540C @ =gUnk_08128B64 ldr r0, _080A540C @ =gItemMenuTable
adds r1, r6, r0 adds r1, r6, r0
ldrb r0, [r1, #6] ldrb r0, [r1, #6]
ldr r3, _080A5400 @ =gOamCmd ldr r3, _080A5400 @ =gOamCmd
@ -3617,7 +3617,7 @@ _080A53E0:
_080A5400: .4byte gOamCmd _080A5400: .4byte gOamCmd
_080A5404: .4byte gSave _080A5404: .4byte gSave
_080A5408: .4byte gMenu _080A5408: .4byte gMenu
_080A540C: .4byte gUnk_08128B64 _080A540C: .4byte gItemMenuTable
_080A5410: .4byte gBombBagSizes _080A5410: .4byte gBombBagSizes
_080A5414: _080A5414:
cmp r3, #0xa cmp r3, #0xa
@ -3676,7 +3676,7 @@ _080A5456:
movs r1, #0x11 movs r1, #0x11
_080A547C: _080A547C:
lsls r0, r1, #3 lsls r0, r1, #3
ldr r1, _080A553C @ =gUnk_08128B64 ldr r1, _080A553C @ =gItemMenuTable
mov r8, r1 mov r8, r1
adds r1, r0, r1 adds r1, r0, r1
mov r4, sb mov r4, sb
@ -3766,7 +3766,7 @@ _080A552C: .4byte gQuiverSizes
_080A5530: .4byte gOamCmd _080A5530: .4byte gOamCmd
_080A5534: .4byte gUnk_080FDFD8 _080A5534: .4byte gUnk_080FDFD8
_080A5538: .4byte gMenu _080A5538: .4byte gMenu
_080A553C: .4byte gUnk_08128B64 _080A553C: .4byte gItemMenuTable
_080A5540: .4byte gMain _080A5540: .4byte gMain
_080A5544: .4byte 0x000001FB _080A5544: .4byte 0x000001FB
_080A5548: .4byte gSave _080A5548: .4byte gSave

View File

@ -1102,7 +1102,7 @@ sub_08088160: @ 0x08088160
push {r4, lr} push {r4, lr}
adds r2, r0, #0 adds r2, r0, #0
lsls r1, r1, #3 lsls r1, r1, #3
ldr r0, _08087FB0 @ =0x080FC094 ldr r0, _08087FB0 @ =gUnk_080FC3E4
adds r1, r1, r0 adds r1, r1, r0
movs r4, #0 movs r4, #0
adds r0, r2, #0 adds r0, r2, #0
@ -1120,7 +1120,7 @@ sub_08088160: @ 0x08088160
beq _08087FBC beq _08087FBC
b _0808806A b _0808806A
.align 2, 0 .align 2, 0
_08087FB0: .4byte 0x080FC094 _08087FB0: .4byte gUnk_080FC3E4
_08087FB4: _08087FB4:
cmp r0, #0x20 cmp r0, #0x20
beq _08087FCA beq _08087FCA

View File

@ -316,12 +316,12 @@ _080A0E50:
lsls r0, r1, #2 lsls r0, r1, #2
adds r0, r0, r1 adds r0, r0, r1
lsls r0, r0, #2 lsls r0, r0, #2
ldr r1, _080A0E70 @ =0x0813AA18 ldr r1, _080A0E70 @ =gUnk_0813ADEC
adds r0, r0, r1 adds r0, r0, r1
bl DoExitTransition bl DoExitTransition
b _080A0E8C b _080A0E8C
.align 2, 0 .align 2, 0
_080A0E70: .4byte 0x0813AA18 _080A0E70: .4byte gUnk_0813ADEC
_080A0E74: _080A0E74:
ldr r0, _080A0E90 @ =0x030010A0 ldr r0, _080A0E90 @ =0x030010A0
ldr r0, [r0] ldr r0, [r0]

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
buildname=tmc_eu buildname=tmc
baserom=baserom_eu baserom=baserom
OBJDUMP="$DEVKITARM/bin/arm-none-eabi-objdump -D -bbinary -marmv4t -Mforce-thumb" OBJDUMP="$DEVKITARM/bin/arm-none-eabi-objdump -D -bbinary -marmv4t -Mforce-thumb"
OPTIONS="--start-address=$(($1)) --stop-address=$(($1 + $2))" OPTIONS="--start-address=$(($1)) --stop-address=$(($1 + $2))"

View File

@ -733,157 +733,3 @@ gUnk_08128B48:: @ 08128B48
gUnk_08128B50:: @ 08128B50 gUnk_08128B50:: @ 08128B50
.incbin "baserom.gba", 0x128B50, 0x0000014 .incbin "baserom.gba", 0x128B50, 0x0000014
gUnk_08128B64:: @ 08128B64
.incbin "baserom.gba", 0x128B64, 0x0000090
gUnk_08128BF4:: @ 08128BF4
.incbin "baserom.gba", 0x128BF4, 0x0000004
gUnk_08128BF8:: @ 08128BF8
.4byte sub_080A5594
.4byte sub_080A56A0
gUnk_08128C00:: @ 08128C00
.incbin "baserom.gba", 0x128C00, 0x0000004
gUnk_08128C04:: @ 08128C04
.incbin "baserom.gba", 0x128C04, 0x0000010
gUnk_08128C14:: @ 08128C14
.incbin "baserom.gba", 0x128C14, 0x0000080
gUnk_08128C94:: @ 08128C94
.incbin "baserom.gba", 0x128C94, 0x0000080
gUnk_08128D14:: @ 08128D14
.4byte sub_080A59AC
.4byte sub_080A59C8
.4byte sub_080A5A54
.4byte sub_080A5A90
gUnk_08128D24:: @ 08128D24
.4byte sub_080A5AF4
.4byte sub_080A5B34
.4byte sub_080A5BB8
gUnk_08128D30:: @ 08128D30
.4byte sub_080A5C44
.4byte sub_080A5C9C
gUnk_08128D38:: @ 08128D38
.incbin "baserom.gba", 0x128D38, 0x0000004
gUnk_08128D3C:: @ 08128D3C
.incbin "baserom.gba", 0x128D3C, 0x0000007
gUnk_08128D43:: @ 08128D43
.incbin "baserom.gba", 0x128D43, 0x000000E
gUnk_08128D51:: @ 08128D51
.incbin "baserom.gba", 0x128D51, 0x0000007
gUnk_08128D58:: @ 08128D58
.4byte sub_080A6024
.4byte sub_080A6044
gUnk_08128D60:: @ 08128D60
.incbin "baserom.gba", 0x128D60, 0x0000010
gUnk_08128D70:: @ 08128D70
.incbin "baserom.gba", 0x128D70, 0x0000040
gUnk_08128DB0:: @ 08128DB0
.4byte sub_080A6108
.4byte sub_080A612C
gUnk_08128DB8:: @ 08128DB8
.incbin "baserom.gba", 0x128DB8, 0x0000004
gUnk_08128DBC:: @ 08128DBC
.incbin "baserom.gba", 0x128DBC, 0x0000010
gUnk_08128DCC:: @ 08128DCC
.4byte sub_080A6290
.4byte sub_080A62E0
gUnk_08128DD4:: @ 08128DD4
.incbin "baserom.gba", 0x128DD4, 0x0000004
gUnk_08128DD8:: @ 08128DD8
.incbin "baserom.gba", 0x128DD8, 0x0000010
gUnk_08128DE8:: @ 08128DE8
.incbin "baserom.gba", 0x128DE8, 0x0000088
gUnk_08128E70:: @ 08128E70
.4byte sub_080A6534
.4byte sub_080A65AC
gUnk_08128E78:: @ 08128E78
.4byte sub_080A6650
.4byte sub_080A667C
gUnk_08128E80:: @ 08128E80
.incbin "baserom.gba", 0x128E80, 0x0000004
gUnk_08128E84:: @ 08128E84
.incbin "baserom.gba", 0x128E84, 0x0000010
gUnk_08128E94:: @ 08128E94
.incbin "baserom.gba", 0x128E94, 0x0000088
gUnk_08128F1C:: @ 08128F1C
.4byte sub_080A6B04
.4byte sub_080A6C1C
gUnk_08128F24:: @ 08128F24
.4byte sub_080A6CA8
.4byte sub_080A6CD8
.4byte sub_080A6DD0
.4byte sub_080A6DF8
.4byte sub_080A6E44
gUnk_08128F38:: @ 08128F38
.incbin "baserom.gba", 0x128F38, 0x0000014
gUnk_08128F4C:: @ 08128F4C
.incbin "baserom.gba", 0x128F4C, 0x000000C
gUnk_08128F58:: @ 08128F58
.incbin "baserom.gba", 0x128F58, 0x0000050
gUnk_08128FA8:: @ 08128FA8
.incbin "baserom.gba", 0x128FA8, 0x0000018
gUnk_08128FC0:: @ 08128FC0
.incbin "baserom.gba", 0x128FC0, 0x0000018
gUnk_08128FD8:: @ 08128FD8
.incbin "baserom.gba", 0x128FD8, 0x0000018
gUnk_08128FF0:: @ 08128FF0
.incbin "baserom.gba", 0x128FF0, 0x0000014
gUnk_08129004:: @ 08129004
.incbin "baserom.gba", 0x129004, 0x0000018
gUnk_0812901C:: @ 0812901C
.4byte sub_080A7250
.4byte sub_080A7328
.4byte sub_080A7528
.4byte sub_080A73A8
.4byte sub_080A74C8
gUnk_08129030:: @ 08129030
.4byte sub_080A71DC
.4byte sub_080A4EA0
.4byte sub_080A71DC
.4byte sub_080A64FC
.4byte DrawKinstoneMenu
.4byte sub_08051E68
.4byte sub_0804AB54
.4byte sub_080A45A4
.4byte sub_08054870
.4byte sub_080A6C74
.4byte sub_080A6AB8

156
data/data_08128BF4.s Normal file
View File

@ -0,0 +1,156 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.section .rodata
.align 2
gUnk_08128BF4:: @ 08128BF4
.incbin "baserom.gba", 0x128BF4, 0x0000004
gUnk_08128BF8:: @ 08128BF8
.4byte sub_080A5594
.4byte sub_080A56A0
gUnk_08128C00:: @ 08128C00
.incbin "baserom.gba", 0x128C00, 0x0000004
gUnk_08128C04:: @ 08128C04
.incbin "baserom.gba", 0x128C04, 0x0000010
gUnk_08128C14:: @ 08128C14
.incbin "baserom.gba", 0x128C14, 0x0000080
gUnk_08128C94:: @ 08128C94
.incbin "baserom.gba", 0x128C94, 0x0000080
gUnk_08128D14:: @ 08128D14
.4byte sub_080A59AC
.4byte sub_080A59C8
.4byte sub_080A5A54
.4byte sub_080A5A90
gUnk_08128D24:: @ 08128D24
.4byte sub_080A5AF4
.4byte sub_080A5B34
.4byte sub_080A5BB8
gUnk_08128D30:: @ 08128D30
.4byte sub_080A5C44
.4byte sub_080A5C9C
gUnk_08128D38:: @ 08128D38
.incbin "baserom.gba", 0x128D38, 0x0000004
gUnk_08128D3C:: @ 08128D3C
.incbin "baserom.gba", 0x128D3C, 0x0000007
gUnk_08128D43:: @ 08128D43
.incbin "baserom.gba", 0x128D43, 0x000000E
gUnk_08128D51:: @ 08128D51
.incbin "baserom.gba", 0x128D51, 0x0000007
gUnk_08128D58:: @ 08128D58
.4byte sub_080A6024
.4byte sub_080A6044
gUnk_08128D60:: @ 08128D60
.incbin "baserom.gba", 0x128D60, 0x0000010
gUnk_08128D70:: @ 08128D70
.incbin "baserom.gba", 0x128D70, 0x0000040
gUnk_08128DB0:: @ 08128DB0
.4byte sub_080A6108
.4byte sub_080A612C
gUnk_08128DB8:: @ 08128DB8
.incbin "baserom.gba", 0x128DB8, 0x0000004
gUnk_08128DBC:: @ 08128DBC
.incbin "baserom.gba", 0x128DBC, 0x0000010
gUnk_08128DCC:: @ 08128DCC
.4byte sub_080A6290
.4byte sub_080A62E0
gUnk_08128DD4:: @ 08128DD4
.incbin "baserom.gba", 0x128DD4, 0x0000004
gUnk_08128DD8:: @ 08128DD8
.incbin "baserom.gba", 0x128DD8, 0x0000010
gUnk_08128DE8:: @ 08128DE8
.incbin "baserom.gba", 0x128DE8, 0x0000088
gUnk_08128E70:: @ 08128E70
.4byte sub_080A6534
.4byte sub_080A65AC
gUnk_08128E78:: @ 08128E78
.4byte sub_080A6650
.4byte sub_080A667C
gUnk_08128E80:: @ 08128E80
.incbin "baserom.gba", 0x128E80, 0x0000004
gUnk_08128E84:: @ 08128E84
.incbin "baserom.gba", 0x128E84, 0x0000010
gUnk_08128E94:: @ 08128E94
.incbin "baserom.gba", 0x128E94, 0x0000088
gUnk_08128F1C:: @ 08128F1C
.4byte sub_080A6B04
.4byte sub_080A6C1C
gUnk_08128F24:: @ 08128F24
.4byte sub_080A6CA8
.4byte sub_080A6CD8
.4byte sub_080A6DD0
.4byte sub_080A6DF8
.4byte sub_080A6E44
gUnk_08128F38:: @ 08128F38
.incbin "baserom.gba", 0x128F38, 0x0000014
gUnk_08128F4C:: @ 08128F4C
.incbin "baserom.gba", 0x128F4C, 0x000000C
gUnk_08128F58:: @ 08128F58
.incbin "baserom.gba", 0x128F58, 0x0000050
gUnk_08128FA8:: @ 08128FA8
.incbin "baserom.gba", 0x128FA8, 0x0000018
gUnk_08128FC0:: @ 08128FC0
.incbin "baserom.gba", 0x128FC0, 0x0000018
gUnk_08128FD8:: @ 08128FD8
.incbin "baserom.gba", 0x128FD8, 0x0000018
gUnk_08128FF0:: @ 08128FF0
.incbin "baserom.gba", 0x128FF0, 0x0000014
gUnk_08129004:: @ 08129004
.incbin "baserom.gba", 0x129004, 0x0000018
gUnk_0812901C:: @ 0812901C
.4byte sub_080A7250
.4byte sub_080A7328
.4byte sub_080A7528
.4byte sub_080A73A8
.4byte sub_080A74C8
gUnk_08129030:: @ 08129030
.4byte sub_080A71DC
.4byte sub_080A4EA0
.4byte sub_080A71DC
.4byte sub_080A64FC
.4byte DrawKinstoneMenu
.4byte sub_08051E68
.4byte sub_0804AB54
.4byte sub_080A45A4
.4byte sub_08054870
.4byte sub_080A6C74
.4byte sub_080A6AB8

View File

@ -109,11 +109,11 @@ typedef struct Entity {
/*0x3b*/ u8 flags2; /*0x3b*/ u8 flags2;
/*0x3c*/ u8 field_0x3c; /*0x3c*/ u8 field_0x3c;
/*0x3d*/ s8 iframes; /*0x3d*/ s8 iframes;
/*0x3e*/ u8 field_0x3e; /*0x3e*/ u8 knockbackDirection;
/*0x3f*/ u8 damageType; /*0x3f*/ u8 damageType;
/*0x40*/ u8 field_0x40; /*0x40*/ u8 field_0x40;
/*0x41*/ u8 bitfield; /*0x41*/ u8 bitfield;
/*0x42*/ u8 field_0x42; /*0x42*/ u8 knockbackDuration;
/*0x43*/ u8 field_0x43; /*0x43*/ u8 field_0x43;
/*0x44*/ u8 field_0x44; /*0x44*/ u8 field_0x44;
/*0x45*/ u8 currentHealth; /*0x45*/ u8 currentHealth;

View File

@ -9,6 +9,7 @@
#include "player.h" #include "player.h"
#include "room.h" #include "room.h"
#include "structures.h" #include "structures.h"
#include "script.h"
// Identified - to be sorted into header files // Identified - to be sorted into header files
extern void ShowNPCDialogue(Entity*, Dialog*); extern void ShowNPCDialogue(Entity*, Dialog*);
@ -42,7 +43,21 @@ extern void ResetPlayer(void);
extern u32 IsItemEquipped(u32); extern u32 IsItemEquipped(u32);
extern void DeleteManager(Manager*); extern void DeleteManager(Manager*);
extern bool32 CheckPlayerInRegion(u32 centerX, u32 centerY, u32 radiusX, u32 radiusY); extern bool32 CheckPlayerInRegion(u32 centerX, u32 centerY, u32 radiusX, u32 radiusY);
extern Entity* CreateProjectileWithParent(Entity*, u8, u8);
extern u32 GetBottleContaining(u32);
extern u32 GetTileTypeByEntity(Entity*); extern u32 GetTileTypeByEntity(Entity*);
extern u32 GetSaleItemConfirmMessageID(u32);
extern void FlushSprites(void);
extern void DispReset(u32);
extern void InitSoundPlayingInfo(void);
extern void InitDMA(void);
extern Entity* CreateProjectile(u32);
extern void RegisterPlayerHitbox();
extern s32 GetItemPrice();
extern void DoExitTransition(ScreenTransitionData*);
extern void CreateDustAt(u32, u32, u32);
extern void PutItemOnSlot(u32 itemID);
extern void CreateSpeechBubbleSleep(Entity*, u32, u32);
// Unidentified // Unidentified
extern u32 sub_0806ED78(Entity*); extern u32 sub_0806ED78(Entity*);
@ -80,8 +95,6 @@ extern u32 sub_08049FA0(Entity*);
extern u32 sub_08049FDC(Entity*, u32); extern u32 sub_08049FDC(Entity*, u32);
extern u32 sub_080041A0(Entity*, Entity*, u32, u32); extern u32 sub_080041A0(Entity*, Entity*, u32, u32);
extern u32 sub_08049EE4(Entity*); extern u32 sub_08049EE4(Entity*);
extern Entity* CreateProjectileWithParent(Entity*, u8, u8);
extern u32 GetBottleContaining(u32);
extern void sub_08077E54(ItemBehavior*); extern void sub_08077E54(ItemBehavior*);
extern void sub_080042BA(Entity*, u32); extern void sub_080042BA(Entity*, u32);
extern bool32 sub_08077F24(ItemBehavior*, u32); extern bool32 sub_08077F24(ItemBehavior*, u32);
@ -92,7 +105,6 @@ extern s32 sub_0807887C(Entity*, u32, u32);
extern s32 sub_08078904(); extern s32 sub_08078904();
extern void sub_0805E5A8(void); extern void sub_0805E5A8(void);
extern void sub_0805E5C0(void); extern void sub_0805E5C0(void);
extern void FlushSprites(void);
extern void sub_080AD9B0(void); extern void sub_080AD9B0(void);
extern void sub_080AD918(void); extern void sub_080AD918(void);
extern void sub_0801E104(void); extern void sub_0801E104(void);
@ -118,7 +130,6 @@ extern u32 sub_08060354(void);
extern void sub_08057E64(void); extern void sub_08057E64(void);
extern void sub_0809F814(u32); extern void sub_0809F814(u32);
extern void sub_080300E8(void); extern void sub_080300E8(void);
extern void DispReset(u32);
extern void sub_08058D34(void); extern void sub_08058D34(void);
extern void sub_0807AABC(Entity*); extern void sub_0807AABC(Entity*);
extern void sub_08078A90(u32); extern void sub_08078A90(u32);
@ -142,7 +153,6 @@ extern void sub_080AF2E4(void);
extern void sub_0804F578(void); extern void sub_0804F578(void);
extern void sub_08059994(void); extern void sub_08059994(void);
extern s32 sub_0801CFA8(u32); extern s32 sub_0801CFA8(u32);
extern void InitSoundPlayingInfo(void);
extern void sub_080ADA14(u32, u32); // trampoline to sub_080B27F4 extern void sub_080ADA14(u32, u32); // trampoline to sub_080B27F4
extern void sub_0801E1B8(u32, u32); extern void sub_0801E1B8(u32, u32);
extern void sub_0801E1EC(s32, s32, s32); extern void sub_0801E1EC(s32, s32, s32);
@ -171,7 +181,6 @@ extern void sub_0807A108(void);
extern u32 sub_0801766C(Entity*); extern u32 sub_0801766C(Entity*);
extern void sub_08004168(Entity*); extern void sub_08004168(Entity*);
extern u32 sub_08052638(u32); extern u32 sub_08052638(u32);
extern void InitDMA(void);
extern void sub_08056208(void); extern void sub_08056208(void);
extern void sub_08050384(); extern void sub_08050384();
extern u32 sub_0806F520(); extern u32 sub_0806F520();
@ -181,7 +190,6 @@ extern void sub_0804A7D4(Entity*);
extern void sub_08033744(Entity*); extern void sub_08033744(Entity*);
extern void sub_0800417E(Entity*, u32); extern void sub_0800417E(Entity*, u32);
extern void sub_080784C8(); extern void sub_080784C8();
extern void RegisterPlayerHitbox();
extern u32 sub_0808288C(Entity*, u32, u32, u32); extern u32 sub_0808288C(Entity*, u32, u32, u32);
extern void sub_0806FDA0(Entity*); extern void sub_0806FDA0(Entity*);
extern void sub_080AE008(Entity*, u32, u32); extern void sub_080AE008(Entity*, u32, u32);
@ -227,7 +235,6 @@ extern u32 sub_0805F7A0(u32);
extern u32* sub_0805F25C(u32); extern u32* sub_0805F25C(u32);
extern u32 sub_080045DA(s32, s32); extern u32 sub_080045DA(s32, s32);
u32 sub_0806FCB8(Entity*, u32, u32, u32); u32 sub_0806FCB8(Entity*, u32, u32, u32);
extern Entity* CreateProjectile(u32);
extern void sub_080A1D70(Entity*, u32); extern void sub_080A1D70(Entity*, u32);
extern void sub_0806F62C(Entity*, u32, u32); extern void sub_0806F62C(Entity*, u32, u32);
extern void sub_080A1ED0(u32, u32, u32); extern void sub_080A1ED0(u32, u32, u32);
@ -241,7 +248,6 @@ extern u32 sub_08052734(); // has Dungeon Map?
extern u32 sub_08052764(); // has Dungeon Compass? extern u32 sub_08052764(); // has Dungeon Compass?
extern u32 sub_0805279C(); // has Dungeon Big Key? extern u32 sub_0805279C(); // has Dungeon Big Key?
extern u32 sub_080527CC(); // num Dungeon small keys? extern u32 sub_080527CC(); // num Dungeon small keys?
extern u32 GetItemPrice();
extern void sub_08078790(Entity*, u32); extern void sub_08078790(Entity*, u32);
extern void sub_080788E0(Entity*); extern void sub_080788E0(Entity*);
extern void sub_08078AA8(u32, u32); extern void sub_08078AA8(u32, u32);
@ -267,7 +273,15 @@ extern void sub_0805EEB4(u8*, u32);
extern void sub_08056BDC(u32); extern void sub_08056BDC(u32);
extern void sub_08056F88(u32, u32); extern void sub_08056F88(u32, u32);
extern void sub_0805F8E4(u32 r0, WStruct* r1); extern void sub_0805F8E4(u32 r0, WStruct* r1);
extern void DoExitTransition(ScreenTransitionData*); extern u32 sub_08002632(Entity*);
extern void sub_0807879C(Entity*);
extern void sub_080787C0(Entity*);
extern void sub_080787B4(Entity*);
extern void sub_0808C650(Entity*, u32);
extern u32 sub_0808C67C(void);
extern void sub_0808C688(void);
extern void sub_0805E4A0(Entity*);
extern void sub_0805E4CC(Entity*);
extern Entity* sub_08077C94(ItemBehavior*, u32); extern Entity* sub_08077C94(ItemBehavior*, u32);
extern Entity* sub_08077C0C(ItemBehavior*, u32); extern Entity* sub_08077C0C(ItemBehavior*, u32);
@ -283,7 +297,6 @@ extern void sub_08078E84(Entity*, Entity*);
extern void sub_080042D0(Entity*, u32, u16); extern void sub_080042D0(Entity*, u32, u16);
extern u32 sub_080002A8(u32, u32, u32); extern u32 sub_080002A8(u32, u32, u32);
extern void CreateDustAt(u32, u32, u32);
extern void sub_080806BC(u32, u32, u32, u32); extern void sub_080806BC(u32, u32, u32, u32);
extern void sub_080186C0(u32); extern void sub_080186C0(u32);

View File

@ -40,6 +40,8 @@ void ReadKeyInput(void);
void LoadPalettes(const u8*, int, int); void LoadPalettes(const u8*, int, int);
void LoadPaletteGroup(u32 group); void LoadPaletteGroup(u32 group);
void sub_0801D79C(u32 colorIndex, u32 color);
void sub_0801D7BC(u32 color, u32 arg1);
/** /**
* Allocate memory on heap. * Allocate memory on heap.

View File

@ -1653,6 +1653,8 @@ data/const/object/object1D.o(.rodata);
data/const/demoScreen.o(.rodata); data/const/demoScreen.o(.rodata);
#endif #endif
data/data_08127280.o(.rodata); data/data_08127280.o(.rodata);
src/itemMenuTable.o(.rodata);
data/data_08128BF4.o(.rodata);
data/const/playerItem/playerItemSword.o(.rodata); data/const/playerItem/playerItemSword.o(.rodata);
data/data_08129320.o(.rodata); data/data_08129320.o(.rodata);
src/projectile/darkNutSwordSlash.o(.rodata); src/projectile/darkNutSwordSlash.o(.rodata);

View File

@ -52,7 +52,7 @@ void sub_080318DC(Entity* this) {
if (this->bitfield != 0x80 && this->bitfield != 0x81) { if (this->bitfield != 0x80 && this->bitfield != 0x81) {
if (this->type == 1) { if (this->type == 1) {
if (this->action < 7 && this->field_0x42) { if (this->action < 7 && this->knockbackDuration != 0) {
brother = this->attachedEntity; brother = this->attachedEntity;
if (brother) { if (brother) {
brother->parent = this->parent; brother->parent = this->parent;
@ -72,7 +72,7 @@ void sub_080318DC(Entity* this) {
this->action = 9; this->action = 9;
this->spritePriority.b1 = 1; this->spritePriority.b1 = 1;
if (this->field_0x3e < 0x10) { if (this->knockbackDirection < 0x10) {
this->spriteSettings.b.flipX = 0; this->spriteSettings.b.flipX = 0;
} else { } else {
this->spriteSettings.b.flipX = 1; this->spriteSettings.b.flipX = 1;
@ -81,19 +81,19 @@ void sub_080318DC(Entity* this) {
} }
if (this->currentHealth == 0) { if (this->currentHealth == 0) {
this->field_0x3e = ((this->field_0x3e + (7 & Random())) - 4) & 0x1f; this->knockbackDirection = ((this->knockbackDirection + (7 & Random())) - 4) & 0x1f;
this->field_0x42 += this->type2 * 3; this->knockbackDuration += this->type2 * 3;
sub_08032338(this); sub_08032338(this);
} }
} }
if (this->field_0x42 && this->frames.all & 0x10) { if (this->knockbackDuration != 0 && this->frames.all & 0x10) {
if (this->type == 0) { if (this->type == 0) {
this->action = 8; this->action = 8;
} else { } else {
this->action = 9; this->action = 9;
} }
if (this->field_0x3e < 0x10) { if (this->knockbackDirection < 0x10) {
this->spriteSettings.b.flipX = 0; this->spriteSettings.b.flipX = 0;
} else { } else {
this->spriteSettings.b.flipX = 1; this->spriteSettings.b.flipX = 1;

View File

@ -48,7 +48,7 @@ void sub_08021780(Entity* this) {
} }
if (this->currentHealth == 0) if (this->currentHealth == 0)
this->field_0x42 = 0; this->knockbackDuration = 0;
sub_0804AA30(this, gUnk_080CB590); sub_0804AA30(this, gUnk_080CB590);
} }

View File

@ -30,8 +30,8 @@ void sub_0802C688(Entity* this) {
case 0: case 0:
case 1: case 1:
if (this->field_0x82.HALF.LO) { if (this->field_0x82.HALF.LO) {
this->field_0x42 = 0; this->knockbackDuration = 0;
gPlayerEntity.field_0x42 = 4; gPlayerEntity.knockbackDuration = 4;
} }
return; return;
case 0xe: case 0xe:
@ -39,7 +39,7 @@ void sub_0802C688(Entity* this) {
case 0x15: case 0x15:
case 0x16: case 0x16:
this->action = 3; this->action = 3;
this->field_0x42 = 0; this->knockbackDuration = 0;
sub_0802CBC4(this); sub_0802CBC4(this);
return; return;
} }

View File

@ -64,7 +64,7 @@ void sub_08020BB8(Entity* this) {
this->action = 11; this->action = 11;
this->actionDelay = gUnk_080CAB0C[this->type]; this->actionDelay = gUnk_080CAB0C[this->type];
this->damageType = 81; this->damageType = 81;
sub_08021218(this, 8, DirectionToAnimationState(this->field_0x3e ^ 0x10)); sub_08021218(this, 8, DirectionToAnimationState(this->knockbackDirection ^ 0x10));
sub_08021588(this); sub_08021588(this);
sub_0804A9FC(this, 0x1c); sub_0804A9FC(this, 0x1c);
break; break;
@ -72,7 +72,7 @@ void sub_08020BB8(Entity* this) {
this->action = 11; this->action = 11;
this->actionDelay = gUnk_080CAB10[this->type]; this->actionDelay = gUnk_080CAB10[this->type];
this->damageType = 81; this->damageType = 81;
sub_08021218(this, 8, DirectionToAnimationState(this->field_0x3e ^ 0x10)); sub_08021218(this, 8, DirectionToAnimationState(this->knockbackDirection ^ 0x10));
sub_08021588(this); sub_08021588(this);
sub_0804A9FC(this, 0x1c); sub_0804A9FC(this, 0x1c);
break; break;

View File

@ -58,7 +58,7 @@ NONMATCH("asm/non_matching/gibdo/sub_080374A4.inc", void sub_080374A4(Entity* th
} else { } else {
if ((u8)(this->action - 1) < 2) { if ((u8)(this->action - 1) < 2) {
this->action = 1; this->action = 1;
x = DirectionTurnAround(this->field_0x3e); x = DirectionTurnAround(this->knockbackDirection);
this->direction = x; this->direction = x;
this->animationState = x >> 3; this->animationState = x >> 3;
InitAnimationForceUpdate(this, this->animationState); InitAnimationForceUpdate(this, this->animationState);
@ -342,8 +342,8 @@ void sub_08037A58(Entity* this) {
this->damageType = 0x26; this->damageType = 0x26;
this->flags2 |= 1; this->flags2 |= 1;
this->iframes = 0xf4; this->iframes = 0xf4;
this->field_0x3e = (this->animationState << 3) ^ 0x10; this->knockbackDirection = DirectionFromAnimationState(this->animationState) ^ 0x10;
this->field_0x42 = 8; this->knockbackDuration = 8;
this->field_0x46 = 0x180; this->field_0x46 = 0x180;
this->field_0x76.HALF.LO = 0x3c; this->field_0x76.HALF.LO = 0x3c;
InitAnimationForceUpdate(this, this->animationState + 0x10); InitAnimationForceUpdate(this, this->animationState + 0x10);
@ -353,8 +353,8 @@ void sub_08037ACC(Entity* this) {
gPlayerState.flags.all &= 0xFFFFFEFF; gPlayerState.flags.all &= 0xFFFFFEFF;
gPlayerEntity.flags |= 0x80; gPlayerEntity.flags |= 0x80;
gPlayerEntity.iframes = 0x1e; gPlayerEntity.iframes = 0x1e;
gPlayerEntity.field_0x3e = DirectionFromAnimationState(this->animationState); gPlayerEntity.knockbackDirection = DirectionFromAnimationState(this->animationState);
gPlayerEntity.field_0x42 = 4; gPlayerEntity.knockbackDuration = 4;
gPlayerEntity.field_0x46 = 0x180; gPlayerEntity.field_0x46 = 0x180;
} }
// Damage player maybe? // Damage player maybe?

View File

@ -48,7 +48,7 @@ void sub_0802BBC4(Entity* this) {
case 2: case 2:
case 3: case 3:
if (this->action == 4) { if (this->action == 4) {
this->field_0x42 = 0; this->knockbackDuration = 0;
sub_0802C218(this); sub_0802C218(this);
} }
break; break;

View File

@ -39,7 +39,7 @@ void sub_080323F4(Entity* this) {
if (this->action != 3 && this->action != 4) { if (this->action != 3 && this->action != 4) {
this->action = 3; this->action = 3;
this->actionDelay = 0xC; this->actionDelay = 0xC;
this->direction = DirectionTurnAround(this->field_0x3e); this->direction = DirectionTurnAround(this->knockbackDirection);
InitAnimationForceUpdate(this, this->direction >> 3); InitAnimationForceUpdate(this, this->direction >> 3);
} else if (this->bitfield == 0xCC) { } else if (this->bitfield == 0xCC) {
if (this->field_0x43 == 0) { if (this->field_0x43 == 0) {

View File

@ -64,7 +64,7 @@ void sub_0803C784(Entity* this) {
Entity* fx = CreateFx(this, 2, 0); Entity* fx = CreateFx(this, 2, 0);
if (fx != NULL) { if (fx != NULL) {
u32 angle = (this->field_0x3e ^ 0x10) << 3; u32 angle = (this->knockbackDirection ^ 0x10) << 3;
s32 sine; s32 sine;
sine = gSineTable[angle]; sine = gSineTable[angle];

View File

@ -24,7 +24,7 @@ void sub_0803CCD4(Entity* this) {
} }
void sub_0803CCEC(Entity* this) { void sub_0803CCEC(Entity* this) {
this->field_0x42 = 0; this->knockbackDuration = 0;
sub_0803CCD4(this); sub_0803CCD4(this);
} }

View File

@ -36,7 +36,7 @@ void sub_08022BEC(Entity* this) {
this->field_0x7a.HALF.LO = this->currentHealth; this->field_0x7a.HALF.LO = this->currentHealth;
this->actionDelay = 1; this->actionDelay = 1;
this->direction = this->field_0x3e; this->direction = this->knockbackDirection;
this->animationState = ((this->direction + 2) & 0x1c) >> 2; this->animationState = ((this->direction + 2) & 0x1c) >> 2;
this->frameIndex = this->animationState; this->frameIndex = this->animationState;

View File

@ -234,7 +234,7 @@ void Peahat_Stunned(Entity* this) {
} }
if (this->direction == 0xff) if (this->direction == 0xff)
this->direction = this->field_0x3e; this->direction = this->knockbackDirection;
ProcessMovement(this); ProcessMovement(this);
GetNextFrame(this); GetNextFrame(this);

View File

@ -75,7 +75,7 @@ void sub_08025020(Entity* this) {
this->field_0x20 = 0; this->field_0x20 = 0;
} }
this->iframes = -0xc; this->iframes = -0xc;
this->field_0x42 = 0; this->knockbackDuration = 0;
if (this->field_0x80.HALF.LO == 0) { if (this->field_0x80.HALF.LO == 0) {
this->animationState = (*(Entity**)&this->field_0x4c)->direction >> 3; this->animationState = (*(Entity**)&this->field_0x4c)->direction >> 3;
InitializeAnimation(this, this->animationState + 4); InitializeAnimation(this, this->animationState + 4);

View File

@ -51,7 +51,7 @@ void sub_08022254(Entity* this) {
this->action = 2; this->action = 2;
this->flags &= ~0x80; this->flags &= ~0x80;
this->spriteSettings.b.draw = 0; this->spriteSettings.b.draw = 0;
this->direction = this->field_0x3e; this->direction = this->knockbackDirection;
this->attachedEntity = ent; this->attachedEntity = ent;
} }
} }
@ -101,8 +101,8 @@ void sub_080223E4(Entity* this) {
ent->bitfield = 0x94; ent->bitfield = 0x94;
ent->iframes = 0x10; ent->iframes = 0x10;
#ifndef EU #ifndef EU
ent->field_0x42 = 0xc; ent->knockbackDuration = 0xc;
ent->field_0x3e = this->direction; ent->knockbackDirection = this->direction;
#endif #endif
} }

View File

@ -54,11 +54,11 @@ void sub_08020668(Entity* this) {
void sub_080206E0(Entity* this) { void sub_080206E0(Entity* this) {
if (Rollobite_TryToHoleUp(this)) { if (Rollobite_TryToHoleUp(this)) {
this->field_0x42 = 0; this->knockbackDuration = 0;
} else if (Rollobite_IsRolledUp(this)) { } else if (Rollobite_IsRolledUp(this)) {
this->field_0x42--; this->knockbackDuration--;
sub_080AE58C(this, this->field_0x3e, 10); sub_080AE58C(this, this->knockbackDirection, 10);
sub_080AE7E8(this, this->field_0x46, this->field_0x3e, 10); sub_080AE7E8(this, this->field_0x46, this->knockbackDirection, 10);
} else { } else {
sub_08001324(this); sub_08001324(this);
} }

View File

@ -379,11 +379,11 @@ bool32 sub_080288A4(Entity* this) {
void sub_080288C0(Entity* this) { void sub_080288C0(Entity* this) {
Entity* ent = this->attachedEntity; Entity* ent = this->attachedEntity;
if (ent && (ent->bitfield & 0x80)) { if (ent && (ent->bitfield & 0x80)) {
this->field_0x3e = ent->field_0x3e; this->knockbackDirection = ent->knockbackDirection;
this->iframes = -ent->iframes; this->iframes = -ent->iframes;
this->field_0x46 = ent->field_0x46; this->field_0x46 = ent->field_0x46;
this->field_0x42 = ent->field_0x42; this->knockbackDuration = ent->knockbackDuration;
ent->field_0x42 = 0; ent->knockbackDuration = 0;
} }
} }

View File

@ -51,8 +51,8 @@ void sub_0802B628(Entity* this) {
this->action = 6; this->action = 6;
this->field_0x20 = 0x18000; this->field_0x20 = 0x18000;
this->speed = 0xc0; this->speed = 0xc0;
this->direction = this->field_0x3e; this->direction = this->knockbackDirection;
this->field_0x42 = 0; this->knockbackDuration = 0;
this->iframes = -8; this->iframes = -8;
this->damageType = 100; this->damageType = 100;
InitializeAnimation(this, 9); InitializeAnimation(this, 9);

View File

@ -1068,7 +1068,7 @@ void sub_080409B0(Entity* this) {
} }
if (this->field_0x80.HALF.HI < 3) { if (this->field_0x80.HALF.HI < 3) {
if (this->field_0x42 != 0) { if (this->knockbackDuration != 0) {
sub_080AF18C(this); sub_080AF18C(this);
} }
} else { } else {

View File

@ -996,7 +996,7 @@ void sub_0804235C(Entity* this) {
InitializeAnimation(((VaatiWrathHeapStruct*)this->myHeap)->type3, 0x1b); InitializeAnimation(((VaatiWrathHeapStruct*)this->myHeap)->type3, 0x1b);
} }
#if defined USA || defined DEMO #if defined USA || defined DEMO_USA || defined DEMO_JP
void VaatiWrathType0PreAction(Entity* this) { void VaatiWrathType0PreAction(Entity* this) {
int temp; int temp;
if ((gScreenTransition.field_0x38 & 2) == 0) { if ((gScreenTransition.field_0x38 & 2) == 0) {

View File

@ -37,9 +37,9 @@ void sub_0802A454(Entity* this) {
} }
} }
if (this->field_0x42) if (this->knockbackDuration != 0)
if (this->field_0x42 > 4) if (this->knockbackDuration > 4)
this->field_0x42 -= 4; this->knockbackDuration -= 4;
if (this->field_0x43 != 0) { if (this->field_0x43 != 0) {
sub_0804A9FC(this, 0x1c); sub_0804A9FC(this, 0x1c);

View File

@ -102,7 +102,7 @@ void DeleteEntity(Entity* ent) {
ent->spriteSettings.b.draw = 0; ent->spriteSettings.b.draw = 0;
ent->field_0x3c = 0; ent->field_0x3c = 0;
ent->bitfield = 0; ent->bitfield = 0;
ent->field_0x42 = 0; ent->knockbackDuration = 0;
ent->currentHealth = 0; ent->currentHealth = 0;
UnlinkEntity(ent); UnlinkEntity(ent);
ent->next = NULL; ent->next = NULL;

53
src/itemMenuTable.c Normal file
View File

@ -0,0 +1,53 @@
#include "global.h"
typedef enum {
SWORD,
GUST_JAR,
CANE,
BOOMERANG,
SHIELD,
MOLE_MITTS,
LANTERN,
BOMBS,
PEGASUS_BOOTS,
ROCS_CAPE,
OCARINA,
BOW,
BOTTLE0,
BOTTLE1,
BOTTLE2,
BOTTLE3,
SAVE_BUTTON,
} ItemMenuTableSlot;
typedef struct {
u8 up;
u8 down;
u8 left;
u8 right;
u8 type;
u8 unk0;
u8 x;
u8 y;
} ItemMenuTableEntry;
const ItemMenuTableEntry gItemMenuTable[] = {
[SWORD] = { BOTTLE0, SHIELD, BOOMERANG, GUST_JAR, 0x01, 0x0c, 0x42, 0x33 },
[GUST_JAR] = { BOTTLE1, MOLE_MITTS, SWORD, CANE, 0x01, 0x10, 0x66, 0x33 },
[CANE] = { BOTTLE3, LANTERN, GUST_JAR, BOOMERANG, 0x01, 0x14, 0x8a, 0x33 },
[BOOMERANG] = { SAVE_BUTTON, BOMBS, CANE, SWORD, 0x01, 0x15, 0xae, 0x33 },
[SHIELD] = { SWORD, PEGASUS_BOOTS, BOMBS, MOLE_MITTS, 0x01, 0x16, 0x42, 0x4b },
[MOLE_MITTS] = { GUST_JAR, ROCS_CAPE, SHIELD, LANTERN, 0x01, 0x17, 0x66, 0x4b },
[LANTERN] = { CANE, OCARINA, MOLE_MITTS, BOMBS, 0x01, 0x00, 0x8a, 0x4b },
[BOMBS] = { BOOMERANG, BOW, LANTERN, SHIELD, 0x01, 0x00, 0xae, 0x4b },
[PEGASUS_BOOTS] = { SHIELD, BOTTLE0, BOW, ROCS_CAPE, 0x01, 0x00, 0x42, 0x63 },
[ROCS_CAPE] = { MOLE_MITTS, BOTTLE1, PEGASUS_BOOTS, OCARINA, 0x01, 0x00, 0x66, 0x63 },
[OCARINA] = { LANTERN, BOTTLE3, ROCS_CAPE, BOW, 0x01, 0x00, 0x8a, 0x63 },
[BOW] = { BOMBS, SAVE_BUTTON, OCARINA, PEGASUS_BOOTS, 0x01, 0x00, 0xae, 0x63 },
[BOTTLE0] = { PEGASUS_BOOTS, SWORD, SAVE_BUTTON, BOTTLE1, 0x01, 0x00, 0x42, 0x7b },
[BOTTLE1] = { ROCS_CAPE, GUST_JAR, BOTTLE0, BOTTLE2, 0x01, 0x00, 0x5a, 0x7b },
[BOTTLE2] = { ROCS_CAPE, GUST_JAR, BOTTLE1, BOTTLE3, 0x01, 0x00, 0x72, 0x7b },
[BOTTLE3] = { OCARINA, CANE, BOTTLE2, SAVE_BUTTON, 0x01, 0x00, 0x8a, 0x7b },
[SAVE_BUTTON] = { BOW, BOOMERANG, BOTTLE3, BOTTLE0, 0x03, 0x00, 0xb5, 0x75 },
{ BOW, BOOMERANG, BOTTLE3, BOTTLE0, 0x05, 0x00, 0xb5, 0x75 },
};

View File

@ -5,8 +5,6 @@
#include "functions.h" #include "functions.h"
#include "save.h" #include "save.h"
extern u32 sub_08002632(Entity*);
void Din(Entity* this) { void Din(Entity* this) {
switch (this->action) { switch (this->action) {
case 0: case 0:

View File

@ -85,8 +85,8 @@ void sub_08063DC8(Entity* this) {
InitAnimationForceUpdate(this, this->animationState + 4); InitAnimationForceUpdate(this, this->animationState + 4);
} else { } else {
sub_0806EE20(this); sub_0806EE20(this);
if (this->field_0x3e != this->animationState) { if (this->knockbackDirection != this->animationState) {
this->animationState = this->field_0x3e; this->animationState = this->knockbackDirection;
InitializeAnimation(this, this->animationState + 4); InitializeAnimation(this, this->animationState + 4);
} else { } else {
GetNextFrame(this); GetNextFrame(this);

View File

@ -67,7 +67,7 @@ void sub_0806045C(Entity* this) {
TextboxNoOverlapFollow(0); TextboxNoOverlapFollow(0);
break; break;
default: default:
bVar1 = this->field_0x3e; bVar1 = this->knockbackDirection;
if (bVar1 != this->animationState) { if (bVar1 != this->animationState) {
this->animationState = bVar1; this->animationState = bVar1;
InitAnimationForceUpdate(this, 4 + bVar1); InitAnimationForceUpdate(this, 4 + bVar1);

View File

@ -66,8 +66,8 @@ void sub_0809CD0C(Entity* this) {
ModHealth(-2); ModHealth(-2);
sub_0800449C(&gPlayerEntity, 0x7a); sub_0800449C(&gPlayerEntity, 0x7a);
gPlayerEntity.iframes = 16; gPlayerEntity.iframes = 16;
gPlayerEntity.field_0x3e = 16; gPlayerEntity.knockbackDirection = 16;
gPlayerEntity.field_0x42 = 12; gPlayerEntity.knockbackDuration = 12;
gPlayerEntity.field_0x46 = 16; gPlayerEntity.field_0x46 = 16;
} }
} }

View File

@ -199,7 +199,7 @@ void sub_08070D38(Entity* this) {
this->flags &= ~0x80; this->flags &= ~0x80;
this->direction = ((this->animationState & 0xe) << 2) ^ 0x10; this->direction = ((this->animationState & 0xe) << 2) ^ 0x10;
this->speed = 0x100; this->speed = 0x100;
this->field_0x42 = 0; this->knockbackDuration = 0;
this->subAction++; this->subAction++;
this->actionDelay = gPlayerState.field_0x38; this->actionDelay = gPlayerState.field_0x38;
this->spriteIndex = 1; this->spriteIndex = 1;
@ -366,7 +366,7 @@ void sub_08071038(Entity* this) {
if (this->frames.all & 0x80) { if (this->frames.all & 0x80) {
this->attachedEntity = 0; this->attachedEntity = 0;
this->field_0x42 = 0; this->knockbackDuration = 0;
this->iframes = 248; this->iframes = 248;
gPlayerState.jumpStatus = 0; gPlayerState.jumpStatus = 0;
sub_080791D0(); sub_080791D0();
@ -465,7 +465,7 @@ void sub_08071130(Entity* this) {
this->subAction++; this->subAction++;
sub_08078F60(); sub_08078F60();
this->field_0x42 = 0; this->knockbackDuration = 0;
SoundReq(SFX_PLY_LAND); SoundReq(SFX_PLY_LAND);
} }
@ -531,7 +531,7 @@ void sub_080712F0(Entity* this) {
if (temp == FALSE) if (temp == FALSE)
return; return;
this->field_0x42 = 0; this->knockbackDuration = 0;
this->iframes = 32; this->iframes = 32;
this->spritePriority.b1 = 1; this->spritePriority.b1 = 1;
this->spriteSettings.b.draw = FALSE; this->spriteSettings.b.draw = FALSE;
@ -568,7 +568,7 @@ void PortalJumpOnUpdate(Entity* this) {
u16 y; u16 y;
this->flags &= ~0x80; this->flags &= ~0x80;
this->field_0x42 = 0; this->knockbackDuration = 0;
x = gArea.curPortalX; x = gArea.curPortalX;
y = gArea.curPortalY; y = gArea.curPortalY;
@ -887,7 +887,7 @@ void sub_08071B60(Entity* this) {
gPlayerState.pushedObject = 2; gPlayerState.pushedObject = 2;
gPlayerState.flags.all &= ~0x1; gPlayerState.flags.all &= ~0x1;
this->type = 0; this->type = 0;
this->field_0x42 = 0; this->knockbackDuration = 0;
sub_080728AC(this); sub_080728AC(this);
this->field_0xf = 6; this->field_0xf = 6;
if ((gPlayerState.flags.all & 0x80) == 0) { if ((gPlayerState.flags.all & 0x80) == 0) {
@ -1139,7 +1139,7 @@ void sub_08071F80(Entity* this) {
void sub_08072008(Entity* this) { void sub_08072008(Entity* this) {
this->iframes = 160; this->iframes = 160;
this->field_0x42 = 0; this->knockbackDuration = 0;
this->flags |= 0x80; this->flags |= 0x80;
this->spriteOffsetX = 0; this->spriteOffsetX = 0;
gPlayerState.flags.all &= ~(0x800 | 0x1); gPlayerState.flags.all &= ~(0x800 | 0x1);
@ -1216,7 +1216,7 @@ void sub_08072168(Entity* this) {
gPlayerState.field_0xd = this->direction; gPlayerState.field_0xd = this->direction;
sub_08019840(); sub_08019840();
if (--this->actionDelay == 0xff) { if (--this->actionDelay == 0xff) {
this->field_0x42 = 0; this->knockbackDuration = 0;
this->flags |= 0x80; this->flags |= 0x80;
UpdateSpriteForCollisionLayer(this); UpdateSpriteForCollisionLayer(this);
sub_080791BC(); sub_080791BC();
@ -1256,7 +1256,7 @@ void sub_08072260(Entity* this) {
} else { } else {
gPlayerState.field_0x8 = 0x944; gPlayerState.field_0x8 = 0x944;
} }
this->field_0x42 = 0; this->knockbackDuration = 0;
sub_080791BC(); sub_080791BC();
} }
} }
@ -1283,7 +1283,7 @@ void sub_080722DC(Entity* this) {
} else { } else {
this->spriteSettings.b.draw = 0; this->spriteSettings.b.draw = 0;
this->subAction = 3; this->subAction = 3;
this->field_0x42 = 10; this->knockbackDuration = 10;
} }
gPlayerState.flags.all |= (0x400 | 0x1); gPlayerState.flags.all |= (0x400 | 0x1);
ResetPlayer(); ResetPlayer();
@ -1299,7 +1299,7 @@ void sub_08072354(Entity* this) {
return; return;
this->spritePriority.b1 = 0; this->spritePriority.b1 = 0;
this->field_0x42 = 0; this->knockbackDuration = 0;
this->subAction = 2; this->subAction = 2;
this->actionDelay = 0x3c; this->actionDelay = 0x3c;
gPlayerState.field_0x8 = 0x2c1; gPlayerState.field_0x8 = 0x2c1;
@ -1320,7 +1320,7 @@ void sub_080723D0(Entity* this) {
} }
void sub_0807240C(Entity* this) { void sub_0807240C(Entity* this) {
if (--this->field_0x42 == 0xff) { if (--this->knockbackDuration == 0xff) {
this->spriteSettings.b.draw = 3; this->spriteSettings.b.draw = 3;
this->iframes = 0x14; this->iframes = 0x14;
gPlayerState.flags.all &= ~0x400; gPlayerState.flags.all &= ~0x400;
@ -1360,7 +1360,7 @@ void PlayerRoomTransition(Entity* this) {
} }
void sub_080724DC(Entity* this) { void sub_080724DC(Entity* this) {
this->field_0x42 = 0; this->knockbackDuration = 0;
sub_0807A108(); sub_0807A108();
if (sub_080002B8(this) != 0x29) { if (sub_080002B8(this) != 0x29) {
if ((gPlayerState.field_0x82[7] == 0) && (gPlayerState.swimState != 0)) { if ((gPlayerState.field_0x82[7] == 0) && (gPlayerState.swimState != 0)) {
@ -1794,7 +1794,7 @@ NONMATCH("asm/non_matching/player/sub_08072D54.inc", void sub_08072D54(Entity* t
} }
this->actionDelay = 6; this->actionDelay = 6;
this->subAction = 3; this->subAction = 3;
this->field_0x42 = 0; this->knockbackDuration = 0;
SoundReq(0x7d); SoundReq(0x7d);
} }
} }
@ -1816,9 +1816,9 @@ void sub_08072F34(Entity* this) {
gPlayerState.field_0xa8 = 0x18; gPlayerState.field_0xa8 = 0x18;
gPlayerState.field_0x10[2] = sub_0807A1E8(this, 0, 0); gPlayerState.field_0x10[2] = sub_0807A1E8(this, 0, 0);
gUnk_0811BBE4[this->subAction](this); gUnk_0811BBE4[this->subAction](this);
if (this->field_0x42 != 0) { if (this->knockbackDuration != 0) {
sub_080792D8(); sub_080792D8();
if (this->field_0x42 == 0) { if (this->knockbackDuration == 0) {
this->action = 0x1d; this->action = 0x1d;
this->subAction = 0; this->subAction = 0;
this->y.HALF.LO = 0; this->y.HALF.LO = 0;
@ -1897,7 +1897,7 @@ void sub_08073094(Entity* this) {
switch (gPlayerState.field_0x10[2]) { switch (gPlayerState.field_0x10[2]) {
case 0x2a: case 0x2a:
case 0x2c: case 0x2c:
this->field_0x42 = 0; this->knockbackDuration = 0;
gPlayerState.flags.all |= 0x20000000; gPlayerState.flags.all |= 0x20000000;
UpdateAnimationSingleFrame(this); UpdateAnimationSingleFrame(this);
if ((this->frames.all & 0x40) != 0) { if ((this->frames.all & 0x40) != 0) {

View File

@ -34,7 +34,7 @@ void sub_080A9334(Entity* this) {
if ((this->bitfield & 0x3f) != 0) { if ((this->bitfield & 0x3f) != 0) {
ModHealth(-2); ModHealth(-2);
sub_080A9488(this); sub_080A9488(this);
this->field_0x42 = 0; this->knockbackDuration = 0;
this->iframes = 0; this->iframes = 0;
} else { } else {
DeleteThisEntity(); DeleteThisEntity();
@ -107,7 +107,7 @@ void sub_080A9488(Entity* this) {
this->flags &= 0x7f; this->flags &= 0x7f;
this->actionDelay = 2; this->actionDelay = 2;
this->field_0x20 = 0x18000; this->field_0x20 = 0x18000;
this->animationState = (this->field_0x3e & 0x18) >> 3; this->animationState = (this->knockbackDirection & 0x18) >> 3;
EnqueueSFX(SFX_METAL_CLINK); EnqueueSFX(SFX_METAL_CLINK);
sub_080A94C0(this, this->animationState); sub_080A94C0(this, this->animationState);
} }

View File

@ -27,7 +27,7 @@ void sub_080AB544(Entity* this) {
if (this->iframes < -4) { if (this->iframes < -4) {
this->action = 2; this->action = 2;
this->direction = this->field_0x3e; this->direction = this->knockbackDirection;
tmp = (this->type ^ 2) << 3; tmp = (this->type ^ 2) << 3;
if (this->direction - tmp + 1 < 3) { if (this->direction - tmp + 1 < 3) {
this->direction = tmp; this->direction = tmp;

View File

@ -30,7 +30,7 @@ void sub_080A8470(Entity* this) {
} }
DeleteEntity(this); DeleteEntity(this);
} else { } else {
this->direction = (this->field_0x3e + 4) & 0x18; this->direction = DirectionRoundUp(this->knockbackDirection);
if ((u8)(this->bitfield + 0x7e) < 2) { if ((u8)(this->bitfield + 0x7e) < 2) {
sub_080A8680(this); sub_080A8680(this);
} else { } else {
@ -74,14 +74,14 @@ void DekuSeedProjectile_Action1(Entity* this) {
parent = this->parent; parent = this->parent;
if ((parent->next != NULL) && (sub_080177A0(this, parent) != 0)) { if ((parent->next != NULL) && (sub_080177A0(this, parent) != 0)) {
this->iframes = 0x10; this->iframes = 0x10;
this->field_0x3e = -this->direction; this->knockbackDirection = -this->direction;
this->bitfield = -0x80; this->bitfield = -0x80;
this->field_0x42 = 0xc; this->knockbackDuration = 0xc;
this->field_0x46 = 0; this->field_0x46 = 0;
parent->iframes = 0x10; parent->iframes = 0x10;
parent->field_0x3e = this->direction; parent->knockbackDirection = this->direction;
parent->bitfield = -0x3e; parent->bitfield = -0x3e;
parent->field_0x42 = 0xc; parent->knockbackDuration = 0xc;
parent->field_0x46 = 0; parent->field_0x46 = 0;
} }
} }

View File

@ -35,7 +35,7 @@ void GuardLineOfSight(Entity* this) {
entity = CreateProjectile(0xc); entity = CreateProjectile(0xc);
if (entity != NULL) { if (entity != NULL) {
entity->type = 1; entity->type = 1;
tmp = this->parent->field_0x3e; tmp = this->parent->knockbackDirection;
entity->direction = (gUnk_081299C8[(this->actionDelay >> 2 & 7)] + (tmp << 3)) & 0x1f; entity->direction = (gUnk_081299C8[(this->actionDelay >> 2 & 7)] + (tmp << 3)) & 0x1f;
entity->parent = this->parent; entity->parent = this->parent;
CopyPosition(this, entity); CopyPosition(this, entity);

View File

@ -66,14 +66,14 @@ void sub_080A9EBC(Entity* this) {
default: default:
parent = this->parent; parent = this->parent;
parent->iframes = this->iframes; parent->iframes = this->iframes;
parent->field_0x3e = this->field_0x3e; parent->knockbackDirection = this->knockbackDirection;
parent->field_0x42 = this->field_0x42; parent->knockbackDuration = this->knockbackDuration;
if (this->action == 1) { if (this->action == 1) {
sub_080AA320(this); sub_080AA320(this);
} }
break; break;
} }
this->field_0x42 = 0; this->knockbackDuration = 0;
} }
} }

View File

@ -27,7 +27,7 @@ void sub_080A832C(Entity* this) {
if (this->bitfield == 0x80) { if (this->bitfield == 0x80) {
this->iframes = 0x10; this->iframes = 0x10;
this->field_0x42 = 0xc; this->knockbackDuration = 0xc;
this->field_0x46 = 0x180; this->field_0x46 = 0x180;
this->parent->bitfield = this->bitfield; this->parent->bitfield = this->bitfield;
} }
@ -37,10 +37,10 @@ void sub_080A832C(Entity* this) {
} else { } else {
this->parent->iframes = -tmp; this->parent->iframes = -tmp;
} }
this->parent->field_0x42 = this->field_0x42; this->parent->knockbackDuration = this->knockbackDuration;
this->parent->field_0x46 = this->field_0x46; this->parent->field_0x46 = this->field_0x46;
this->parent->field_0x3e = this->field_0x3e; this->parent->knockbackDirection = this->knockbackDirection;
this->field_0x42 = 0; this->knockbackDuration = 0;
} }
void MoblinSpear_Init(Entity* this) { void MoblinSpear_Init(Entity* this) {

View File

@ -84,7 +84,7 @@ void OctorokBossProjectile_Action1(Entity* this) {
if ((this->bitfield & 0x7f) == 0) { if ((this->bitfield & 0x7f) == 0) {
OctorokBossProjectile_Action2(this); OctorokBossProjectile_Action2(this);
} }
this->direction = this->field_0x3e << 3; this->direction = this->knockbackDirection << 3;
this->speed = 0x400; this->speed = 0x400;
this->type2 = 1; this->type2 = 1;
this->actionDelay = 0; this->actionDelay = 0;
@ -98,9 +98,9 @@ void OctorokBossProjectile_Action1(Entity* this) {
this->parent->currentHealth -= 1; this->parent->currentHealth -= 1;
this->parent->iframes = 0x1e; this->parent->iframes = 0x1e;
if (this->parent->field_0x7c.BYTES.byte0 != 0) { if (this->parent->field_0x7c.BYTES.byte0 != 0) {
this->parent->field_0x42 = 0x18; this->parent->knockbackDuration = 0x18;
this->parent->field_0x46 = 0x200; this->parent->field_0x46 = 0x200;
this->parent->field_0x3e = this->direction >> 3; this->parent->knockbackDirection = this->direction >> 3;
} }
SoundReq(SFX_BOSS_HIT); SoundReq(SFX_BOSS_HIT);
OctorokBossProjectile_Action2(this); OctorokBossProjectile_Action2(this);

View File

@ -23,7 +23,7 @@ void sub_080A8064(Entity* this) {
if (this->bitfield == 0x80) { if (this->bitfield == 0x80) {
DeleteEntity(this); DeleteEntity(this);
} else { } else {
this->direction = this->field_0x3e; this->direction = this->knockbackDirection;
sub_080A8178(this); sub_080A8178(this);
} }
} }

View File

@ -49,8 +49,8 @@ void sub_080AAC44(Entity* this) {
CopyPosition(this->parent, this); CopyPosition(this->parent, this);
} }
} }
if (this->field_0x42 != 0) { if (this->knockbackDuration != 0) {
this->field_0x42 = 0; this->knockbackDuration = 0;
} }
} }

View File

@ -11,6 +11,7 @@
#include "random.h" #include "random.h"
#include "audio.h" #include "audio.h"
#include "functions.h" #include "functions.h"
#include "main.h"
void InitScriptForEntity(Entity*, ScriptExecutionContext*, u16*); void InitScriptForEntity(Entity*, ScriptExecutionContext*, u16*);
void InitScriptExecutionContext(ScriptExecutionContext* context, u16* script); void InitScriptExecutionContext(ScriptExecutionContext* context, u16* script);
@ -301,6 +302,9 @@ const ScriptCommand gScriptCommands[] = { ScriptCommandNop,
ScriptCommand_0807F0B4, ScriptCommand_0807F0B4,
ScriptCommand_0807F0C8 }; ScriptCommand_0807F0C8 };
extern u16* gUnk_08001A7C[];
extern u8 gUnk_08114F30[];
extern u8 gUnk_08114F34[];
extern const u16 gUnk_08016984; extern const u16 gUnk_08016984;
extern u8 gUnk_0811E514[]; extern u8 gUnk_0811E514[];
extern u8 gUnk_0811E510[]; extern u8 gUnk_0811E510[];
@ -1524,3 +1528,627 @@ void ScriptCommand_0807F0B4(Entity* entity, ScriptExecutionContext* context) {
void ScriptCommand_0807F0C8(Entity* entity, ScriptExecutionContext* context) { void ScriptCommand_0807F0C8(Entity* entity, ScriptExecutionContext* context) {
sub_08080964(context->scriptInstructionPointer[1], context->scriptInstructionPointer[2]); sub_08080964(context->scriptInstructionPointer[1], context->scriptInstructionPointer[2]);
} }
extern u8 gUnk_0811E750[];
extern u8 gUnk_0811E758[];
extern u8 gUnk_0811E760[];
void sub_0807F0D8(Entity* entity, ScriptExecutionContext* context) {
context->condition = (-(u32)gInput.newKeys | ((u32)gInput.newKeys)) >> 0x1f;
}
void sub_0807F0EC(Entity* entity, ScriptExecutionContext* context) {
context->intVariable = (s32)Random() % (s32)context->intVariable;
}
void sub_0807F100(Entity* entity, ScriptExecutionContext* context) {
u32 rand;
rand = Random();
entity->animationState = rand & 6;
context->unk_1A = gUnk_0811E750[(rand >> 8) & 7];
}
void sub_0807F128(Entity* entity, ScriptExecutionContext* context) {
u32 rand;
rand = Random();
entity->animationState = gUnk_0811E758[rand & 7];
context->unk_1A = gUnk_0811E760[(rand >> 8) & 7];
}
void sub_0807F158(Entity* entity, ScriptExecutionContext* context) {
entity->collisionLayer = 1;
UpdateSpriteForCollisionLayer(entity);
}
void sub_0807F168(Entity* entity, ScriptExecutionContext* context) {
gPlayerEntity.collisionLayer = 1;
UpdateSpriteForCollisionLayer(&gPlayerEntity);
}
void sub_0807F180(Entity* entity, ScriptExecutionContext* context) {
entity->collisionLayer = 2;
UpdateSpriteForCollisionLayer(entity);
}
void sub_0807F190(Entity* entity, ScriptExecutionContext* context) {
DoFade(4, 256);
}
void sub_0807F1A0(Entity* entity, ScriptExecutionContext* context) {
sub_0807DEDC(entity, context, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI);
gActiveScriptInfo.flags |= 1;
}
void sub_0807F1C4(Entity* entity, ScriptExecutionContext* context) {
if ((gPlayerState.flags.all & 8) != 0) {
gPlayerState.field_0x8 = 0x459;
} else {
gPlayerState.field_0x8 = 0x1bc;
}
}
void sub_0807F1E8(Entity* entity, ScriptExecutionContext* context) {
if ((gPlayerState.flags.all & 8) != 0) {
gPlayerState.field_0x8 = 0x45a;
} else {
gPlayerState.field_0x8 = 0x2bd;
}
}
void sub_0807F210(Entity* entity, ScriptExecutionContext* context) {
if ((gPlayerState.flags.all & 8) != 0) {
gPlayerState.field_0x8 = 0x41c;
} else {
gPlayerState.field_0x8 = 0x80c;
}
}
void sub_0807F238(Entity* entity, ScriptExecutionContext* context) {
gPlayerState.field_0x8 = context->intVariable;
}
void sub_0807F244(Entity* entity, ScriptExecutionContext* context) {
u32 slot;
u32 item;
item = context->intVariable & 0xFFFF;
slot = context->intVariable >> 0x10;
item &= 0xFFFF;
switch (item) {
case 1:
case 2:
case 3:
case 4:
case 6:
// Pick greatest sword unlocked
item = 1;
if (GetInventoryValue(2))
item = 2;
if (GetInventoryValue(3))
item = 3;
if (GetInventoryValue(4))
item = 4;
if (GetInventoryValue(6))
item = 6;
break;
}
ForceEquipItem(item, slot);
}
void sub_0807F29C(Entity* entity, ScriptExecutionContext* context) {
sub_0805ED14((void*)context->intVariable);
}
void sub_0807F2A8(Entity* entity, ScriptExecutionContext* context) {
if (gPlayerState.field_0x9c == 0) {
gActiveScriptInfo.flags |= 1;
} else {
gActiveScriptInfo.commandSize = 0;
}
}
void sub_0807F2D4(Entity* entity, ScriptExecutionContext* context) {
if ((entity->frames.all & 0x80) != 0) {
gActiveScriptInfo.flags |= 1;
} else {
gActiveScriptInfo.commandSize = 0;
}
}
void sub_0807F304(Entity* entity, ScriptExecutionContext* context) {
if ((gPlayerEntity.frames.all & 0x80) != 0) {
gActiveScriptInfo.flags |= 1;
} else {
gActiveScriptInfo.commandSize = 0;
}
}
void sub_0807F338(Entity* entity, ScriptExecutionContext* context) {
entity->hitbox = NULL;
entity->field_0x17 &= ~1;
}
void sub_0807F348(Entity* entity, ScriptExecutionContext* context) {
sub_0805E3A0(entity, 2);
}
void sub_0807F354(Entity* entity, ScriptExecutionContext* context) {
sub_0805E3A0(entity, 6);
}
void sub_0807F360(Entity* entity, ScriptExecutionContext* context) {
sub_0805E3A0(entity, 3);
}
void sub_0807F36C(Entity* entity, ScriptExecutionContext* context) {
Entity* fx;
fx = CreateFx(entity, 0x41, 0);
if (fx != NULL) {
fx->spritePriority.b0 = 1;
PositionRelative(entity, fx, 0, -524288);
if (Random() & 1)
fx->spriteSettings.b.flipX = 1;
if (Random() & 1)
fx->spriteSettings.b.flipY = 1;
}
}
void sub_0807F3C8(Entity* entity, ScriptExecutionContext* context) {
sub_0807F36C(entity, context);
SoundReq(SFX_BUTTON_DEPRESS);
}
void sub_0807F3D8(Entity* entity, ScriptExecutionContext* context) {
InitAnimationForceUpdate(entity, context->intVariable + (entity->animationState >> 1));
entity->field_0x80.HWORD = entity->animIndex;
}
void sub_0807F3F8(Entity* entity, ScriptExecutionContext* context) {
CreateSpeechBubbleExclamationMark(&gPlayerEntity, 8, -24);
}
void sub_0807F40C(Entity* entity, ScriptExecutionContext* context) {
CreateSpeechBubbleQuestionMark(&gPlayerEntity, 8, -24);
}
void sub_0807F420(Entity* entity, ScriptExecutionContext* context) {
MenuFadeIn(context->intVariable & 0xff, (u8)(context->intVariable >> 8));
}
void sub_0807F434(Entity* entity, ScriptExecutionContext* context) {
switch (entity->interactType) {
case 1:
entity->interactType = 0;
context->intVariable = 1;
break;
case 2:
entity->interactType = 0;
context->intVariable = 2;
break;
default:
context->intVariable = 0;
break;
}
gActiveScriptInfo.flags |= 1;
}
void sub_0807F464(Entity* entity, ScriptExecutionContext* context) {
s32 s32Var;
if (!context->unk_18) {
context->unk_18++;
context->postScriptActions |= 2;
s32Var = context->intVariable;
context->x.HALF.HI = gRoomControls.roomOriginX + s32Var;
context->y.HALF.HI = entity->y.HALF.HI;
if (s32Var > entity->x.HALF.HI - gRoomControls.roomOriginX) {
entity->direction = 64;
entity->animationState = (entity->animationState & 0x80) | 2;
} else {
entity->direction = -64;
entity->animationState = (entity->animationState & 0x80) | 6;
}
}
sub_0806F62C(entity, entity->speed, entity->direction);
if (((context->x.HALF.HI - entity->x.HALF.HI) ^ ((entity->direction & 0x80) << 24)) < 0)
entity->x.HALF.HI = context->x.HALF.HI;
else
gActiveScriptInfo.commandSize = 0;
}
void sub_0807F4F8(Entity* entity, ScriptExecutionContext* context) {
s32 s32Var;
if (!context->unk_18) {
context->unk_18++;
context->postScriptActions |= 2;
s32Var = context->intVariable;
context->x.HALF.HI = entity->x.HALF.HI;
context->y.HALF.HI = gRoomControls.roomOriginY + s32Var;
if (s32Var > entity->y.HALF.HI - gRoomControls.roomOriginY) {
entity->direction = 128;
entity->animationState = (entity->animationState & 0x80) | 4;
} else {
entity->direction = 0;
entity->animationState = (entity->animationState & 0x80);
}
}
sub_0806F62C(entity, entity->speed, entity->direction);
if (((context->y.HALF.HI - entity->y.HALF.HI) ^ ((entity->direction & 0x80) << 24)) >= 0)
entity->y.HALF.HI = context->y.HALF.HI;
else
gActiveScriptInfo.commandSize = 0;
}
void sub_0807F584(Entity* entity, ScriptExecutionContext* context) {
context->intVariable = gPlayerEntity.animationState >> 1;
}
void sub_0807F594(Entity* entity, ScriptExecutionContext* context) {
if (gPlayerState.field_0xa8)
gActiveScriptInfo.commandSize = 0;
}
void sub_0807F5B0(Entity* entity, ScriptExecutionContext* context) {
gPlayerState.field_0x27[0] = context->intVariable;
}
void sub_0807F5C0(Entity* entity, ScriptExecutionContext* context) {
s32 left;
s32 bottom;
if (gRoomControls.cameraTarget != NULL) {
left = gRoomControls.cameraTarget->x.HALF.HI - DISPLAY_WIDTH / 2;
bottom = gRoomControls.cameraTarget->y.HALF.HI - DISPLAY_HEIGHT / 2;
if (left < gRoomControls.roomOriginX)
left = gRoomControls.roomOriginX;
if (left > gRoomControls.roomOriginX + gRoomControls.width - DISPLAY_WIDTH)
left = gRoomControls.roomOriginX + gRoomControls.width - DISPLAY_WIDTH;
if (bottom < gRoomControls.roomOriginY)
bottom = gRoomControls.roomOriginY;
if (bottom > gRoomControls.roomOriginY + gRoomControls.height - DISPLAY_HEIGHT)
bottom = gRoomControls.roomOriginY + gRoomControls.height - DISPLAY_HEIGHT;
if (left == gRoomControls.roomScrollX && bottom == gRoomControls.roomScrollY)
gActiveScriptInfo.flags |= 1u;
else
gActiveScriptInfo.commandSize = 0;
}
}
void sub_0807F634(Entity* entity, ScriptExecutionContext* context) {
u16* p = (u16*)context->intVariable;
sub_0801DFB4(entity, p[0], p[1], p[2]);
gPlayerState.field_0x8b = 3;
}
void sub_0807F650(Entity* entity, ScriptExecutionContext* context) {
u32 p = sub_08002632(entity);
sub_0801DFB4(entity, gUnk_08001A7C[p][0], gUnk_08001A7C[p][1], gUnk_08001A7C[p][2]);
gPlayerState.field_0x8b = 3;
}
void sub_0807F680(Entity* entity, ScriptExecutionContext* context) {
context->condition = gPlayerEntity.x.HALF.HI - gRoomControls.roomOriginX > (s32)(context->intVariable & 0xffff);
gActiveScriptInfo.flags |= 1;
}
void sub_0807F6B4(Entity* entity, ScriptExecutionContext* context) {
context->condition = gPlayerEntity.y.HALF.HI - gRoomControls.roomOriginY > (s32)(context->intVariable & 0xffff);
gActiveScriptInfo.flags |= 1;
}
void sub_0807F6E8(Entity* entity, ScriptExecutionContext* context) {
gPlayerState.flags.all |= context->intVariable;
}
void sub_0807F6F8(Entity* entity, ScriptExecutionContext* context) {
gPlayerState.flags.all &= ~context->intVariable;
}
void sub_0807F708(Entity* entity, ScriptExecutionContext* context) {
ShowNPCDialogue(entity, (Dialog*)context->intVariable);
}
void sub_0807F714(Entity* entity, ScriptExecutionContext* context) {
entity->spriteRendering.b3 = gUnk_08114F30[entity->spriteRendering.b3];
ResolveEntityOnTop(entity, entity);
}
void sub_0807F738(Entity* entity, ScriptExecutionContext* context) {
entity->spriteRendering.b3 = gUnk_08114F34[entity->spriteRendering.b3];
sub_0806FAD8(entity, entity);
}
void sub_0807F75C(Entity* entity, ScriptExecutionContext* context) {
s32 s32Var = context->intVariable;
gPlayerEntity.x.HALF.HI = (s32Var >> 16) + gRoomControls.roomOriginX;
gPlayerEntity.y.HALF.HI = (s32Var & 0xffff) + gRoomControls.roomOriginY;
}
void sub_0807F77C(Entity* entity, ScriptExecutionContext* context) {
if (context->condition)
context->intVariable = 1;
else
context->intVariable = 0;
}
void sub_0807F78C(Entity* entity, ScriptExecutionContext* context) {
u32 item = context->intVariable;
u32 msg;
u32 price;
if (context->intVariable == 0)
item = gRoomVars.itemForSaleIndex;
msg = GetSaleItemConfirmMessageID(item);
price = GetItemPrice(item);
TextboxNoOverlap(msg, entity);
gTextBox.field_0x10 = (u16)price;
}
void sub_0807F7C4(Entity* entity, ScriptExecutionContext* context) {
u32 item = context->intVariable;
u32 msg;
u32 price;
if (context->intVariable == 0)
item = gRoomVars.itemForSaleIndex;
context->condition = GetItemPrice(item) <= gSave.stats.rupees;
gActiveScriptInfo.flags |= 1;
}
void sub_0807F800(Entity* entity, ScriptExecutionContext* context) {
u32 item = context->intVariable;
u32 msg;
u32 price;
if (context->intVariable == 0)
item = gRoomVars.itemForSaleIndex;
price = GetItemPrice(item);
ModRupees(-price);
sub_080A7C18(item, 0, 0);
gRoomVars.itemForSaleIndex = 0;
gActiveScriptInfo.flags |= 1;
}
void sub_0807F83C(Entity* entity, ScriptExecutionContext* context) {
sub_08079184();
}
void sub_0807F844(Entity* entity, ScriptExecutionContext* context) {
gRoomControls.cameraTarget = entity;
sub_080809D4();
}
void sub_0807F854(Entity* entity, ScriptExecutionContext* context) {
u32 value;
u32 idx;
idx = (context->intVariable >> 0x10) & 3;
value = context->intVariable & 0xffff;
switch (idx) {
case 0:
case 1:
gTextBox.field_0x10 = value;
break;
case 2:
gTextBox.field_0x14 = value;
break;
case 3:
gTextBox.field_0x18 = value;
break;
case 4:
gTextBox.field_0x1c = value;
break;
}
}
void sub_0807F8BC(Entity* entity, ScriptExecutionContext* context) {
if (sub_080040A8(entity))
context->condition = 1;
else
context->condition = 0;
}
void sub_0807F8D0(Entity* entity, ScriptExecutionContext* context) {
sub_08003FC4(entity, context->intVariable);
gActiveScriptInfo.flags |= 1;
}
void sub_0807F8E8(Entity* entity, ScriptExecutionContext* context) {
Entity* c = CreateObjectWithParent(entity, 0xA6, 0, 0);
if (c != NULL) {
c->parent = entity;
c->field_0x86.HWORD = (context->intVariable & 0x3ff) | 0x8000;
}
}
void sub_0807F918(Entity* entity, ScriptExecutionContext* context) {
PutItemOnSlot(context->intVariable);
}
void sub_0807F924(Entity* entity, ScriptExecutionContext* context) {
sub_0807879C(entity);
}
void sub_0807F92C(Entity* entity, ScriptExecutionContext* context) {
sub_080787C0(entity);
}
void sub_0807F934(Entity* entity, ScriptExecutionContext* context) {
sub_080787B4(entity);
}
void sub_0807F93C(Entity* entity, ScriptExecutionContext* context) {
CreateSpeechBubbleSleep(entity, (context->intVariable >> 8) & 0xff, context->intVariable & 0xff);
}
void sub_0807F950(Entity* entity, ScriptExecutionContext* context) {
Entity* c = FindEntity(6, 0x56, 6, 0, 2);
if (c != NULL)
DeleteEntity(c);
}
void sub_0807F970(Entity* entity, ScriptExecutionContext* context) {
context->condition = context->intVariable == gCurrentTextBox._28;
}
void sub_0807F98C(Entity* entity, ScriptExecutionContext* context) {
entity->height.WORD = context->intVariable;
}
void sub_0807F994(Entity* entity, ScriptExecutionContext* context) {
entity->spriteOffsetX = (s32)context->intVariable >> 0x10;
entity->spriteOffsetY = context->intVariable & 0xffff;
}
void sub_0807F9A4(Entity* entity, ScriptExecutionContext* context) {
switch (gPlayerState.field_0xa8) {
case 5:
case 7:
case 8:
case 10:
case 11:
case 12:
case 13:
case 14:
case 15:
case 16:
case 17:
case 18:
case 19:
case 20:
case 21:
case 22:
case 23:
case 24:
case 27:
case 28:
gActiveScriptInfo.commandSize = 0;
break;
default:
gActiveScriptInfo.flags |= 1u;
break;
}
}
void sub_0807FA40(Entity* entity, ScriptExecutionContext* context) {
switch (gPlayerState.field_0xa8) {
case 5:
case 7:
case 8:
case 10:
case 11:
case 12:
case 13:
case 14:
case 15:
case 16:
case 17:
case 18:
case 20:
case 21:
case 22:
case 23:
case 24:
case 27:
case 28:
gActiveScriptInfo.commandSize = 0;
break;
default:
gActiveScriptInfo.flags |= 1u;
break;
}
}
void sub_0807FADC(Entity* entity, ScriptExecutionContext* context) {
switch (context->unk_18) {
case 0:
context->unk_18++;
sub_0808C650(entity, context->intVariable);
break;
case 1:
if (sub_0808C67C())
context->unk_18++;
break;
case 2:
sub_0808C688();
return;
}
gActiveScriptInfo.commandSize = 0;
}
void sub_0807FB28(Entity* entity, ScriptExecutionContext* context) {
if (!context->unk_18)
sub_0801D7BC(0x7fff, 1);
context->unk_18++;
if (context->unk_18 >= context->intVariable)
sub_0801D7BC(0, 0);
else
gActiveScriptInfo.commandSize = 0;
}
void sub_0807FB64(Entity* entity, ScriptExecutionContext* context) {
gPlayerEntity.iframes = context->intVariable;
}
void sub_0807FB74(Entity* entity, ScriptExecutionContext* context) {
gPlayerState.swimState = 0;
gPlayerEntity.field_0x3c &= ~4;
}
void sub_0807FB94(Entity* entity, ScriptExecutionContext* context) {
InitScreen(SCREEN_CREDITS);
}
void sub_0807FBA0(Entity* entity, ScriptExecutionContext* context) {
entity->x.HALF.HI = gRoomControls.roomScrollX + 120;
entity->y.HALF.HI = gRoomControls.roomScrollY + 80;
}
void sub_0807FBB4(Entity* entity, ScriptExecutionContext* context) {
gPlayerState.field_0x1a[0] |= 0x80;
}
void sub_0807FBC4(Entity* entity, ScriptExecutionContext* context) {
sub_0805E4A0(entity);
}
void sub_0807FBCC(Entity* entity, ScriptExecutionContext* context) {
sub_0805E4CC(entity);
}
void sub_0807FBD4(Entity* entity, ScriptExecutionContext* context) {
sub_0806F62C(entity, entity->speed, entity->direction);
if (sub_080040A8(entity))
gActiveScriptInfo.commandSize = 0;
}
#ifndef EU
void sub_0807FBFC(Entity* entity, ScriptExecutionContext* context) {
gSave.stats.charm = 0;
gSave.stats.charmTimer = 0;
gSave.stats.unkB = 0;
gSave.stats.unkTimer = 0;
gSave.stats.effect = 0;
gSave.stats.effectTimer = 0;
}
#if defined(USA) || defined(DEMO_USA) || defined(DEMO_JP)
void sub_0807FC24(Entity* entity, ScriptExecutionContext* context) {
#if defined(DEMO_JP)
u32 idx = gRoomControls.roomID == 1 ? 0xcf : 0xd0;
#else
u32 idx = gRoomControls.roomID == 1 ? 0xcf : 0xd1;
#endif
SetLocalFlag(idx);
}
#endif
#endif