diff options
author | B. Watson <yalhcru@gmail.com> | 2016-02-16 02:08:05 -0500 |
---|---|---|
committer | B. Watson <yalhcru@gmail.com> | 2016-02-16 02:08:05 -0500 |
commit | 3a22a9af57b8b564301cd86e8e933eb1a22981ce (patch) | |
tree | 44eb7abac4ea5f3add959e30f86ed7a9441510e9 | |
parent | 3988e55f135d6328d16ce95fe363acf2d2e07f56 (diff) | |
download | taipan-3a22a9af57b8b564301cd86e8e933eb1a22981ce.tar.gz |
keep RODATA in ROM for cart build
-rw-r--r-- | Makefile | 33 | ||||
-rw-r--r-- | bank2.s | 6 | ||||
-rw-r--r-- | bank3.s | 2 | ||||
-rw-r--r-- | bank7.s | 10 | ||||
-rw-r--r-- | cartbank3.cfg | 66 | ||||
-rw-r--r-- | taipan.c | 7 |
6 files changed, 100 insertions, 24 deletions
@@ -305,11 +305,16 @@ mkcart: mkcart.c # the "tail -c+2" stuff removes the first byte, so we end up with # a romable_taimain.raw that's ready to be copied to $0400 and run # via "JSR $0400". -romable_taimain.raw: $(TAIMAIN_C_SRC) $(TAIMAIN_ASM_SRC) $(TAIMAIN_HDRS) - rm -f taimain.xex - $(MAKE) FONT_ADDR=0x9c00 TAIMAIN_ADDR=0x3ff EXTRACFLAGS="-Wl -D__AUTOSTART__=1 -Wl -D__EXEHDR__=1 -DCART_TARGET=1 --asm-define CART_TARGET=1" taimain.xex - tail -c+2 taimain.xex > romable_taimain.raw - rm -f taimain.xex +#romable_taimain.raw: $(TAIMAIN_C_SRC) $(TAIMAIN_ASM_SRC) $(TAIMAIN_HDRS) +# rm -f taimain.xex +# $(MAKE) FONT_ADDR=0x9c00 TAIMAIN_ADDR=0x3ff EXTRACFLAGS="-Wl -D__AUTOSTART__=1 -Wl -D__EXEHDR__=1 -DCART_TARGET=1 --asm-define CART_TARGET=1" taimain.xex +# tail -c+2 taimain.xex > romable_taimain.raw +# rm -f taimain.xex + +romable_taimain.raw: $(TAIMAIN_C_SRC) $(TAIMAIN_ASM_SRC) $(TAIMAIN_HDRS) $(BIGNUM_SRC) $(BIGNUM_HDRS) + cl65 --config cartbank3.cfg -m taipan.map -t atari -T -I. -L. -DFONT_ADDR=0x9c00 --start-addr 0x3ff -Wl -D__STACKSIZE__=0x200 -O -Wl -D__SYSTEM_CHECK__=1 -Wl -D__AUTOSTART__=1 -Wl -D__EXEHDR__=1 -DCART_TARGET=1 --asm-define CART_TARGET=1 -DBIGNUM=BIGFLOAT -o romable_taimain.raw.in $(TAIMAIN_C_SRC) $(TAIMAIN_ASM_SRC) $(BIGNUM_SRC) + tail -c+2 romable_taimain.raw.in > romable_taimain.raw + rm -f romable_taimain.raw.in # 256 bytes of $ff filler, for the last page of each code bank. Wasting # this little bit of space simplifies the copying code in bank7.s (no @@ -323,18 +328,16 @@ fill256: blankbank: $(PERL) -Mbytes -e 'print chr(0xff) x 8192' > blankbank -splitrom.raw.0: splitrom.raw.3 - -splitrom.raw.1: splitrom.raw.3 +splitrom.raw.0: splitrom.raw.2 -splitrom.raw.2: splitrom.raw.3 +splitrom.raw.1: splitrom.raw.2 # split romable_taimain.raw into bank-sized chunks. if we end up -# with 4 chunks, the cart won't work correctly, so stop the build here +# with 3 chunks, the cart won't work correctly, so stop the build here # in that case. -splitrom.raw.3: romable_taimain.raw +splitrom.raw.2: romable_taimain.raw split -b 7936 -a 1 -d romable_taimain.raw splitrom.raw. - [ -e splitrom.raw.4 ] && echo "*** romable_taimain.raw too big" && rm -f splitrom.raw.* && exit 1 || exit 0 + [ -e splitrom.raw.3 ] && echo "*** romable_taimain.raw too big" && rm -f splitrom.raw.* && exit 1 || exit 0 bank0: splitrom.raw.0 fill256 cat splitrom.raw.0 fill256 > bank0 @@ -343,13 +346,13 @@ bank1: splitrom.raw.1 fill256 cat splitrom.raw.1 fill256 > bank1 bank2: splitrom.raw.2 fill256 - cat splitrom.raw.2 fill256 > bank2 + cl65 -l bank2.lst -m bank2.map -t none -o bank2 bank2.s -bank3: splitrom.raw.3 bank3.s taifont +bank3: rodata.8000 bank3.s taifont romable_taimain.raw cl65 -l bank3.lst -m bank3.map -t none -o bank3 bank3.s bank7: bank7.s titledata.dat ver.dat help.dat newtitle.s - cl65 --asm-define BANK3SIZE=`$(PERL) -e 'print -s "splitrom.raw.3"'` -l bank7.lst -m bank7.map -t none -o bank7 bank7.s + cl65 --asm-define BANK2SIZE=`$(PERL) -e 'print -s "splitrom.raw.2"'` -l bank7.lst -m bank7.map -t none -o bank7 bank7.s # raw ROM, for burning to EPROM/flash. taipan.rom: bank0 bank1 bank2 bank3 bank7 blankbank @@ -0,0 +1,6 @@ + +start = $8000 +end = $9fff + .org start + .incbin "splitrom.raw.2" + .res end-*+1, $ff @@ -5,7 +5,7 @@ font = $9c00 .org $8000 - .incbin "splitrom.raw.3" + .incbin "rodata.8000" .if * > font .fatal "bank7 code too large" @@ -103,13 +103,15 @@ cartstart: jsr copy_31_pages lda #2 ; bank 2... sta CCNTL ; ...select it - jsr copy_31_pages + ldx #(>BANK2SIZE)+1 ; BANK2SIZE defined on the command line + jsr copy_x_pages + + ; bank 3 contains RODATA and some code, that runs from ROM rather than + ; being copied to RAM. lda #3 ; bank 3... sta CCNTL ; ...select it - ldx #(>BANK3SIZE)+1 ; BANK3SIZE defined on the command line - jsr copy_x_pages - .out .sprintf("BANK3SIZE %x (%x pages)", BANK3SIZE, (>BANK3SIZE)+1) + .out .sprintf("BANK2SIZE $%x (%d pages)", BANK2SIZE, (>BANK2SIZE)+1) ; leave bank 3 enabled, as it has our custom font in it diff --git a/cartbank3.cfg b/cartbank3.cfg new file mode 100644 index 0000000..e50d755 --- /dev/null +++ b/cartbank3.cfg @@ -0,0 +1,66 @@ +# TODO: get rid of some of the chunks like HEADER SYSCHKHDR etc. +# right now I'm killing them with -Wl options to cl65. + +FEATURES { + STARTADDRESS: default = $2000; +} +SYMBOLS { + __EXEHDR__: type = import; + __SYSTEM_CHECK__: type = import; # force inclusion of "system check" load chunk + __AUTOSTART__: type = import; # force inclusion of autostart "trailer" + __STACKSIZE__: type = weak, value = $0800; # 2k stack + __STARTADDRESS__: type = export, value = %S; + __RESERVED_MEMORY__: type = weak, value = $0000; +} +MEMORY { + ZP: file = "", define = yes, start = $0082, size = $007E; + +# file header, just $FFFF + HEADER: file = %O, start = $0000, size = $0002; + +# "system check" load chunk + SYSCHKHDR: file = %O, start = $0000, size = $0004; + SYSCHKCHNK: file = %O, start = $2E00, size = $0300; + SYSCHKTRL: file = %O, start = $0000, size = $0006; + +# "main program" load chunk + MAINHDR: file = %O, start = $0000, size = $0004; + RAM: file = %O, define = yes, start = %S, size = $BC20 - __STACKSIZE__ - __RESERVED_MEMORY__ - %S; + TRAILER: file = %O, start = $0000, size = $0006; + +# read-only data goes in a cart bank + HIGHDATA: file = "rodata.8000" start = $8000, size = $2000; +} +SEGMENTS { + EXEHDR: load = HEADER, type = ro; + SYSCHKHDR: load = SYSCHKHDR, type = ro, optional = yes; + SYSCHK: load = SYSCHKCHNK, type = rw, define = yes, optional = yes; + SYSCHKTRL: load = SYSCHKTRL, type = ro, optional = yes; + MAINHDR: load = MAINHDR, type = ro; + STARTUP: load = RAM, type = ro, define = yes; + LOWCODE: load = RAM, type = ro, define = yes, optional = yes; + INIT: load = RAM, type = ro, optional = yes; + CODE: load = RAM, type = ro, define = yes; + RODATA: load = HIGHDATA, type = ro; + DATA: load = RAM, type = rw; + INITBSS: load = RAM, type = bss, optional = yes; + BSS: load = RAM, type = bss, define = yes; + ZEROPAGE: load = ZP, type = zp; + EXTZP: load = ZP, type = zp, optional = yes; + AUTOSTRT: load = TRAILER, type = ro; +} +FEATURES { + CONDES: type = constructor, + label = __CONSTRUCTOR_TABLE__, + count = __CONSTRUCTOR_COUNT__, + segment = INIT; + CONDES: type = destructor, + label = __DESTRUCTOR_TABLE__, + count = __DESTRUCTOR_COUNT__, + segment = RODATA; + CONDES: type = interruptor, + label = __INTERRUPTOR_TABLE__, + count = __INTERRUPTOR_COUNT__, + segment = RODATA, + import = __CALLIRQ__; +} @@ -1,10 +1,9 @@ // TODO: replace conio with coffio #include <conio.h> -#include <time.h> -#include <stdlib.h> -#include <peekpoke.h> -#include <stdint.h> +#include <stdlib.h> /* rand() srand() exit() */ +#include <stdint.h> /* UINT32_MAX */ +#include <peekpoke.h> /* PEEK() PEEKW() POKE() POKEW() */ #include "sounds.h" |