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

View File

@ -20,8 +20,8 @@ SPCFILE = $(SPCSFILES:.asm=.bin)
all: spc $(OFILES) all: spc $(OFILES)
$(LD) $(LDFLAGS) linkfile $(ROMFILE) $(LD) $(LDFLAGS) linkfile $(ROMFILE)
dd if=$(ROMFILE) of=rom.smc bs=64k count=1 python conv_rle.py
python conv_rle.py > loader.c
$(OFILES): $(SFILES) $(OFILES): $(SFILES)
$(AC) $(AFLAGS) $(SFILES) $(AC) $(AFLAGS) $(SFILES)
@ -43,6 +43,6 @@ run:
$(EMU) $(ROMFILE) $(EMU) $(ROMFILE)
clean: 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