Detect CallWithArg that pass a pointer to a script as an argument

This commit is contained in:
octorock 2021-03-07 01:50:27 +01:00
parent 8f7ad0a35c
commit 5304b4759f
17 changed files with 59 additions and 52 deletions

View File

@ -12,7 +12,7 @@ script_0800A0FE:
Call sub_0807F844
_0807E8E4_3
CallWithArg sub_0807F75C, 0x00d00060
CallWithArg sub_08094AE8, 0x0800a160
CallWithArg sub_08094AE8, script_0800A160
SoundReq 0x00f7
_0807E778 0x0002
DoFade6

View File

@ -6,7 +6,7 @@ SCRIPT_START script_0800A160
_0807E930 0x0002
SetEntityPositionRelative 0x00b0, 0x0080
CallWithArg sub_0807F98C, 0xff800000
CallWithArg sub_080960C4, 0x0800a1b4
CallWithArg sub_080960C4, script_0800A1B4
EndBlock
SoundReq 0x0142
_0807EF3C 0xff80, 0x0000

View File

@ -37,7 +37,7 @@ SCRIPT_START script_0800A310
Call sub_0807F2D4
_0807E5F8 0x00000040
WaitForSomething2 0x00000002
CallWithArg sub_080960C4, 0x0800a680
CallWithArg sub_080960C4, script_0800A680
_0807E5F8 0x00000040
SCRIPT_END
.short 0x0000

View File

@ -28,7 +28,7 @@ SCRIPT_START script_0800A3D8
_0807EB44 0x0004
_0807EF80 0x0000
SoundReq 0x0142
CallWithArg sub_080960C4, 0x0800a638
CallWithArg sub_080960C4, script_0800A638
_0807E5F8 0x00000080
WaitForSomething2 0x00000004
SoundReq 0x0143
@ -39,7 +39,7 @@ SCRIPT_START script_0800A3D8
_0807E5F8 0x00000080
WaitForSomething2 0x00000004
SoundReq 0x0142
CallWithArg sub_080960C4, 0x0800a680
CallWithArg sub_080960C4, script_0800A680
Wait 0x0078
SoundReq 0x0153
CallWithArg sub_0807FADC, 0x00000003

View File

@ -9,7 +9,7 @@ SCRIPT_START script_0800A500
WaitForSomething2 0x00000008
SoundReq 0x0142
_0807E610 0x00000800
CallWithArg sub_080960C4, 0x0800a65c
CallWithArg sub_080960C4, script_0800A65C
_0807E930 0x0002
Call sub_08094B0C
_0807EDD4 0x0068, 0x0088

View File

@ -14,7 +14,7 @@ SCRIPT_START script_0800A590
_0807EF80 0x0007
SoundReq 0x0142
_0807E610 0x00000800
CallWithArg sub_080960C4, 0x0800a65c
CallWithArg sub_080960C4, script_0800A65C
Wait 0x003c
_0807EDD4 0x0088, 0x0068
Wait 0x0078

View File

@ -40,7 +40,7 @@ SCRIPT_START script_0800AD54
Call sub_0807F2D4
_0807E5F8 0x00000004
WaitForSomething2 0x00000002
CallWithArg sub_080960C4, 0x0800af18
CallWithArg sub_080960C4, script_0800AF18
_0807E930 0x0012
Call sub_0807F2D4
Wait 0x001e

View File

@ -59,7 +59,7 @@ script_0801015A:
Call sub_080A1608
_0807EA94
_0807E878
CallWithArg sub_080A1550, 0x080101ac
CallWithArg sub_080A1550, script_080101AC
JumpIfNot script_0801015A
SoundReq2 0x0015
SetRoomFlag 0x0001

View File

@ -33,7 +33,7 @@ SCRIPT_START script_080116A8
_0807EB44 0x0000
_0807EF80 0x0014
SoundReq 0x0120
CallWithArg sub_08095420, 0x08011890
CallWithArg sub_08095420, script_08011890
Wait 0x00f0
_0807EF80 0x0016
SoundReq 0x01cb
@ -50,7 +50,7 @@ SCRIPT_START script_080116A8
WaitForSomething2 0x00000100
_0807EF80 0x0014
SoundReq 0x01c4
CallWithArg sub_0809545C, 0x080118d4
CallWithArg sub_0809545C, script_080118D4
_0807E5F8 0x00000200
WaitForSomething2 0x00000100
Wait 0x003c

View File

@ -15,7 +15,7 @@ SCRIPT_START script_080133F8
Wait 0x003c
_0807EF80 0x0014
SoundReq 0x0120
CallWithArg sub_08095420, 0x08013494
CallWithArg sub_08095420, script_08013494
Wait 0x005a
_0807EF80 0x0016
WaitForSomething2 0x00000080

