mirror of
https://gitlab.com/xCrystal/pokecrystal-board.git
synced 2025-01-23 09:16:20 -08:00
simplify load_rom in gbz80disasm
This commit is contained in:
parent
82b8b5121a
commit
57200b6cf7
@ -14,11 +14,8 @@ if not hasattr(json, "read"):
|
|||||||
from romstr import RomStr
|
from romstr import RomStr
|
||||||
|
|
||||||
def load_rom(filename="../baserom.gbc"):
|
def load_rom(filename="../baserom.gbc"):
|
||||||
"""loads bytes into memory"""
|
|
||||||
global rom
|
global rom
|
||||||
file_handler = open(filename, "rb")
|
rom = RomStr.load(filename=filename)
|
||||||
rom = RomStr(file_handler.read())
|
|
||||||
file_handler.close()
|
|
||||||
return rom
|
return rom
|
||||||
|
|
||||||
spacing = "\t"
|
spacing = "\t"
|
||||||
|
@ -46,15 +46,17 @@ class RomStr(str):
|
|||||||
return "RomStr(too long)"
|
return "RomStr(too long)"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def load(cls, crystal=True, red=False):
|
def load(cls, filename=None, crystal=True, red=False):
|
||||||
""" Loads a ROM into a RomStr.
|
""" Loads a ROM into a RomStr.
|
||||||
"""
|
"""
|
||||||
if crystal and not red:
|
if crystal and not red and not filename:
|
||||||
file_handler = open("../baserom.gbc", "r")
|
file_handler = open("../baserom.gbc", "r")
|
||||||
elif red and not crystal:
|
elif red and not crystal and not filename:
|
||||||
file_handler = open("../pokered-baserom.gbc", "r")
|
file_handler = open("../pokered-baserom.gbc", "r")
|
||||||
|
elif filename not in ["", None]:
|
||||||
|
file_handler = open(filename, "rb")
|
||||||
else:
|
else:
|
||||||
raise Exception, "not sure which rom to load?"
|
raise Exception("not sure which rom to load?")
|
||||||
bytes = file_handler.read()
|
bytes = file_handler.read()
|
||||||
file_handler.close()
|
file_handler.close()
|
||||||
return RomStr(bytes)
|
return RomStr(bytes)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user