summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryenatch <yenatch@gmail.com>2014-10-28 21:54:29 -0700
committeryenatch <yenatch@gmail.com>2014-10-28 21:59:07 -0700
commit074f8dfdf4686d973234162ab6ebdc8a91e01550 (patch)
treeb38111313b200e68a1e3d1a3b7e366e03ea6ff92
parentaff76027a0aa8ec4cd3f4a392af8103063630be3 (diff)
audio: Expose header reads via separate functions.
-rw-r--r--pokemontools/audio.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/pokemontools/audio.py b/pokemontools/audio.py
index 896ceef..9e08113 100644
--- a/pokemontools/audio.py
+++ b/pokemontools/audio.py
@@ -370,7 +370,8 @@ class Sound:
self.asms = []
self.parse()
- def parse(self):
+
+ def parse_header(self):
self.num_channels = (rom[self.address] >> 6) + 1
self.channels = []
for ch in xrange(self.num_channels):
@@ -383,9 +384,9 @@ class Sound:
self.channels += [(current_channel, channel)]
self.labels += channel.labels
- asms = []
- asms += [generate_label_asm(self.base_label, self.start_address)]
+ def make_header(self):
+ asms = []
for i, (num, channel) in enumerate(self.channels):
channel_id = num - 1
@@ -397,16 +398,27 @@ class Sound:
comment_text = '; %x\n' % self.address
asms += [(self.address, comment_text, self.address)]
+ return asms
+
+
+ def parse(self):
+ self.parse_header()
+
+ asms = []
+
+ asms += [generate_label_asm(self.base_label, self.start_address)]
+ asms += self.make_header()
for num, channel in self.channels:
asms += channel.output
asms = sort_asms(asms)
- self.last_address = asms[-1][2]
+ _, _, self.last_address = asms[-1]
asms += [(self.last_address,'; %x\n' % self.last_address, self.last_address)]
self.asms += asms
+
def to_asm(self, labels=[]):
"""insert outside labels here"""
asms = self.asms