ref: 0a54ce9e75201d718b971789a6502f8205d2e986
parent: 80781e56f045dca95e03ccf8d8851f44b0bae0df
author: Bryan Bishop <[email protected]>
date: Tue Jan 15 11:20:10 EST 2013
clean up python script imports
--- a/extras/crystal.py
+++ b/extras/crystal.py
@@ -6,6 +6,9 @@
from new import classobj
import random
+# for capwords
+import string
+
# for testing all this crap
try:
import unittest2 as unittest
@@ -12,9 +15,6 @@
except ImportError:
import unittest
-# for capwords
-import string
-
# Check for things we need in unittest.
if not hasattr(unittest.TestCase, 'setUpClass'):
sys.stderr.write("The unittest2 module or Python 2.7 is required to run this script.")
@@ -27,6 +27,14 @@
if not hasattr(json, "read"):
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"
lousy_dragon_shrine_hack = [0x18d079, 0x18d0a9, 0x18d061, 0x18d091]
@@ -71,6 +79,13 @@
from interval_map import IntervalMap
+from pksv import (
+ pksv_gs,
+ pksv_crystal,
+ pksv_crystal_unknowns,
+ pksv_crystal_more_enders
+)
+
# ---- script_parse_table explanation ----
# 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
@@ -226,6 +241,28 @@
long_info = "\n".join(new_lines)
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):
"used to help debug in parse_script_engine_script_at"
info1 = "parsing command byte " + hex(command_byte) + " for map " + \
@@ -1145,32 +1182,10 @@
returnlines.append(line)
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):
# XXX TODO
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):
"""returns a list of text pointers
based on each script-engine script command"""
@@ -1218,9 +1233,6 @@
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"
-from pksv import pksv_gs, pksv_crystal, pksv_crystal_unknowns,\
- pksv_crystal_more_enders
-
class SingleByteParam():
"""or SingleByte(CommandParam)"""
size = 1
@@ -7668,10 +7680,6 @@
object = self.object
name = object.make_label()
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():
"""scans the asm source and finds labels that are unmarked"""