View File

@ -13,33 +13,33 @@ script_080134F8:
Call sub_0807DF28
StartPlayerScript script_080136D8
WaitForSomething2 0x00000001
CallWithArg sub_08095A1C, 0x08013f04
CallWithArg sub_08095A1C, script_08013F04
SoundReq 0x01cd
Wait 0x005a
BeginBlock
SoundReq 0x01ce
CallWithArg sub_08095D54, 0x08013e04
CallWithArg sub_08095D54, 0x08013e28
CallWithArg sub_08095D54, script_08013E04
CallWithArg sub_08095D54, script_08013E28
EndBlock
WaitForSomething2 0x18000000
BeginBlock
SoundReq 0x01cf
CallWithArg sub_08095D8C, 0x08014054
CallWithArg sub_08095D8C, 0x08014074
CallWithArg sub_08095D8C, script_08014054
CallWithArg sub_08095D8C, script_08014074
EndBlock
Wait 0x001e
BeginBlock
SoundReq 0x01d0
CallWithArg sub_08095D8C, 0x080140dc
CallWithArg sub_08095D8C, 0x08014118
CallWithArg sub_08095D8C, script_080140DC
CallWithArg sub_08095D8C, script_08014118
EndBlock
Wait 0x003c
CallWithArg sub_0805DDEC, 0x00000000
_0807E5F8 0x00000200
WaitForSomething2 0x00002000
SoundReq 0x01d2
CallWithArg sub_08095D8C, 0x080141dc
CallWithArg sub_08095D8C, 0x08014210
CallWithArg sub_08095D8C, script_080141DC
CallWithArg sub_08095D8C, script_08014210
_0807E5F8 0x00000400
WaitForSomething2 0x00004000
Wait 0x0078

View File

@ -13,34 +13,34 @@ script_0801373C:
Call sub_0807DF28
StartPlayerScript script_080136D8
WaitForSomething2 0x00000001
CallWithArg sub_08095A1C, 0x08013f34
CallWithArg sub_08095A1C, script_08013F34
SoundReq 0x01cd
Wait 0x005a
BeginBlock
SoundReq 0x01ce
CallWithArg sub_08095D54, 0x08013e4c
CallWithArg sub_08095D54, script_08013E4C
EndBlock
WaitForSomething2 0x20000000
BeginBlock
SoundReq 0x01cf
CallWithArg sub_08095D8C, 0x08014054
CallWithArg sub_08095D8C, 0x08014074
CallWithArg sub_08095D8C, 0x08014094
CallWithArg sub_08095D8C, script_08014054
CallWithArg sub_08095D8C, script_08014074
CallWithArg sub_08095D8C, script_08014094
EndBlock
Wait 0x001e
BeginBlock
SoundReq 0x01d0
CallWithArg sub_08095D8C, 0x080140dc
CallWithArg sub_08095D8C, 0x08014118
CallWithArg sub_08095D8C, 0x08014154
CallWithArg sub_08095D8C, script_080140DC
CallWithArg sub_08095D8C, script_08014118
CallWithArg sub_08095D8C, script_08014154
EndBlock
Wait 0x003c
CallWithArg sub_0805DDEC, 0x00000000
_0807E5F8 0x00000200
WaitForSomething2 0x00002000
SoundReq 0x01d2
CallWithArg sub_08095D8C, 0x080141dc
CallWithArg sub_08095D8C, 0x08014210
CallWithArg sub_08095D8C, script_080141DC
CallWithArg sub_08095D8C, script_08014210
_0807E5F8 0x00000400
WaitForSomething2 0x00004000
_0807E5F8 0x00000800

View File

