diff options
author | Bryan Bishop <kanzure@gmail.com> | 2012-05-29 13:08:43 -0500 |
---|---|---|
committer | Bryan Bishop <kanzure@gmail.com> | 2012-05-29 13:08:43 -0500 |
commit | 19e3c8ae4e2544ab7dc0794c9658ce592f240781 (patch) | |
tree | 58f9f47384a5fddaaf89e6b3f4a38618902266cc | |
parent | f2c2dbc90c2d890e56f52a8ec0aa4ec7cf7b131e (diff) |
move RomStr into a shared file
original-commit-id: ee7d39bf046ca4b8c40eb293d50657cda151dc58
-rw-r--r-- | crystal.py | 26 | ||||
-rw-r--r-- | romstr.py | 25 |
2 files changed, 26 insertions, 25 deletions
@@ -230,31 +230,7 @@ def map_name_cleaner(input): replace("hooh", "HoOh").\ replace(" ", "") -class RomStr(str): - """simple wrapper to prevent a giant rom from being shown on screen""" - - def length(self): - """len(self)""" - return len(self) - - def __repr__(self): - return "RomStr(too long)" - - def interval(self, offset, length, strings=True, debug=True): - """returns hex values for the rom starting at offset until offset+length""" - returnable = [] - for byte in self[offset:offset+length]: - if strings: - returnable.append(hex(ord(byte))) - else: - returnable.append(ord(byte)) - return returnable - - def until(self, offset, byte, strings=True, debug=False): - """returns hex values from rom starting at offset until the given byte""" - return self.interval(offset, self.find(chr(byte), offset) - offset, strings=strings) - - +from romstr import RomStr rom = RomStr(None) def direct_load_rom(filename="../baserom.gbc"): diff --git a/romstr.py b/romstr.py new file mode 100644 index 0000000..9d50fce --- /dev/null +++ b/romstr.py @@ -0,0 +1,25 @@ +class RomStr(str): + """ Simple wrapper to prevent a giant rom from being shown on screen + """ + + def length(self): + """len(self)""" + return len(self) + + def __repr__(self): + return "RomStr(too long)" + + def interval(self, offset, length, strings=True, debug=True): + """returns hex values for the rom starting at offset until offset+length""" + returnable = [] + for byte in self[offset:offset+length]: + if strings: + returnable.append(hex(ord(byte))) + else: + returnable.append(ord(byte)) + return returnable + + def until(self, offset, byte, strings=True, debug=False): + """returns hex values from rom starting at offset until the given byte""" + return self.interval(offset, self.find(chr(byte), offset) - offset, strings=strings) + |