diff options
| author | Bryan Bishop <kanzure@gmail.com> | 2012-04-21 12:38:12 -0500 | 
|---|---|---|
| committer | Bryan Bishop <kanzure@gmail.com> | 2012-04-21 12:38:12 -0500 | 
| commit | 02497888f6a467d5d5922cc7817c787a98aefd25 (patch) | |
| tree | 7a6e6e2f8e97f3c3f9ef51538125f08f81fea4ea /extras | |
| parent | 285b3066a443438b30691be7193e7f7135b9a950 (diff) | |
Incbin.split method similar to split_incbin_line_into_three
Diffstat (limited to 'extras')
| -rw-r--r-- | extras/crystal.py | 24 | 
1 files changed, 23 insertions, 1 deletions
| diff --git a/extras/crystal.py b/extras/crystal.py index a2c9fed10..226886ac5 100644 --- a/extras/crystal.py +++ b/extras/crystal.py @@ -4466,7 +4466,29 @@ class Incbin:          if self.interval > 0:              return self.line          else: return "" +    def split(self, start_address, byte_count): +        """splits this incbin into three separate incbins""" +        if start_address < self.start_address or start_address > self.end_address: +            raise Exception, "this incbin doesn't handle this address" +        incbins = [] + +        #start, end1, end2 (to be printed as start, end1 - end2) +        if (start_address - self.start) > 0: +            first = (self.start, start_address, self.start) +            incbins.append(Incbin("INCBIN \"baserom.gbc\",$%.2x,$%.2x - $%.2x" % (first[0], first[1], first[2]))) +        else: +            #skip this one because we're not including anything +            first = None + +        #this is the one you will replace with whatever content +        second = (start_address, byte_count) +        incbins.append(Incbin("INCBIN \"baserom.gbc\",$%.2x,$%.2x" % (start_address, byte_count))) + +        third = (start_address + byte_count, end - (start_address + byte_count)) +        incbins.append(Incbin("INCBIN \"baserom.gbc\",$%.2x,$%.2x" % (third[0], third[1]))) +        return incbins +          def AsmSection:      def __init__(self, line):          self.bank_id = None @@ -4491,7 +4513,6 @@ class Asm:          self.parts = []          self.filename = filename          self.load_and_parse() -      def load_and_parse(self):          self.parts = []          asm = open(self.filename, "r").read().split("\n") @@ -4506,6 +4527,7 @@ class Asm:              else:                  thing = AsmLine(line, bank=bank)              self.parts.append(thing) +    def insert(self, object):  def index(seq, f):      """return the index of the first item in seq | 
