Skip to content

Instantly share code, notes, and snippets.

@digarok
Created March 14, 2020 16:36
Show Gist options
  • Save digarok/d9bb02c779a2af97917e01be8ea0c16b to your computer and use it in GitHub Desktop.
Save digarok/d9bb02c779a2af97917e01be8ea0c16b to your computer and use it in GitHub Desktop.
This takes a raw Apple IIgs $C1 image and writes zeros to every other "scanline".
# Invoke like:
# $ python stripe.py example.c1 output_dir
from sys import argv
from array import array
import os
data = array('B')
with open(argv[1], 'rb') as input_img:
data = input_img.read()
outdata = bytearray(data)
# do every other line from 0-199. you can change 0 to 1 if you want odd lines
for line in range(0,200,2):
# calculate beginning of line (each line is 160 ($A0) bytes)
offset = 0xA0 * line
for b in range(0,0xA0):
# write 00's
outdata[offset+b] = 0x00
# save file to output_dir
out_file = argv[2] + os.path.basename(argv[1])
newFile = open(out_file, "wb")
newFile.write(outdata)
print("Wrote {} bytes to {}.".format(len(outdata),out_file))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment