Push functions matched on decomp.me by various people

This commit is contained in:
Tal Hayon 2022-07-11 01:33:43 +03:00
parent 021e77b203
commit 3259c71966
17 changed files with 362 additions and 1318 deletions

View File

@ -1,94 +0,0 @@
.syntax unified
push {r4, r5, r6, r7, lr}
adds r4, r0, #0
ldrb r0, [r4]
movs r6, #0xf
ands r6, r0
ldrb r1, [r4, #1]
movs r0, #0xf0
ands r0, r1
cmp r0, #0x50
bne _0804AE1C
ldrb r1, [r4, #2]
adds r0, r6, #0
bl DeepFindEntityByID
cmp r0, #0
beq _0804AE1C
movs r0, #0
b _0804AEAC
_0804AE1C:
adds r0, r6, #0
bl GetEmptyEntityByKind
adds r5, r0, #0
cmp r5, #0
beq _0804AEAA
strb r6, [r5, #8]
ldrb r0, [r4, #2]
strb r0, [r5, #9]
ldrb r0, [r4, #3]
strb r0, [r5, #0xa]
adds r0, r5, #0
adds r1, r4, #0
bl RegisterRoomEntity
ldrb r1, [r4, #1]
movs r7, #0xf0
adds r0, r7, #0
ands r0, r1
cmp r0, #0x10
beq _0804AEAA
ldrb r0, [r4, #4]
strb r0, [r5, #0xb]
ldr r0, [r4, #4]
movs r1, #0xff
lsls r1, r1, #8
ands r0, r1
lsrs r0, r0, #8
strb r0, [r5, #0xe]
cmp r6, #9
beq _0804AEAA
adds r0, r5, #0
adds r1, r4, #0
bl sub_0804AF0C
ldr r0, [r5, #4]
cmp r0, #0
beq _0804AEAA
ldrb r0, [r4]
adds r2, r7, #0
ands r2, r0
movs r0, #0x10
ands r0, r2
cmp r0, #0
bne _0804AE94
movs r0, #0x20
ands r2, r0
cmp r2, #0
beq _0804AE88
adds r1, r5, #0
adds r1, #0x38
movs r0, #2
strb r0, [r1]
b _0804AEAA
_0804AE88:
ldr r0, _0804AEA0 @ =gRoomControls
ldrb r1, [r0, #0xf]
movs r0, #2
ands r0, r1
cmp r0, #0
beq _0804AEA4
_0804AE94:
adds r1, r5, #0
adds r1, #0x38
movs r0, #1
strb r0, [r1]
b _0804AEAA
.align 2, 0
_0804AEA0: .4byte gRoomControls
_0804AEA4:
adds r0, r5, #0
bl ResolveCollisionLayer
_0804AEAA:
adds r0, r5, #0
_0804AEAC:
pop {r4, r5, r6, r7, pc}
.align 2, 0
.syntax divided

View File

@ -1,90 +0,0 @@
.syntax unified
push {r4, lr}
adds r4, r0, #0
adds r0, #0x45
ldrb r1, [r0]
movs r0, #0x7f
ands r0, r1
cmp r0, #0
beq _08017550
ldr r0, _080175D8 @ =gUnk_020342F8
subs r1, #1
bl ReadBit
cmp r0, #0
bne _08017550
bl DeleteThisEntity
_08017550:
ldrb r0, [r4, #0xc]
cmp r0, #0
bne _08017566
ldrb r1, [r4, #0x10]
movs r0, #1
ands r0, r1
cmp r0, #0
bne _08017566
adds r0, r4, #0
bl NPCInit
_08017566:
adds r0, r4, #0
bl EntityIsDeleted
cmp r0, #0
bne _08017584
ldr r2, _080175DC @ =gNPCFunctions
ldrb r1, [r4, #9]
lsls r0, r1, #1
adds r0, r0, r1
lsls r0, r0, #2
adds r0, r0, r2
ldr r1, [r0]
adds r0, r4, #0
bl _call_via_r1
_08017584:
ldr r0, [r4, #4]
cmp r0, #0
beq _080175D2
ldr r2, _080175DC @ =gNPCFunctions
ldrb r1, [r4, #9]
lsls r0, r1, #1
adds r0, r0, r1
lsls r0, r0, #2
adds r2, #4
adds r0, r0, r2
ldr r1, [r0]
cmp r1, #0
beq _080175A4
adds r0, r4, #0
bl _call_via_r1
_080175A4:
adds r0, r4, #0
adds r0, #0x45
ldrb r1, [r0]
movs r0, #0x7f
ands r0, r1
cmp r0, #0
beq _080175CC
ldr r2, _080175E0 @ =gNPCData
lsls r0, r1, #4
subs r0, #0x10
adds r2, r0, r2
ldr r3, _080175E4 @ =gRoomControls
ldrh r0, [r4, #0x2e]
ldrh r1, [r3, #6]
subs r0, r0, r1
strh r0, [r2, #4]
ldrh r0, [r4, #0x32]
ldrh r1, [r3, #8]
subs r0, r0, r1
strh r0, [r2, #6]
_080175CC:
adds r0, r4, #0
bl DrawEntity
_080175D2:
pop {r4}
pop {r0}
bx r0
.align 2, 0
_080175D8: .4byte gUnk_020342F8
_080175DC: .4byte gNPCFunctions
_080175E0: .4byte gNPCData
_080175E4: .4byte gRoomControls
.syntax divided

View File

@ -1,50 +0,0 @@
.syntax unified
push {r4, r5, r6, r7, lr}
adds r4, r0, #0
ldr r2, _08017758 @ =gUnk_03003C70
movs r0, #0x80
lsls r0, r0, #1
adds r7, r2, r0
movs r5, #0x41
rsbs r5, r5, #0
ldr r6, _0801775C @ =gUnk_02018EA0
b _08017766
.align 2, 0
_08017758: .4byte gUnk_03003C70
_0801775C: .4byte gUnk_02018EA0
_08017760:
adds r2, #0x10
cmp r7, r2
bls _0801779A
_08017766:
ldr r0, [r2, #8]
cmp r4, r0
bne _08017760
adds r3, r4, #0
adds r3, #0x29
ldrb r1, [r3]
movs r0, #0x40
ands r0, r1
cmp r0, #0
beq _08017760
adds r0, r5, #0
ands r0, r1
strb r0, [r3]
movs r0, #0
str r0, [r2, #8]
ldr r1, [r2]
ldr r0, [r2, #4]
str r0, [r1, #4]
ldr r1, [r2, #4]
ldr r0, [r2]
str r0, [r1]
ldr r0, [r6]
cmp r2, r0
bne _0801779A
ldr r0, [r2, #4]
str r0, [r6]
_0801779A:
pop {r4, r5, r6, r7}
pop {r0}
bx r0
.syntax divided

View File

@ -1,192 +0,0 @@
.syntax unified
.text
push {r4, r5, r6, r7, lr}
sub sp, #0xb0
adds r5, r1, #0
lsls r0, r0, #0x10
lsrs r1, r0, #0x10
lsls r2, r2, #0x18
lsrs r7, r2, #0x18
ldr r0, _080B16C8 @ =gEEPROMConfig
ldr r0, [r0]
ldrh r0, [r0, #4]
cmp r1, r0
blo _080B16D0
ldr r0, _080B16CC @ =0x000080FF
b _080B1804
.align 2, 0
_080B16C8: .4byte gEEPROMConfig
_080B16CC: .4byte 0x000080FF
_080B16D0:
ldr r0, _080B1710 @ =gEEPROMConfig
ldr r0, [r0]
ldrb r0, [r0, #8]
lsls r0, r0, #1
mov r2, sp
adds r3, r0, r2
adds r3, #0x84
movs r0, #0
strh r0, [r3]
subs r3, #2
movs r4, #0
_080B16E6:
ldrh r2, [r5]
adds r5, #2
movs r0, #0
_080B16EC:
strh r2, [r3]
subs r3, #2
lsrs r2, r2, #1
adds r0, #1
lsls r0, r0, #0x18
lsrs r0, r0, #0x18
cmp r0, #0xf
bls _080B16EC
adds r0, r4, #1
lsls r0, r0, #0x18
lsrs r4, r0, #0x18
cmp r4, #3
bls _080B16E6
movs r4, #0
ldr r0, _080B1710 @ =gEEPROMConfig
adds r2, r0, #0
ldr r0, [r0]
b _080B1722
.align 2, 0
_080B1710: .4byte gEEPROMConfig
_080B1714:
strh r1, [r3]
subs r3, #2
lsrs r1, r1, #1
adds r0, r4, #1
lsls r0, r0, #0x18
lsrs r4, r0, #0x18
ldr r0, [r2]
_080B1722:
ldrb r0, [r0, #8]
cmp r4, r0
blo _080B1714
movs r0, #0
strh r0, [r3]
subs r3, #2
movs r6, #1
strh r6, [r3]
movs r4, #0xd0
lsls r4, r4, #0x14
ldr r0, _080B1794 @ =gEEPROMConfig
ldr r0, [r0]
ldrb r2, [r0, #8]
adds r2, #0x43
mov r0, sp
adds r1, r4, #0
bl DMA3Transfer
movs r5, #0
add r2, sp, #0xa4
strh r5, [r2]
mov r1, sp
adds r1, #0xa6
ldr r0, _080B1798 @ =0x04000006
ldrh r0, [r0]
strh r0, [r1]
add r0, sp, #0xac
str r5, [r0]
ldrh r0, [r2]
cmp r0, #0
bne _080B1768
ldrh r0, [r4]
ands r0, r6
cmp r0, #0
bne _080B17F8
_080B1768:
add r3, sp, #0xa8
ldr r0, _080B1798 @ =0x04000006
ldrh r0, [r0]
strh r0, [r3]
mov r4, sp
adds r4, #0xa6
ldrh r1, [r3]
ldrh r0, [r4]
cmp r1, r0
beq _080B17E2
ldrh r1, [r3]
ldrh r0, [r4]
cmp r1, r0
bls _080B179C
add r2, sp, #0xac
ldrh r1, [r3]
ldrh r0, [r4]
subs r1, r1, r0
ldr r0, [r2]
adds r1, r1, r0
str r1, [r2]
b _080B17B2
.align 2, 0
_080B1794: .4byte gEEPROMConfig
_080B1798: .4byte 0x04000006
_080B179C:
add r2, sp, #0xac
add r0, sp, #0xa8
ldrh r0, [r0]
adds r0, #0xe4
mov r1, sp
adds r1, #0xa6
ldrh r1, [r1]
subs r0, r0, r1
ldr r1, [r2]
adds r0, r0, r1
str r0, [r2]
_080B17B2:
add r0, sp, #0xac
ldr r0, [r0]
cmp r0, #0x88
bls _080B17D8
add r0, sp, #0xa4
ldrh r0, [r0]
cmp r0, #0
bne _080B1802
movs r0, #0xd0
lsls r0, r0, #0x14
ldrh r0, [r0]
movs r1, #1
ands r0, r1
cmp r0, #0
bne _080B1802
ldr r5, _080B17D4 @ =0x0000C001
b _080B1802
.align 2, 0
_080B17D4: .4byte 0x0000C001
_080B17D8:
mov r0, sp
adds r0, #0xa6
add r1, sp, #0xa8
ldrh r1, [r1]
strh r1, [r0]
_080B17E2:
add r2, sp, #0xa4
ldrh r0, [r2]
cmp r0, #0
bne _080B1768
movs r0, #0xd0
lsls r0, r0, #0x14
movs r1, #1
ldrh r0, [r0]
ands r1, r0
cmp r1, #0
beq _080B1768
_080B17F8:
ldrh r0, [r2]
adds r0, #1
strh r0, [r2]
cmp r7, #0
bne _080B1768
_080B1802:
adds r0, r5, #0
_080B1804:
add sp, #0xb0
pop {r4, r5, r6, r7}
pop {r1}
bx r1
.syntax divided

View File

@ -1,138 +0,0 @@
.syntax unified
push {r4, r5, r6, r7, lr}
mov r7, r8
push {r7}
ldr r0, _08050F40 @ =gMapDataBottomSpecial
ldrb r1, [r0]
adds r6, r0, #0
cmp r1, #0
bne _08050FF4
ldrb r1, [r6, #6]
ldr r0, _08050F44 @ =0x000004B4
muls r1, r0, r1
adds r0, r6, #0
adds r0, #0xc
adds r1, r1, r0
ldr r0, _08050F48 @ =gMenu
ldrb r3, [r0, #1]
adds r4, r1, #3
mov ip, r0
cmp r3, #0
bne _08050F1E
adds r4, r1, #2
_08050F1E:
ldrb r2, [r4]
movs r5, #0
ldr r0, _08050F4C @ =gInput
ldrh r0, [r0, #2]
mov r8, r2
cmp r0, #0x10
beq _08050F7A
cmp r0, #0x10
bgt _08050F56
cmp r0, #2
beq _08050F8C
cmp r0, #2
bgt _08050F50
cmp r0, #1
beq _08050F82
b _08050F8E
.align 2, 0
_08050F40: .4byte gMapDataBottomSpecial
_08050F44: .4byte 0x000004B4
_08050F48: .4byte gMenu
_08050F4C: .4byte gInput
_08050F50:
cmp r0, #8
beq _08050F82
b _08050F8E
_08050F56:
cmp r0, #0x40
beq _08050F6A
cmp r0, #0x40
bgt _08050F64
cmp r0, #0x20
beq _08050F72
b _08050F8E
_08050F64:
cmp r0, #0x80
beq _08050F6E
b _08050F8E
_08050F6A:
movs r3, #0
b _08050F8E
_08050F6E:
movs r3, #1
b _08050F8E
_08050F72:
cmp r2, #0
beq _08050F8E
subs r2, #1
b _08050F8E
_08050F7A:
cmp r2, #1
bhi _08050F8E
adds r2, #1
b _08050F8E
_08050F82:
ldrh r0, [r6, #4]
movs r5, #2
ldrh r7, [r1, #2]
cmp r0, r7
bne _08050F8E
_08050F8C:
movs r5, #3
_08050F8E:
cmp r5, #0
beq _08050FD0
cmp r5, #2
beq _08050F9C
cmp r5, #3
beq _08050FAC
b _08050FBA
_08050F9C:
movs r0, #8
movs r1, #0
bl CreateDialogBox
movs r0, #0x6a
bl SoundReq
b _08050FBA
_08050FAC:
ldrb r0, [r6, #4]
strb r0, [r1, #2]
ldrb r0, [r6, #5]
strb r0, [r1, #3]
movs r0, #0x6c
bl SoundReq
_08050FBA:
adds r0, r5, #0
bl SetMenuType
ldr r0, _08050FCC @ =gMapDataBottomSpecial
ldrb r0, [r0, #6]
bl SetActiveSave
b _08050FF4
.align 2, 0
_08050FCC: .4byte gMapDataBottomSpecial
_08050FD0:
mov r1, ip
ldrb r0, [r1, #1]
cmp r0, r3
beq _08050FE2
strb r3, [r1, #1]
movs r0, #0x69
bl SoundReq
b _08050FF4
_08050FE2:
cmp r2, r8
beq _08050FF4
strb r2, [r4]
ldrb r0, [r6, #6]
bl LoadOptionsFromSave
movs r0, #0x69
bl SoundReq
_08050FF4:
pop {r3}
mov r8, r3
pop {r4, r5, r6, r7, pc}
.align 2, 0
.syntax divided

View File

@ -1,90 +0,0 @@
.syntax unified
push {r4, lr}
ldr r0, _08056598 @ =gNewWindow
movs r1, #8
bl MemClear
ldr r0, _0805659C @ =gMessageChoices
movs r1, #0x18
bl MemClear
ldr r4, _080565A0 @ =gTextRender
adds r0, r4, #0
movs r1, #0xa8
bl MemClear
ldr r0, _080565A4 @ =gMessage
adds r1, r4, #0
movs r2, #0x20
bl MemCopy
ldrb r0, [r4, #2]
cmp r0, #0x63
bne _08056520
movs r0, #0x80
lsls r0, r0, #0x12
ldrb r0, [r0, #5]
strb r0, [r4, #2]
_08056520:
adds r1, r4, #0
adds r1, #0x9c
movs r0, #0xff
strb r0, [r1]
adds r0, r4, #0
adds r0, #0x20
ldrh r1, [r4, #8]
bl sub_0805EEB4
adds r3, r4, #0
adds r3, #0x5c
movs r0, #2
strb r0, [r3]
movs r0, #0xe
strb r0, [r3, #1]
adds r3, #2
movs r2, #0
ldr r0, _080565A8 @ =gSave
adds r0, #0x80
ldrb r1, [r0]
cmp r1, #0
beq _08056560
adds r4, r0, #0
_0805654E:
strb r1, [r3]
adds r3, #1
adds r2, #1
cmp r2, #5
bhi _08056560
adds r0, r2, r4
ldrb r1, [r0]
cmp r1, #0
bne _0805654E
_08056560:
movs r0, #2
strb r0, [r3]
movs r0, #0xf
strb r0, [r3, #1]
movs r0, #0
strb r0, [r3, #2]
ldr r4, _080565A0 @ =gTextRender
adds r0, r4, #0
bl sub_08056FBC
ldr r0, _080565AC @ =gUnk_08107BE0
str r0, [r4, #0x2c]
ldr r0, _080565B0 @ =gTextGfxBuffer
str r0, [r4, #0x58]
adds r4, #0x54
movs r0, #0xd0
strh r0, [r4]
movs r0, #2
bl SetDoTextBox
movs r0, #0
bl MsgChangeLine
movs r0, #2
bl StatusUpdate
movs r0, #1
pop {r4, pc}
.align 2, 0
_08056598: .4byte gNewWindow
_0805659C: .4byte gMessageChoices
_080565A0: .4byte gTextRender
_080565A4: .4byte gMessage
_080565A8: .4byte gSave
_080565AC: .4byte gUnk_08107BE0
_080565B0: .4byte gTextGfxBuffer
.syntax divided

View File

@ -1,318 +0,0 @@
.syntax unified
push {r4, r5, r6, r7, lr}
adds r5, r0, #0
ldrh r7, [r5, #0x24]
cmp r7, #0
beq _0805675C
b _0805694C
_0805675C:
adds r4, r5, #0
adds r4, #0x20
adds r0, r4, #0
bl GetCharacter
adds r7, r0, #0
cmp r7, #0xe
bls _0805676E
b _08056942
_0805676E:
lsls r0, r7, #2
ldr r1, _08056778 @ =_0805677C
adds r0, r0, r1
ldr r0, [r0]
mov pc, r0
.align 2, 0
_08056778: .4byte _0805677C
_0805677C: @ jump table
.4byte _080567B8 @ case 0
.4byte _080567DE @ case 1
.4byte _08056802 @ case 2
.4byte _0805680A @ case 3
.4byte _08056812 @ case 4
.4byte _08056838 @ case 5
.4byte _08056844 @ case 6
.4byte _08056858 @ case 7
.4byte _0805688C @ case 8
.4byte _08056894 @ case 9
.4byte _080568AC @ case 10
.4byte _08056942 @ case 11
.4byte _080568B2 @ case 12
.4byte _08056914 @ case 13
.4byte _0805693A @ case 14
_080567B8:
ldr r0, _080567D4 @ =gUnk_02000040
ldrb r0, [r0]
cmp r0, #1
bne _080567D8
adds r1, r5, #0
adds r1, #0x89
movs r0, #5
strb r0, [r1]
.ifndef EU
movs r0, #0
movs r1, #0
bl SwitchChoice
.endif
b _08056942
.align 2, 0
_080567D4: .4byte gUnk_02000040
_080567D8:
adds r1, r5, #0
adds r1, #0x89
b _0805692C
_080567DE:
adds r1, r5, #0
adds r1, #0x8a
movs r0, #2
strb r0, [r1]
adds r0, r5, #0
adds r0, #0x98
ldrb r0, [r0]
cmp r0, #0
bne _080567F8
movs r0, #1
bl MsgChangeLine
b _08056942
_080567F8:
adds r1, r5, #0
adds r1, #0x89
movs r0, #3
strb r0, [r1]
b _08056942
_08056802:
movs r0, #3
bl StatusUpdate
b _08056942
_0805680A:
movs r0, #4
bl StatusUpdate
b _08056942
_08056812:
adds r0, r4, #0
movs r1, #0
bl GetFontStrWith
adds r3, r0, #0
adds r4, r5, #0
adds r4, #0x56
adds r0, r5, #0
adds r0, #0x54
ldrh r0, [r0]
ldrh r2, [r4]
subs r0, r0, r2
subs r0, r0, r3
lsrs r1, r0, #0x1f
adds r0, r0, r1
asrs r0, r0, #1
adds r2, r2, r0
strh r2, [r4]
b _08056942
_08056838:
ldr r1, _08056840 @ =gMessage
ldrh r0, [r5, #0x22]
strb r0, [r1, #1]
b _08056942
.align 2, 0
_08056840: .4byte gMessage
_08056844:
ldr r0, _08056854 @ =gUnk_0200005C
ldrh r1, [r5, #0x22]
movs r2, #0x1f
ands r1, r2
bl WriteBit
b _08056942
.align 2, 0
_08056854: .4byte gMessage+0xc
_08056858:
ldrh r3, [r5, #0x22]
cmp r3, #0xe
beq _08056864
cmp r3, #0xf
beq _08056874
b _0805687A
_08056864:
adds r0, r5, #0
adds r0, #0x8f
ldrb r0, [r0]
adds r1, r5, #0
adds r1, #0x91
strb r0, [r1]
movs r3, #2
b _0805687A
_08056874:
adds r0, r5, #0
adds r0, #0x91
ldrb r3, [r0]
_0805687A:
adds r1, r5, #0
adds r1, #0x90
movs r0, #0
strb r0, [r1]
adds r0, r5, #0
adds r1, r3, #0
bl PaletteChange
b _08056942
_0805688C:
ldrh r0, [r5, #0x22]
bl SoundReq
b _08056942
_08056894:
ldr r1, _080568A8 @ =gTextRender
ldrh r0, [r5, #0x22]
strb r0, [r1, #3]
ldrh r0, [r5, #0x22]
adds r1, r5, #0
adds r1, #0x53
ldrb r1, [r1]
bl sub_08056F88
b _08056942
.align 2, 0
_080568A8: .4byte gTextRender
_080568AC:
ldrh r0, [r5, #0x22]
strb r0, [r5, #7]
b _08056942
_080568B2:
ldr r6, _0805690C @ =gUnk_02000040
ldrb r0, [r6]
cmp r0, #1
beq _080568D2
adds r0, r6, #0
movs r1, #4
bl MemClear
ldr r4, _08056910 @ =gMessageChoices
adds r0, r4, #0
movs r1, #0x18
bl MemClear
movs r0, #1
strb r0, [r4]
strb r0, [r6]
_080568D2:
ldr r2, _08056910 @ =gMessageChoices
movs r0, #2
ldrsb r0, [r2, r0]
cmp r0, #3
bgt _08056942
lsls r0, r0, #1
adds r1, r2, #0
adds r1, #0x10
adds r0, r0, r1
ldrh r1, [r5, #0x26]
strh r1, [r0]
movs r0, #2
ldrsb r0, [r2, r0]
lsls r0, r0, #1
adds r1, r2, #0
adds r1, #8
adds r0, r0, r1
adds r3, r5, #0
adds r3, #0x56
ldrh r1, [r3]
strh r1, [r0]
ldrb r0, [r2, #2]
adds r0, #1
strb r0, [r2, #2]
ldrh r0, [r3]
adds r0, #8
strh r0, [r3]
b _08056942
.align 2, 0
_0805690C: .4byte gUnk_02000040
_08056910: .4byte gMessageChoices
_08056914:
ldrh r3, [r5, #0x22]
cmp r3, #0xfe
beq _08056928
cmp r3, #0xff
bne _08056932
adds r1, r5, #0
adds r1, #0x8e
movs r0, #1
strb r0, [r1]
b _08056942
_08056928:
adds r1, r5, #0
adds r1, #0x8e
_0805692C:
movs r0, #2
strb r0, [r1]
b _08056942
_08056932:
adds r0, r5, #0
adds r0, #0x95
strb r3, [r0]
b _08056942
_0805693A:
ldrh r1, [r5, #0x22]
adds r0, r5, #0
adds r0, #0x94
strb r1, [r0]
_08056942:
lsrs r0, r7, #8
cmp r0, #0
bne _0805694C
movs r0, #0
b _080569C2
_0805694C:
ldr r0, _08056960 @ =gTextRender
adds r0, #0x99
ldrb r0, [r0]
cmp r0, #2
beq _08056964
movs r0, #3
bl StatusUpdate
movs r0, #0
b _080569C2
.align 2, 0
_08056960: .4byte gTextRender
_08056964:
ldr r1, _08056994 @ =gMessage
ldrb r0, [r1, #1]
cmp r0, #0
bne _08056970
movs r0, #0x80
strb r0, [r1, #1]
_08056970:
movs r0, #0
strh r0, [r5, #0x24]
lsrs r0, r7, #8
cmp r0, #7
bne _08056998
adds r0, r5, #0
adds r0, #0x8f
ldrb r0, [r0]
movs r1, #0x80
adds r2, r5, #0
adds r2, #0x90
orrs r1, r0
strb r1, [r2]
adds r0, r5, #0
movs r1, #0
bl PaletteChange
b _080569B4
.align 2, 0
_08056994: .4byte gMessage
_08056998:
adds r2, r5, #0
adds r2, #0x90
ldrb r1, [r2]
movs r0, #0x80
ands r0, r1
cmp r0, #0
beq _080569B4
ldrb r3, [r2]
movs r0, #0
strb r0, [r2]
adds r0, r5, #0
adds r1, r3, #0
bl PaletteChange
_080569B4:
adds r1, r5, #0
adds r1, #0x50
adds r0, r7, #0
bl sub_0805F7DC
lsls r0, r0, #0x10
lsrs r0, r0, #0x10
_080569C2:
pop {r4, r5, r6, r7, pc}
.syntax divided

View File

@ -1,15 +0,0 @@
.syntax unified
ldr r2, _080AD908 @ =gFrameObjLists
lsls r0, r0, #2
adds r0, r0, r2
ldr r0, [r0]
lsls r1, r1, #2
adds r0, r0, r2
adds r1, r1, r0
ldr r0, [r1]
adds r2, r0, r2
adds r0, r2, #0
bx lr
.align 2, 0
_080AD908: .4byte gFrameObjLists
.syntax divided

View File

@ -279,6 +279,7 @@ SECTIONS {
src/playerItem.o(.text);
src/object.o(.text);
src/manager.o(.text);
src/npcFunctions.o(.text);
src/npc.o(.text);
src/collision.o(.text);
/* C source compiled without interworking */
@ -863,6 +864,7 @@ SECTIONS {
src/playerItem.o(.rodata);
src/object.o(.rodata);
src/manager.o(.rodata);
src/npcFunctions.o(.rodata);
src/npc.o(.rodata);
src/collision.o(.rodata);
data/data_080B3740.o(.rodata);

View File

@ -10,15 +10,13 @@ extern void ram_DrawEntities(void);
extern void ram_sub_080ADA04(OAMCommand*, void*);
extern void ram_DrawDirect(OAMCommand*, u32, u32);
// regalloc
NONMATCH("asm/non_matching/vram/sub_080AD8F0.inc", void* sub_080AD8F0(u32 sprite, u32 frame)) {
void* sub_080AD8F0(u32 sprite, u32 frame) {
u32* temp = &gFrameObjLists[0];
u32 x = gFrameObjLists[sprite];
u8* y = (u8*)&gFrameObjLists[frame];
u32 tmp = *(u32*)&y[x];
temp = (u32*)((uintptr_t)(((u32*)((uintptr_t)temp + x))[frame]) + (uintptr_t)temp);
return (u8*)gFrameObjLists + tmp;
return temp;
}
END_NONMATCH
void FlushSprites(void) {
gOAMControls.updated = 0;

View File

@ -154,28 +154,24 @@ u32 sub_080176E4(Entity* this) {
}
}
// Several issues:
// 1. b2 mask value is set before the loop even begins
// 2. data is allocated mid function
// 3. regalloc
NONMATCH("asm/non_matching/arm_proxy/sub_08017744.inc", void sub_08017744(Entity* this)) {
LinkedList2* i;
LinkedList2* end;
for (i = gUnk_03003C70, end = gUnk_03003C70 + 16; end > i; ++i) {
if (i->node == this) {
void sub_08017744(Entity* this) {
LinkedList2* ll = gUnk_03003C70;
LinkedList2* end = &gUnk_03003C70[16];
do {
if (this == ll->node) {
if (this->spritePriority.b2 != 0) {
this->spritePriority.b2 = 0;
i->node = NULL;
((LinkedList2*)i->last)->first = i->first;
((LinkedList2*)i->first)->last = i->last;
if (i != gUnk_02018EA0)
return;
gUnk_02018EA0 = i->first;
ll->node = NULL;
((LinkedList2*)ll->last)->first = ll->first;
((LinkedList2*)ll->first)->last = ll->last;
if (ll == gUnk_02018EA0)
gUnk_02018EA0 = ll->first;
break;
}
}
}
} while (end > ++ll);
}
END_NONMATCH
bool32 IsColliding(Entity* this, Entity* that) {
u32 this_d;

View File

@ -107,15 +107,16 @@ u16 EEPROMWrite1(u16 address, const u16* data) {
}
// reading from EEPROM like a status register
#define REG_EEPROM (*(u16*)0xd000000)
// this is the furthest I could get
// 0x080B16AC
NONMATCH("asm/non_matching/code_080B1520/EEPROMWrite.inc", u16 EEPROMWrite(u16 address, const u16* data, u8 unk_3)) {
#define REG_EEPROM (*(vu16*)0xd000000)
u16 EEPROMWrite(u16 address, const u16* data, u8 unk_3) {
u16 buffer[0x52]; // this is one too large?
vu16 stack_a4;
vu16 timeout_flag;
vu16 prev_vcount; // stack + a6
vu16 current_vcount; // stack + a6
vu16 current_vcount; // stack + a8
vu32 passed_scanlines; // stack + ac
u16 ret;
vu16* temp2;
u32 r2;
@ -125,64 +126,65 @@ NONMATCH("asm/non_matching/code_080B1520/EEPROMWrite.inc", u16 EEPROMWrite(u16 a
if (address >= gEEPROMConfig->size)
return EEPROM_OUT_OF_RANGE;
ptr = buffer + gEEPROMConfig->address_width + 0x42;
*ptr = 0;
ptr--;
ptr = (u16*)(0x42 + (uintptr_t)&buffer + (uintptr_t)(gEEPROMConfig->address_width * 2) + 0x42);
*ptr-- = 0;
// copy data into buffer
for (i = 0; i <= 3; i++) {
r2 = *data;
data++;
for (j = 0; j <= 0xf; j++) {
for (i = 0; i < 4; i++) {
r2 = *data++;
for (j = 0; j < 16; j++) {
*ptr = r2;
ptr--;
r2 = r2 >> 1;
}
}
// copy address to buffer
for (i = 0; i < gEEPROMConfig->address_width; i++) {
*ptr = address;
ptr--;
address = address >> 1;
}
*ptr = 0;
ptr--;
*ptr = 1;
*ptr-- = 0;
*ptr-- = 1;
DMA3Transfer(buffer, (u16*)0xd000000, gEEPROMConfig->address_width + 0x43);
stack_a4 = 0;
ret = 0;
timeout_flag = 0;
prev_vcount = REG_VCOUNT;
passed_scanlines = 0;
if (stack_a4 == 0) {
if ((REG_EEPROM & 1) != 0)
goto bad;
}
// before here its only regalloc, but after I cant get it to work
do {
do {
do {
current_vcount = REG_VCOUNT;
if (current_vcount != prev_vcount) {
if (current_vcount >= prev_vcount) {
passed_scanlines += current_vcount - prev_vcount;
} else {
passed_scanlines += (current_vcount + 0xe4) - prev_vcount;
}
if (passed_scanlines > 0x88) {
if (stack_a4 != 0)
return 0;
if ((REG_EEPROM & 1) != 0)
return 0;
return 0xc001;
}
prev_vcount = current_vcount;
while (1) {
if (!timeout_flag) {
if (REG_EEPROM & 1) {
timeout_flag++;
if (!unk_3)
break;
}
}
current_vcount = REG_VCOUNT;
if (current_vcount != prev_vcount) {
if (current_vcount > prev_vcount) {
passed_scanlines += (current_vcount - prev_vcount);
} else {
passed_scanlines += (current_vcount - (prev_vcount - 0xE4));
}
if (passed_scanlines > 0x88) {
if (timeout_flag)
break;
if ((REG_EEPROM & 1)) {
break;
}
} while (stack_a4 != 0);
} while ((REG_EEPROM & 1) != 0);
bad:
stack_a4++;
} while (unk_3 != 0);
return 0;
ret = 0xc001;
break;
}
prev_vcount = current_vcount;
}
}
return ret;
}
END_NONMATCH
u16 EEPROMCompare(u16 address, const u16* data) {
u16 ret;

View File

@ -757,81 +757,78 @@ void sub_08050EB8(void) {
SetMenuType(1);
}
NONMATCH("asm/non_matching/fileScreen/sub_08050EF4.inc", void sub_08050EF4(void)) {
void sub_08050EF4(void) {
u8* p_option;
u32 option;
char column_idx;
int mode;
u8 mode;
if (gMapDataBottomSpecial.isTransitioning)
return;
if (gMapDataBottomSpecial.isTransitioning == 0) {
SaveFile* currentFile = &gMapDataBottomSpecial.saves[gMapDataBottomSpecial.unk6];
column_idx = gMenu.column_idx;
p_option = &gMapDataBottomSpecial.saves[gMapDataBottomSpecial.unk6].brightness;
if (gMenu.column_idx == 0) {
p_option = &gMapDataBottomSpecial.saves[gMapDataBottomSpecial.unk6].msg_speed;
}
if (column_idx == 0) {
p_option = &currentFile->msg_speed;
} else {
p_option = &currentFile->brightness;
}
mode = 0;
option = *p_option;
column_idx = gMenu.column_idx;
switch (gInput.newKeys) {
case DPAD_RIGHT:
if (*p_option < 2) {
option = *p_option + 1;
}
break;
case DPAD_LEFT:
if (*p_option != 0) {
option = *p_option - 1;
}
break;
case DPAD_UP:
column_idx = 0;
break;
case DPAD_DOWN:
column_idx = 1;
break;
case A_BUTTON:
case START_BUTTON:
mode = 2;
if (*(u16*)&gMapDataBottomSpecial.unk4 !=
*(u16*)&gMapDataBottomSpecial.saves[gMapDataBottomSpecial.unk6].msg_speed)
option = *p_option;
mode = 0;
switch (gInput.newKeys) {
case DPAD_UP:
column_idx = 0;
break;
case DPAD_DOWN:
column_idx = 1;
break;
case DPAD_LEFT:
if (option != 0) {
option--;
}
break;
case DPAD_RIGHT:
if (option < 2) {
option++;
}
break;
case A_BUTTON:
case START_BUTTON:
if (gMapDataBottomSpecial.unk4 != currentFile->msg_speed ||
gMapDataBottomSpecial.unk5 != currentFile->brightness) {
mode = 2;
break;
}
case B_BUTTON:
mode = 3;
break;
case B_BUTTON:
mode = 2;
break;
}
break;
}
switch (mode) {
case 3:
gMapDataBottomSpecial.saves[gMapDataBottomSpecial.unk6].msg_speed = gMapDataBottomSpecial.unk4;
gMapDataBottomSpecial.saves[gMapDataBottomSpecial.unk6].brightness = gMapDataBottomSpecial.unk5;
SoundReq(SFX_MENU_CANCEL);
SetMenuType(mode);
SetActiveSave(gMapDataBottomSpecial.unk6);
break;
case 2:
CreateDialogBox(8, 0);
SoundReq(SFX_TEXTBOX_SELECT);
default:
case 1:
SetMenuType(mode);
SetActiveSave(gMapDataBottomSpecial.unk6);
break;
case 0:
if (gMenu.column_idx != column_idx) {
gMenu.column_idx = column_idx;
SoundReq(SFX_TEXTBOX_CHOICE);
} else if (option != *p_option) {
*p_option = option;
LoadOptionsFromSave(gMapDataBottomSpecial.unk6);
SoundReq(SFX_TEXTBOX_CHOICE);
if (mode != 0) {
switch (mode) {
case 2:
CreateDialogBox(8, 0);
SoundReq(SFX_TEXTBOX_SELECT);
break;
case 3:
currentFile->msg_speed = gMapDataBottomSpecial.unk4;
currentFile->brightness = gMapDataBottomSpecial.unk5;
SoundReq(SFX_MENU_CANCEL);
break;
}
break;
SetMenuType(mode);
SetActiveSave(gMapDataBottomSpecial.unk6);
} else if (gMenu.column_idx != column_idx) {
gMenu.column_idx = column_idx;
SoundReq(SFX_TEXTBOX_CHOICE);
} else if (option != *p_option) {
*p_option = option;
LoadOptionsFromSave(gMapDataBottomSpecial.unk6);
SoundReq(SFX_TEXTBOX_CHOICE);
}
}
}
END_NONMATCH
void sub_08050FFC(void) {
switch (HandleSave(0)) {

View File

@ -226,8 +226,7 @@ u8* const gUnk_08107BE0[] = {
&gUnk_020227DC, &gUnk_020227E8, &gUnk_020227F0, &gUnk_020227F8, &gUnk_02022800,
};
// regalloc in loop
NONMATCH("asm/non_matching/textbox/MsgInit.inc", /*static*/ u32 MsgInit(void)) {
u32 MsgInit(void) {
char* dest;
u32 i;
@ -240,20 +239,21 @@ NONMATCH("asm/non_matching/textbox/MsgInit.inc", /*static*/ u32 MsgInit(void)) {
}
gTextRender._9c = 0xff;
sub_0805EEB4(&gTextRender.curToken, gTextRender.message.textIndex);
gTextRender.player_name[0] = 2;
gTextRender.player_name[1] = 0xe; // Green text color
dest = &gTextRender.player_name[2];
dest = &gTextRender.player_name[0];
dest[0] = 2;
dest[1] = 0xe; // Green text color
dest += 2;
for (i = 0; i < FILENAME_LENGTH; ++i) {
char c = gSave.name[i];
if (c == 0)
if (c == '\0')
break;
*dest++ = c;
}
dest[0] = 2;
dest[1] = 0xf; // White text color
dest[2] = 0;
dest[2] = '\0';
sub_08056FBC(&gTextRender);
gTextRender.curToken._c = &gUnk_08107BE0;
gTextRender._50.unk8 = gTextGfxBuffer;
@ -263,7 +263,6 @@ NONMATCH("asm/non_matching/textbox/MsgInit.inc", /*static*/ u32 MsgInit(void)) {
StatusUpdate(MSG_UPDATE);
return 1;
}
END_NONMATCH
/*static*/ u32 MsgOpen(void) {
if (gTextRender.renderStatus == RENDER_INIT) {
@ -366,9 +365,12 @@ static void TextDispUpdate(TextRender* this) {
}
}
NONMATCH("asm/non_matching/textbox/RunTextCommand.inc", /*static*/ u16 RunTextCommand(TextRender* this)) {
s32 palette;
u16 RunTextCommand(TextRender* this) {
u32 chr = this->curToken.extended;
s32 temp;
u32 tmp2;
u32 tmp3;
u32* ptr;
if (chr == 0) {
s32 r1;
@ -377,7 +379,9 @@ NONMATCH("asm/non_matching/textbox/RunTextCommand.inc", /*static*/ u16 RunTextCo
case 0:
if (gUnk_02000040.unk_00 == 1) {
this->renderStatus = RENDER_ENQUIRY;
#ifndef EU
SwitchChoice(0, 0);
#endif
} else {
this->renderStatus = RENDER_DIE;
}
@ -397,29 +401,31 @@ NONMATCH("asm/non_matching/textbox/RunTextCommand.inc", /*static*/ u16 RunTextCo
StatusUpdate(MSG_CLOSE);
break;
case 4:
this->_50.unk6 += (this->_50.unk4 - this->_50.unk6 - GetFontStrWith(&this->curToken, 0)) / 2;
temp = GetFontStrWith(&this->curToken, 0);
this->_50.unk6 = this->_50.unk6 + (this->_50.unk4 - this->_50.unk6 - temp) / 2;
break;
case 5:
gMessage.unk = this->curToken.param;
break;
case 6:
WriteBit(&gMessage.field_0xc, this->curToken.param & 0x1f);
ptr = &gMessage.field_0xc;
tmp3 = this->curToken.param;
tmp3 &= 0x1f;
WriteBit(ptr, tmp3);
break;
case 7:
switch (this->curToken.param) {
temp = this->curToken.param;
switch (temp) {
case 0xe:
this->_91 = this->_8f;
palette = 2;
temp = 2;
break;
case 0xf:
palette = this->_91;
break;
default:
palette = this->curToken.param;
temp = this->_91;
break;
}
this->_90 = 0;
PaletteChange(this, palette);
PaletteChange(this, temp);
break;
case 8:
SoundReq(this->curToken.param);
@ -447,7 +453,8 @@ NONMATCH("asm/non_matching/textbox/RunTextCommand.inc", /*static*/ u16 RunTextCo
this->_50.unk6 += 8;
break;
case 13:
switch (this->curToken.param) {
temp = this->curToken.param;
switch (temp) {
case 0xff:
this->_8e = 1;
break;
@ -455,13 +462,12 @@ NONMATCH("asm/non_matching/textbox/RunTextCommand.inc", /*static*/ u16 RunTextCo
this->_8e = 2;
break;
default:
this->delay = this->curToken.param;
this->delay = temp;
break;
}
break;
case 14:
r1 = this->curToken.param;
this->_94 = r1;
this->_94 = this->curToken.param;
break;
default:
break;
@ -482,14 +488,13 @@ NONMATCH("asm/non_matching/textbox/RunTextCommand.inc", /*static*/ u16 RunTextCo
PaletteChange(this, 0);
} else {
if ((this->_90 & 0x80) != 0) {
palette = this->_90;
temp = this->_90;
this->_90 = 0;
PaletteChange(this, palette);
PaletteChange(this, temp);
}
}
return sub_0805F7DC(chr, &this->_50);
}
END_NONMATCH
/*static*/ void PaletteChange(TextRender* this, u32 id) {
u32 temp = id % 8;

176
src/npc.c
View File

@ -3,140 +3,6 @@
#include "room.h"
#include "npc.h"
//clang-format off
void (*const gNPCFunctions[][3])(Entity* ent) = {
[NPC_NONE_0] = { DeleteEntity, NULL, NULL },
[GENTARI] = { Gentari, NULL, Gentari_Fusion },
[FESTARI] = { Festari, NULL, Festari_Fusion },
[FOREST_MINISH] = { ForestMinish, ForestMinish_Head, ForestMinish_Fusion },
[POSTMAN] = { Postman, NULL, Postman_Fusion },
[NPC_UNK_5] = { NPC5, NULL, NULL },
[TPWNSPERSON] = { Townsperson, Townsperson_Head, Townsperson_Fusion },
[KID] = { Kid, Kid_Head, Kid_Fusion },
[GUARD] = { Guard, Guard_Head, NULL },
[NPC_UNK_9] = { NPC9, NULL, NULL },
[STAMP] = { Stamp, NULL, NULL },
[MAID] = { Maid, Maid_Head, NULL },
[MARCY] = { Marcy, NULL, NULL },
[WHEATON] = { Wheaton, NULL, NULL },
[PITA] = { Pita, NULL, NULL },
[MINISH_EZLO] = { MinishEzlo, MinishEzlo_Head, NULL },
[MAILBOX] = { Mailbox, NULL, NULL },
[BEEDLE] = { Beedle, Beedle_Head, NULL },
[BROCCO] = { Brocco, NULL, Brocco_Fusion },
[SITTING_PERSON] = { SittingPerson, SittingPerson_Head, SittingPerson_Fusion },
[PINA] = { Pina, NULL, Pina_Fusion },
[GUARD_1] = { Guard, Guard_Head, NULL },
[MAID_1] = { Maid, Maid_Head, NULL },
[DIN] = { Din, NULL, Din_Fusion },
[NAYRU] = { Nayru, NULL, Nayru_Fusion },
[FARORE] = { Farore, NULL, Farore_Fusion },
[STURGEON] = { Sturgeon, Sturgeon_Head, Sturgeon_Fusion },
[TINGLE_SIBLINGS] = { TingleSiblings, NULL, TingleSiblings_Fusion },
[STOCKWELL] = { Stockwell, NULL, NULL },
[TALON] = { Talon, Talon_Head, Talon_Fusion },
[MALON] = { Malon, NULL, Malon_Fusion },
[EPONA] = { Epona, NULL, Epona_Fusion },
[MILK_CART] = { MilkCart, NULL, NULL },
[GHOST_BROTHERS] = { GhostBrothers, NULL, GhostBrothers_Fusion },
[SMITH] = { Smith, Smith_Head, Smith_Fusion },
[NPC_UNK_23] = { NPC23, NULL, NULL },
[KING_DALTUS] = { KingDaltus, NULL, KingDaltus_Fusion },
[MINISTER_POTHO] = { MinisterPotho, NULL, MinisterPotho_Fusion },
[NPC_UNK_26] = { NPC26, NULL, NULL },
[VAATI] = { Vaati, NULL, NULL },
[ZELDA] = { Zelda, NULL, NULL },
[MUTOH] = { Mutoh, Mutoh_Head, Mutoh_Fusion },
[CARPENTER] = { Carpenter, Carpenter_Head, Carpenter_Fusion },
[CASTOR_WILDS_STATUE] = { CastorWildsStatue, NULL, CastorWildsStatue_Fusion },
[CAT] = { Cat, NULL, Cat_Fusion },
[MOUNTAIN_MINISH] = { MountainMinish, MountainMinish_Head, MountainMinish_Fusion },
[ZELDA_FOLLOWER] = { ZeldaFollower, NULL, NULL },
[MELARI] = { Melari, Melari_Head, Melari_Fusion },
[BLADE_BROTHERS] = { BladeBrothers, NULL, BladeBrothers_Fusion },
[COW] = { Cow, NULL, Cow_Fusion },
[GORON] = { Goron, NULL, Goron_Fusion },
[GORON_MERCHANT] = { GoronMerchant, NULL, NULL },
[GORMAN] = { Gorman, Gorman_Head, NULL },
[DOG] = { Dog, Dog_Head, Dog_Fusion },
[SYRUP] = { Syrup, Syrup_Head, NULL },
[REM] = { Rem, NULL, NULL },
[TOWN_MINISH] = { TownMinish, TownMinish_Head, TownMinish_Fusion },
[LIBRARI] = { Librari, NULL, Librari_Fusion },
[PERCY] = { Percy, Percy_Head, Percy_Fusion },
[VAATI_REBORN] = { VaatiReborn, NULL, NULL },
[MOBLIN_LADY] = { MoblinLady, NULL, NULL },
[LIBRARIANS] = { Librarians, NULL, NULL },
[FARMERS] = { Farmers, Farmers_Head, Farmers_Fusion },
[CARLOV] = { Carlov, NULL, NULL },
[DAMPE] = { Dampe, NULL, Dampe_Fusion },
[DR_LEFT] = { DrLeft, NULL, NULL },
[KING_GUSTAF] = { KingGustaf, NULL, NULL },
[GINA] = { Gina, NULL, Gina_Fusion },
[SIMON] = { Simon, NULL, NULL },
[ANJU] = { Anju, NULL, Anju_Fusion },
[MAMA] = { Mama, Mama_Head, Mama_Fusion },
[EMMA] = { Emma, NULL, NULL },
[TEACHERS] = { Teachers, Teachers_Head, Teachers_Fusion },
[WIND_TRIBESPEOPLE] = { WindTribespeople, WindTribespeople_Head, WindTribespeople_Fusion },
[GREGAL] = { Gregal, NULL, Gregal_Fusion },
[MAYOR_HAGEN] = { MayorHagen, NULL, MayorHagen_Fusion },
[BIG_GORON] = { BigGoron, NULL, NULL },
[EZLO] = { Ezlo, NULL, NULL },
[NPC_UNK_4E] = { NPC4E, NULL, NPC4E_Fusion },
[NPC_UNK_4F] = { NPC4F, NULL, NULL },
[CLOTHES_RACK] = { ClothesRack, NULL, NULL },
[PICOLYTE_BOTTLE] = { PicolyteBottle, NULL, NULL },
[SMALL_TOWN_MINISH] = { SmallTownMinish, NULL, NULL },
[HURDY_GURDY_MAN] = { HurdyGurdyMan, HurdyGurdyMan_Head, HurdyGurdyMan_Fusion },
[CUCCO] = { Cucco, NULL, Cucco_Fusion },
[CUCCO_CHICK] = { CuccoChick, NULL, CuccoChick_Fusion },
[FUSION_MENU_NPC] = { FusionMenuNPC, FusionMenuNPC_Head, NULL },
[PHONOGRAPH] = { Phonograph, NULL, NULL },
[NPC_UNK_58] = { NPC58, NPC58_Head, NULL },
[NPC_NONE_1] = { DeleteEntity, NULL, NULL },
[NPC_NONE_2] = { DeleteEntity, NULL, NULL },
[NPC_NONE_3] = { DeleteEntity, NULL, NULL },
[NPC_NONE_4] = { DeleteEntity, NULL, NULL },
[NPC_NONE_5] = { DeleteEntity, NULL, NULL },
[NPC_NONE_6] = { DeleteEntity, NULL, NULL },
[NPC_NONE_7] = { DeleteEntity, NULL, NULL },
[NPC_NONE_8] = { DeleteEntity, NULL, NULL },
[NPC_NONE_9] = { DeleteEntity, NULL, NULL },
[NPC_NONE_10] = { DeleteEntity, NULL, NULL },
[NPC_NONE_11] = { DeleteEntity, NULL, NULL },
[NPC_NONE_12] = { DeleteEntity, NULL, NULL },
[NPC_NONE_13] = { DeleteEntity, NULL, NULL },
[NPC_NONE_14] = { DeleteEntity, NULL, NULL },
[NPC_NONE_15] = { DeleteEntity, NULL, NULL },
[NPC_NONE_16] = { DeleteEntity, NULL, NULL },
[NPC_NONE_17] = { DeleteEntity, NULL, NULL },
[NPC_NONE_18] = { DeleteEntity, NULL, NULL },
[NPC_NONE_19] = { DeleteEntity, NULL, NULL },
[NPC_NONE_20] = { DeleteEntity, NULL, NULL },
[NPC_NONE_21] = { DeleteEntity, NULL, NULL },
[NPC_NONE_22] = { DeleteEntity, NULL, NULL },
[NPC_NONE_23] = { DeleteEntity, NULL, NULL },
[NPC_NONE_24] = { DeleteEntity, NULL, NULL },
[NPC_NONE_25] = { DeleteEntity, NULL, NULL },
[NPC_NONE_26] = { DeleteEntity, NULL, NULL },
[NPC_NONE_27] = { DeleteEntity, NULL, NULL },
[NPC_NONE_28] = { DeleteEntity, NULL, NULL },
[NPC_NONE_29] = { DeleteEntity, NULL, NULL },
[NPC_NONE_30] = { DeleteEntity, NULL, NULL },
[NPC_NONE_31] = { DeleteEntity, NULL, NULL },
[NPC_NONE_32] = { DeleteEntity, NULL, NULL },
[NPC_NONE_33] = { DeleteEntity, NULL, NULL },
[NPC_NONE_34] = { DeleteEntity, NULL, NULL },
[NPC_NONE_35] = { DeleteEntity, NULL, NULL },
[NPC_NONE_36] = { DeleteEntity, NULL, NULL },
[NPC_NONE_37] = { DeleteEntity, NULL, NULL },
[NPC_NONE_38] = { DeleteEntity, NULL, NULL },
[NPC_NONE_39] = { DeleteEntity, NULL, NULL }
};
//clang-format on
const u8 npc_unk[] = { 0x04, 0x05, 0x06, 0x06 };
extern u32 gUnk_020342F8;
typedef struct {
u16 unk0;
@ -146,25 +12,47 @@ typedef struct {
} NPCStruct;
extern NPCStruct gNPCData[100];
void InitNPC(Entity*);
extern void InitNPC(Entity*);
// regalloc
NONMATCH("asm/non_matching/arm_proxy/NPCUpdate.inc", void NPCUpdate(Entity* this)) {
if ((this->health & 0x7f) && !ReadBit(&gUnk_020342F8, this->health - 1))
// NONMATCH("asm/non_matching/arm_proxy/NPCUpdate.inc", void NPCUpdate(Entity* this)) {
// if ((this->health & 0x7f) && !ReadBit(&gUnk_020342F8, this->health - 1))
// DeleteThisEntity();
// if (this->action == 0 && (this->flags & ENT_DID_INIT) == 0)
// InitNPC(this);
// if (!EntityIsDeleted(this))
// gNPCFunctions[this->id][0](this);
// if (this->next != NULL) {
// if (gNPCFunctions[this->id][1] != NULL)
// gNPCFunctions[this->id][1](this);
// if ((this->health & 0x7f) != 0) {
// u32 temp = this->health & 0x7f;
// gNPCData[temp * 2 - 2].x = this->x.HALF.HI - gRoomControls.origin_x;
// gNPCData[temp * 2 - 2].y = this->y.HALF.HI - gRoomControls.origin_y;
// }
// DrawEntity(this);
// }
// }
// END_NONMATCH
void NPCUpdate(Entity* this) {
u32 health = this->health;
u32 temp;
if ((health & 0x7f) && !ReadBit(&gUnk_020342F8, health - 1))
DeleteThisEntity();
if (this->action == 0 && (this->flags & ENT_DID_INIT) == 0)
InitNPC(this);
NPCInit(this);
if (!EntityIsDeleted(this))
gNPCFunctions[this->id][0](this);
if (this->next != NULL) {
if (gNPCFunctions[this->id][1] != NULL)
gNPCFunctions[this->id][1](this);
if ((this->health & 0x7f) != 0) {
u32 temp = this->health & 0x7f;
gNPCData[temp * 2 - 2].x = this->x.HALF.HI - gRoomControls.origin_x;
gNPCData[temp * 2 - 2].y = this->y.HALF.HI - gRoomControls.origin_y;
if (this->health % 0x80) {
NPCStruct* npc = gNPCData;
npc += (this->health * 2 - 2);
npc->x = this->x.HALF.HI - gRoomControls.origin_x;
npc->y = this->y.HALF.HI - gRoomControls.origin_y;
}
DrawEntity(this);
}
}
END_NONMATCH

135
src/npcFunctions.c Normal file
View File

@ -0,0 +1,135 @@
#include "npc.h"
//clang-format off
void (*const gNPCFunctions[][3])(Entity* ent) = {
[NPC_NONE_0] = { DeleteEntity, NULL, NULL },
[GENTARI] = { Gentari, NULL, Gentari_Fusion },
[FESTARI] = { Festari, NULL, Festari_Fusion },
[FOREST_MINISH] = { ForestMinish, ForestMinish_Head, ForestMinish_Fusion },
[POSTMAN] = { Postman, NULL, Postman_Fusion },
[NPC_UNK_5] = { NPC5, NULL, NULL },
[TPWNSPERSON] = { Townsperson, Townsperson_Head, Townsperson_Fusion },
[KID] = { Kid, Kid_Head, Kid_Fusion },
[GUARD] = { Guard, Guard_Head, NULL },
[NPC_UNK_9] = { NPC9, NULL, NULL },
[STAMP] = { Stamp, NULL, NULL },
[MAID] = { Maid, Maid_Head, NULL },
[MARCY] = { Marcy, NULL, NULL },
[WHEATON] = { Wheaton, NULL, NULL },
[PITA] = { Pita, NULL, NULL },
[MINISH_EZLO] = { MinishEzlo, MinishEzlo_Head, NULL },
[MAILBOX] = { Mailbox, NULL, NULL },
[BEEDLE] = { Beedle, Beedle_Head, NULL },
[BROCCO] = { Brocco, NULL, Brocco_Fusion },
[SITTING_PERSON] = { SittingPerson, SittingPerson_Head, SittingPerson_Fusion },
[PINA] = { Pina, NULL, Pina_Fusion },
[GUARD_1] = { Guard, Guard_Head, NULL },
[MAID_1] = { Maid, Maid_Head, NULL },
[DIN] = { Din, NULL, Din_Fusion },
[NAYRU] = { Nayru, NULL, Nayru_Fusion },
[FARORE] = { Farore, NULL, Farore_Fusion },
[STURGEON] = { Sturgeon, Sturgeon_Head, Sturgeon_Fusion },
[TINGLE_SIBLINGS] = { TingleSiblings, NULL, TingleSiblings_Fusion },
[STOCKWELL] = { Stockwell, NULL, NULL },
[TALON] = { Talon, Talon_Head, Talon_Fusion },
[MALON] = { Malon, NULL, Malon_Fusion },
[EPONA] = { Epona, NULL, Epona_Fusion },
[MILK_CART] = { MilkCart, NULL, NULL },
[GHOST_BROTHERS] = { GhostBrothers, NULL, GhostBrothers_Fusion },
[SMITH] = { Smith, Smith_Head, Smith_Fusion },
[NPC_UNK_23] = { NPC23, NULL, NULL },
[KING_DALTUS] = { KingDaltus, NULL, KingDaltus_Fusion },
[MINISTER_POTHO] = { MinisterPotho, NULL, MinisterPotho_Fusion },
[NPC_UNK_26] = { NPC26, NULL, NULL },
[VAATI] = { Vaati, NULL, NULL },
[ZELDA] = { Zelda, NULL, NULL },
[MUTOH] = { Mutoh, Mutoh_Head, Mutoh_Fusion },
[CARPENTER] = { Carpenter, Carpenter_Head, Carpenter_Fusion },
[CASTOR_WILDS_STATUE] = { CastorWildsStatue, NULL, CastorWildsStatue_Fusion },
[CAT] = { Cat, NULL, Cat_Fusion },
[MOUNTAIN_MINISH] = { MountainMinish, MountainMinish_Head, MountainMinish_Fusion },
[ZELDA_FOLLOWER] = { ZeldaFollower, NULL, NULL },
[MELARI] = { Melari, Melari_Head, Melari_Fusion },
[BLADE_BROTHERS] = { BladeBrothers, NULL, BladeBrothers_Fusion },
[COW] = { Cow, NULL, Cow_Fusion },
[GORON] = { Goron, NULL, Goron_Fusion },
[GORON_MERCHANT] = { GoronMerchant, NULL, NULL },
[GORMAN] = { Gorman, Gorman_Head, NULL },
[DOG] = { Dog, Dog_Head, Dog_Fusion },
[SYRUP] = { Syrup, Syrup_Head, NULL },
[REM] = { Rem, NULL, NULL },
[TOWN_MINISH] = { TownMinish, TownMinish_Head, TownMinish_Fusion },
[LIBRARI] = { Librari, NULL, Librari_Fusion },
[PERCY] = { Percy, Percy_Head, Percy_Fusion },
[VAATI_REBORN] = { VaatiReborn, NULL, NULL },
[MOBLIN_LADY] = { MoblinLady, NULL, NULL },
[LIBRARIANS] = { Librarians, NULL, NULL },
[FARMERS] = { Farmers, Farmers_Head, Farmers_Fusion },
[CARLOV] = { Carlov, NULL, NULL },
[DAMPE] = { Dampe, NULL, Dampe_Fusion },
[DR_LEFT] = { DrLeft, NULL, NULL },
[KING_GUSTAF] = { KingGustaf, NULL, NULL },
[GINA] = { Gina, NULL, Gina_Fusion },
[SIMON] = { Simon, NULL, NULL },
[ANJU] = { Anju, NULL, Anju_Fusion },
[MAMA] = { Mama, Mama_Head, Mama_Fusion },
[EMMA] = { Emma, NULL, NULL },
[TEACHERS] = { Teachers, Teachers_Head, Teachers_Fusion },
[WIND_TRIBESPEOPLE] = { WindTribespeople, WindTribespeople_Head, WindTribespeople_Fusion },
[GREGAL] = { Gregal, NULL, Gregal_Fusion },
[MAYOR_HAGEN] = { MayorHagen, NULL, MayorHagen_Fusion },
[BIG_GORON] = { BigGoron, NULL, NULL },
[EZLO] = { Ezlo, NULL, NULL },
[NPC_UNK_4E] = { NPC4E, NULL, NPC4E_Fusion },
[NPC_UNK_4F] = { NPC4F, NULL, NULL },
[CLOTHES_RACK] = { ClothesRack, NULL, NULL },
[PICOLYTE_BOTTLE] = { PicolyteBottle, NULL, NULL },
[SMALL_TOWN_MINISH] = { SmallTownMinish, NULL, NULL },
[HURDY_GURDY_MAN] = { HurdyGurdyMan, HurdyGurdyMan_Head, HurdyGurdyMan_Fusion },
[CUCCO] = { Cucco, NULL, Cucco_Fusion },
[CUCCO_CHICK] = { CuccoChick, NULL, CuccoChick_Fusion },
[FUSION_MENU_NPC] = { FusionMenuNPC, FusionMenuNPC_Head, NULL },
[PHONOGRAPH] = { Phonograph, NULL, NULL },
[NPC_UNK_58] = { NPC58, NPC58_Head, NULL },
[NPC_NONE_1] = { DeleteEntity, NULL, NULL },
[NPC_NONE_2] = { DeleteEntity, NULL, NULL },
[NPC_NONE_3] = { DeleteEntity, NULL, NULL },
[NPC_NONE_4] = { DeleteEntity, NULL, NULL },
[NPC_NONE_5] = { DeleteEntity, NULL, NULL },
[NPC_NONE_6] = { DeleteEntity, NULL, NULL },
[NPC_NONE_7] = { DeleteEntity, NULL, NULL },
[NPC_NONE_8] = { DeleteEntity, NULL, NULL },
[NPC_NONE_9] = { DeleteEntity, NULL, NULL },
[NPC_NONE_10] = { DeleteEntity, NULL, NULL },
[NPC_NONE_11] = { DeleteEntity, NULL, NULL },
[NPC_NONE_12] = { DeleteEntity, NULL, NULL },
[NPC_NONE_13] = { DeleteEntity, NULL, NULL },
[NPC_NONE_14] = { DeleteEntity, NULL, NULL },
[NPC_NONE_15] = { DeleteEntity, NULL, NULL },
[NPC_NONE_16] = { DeleteEntity, NULL, NULL },
[NPC_NONE_17] = { DeleteEntity, NULL, NULL },
[NPC_NONE_18] = { DeleteEntity, NULL, NULL },
[NPC_NONE_19] = { DeleteEntity, NULL, NULL },
[NPC_NONE_20] = { DeleteEntity, NULL, NULL },
[NPC_NONE_21] = { DeleteEntity, NULL, NULL },
[NPC_NONE_22] = { DeleteEntity, NULL, NULL },
[NPC_NONE_23] = { DeleteEntity, NULL, NULL },
[NPC_NONE_24] = { DeleteEntity, NULL, NULL },
[NPC_NONE_25] = { DeleteEntity, NULL, NULL },
[NPC_NONE_26] = { DeleteEntity, NULL, NULL },
[NPC_NONE_27] = { DeleteEntity, NULL, NULL },
[NPC_NONE_28] = { DeleteEntity, NULL, NULL },
[NPC_NONE_29] = { DeleteEntity, NULL, NULL },
[NPC_NONE_30] = { DeleteEntity, NULL, NULL },
[NPC_NONE_31] = { DeleteEntity, NULL, NULL },
[NPC_NONE_32] = { DeleteEntity, NULL, NULL },
[NPC_NONE_33] = { DeleteEntity, NULL, NULL },
[NPC_NONE_34] = { DeleteEntity, NULL, NULL },
[NPC_NONE_35] = { DeleteEntity, NULL, NULL },
[NPC_NONE_36] = { DeleteEntity, NULL, NULL },
[NPC_NONE_37] = { DeleteEntity, NULL, NULL },
[NPC_NONE_38] = { DeleteEntity, NULL, NULL },
[NPC_NONE_39] = { DeleteEntity, NULL, NULL }
};
//clang-format on
const u8 npc_unk[] = { 0x04, 0x05, 0x06, 0x06 };

View File

@ -47,44 +47,52 @@ void LoadRoomEntityList(const EntityData* listPtr) {
}
}
NONMATCH("asm/non_matching/LoadRoomEntity.inc", Entity* LoadRoomEntity(const EntityData* dat)) {
Entity* LoadRoomEntity(const EntityData* dat) {
int kind;
Entity* v4;
Entity* v5;
Entity* entity;
// r4/r5 regalloc
#ifndef NON_MATCHING
asm("" ::: "r5");
#endif
kind = dat->kind & 0xF;
if ((dat->flags & 0xF0) == 0x50 && DeepFindEntityByID(kind, dat->id))
return NULL;
v4 = GetEmptyEntityByKind(kind);
v5 = v4;
if (v4 != NULL) {
v4->kind = kind;
v4->id = dat->id;
v4->type = dat->type;
RegisterRoomEntity(v4, dat);
entity = GetEmptyEntityByKind(kind);
if (entity != NULL) {
entity->kind = kind;
entity->id = dat->id;
entity->type = dat->type;
RegisterRoomEntity(entity, dat);
if ((dat->flags & 0xF0) != 16) {
v5->type2 = dat->type2;
v5->timer = (dat->type2 & 0xFF00) >> 8;
if (kind == MANAGER)
return v5;
sub_0804AF0C(v5, dat);
if (v5->next == NULL)
return v5;
if ((dat->kind & 0x10) == 0) {
if ((dat->kind & 0x20) != 0) {
v5->collisionLayer = 2;
return v5;
}
if ((gRoomControls.scroll_flags & 2) == 0) {
ResolveCollisionLayer(v5);
u8 kind2;
entity->type2 = *(u8*)&dat->type2;
entity->timer = (dat->type2 & 0xFF00) >> 8;
if (kind == 9)
return entity;
sub_0804AF0C(entity, dat);
if (!entity->next)
return entity;
kind2 = dat->kind & 0xF0;
if ((kind2 & 0x10) == 0) {
if ((kind2 & 0x20) != 0) {
entity->collisionLayer = 2;
return entity;
}
}
v5->collisionLayer = 1;
if ((kind2 & 0x10) || (gRoomControls.scroll_flags & 2)) {
entity->collisionLayer = 1;
return entity;
}
ResolveCollisionLayer(entity);
return entity;
}
}
return v5;
return entity;
}
END_NONMATCH
void RegisterRoomEntity(Entity* ent, const EntityData* dat) {
u32 list;