moved cart header into seperate file, moved nmi stub into several file, tweaked linker config

This commit is contained in:
mrdudz 2015-11-29 16:01:36 +01:00
parent 1893e24da9
commit c636675521
8 changed files with 53 additions and 50 deletions

View File

@ -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;

View File

@ -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

16
libsrc/gamate/header.s Normal file
View File

@ -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)

7
libsrc/gamate/nmi.s Normal file
View File

@ -0,0 +1,7 @@
;
; NMI handling (Gamate version)
;
.export NMIStub
NMIStub:
rts

View File

@ -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

View File

@ -4,7 +4,7 @@
#include <conio.h>
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;

View File

@ -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

View File

@ -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);
}