Created
March 14, 2020 16:36
-
-
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".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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