diff --git a/snes/Makefile b/snes/Makefile index 079b43e..253cac4 100644 --- a/snes/Makefile +++ b/snes/Makefile @@ -1,19 +1,23 @@ OBJS = header.ips reset.o65 main.o65 font.o65 palette.o65 data.o65 const.o65 logo.o65 logospr.o65 text.o65 dma.o65 menu.o65 pad.o65 time.o65 mainmenu.o65 sysinfo.o65 # gfx.o65 # vars.o65 -all: menu.bin +all: clean menu.bin map smc: menu.bin cat menu.bin sd2snes.rom > menu.smc + +map: menu.bin + utils/mkmap.sh $(OBJS) + menu.bin: $(OBJS) - sneslink -fsmc -o $@ $^ + sneslink -fsmc -o $@ $^ 2>&1 | tee link.log # Generic rule to create .o65 out from .a65 %.o65: %.a65 - snescom -J -Wall -o $@ $< + snescom -J -Wall -o $@ $< 2>&1 | tee $@.log # Generic rule to create .ips out from .a65 %.ips: %.a65 - snescom -I -J -Wall -o $@ $< + snescom -I -J -Wall -o $@ $< 2>&1 | tee $@.log clean: rm -f *.ips *.o65 *~ menu.bin diff --git a/snes/data.a65 b/snes/data.a65 index df04d5d..6f7abd5 100644 --- a/snes/data.a65 +++ b/snes/data.a65 @@ -1,3 +1,4 @@ +*=$7E0000 .data ;don't anger the stack! dirptr_addr .word 0 diff --git a/snes/header.a65 b/snes/header.a65 index d33cd62..02d6c73 100644 --- a/snes/header.a65 +++ b/snes/header.a65 @@ -1,6 +1,16 @@ -; This file is part of the snescom-asm demo - a demo of how to build a SNES program. +; This file is a modified version of the header.a65 file from: +; snescom-asm demo - a demo of how to build a SNES program. ; See http://bisqwit.iki.fi/source/snescom.html for details. +; fill whole area beforehand so the linker does not create multiple +; objects from it. (necessary for map creation) + +*= $C0FF00 + .word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + .word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + .word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + .word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + ; Begin assembling to this address. *= $C0FF00 diff --git a/snes/utils/mkmap.sh b/snes/utils/mkmap.sh new file mode 100755 index 0000000..b133c3b --- /dev/null +++ b/snes/utils/mkmap.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +args=("$@") +objcount=0 + +grep object_ link.log | \ +sed -e 's/object_//g; s/_code//g; s/_data//g' | \ +while read obj; do + objcount=$((objcount+1)) + read base idx <<< "$obj" + base="0x${base}" + fn=${args[$idx-1]} + echo ======$fn, base=$base====== > ${fn%%.*}.map + sed -e '/^Externs/,$d;/^Labels/d' < $fn.log | \ + while read line; do + read addr label <<< "$line" + addr="0x$addr" + decaddr=`printf "%d" $addr` + [ "$decaddr" -gt "65535" ] && base=0 + ea=`printf "%X" $((base+addr))` + echo $ea $label >> ${fn%%.*}.map + done +done +