22"""
33Find shared functions between red/crystal.
44"""
5+ from __future__ import print_function
6+ from __future__ import absolute_import
57
6- from crystal import (
8+ from . crystal import (
79 get_label_from_line ,
810 get_address_from_line_comment ,
911 AsmSection ,
1012 direct_load_rom ,
1113 direct_load_asm ,
1214)
1315
14- from romstr import (
16+ from . romstr import (
1517 RomStr ,
1618 AsmList ,
1719)
@@ -53,7 +55,7 @@ def __new__(cls, x=None, *args, **kwargs):
5355 instance = int .__new__ (cls , int (x , base = 16 ), * args , ** kwargs )
5456 else :
5557 msg = "Address.__new__ doesn't know how to parse this string"
56- raise Exception , msg
58+ raise Exception ( msg )
5759 else :
5860 instance = int .__new__ (cls , x , * args , ** kwargs )
5961
@@ -157,7 +159,7 @@ def find_in_crystal(self):
157159 found_blobs .append (self )
158160
159161 if self .debug :
160- print self .label + ": found " + str (len (self .locations )) + " matches."
162+ print ( self .label + ": found " + str (len (self .locations )) + " matches." )
161163
162164 def find_by_first_bytes (self ):
163165 """
@@ -181,7 +183,7 @@ def find_by_first_bytes(self):
181183 found_blobs .append (self )
182184
183185 if self .debug :
184- print self .label + ": found " + str (len (self .locations )) + " matches."
186+ print ( self .label + ": found " + str (len (self .locations )) + " matches." )
185187
186188pokecrystal_rom_path = "../baserom.gbc"
187189pokecrystal_src_path = "../main.asm"
@@ -214,14 +216,14 @@ def scan_red_asm(bank_stop=3, debug=True):
214216
215217 for line in redsrc :
216218 if debug and show_lines :
217- print "processing a line from red: " + line
219+ print ( "processing a line from red: " + line )
218220
219221 if line [0 :7 ] == "SECTION" :
220222 thing = AsmSection (line )
221223 current_bank = thing .bank_id
222224
223225 if debug :
224- print "scan_red_asm: switching to bank " + str (current_bank )
226+ print ( "scan_red_asm: switching to bank " + str (current_bank ) )
225227
226228 elif line [0 :6 ] != "INCBIN" :
227229 if ":" in line and not ";XXX:" in line and not " ; XXX:" in line :
@@ -240,7 +242,7 @@ def scan_red_asm(bank_stop=3, debug=True):
240242 line_number = line_number )
241243
242244 if debug :
243- print "Created a new blob: " + str (blob ) + " from line: " + str (latest_line )
245+ print ( "Created a new blob: " + str (blob ) + " from line: " + str (latest_line ) )
244246
245247 latest_label = current_label
246248 latest_start_address = current_start_address
@@ -250,18 +252,18 @@ def scan_red_asm(bank_stop=3, debug=True):
250252
251253 if current_bank == bank_stop :
252254 if debug :
253- print "scan_red_asm: stopping because current_bank >= " + \
254- str (bank_stop ) + " (bank_stop)"
255+ print ( "scan_red_asm: stopping because current_bank >= " + \
256+ str (bank_stop ) + " (bank_stop)" )
255257
256258 break
257259
258260scan_red_asm (bank_stop = 3 )
259261
260- print "================================"
262+ print ( "================================" )
261263
262264for blob in found_blobs :
263- print blob
265+ print ( blob )
264266
265- print "Found " + str (len (found_blobs )) + " possibly copied functions."
267+ print ( "Found " + str (len (found_blobs )) + " possibly copied functions." )
266268
267- print [hex (x ) for x in found_blobs [10 ].locations ]
269+ print ( [hex (x ) for x in found_blobs [10 ].locations ])
0 commit comments