fix merge conflict

This commit is contained in:
theo3 2021-03-21 22:59:52 -07:00
commit f56a1cade6
116 changed files with 850 additions and 860 deletions

View File

@ -120,7 +120,7 @@ sub_0806D0F8: @ 0x0806D0F8
movs r0, #7
movs r1, #0x4c
movs r2, #7
bl FindEntityInListBySubtype
bl FindEntityByID
cmp r0, #0
beq _0806D10C
bl sub_0806D0B0
@ -928,7 +928,7 @@ sub_0806D6D0: @ 0x0806D6D0
movs r1, #0x4c
movs r2, #7
movs r3, #2
bl FindEntityInListByForm
bl FindEntity
adds r1, r0, #0
cmp r1, #0
beq _0806D6EE
@ -940,7 +940,7 @@ _0806D6EE:
movs r1, #0x4c
movs r2, #7
movs r3, #1
bl FindEntityInListByForm
bl FindEntity
adds r1, r0, #0
cmp r1, #0
beq _0806D706
@ -961,7 +961,7 @@ sub_0806D70C: @ 0x0806D70C
movs r1, #0x4c
movs r2, #7
movs r3, #2
bl FindEntityInListByForm
bl FindEntity
adds r2, r0, #0
cmp r2, #0
beq _0806D728
@ -972,7 +972,7 @@ _0806D728:
movs r1, #0x4c
movs r2, #7
movs r3, #1
bl FindEntityInListByForm
bl FindEntity
adds r2, r0, #0
cmp r2, #0
beq _0806D746
@ -996,7 +996,7 @@ sub_0806D74C: @ 0x0806D74C
movs r1, #0x4c
movs r2, #7
movs r3, #2
bl FindEntityInListByForm
bl FindEntity
adds r1, r0, #0
cmp r1, #0
beq _0806D76A
@ -1008,7 +1008,7 @@ _0806D76A:
movs r1, #0x4c
movs r2, #7
movs r3, #1
bl FindEntityInListByForm
bl FindEntity
adds r1, r0, #0
cmp r1, #0
beq _0806D782
@ -1029,7 +1029,7 @@ sub_0806D788: @ 0x0806D788
movs r1, #0x4c
movs r2, #7
movs r3, #2
bl FindEntityInListByForm
bl FindEntity
adds r1, r0, #0
cmp r1, #0
beq _0806D7A6
@ -1041,7 +1041,7 @@ _0806D7A6:
movs r1, #0x4c
movs r2, #7
movs r3, #1
bl FindEntityInListByForm
bl FindEntity
adds r1, r0, #0
cmp r1, #0
beq _0806D7BE
@ -1070,7 +1070,7 @@ sub_0806D7C4: @ 0x0806D7C4
movs r1, #0x4c
movs r2, #7
movs r3, #2
bl FindEntityInListByForm
bl FindEntity
cmp r0, #0
beq _0806D7FC
movs r1, #0x2e
@ -1098,7 +1098,7 @@ sub_0806D804: @ 0x0806D804
movs r1, #0x4c
movs r2, #7
movs r3, #2
bl FindEntityInListByForm
bl FindEntity
adds r1, r0, #0
cmp r1, #0
beq _0806D83A

View File

@ -639,7 +639,7 @@ CreateBird: @ 0x0809D700
movs r1, #0x95
movs r2, #6
movs r3, #8
bl FindEntityInListByForm
bl FindEntity
adds r4, r0, #0
cmp r4, #0
bne _0809D732

View File

@ -327,7 +327,7 @@ _0809B606:
movs r0, #7
movs r1, #0x1a
movs r2, #7
bl FindEntityInListBySubtype
bl FindEntityByID
adds r2, r0, #0
cmp r2, #0
beq _0809B682

View File

@ -1238,7 +1238,7 @@ _08002812:
cmp r0, #0
beq _08002834
adds r6, #1
bl sub_0806F9EC
bl FixedMul
lsls r0, r0, #8
_08002834:
adds r4, r0, #0
@ -1256,7 +1256,7 @@ _0800283E:
cmp r0, #0
beq _08002856
adds r6, #2
bl sub_0806F9EC
bl FixedMul
lsls r0, r0, #8
_08002856:
adds r4, r0, #0

View File

@ -217,8 +217,8 @@ _0801DA02:
mov sl, r5
pop {r4, r5, r6, r7, pc}
thumb_func_start sub_0801DA0C
sub_0801DA0C: @ 0x0801DA0C
thumb_func_start zFree
zFree: @ 0x0801DA0C
push {r4, r5, lr}
ldr r3, _0801DA44 @ =gzHeap
subs r1, r0, r3
@ -287,8 +287,8 @@ zMallocInit: @ 0x0801DA7C
.align 2, 0
_0801DA8C: .4byte gzHeap
thumb_func_start sub_0801DA90
sub_0801DA90: @ 0x0801DA90
thumb_func_start DispReset
DispReset: @ 0x0801DA90
push {r4, r5, lr}
adds r4, r0, #0
ldr r1, _0801DAEC @ =gMain
@ -319,7 +319,7 @@ sub_0801DA90: @ 0x0801DA90
movs r0, #0x80
lsls r0, r0, #0x13
strh r3, [r0]
bl sub_0801DB10
bl ClearOAM
bl sub_0801DB34
ldr r0, _0801DB08 @ =0x0600C000
movs r1, #0x20
@ -341,8 +341,8 @@ _0801DB04: .4byte 0x00007FFF
_0801DB08: .4byte 0x0600C000
_0801DB0C: .4byte gBG0Buffer
thumb_func_start sub_0801DB10
sub_0801DB10: @ 0x0801DB10
thumb_func_start ClearOAM
ClearOAM: @ 0x0801DB10
push {r4, lr}
ldr r3, _0801DB30 @ =gUnk_03000020
movs r1, #0xe0

View File

@ -9,7 +9,7 @@
sub_0804AB70: @ 0x0804AB70
push {r4, r5, lr}
movs r0, #0
bl sub_0801DA90
bl DispReset
ldr r1, _0804ABF8 @ =gScreen
movs r2, #0
movs r0, #0x92

View File

