clean up python script imports
This commit is contained in:
@@ -6,15 +6,15 @@ import subprocess
|
|||||||
from new import classobj
|
from new import classobj
|
||||||
import random
|
import random
|
||||||
|
|
||||||
|
# for capwords
|
||||||
|
import string
|
||||||
|
|
||||||
# for testing all this crap
|
# for testing all this crap
|
||||||
try:
|
try:
|
||||||
import unittest2 as unittest
|
import unittest2 as unittest
|
||||||
except ImportError:
|
except ImportError:
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
# for capwords
|
|
||||||
import string
|
|
||||||
|
|
||||||
# Check for things we need in unittest.
|
# Check for things we need in unittest.
|
||||||
if not hasattr(unittest.TestCase, 'setUpClass'):
|
if not hasattr(unittest.TestCase, 'setUpClass'):
|
||||||
sys.stderr.write("The unittest2 module or Python 2.7 is required to run this script.")
|
sys.stderr.write("The unittest2 module or Python 2.7 is required to run this script.")
|
||||||
@@ -27,6 +27,14 @@ if not hasattr(json, "dumps"):
|
|||||||
if not hasattr(json, "read"):
|
if not hasattr(json, "read"):
|
||||||
json.read = json.loads
|
json.read = json.loads
|
||||||
|
|
||||||
|
from labels import (
|
||||||
|
remove_quoted_text,
|
||||||
|
line_has_comment_address,
|
||||||
|
line_has_label,
|
||||||
|
get_label_from_line,
|
||||||
|
get_address_from_line_comment
|
||||||
|
)
|
||||||
|
|
||||||
spacing = "\t"
|
spacing = "\t"
|
||||||
|
|
||||||
lousy_dragon_shrine_hack = [0x18d079, 0x18d0a9, 0x18d061, 0x18d091]
|
lousy_dragon_shrine_hack = [0x18d079, 0x18d0a9, 0x18d061, 0x18d091]
|
||||||
@@ -71,6 +79,13 @@ trainer_group_pointer_table_address_gs = 0x3993E
|
|||||||
|
|
||||||
from interval_map import IntervalMap
|
from interval_map import IntervalMap
|
||||||
|
|
||||||
|
from pksv import (
|
||||||
|
pksv_gs,
|
||||||
|
pksv_crystal,
|
||||||
|
pksv_crystal_unknowns,
|
||||||
|
pksv_crystal_more_enders
|
||||||
|
)
|
||||||
|
|
||||||
# ---- script_parse_table explanation ----
|
# ---- script_parse_table explanation ----
|
||||||
# This is an IntervalMap that keeps track of previously parsed scripts, texts
|
# This is an IntervalMap that keeps track of previously parsed scripts, texts
|
||||||
# and other objects. Anything that has a location in the ROM should be mapped
|
# and other objects. Anything that has a location in the ROM should be mapped
|
||||||
@@ -226,6 +241,28 @@ def clean_up_long_info(long_info):
|
|||||||
long_info = "\n".join(new_lines)
|
long_info = "\n".join(new_lines)
|
||||||
return long_info
|
return long_info
|
||||||
|
|
||||||
|
from pokemon_constants import pokemon_constants
|
||||||
|
|
||||||
|
def get_pokemon_constant_by_id(id):
|
||||||
|
if id == 0: return None
|
||||||
|
return pokemon_constants[id]
|
||||||
|
|
||||||
|
from item_constants import item_constants
|
||||||
|
|
||||||
|
def find_item_label_by_id(id):
|
||||||
|
if id in item_constants.keys():
|
||||||
|
return item_constants[id]
|
||||||
|
else: return None
|
||||||
|
|
||||||
|
def generate_item_constants():
|
||||||
|
"""make a list of items to put in constants.asm"""
|
||||||
|
output = ""
|
||||||
|
for (id, item) in item_constants.items():
|
||||||
|
val = ("$%.2x"%id).upper()
|
||||||
|
while len(item)<13: item+= " "
|
||||||
|
output += item + " EQU " + val + "\n"
|
||||||
|
return output
|
||||||
|
|
||||||
def command_debug_information(command_byte=None, map_group=None, map_id=None, address=0, info=None, long_info=None, pksv_name=None):
|
def command_debug_information(command_byte=None, map_group=None, map_id=None, address=0, info=None, long_info=None, pksv_name=None):
|
||||||
"used to help debug in parse_script_engine_script_at"
|
"used to help debug in parse_script_engine_script_at"
|
||||||
info1 = "parsing command byte " + hex(command_byte) + " for map " + \
|
info1 = "parsing command byte " + hex(command_byte) + " for map " + \
|
||||||
@@ -1145,32 +1182,10 @@ def transform_wildmons(asm):
|
|||||||
returnlines.append(line)
|
returnlines.append(line)
|
||||||
return "\n".join(returnlines)
|
return "\n".join(returnlines)
|
||||||
|
|
||||||
from pokemon_constants import pokemon_constants
|
|
||||||
|
|
||||||
def get_pokemon_constant_by_id(id):
|
|
||||||
if id == 0: return None
|
|
||||||
return pokemon_constants[id]
|
|
||||||
|
|
||||||
def parse_script_asm_at(*args, **kwargs):
|
def parse_script_asm_at(*args, **kwargs):
|
||||||
# XXX TODO
|
# XXX TODO
|
||||||
return None
|
return None
|
||||||
|
|
||||||
from item_constants import item_constants
|
|
||||||
|
|
||||||
def find_item_label_by_id(id):
|
|
||||||
if id in item_constants.keys():
|
|
||||||
return item_constants[id]
|
|
||||||
else: return None
|
|
||||||
|
|
||||||
def generate_item_constants():
|
|
||||||
"""make a list of items to put in constants.asm"""
|
|
||||||
output = ""
|
|
||||||
for (id, item) in item_constants.items():
|
|
||||||
val = ("$%.2x"%id).upper()
|
|
||||||
while len(item)<13: item+= " "
|
|
||||||
output += item + " EQU " + val + "\n"
|
|
||||||
return output
|
|
||||||
|
|
||||||
def find_all_text_pointers_in_script_engine_script(script, bank=None, debug=False):
|
def find_all_text_pointers_in_script_engine_script(script, bank=None, debug=False):
|
||||||
"""returns a list of text pointers
|
"""returns a list of text pointers
|
||||||
based on each script-engine script command"""
|
based on each script-engine script command"""
|
||||||
@@ -1218,9 +1233,6 @@ def translate_command_byte(crystal=None, gold=None):
|
|||||||
if gold > 0xA3: raise Exception, "dunno yet if crystal has new insertions after gold:0xA3 (crystal:0xA5)"
|
if gold > 0xA3: raise Exception, "dunno yet if crystal has new insertions after gold:0xA3 (crystal:0xA5)"
|
||||||
else: raise Exception, "translate_command_byte needs either a crystal or gold command"
|
else: raise Exception, "translate_command_byte needs either a crystal or gold command"
|
||||||
|
|
||||||
from pksv import pksv_gs, pksv_crystal, pksv_crystal_unknowns,\
|
|
||||||
pksv_crystal_more_enders
|
|
||||||
|
|
||||||
class SingleByteParam():
|
class SingleByteParam():
|
||||||
"""or SingleByte(CommandParam)"""
|
"""or SingleByte(CommandParam)"""
|
||||||
size = 1
|
size = 1
|
||||||
@@ -7669,10 +7681,6 @@ class Label:
|
|||||||
name = object.make_label()
|
name = object.make_label()
|
||||||
return name
|
return name
|
||||||
|
|
||||||
from labels import remove_quoted_text, line_has_comment_address, \
|
|
||||||
line_has_label, get_label_from_line, \
|
|
||||||
get_address_from_line_comment
|
|
||||||
|
|
||||||
def find_labels_without_addresses():
|
def find_labels_without_addresses():
|
||||||
"""scans the asm source and finds labels that are unmarked"""
|
"""scans the asm source and finds labels that are unmarked"""
|
||||||
without_addresses = []
|
without_addresses = []
|
||||||
|
Reference in New Issue
Block a user