summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryenatch <yenatch@gmail.com>2013-12-06 19:42:58 -0500
committeryenatch <yenatch@gmail.com>2013-12-06 19:43:41 -0500
commit460171a2c52d6fcd591559ab1c5fff09e9bc49cb (patch)
treecd459628f69ab3bbd4c45ad0af3b8514fc69fc97
parent1be104b8e8beb964783fdd7de82569c291f9cdfc (diff)
wram: cleaner line parsing
fixes 0fd121a8
-rw-r--r--pokemontools/wram.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/pokemontools/wram.py b/pokemontools/wram.py
index e467a01..7bc017d 100644
--- a/pokemontools/wram.py
+++ b/pokemontools/wram.py
@@ -20,11 +20,19 @@ def bracket_value(string, i=0):
def read_bss_sections(bss):
sections = []
section = {
+ 'name': None,
+ 'type': None,
+ 'bank': None,
+ 'start': None,
+ 'labels': [],
}
address = None
if type(bss) is not list: bss = bss.split('\n')
for line in bss:
- line = line.lstrip()
+
+ comment_index = line.find(';')
+ line, comment = line[:comment_index].lstrip(), line[comment_index:]
+
if 'SECTION' == line[:7]:
if section: # previous
sections += [section]
@@ -71,7 +79,7 @@ def read_bss_sections(bss):
}]
elif line[:3] == 'ds ':
- length = eval(line[3:line.find(';')].replace('$','0x'))
+ length = eval(line[3:].replace('$','0x'))
address += length
# adjacent labels use the same space
for label in section['labels'][::-1]: