junglejourney

changeset 145:6d00763499c1

Added padding to the UEF file to make it load more reliably in various emulators.
author David Boddie <david@boddie.org.uk>
date Sun Sep 11 22:35:43 2011 +0200
parents 9a9866af70fd
children 8dcefb5a013d
files build.py
diffstat 1 files changed, 17 insertions(+), 2 deletions(-) [+]
line diff
     1.1 --- a/build.py	Sun Sep 11 02:17:33 2011 +0200
     1.2 +++ b/build.py	Sun Sep 11 22:35:43 2011 +0200
     1.3 @@ -168,11 +168,26 @@
     1.4      
     1.5      u = UEFfile.UEFfile(creator = 'build.py '+version)
     1.6      u.minor = 6
     1.7 +    u.target_machine = "Electron"
     1.8      
     1.9 -    # Insert a gap at the start of the tape.
    1.10 -    u.chunks.append((0x110, "\xdc\x05"))
    1.11      u.import_files(0, files)
    1.12      
    1.13 +    # Insert a gap before each file.
    1.14 +    offset = 0
    1.15 +    for f in u.contents:
    1.16 +    
    1.17 +        # Insert a gap and some padding before the file.
    1.18 +        gap_padding = [(0x112, "\xdc\x05"), (0x110, "\xdc\x05"), (0x100, "\xdc")]
    1.19 +        u.chunks = u.chunks[:f["position"] + offset] + \
    1.20 +                   gap_padding + u.chunks[f["position"] + offset:]
    1.21 +
    1.22 +        # Each time we insert a gap, the position of the file changes, so we
    1.23 +        # need to update its position and last position. This isn't really
    1.24 +        # necessary because we won't read the contents list again.
    1.25 +        offset += len(gap_padding)
    1.26 +        f["position"] += offset
    1.27 +        f["last position"] += offset
    1.28 +    
    1.29      # Write the new UEF file.
    1.30      try:
    1.31          u.write(out_uef_file, write_emulator_info = False)