Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Refactor the LZ tools and fix BSSReader's eval shenanigans. #86

Merged
merged 14 commits into from
Mar 12, 2015
Merged
20 changes: 16 additions & 4 deletions pokemontools/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,8 @@ def __init__(self, address, name='', sfx=False):
self.asms = []
self.parse()

def parse(self):

def parse_header(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docstring on parse_header and why is it different from make_header..

self.num_channels = (rom[self.address] >> 6) + 1
self.channels = []
for ch in xrange(self.num_channels):
Expand All @@ -383,9 +384,9 @@ def parse(self):
self.channels += [(current_channel, channel)]
self.labels += channel.labels

asms = []

asms += [generate_label_asm(self.base_label, self.start_address)]
def make_header(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make_header should have a docstring.

asms = []

for i, (num, channel) in enumerate(self.channels):
channel_id = num - 1
Expand All @@ -397,16 +398,27 @@ def parse(self):

comment_text = '; %x\n' % self.address
asms += [(self.address, comment_text, self.address)]
return asms


def parse(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parse should have a docstring.

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)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using str.format() instead of %.


self.asms += asms


def to_asm(self, labels=[]):
"""insert outside labels here"""
asms = self.asms
Expand Down
2 changes: 1 addition & 1 deletion pokemontools/crystal.py
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,7 @@ def to_asm(self):
lo, hi = self.bytes[1:3]
else:
lo, hi = self.bytes[0:2]
pointer_part = "{0}{1:2x}{2:2x}".format(self.prefix, hi, lo)
pointer_part = "{0}{1:02x}{2:02x}".format(self.prefix, hi, lo)

# bank positioning matters!
if bank == True or bank == "reverse": # bank, pointer
Expand Down
Loading