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
#endif
''' % len(data))
cfile.write('''
#include <avr/pgmspace.h>
#include <loader.h>
const char _rom[ROM_SIZE] PROGMEM = {
''' % len(data)
''')
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()

View File

@ -20,8 +20,8 @@ SPCFILE = $(SPCSFILES:.asm=.bin)
all: spc $(OFILES)
$(LD) $(LDFLAGS) linkfile $(ROMFILE)
dd if=$(ROMFILE) of=rom.smc bs=64k count=1
python conv_rle.py > loader.c
python conv_rle.py
$(OFILES): $(SFILES)
$(AC) $(AFLAGS) $(SFILES)
@ -43,6 +43,6 @@ run:
$(EMU) $(ROMFILE)
clean:
rm -f $(ROMFILE) rom.smc $(SPCFILE) core *~ *.o *.sym *.srm data/apu/*.o data/apu/*.sym
rm -f $(ROMFILE) rom.smc $(SPCFILE) core *~ *.o *.sym *.srm data/apu/*.o data/apu/*.sym loader.c loader.h