#!/usr/bin/env python # Tool to build relocatable Supermon+64 binary # Jim Butterfield described the post-processing of Supermon 64 binaries # in a posting to comp.sys.cbm on Dec 20, 2003: # I should note that, since Supermon+64 is relocatable code, the source # does not assemble into the final binary file. It may seem crude, but # I follow this procedure: (1) The source is carefully structured so # that there are no "dispersed addresses" such as might be created with # something like LDA #>VECTOR .. LDY # i+1 and mon1[i+1] != mon2[i+1]: addr = struct.unpack('H', mon1[i:i+2])[0] # calculate offset to address offset = struct.pack('h', addr - end1) out.write(offset) # mark address to be adjusted with $36 out.write(b'\x36') i += 2 else: out.write(mon1[i:i+1]) i += 1