diff options
-rw-r--r-- | pokemontools/crystal.py | 12 | ||||
-rw-r--r-- | tests/tests.py | 9 |
2 files changed, 11 insertions, 10 deletions
diff --git a/pokemontools/crystal.py b/pokemontools/crystal.py index 9ee6ec0..dcd95d9 100644 --- a/pokemontools/crystal.py +++ b/pokemontools/crystal.py @@ -6663,9 +6663,11 @@ def get_dependencies_for(some_object, recompute=False, global_dependencies=set() print "asm is: \n\n" + to_asm(some_object) raise e -def isolate_incbins(): +def isolate_incbins(asm=None): "find each incbin line" - global incbin_lines, asm + global incbin_lines + if asm == None: + asm = globals()["asm"] incbin_lines = [] for line in asm: if line == "": continue @@ -6687,7 +6689,7 @@ def process_incbins(): load_asm() # get a list of incbins if that hasn't happened yet if incbin_lines == [] or incbin_lines == None: - isolate_incbins() + isolate_incbins(asm=asm) # reset the global that this function creates processed_incbins = {} # for each incbin.. @@ -6728,7 +6730,7 @@ def reset_incbins(): incbin_lines = [] processed_incbins = {} load_asm() - isolate_incbins() + isolate_incbins(asm=asm) process_incbins() def find_incbin_to_replace_for(address, debug=False, rom_file="../baserom.gbc"): @@ -7340,7 +7342,7 @@ def analyze_intervals(): if asm == None: load_asm() if processed_incbins == {}: - isolate_incbins() + isolate_incbins(asm=asm) process_incbins() results = [] ordered_keys = sorted(processed_incbins, key=lambda entry: processed_incbins[entry]["interval"]) diff --git a/tests/tests.py b/tests/tests.py index 8430eb6..79af902 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -445,12 +445,11 @@ class TestAsmList(unittest.TestCase): os.system("rm " + filename) def test_isolate_incbins(self): - global asm asm = ["123", "456", "789", "abc", "def", "ghi", 'INCBIN "baserom.gbc",$12DA,$12F8 - $12DA', "jkl", 'INCBIN "baserom.gbc",$137A,$13D0 - $137A'] - lines = isolate_incbins() + lines = isolate_incbins(asm=asm) self.assertIn(asm[6], lines) self.assertIn(asm[8], lines) for line in lines: @@ -489,7 +488,7 @@ class TestAsmList(unittest.TestCase): asm = ['first line', 'second line', 'third line', 'INCBIN "baserom.gbc",$90,$200 - $90', 'fifth line', 'last line'] - isolate_incbins() + isolate_incbins(asm=asm) process_incbins() line_num = find_incbin_to_replace_for(0x100) # must be the 4th line (the INBIN line) @@ -504,7 +503,7 @@ class TestAsmList(unittest.TestCase): asm = ['first line', 'second line', 'third line', 'INCBIN "baserom.gbc",$90,$200 - $90', 'fifth line', 'last line'] - isolate_incbins() + isolate_incbins(asm=asm) process_incbins() content = split_incbin_line_into_three(3, 0x100, 10) # must end up with three INCBINs in output @@ -517,7 +516,7 @@ class TestAsmList(unittest.TestCase): 'INCBIN "baserom.gbc",$90,$200 - $90', 'fifth line', 'last line', 'INCBIN "baserom.gbc",$33F,$4000 - $33F'] - isolate_incbins() + isolate_incbins(asm=asm) process_incbins() largest = analyze_intervals() self.assertEqual(largest[0]["line_number"], 6) |