diff --git a/cfg/gamate.cfg b/cfg/gamate.cfg index 577dfeb1d..d7c87b455 100644 --- a/cfg/gamate.cfg +++ b/cfg/gamate.cfg @@ -8,23 +8,24 @@ SYMBOLS { MEMORY { # 0000-03ff is RAM # FIXME: what zp range can we actually use? - ZP: start = $0080, size = $80; + ZP: start = $0020, size = $e0; CPUSTACK: start = $0100, size =$100; - RAM: start = $0200, size = $180, define = yes; + RAM: start = $0200, size = $200 - __STACKSIZE__, define = yes; + CARTHEADER: file = %O, define = yes, start = %S, size = $0029; # 6000-e000 can be (Cartridge) ROM # WARNING: fill value must be $00 else it will no more work #ROM: start = $6000, size = $1000, fill = yes, fillval = $00, file = %O, define = yes; #ROMFILL: start = $7000, size = $7000, fill = yes, fillval = $00, file = %O, define = yes; # for images that have code >$6fff we must calculate the checksum! - ROM: start = $6000, size = $8000, fill = yes, fillval = $00, file = %O, define = yes; + ROM: start = $6000 + $29, size = $8000 - $29, fill = yes, fillval = $00, file = %O, define = yes; } SEGMENTS { ZEROPAGE: load = ZP, type = zp, define = yes; EXTZP: load = ZP, type = zp, define = yes, optional = yes; APPZP: load = ZP, type = zp, define = yes, optional = yes; - STARTUP: load = ROM, type = ro, define=yes; + STARTUP: load = CARTHEADER, type = ro, define=yes; INIT: load = ROM, type = ro, define = yes, optional = yes; CODE: load = ROM, type = ro, define=yes; RODATA: load = ROM, type = ro, define=yes; diff --git a/libsrc/gamate/crt0.s b/libsrc/gamate/crt0.s index b54d8ade1..5df5ad38c 100644 --- a/libsrc/gamate/crt0.s +++ b/libsrc/gamate/crt0.s @@ -1,33 +1,16 @@ - .export __STARTUP__ : absolute = 1 ; Mark as startup + .export Start, _exit .import initlib, donelib, callmain .import push0, _main, zerobss, copydata - .import IRQStub - ; Linker generated symbols .import __RAM_START__, __RAM_SIZE__ - .import __ROM_START__, __ROM_SIZE__ - .import __STARTUP_LOAD__,__STARTUP_RUN__, __STARTUP_SIZE__ - .import __CODE_LOAD__,__CODE_RUN__, __CODE_SIZE__ - .import __RODATA_LOAD__,__RODATA_RUN__, __RODATA_SIZE__ .include "zeropage.inc" .include "gamate.inc" - .segment "STARTUP" - - .word 0 ; +00 checksum from 7000-7fff (simple 8bit adds) - .byte 1, 0, 1 ; +02 flags - .byte "COPYRIGHT BIT CORPORATION", 0, $ff ; +05 copyright - ; system vectors - jmp reset ; +20 reset entry - jmp nmi ; +23 nmi entry - jmp IRQStub ; +26 irq entry (135 hz) - -;------------------------------------------------------------------------------- -reset: +Start: ; setup the CPU and System-IRQ ; Initialize CPU @@ -67,12 +50,8 @@ _exit: jsr donelib ; Run module destructors ; reset (start over) - jmp reset + jmp Start .export initmainargs initmainargs: rts - -;------------------------------------------------------------------------------- -nmi: - rts diff --git a/libsrc/gamate/header.s b/libsrc/gamate/header.s new file mode 100644 index 000000000..da15a51eb --- /dev/null +++ b/libsrc/gamate/header.s @@ -0,0 +1,16 @@ + ; The following symbol is used by linker config to force the module + ; to get included into the output file + .export __STARTUP__: absolute = 1 + + .import Start, IRQStub, NMIStub + + + .segment "STARTUP" + + .word 0 ; +00 checksum from 7000-7fff (simple 8bit adds) + .byte 1, 0, 1 ; +02 flags + .byte "COPYRIGHT BIT CORPORATION", 0, $ff ; +05 copyright + ; system vectors + jmp Start ; +20 reset entry + jmp NMIStub ; +23 nmi entry + jmp IRQStub ; +26 irq entry (135 hz) diff --git a/libsrc/gamate/nmi.s b/libsrc/gamate/nmi.s new file mode 100644 index 000000000..918431340 --- /dev/null +++ b/libsrc/gamate/nmi.s @@ -0,0 +1,7 @@ +; +; NMI handling (Gamate version) +; + .export NMIStub + +NMIStub: + rts \ No newline at end of file diff --git a/testcode/lib/gamate/audiotest.s b/testcode/lib/gamate/audiotest.s index 2fa38a500..1b5d22767 100644 --- a/testcode/lib/gamate/audiotest.s +++ b/testcode/lib/gamate/audiotest.s @@ -1,7 +1,6 @@ ; original audiotest.s by PeT (mess@utanet.at) - .export _main .include "gamate.inc" .zeropage @@ -29,17 +28,15 @@ psy: .byte 0 xpos: .byte 0 ypos: .byte 0 -.code + .code -chars: - .incbin "cga2.chr" - -hex2asc: .byte "0123456789abcdef" +chars: .incbin "cga2.chr" +hex2asc: .byte "0123456789abcdef" ;------------------------------------------------------------------------------- - .export IRQStub + .export IRQStub, NMIStub -.proc nmi +.proc NMIStub inc nmi_count rts .endproc @@ -50,8 +47,9 @@ hex2asc: .byte "0123456789abcdef" .endproc ;------------------------------------------------------------------------------- + .export Start -.proc _main +.proc Start lda #>AUDIO_BASE sta writeaddr+1 sta readaddr+1 diff --git a/testcode/lib/gamate/ctest.c b/testcode/lib/gamate/ctest.c index da81bf240..dfebd9bef 100644 --- a/testcode/lib/gamate/ctest.c +++ b/testcode/lib/gamate/ctest.c @@ -4,7 +4,7 @@ #include unsigned char y = 0; -unsigned char x; +unsigned char x = 0; unsigned short n; int main(int argc, char *argv[]) @@ -22,14 +22,14 @@ int main(int argc, char *argv[]) n = clock(); - gotoxy(0,2);cprintf("%04x %02x %02x", n, x, y); + gotoxy(0,2);cprintf("%04x %02x %02x %02x", n, x, y, *((unsigned char*)JOY_DATA)); switch((*((unsigned char*)JOY_DATA))) { case 0xff ^ JOY_DATA_UP: - ++y; + ++y; if (y == 0xc8) y = 0; break; case 0xff ^ JOY_DATA_DOWN: - --y; + --y; if (y == 0xff) y = 0xc7; break; case 0xff ^ JOY_DATA_LEFT: ++x; @@ -40,14 +40,12 @@ int main(int argc, char *argv[]) case 0xff ^ JOY_DATA_FIRE_A: break; } - if (y == 0xff) y = 0xc7; - if (y == 0xc8) y = 0; + + waitvblank(); (*((unsigned char*)LCD_XPOS)) = x; (*((unsigned char*)LCD_YPOS)) = y; - waitvblank(); - } return 0; diff --git a/testcode/lib/gamate/lcdtest.s b/testcode/lib/gamate/lcdtest.s index 41242a982..3ac8f968b 100644 --- a/testcode/lib/gamate/lcdtest.s +++ b/testcode/lib/gamate/lcdtest.s @@ -1,7 +1,6 @@ ; original lcdtest.s by PeT (mess@utanet.at) - .export _main .include "gamate.inc" .zeropage @@ -32,15 +31,15 @@ xdesc: .byte "0123456789abcdefghijklmnopqrstuv", 0 ydesc: .byte "0123456789ABCDEFGHIJKLMNOPQRSTUV", 0 ;------------------------------------------------------------------------------- + .export IRQStub, NMIStub -.proc nmi + +.proc NMIStub inc nmi_count rts .endproc - .export IRQStub - .proc IRQStub inc irq_count @@ -55,8 +54,9 @@ ydesc: .byte "0123456789ABCDEFGHIJKLMNOPQRSTUV", 0 .endproc ;------------------------------------------------------------------------------- + .export Start -.proc _main +.proc Start lda #0 sta LCD_XPOS diff --git a/util/gamate/gamate-fixcart.c b/util/gamate/gamate-fixcart.c index a99483844..e38832461 100644 --- a/util/gamate/gamate-fixcart.c +++ b/util/gamate/gamate-fixcart.c @@ -13,6 +13,9 @@ int main(int argc, char *argv[]) { } in = fopen(argv[1], "rb"); out = fopen(argv[2], "wb"); + if (!in || !out) { + exit(-1); + } len = fread(buffer, 1, 512 * 1024, in); n = 0; for (i = 0x1000; i < 0x2000; i++) { n += buffer[i]; @@ -22,4 +25,5 @@ int main(int argc, char *argv[]) { fwrite(buffer, 1, len, out); fclose(in); fclose(out); + return (0); }