mirror of
https://github.com/thornAvery/kep-hack.git
synced 2025-11-17 10:32:29 +13:00
Restore auto-loading of default "main" asm file
This feature was removed misunderstanding its actual use: if filename passed to load_asm() is in defaults the correct current main asm file is loaded. This saves us from knowing which actually is the current name of the "main" asm file, because the correct one is chosen automatically (unless, of course, the passed filename is not in the defaults list.
This commit is contained in:
parent
cbb722d09b
commit
58a9aacc0b
|
|
@ -33,13 +33,31 @@ def load_asm(filename=os.path.join(pokered_dir, "main.asm")):
|
||||||
is using main.asm, common.asm or pokered.asm, which is
|
is using main.asm, common.asm or pokered.asm, which is
|
||||||
useful when generating images in romvisualizer.py"""
|
useful when generating images in romvisualizer.py"""
|
||||||
global asm
|
global asm
|
||||||
|
# chronological order is important
|
||||||
defaults = [os.path.join(pokered_dir, f) for f in ["main.asm", "common.asm", "pokered.asm"]]
|
defaults = [os.path.join(pokered_dir, f) for f in ["main.asm", "common.asm", "pokered.asm"]]
|
||||||
if filename in defaults:
|
if filename in defaults:
|
||||||
asm = open(filename, "r").read().split("\n")
|
if not load_asm_if_one_exists_in(defaults):
|
||||||
else:
|
raise Exception("This shouldn't happen")
|
||||||
raise Exception("this shouldn't happen")
|
elif os.path.exists(filename):
|
||||||
|
asm = get_all_lines_from_file(filename)
|
||||||
|
if asm is None:
|
||||||
|
raise Exception("file doesn't exists (did you mean one among: {0}?)".format(", ".join(defaults)))
|
||||||
return asm
|
return asm
|
||||||
|
|
||||||
|
def load_asm_if_one_exists_in(*args):
|
||||||
|
global asm
|
||||||
|
for f in args:
|
||||||
|
if os.path.exists(f):
|
||||||
|
asm = get_all_lines_from_file(f)
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def get_all_lines_from_file(filename):
|
||||||
|
try:
|
||||||
|
return open(filename, "r").read().split("\n")
|
||||||
|
except IOError as e:
|
||||||
|
raise(e)
|
||||||
|
|
||||||
def isolate_incbins():
|
def isolate_incbins():
|
||||||
"find each incbin line"
|
"find each incbin line"
|
||||||
global incbin_lines
|
global incbin_lines
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue