mirror of
https://github.com/pevans/erc-c.git
synced 2024-12-22 14:30:45 +00:00
42394fee80
...The latter being in the form of the zeropad file, 256 bytes long.
54 lines
1.8 KiB
Python
Executable File
54 lines
1.8 KiB
Python
Executable File
#!/usr/bin/env python2
|
|
|
|
import sys
|
|
|
|
# If we can open fname, then return its data; otherwise, raise an exception
|
|
def file_data(fname):
|
|
with open(fname, 'r') as f:
|
|
return f.read()
|
|
raise Exception("failed to read file %s" % (fname))
|
|
|
|
# This is "header" field of the objstore struct.
|
|
data = 'hope'
|
|
|
|
# These must be appended in the exact order indicated by the struct definition
|
|
# in objstore.h
|
|
data += file_data('./data/print.rom') # $C100
|
|
data += file_data('./data/serial.rom') # $C200
|
|
data += file_data('./data/zeropad0x100.rom') # $C300
|
|
data += file_data('./data/zeropad0x100.rom') # $C400
|
|
data += file_data('./data/zeropad0x100.rom') # $C500
|
|
data += file_data('./data/disk2.rom') # $C600
|
|
data += file_data('./data/disk2.rom') # $C700
|
|
data += file_data('./data/apple2.rom') # $D000
|
|
data += file_data('./fonts/apple2-system.bmp')
|
|
|
|
# Let's not keep calling len(data) since we know it won't change over our
|
|
# iterations
|
|
data_len = len(data)
|
|
|
|
print data_len
|
|
exit(0)
|
|
|
|
# This just defines the variable name for the store data
|
|
sys.stdout.write("static unsigned char store_data[] =\n")
|
|
|
|
# This loop will write out a series of 16 characters given in hexadecimal
|
|
# escape, preceded by a quote and ending in a quote. C will automatically
|
|
# append literal strings when given one after another with no other punctuation
|
|
# (e.g. "abc" "def" is equivalent to "abcdef"). The first sys.stdout.write()
|
|
# will start us off with the first line's quote mark.
|
|
sys.stdout.write('"')
|
|
for i in range(0, data_len):
|
|
sys.stdout.write("\\x%02x" % (ord(data[i])))
|
|
if i == data_len - 1:
|
|
break
|
|
if i > 0 and (i+1) % 16 == 0:
|
|
sys.stdout.write('" // %06x\n"' % (i))
|
|
|
|
# And we're about done; finish with the last quote, and then terminate with a
|
|
# semicolon.
|
|
sys.stdout.write('";')
|
|
|
|
# vim:ft=python:
|