split up image into c and header file

This commit is contained in:
David Voswinkel
2009-08-01 15:16:55 +02:00
parent 553ef0059a
commit 82a6edad50
2 changed files with 28 additions and 12 deletions

View File

@@ -2,19 +2,35 @@ import binascii
data = open("rom.smc","r").read()
data = binascii.rlecode_hqx(data)
print '''
#include <avr/pgmspace.h>
cfile = open("loader.c","w")
hfile = open("loader.h","w")
hfile.write('''
#ifndef __FIFO_H__
#define __FIFO_H__
#define ROM_SIZE %i
const char _rom[ROM_SIZE] PROGMEM = {
''' % len(data)
#endif
''' % len(data))
cfile.write('''
#include <avr/pgmspace.h>
#include <loader.h>
const char _rom[ROM_SIZE] PROGMEM = {
''')
for idx,c in enumerate(data):
c = ord(c)
if idx<len(data)-1:
print "0x%02x," % c,
cfile.write("0x%02x," % c)
else:
print "0x%02x" % c,
cfile.write("0x%02x" % c)
if idx and idx%16==0:
print
print '''
cfile.write("\n")
cfile.write('''
};
'''
''')
cfile.close()