TheZZAZZGlitch's April Fools Event 2022
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

158 lines
3.3 KiB

#!/usr/bin/env python3
file = open("cave5.map", "rb").read()
def read_byte():
global offset
val = file[offset + 0]
offset += 1
return val
def read_half():
global offset
val = file[offset + 0] << 0
val |= file[offset + 1] << 8
offset += 2
return val
def read_word():
global offset
val = file[offset + 0] << 0
val |= file[offset + 1] << 8
val |= file[offset + 2] << 16
val |= file[offset + 3] << 24
offset += 4
return val
def dump_loadword():
dest = read_byte()
value = read_word()
print("loadword %d, 0x%08x" % (dest, value))
def dump_callstd():
func = read_byte()
print("callstd %d" % func)
def dump_call():
dest = read_word()
print("call 0x%08x" % dest)
def dump_callnative():
dest = read_word()
print("callnative 0x%08x" % dest)
def dump_compare_var_to_value():
var = read_half()
value = read_half()
print("compare_var_to_value %d, %d" % (var, value))
def dump_goto_if():
cond = read_byte()
dest = read_word()
print("goto_if %d, 0x%08x" % (cond, dest))
def dump_playse():
song = read_half()
print("playse %d" % song)
def dump_setvar():
var = read_half()
val = read_half()
print("setvar %d, %d" % (var, val))
def dump_loadbytefromptr():
var = read_byte()
source = read_word()
print("loadbytefromptr %d, 0x%08x" % (var, source))
def dump_setptrbyte():
var = read_byte()
dest = read_word()
print("setptrbyte %d, 0x%08x" % (var, dest))
def dump_addvar():
var = read_half()
val = read_half()
print("addvar %d, %d" % (var, val))
def dump_subvar():
var = read_half()
val = read_half()
print("subvar %d, %d" % (var, val))
def dump_copyvar():
var = read_half()
val = read_half()
print("copyvar %d, %d" % (var, val))
def dump_checkflag():
flag = read_half()
print("checkflag %d" % flag)
def dump_delay():
frames = read_half()
print("delay %d" % frames)
def dump_message():
text = read_word()
print("message 0x%08x" % text)
def dump_setflag():
flag = read_half()
print("setflag %d" % flag)
def dump_playfanfare():
song = read_half()
print("playfanfare %d" % song)
cmds = {
0x02: "end",
0x03: "return",
0x04: dump_call,
0x06: dump_goto_if,
0x09: dump_callstd,
0x0f: dump_loadword,
0x12: dump_loadbytefromptr,
0x13: dump_setptrbyte,
0x16: dump_setvar,
0x17: dump_addvar,
0x18: dump_subvar,
0x19: dump_copyvar,
0x21: dump_compare_var_to_value,
0x23: dump_callnative,
0x27: "waitstate",
0x28: dump_delay,
0x29: dump_setflag,
0x2b: dump_checkflag,
0x2f: dump_playse,
0x31: dump_playfanfare,
0x32: "waitfanfare",
0x5a: "faceplayer",
0x66: "waitmessage",
0x67: dump_message,
0x68: "closemessage",
0x6a: "lock",
0x6c: "release"
}
def dump():
global offset
while True:
cmd = file[offset]
if cmd not in cmds:
print("Unknown cmd: %02x" % cmd)
return
print("%08x: " % (offset - base_rel + base), end="")
offset += 1
ex = cmds[cmd]
if isinstance(ex, str):
print(ex)
else:
ex()
if cmd == 0x02 or cmd == 0x03:
return
base = 0x02018213
base_rel = 0x213
offset = (0x02018213 - base) + base_rel
dump()