@ -13,36 +13,36 @@ script_080138D0:
Call sub_0807DF28
StartPlayerScript script_080136D8
WaitForSomething2 0x00000001
CallWithArg sub_08095A1C, 0x08013f64
CallWithArg sub_08095A1C, script_08013F64
SoundReq 0x01cd
Wait 0x005a
BeginBlock
SoundReq 0x01ce
CallWithArg sub_08095D54, 0x08013e70
CallWithArg sub_08095D54, script_08013E70
EndBlock
WaitForSomething2 0x40000000
BeginBlock
SoundReq 0x01cf
CallWithArg sub_08095D8C, 0x08014054
CallWithArg sub_08095D8C, 0x08014074
CallWithArg sub_08095D8C, 0x08014094
CallWithArg sub_08095D8C, 0x080140b8
CallWithArg sub_08095D8C, script_08014054
CallWithArg sub_08095D8C, script_08014074
CallWithArg sub_08095D8C, script_08014094
CallWithArg sub_08095D8C, script_080140B8
EndBlock
Wait 0x001e
BeginBlock
SoundReq 0x01d0
CallWithArg sub_08095D8C, 0x080140dc
CallWithArg sub_08095D8C, 0x08014118
CallWithArg sub_08095D8C, 0x08014154
CallWithArg sub_08095D8C, 0x08014198
CallWithArg sub_08095D8C, script_080140DC
CallWithArg sub_08095D8C, script_08014118
CallWithArg sub_08095D8C, script_08014154
CallWithArg sub_08095D8C, script_08014198
EndBlock
Wait 0x003c
CallWithArg sub_0805DDEC, 0x00000000
_0807E5F8 0x00000200
WaitForSomething2 0x00002000
SoundReq 0x01d2
CallWithArg sub_08095D8C, 0x080141dc
CallWithArg sub_08095D8C, 0x08014210
CallWithArg sub_08095D8C, script_080141DC
CallWithArg sub_08095D8C, script_08014210
_0807E5F8 0x00000400
WaitForSomething2 0x00004000
_0807E5F8 0x00000800

View File

@ -1,5 +1,5 @@
SCRIPT_START script_08013BA8
CallWithArg sub_08095E7C, 0x08014248
CallWithArg sub_08095E7C, script_08014248
SoundReq 0x01d3
CallWithArg sub_0807F238, 0x000008e3
Call sub_08096028

View File

@ -29,7 +29,7 @@ SCRIPT_START script_08015684
WaitForSomething2 0x00000800
_0807EB44 0x0004
_0807EF80 0x0014
CallWithArg sub_0809545C, 0x08015754
CallWithArg sub_0809545C, script_08015754
SoundReq 0x01c4
Wait 0x0078
_0807EF80 0x0016

View File

@ -1,6 +1,10 @@
from utils import barray_to_u16_hex, barray_to_u32_hex, barray_to_s16
import struct
ROM_OFFSET = 0x08000000
SCRIPTS_START = 0x08008B5C
SCRIPTS_END = 0x08016984
# A list of all the commands, their correspondingScriptCommand_ functions and what kind of parameters they take
commands = [
{'fun': 'ScriptCommandNop', 'params': ''},
@ -15,7 +19,7 @@ commands = [
{'fun': 'ScriptCommand_JumpAbsoluteIfNot', 'params': 'x'},
{'fun': 'ScriptCommand_JumpAbsoluteSwitch', 'params': 'xx'},
{'fun': 'ScriptCommand_Call', 'params': 'p'},
{'fun': 'ScriptCommand_CallWithArg', 'params': ['pw', 'p']},
{'fun': 'ScriptCommand_CallWithArg', 'params': ['px', 'p']},
{'fun': 'ScriptCommand_LoadRoomEntityList', 'params': 'd'},
{'fun': 'ScriptCommand_TestBit', 'params': 'w'},
{'fun': 'ScriptCommand_CheckInventory1', 'params': 's'},
@ -181,7 +185,11 @@ def get_data_pointer(barray):
def get_script_pointer(barray):
integers = struct.unpack('I', barray)
return 'script_' + (struct.pack('>I', integers[0]).hex()).upper()
val = integers[0]
if val >= SCRIPTS_START and val <= SCRIPTS_END:
return 'script_' + (struct.pack('>I', val).hex()).upper()
else:
return '0x'+struct.pack('>I', val).hex()
def get_script_label(u32):
@ -285,11 +293,11 @@ parameters = {
'read': lambda ctx: get_pointer(ctx.data[ctx.ptr + 2:ctx.ptr + 6])
},
'pw': {
'px': {
'length': 4,
'param': 'a,b',
'expr': ' .word \\a\n .word \\b',
'read': lambda ctx: get_pointer(ctx.data[ctx.ptr + 2:ctx.ptr + 6]) + ', ' + barray_to_u32_hex(ctx.data[ctx.ptr + 6:ctx.ptr + 14])[0]
'read': lambda ctx: get_pointer(ctx.data[ctx.ptr + 2:ctx.ptr + 6]) + ', ' + get_script_pointer(ctx.data[ctx.ptr + 6:ctx.ptr + 10])
},
'd': { # Data pointer
'length': 2,

View File

@ -1,3 +1,4 @@
from definitions import ROM_OFFSET, SCRIPTS_END, SCRIPTS_START
from script_disassembler import disassemble_script, generate_macros
import sys
@ -6,9 +7,7 @@ import sys
TMC_FOLDER = '../..'
ROM_OFFSET = 0x08000000
SCRIPTS_START = 0x08008B5C
SCRIPTS_END = 0x08016984
# Create labels for these additional script instructions
# Currently done by splitting the script at that point