Skip to content
Permalink
Browse files
* Merge Super Forum Poster 2 by @fweez
* Add graphicstool.py to aid in copying graphics & map sections

Note: I didn't have a chance to test the graphics tool with the second
row of map sections. I'll get it tested tonight.
  • Loading branch information
fweez committed Sep 28, 2016
1 parent 99ada94 commit ead5effb0153af9dd0b4972c1eeec099ad9d9fd0
Showing with 45 additions and 0 deletions.
  1. +45 −0 graphicstool.py
@@ -0,0 +1,45 @@
#!/usr/bin/env python

import os.path
import sys

if len(sys.argv) < 4:
sys.stderr.write("usage: " + sys.argv[0] + " <input p8> <graphics section letter> <collab subdir>")
exit(1)

# fixme: replace with args
inputfile = sys.argv[1]
section = sys.argv[2]
collabprefix = sys.argv[3]

sections = list('0abcdefghijklmnopqrstuvw')
sectionindex = sections.index(section) / 4
sectionname = "gfx"
sectionsize = 32
if sectionindex > 3:
sectionname = "map"
sectionindex = sectionindex-4
sectionsize = 16
outfile = sectionname + str(sectionindex)

outfile = os.path.join(collabprefix, sectionname, outfile)
col = (sections.index(section) % 4) * 32

mergedlines = ['']*sectionsize

with open(inputfile, 'r') as source:
while True:
if source.readline().startswith('__' + sectionname + '__'): break

for _ in range(0, sectionindex*sectionsize):
source.readline()

with open(outfile, 'r') as output:
for outlineidx in range(0,sectionsize):
i = source.readline()
o = output.readline()
mergedlines[outlineidx] = o[0:col] + i[col:col+32] + o[col+32:]

with open(outfile, 'w') as output:
for outline in mergedlines:
output.write(outline)

0 comments on commit ead5eff

Please sign in to comment.