You've already forked pokecrystal-board
mirror of
https://gitlab.com/xCrystal/pokecrystal-board.git
synced 2025-04-09 05:44:44 -07:00
remove a duplication of load_rom and load_asm
This commit is contained in:
@ -7,6 +7,8 @@ from crystal import (
|
|||||||
get_label_from_line,
|
get_label_from_line,
|
||||||
get_address_from_line_comment,
|
get_address_from_line_comment,
|
||||||
AsmSection,
|
AsmSection,
|
||||||
|
direct_load_rom,
|
||||||
|
direct_load_asm,
|
||||||
)
|
)
|
||||||
|
|
||||||
from romstr import (
|
from romstr import (
|
||||||
@ -17,22 +19,12 @@ from romstr import (
|
|||||||
def load_rom(path):
|
def load_rom(path):
|
||||||
""" Loads a ROM file into an abbreviated RomStr object.
|
""" Loads a ROM file into an abbreviated RomStr object.
|
||||||
"""
|
"""
|
||||||
|
return direct_load_rom(filename=path)
|
||||||
fh = open(path, "r")
|
|
||||||
x = RomStr(fh.read())
|
|
||||||
fh.close()
|
|
||||||
|
|
||||||
return x
|
|
||||||
|
|
||||||
def load_asm(path):
|
def load_asm(path):
|
||||||
""" Loads source ASM into an abbreviated AsmList object.
|
""" Loads source ASM into an abbreviated AsmList object.
|
||||||
"""
|
"""
|
||||||
|
return direct_load_asm(filename=path)
|
||||||
fh = open(path, "r")
|
|
||||||
x = AsmList(fh.read().split("\n"))
|
|
||||||
fh.close()
|
|
||||||
|
|
||||||
return x
|
|
||||||
|
|
||||||
def findall_iter(sub, string):
|
def findall_iter(sub, string):
|
||||||
# url: http://stackoverflow.com/a/3874760/687783
|
# url: http://stackoverflow.com/a/3874760/687783
|
||||||
|
@ -145,14 +145,18 @@ def load_rom(filename="../baserom.gbc"):
|
|||||||
elif os.lstat(filename).st_size != len(rom):
|
elif os.lstat(filename).st_size != len(rom):
|
||||||
return direct_load_rom(filename)
|
return direct_load_rom(filename)
|
||||||
|
|
||||||
|
def direct_load_asm(filename="../main.asm"):
|
||||||
def load_asm(filename="../main.asm"):
|
"""returns asm source code (AsmList) from a file"""
|
||||||
"""loads the asm source code into memory"""
|
|
||||||
global asm
|
|
||||||
asm = open(filename, "r").read().split("\n")
|
asm = open(filename, "r").read().split("\n")
|
||||||
asm = AsmList(asm)
|
asm = AsmList(asm)
|
||||||
return asm
|
return asm
|
||||||
|
|
||||||
|
def load_asm(filename="../main.asm"):
|
||||||
|
"""returns asm source code (AsmList) from a file (uses a global)"""
|
||||||
|
global asm
|
||||||
|
asm = direct_load_asm(filename=filename)
|
||||||
|
return asm
|
||||||
|
|
||||||
def grouper(some_list, count=2):
|
def grouper(some_list, count=2):
|
||||||
"""splits a list into sublists
|
"""splits a list into sublists
|
||||||
given: [1, 2, 3, 4]
|
given: [1, 2, 3, 4]
|
||||||
|
Reference in New Issue
Block a user