@ -2013,7 +2013,7 @@ sub_0805368C: @ 0x0805368C
movs r0, #6
movs r1, #0x5d
movs r2, #6
bl FindEntityInListBySubtype
bl FindEntityByID
cmp r0, #0
beq _080536A6
bl DeleteEntity
@ -2139,7 +2139,7 @@ sub_08053758: @ 0x08053758
strh r2, [r0, #0xa]
bl sub_0801B170
movs r0, #0
bl sub_0801DA90
bl DispReset
ldr r2, _080537F0 @ =gScreen
movs r0, #0x99
lsls r0, r0, #6
@ -2380,7 +2380,7 @@ sub_08053974: @ 0x08053974
bne _080539A8
bl sub_0804FFE4
movs r0, #1
bl sub_0801DA90
bl DispReset
bl sub_080197AC
bl sub_08051F78
ldr r0, _080539B0 @ =gUnk_080FCBC4
@ -2437,7 +2437,7 @@ sub_080539F4: @ 0x080539F4
cmp r0, #0
bne _08053A10
movs r0, #1
bl sub_0801DA90
bl DispReset
ldr r0, _08053A18 @ =gMenu
ldrb r1, [r0, #6]
adds r1, #1
@ -2587,7 +2587,7 @@ sub_08053B10: @ 0x08053B10
adds r1, #1
strb r1, [r0, #5]
movs r0, #1
bl sub_0801DA90
bl DispReset
movs r1, #0x80
lsls r1, r1, #1
movs r0, #4
@ -2673,7 +2673,7 @@ sub_08053BBC: @ 0x08053BBC
adds r1, #1
strb r1, [r0, #5]
movs r0, #1
bl sub_0801DA90
bl DispReset
movs r1, #0x80
lsls r1, r1, #1
movs r0, #4

View File

@ -33,7 +33,7 @@ sub_0805488C: @ 0x0805488C
lsls r0, r0, #1
strh r0, [r2, #8]
movs r0, #0
bl sub_0801DA90
bl DispReset
ldrb r0, [r4, #3]
movs r1, #1
bl sub_08054974
@ -2571,7 +2571,7 @@ _08055C6C:
movs r1, #0x9e
movs r2, #6
movs r3, #0
bl FindEntityInListByForm
bl FindEntity
adds r4, r0, #0
cmp r4, #0
beq _08055C8C

View File

@ -27,7 +27,7 @@ sub_0806EC38: @ 0x0806EC38
movs r0, #7
movs r1, #0x58
movs r2, #7
bl FindEntityInListBySubtype
bl FindEntityByID
cmp r0, #0
beq _0806EC4C
bl DeleteEntity

View File

@ -1193,13 +1193,13 @@ sub_0806F5BC: @ 0x0806F5BC
lsls r5, r1, #0x10
asrs r5, r5, #0x10
adds r1, r5, #0
bl sub_0806F9EC
bl FixedMul
lsls r0, r0, #0x10
asrs r0, r0, #0x10
movs r6, #0x80
lsls r6, r6, #1
adds r1, r6, #0
bl sub_0806FA04
bl FixedDiv
lsls r0, r0, #0x10
asrs r0, r0, #8
ldr r1, [r7, #0x2c]
@ -1211,11 +1211,11 @@ sub_0806F5BC: @ 0x0806F5BC
movs r1, #0
ldrsh r0, [r4, r1]
adds r1, r5, #0
bl sub_0806F9EC
bl FixedMul
lsls r0, r0, #0x10
asrs r0, r0, #0x10
adds r1, r6, #0
bl sub_0806FA04
bl FixedDiv
lsls r0, r0, #0x10
asrs r0, r0, #8
ldr r1, [r7, #0x30]
@ -1248,13 +1248,13 @@ sub_0806F62C: @ 0x0806F62C
lsls r5, r5, #0x10
asrs r5, r5, #0x10
adds r1, r5, #0
bl sub_0806F9EC
bl FixedMul
lsls r0, r0, #0x10
asrs r0, r0, #0x10
movs r1, #0x80
lsls r1, r1, #1
mov r8, r1
bl sub_0806FA04
bl FixedDiv
lsls r0, r0, #0x10
asrs r0, r0, #8
ldr r1, [r6, #0x2c]
@ -1266,11 +1266,11 @@ sub_0806F62C: @ 0x0806F62C
movs r1, #0
ldrsh r0, [r4, r1]
adds r1, r5, #0
bl sub_0806F9EC
bl FixedMul
lsls r0, r0, #0x10
asrs r0, r0, #0x10
mov r1, r8
bl sub_0806FA04
bl FixedDiv
lsls r0, r0, #0x10
asrs r0, r0, #8
ldr r1, [r6, #0x30]
@ -1300,13 +1300,13 @@ sub_0806F69C: @ 0x0806F69C
ldrsh r0, [r0, r1]
movs r2, #0x24
ldrsh r1, [r6, r2]
bl sub_0806F9EC
bl FixedMul
lsls r0, r0, #0x10
asrs r0, r0, #0x10
movs r4, #0x80
lsls r4, r4, #1
adds r1, r4, #0
bl sub_0806FA04
bl FixedDiv
lsls r0, r0, #0x10
asrs r0, r0, #8
ldr r1, [r6, #0x2c]
@ -1320,11 +1320,11 @@ sub_0806F69C: @ 0x0806F69C
ldrsh r0, [r0, r1]
movs r2, #0x24
ldrsh r1, [r6, r2]
bl sub_0806F9EC
bl FixedMul
lsls r0, r0, #0x10
asrs r0, r0, #0x10
adds r1, r4, #0
bl sub_0806FA04
bl FixedDiv
lsls r0, r0, #0x10
asrs r0, r0, #8
ldr r1, [r6, #0x30]

View File

@ -139,7 +139,7 @@ UnloadHitbox: @ 0x0806FBEC
push {r4, lr}
adds r4, r0, #0
ldr r0, [r4, #0x48]
bl sub_0801DA0C
bl zFree
movs r0, #0
str r0, [r4, #0x48]
pop {r4, pc}

View File

@ -4592,7 +4592,7 @@ _080754F2:
movs r0, #8
movs r1, #0xf
movs r2, #2
bl FindEntityInListBySubtype
bl FindEntityByID
cmp r0, #0
bne _08075538
adds r0, r4, #0
@ -6017,7 +6017,7 @@ sub_08075FF8: @ 0x08075FF8
movs r0, #8
movs r1, #2
movs r2, #2
bl FindEntityInListBySubtype
bl FindEntityByID
b _08076026
.align 2, 0
_08076018: .4byte gPlayerState
@ -6025,7 +6025,7 @@ _0807601C:
adds r5, #1
adds r0, r4, #0
movs r1, #2
bl FindNextEntityOfSameSubtype
bl FindNextDuplicateID
_08076026:
adds r4, r0, #0
cmp r4, #0

View File

@ -44,7 +44,7 @@ _080788BA:
movs r0, #6
movs r1, #9
movs r2, #6
bl FindEntityInListBySubtype
bl FindEntityByID
cmp r0, #0
bne _080788D6
movs r0, #9

View File

@ -1228,7 +1228,7 @@ sub_0807F950: @ 0x0807F950
movs r1, #0x56
movs r2, #6
movs r3, #0
bl FindEntityInListByForm
bl FindEntity
cmp r0, #0
beq _0807F96C
bl DeleteEntity

View File

@ -96,13 +96,13 @@ sub_080A2AF4: @ 0x080A2AF4
lsls r4, r4, #0x18
asrs r4, r4, #0x10
adds r1, r4, #0
bl sub_0806F9EC
bl FixedMul
lsls r0, r0, #0x10
asrs r0, r0, #0x10
movs r5, #0x80
lsls r5, r5, #1
adds r1, r5, #0
bl sub_0806FA04
bl FixedDiv
lsls r0, r0, #0x10
asrs r0, r0, #8
ldr r1, [r6, #0x2c]
@ -115,11 +115,11 @@ sub_080A2AF4: @ 0x080A2AF4
movs r1, #0
ldrsh r0, [r0, r1]
adds r1, r4, #0
bl sub_0806F9EC
bl FixedMul
lsls r0, r0, #0x10
asrs r0, r0, #0x10
adds r1, r5, #0
bl sub_0806FA04
bl FixedDiv
lsls r0, r0, #0x10
asrs r0, r0, #8
ldr r1, [r6, #0x30]

View File

@ -266,7 +266,7 @@ _080A365C:
_080A365E:
str r0, [r2, #0xc]
movs r0, #0
bl sub_0801DA90
bl DispReset
movs r0, #0xb
bl LoadPaletteGroup
movs r0, #0xc
@ -699,7 +699,7 @@ _080A39C8:
strh r0, [r2, #8]
strb r4, [r2, #3]
movs r0, #1
bl sub_0801DA90
bl DispReset
bl sub_080A3210
bl sub_080A4D34
movs r0, #0xa

View File

@ -3782,7 +3782,7 @@ sub_080A7328: @ 0x080A7328
movs r0, #8
strb r0, [r4, #8]
movs r0, #1
bl sub_0801DA90
bl DispReset
bl MessageInitialize
bl sub_080ADD30
movs r0, #0

View File

@ -160,7 +160,7 @@ _080441F2:
cmp r2, #0
bne _08044248
ldr r0, [r4, #0x64]
bl sub_0801DA0C
bl zFree
b _0804429A
.align 2, 0
_08044244: .4byte 0x000001EB

View File

@ -341,13 +341,13 @@ _080864EE:
ldrsh r0, [r0, r1]
movs r1, #0x80
lsls r1, r1, #6
bl sub_0806F9EC
bl FixedMul
lsls r0, r0, #0x10
asrs r0, r0, #0x10
movs r4, #0x80
lsls r4, r4, #1
adds r1, r4, #0
bl sub_0806FA04
bl FixedDiv
adds r1, r6, #0
adds r1, #0x80
lsls r0, r0, #0x10
@ -363,11 +363,11 @@ _080864EE:
ldrsh r0, [r0, r3]
movs r1, #0x80
lsls r1, r1, #5
bl sub_0806F9EC
bl FixedMul
lsls r0, r0, #0x10
asrs r0, r0, #0x10
adds r1, r4, #0
bl sub_0806FA04
bl FixedDiv
adds r1, r6, #0
adds r1, #0x84
lsls r0, r0, #0x10
@ -520,13 +520,13 @@ _0808663A:
ldrsh r0, [r0, r1]
movs r1, #0x80
lsls r1, r1, #6
bl sub_0806F9EC
bl FixedMul
lsls r0, r0, #0x10
asrs r0, r0, #0x10
movs r5, #0x80
lsls r5, r5, #1
adds r1, r5, #0
bl sub_0806FA04
bl FixedDiv
adds r1, r7, #0
adds r1, #0x80
lsls r0, r0, #0x10
@ -541,11 +541,11 @@ _0808663A:
ldrsh r0, [r0, r1]
movs r1, #0x80
lsls r1, r1, #5
bl sub_0806F9EC
bl FixedMul
lsls r0, r0, #0x10
asrs r0, r0, #0x10
adds r1, r5, #0
bl sub_0806FA04
bl FixedDiv
adds r1, r7, #0
adds r1, #0x84
lsls r0, r0, #0x10

View File

@ -33,7 +33,7 @@ sub_080519B0: @ 0x080519B0
cmp r5, #0
bne _08051A02
movs r0, #1
bl sub_0801DA90
bl DispReset
bl sub_080A3210
bl zMallocInit
bl sub_080A7124
@ -69,7 +69,7 @@ _08051A10: .4byte gMain
sub_08051A14: @ 0x08051A14
push {lr}
movs r0, #1
bl sub_0801DA90
bl DispReset
ldr r1, _08051A70 @ =gFadeControl
movs r0, #1
rsbs r0, r0, #0
@ -368,7 +368,7 @@ sub_08051CF0: @ 0x08051CF0
cmp r4, #0
bne _08051D1E
movs r0, #1
bl sub_0801DA90
bl DispReset
strb r6, [r5, #3]
strb r4, [r5, #4]
ldr r0, _08051D28 @ =gScreenTransition
@ -729,7 +729,7 @@ sub_08052010: @ 0x08052010
bl sub_080A3210
bl MessageInitialize
movs r0, #1
bl sub_0801DA90
bl DispReset
ldr r0, _0805207C @ =gBG1Buffer
movs r4, #0x80
lsls r4, r4, #4

View File

@ -355,7 +355,7 @@ sub_080A0464: @ 0x080A0464
movs r0, #6
movs r1, #0xac
movs r2, #6
bl FindEntityInListBySubtype
bl FindEntityByID
cmp r0, #0
beq _080A048A
movs r1, #0x2e

View File

@ -2824,11 +2824,11 @@ _0802E580:
ldrb r1, [r6]
lsls r1, r1, #0x18
asrs r1, r1, #0x10
bl sub_0806F9EC
bl FixedMul
lsls r0, r0, #0x10
asrs r0, r0, #0x10
adds r1, r7, #0
bl sub_0806FA04
bl FixedDiv
adds r1, r0, #0
ldrb r0, [r4, #1]
lsls r0, r0, #4
@ -2838,11 +2838,11 @@ _0802E580:
ldrsh r0, [r0, r2]
lsls r1, r1, #0x10
asrs r1, r1, #0x10
bl sub_0806F9EC
bl FixedMul
lsls r0, r0, #0x10
asrs r0, r0, #0x10
adds r1, r7, #0
bl sub_0806FA04
bl FixedDiv
ldr r2, [r5]
lsls r0, r0, #0x10
asrs r0, r0, #8
@ -2859,11 +2859,11 @@ _0802E580:
ldrb r1, [r6]
lsls r1, r1, #0x18
asrs r1, r1, #0x10
bl sub_0806F9EC
bl FixedMul
lsls r0, r0, #0x10
asrs r0, r0, #0x10
adds r1, r7, #0
bl sub_0806FA04
bl FixedDiv
ldr r2, [r5]
lsls r0, r0, #0x10
asrs r0, r0, #8

View File

@ -153,7 +153,7 @@ sub_08064180: @ 0x08064180
movs r0, #7
movs r1, #0x15
movs r2, #7
bl FindEntityInListBySubtype
bl FindEntityByID
cmp r0, #0
beq _08064194
bl DeleteEntity

View File

@ -656,7 +656,7 @@ sub_0806252C: @ 0x0806252C
lsls r0, r1, #0x10
asrs r0, r0, #0x10
movs r1, #0x14
bl sub_0806FA04
bl FixedDiv
lsls r0, r0, #0x10
asrs r0, r0, #0x10
mov sl, r0
@ -664,7 +664,7 @@ sub_0806252C: @ 0x0806252C
lsls r0, r2, #0x10
asrs r0, r0, #0x10
movs r1, #0x14
bl sub_0806FA04
bl FixedDiv
lsls r0, r0, #0x10
asrs r0, r0, #0x10
mov r8, r0

View File

@ -73,7 +73,7 @@ _08085566:
b _0808557A
_0808556C:
adds r0, r4, #0
bl DoesSimilarEntityExist
bl EntityHasDuplicateID
cmp r0, #0
beq _0808557A
bl DeleteThisEntity
@ -349,13 +349,13 @@ _08085774:
lsls r4, r4, #0x10
asrs r4, r4, #0x18
adds r1, r4, #0
bl sub_0806F9EC
bl FixedMul
lsls r0, r0, #0x10
asrs r0, r0, #0x10
movs r5, #0x80
lsls r5, r5, #1
adds r1, r5, #0
bl sub_0806FA04
bl FixedDiv
lsls r0, r0, #0x10
asrs r0, r0, #8
ldr r1, [r7, #0x6c]
@ -368,11 +368,11 @@ _08085774:
movs r2, #0
ldrsh r0, [r0, r2]
adds r1, r4, #0
bl sub_0806F9EC
bl FixedMul
lsls r0, r0, #0x10
asrs r0, r0, #0x10
adds r1, r5, #0
bl sub_0806FA04
bl FixedDiv
lsls r0, r0, #0x10
asrs r0, r0, #8
ldr r1, [r7, #0x70]
@ -441,7 +441,7 @@ _0808581A:
movs r4, #0x80
lsls r4, r4, #1
adds r1, r4, #0
bl sub_0806F9EC
bl FixedMul
lsls r0, r0, #0x10
asrs r0, r0, #0x10
ldr r5, _080858A8 @ =gSineTable
@ -450,13 +450,13 @@ _0808581A:
adds r1, r1, r5
movs r2, #0
ldrsh r1, [r1, r2]
bl sub_0806FA04
bl FixedDiv
strh r0, [r7, #0x24]
ldr r0, [r7, #0x70]
lsls r0, r0, #8
asrs r0, r0, #0x10
adds r1, r4, #0
bl sub_0806F9EC
bl FixedMul
lsls r0, r0, #0x10
asrs r0, r0, #0x10
ldrb r1, [r7, #0x15]
@ -465,7 +465,7 @@ _0808581A:
adds r1, r1, r5
movs r2, #0
ldrsh r1, [r1, r2]
bl sub_0806FA04
bl FixedDiv
lsls r0, r0, #0x10
asrs r0, r0, #0x10
rsbs r4, r0, #0
@ -1072,7 +1072,7 @@ _08085D0C:
sub_08085D10: @ 0x08085D10
push {r4, lr}
adds r4, r0, #0
bl DoesSimilarEntityExist
bl EntityHasDuplicateID
cmp r0, #0
beq _08085D26
ldrb r0, [r4, #0xb]

View File

@ -19,14 +19,14 @@ LoadRoomEntity: @ 0x0804ADF8
bne _0804AE1C
ldrb r1, [r4, #2]
adds r0, r6, #0
bl FindEntityBySubtype
bl DeepFindEntityByID
cmp r0, #0
beq _0804AE1C
movs r0, #0
b _0804AEAC
_0804AE1C:
adds r0, r6, #0
bl GetEmptyEntityByType
bl GetEmptyEntityByKind
adds r5, r0, #0
cmp r5, #0
beq _0804AEAA

View File

@ -360,7 +360,7 @@ sub_0809AA00: @ 0x0809AA00
movs r0, #7
movs r1, #0x38
movs r2, #7
bl FindEntityInListBySubtype
bl FindEntityByID
adds r4, r0, #0
adds r7, r5, #0
adds r7, #0x78
@ -380,7 +380,7 @@ _0809AA30:
_0809AA3A:
adds r0, r4, #0
movs r1, #7
bl FindNextEntityOfSameSubtype
bl FindNextDuplicateID
adds r4, r0, #0
cmp r4, #0
bne _0809AA30

View File

@ -30,7 +30,7 @@ _08059E7C: .4byte gUnk_081085A4
sub_08059E80: @ 0x08059E80
push {r4, r5, lr}
adds r4, r0, #0
bl DoesSimilarEntityExist
bl EntityHasDuplicateID
cmp r0, #0
beq _08059E90
bl DeleteThisEntity

View File

@ -10,7 +10,7 @@
sub_0805B3B4: @ 0x0805B3B4
push {r4, r5, lr}
adds r4, r0, #0
bl DoesSimilarEntityExist
bl EntityHasDuplicateID
cmp r0, #0
beq _0805B3C4
bl DeleteThisEntity

View File

@ -342,7 +342,7 @@ _0805BB82:
strh r1, [r2, #0xc]
movs r0, #9
movs r1, #0x22
bl FindEntityBySubtype
bl DeepFindEntityByID
cmp r0, #0
beq _0805BBAE
bl sub_0805B8EC

View File

@ -72,7 +72,7 @@ sub_0805DE18: @ 0x0805DE18
movs r0, #9
movs r1, #0x36
movs r2, #6
bl FindEntityInListByForm
bl FindEntity
cmp r0, #0
beq _0805DE34
bl DeleteEntityAny

View File

@ -492,7 +492,7 @@ sub_08059278: @ 0x08059278
movs r0, #9
movs r1, #0xf
movs r2, #6
bl FindEntityInListBySubtype
bl FindEntityByID
cmp r0, #0
beq _0805928C
bl sub_08058ECC

View File

@ -1,62 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.syntax unified
.text
thumb_func_start sub_08090F00
sub_08090F00: @ 0x08090F00
push {r4, r5, r6, lr}
adds r4, r0, #0
ldrb r1, [r4, #0xa]
cmp r1, #1
bne _08090F1C
ldr r0, [r4, #0x50]
ldrb r2, [r4, #0xf]
lsls r1, r2
ldr r0, [r0, #0x20]
ands r0, r1
cmp r0, #0
bne _08090F1C
bl DeleteThisEntity
_08090F1C:
ldr r6, _08090F64 @ =gPlayerState
ldr r0, [r6, #0x30]
movs r1, #0x80
ands r0, r1
cmp r0, #0
beq _08090F62
ldr r5, _08090F68 @ =gPlayerEntity
adds r0, r4, #0
adds r1, r5, #0
movs r2, #4
movs r3, #4
bl sub_080041A0
cmp r0, #0
beq _08090F62
movs r1, #0x36
ldrsh r0, [r5, r1]
cmp r0, #0
bne _08090F62
adds r2, r6, #0
adds r2, #0x90
ldr r1, _08090F6C @ =gUnk_0812225C
ldrb r0, [r4, #0xb]
lsls r0, r0, #1
adds r0, r0, r1
ldrh r1, [r2]
ldrh r0, [r0]
ands r0, r1
cmp r0, #0
beq _08090F62
ldrb r0, [r4, #0xe]
bl GetCurrentRoomProperty
bl DoExitTransition
_08090F62:
pop {r4, r5, r6, pc}
.align 2, 0
_08090F64: .4byte gPlayerState
_08090F68: .4byte gPlayerEntity
_08090F6C: .4byte gUnk_0812225C

View File

@ -247,7 +247,7 @@ sub_0808D280: @ 0x0808D280
movs r1, #0x3e
movs r2, #6
movs r3, #9
bl FindEntityInListByForm
bl FindEntity
adds r2, r0, #0
cmp r2, #0
beq _0808D2C4
@ -287,7 +287,7 @@ sub_0808D2CC: @ 0x0808D2CC
movs r1, #0x3e
movs r2, #6
movs r3, #1
bl FindEntityInListByForm
bl FindEntity
adds r1, r0, #0
cmp r1, #0
beq _0808D2F2

View File

@ -235,7 +235,7 @@ sub_08094BE0: @ 0x08094BE0
movs r1, #0x6a
movs r2, #6
movs r3, #0x22
bl FindEntityInListByForm
bl FindEntity
adds r4, r0, #0
cmp r4, #0
beq _08094C22
@ -390,7 +390,7 @@ sub_08094D10: @ 0x08094D10
movs r1, #0x6a
movs r2, #6
movs r3, #3
bl FindEntityInListByForm
bl FindEntity
adds r1, r0, #0
cmp r1, #0
beq _08094D2E
@ -442,7 +442,7 @@ sub_08094D70: @ 0x08094D70
movs r1, #0x6a
movs r2, #6
movs r3, #0x15
bl FindEntityInListByForm
bl FindEntity
adds r1, r0, #0
cmp r1, #0
beq _08094D8E
@ -527,7 +527,7 @@ sub_08094E0C: @ 0x08094E0C
movs r1, #0x6a
movs r2, #6
movs r3, #4
bl FindEntityInListByForm
bl FindEntity
adds r1, r0, #0
cmp r1, #0
beq _08094E2A
@ -951,7 +951,7 @@ sub_08095164: @ 0x08095164
movs r1, #0x6a
movs r2, #6
movs r3, #8
bl FindEntityInListByForm
bl FindEntity
cmp r0, #0
beq _08095182
movs r1, #3
@ -2103,7 +2103,7 @@ sub_08095A68: @ 0x08095A68
movs r1, #0x6a
movs r2, #6
movs r3, #0x16
bl FindEntityInListByForm
bl FindEntity
adds r1, r0, #0
cmp r1, #0
beq _08095A86

View File

@ -968,13 +968,13 @@ sub_0809A648: @ 0x0809A648
lsls r5, r5, #8
asrs r5, r5, #0x10
adds r1, r5, #0
bl sub_0806F9EC
bl FixedMul
lsls r0, r0, #0x10
asrs r0, r0, #0x10
movs r4, #0x80
lsls r4, r4, #1
adds r1, r4, #0
bl sub_0806FA04
bl FixedDiv
ldr r1, [r7, #0x50]
lsls r0, r0, #0x10
asrs r0, r0, #8
@ -989,11 +989,11 @@ sub_0809A648: @ 0x0809A648
movs r2, #0
ldrsh r0, [r0, r2]
adds r1, r5, #0
bl sub_0806F9EC
bl FixedMul
lsls r0, r0, #0x10
asrs r0, r0, #0x10
adds r1, r4, #0
bl sub_0806FA04
bl FixedDiv
ldr r1, [r7, #0x50]
lsls r0, r0, #0x10
asrs r0, r0, #8

View File

@ -1024,13 +1024,13 @@ sub_0809CB70: @ 0x0809CB70
lsls r5, r5, #0x10
asrs r5, r5, #0x10
adds r1, r5, #0
bl sub_0806F9EC
bl FixedMul
lsls r0, r0, #0x10
asrs r0, r0, #0x10
movs r1, #0x80
lsls r1, r1, #1
mov r8, r1
bl sub_0806FA04
bl FixedDiv
ldr r1, [r6, #0x50]
lsls r0, r0, #0x10
asrs r0, r0, #8
@ -1043,11 +1043,11 @@ sub_0809CB70: @ 0x0809CB70
movs r1, #0
ldrsh r0, [r4, r1]
adds r1, r5, #0
bl sub_0806F9EC
bl FixedMul
lsls r0, r0, #0x10
asrs r0, r0, #0x10
mov r1, r8
bl sub_0806FA04
bl FixedDiv
ldr r2, [r6, #0x50]
lsls r0, r0, #0x10
asrs r0, r0, #8

View File

@ -62,7 +62,7 @@ sub_0809D9D8: @ 0x0809D9D8
bl InitAnimationForceUpdate
adds r0, r4, #0
movs r1, #6
bl FindNextEntityOfSameSubtype
bl FindNextDuplicateID
cmp r0, #0
beq _0809DA1E
str r4, [r0, #0x50]
@ -436,7 +436,7 @@ sub_0809DC80: @ 0x0809DC80
bl InitAnimationForceUpdate
adds r0, r4, #0
movs r1, #6
bl FindNextEntityOfSameSubtype
bl FindNextDuplicateID
cmp r0, #0
beq _0809DD00
str r4, [r0, #0x50]
@ -1141,7 +1141,7 @@ sub_0809E238: @ 0x0809E238
adds r5, #0x6c
movs r2, #0
ldrsh r1, [r5, r2]
bl sub_0806F9EC
bl FixedMul
adds r4, r0, #0
lsls r4, r4, #0x10
asrs r4, r4, #0x10
@ -1154,7 +1154,7 @@ sub_0809E238: @ 0x0809E238
ldrsh r0, [r0, r2]
movs r2, #0
ldrsh r1, [r5, r2]
bl sub_0806F9EC
bl FixedMul
lsls r0, r0, #0x10
asrs r0, r0, #0x10
adds r1, r7, #0

View File

@ -597,13 +597,13 @@ _08035616:
adds r1, r4, #0
ands r1, r2
lsls r1, r1, #8
bl sub_0806F9EC
bl FixedMul
lsls r0, r0, #0x10
asrs r0, r0, #0x10
movs r5, #0x80
lsls r5, r5, #1
adds r1, r5, #0
bl sub_0806FA04
bl FixedDiv
lsrs r0, r0, #8
adds r1, r7, #0
adds r1, #0x62
@ -619,11 +619,11 @@ _08035616:
ands r4, r1
lsls r4, r4, #8
adds r1, r4, #0
bl sub_0806F9EC
bl FixedMul
lsls r0, r0, #0x10
asrs r0, r0, #0x10
adds r1, r5, #0
bl sub_0806FA04
bl FixedDiv
lsls r0, r0, #0x10
asrs r0, r0, #8
rsbs r0, r0, #0
@ -3086,13 +3086,13 @@ sub_08036914: @ 0x08036914
lsls r6, r6, #0x10
asrs r6, r6, #0x10
adds r1, r6, #0
bl sub_0806F9EC
bl FixedMul
lsls r0, r0, #0x10
asrs r0, r0, #0x10
movs r1, #0x80
lsls r1, r1, #1
mov r8, r1
bl sub_0806FA04
bl FixedDiv
ldr r1, [r5, #0x50]
lsls r0, r0, #0x10
asrs r0, r0, #8
@ -3105,11 +3105,11 @@ sub_08036914: @ 0x08036914
movs r1, #0
ldrsh r0, [r4, r1]
adds r1, r6, #0
bl sub_0806F9EC
bl FixedMul
lsls r0, r0, #0x10
asrs r0, r0, #0x10
mov r1, r8
bl sub_0806FA04
bl FixedDiv
ldr r2, [r5, #0x50]
lsls r0, r0, #0x10
asrs r0, r0, #8
@ -3270,11 +3270,11 @@ _08036A78:
movs r1, #0
ldrsh r0, [r0, r1]
adds r1, r6, #0
bl sub_0806F9EC
bl FixedMul
lsls r0, r0, #0x10
asrs r0, r0, #0x10
adds r1, r7, #0
bl sub_0806FA04
bl FixedDiv
ldr r2, [r5]
ldr r1, [r5, #4]
lsls r0, r0, #0x10
@ -3293,11 +3293,11 @@ _08036A78:
movs r1, #0
ldrsh r0, [r0, r1]
adds r1, r6, #0
bl sub_0806F9EC
bl FixedMul
lsls r0, r0, #0x10
asrs r0, r0, #0x10
adds r1, r7, #0
bl sub_0806FA04
bl FixedDiv
ldr r2, [r5]
ldr r1, [r5, #4]
lsls r0, r0, #0x10
@ -3386,12 +3386,12 @@ _08036B48:
movs r3, #0
ldrsh r0, [r0, r3]
mov r1, sl
bl sub_0806F9EC
bl FixedMul
lsls r0, r0, #0x10
asrs r0, r0, #0x10
movs r1, #0x80
lsls r1, r1, #1
bl sub_0806FA04
bl FixedDiv
ldr r2, [r5]
ldr r1, [r6]
lsls r0, r0, #0x10
@ -3409,12 +3409,12 @@ _08036B48:
movs r2, #0
ldrsh r0, [r0, r2]
mov r1, sl
bl sub_0806F9EC
bl FixedMul
lsls r0, r0, #0x10
asrs r0, r0, #0x10
movs r1, #0x80
lsls r1, r1, #1
bl sub_0806FA04
bl FixedDiv
ldr r2, [r5]
ldr r1, [r6]
b _08036C6E
@ -3475,12 +3475,12 @@ _08036C0E:
movs r2, #0
ldrsh r0, [r0, r2]
mov r1, sl
bl sub_0806F9EC
bl FixedMul
lsls r0, r0, #0x10
asrs r0, r0, #0x10
movs r1, #0x80
lsls r1, r1, #1
bl sub_0806FA04
bl FixedDiv
ldr r2, [r4]
adds r5, r6, r7
ldr r1, [r5]
@ -3499,12 +3499,12 @@ _08036C0E:
movs r1, #0
ldrsh r0, [r0, r1]
mov r1, sl
bl sub_0806F9EC
bl FixedMul
lsls r0, r0, #0x10
asrs r0, r0, #0x10
movs r1, #0x80
lsls r1, r1, #1
bl sub_0806FA04
bl FixedDiv
ldr r2, [r4]
ldr r1, [r5]
_08036C6E:

View File

@ -235,7 +235,7 @@ sub_08063C14: @ 0x08063C14
push {lr}
movs r0, #7
movs r1, #0x14
bl FindEntityBySubtype
bl DeepFindEntityByID
cmp r0, #0
beq _08063C28
movs r1, #8
@ -249,7 +249,7 @@ sub_08063C2C: @ 0x08063C2C
push {lr}
movs r0, #7
movs r1, #0x14
bl FindEntityBySubtype
bl DeepFindEntityByID
cmp r0, #0
beq _08063C40
movs r1, #4
@ -263,7 +263,7 @@ sub_08063C44: @ 0x08063C44
push {lr}
movs r0, #7
movs r1, #0x14
bl FindEntityBySubtype
bl DeepFindEntityByID
cmp r0, #0
beq _08063C58
movs r1, #0
@ -277,7 +277,7 @@ sub_08063C5C: @ 0x08063C5C
push {lr}
movs r0, #7
movs r1, #0x14
bl FindEntityBySubtype
bl DeepFindEntityByID
cmp r0, #0
beq _08063C70
movs r1, #9
@ -291,7 +291,7 @@ sub_08063C74: @ 0x08063C74
push {lr}
movs r0, #7
movs r1, #0x14
bl FindEntityBySubtype
bl DeepFindEntityByID
cmp r0, #0
beq _08063C8C
movs r2, #0x18

View File

@ -938,7 +938,7 @@ _0806AAEE:
adds r0, #0xac
ldr r0, [r0]
movs r1, #7
bl FindNextEntityOfSameSubtype
bl FindNextDuplicateID
adds r1, r0, #0
adds r0, r4, #0
adds r0, #0xb0
@ -948,7 +948,7 @@ _0806AB02:
adds r0, #0xb0
ldr r0, [r0]
movs r1, #7
bl FindNextEntityOfSameSubtype
bl FindNextDuplicateID
adds r1, r0, #0
mov r0, r8
adds r0, #0xb4
@ -1041,7 +1041,7 @@ sub_0806AB9C: @ 0x0806AB9C
movs r1, #0x37
movs r2, #7
movs r3, #1
bl FindEntityInListByForm
bl FindEntity
cmp r0, #0
beq _0806ABBC
bl DeleteEntity

View File

@ -378,7 +378,7 @@ sub_08068578: @ 0x08068578
lsls r0, r1, #0x10
asrs r0, r0, #0x10
movs r1, #0x14
bl sub_0806FA04
bl FixedDiv
lsls r0, r0, #0x10
asrs r0, r0, #0x10
mov sl, r0
@ -386,7 +386,7 @@ sub_08068578: @ 0x08068578
lsls r0, r2, #0x10
asrs r0, r0, #0x10
movs r1, #0x14
bl sub_0806FA04
bl FixedDiv
lsls r0, r0, #0x10
asrs r0, r0, #0x10
mov r8, r0

6
include/arm_proxy.h Normal file
View File

@ -0,0 +1,6 @@
#ifndef ARM_PROXY_H
#define ARM_PROXY_H
extern void PrepNextFrame(void);
#endif

View File

@ -4,6 +4,9 @@
#include "global.h"
#include "entity.h"
s16 FixedMul(s16 r0, s16 r1);
s16 FixedDiv(s16 r0, s16 r1);
void CopyPosition(Entity*, Entity*);
void PositionEntityOnTop(Entity*, Entity*);
void PositionRelative(Entity*, Entity*, s32, s32);
@ -12,4 +15,7 @@ void sub_0806FA90(Entity*, Entity*, s32, s32);
void ResolveEntityOnTop(Entity*, Entity*);
void sub_0806FAD8(Entity*, Entity*);
const s16 gSineTable[64];
const s16 gCosineTable[256];
#endif

View File

@ -1,9 +0,0 @@
#ifndef DMA_H
#define DMA_H
void MemFill16(u32 value, void* dest, u32 size);
void MemFill32(u32 value, void* dest, u32 size);
void MemClear(void* dest, u32 size);
void MemCopy(const void* src, void* dest, u32 size);
#endif // DMA_H

View File

@ -175,34 +175,6 @@ extern LinkedList gUnk_03003DA0;
#define COORD_TO_TILE_OFFSET(entity, xOff, yOff) \
TILE((entity)->x.HALF.HI - (xOff), (entity)->y.HALF.HI - (yOff))
Entity* GetEmptyEntity(void);
extern Entity* CreateEnemy(u32 subtype, u32 form);
extern Entity* CreateObject(u32 subtype, u32 form, u32 parameter);
extern Entity* CreateNPC(u32 subtype, u32 form, u32 parameter);
extern Entity* CreateObjectWithParent(Entity* parent, u32 subtype, u32 form, u32 parameter);
extern Entity* CreateFx(Entity* parent, u32 form, u32 parameter);
extern void InitializeAnimation(Entity*, u32);
extern void InitAnimationForceUpdate(Entity*, u32);
extern void UpdateAnimationSingleFrame(Entity*);
extern void UpdateSpriteForCollisionLayer(Entity*);
extern void GetNextFrame(Entity*);
extern u32 LoadExtraSpriteData(Entity*, SpriteLoadData*);
extern void SetExtraSpriteFrame(Entity*, u32, u32);
extern void SetSpriteSubEntryOffsetData1(Entity*, u32, u32);
extern void SetSpriteSubEntryOffsetData2(Entity*, u32, u32);
extern u32 GetFacingDirection(Entity*, Entity*);
void DeleteThisEntity(void);
void DeleteEntity(Entity*);
void AppendEntityToList(Entity* entity, u32 listIndex);
void PrependEntityToList(Entity* entity, int listIndex);
Entity* FindEntityInListBySubtype(u32 type, u32 subtype, u32 listIndex);
Entity* FindEntityInListByForm(u32 type, u32 subtype, u32 listIndex, u32 form, u32 parameter);
enum {
DirectionNorth = 0x00,
DirectionEast = 0x08,
@ -224,4 +196,73 @@ enum {
#define Direction8ToAnimationState(expr) (Direction8RoundUp(expr) >> 2)
#define Direction8FromAnimationState(expr) (((expr) << 2)
Entity* GetEmptyEntity(void);
extern Entity* CreateEnemy(u32 id, u32 type);
extern Entity* CreateNPC(u32 id, u32 type, u32 type2);
extern Entity* CreateObject(u32 id, u32 type, u32 type2);
extern Entity* CreateObjectWithParent(Entity* parent, u32 id, u32 type, u32 type2);
extern Entity* CreateFx(Entity* parent, u32 type, u32 type2);
extern void InitializeAnimation(Entity*, u32);
extern void InitAnimationForceUpdate(Entity*, u32);
extern void UpdateAnimationSingleFrame(Entity*);
extern void UpdateSpriteForCollisionLayer(Entity*);
extern void GetNextFrame(Entity*);
extern u32 LoadExtraSpriteData(Entity*, SpriteLoadData*);
extern void SetExtraSpriteFrame(Entity*, u32, u32);
extern void SetSpriteSubEntryOffsetData1(Entity*, u32, u32);
extern void SetSpriteSubEntryOffsetData2(Entity*, u32, u32);
extern u32 GetFacingDirection(Entity*, Entity*);
/**
* @brief Delete the entity currently in execution.
*/
void DeleteThisEntity(void);
/**
* @brief Delete an entity.
*/
void DeleteEntity(Entity*);
/**
* @brief Append entity to linked list.
*/
void AppendEntityToList(Entity* entity, u32 listIndex);
/**
* @brief Prepend entity to linked list.
*/
void PrependEntityToList(Entity* entity, u32 listIndex);
/**
* @brief Find an entity for a given kind and ID.
* @return Entity* First result or NULL if none found
*/
Entity* FindEntityByID(u32 kind, u32 id, u32 listIndex);
/**
* @brief Search all lists for an entity of same kind and id.
* @return Entity* First result or NULL if none found
*/
Entity* DeepFindEntityByID(u32 kind, u32 id);
/**
* @brief Search all lists for entity of same kind and id.
* @return bool32 Duplicate was entity found
*/
bool32 EntityHasDuplicateID(Entity* ent);
/**
* @brief Find an entity of same kind and id in list.
* @return Entity* First result or NULL if none found
*/
Entity* FindNextDuplicateID(Entity* ent, int listIndex);
/**
* @brief Find Entity with full identifiers.
* @return Entity* First result or NULL if none found
*/
Entity* FindEntity(u32 kind, u32 id, u32 listIndex, u32 type, u32 type2);
#endif

View File

@ -5,7 +5,7 @@
#include "global.h"
#include "entity.h"
#include "manager.h"
#include "position.h"
#include "coord.h"
#include "player.h"
#include "room.h"
#include "structures.h"
@ -13,7 +13,6 @@
// Identified - to be sorted into header files
extern void SoundReq(u32);
extern void ShowNPCDialogue(Entity*, Dialog*);
extern u32 __modsi3(u32, u32);
extern void DoFade(u32, u32);
extern u32 CheckKinstoneFused(u32);
extern void ForceEquipItem(u32, u8);
@ -120,7 +119,7 @@ extern u32 sub_08060354(void);
extern void sub_08057E64(void);
extern void sub_0809F814(u32);
extern void sub_080300E8(void);
extern void sub_0801DA90(u32);
extern void DispReset(u32);
extern void sub_08058D34(void);
extern void sub_0807AABC(Entity*);
extern void sub_08078A90(u32);

View File

@ -24,7 +24,6 @@ extern u32 gUnk_0810C2E4;
extern const s16 GreatFairy_RippleOffsets[10];
extern u32 gUnk_02034350;
extern u8 gUnk_0812079C[8];
extern s16 gSineTable[];
extern s8 gUnk_081207AC[];
#endif

View File

@ -77,18 +77,13 @@ static_assert(sizeof(UI) == 0x3b4);
extern Main gMain;
extern UI gUnk_02032EC0;
void InitScreen();
void InitScreen(u32 screen);
extern void InitSound(void);
extern void sub_080560B8(void);
extern void sub_08056208(void);
extern void sub_0804FFE4(void);
extern void MessageInitialize(void);
extern void sub_080ADD30(void);
extern void InitScreen(u32);
extern void PrepNextFrame(void);
extern void ReadKeyInput(void);
extern void DoSoftReset(void);
extern void sub_08056260(void);
extern void VBlankIntrWait();

View File

@ -1,9 +0,0 @@
typedef struct {
u16 heldKeys;
u16 newKeys;
u16 unk4;
u8 unk6;
u8 unk7;
} Input;
extern Input gInput;

View File

@ -56,9 +56,40 @@ typedef struct {
extern struct_02022780 gUnk_02022780;
static_assert(sizeof(struct_02022780) == 0xa8);
/**
* @brief Initialize the message system.
*/
void MessageInitialize(void);
/**
* @brief Show a message on screen.
*
* @param index u32 Message index
*/
void ShowTextbox(u32 index);
/**
* @brief Show a message at screen posiiton.
*
* @param index u32 Message index
* @param x u32 Screen x
* @param y u32 Screen y
*/
void TextboxAtPosition(u32 index, u32 x, u32 y);
/**
* @brief Show a message that attempts not to obscure the entity.
*
* @param index u32 Message index
* @param ent Entity* Your important entity
*/
void TextboxNoOverlap(u32 index, Entity* ent);
/**
* @brief Show a message that attempts not to obscure the camera target.
*
* @param index u32 Message index
*/
void TextboxNoOverlapFollow(u32 index);
#endif

View File

@ -1,7 +0,0 @@
#ifndef TRIG_H
#define TRIG_H
extern const s16 gSineTable[];
extern const s16 gCosineTable[];
#endif

64
include/utils.h Normal file
View File

@ -0,0 +1,64 @@
typedef struct {
u16 heldKeys;
u16 newKeys;
u16 unk4;
u8 unk6;
u8 unk7;
} Input;
extern Input gInput;
/**
* Fill memory with 16 bit value.
*/
void MemFill16(u32 value, void* dest, u32 size);
/**
* Fill memory with 32 bit value.
*/
void MemFill32(u32 value, void* dest, u32 size);
/**
* Clear memory.
*/
void MemClear(void* dest, u32 size);
/**
* Copy memory.
*/
void MemCopy(const void* src, void* dest, u32 size);
/**
* Refresh gInput from hardware registers.
*/
void ReadKeyInput(void);
void LoadPalettes(const u8*, int, int);
void LoadPaletteGroup(u32 group);
/**
* Allocate memory on heap.
*
* The heap size is 0x1000 bytes and should be used sparingly.
* It is customary for entities store the returned handle in their 'myHeap' field.
*
* @param size u32 Size to be allocated
* @return void* Pointer to allocated memory
*/
void* zMalloc(u32 size);
/**
* Free memory from heap.
*
* The entity system will automatically free the address stored in the 'myHeap' field.
*
* @param ptr void* Handle to be freed
*/
void zFree(void* ptr);
/**
* Reset All display hardware registers.
*
* @param updateHUD bool32 Request refresh of HUD layer (bg 0)
*/
void DispReset(bool32 updateHUD);

View File

@ -327,10 +327,7 @@ SECTIONS {
asm/code_0801C85C.o(.text);
src/ezloNag.o(.text);
asm/code_0801CEC0.o(.text);
src/dma.o(.text);
src/input.o(.text);
src/code_0801D714.o(.text);
src/code_0801D79C.o(.text);
src/utils.o(.text);
asm/code_0801D79C.o(.text);
/* enemies */
src/enemy/octorok.o(.text);
@ -451,13 +448,12 @@ SECTIONS {
src/loadRoomEntityList.o(.text);
asm/loadRoomEntity.o(.text);
asm/code_0804AEB0.o(.text);
src/sub_0804AFF4.o(.text);
src/loadRoom.o(.text);
asm/code_0804B058.o(.text);
src/room.o(.text);
asm/code_0804B9F8.o(.text);
src/sub_08050008.o(.text);
src/sub_08050024.o(.text);
src/fade.o(.text);
asm/code_08050038.o(.text);
src/fileScreen.o(.text);
asm/fileScreen.o(.text);
@ -540,7 +536,7 @@ SECTIONS {
src/code_0805EC04.o(.text);
asm/code_0805EC04.o(.text);
src/code_0805F9A0.o(.text);
src/screenDebug.o(.text);
src/debugScreen.o(.text);
src/item14.o(.text);
/* npcs */
src/npc/gentari.o(.text);
@ -646,9 +642,7 @@ SECTIONS {
asm/code_0806EC20.o(.text);
src/createNPC.o(.text);
asm/code_0806ED78.o(.text);
src/sub_0806F9EC.o(.text);
src/sub_0806FA04.o(.text);
src/position.o(.text);
src/coord.o(.text);
asm/code_0806FA6C.o(.text);
src/player.o(.text);
asm/code_08070698.o(.text);
@ -663,13 +657,9 @@ SECTIONS {
asm/code_08077B98.o(.text);
src/code_08078778.o(.text);
asm/code_08078778.o(.text);
src/sub_0807B7D8.o(.text);
src/sub_0807B820.o(.text);
src/sub_0807B8A8.o(.text);
src/sub_0807B930.o(.text);
asm/code_0807B9B8.o(.text);
src/sub_0807C998.o(.text);
src/sub_0801D754.o(.text); /* ??? */
asm/sub_0807CA18.o(.text);
asm/getInventoryValue.o(.text);
asm/code_0807CAA0.o(.text);
@ -765,7 +755,6 @@ SECTIONS {
asm/pushableFurniture.o(.text);
asm/furniture.o(.text);
src/object/minishSizedEntrance.o(.text);
asm/minishSizedEntrance.o(.text);
src/object/archway.o(.text);
asm/giantRock.o(.text);
asm/object51.o(.text);
@ -915,7 +904,7 @@ SECTIONS {
src/manager.o(.rodata);
src/npc.o(.rodata);
data/data_080B3740.o(.rodata);
src/trig.o(.rodata);
src/coord.o(.rodata);
data/data_080C93E0.o(.rodata);
src/enemy/octorok.o(.rodata);
data/animations/octorok.o(.rodata);

View File

@ -8,7 +8,7 @@
#include "functions.h"
#include "object.h"
#include "manager.h"
#include "dma.h"
#include "utils.h"
#include "npc.h"
extern u8 gUnk_03003DE0;

View File

@ -1,43 +0,0 @@
#include "global.h"
extern void LoadPalettes(const u8*, int, int);
extern u32 gUsedPalettes;
extern u16 gPaletteBuffer[];
typedef struct {
u16 paletteId;
u8 destPaletteNum;
u8 numPalettes;
} PaletteGroup;
extern const PaletteGroup* gPaletteGroups[];
extern const u8 gGlobalGfxAndPalettes[];
void LoadPaletteGroup(u32 group) {
const PaletteGroup* paletteGroup = gPaletteGroups[group];
while (1) {
u32 destPaletteNum = paletteGroup->destPaletteNum;
u32 numPalettes = paletteGroup->numPalettes & 0xF;
if (numPalettes == 0) {
numPalettes = 16;
}
LoadPalettes(&gGlobalGfxAndPalettes[paletteGroup->paletteId * 32], destPaletteNum, numPalettes);
if ((paletteGroup->numPalettes & 0x80) == 0) {
break;
}
paletteGroup++;
}
}
void LoadPalettes(const u8* src, int destPaletteNum, int numPalettes) {
u16* dest;
u32 size = numPalettes * 32;
u32 usedPalettesMask = 1 << destPaletteNum;
while (--numPalettes > 0) {
usedPalettesMask |= (usedPalettesMask << 1);
}
gUsedPalettes |= usedPalettesMask;
dest = &gPaletteBuffer[destPaletteNum * 16];
DmaCopy32(3, src, dest, size);
}

View File

@ -1,96 +0,0 @@
#include "global.h"
#include "screen.h"
#include "structures.h"
extern u16 gPaletteBuffer[];
extern u32 gUsedPalettes;
typedef struct {
union {
int raw;
struct {
u8 filler0[0x3];
u8 unk3;
} bytes;
} unk0;
u32 dest;
u32 unk8;
} GfxItem;
extern const GfxItem* gUnk_08100AA8[];
extern const u8 gGlobalGfxAndPalettes[];
void sub_0801D79C(u32 colorIndex, u32 color) {
gPaletteBuffer[colorIndex] = color;
gUsedPalettes |= 1 << (colorIndex / 16);
}
void sub_0801D7BC(u32 color, u32 arg1) {
if (arg1) {
gScreen.lcd.unk6 = 0xE0FF;
} else {
gScreen.lcd.unk6 = 0xFFFF;
}
sub_0801D79C(0, color);
}
void LoadGfxGroup(u32 group) {
u32 terminator;
u32 dmaCtrl;
int gfxOffset;
const u8* src;
u32 dest;
int size;
const GfxItem* gfxItem = gUnk_08100AA8[group];
while (1) {
u32 loadGfx = FALSE;
u32 ctrl = gfxItem->unk0.bytes.unk3;
ctrl &= 0xF;
switch (ctrl) {
case 0x7:
loadGfx = TRUE;
break;
case 0xD:
return;
case 0xE:
if (((struct_02000000*)0x2000000)->gameLanguage > 1) {
loadGfx = TRUE;
}
break;
case 0xF:
if (((struct_02000000*)0x2000000)->gameLanguage != 0) {
loadGfx = TRUE;
}
break;
default:
if (ctrl == ((struct_02000000*)0x2000000)->gameLanguage) {
loadGfx = TRUE;
}
break;
}
if (loadGfx) {
gfxOffset = gfxItem->unk0.raw & 0xFFFFFF;
src = &gGlobalGfxAndPalettes[gfxOffset];
dest = gfxItem->dest;
size = gfxItem->unk8;
dmaCtrl = 0x80000000;
if (size < 0) {
if (dest >= VRAM) {
LZ77UnCompVram(src, (void*)dest);
} else {
LZ77UnCompWram(src, (void*)dest);
}
} else {
DmaSet(3, src, dest, dmaCtrl | ((u32)size >> 1));
}
}
terminator = gfxItem->unk0.bytes.unk3;
terminator &= 0x80;
gfxItem++;
if (!terminator) {
break;
}
}
}

View File

@ -1,5 +1,5 @@
#include "global.h"
#include "dma.h"
#include "utils.h"
#include "functions.h"
typedef struct {

View File

@ -2,7 +2,7 @@
#include "entity.h"
#include "area.h"
#include "main.h"
#include "dma.h"
#include "utils.h"
#include "functions.h"
#include "screen.h"

View File

@ -1,5 +1,5 @@
#include "global.h"
#include "dma.h"
#include "utils.h"
#include "structures.h"
#include "functions.h"

View File

@ -82,7 +82,7 @@ void* sub_08077C54(UnkItemStruct* unk) {
Entity* sub_08077C94(ItemBehavior* arg0, u32 arg1) {
Entity* iVar1;
iVar1 = FindEntityInListBySubtype(8, gUnk_0811BE48[arg1].unk[3], 2);
iVar1 = FindEntityByID(8, gUnk_0811BE48[arg1].unk[3], 2);
if (iVar1 == NULL) {
return NULL;
}

View File

@ -1,7 +1,7 @@
#include "global.h"
#include "entity.h"
#include "player.h"
#include "dma.h"
#include "utils.h"
#include "functions.h"
typedef struct {

View File

@ -1,7 +1,71 @@
#include "global.h"
#include "entity.h"
#include "coord.h"
extern u8 gUnk_08114F78[];
extern u8 gUnk_08114F80[];
s16 FixedMul(s16 r0, s16 r1) {
s32 temp = r0 * r1;
if (temp < 0)
return (temp + 255) >> 8;
else
return temp >> 8;
}
s16 FixedDiv(s16 r0, s16 r1) {
if (r1 == 0)
return 0;
else
return (r0 * 256) / r1;
}
void CopyPosition(Entity* param_1, Entity* param_2) {
PositionRelative(param_1, param_2, 0, 0);
}
void PositionEntityOnTop(Entity* ent, Entity* ent2) {
PositionRelative(ent, ent2, 0, 0);
ResolveEntityOnTop(ent, ent2);
}
void PositionRelative(Entity* source, Entity* target, s32 offsetX, s32 offsetY) { // r0, r1, r2, r3
s32 x;
s32 y;
x = source->x.WORD;
target->x.WORD = x + offsetX;
y = source->y.WORD;
target->y.WORD = y + offsetY;
target->height = source->height; // ldr
target->collisionLayer = source->collisionLayer;
UpdateSpriteForCollisionLayer(target);
}
void CopyPositionAndSpriteOffset(Entity* param_1, Entity* param_2) {
param_2->spriteOffsetX = param_1->spriteOffsetX;
param_2->spriteOffsetY = param_1->spriteOffsetY;
PositionRelative(param_1, param_2, 0, 0);
}
void sub_0806FA90(Entity* param_1, Entity* param_2, s32 offsetX, s32 offsetY) {
param_2->spriteOffsetX = param_1->spriteOffsetX;
param_2->spriteOffsetY = param_1->spriteOffsetY;
PositionRelative(param_1, param_2, offsetX * 64 * 32 * 32, offsetY * 64 * 32 * 32);
}
void ResolveEntityOnTop(Entity* param_1, Entity* param_2) {
param_2->spritePriority.b0 = gUnk_08114F78[param_1->spritePriority.b0];
}
void sub_0806FAD8(Entity* param_1, Entity* param_2) {
param_2->spritePriority.b0 = gUnk_08114F80[param_1->spritePriority.b0];
}
// Values of sin(x*(π/128)) as Q8.8 fixed-point numbers from x = 0 to x = 319
const s16 gSineTable[] = {
const s16 gSineTable[64] = {
Q_8_8(0), // sin(0*(π/128))
Q_8_8(0.0234375), // sin(1*(π/128))
Q_8_8(0.046875), // sin(2*(π/128))
@ -68,8 +132,7 @@ const s16 gSineTable[] = {
Q_8_8(0.99609375), // sin(63*(π/128))
};
const s16 gCosineTable[] = {
const s16 gCosineTable[256] = {
Q_8_8(1), // sin(64*(π/128))
Q_8_8(0.99609375), // sin(65*(π/128))
Q_8_8(0.99609375), // sin(66*(π/128))

View File

@ -2,8 +2,8 @@
// #include "entityData.h"
// #include "global.h"
// extern Entity * FindEntityBySubtype(u32, u32);
// extern Entity * GetEmptyEntityByType();
// extern Entity * DeepFindEntityByID(u32, u32);
// extern Entity * GetEmptyEntityByKind();
// extern void RegisterRoomEntity(Entity *, EntityData *);
// extern u32 sub_0804AF0C(Entity *, EntityData *);
// extern void sub_08016A30(Entity *);
@ -17,11 +17,11 @@
// type = param_1->entityType & 15;
// if (((param_1->field_0x1 & 240) == 80) &&
// (preexisting = FindEntityBySubtype(type,param_1->entitySubtype), preexisting != NULL)) {
// (preexisting = DeepFindEntityByID(type,param_1->entitySubtype), preexisting != NULL)) {
// entity = NULL;
// }
// else {
// entity = GetEmptyEntityByType(); //Get empty entity
// entity = GetEmptyEntityByKind(); //Get empty entity
// if (entity != NULL) {
// (entity->entityType).type = type;
// (entity->entityType).subtype = param_1->entitySubtype;

View File

@ -1,6 +1,6 @@
#include "global.h"
#include "entity.h"
#include "position.h"
#include "coord.h"
#include "room.h"
#include "createObject.h"

View File

@ -1,5 +1,5 @@
#include "global.h"
#include "dma.h"
#include "utils.h"
#include "functions.h"
#include "main.h"
#include "menu.h"
@ -7,13 +7,6 @@
#include "structures.h"
#include "textbox.h"
typedef struct {
u16 unk0;
u16 unk2;
u16 unk4;
} VStruct;
extern VStruct gInput;
extern u8 gBG3Buffer[];
extern void (*const gUnk_08109A30[])();
@ -23,7 +16,7 @@ void HandleDebugTextScreen() {
}
void sub_0805FA04(void) {
sub_0801DA90(1);
DispReset(1);
MemClear(&gBG0Buffer, sizeof(BGBuffer));
MemClear(&gBG3Buffer, 0x1000);
gScreen.lcd.displayControl = 0x940;
@ -47,7 +40,7 @@ void sub_0805FA04(void) {
void sub_0805FA98(void) {
int iVar1;
switch (gInput.unk2) {
switch (gInput.newKeys) {
case 0x40:
gMenu.focusCoords[1] -= 1;
break;

View File

@ -1,46 +0,0 @@
#include "global.h"
#include "dma.h"
void MemFill16(u32 value, void* dest, u32 size) {
DmaFill16(3, value, dest, size);
}
void MemFill32(u32 value, void* dest, u32 size) {
DmaFill32(3, value, dest, size);
}
void MemClear(void* dest, u32 size) {
u32 zero = 0;
switch (((u32)dest | size) & 3) {
case 0:
MemFill32(0, dest, size);
break;
case 2:
MemFill16(0, dest, size);
break;
default:
do {
*(u8*)dest = zero;
dest++;
size--;
} while (size != 0);
}
}
void MemCopy(const void* src, void* dest, u32 size) {
switch (((u32)src | (u32)dest | size) & 3) {
case 0:
DmaCopy32(3, src, dest, size);
break;
case 2:
DmaCopy16(3, src, dest, size);
break;
default:
do {
*(u8*)dest = *(u8*)src;
src++;
dest++;
} while (--size);
}
}

View File

@ -2,7 +2,7 @@
#include "enemy.h"
#include "player.h"
#include "room.h"
#include "trig.h"
#include "coord.h"
#include "fileScreen.h"
#include "random.h"
#include "functions.h"

View File

@ -2,7 +2,7 @@
#include "entity.h"
#include "enemy.h"
#include "functions.h"
#include "trig.h"
#include "coord.h"
#include "random.h"
#include "player.h"

View File

@ -3,12 +3,12 @@
#include "enemy.h"
#include "random.h"
#include "functions.h"
#include "coord.h"
extern u32 sub_080002D4(s32, s32, u32);
extern u32 sub_080002BC(s32, s32, u32);
extern Entity* gUnk_020000B0;
extern s16 gSineTable[];
bool32 Leever_PlayerInRange(Entity*, s32);
void Leever_Move(Entity*);

View File

@ -6,7 +6,6 @@
void sub_08045374(Entity*);
extern u32 sub_0806FA04(u32, u32);
extern void sub_080452E4();
extern void ReplaceMonitoredEntity(Entity*, Entity*);
@ -70,7 +69,7 @@ void sub_080452FC(Entity* this) {
this->action = 3;
this->actionDelay = 1;
if (0 < this->speed)
this->actionDelay = sub_0806FA04(0x1000, this->speed) >> 0x8;
this->actionDelay = FixedDiv(0x1000, this->speed) >> 0x8;
if (sub_08049FA0(this) == 0 && (Random() & 3)) {
cVar2 = sub_08049EE4(this);

View File

@ -10,7 +10,7 @@ extern void sub_0800449C(Entity*, u32);
extern u32 sub_08049F1C(Entity*, Entity*, u32);
extern u32 PlayerInRange(Entity*, u32, u32);
extern void sub_080AEFB4(Entity*);
extern Entity* FindNextEntityOfSameSubtype(Entity* ent, int listIndex);
extern Entity* FindNextDuplicateID(Entity* ent, int listIndex);
void sub_080249F4(Entity*);
void sub_08024940(Entity*);
@ -666,7 +666,7 @@ bool32 sub_08024B38(Entity* this) {
}
}
ent = FindEntityInListBySubtype(8, 2, 2);
ent = FindEntityByID(8, 2, 2);
if (ent) {
do {
if (ent->action != 2 && ent->height.HALF.HI == 0 && sub_08049F1C(this, ent, 0xa0)) {
@ -676,14 +676,14 @@ bool32 sub_08024B38(Entity* this) {
this->field_0x82.HALF.HI &= ~0x40;
break;
}
} while (ent = FindNextEntityOfSameSubtype(ent, 2), ent != NULL);
} while (ent = FindNextDuplicateID(ent, 2), ent != NULL);
}
if (iVar4 != 0) {
return iVar4;
}
ent = FindEntityInListBySubtype(6, 5, 6);
ent = FindEntityByID(6, 5, 6);
if (ent) {
do {
if (ent->action == 1 && sub_08049F1C(this, ent, 0xa0)) {
@ -693,7 +693,7 @@ bool32 sub_08024B38(Entity* this) {
this->field_0x82.HALF.HI &= ~0x40;
break;
}
} while (ent = FindNextEntityOfSameSubtype(ent, 6), ent != NULL);
} while (ent = FindNextDuplicateID(ent, 6), ent != NULL);
}
if (iVar4 == 0) {

View File

@ -12,7 +12,6 @@ typedef struct {
void sub_08044FF8(Entity*);
void sub_08045178(Entity*, Entity*, int, int);
extern u32 sub_0806FA04(u32, u32);
extern void sub_0804A4E4(Entity*, Entity*);
extern u32 sub_080002CC(Entity*, s32, s32);
@ -68,7 +67,7 @@ void sub_08045018(Entity* this) {
this->action = 3;
this->actionDelay = 1;
if (0 < this->speed) {
this->actionDelay = sub_0806FA04(4096, this->speed) >> 8;
this->actionDelay = FixedDiv(4096, this->speed) >> 8;
}
if (sub_08049FA0(this) == 0 && (Random() & 3)) {
this->direction = (sub_08049EE4(this) + 0xfc + (Random() & 8)) & 24;

View File

@ -1,6 +1,6 @@
#include "global.h"
#include "entity.h"
#include "position.h"
#include "coord.h"
#include "random.h"
#include "functions.h"

View File

@ -1,6 +1,7 @@
#include "global.h"
#include "area.h"
#include "entity.h"
#include "dma.h"
#include "utils.h"
#include "script.h"
typedef struct OtherEntity {
@ -28,9 +29,9 @@ OtherEntity* GetEmptyManager(void);
typedef void* (*Getter)(void);
void* GetEmptyEntityByType(int type) {
void* GetEmptyEntityByKind(u32 kind) {
Getter getter = NULL;
if (type == 9) {
if (kind == MANAGER) {
getter = (Getter)GetEmptyManager;
} else {
getter = (Getter)GetEmptyEntity;
@ -61,7 +62,7 @@ typedef void (*Deleter)(void*);
void DeleteEntityAny(Entity* ent) {
Deleter deleter = NULL;
if (ent->kind == 9) {
if (ent->kind == MANAGER) {
deleter = (Deleter)DeleteManager;
} else {
deleter = (Deleter)DeleteEntity;
@ -78,7 +79,6 @@ extern void sub_0805EC60();
extern void sub_08017744();
extern void sub_0805E92C();
extern void UnloadHitbox();
extern void sub_0801DA0C();
extern void sub_0804AA1C();
void UnlinkEntity();
@ -94,9 +94,9 @@ void DeleteEntity(Entity* ent) {
sub_0805E92C(ent);
UnloadCutsceneData(ent);
UnloadHitbox(ent);
sub_0801DA0C(ent->myHeap);
zFree(ent->myHeap);
ent->myHeap = NULL;
if (ent->kind == 3) {
if (ent->kind == ENEMY) {
sub_0804AA1C(ent);
}
ent->flags = ent->flags & 0x7f;
@ -171,8 +171,6 @@ void DeleteManager(OtherEntity* ent) {
gManagerCount--;
}
#include "area.h"
void sub_0805E92C(u32 param_1) {
if (param_1 == gArea.unk2) {
gArea.unk2 = 0;
@ -209,7 +207,7 @@ void sub_0805E9A8(void) {
list = &gEntityLists[0];
do {
for (i = list->first; (u32)i != (u32)list; i = i->next) {
i->flags &= 0xfd;
i->flags &= ~2;
if ((i->flags & 0x20) == 0) {
i->flags |= 0x10;
}
@ -242,7 +240,7 @@ void AppendEntityToList(Entity* entity, u32 listIndex) {
entity->prev = list->last;
list->last->next = entity;
list->last = entity;
if (entity->kind != 9) {
if (entity->kind != MANAGER) {
entity->spritePriority.b0 = 4;
gEntCount++;
} else {
@ -251,7 +249,7 @@ void AppendEntityToList(Entity* entity, u32 listIndex) {
sub_0805E374(entity);
}
void PrependEntityToList(Entity* entity, int listIndex) {
void PrependEntityToList(Entity* entity, u32 listIndex) {
LinkedList* list;
UnlinkEntity(entity);
@ -270,7 +268,7 @@ void UnlinkEntity(Entity* ent) {
ent->next->prev = ent->prev;
}
bool32 DoesSimilarEntityExist(Entity* ent) {
bool32 EntityHasDuplicateID(Entity* ent) {
Entity* i;
LinkedList* list;
@ -286,31 +284,31 @@ bool32 DoesSimilarEntityExist(Entity* ent) {
return FALSE;
}
Entity* FindEntityInListBySubtype(u32 type, u32 subtype, u32 listIndex) {
Entity* FindEntityByID(u32 kind, u32 id, u32 listIndex) {
Entity* it;
LinkedList* list;
list = &gEntityLists[listIndex];
for (it = list->first; (u32)it != (u32)list; it = it->next) {
if (type == it->kind && subtype == it->id)
if (kind == it->kind && id == it->id)
return it;
}
return NULL;
}
Entity* FindEntityInListByForm(u32 type, u32 subtype, u32 listIndex, u32 form, u32 parameter) {
Entity* FindEntity(u32 kind, u32 id, u32 listIndex, u32 type, u32 type2) {
Entity* i;
LinkedList* list;
list = &gEntityLists[listIndex];
for (i = list->first; (u32)i != (u32)list; i = i->next) {
if (type == i->kind && subtype == i->id && form == i->type && parameter == i->type2)
if (kind == i->kind && id == i->id && type == i->type && type2 == i->type2)
return i;
}
return NULL;
}
Entity* FindNextEntityOfSameSubtype(Entity* ent, int listIndex) {
Entity* FindNextDuplicateID(Entity* ent, int listIndex) {
Entity* i;
LinkedList* list;
@ -322,14 +320,14 @@ Entity* FindNextEntityOfSameSubtype(Entity* ent, int listIndex) {
return NULL;
}
Entity* FindEntityBySubtype(int type, int subtype) {
Entity* DeepFindEntityByID(u32 kind, u32 id) {
Entity* i;
LinkedList* list;
list = &gEntityLists[0];
do {
for (i = (Entity*)list->first; (u32)i != (u32)list; i = i->next) {
if (type == i->kind && (subtype == i->id))
if (kind == i->kind && (id == i->id))
return i;
}
} while (++list < &gEntityLists[9]);
@ -346,7 +344,7 @@ void DeleteAllEnemies(void) {
do {
for (ent = list->first; (u32)ent != (u32)list; ent = next) {
next = ent->next;
if (ent->kind == 3)
if (ent->kind == ENEMY)
DeleteEntity(ent);
}
} while (++list < &gEntityLists[9]);

View File

@ -1,11 +1,11 @@
#include "fileScreen.h"
#include "main.h"
#include "player.h"
#include "readKeyInput.h"
#include "utils.h"
#include "screen.h"
#include "menu.h"
#include "dma.h"
#include "random.h"
#include "textbox.h"
// copy, erase, start
#define NUM_FILE_OPERATIONS 3
@ -189,7 +189,7 @@ void HandleChooseFileScreen(void) {
static void HandleFileScreenEnter(void) {
u32 i;
sub_0801DA90(1);
DispReset(1);
sub_080A3210();
MemClear((void*)VRAM, 0x80); // clear palettes
MessageInitialize();

View File

@ -1,7 +1,6 @@
#include "global.h"
#include "screen.h"
#include "structures.h"
#include "dma.h"
#include "screen.h"
#include "entity.h"
#include "player.h"
@ -9,7 +8,7 @@
#include "main.h"
#include "flags.h"
#include "save.h"
#include "readKeyInput.h"
#include "utils.h"
#include "fileScreen.h"
#include "functions.h"

View File

@ -1,27 +0,0 @@
#include "global.h"
#include "readKeyInput.h"
static void StoreKeyInput(Input*, u32);
void ReadKeyInput(void) {
u32 keyInput = ~REG_KEYINPUT & KEYS_MASK;
StoreKeyInput(&gInput, keyInput);
}
static void StoreKeyInput(Input* input, u32 keyInput) {
u32 heldKeys = input->heldKeys;
u32 difference = keyInput & ~heldKeys;
input->newKeys = difference;
if (keyInput == heldKeys) {
if (--input->unk7 == 0) {
input->unk7 = 4;
input->unk4 = keyInput;
} else {
input->unk4 = 0;
}
} else {
input->unk7 = 0x14;
input->unk4 = difference;
}
input->heldKeys = keyInput;
}

View File

@ -1,11 +1,11 @@
#include "global.h"
#include "main.h"
#include "entity.h"
#include "dma.h"
#include "functions.h"
#include "readKeyInput.h"
#include "utils.h"
#include "screen.h"
#include "structures.h"
#include "textbox.h"
typedef struct {
u8 filler0[0x4];
@ -74,7 +74,7 @@ void HandleIntroScreen(void) {
if (gFadeControl.active) {
return;
}
sub_0801DA90(1);
DispReset(1);
gMain.funcIndex = 1;
break;
}
@ -87,7 +87,7 @@ static void HandleNintendoCapcomLogos(void) {
advance = GetAdvanceState();
if (gIntroState.state == 0) {
sub_0801DA90(1);
DispReset(1);
gIntroState.state = 1;
gIntroState.timer = 120;
LoadGfxGroup(16);

View File

@ -12,6 +12,24 @@ extern void* GetRoomProperty(u32, u32, u32);
extern u32 gUnk_02017654;
extern u32* gAreaEntities;
extern void sub_080186EC();
extern void sub_0804B16C();
void sub_0804AFF4(void) {
void (*func)();
sub_080186EC();
func = (void (*)())GetCurrentRoomProperty(5);
if (func) {
func();
}
func = (void (*)())GetCurrentRoomProperty(7);
if (func) {
func();
}
sub_0804B16C();
}
void LoadRoom(void) {
s32 iVar1;
s32* dat;

View File

@ -1,12 +1,13 @@
#include "global.h"
#include "dma.h"
#include "functions.h"
#include "structures.h"
#include "main.h"
#include "screen.h"
#include "random.h"
#include "readKeyInput.h"
#include "utils.h"
#include "save.h"
#include "textbox.h"
#include "arm_proxy.h"
extern void HandleIntroScreen(void);
extern void HandleChooseFileScreen(void);
@ -21,6 +22,8 @@ static void (*const sScreenHandlers[])(void) = {
[SCREEN_CREDITS] = HandleCreditsScreen, [SCREEN_DEBUG_TEXT] = HandleDebugTextScreen,
};
static void sub_080560B8(void);
void AgbMain(void) {
int var0;
@ -104,7 +107,7 @@ static void sub_08055F70(void) {
MemCopy(gUnk_080B2CD8_3, gUnk_02038560, size);
}
sub_0801DA90(0);
DispReset(0);
sub_08016B34();
}
@ -147,21 +150,21 @@ typedef struct {
u8 name[6];
u8 _e;
u8 _f;
} test;
} Defaults;
const test sDefaultSettings = {
const Defaults sDefaultSettings = {
.signature = SIGNATURE,
.saveFileId = 0,
.messageSpeed = 1,
.brightnessPref = 1,
.gameLanguage = LANGUAGE_EN,
.gameLanguage = GAME_LANGUAGE,
.name = "LINK",
._e = 0,
._f = 0,
};
// single misplaced ldr
NONMATCH("asm/non_matching/sub_080560B8.inc", void sub_080560B8(void)) {
NONMATCH("asm/non_matching/sub_080560B8.inc", static void sub_080560B8(void)) {
u32 temp;
u32 b;
@ -183,9 +186,9 @@ NONMATCH("asm/non_matching/sub_080560B8.inc", void sub_080560B8(void)) {
b = BOOLCAST(temp);
if ((gUnk_02000010.field_0x4 != 0) && (gUnk_02000010.field_0x4 != 0xc1)) {
b = 1;
b = TRUE;
}
if (b != 0) {
if (b) {
MemClear((u8*)&gUnk_02000010.signature, 0x20);
gUnk_02000010.signature = SIGNATURE;
}
@ -251,7 +254,7 @@ void sub_08056260(void) {
temp2->field_0x1 = 0;
}
// Convert in-game AABB to screen coordinates and check if it's within the viewport
// Convert AABB to screen coordinates and check if it's within the viewport
u32 sub_080562CC(u32 x0, u32 y0, u32 x1, u32 y1) {
u32 result;
u32 x = ((gRoomControls.roomScrollX - gRoomControls.roomOriginX) - x0 + DISPLAY_WIDTH);

View File

@ -86,7 +86,7 @@ void sub_0805A370(Manager15* this) {
void sub_0805A394(Manager15* this) {
Entity* ent;
if ((ent = FindEntityInListBySubtype(0x3, 0x13, 0x4))) {
if ((ent = FindEntityByID(0x3, 0x13, 0x4))) {
if (ent->type != 4) {
return;
}

View File

@ -4,7 +4,7 @@
#include "entity.h"
#include "room.h"
#include "screen.h"
#include "dma.h"
#include "utils.h"
#include "functions.h"
typedef struct {

View File

@ -3,7 +3,7 @@
#include "screen.h"
#include "area.h"
#include "textbox.h"
#include "dma.h"
#include "utils.h"
#include "game.h"
#include "functions.h"

View File

@ -4,7 +4,7 @@
#include "entity.h"
#include "room.h"
#include "area.h"
#include "dma.h"
#include "utils.h"
#include "functions.h"
/*

View File

@ -4,7 +4,7 @@
#include "structures.h"
#include "room.h"
#include "screen.h"
#include "trig.h"
#include "coord.h"
#include "functions.h"
#include "save.h"

View File

@ -56,7 +56,7 @@ void sub_0806CF30(Entity* this) {
void sub_0806D00C(Entity* this) {
Entity* pEVar1;
pEVar1 = FindEntityInListByForm(7, 76, 7, 0, 0);
pEVar1 = FindEntity(7, 76, 7, 0, 0);
if (pEVar1 != NULL) {
this->parent = pEVar1;
}

View File

@ -225,7 +225,7 @@ void sub_08060318(void) {
int i;
for (i = 2; i >= 0; i--) {
ent = FindEntityInListBySubtype(8, 2, 2);
ent = FindEntityByID(8, 2, 2);
if (ent != NULL) {
CreateDust(ent);
DeleteEntity(ent);

View File

@ -84,7 +84,7 @@ void sub_08069660(Entity* this) {
void sub_08069684(void) {
Manager* mgr;
if (FindEntityInListBySubtype(9, 0x31, 8) == NULL) {
if (FindEntityByID(9, 0x31, 8) == NULL) {
mgr = GetEmptyManager();
if (mgr != NULL) {
mgr->type = 9;

View File

@ -57,12 +57,12 @@ void sub_08065900(Entity* this) {
void sub_08065914(Entity* this) {
Entity* target;
target = FindEntityInListBySubtype(7, 0x1F, 7);
target = FindEntityByID(7, 0x1F, 7);
if (target != NULL) {
PositionRelative(this, target, 0x180000, -0x10000);
target->parent = this;
}
target = FindEntityInListBySubtype(7, 0x20, 7);
target = FindEntityByID(7, 0x20, 7);
if (target != NULL) {
PositionRelative(this, target, 0x280000, 0);
target->parent = this;

View File

@ -5,7 +5,7 @@
#include "flags.h"
#include "script.h"
extern Entity* FindEntityBySubtype(u32, u32);
extern Entity* DeepFindEntityByID(u32, u32);
void sub_08068680(Entity*, Entity*);
void sub_08068694(Entity*, Entity*);
extern Entity* GetEntityByType(u32, u32);
@ -31,7 +31,7 @@ void sub_08066CF8(Entity* this) {
}
void sub_08066D04(Entity* this) {
this->parent = FindEntityBySubtype(7, 0x2E);
this->parent = DeepFindEntityByID(7, 0x2E);
}
void sub_08066D14(Entity* this, ScriptExecutionContext* context) {
@ -86,7 +86,7 @@ void sub_08066D94(Entity* this) {
void sub_08066DE4(Entity* this) {
Entity* pEVar1;
pEVar1 = FindEntityBySubtype(7, 0x2E);
pEVar1 = DeepFindEntityByID(7, 0x2E);
if (pEVar1 != NULL) {
CopyPosition(this, pEVar1);
sub_080686C4(this, pEVar1);

View File

@ -4,9 +4,9 @@
#include "main.h"
#include "menu.h"
#include "npc.h"
#include "position.h"
#include "coord.h"
#include "fileScreen.h"
#include "readKeyInput.h"
#include "utils.h"
#include "structures.h"
#include "functions.h"

View File

@ -25,11 +25,9 @@ enum {
// Main
void GreatFairy(Entity* this) {
u8 bVar1;
if (this->action == 0) {
bVar1 = __modsi3(this->type, 11);
this->type2 = bVar1;
s32 temp = 11;
this->type2 = this->type % temp;
}
GreatFairy_Main[this->type2](this);
}
@ -68,20 +66,18 @@ void GreatFairy_DormantUpdate(Entity* this) {
--*pFrame;
}
switch (*pFrame) {
case 0x96:
case 0x82:
goto e;
case 0x0:
case 0:
this->action = 2;
break;
e:
case 0xd2:
case 0xaa:
case 0x121:
case 130:
case 150:
case 170:
case 210:
case 289:
ripple = GreatFairy_CreateForm(this, RIPPLE, 0);
if (ripple) {
PositionRelative(this, ripple, (s32)GreatFairy_RippleOffsets[this->actionDelay] << 16,
(s32)GreatFairy_RippleOffsets[this->actionDelay + 1] << 16);
PositionRelative(this, ripple, (s32)GreatFairy_RippleOffsets[this->actionDelay] * 65536,
(s32)GreatFairy_RippleOffsets[this->actionDelay + 1] * 65536);
this->actionDelay += 2;
break;
}
@ -110,9 +106,8 @@ void GreatFairy_SpawningUpdate(Entity* this) {
DoFade(6, 4);
SoundReq(325);
this->action = 4;
this->actionDelay = 0x3c;
var = this->spriteSettings.raw & ~0x3;
this->spriteSettings.raw = (this->spriteSettings.raw & var) | 1;
this->actionDelay = 60;
this->spriteSettings.b.draw = 1;
}
}
}
@ -166,10 +161,8 @@ void GreatFairy_WingsInit(Entity* this) {
}
void GreatFairy_WingsUpdate(Entity* this) {
s32 iVar1;
iVar1 = this->speed -= 32;
if (iVar1 * 65536 >> 16 == 256) {
this->speed -= 32;
if (this->speed == 256) {
this->action = 2;
sub_0805EC60(this);
gRoomVars.greatFairyState |= 32;
@ -237,7 +230,7 @@ void GreatFairy_MiniRisingUpdate(Entity* this) {
void GreatFairy_MiniRemoveMe(Entity* this) {
GetNextFrame(this);
sub_080873D0(this);
if ((gRoomVars.greatFairyState & 1) != 0) {
if (gRoomVars.greatFairyState & 1) {
DeleteEntity(this);
}
}
@ -270,15 +263,13 @@ void GreatFairy_MiniAffineInit2(Entity* this) {
// Mini great fairy stretch
void GreatFairy_MiniAffineUpdate(Entity* this) {
s32 iVar2;
if (--this->actionDelay == 0) {
gRoomVars.greatFairyState |= 1;
this->action = 3;
sub_0805EC60(this);
} else {
iVar2 = this->speed -= 24;
sub_0805EC9C(this, 256, iVar2 * 0x10000 >> 20, 0);
this->speed -= 24;
sub_0805EC9C(this, 256, this->speed >> 4, 0);
}
}
@ -297,7 +288,7 @@ void GreatFairy_DropletInit(Entity* this) {
void GreatFairy_DropletUpdate(Entity* this) {
GetNextFrame(this);
if (this->frames.b.f3) {
if (this->frames.all & 0x80) {
DeleteEntity(this);
}
}
@ -314,7 +305,7 @@ void GreatFairy_RippleInit(Entity* this) {
}
void GreatFairy_RippleUpdate(Entity* this) {
if ((gRoomVars.greatFairyState & 2) != 0) {
if (gRoomVars.greatFairyState & 2) {
DeleteEntity(this);
} else {
GetNextFrame(this);
@ -363,7 +354,7 @@ void GreatFairy_EnergyInit(Entity* this) {
void GreatFairy_EnergyUpdate(Entity* this) {
GetNextFrame(this);
if (this->frames.b.f3) {
if (this->frames.all & 0x80) {
DeleteEntity(this);
}
}
@ -377,35 +368,25 @@ void sub_08087114(Entity* this) {
}
}
#ifdef NON_MATCHING
extern u8 gUnk_0812079C;
void sub_08087150(Entity* this) {
NONMATCH("asm/greatFairy/sub_08087150.inc", void sub_08087150(Entity* this)) {
u32 temp;
GreatFairy_InitializeAnimation();
GreatFairy_InitializeAnimation(this);
this->spriteSettings.b.draw = TRUE;
this->spriteOrientation.flipY = 0;
this->spriteRendering.b0 = 0;
this->spritePriority.b0 = 3;
this->speed = 0x80;
this->speed = 128;
this->direction = 0x10;
temp = gUnk_0812079C;
temp = gUnk_0812079C[0];
this->palette.raw = ((temp & 0xf) << 4) | 0xf;
}
#else
NAKED
void sub_08087150(Entity* this) {
asm(".include \"asm/greatFairy/sub_08087150.inc\"");
}
#endif
END_NONMATCH
void nullsub_516(Entity* this) {
}
void sub_080871A8(Entity* this) {
u32 bVar1;
if (--this->actionDelay == 0) {
this->action = 3;
this->actionDelay = 60;
@ -414,7 +395,6 @@ void sub_080871A8(Entity* this) {
}
void sub_080871D0(Entity* this) {
if (--this->actionDelay == 0) {
gRoomVars.greatFairyState |= 8;
DeleteEntity(this);
@ -424,16 +404,16 @@ void sub_080871D0(Entity* this) {
void sub_080871F8(Entity* this) {
Entity* temp = this->attachedEntity;
if ((temp->x.HALF.HI == this->x.HALF.HI) && (temp->y.HALF.HI - 0x20 == this->y.HALF.HI)) {
if ((temp->x.HALF.HI == this->x.HALF.HI) && (temp->y.HALF.HI - 32 == this->y.HALF.HI)) {
this->action = 2;
} else {
this->direction = sub_080045D4(this->x.HALF.HI, this->y.HALF.HI, temp->x.HALF.HI, temp->y.HALF.HI - 0x20);
this->direction = sub_080045D4(this->x.HALF.HI, this->y.HALF.HI, temp->x.HALF.HI, temp->y.HALF.HI - 32);
sub_0806F69C(this);
}
}
void sub_08087240(Entity* this) {
if ((gRoomVars.greatFairyState & 4) != 0) {
if (gRoomVars.greatFairyState & 4) {
this->action = 3;
this->actionDelay = 20;
this->direction = 16;
@ -448,7 +428,6 @@ void sub_08087264(Entity* this) {
}
void sub_0808727C(Entity* this) {
if (--this->actionDelay == 0) {
DeleteEntity(this);
}
@ -479,17 +458,16 @@ void sub_080872F8(Entity* this) {
sub_080045D4(this->x.HALF.HI, this->y.HALF.HI, (s16)this->field_0x68.HWORD, (s16)this->field_0x6a.HWORD);
this->direction = (this->direction + gUnk_081207AC[Random() & 3]) & 0x1f;
}
temp = gSineTable[this->actionDelay + 0x40];
temp = gSineTable[this->actionDelay + 64];
this->height.HALF.HI = (temp >> 6) - 8;
this->actionDelay++;
}
void GreatFairy_InitializeAnimation(Entity* this) {
s32 temp;
s32 temp = 11;
this->action = 1;
temp = this->type;
this->type2 = temp % 11;
this->type2 = this->type % temp;
this->collisionLayer = 2;
InitializeAnimation(this, this->type2);
sub_0805E3A0(this, 2);
@ -515,7 +493,7 @@ void sub_080873D0(Entity* this) {
ent = GreatFairy_CreateForm(this, 8, 0);
if (ent != NULL) {
CopyPosition(this, ent);
this->actionDelay = 0x30;
this->actionDelay = 48;
}
}
}
@ -526,7 +504,7 @@ void sub_080873FC(void) {
SoundReq(0xf7);
gRoomControls.cameraTarget = NULL;
while (ent = FindEntityInListBySubtype(0x6, 0x1b, 0x6), ent != NULL) {
while (ent = FindEntityByID(0x6, 0x1b, 0x6), ent != NULL) {
DeleteEntity(ent);
}
}
@ -555,101 +533,87 @@ void sub_08087424(Entity* this, ScriptExecutionContext* context) {
void sub_0808747C(Entity* this, ScriptExecutionContext* context) {
u32 iVar1 = 0;
iVar1 = (u32)FindEntityInListByForm(0x6, 0xf, 0x6, 0xb, 0x0);
iVar1 = (u32)FindEntity(0x6, 0xf, 0x6, 0xb, 0x0);
if (iVar1 != 0) {
iVar1 = 1;
}
context->condition = iVar1;
}
// clang-format off
void (*const GreatFairy_Main[])(Entity*) = {
GreatFairy_CallBehavior,
GreatFairy_CallBehavior,
GreatFairy_WingsCallBehavior,
GreatFairy_WakeCallBehavior,
GreatFairy_MiniCallBehavior,
GreatFairy_MiniAffineCallBehavior,
GreatFairy_DropletCallBehavior,
GreatFairy_RippleCallBehavior,
GreatFairy_MiniAffineCallBehavior,
GreatFairy_DropletCallBehavior,
GreatFairy_RippleCallBehavior,
GreatFairy_BigRippleCallBehavior,
GreatFairy_EnergyCallBehavior,
sub_08087114,
sub_08087294
GreatFairy_EnergyCallBehavior,
sub_08087114,
sub_08087294,
};
void (*const GreatFairy_Behaviors[])(Entity*) = {
GreatFairy_Init,
GreatFairy_DormantUpdate,
GreatFairy_CreateBigRipple,
GreatFairy_SpawningUpdate,
GreatFairy_MiniUpdate,
GreatFairy_FinalUpdate
GreatFairy_Init, GreatFairy_DormantUpdate, GreatFairy_CreateBigRipple,
GreatFairy_SpawningUpdate, GreatFairy_MiniUpdate, GreatFairy_FinalUpdate,
};
const s16 GreatFairy_RippleOffsets[10] = {
0, 0,
-32, -8,
16, 20,
24, -12,
-16, 24
0, 0, -32, -8, 16, 20, 24, -12, -16, 24,
};
void (*const GreatFairy_WingsBehaviors[])(Entity*) = {
void (*const GreatFairy_WingsBehaviors[])(Entity*) = {
GreatFairy_WingsInit,
GreatFairy_WingsUpdate,
nullsub_116
nullsub_116,
};
void (*const GreatFairy_WakeBehaviors[])(Entity*) = {
GreatFairy_WakeInit,
GreatFairy_WakeUpdate
GreatFairy_WakeUpdate,
};
void (*const GreatFairy_MiniBehaviors[])(Entity*) = {
GreatFairy_MiniInit,
GreatFairy_MiniRisingUpdate,
GreatFairy_MiniRemoveMe
GreatFairy_MiniRemoveMe,
};
void (*const GreatFairy_MiniAffineBehaviors[])(Entity*) = {
GreatFairy_MiniAffineInit,
GreatFairy_MiniAffineInit2,
GreatFairy_MiniAffineUpdate,
DeleteEntity
DeleteEntity,
};
void (*const GreatFairy_DropletBehaviors[])(Entity*) = {
GreatFairy_DropletInit,
GreatFairy_DropletUpdate
GreatFairy_DropletUpdate,
};
void (*const GreatFairy_RippleBehaviors[])(Entity*) = {
GreatFairy_RippleInit,
GreatFairy_RippleUpdate
GreatFairy_RippleUpdate,
};
void (*const GreatFairy_BigRippleBehaviors[])(Entity*) = {
GreatFairy_BigRippleInit,
GreatFairy_BigRippleUpdate
GreatFairy_BigRippleUpdate,
};
void (*const GreatFairy_EnergyBehaviors[])(Entity*) = {
GreatFairy_EnergyInit,
GreatFairy_EnergyUpdate
GreatFairy_EnergyUpdate,
};
void (*const GreatFairy_Form1Behaviors[])(Entity*) = {
sub_08087150,
nullsub_516,
sub_080871A8,
sub_080871D0
sub_080871D0,
};
void (*const GreatFairy_Form2Behaviors[])(Entity*) = {
sub_08087150,
sub_080871F8,
sub_08087240,
sub_08087264,
sub_0808727C
sub_08087150, sub_080871F8, sub_08087240, sub_08087264, sub_0808727C,
};
// clang-format on

View File

@ -1,9 +1,13 @@
#include "global.h"
#include "entity.h"
#include "game.h"
#include "player.h"
#include "functions.h"
extern void DoExitTransition(void*);
extern void (*const gUnk_08122254[])(Entity*);
extern u16 gUnk_0812225C[];
void MinishSizedEntrance(Entity* this) {
gUnk_08122254[this->action](this);
@ -20,3 +24,17 @@ void sub_08090EC0(Entity* this) {
LoadFixedGFX(this, 0x184);
}
}
void sub_08090F00(Entity* this) {
if (this->type == 1) {
Entity* parent = this->parent;
u32 mask = 1 << this->field_0xf;
if (!(parent->field_0x20 & mask)) {
DeleteThisEntity();
}
}
if ((gPlayerState.flags.all & 0x80) && sub_080041A0(this, &gPlayerEntity, 4, 4) &&
(gPlayerEntity.height.HALF.HI == 0) && (((u16)gPlayerState.field_0x90.HALF.LO) & gUnk_0812225C[this->type2])) {
DoExitTransition((Entity*)GetCurrentRoomProperty(this->actionDelay));
}
}

View File

@ -1,7 +1,7 @@
#include "global.h"
#include "entity.h"
#include "functions.h"
#include "position.h"
#include "coord.h"
#include "random.h"
#include "structures.h"

View File

@ -1,6 +1,6 @@
#include "global.h"
#include "entity.h"
#include "position.h"
#include "coord.h"
void Object7E(Entity* this) {

View File

@ -1,6 +1,6 @@
#include "global.h"
#include "entity.h"
#include "position.h"
#include "coord.h"
#include "player.h"
#include "flags.h"
#include "functions.h"

View File

@ -1,6 +1,6 @@
#include "global.h"
#include "entity.h"
#include "position.h"
#include "coord.h"
#include "room.h"
#include "functions.h"

View File

@ -1,6 +1,6 @@
#include "global.h"
#include "entity.h"
#include "position.h"
#include "coord.h"
extern void sub_080A0640(Entity*);

Some files were not shown because too many files have changed in this diff Show More