summaryrefslogtreecommitdiff
path: root/tools/script_extractor.py
diff options
context:
space:
mode:
authorAndrew <andrewrmartinek@gmail.com>2020-12-14 00:46:55 -0500
committerAndrew <andrewrmartinek@gmail.com>2020-12-14 00:46:55 -0500
commit58f19904158c02c55b6b264a1bc76ac6467d1e18 (patch)
tree2a2ce2e6edffa27fb88a71a71ce3984ecc54dba0 /tools/script_extractor.py
parentd8f98d97bcd41f710d51925470dc799a6051f022 (diff)
added move_player macro and updated script extractor
Diffstat (limited to 'tools/script_extractor.py')
-rw-r--r--tools/script_extractor.py268
1 files changed, 153 insertions, 115 deletions
diff --git a/tools/script_extractor.py b/tools/script_extractor.py
index 812678c..a678bac 100644
--- a/tools/script_extractor.py
+++ b/tools/script_extractor.py
@@ -55,43 +55,78 @@ def extractMovement(game_data, loc, errQuit):
def decodeLine(scriptList, game_data, loc, ignore_broken, locList):
currLine = scriptList[game_data[loc]]
- ret = "\trun_command " + currLine[0] + "\n"
+ macroMode = False
+ if currLine[3] != "": # this seems like a bad way to handle macros, but the least bad I wanna do rn
+ macroMode = True
+ ret = "\t" + currLine[3] + " "
+ else:
+ ret = "\trun_command " + currLine[0] + "\n"
loc+=1
quit = currLine[2]
for c in currLine[1]:
if c == "b":
- ret += "\tdb $" + format(game_data[loc],"02x") + "\n"
+ if macroMode:
+ ret += "$" + format(game_data[loc],"02x") + ", "
+ else:
+ ret += "\tdb $" + format(game_data[loc],"02x") + "\n"
loc += 1
elif c == "i":
- ret += "\tdb " + str(game_data[loc]) + "\n"
+ if macroMode:
+ ret += str(game_data[loc]) + ", "
+ else:
+ ret += "\tdb " + str(game_data[loc]) + "\n"
loc += 1
elif c == "w":
- ret += "\tdw $" + format((game_data[loc] + (game_data[loc+1]<<8)),"04x") + "\n"
+ if macroMode:
+ ret += "$" + format((game_data[loc] + (game_data[loc+1]<<8)),"04x") + ", "
+ else:
+ ret += "\tdw $" + format((game_data[loc] + (game_data[loc+1]<<8)),"04x") + "\n"
loc += 2
elif c == "j":
wordLoc = (game_data[loc] + (game_data[loc+1]<<8))
if wordLoc == 0000:
- ret += "\tdw NO_JUMP\n"
+ if macroMode:
+ ret += "NO_JUMP, "
+ else:
+ ret += "\tdw NO_JUMP\n"
else:
- ret += "\tdw .ows_" + format(wordLoc+0x8000,"04x") + "\n"
+ if macroMode:
+ ret += ".ows_" + format(wordLoc+0x8000,"04x") + ", "
+ else:
+ ret += "\tdw .ows_" + format(wordLoc+0x8000,"04x") + "\n"
locList.append(wordLoc)
loc += 2
elif c == "t":
addr = (game_data[loc] + (game_data[loc+1]<<8))
if addr == 0:
- ret += "\tdw $0000\n"
+ if macroMode:
+ ret += "$0000, "
+ else:
+ ret += "\tdw $0000\n"
else:
- ret += "\ttx Text" + format(addr,"04x") + "\n"
+ if macroMode:
+ ret += "Text" + format(addr,"04x") + ", "
+ else:
+ ret += "\ttx Text" + format(addr,"04x") + "\n"
loc += 2
elif c == "f":
- ret += "\tdb EVENT_FLAG_" + format(game_data[loc],"02X") + "\n"
+ if macroMode:
+ ret += "EVENT_FLAG_" + format(game_data[loc],"02X") + ", "
+ else:
+ ret += "\tdb EVENT_FLAG_" + format(game_data[loc],"02X") + "\n"
loc += 1
elif c == "d":
- ret += "\tdb " + dir_list[game_data[loc]] + "\n"
+ if macroMode:
+ ret += dir_list[game_data[loc]] + ", "
+ else:
+ ret += "\tdb " + dir_list[game_data[loc]] + "\n"
loc += 1
elif c == "m":
wordLoc = (game_data[loc] + (game_data[loc+1]<<8))
- ret += "\tdw NPCMovement_" + format(wordLoc + 0x8000, "04x") + "\n"
+ if macroMode:
+ ret += "NPCMovement_" + format(wordLoc + 0x8000, "04x") + ", "
+ else:
+ ret += "\tdw NPCMovement_" + format(wordLoc + 0x8000, "04x") + "\n"
loc += 2
elif c == "q":
print("haven't updated data for this yet")
@@ -99,6 +134,9 @@ def decodeLine(scriptList, game_data, loc, ignore_broken, locList):
quit = QUIT_DEBUG
else:
print("UNACCEPTED CHARACTER: " + c)
+ # if in macro mode, remove the extra `, ` from the end
+ if macroMode:
+ ret = ret[:-1]
return (loc, ret, quit)
def main():
@@ -175,110 +213,110 @@ def printScript(game_data, loc, auto, ignore_broken, scriptList, \
def createList(): # this is a func just so all this can go at the bottom
# name, arg list, is an ender
return [
- ("ScriptCommand_EndScriptLoop1", "", QUIT_CONTINUE_CODE),
- ("ScriptCommand_CloseAdvancedTextBox", "", DO_NOT_QUIT),
- ("ScriptCommand_PrintTextString", "t", DO_NOT_QUIT),
- ("Func_ccdc", "t", DO_NOT_QUIT),
- ("ScriptCommand_AskQuestionJump", "tj", DO_NOT_QUIT), # more complex behavior too (jumping)
- ("ScriptCommand_StartBattle", "bbb", DO_NOT_QUIT),
- ("ScriptCommand_PrintVariableText", "tt", DO_NOT_QUIT),
- ("Func_cda8", "bbbb", DO_NOT_QUIT),
- ("ScriptCommand_PrintTextQuitFully", "t", QUIT_SPECIAL),
- ("Func_cdcb", "", DO_NOT_QUIT),
- ("ScriptCommand_MoveActiveNPCByDirection", "w", DO_NOT_QUIT),
- ("ScriptCommand_CloseTextBox", "", DO_NOT_QUIT),
- ("ScriptCommand_GiveBoosterPacks", "bbb", DO_NOT_QUIT),
- ("ScriptCommand_CheckIfCardInCollectionOrDecks", "bj", DO_NOT_QUIT), # more complex behavior too (jumping)
- ("ScriptCommand_CheckIfCardInCollection", "bj", DO_NOT_QUIT),
- ("ScriptCommand_GiveCard", "b", DO_NOT_QUIT),
- ("ScriptCommand_TakeCard", "b", DO_NOT_QUIT),
- ("Func_cf53", "w", DO_NOT_QUIT), # more complex behavior too (jumping)
- ("Func_cf7b", "", DO_NOT_QUIT),
- ("ScriptCommand_CheckRawAmountOfCardsOwned", "bbbb", DO_NOT_QUIT), # more complex behavior too (jumping + ??)
- ("ScriptCommand_JumpBasedOnFightingClubPupilStatus", "w", DO_NOT_QUIT), # only jumps? still needs args to do that though
- ("Func_cfc6", "b", DO_NOT_QUIT),
- ("Func_cfd4", "", DO_NOT_QUIT),
- ("Func_d00b", "", DO_NOT_QUIT), # includes something with random and extra data
- ("Func_d025", "w", DO_NOT_QUIT), # possibly only jumps, still needs args
- ("Func_d032", "w", DO_NOT_QUIT), # see above
- ("Func_d03f", "", DO_NOT_QUIT),
- ("ScriptCommand_Jump", "j", QUIT_JUMP), # jumps to d
- ("ScriptCommand_TryGiveMedalPCPacks", "", DO_NOT_QUIT),
- ("ScriptCommand_SetPlayerDirection", "d", DO_NOT_QUIT),
- ("ScriptCommand_MovePlayer", "db", DO_NOT_QUIT),
- ("ScriptCommand_ShowCardReceivedScreen", "b", DO_NOT_QUIT),
- ("ScriptCommand_SetDialogName", "b", DO_NOT_QUIT),
- ("ScriptCommand_SetNextNPCandScript", "bj", DO_NOT_QUIT),
- ("Func_d095", "bbb", DO_NOT_QUIT),
- ("Func_d0be", "bb", DO_NOT_QUIT),
- ("ScriptCommand_DoFrames", "i", DO_NOT_QUIT),
- ("Func_d0d9", "bbw", DO_NOT_QUIT), # jumps but still needs args
- ("ScriptCommand_JumpIfPlayerCoordMatches", "iij", DO_NOT_QUIT), # jumps but still needs args
- ("ScriptCommand_MoveActiveNPC", "m", DO_NOT_QUIT),
- ("ScriptCommand_GiveOneOfEachTrainerBooster", "", DO_NOT_QUIT),
- ("Func_d103", "q", DO_NOT_QUIT),
- ("Func_d125", "b", DO_NOT_QUIT),
- ("Func_d135", "b", DO_NOT_QUIT),
- ("Func_d16b", "b", DO_NOT_QUIT),
- ("Func_cd4f", "bbb", DO_NOT_QUIT),
- ("Func_cd94", "q", DO_NOT_QUIT),
- ("ScriptCommand_MoveWramNPC", "m", DO_NOT_QUIT),
- ("Func_cdd8", "", DO_NOT_QUIT),
- ("Func_cdf5", "bb", DO_NOT_QUIT),
- ("Func_d195", "", DO_NOT_QUIT),
- ("Func_d1ad", "", DO_NOT_QUIT),
- ("Func_d1b3", "", DO_NOT_QUIT),
- ("ScriptCommand_QuitScriptFully", "", QUIT_SPECIAL),
- ("Func_d244", "q", DO_NOT_QUIT),
- ("Func_d24c", "q", DO_NOT_QUIT),
- ("ScriptCommand_OpenDeckMachine", "b", DO_NOT_QUIT),
- ("Func_d271", "q", DO_NOT_QUIT),
- ("ScriptCommand_EnterMap", "bbood", DO_NOT_QUIT),
- ("ScriptCommand_MoveArbitraryNPC", "bm", DO_NOT_QUIT),
- ("Func_d209", "", DO_NOT_QUIT),
- ("Func_d38f", "b", DO_NOT_QUIT),
- ("Func_d396", "b", DO_NOT_QUIT),
- ("Func_cd76", "", DO_NOT_QUIT),
- ("Func_d39d", "b", DO_NOT_QUIT),
- ("Func_d3b9", "", DO_NOT_QUIT),
- ("ScriptCommand_TryGivePCPack", "b", DO_NOT_QUIT),
- ("ScriptCommand_nop", "", DO_NOT_QUIT),
- ("Func_d3d4", "q", DO_NOT_QUIT),
- ("Func_d3e0", "", DO_NOT_QUIT),
- ("Func_d3fe", "q", DO_NOT_QUIT),
- ("Func_d408", "b", DO_NOT_QUIT),
- ("Func_d40f", "q", DO_NOT_QUIT),
- ("ScriptCommand_PlaySFX", "b", DO_NOT_QUIT),
- ("ScriptCommand_PauseSong", "q", DO_NOT_QUIT),
- ("ScriptCommand_ResumeSong", "q", DO_NOT_QUIT),
- ("Func_d41d", "", DO_NOT_QUIT),
- ("ScriptCommand_WaitForSongToFinish", "q", DO_NOT_QUIT),
- ("Func_d435", "b", DO_NOT_QUIT),
- ("ScriptCommand_AskQuestionJumpDefaultYes", "tj", DO_NOT_QUIT),
- ("Func_d2f6", "q", DO_NOT_QUIT),
- ("Func_d317", "", DO_NOT_QUIT),
- ("Func_d43d", "", DO_NOT_QUIT),
- ("ScriptCommand_EndScriptLoop2", "q", QUIT_CONTINUE_CODE),
- ("ScriptCommand_EndScriptLoop3", "q", QUIT_CONTINUE_CODE),
- ("ScriptCommand_EndScriptLoop4", "q", QUIT_CONTINUE_CODE),
- ("ScriptCommand_EndScriptLoop5", "q", QUIT_CONTINUE_CODE),
- ("ScriptCommand_EndScriptLoop6", "q", QUIT_CONTINUE_CODE),
- ("ScriptCommand_SetFlagValue", "fb", DO_NOT_QUIT),
- ("ScriptCommand_JumpIfFlagZero1", "fj", DO_NOT_QUIT),
- ("ScriptCommand_JumpIfFlagNonzero1", "q", DO_NOT_QUIT),
- ("ScriptCommand_JumpIfFlagEqual", "fbj", DO_NOT_QUIT), # also capable of jumping
- ("ScriptCommand_JumpIfFlagNotEqual", "fbj", DO_NOT_QUIT), # jumps
- ("ScriptCommand_JumpIfFlagNotLessThan", "fbj", DO_NOT_QUIT),
- ("ScriptCommand_JumpIfFlagLessThan", "fbj", DO_NOT_QUIT),
- ("ScriptCommand_MaxOutFlagValue", "f", DO_NOT_QUIT),
- ("ScriptCommand_ZeroOutFlagValue", "f", DO_NOT_QUIT),
- ("ScriptCommand_JumpIfFlagNonzero2", "fj", DO_NOT_QUIT),
- ("ScriptCommand_JumpIfFlagZero2", "fj", DO_NOT_QUIT),
- ("ScriptCommand_IncrementFlagValue", "f", DO_NOT_QUIT),
- ("ScriptCommand_EndScriptLoop7", "q", QUIT_CONTINUE_CODE),
- ("ScriptCommand_EndScriptLoop8", "q", QUIT_CONTINUE_CODE),
- ("ScriptCommand_EndScriptLoop9", "q", QUIT_CONTINUE_CODE),
- ("ScriptCommand_EndScriptLoop10", "q", QUIT_CONTINUE_CODE)
+ ("ScriptCommand_EndScriptLoop1", "", QUIT_CONTINUE_CODE,""),
+ ("ScriptCommand_CloseAdvancedTextBox", "", DO_NOT_QUIT,""),
+ ("ScriptCommand_PrintTextString", "t", DO_NOT_QUIT,""),
+ ("Func_ccdc", "t", DO_NOT_QUIT,""),
+ ("ScriptCommand_AskQuestionJump", "tj", DO_NOT_QUIT,""), # more complex behavior too (jumping)
+ ("ScriptCommand_StartBattle", "bbb", DO_NOT_QUIT,""),
+ ("ScriptCommand_PrintVariableText", "tt", DO_NOT_QUIT,""),
+ ("Func_cda8", "bbbb", DO_NOT_QUIT,""),
+ ("ScriptCommand_PrintTextQuitFully", "t", QUIT_SPECIAL,""),
+ ("Func_cdcb", "", DO_NOT_QUIT,""),
+ ("ScriptCommand_MoveActiveNPCByDirection", "w", DO_NOT_QUIT,""),
+ ("ScriptCommand_CloseTextBox", "", DO_NOT_QUIT,""),
+ ("ScriptCommand_GiveBoosterPacks", "bbb", DO_NOT_QUIT,""),
+ ("ScriptCommand_CheckIfCardInCollectionOrDecks", "bj", DO_NOT_QUIT,""), # more complex behavior too (jumping)
+ ("ScriptCommand_CheckIfCardInCollection", "bj", DO_NOT_QUIT,""),
+ ("ScriptCommand_GiveCard", "b", DO_NOT_QUIT,""),
+ ("ScriptCommand_TakeCard", "b", DO_NOT_QUIT,""),
+ ("Func_cf53", "w", DO_NOT_QUIT,""), # more complex behavior too (jumping)
+ ("Func_cf7b", "", DO_NOT_QUIT,""),
+ ("ScriptCommand_CheckRawAmountOfCardsOwned", "bbbb", DO_NOT_QUIT,""), # more complex behavior too (jumping + ??)
+ ("ScriptCommand_JumpBasedOnFightingClubPupilStatus", "w", DO_NOT_QUIT,""), # only jumps? still needs args to do that though
+ ("Func_cfc6", "b", DO_NOT_QUIT,""),
+ ("Func_cfd4", "", DO_NOT_QUIT,""),
+ ("Func_d00b", "", DO_NOT_QUIT,""), # includes something with random and extra data
+ ("Func_d025", "w", DO_NOT_QUIT,""), # possibly only jumps, still needs args
+ ("Func_d032", "w", DO_NOT_QUIT,""), # see above
+ ("Func_d03f", "", DO_NOT_QUIT,""),
+ ("ScriptCommand_Jump", "j", QUIT_JUMP,""), # jumps to d
+ ("ScriptCommand_TryGiveMedalPCPacks", "", DO_NOT_QUIT,""),
+ ("ScriptCommand_SetPlayerDirection", "d", DO_NOT_QUIT,""),
+ ("ScriptCommand_MovePlayer", "di", DO_NOT_QUIT,"move_player"),
+ ("ScriptCommand_ShowCardReceivedScreen", "b", DO_NOT_QUIT,""),
+ ("ScriptCommand_SetDialogName", "b", DO_NOT_QUIT,""),
+ ("ScriptCommand_SetNextNPCandScript", "bj", DO_NOT_QUIT,""),
+ ("Func_d095", "bbb", DO_NOT_QUIT,""),
+ ("Func_d0be", "bb", DO_NOT_QUIT,""),
+ ("ScriptCommand_DoFrames", "i", DO_NOT_QUIT,""),
+ ("Func_d0d9", "bbw", DO_NOT_QUIT,""), # jumps but still needs args
+ ("ScriptCommand_JumpIfPlayerCoordMatches", "iij", DO_NOT_QUIT,""), # jumps but still needs args
+ ("ScriptCommand_MoveActiveNPC", "m", DO_NOT_QUIT,""),
+ ("ScriptCommand_GiveOneOfEachTrainerBooster", "", DO_NOT_QUIT,""),
+ ("Func_d103", "q", DO_NOT_QUIT,""),
+ ("Func_d125", "b", DO_NOT_QUIT,""),
+ ("Func_d135", "b", DO_NOT_QUIT,""),
+ ("Func_d16b", "b", DO_NOT_QUIT,""),
+ ("Func_cd4f", "bbb", DO_NOT_QUIT,""),
+ ("Func_cd94", "q", DO_NOT_QUIT,""),
+ ("ScriptCommand_MoveWramNPC", "m", DO_NOT_QUIT,""),
+ ("Func_cdd8", "", DO_NOT_QUIT,""),
+ ("Func_cdf5", "bb", DO_NOT_QUIT,""),
+ ("Func_d195", "", DO_NOT_QUIT,""),
+ ("Func_d1ad", "", DO_NOT_QUIT,""),
+ ("Func_d1b3", "", DO_NOT_QUIT,""),
+ ("ScriptCommand_QuitScriptFully", "", QUIT_SPECIAL,""),
+ ("Func_d244", "q", DO_NOT_QUIT,""),
+ ("Func_d24c", "q", DO_NOT_QUIT,""),
+ ("ScriptCommand_OpenDeckMachine", "b", DO_NOT_QUIT,""),
+ ("Func_d271", "q", DO_NOT_QUIT,""),
+ ("ScriptCommand_EnterMap", "bbood", DO_NOT_QUIT,""),
+ ("ScriptCommand_MoveArbitraryNPC", "bm", DO_NOT_QUIT,""),
+ ("Func_d209", "", DO_NOT_QUIT,""),
+ ("Func_d38f", "b", DO_NOT_QUIT,""),
+ ("Func_d396", "b", DO_NOT_QUIT,""),
+ ("Func_cd76", "", DO_NOT_QUIT,""),
+ ("Func_d39d", "b", DO_NOT_QUIT,""),
+ ("Func_d3b9", "", DO_NOT_QUIT,""),
+ ("ScriptCommand_TryGivePCPack", "b", DO_NOT_QUIT,""),
+ ("ScriptCommand_nop", "", DO_NOT_QUIT,""),
+ ("Func_d3d4", "q", DO_NOT_QUIT,""),
+ ("Func_d3e0", "", DO_NOT_QUIT,""),
+ ("Func_d3fe", "q", DO_NOT_QUIT,""),
+ ("Func_d408", "b", DO_NOT_QUIT,""),
+ ("Func_d40f", "q", DO_NOT_QUIT,""),
+ ("ScriptCommand_PlaySFX", "b", DO_NOT_QUIT,""),
+ ("ScriptCommand_PauseSong", "q", DO_NOT_QUIT,""),
+ ("ScriptCommand_ResumeSong", "q", DO_NOT_QUIT,""),
+ ("Func_d41d", "", DO_NOT_QUIT,""),
+ ("ScriptCommand_WaitForSongToFinish", "q", DO_NOT_QUIT,""),
+ ("Func_d435", "b", DO_NOT_QUIT,""),
+ ("ScriptCommand_AskQuestionJumpDefaultYes", "tj", DO_NOT_QUIT,""),
+ ("Func_d2f6", "q", DO_NOT_QUIT,""),
+ ("Func_d317", "", DO_NOT_QUIT,""),
+ ("Func_d43d", "", DO_NOT_QUIT,""),
+ ("ScriptCommand_EndScriptLoop2", "q", QUIT_CONTINUE_CODE,""),
+ ("ScriptCommand_EndScriptLoop3", "q", QUIT_CONTINUE_CODE,""),
+ ("ScriptCommand_EndScriptLoop4", "q", QUIT_CONTINUE_CODE,""),
+ ("ScriptCommand_EndScriptLoop5", "q", QUIT_CONTINUE_CODE,""),
+ ("ScriptCommand_EndScriptLoop6", "q", QUIT_CONTINUE_CODE,""),
+ ("ScriptCommand_SetFlagValue", "fb", DO_NOT_QUIT,""),
+ ("ScriptCommand_JumpIfFlagZero1", "fj", DO_NOT_QUIT,""),
+ ("ScriptCommand_JumpIfFlagNonzero1", "q", DO_NOT_QUIT,""),
+ ("ScriptCommand_JumpIfFlagEqual", "fbj", DO_NOT_QUIT,""), # also capable of jumping
+ ("ScriptCommand_JumpIfFlagNotEqual", "fbj", DO_NOT_QUIT,""), # jumps
+ ("ScriptCommand_JumpIfFlagNotLessThan", "fbj", DO_NOT_QUIT,""),
+ ("ScriptCommand_JumpIfFlagLessThan", "fbj", DO_NOT_QUIT,""),
+ ("ScriptCommand_MaxOutFlagValue", "f", DO_NOT_QUIT,""),
+ ("ScriptCommand_ZeroOutFlagValue", "f", DO_NOT_QUIT,""),
+ ("ScriptCommand_JumpIfFlagNonzero2", "fj", DO_NOT_QUIT,""),
+ ("ScriptCommand_JumpIfFlagZero2", "fj", DO_NOT_QUIT,""),
+ ("ScriptCommand_IncrementFlagValue", "f", DO_NOT_QUIT,""),
+ ("ScriptCommand_EndScriptLoop7", "q", QUIT_CONTINUE_CODE,""),
+ ("ScriptCommand_EndScriptLoop8", "q", QUIT_CONTINUE_CODE,""),
+ ("ScriptCommand_EndScriptLoop9", "q", QUIT_CONTINUE_CODE,""),
+ ("ScriptCommand_EndScriptLoop10", "q", QUIT_CONTINUE_CODE,"")
]
main()