You've already forked pokecrystal-board
mirror of
https://gitlab.com/xCrystal/pokecrystal-board.git
synced 2025-04-09 05:44:44 -07:00
make parse_text_at use script_parse_table and make 2writetext parse target texts
This commit is contained in:
@@ -704,7 +704,7 @@ class TextScript():
|
|||||||
addresses.update(texts2)
|
addresses.update(texts2)
|
||||||
return addresses
|
return addresses
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def parse_text_at(address, map_group=None, map_id=None, debug=True, show=True):
|
def parse_text_at(address, map_group=None, map_id=None, debug=True, show=True, force=False):
|
||||||
"""parses a text-engine script ("in-text scripts")
|
"""parses a text-engine script ("in-text scripts")
|
||||||
http://hax.iimarck.us/files/scriptingcodes_eng.htm#InText
|
http://hax.iimarck.us/files/scriptingcodes_eng.htm#InText
|
||||||
|
|
||||||
@@ -712,18 +712,23 @@ class TextScript():
|
|||||||
|
|
||||||
see parse_text_at2, parse_text_at, and process_00_subcommands
|
see parse_text_at2, parse_text_at, and process_00_subcommands
|
||||||
"""
|
"""
|
||||||
global rom, text_count, max_texts, texts
|
global rom, text_count, max_texts, texts, script_parse_table
|
||||||
if rom == None:
|
if rom == None:
|
||||||
direct_load_rom()
|
direct_load_rom()
|
||||||
if address == None:
|
if address == None:
|
||||||
return "not a script"
|
return "not a script"
|
||||||
commands = {}
|
commands = {}
|
||||||
|
|
||||||
|
if is_script_already_parsed_at(address) and not force:
|
||||||
|
print "text is already parsed at this location: " + hex(address)
|
||||||
|
return script_parse_table[address]
|
||||||
|
|
||||||
total_text_commands = 0
|
total_text_commands = 0
|
||||||
command_counter = 0
|
command_counter = 0
|
||||||
original_address = address
|
original_address = address
|
||||||
offset = address
|
offset = address
|
||||||
end = False
|
end = False
|
||||||
|
script_parse_table[original_address:original_address+1] = "incomplete text"
|
||||||
while not end:
|
while not end:
|
||||||
address = offset
|
address = offset
|
||||||
command = {}
|
command = {}
|
||||||
@@ -913,6 +918,7 @@ class TextScript():
|
|||||||
#if text_count >= max_texts:
|
#if text_count >= max_texts:
|
||||||
# sys.exit()
|
# sys.exit()
|
||||||
|
|
||||||
|
script_parse_table[original_address:offset-1] = commands
|
||||||
return commands
|
return commands
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def to_asm_at(address, label="SomeLabel"):
|
def to_asm_at(address, label="SomeLabel"):
|
||||||
@@ -1110,12 +1116,14 @@ class TextScript():
|
|||||||
print output
|
print output
|
||||||
return (output, byte_count)
|
return (output, byte_count)
|
||||||
|
|
||||||
def parse_text_engine_script_at(address, map_group=None, map_id=None, debug=True, show=True):
|
def parse_text_engine_script_at(address, map_group=None, map_id=None, debug=True, show=True, force=False):
|
||||||
"""parses a text-engine script ("in-text scripts")
|
"""parses a text-engine script ("in-text scripts")
|
||||||
http://hax.iimarck.us/files/scriptingcodes_eng.htm#InText
|
http://hax.iimarck.us/files/scriptingcodes_eng.htm#InText
|
||||||
see parse_text_at2, parse_text_at, and process_00_subcommands
|
see parse_text_at2, parse_text_at, and process_00_subcommands
|
||||||
"""
|
"""
|
||||||
return TextScript.parse_text_at(address, map_group=map_group, map_id=map_id, debug=debug, show=show)
|
if is_script_already_parsed_at(address) and not force:
|
||||||
|
return script_parse_table[address]
|
||||||
|
return TextScript.parse_text_at(address, map_group=map_group, map_id=map_id, debug=debug, show=show, force=force)
|
||||||
def find_text_addresses():
|
def find_text_addresses():
|
||||||
"""returns a list of text pointers
|
"""returns a list of text pointers
|
||||||
useful for testing parse_text_engine_script_at"""
|
useful for testing parse_text_engine_script_at"""
|
||||||
@@ -2296,12 +2304,15 @@ class MenuDataPointerParam(PointerLabelParam):
|
|||||||
#raise NotImplementedError, bryan_message
|
#raise NotImplementedError, bryan_message
|
||||||
pass
|
pass
|
||||||
class RawTextPointerLabelParam(PointerLabelParam):
|
class RawTextPointerLabelParam(PointerLabelParam):
|
||||||
#is this to raw text? or to a text script?
|
#not sure if these are always to a text script or raw text?
|
||||||
#raise NotImplementedError, bryan_message
|
|
||||||
pass
|
pass
|
||||||
class TextPointerLabelParam(PointerLabelParam):
|
class TextPointerLabelParam(PointerLabelParam):
|
||||||
#definitely points to a text script
|
"""this is a pointer to a text script"""
|
||||||
pass
|
bank = False
|
||||||
|
def parse(self):
|
||||||
|
PointerLabelParam.parse(self)
|
||||||
|
address = calculate_pointer_from_bytes_at(self.address, bank=self.bank)
|
||||||
|
self.text = parse_text_engine_script_at(address, map_group=self.map_group, map_id=self.map_id, force=self.force, debug=self.debug)
|
||||||
class MovementPointerLabelParam(PointerLabelParam):
|
class MovementPointerLabelParam(PointerLabelParam):
|
||||||
pass
|
pass
|
||||||
class MapDataPointerParam(PointerLabelParam):
|
class MapDataPointerParam(PointerLabelParam):
|
||||||
@@ -2387,12 +2398,11 @@ pksv_crystal_more = {
|
|||||||
0x49: ["loadmovesprites"],
|
0x49: ["loadmovesprites"],
|
||||||
0x4A: ["loadbytec1ce", ["byte", SingleByteParam]], #not pksv
|
0x4A: ["loadbytec1ce", ["byte", SingleByteParam]], #not pksv
|
||||||
0x4B: ["3writetext", ["text_pointer", PointerLabelBeforeBank]],
|
0x4B: ["3writetext", ["text_pointer", PointerLabelBeforeBank]],
|
||||||
0x4C: ["2writetext", ["text_pointer", RawTextPointerLabelParam]], #XXX - is this to a text script, or raw text?
|
0x4C: ["2writetext", ["text_pointer", TextPointerLabelParam]],
|
||||||
0x4D: ["repeattext", ["byte", SingleByteParam], ["byte", SingleByteParam]], #not pksv
|
0x4D: ["repeattext", ["byte", SingleByteParam], ["byte", SingleByteParam]], #not pksv
|
||||||
0x4E: ["yesorno"],
|
0x4E: ["yesorno"],
|
||||||
0x4F: ["loadmenudata", ["data", MenuDataPointerParam]],
|
0x4F: ["loadmenudata", ["data", MenuDataPointerParam]],
|
||||||
0x50: ["writebackup"],
|
0x50: ["writebackup"],
|
||||||
#XXX test123
|
|
||||||
0x51: ["jumptextfaceplayer", ["text_pointer", RawTextPointerLabelParam]],
|
0x51: ["jumptextfaceplayer", ["text_pointer", RawTextPointerLabelParam]],
|
||||||
0x53: ["jumptext", ["text_pointer", TextPointerLabelParam]],
|
0x53: ["jumptext", ["text_pointer", TextPointerLabelParam]],
|
||||||
0x54: ["closetext"],
|
0x54: ["closetext"],
|
||||||
@@ -2634,7 +2644,7 @@ def parse_script_with_command_classes(start_address, force=False, map_group=None
|
|||||||
global command_classes, rom, script_parse_table
|
global command_classes, rom, script_parse_table
|
||||||
current_address = start_address
|
current_address = start_address
|
||||||
if start_address in stop_points and force == False:
|
if start_address in stop_points and force == False:
|
||||||
print "got " + hex(start_address) + " at map_group="+str(map_group)+" map_id="+str(map_id)
|
print "script parsing is stopping at stop_point=" + hex(start_address) + " at map_group="+str(map_group)+" map_id="+str(map_id)
|
||||||
return None
|
return None
|
||||||
if start_address < 0x4000 and start_address not in [0x26ef, 0x114, 0x1108]:
|
if start_address < 0x4000 and start_address not in [0x26ef, 0x114, 0x1108]:
|
||||||
print "address is less than 0x4000.. address is: " + hex(start_address)
|
print "address is less than 0x4000.. address is: " + hex(start_address)
|
||||||
|
Reference in New Issue
Block a user