]> git.sur5r.net Git - cc65/commitdiff
moved cart header into seperate file, moved nmi stub into several file, tweaked linke...
authormrdudz <mrdudz@users.noreply.github.com>
Sun, 29 Nov 2015 15:01:36 +0000 (16:01 +0100)
committermrdudz <mrdudz@users.noreply.github.com>
Sun, 29 Nov 2015 15:01:36 +0000 (16:01 +0100)
cfg/gamate.cfg
libsrc/gamate/crt0.s
libsrc/gamate/header.s [new file with mode: 0644]
libsrc/gamate/nmi.s [new file with mode: 0644]
testcode/lib/gamate/audiotest.s
testcode/lib/gamate/ctest.c
testcode/lib/gamate/lcdtest.s
util/gamate/gamate-fixcart.c

index 577dfeb1d8fb9319dfa89cb7ada26e169038da81..d7c87b455c8c399e39e2dec9f985d30d1d734500 100644 (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;
index b54d8ade1137fcb6fa2a76d178b00ad24f678223..5df5ad38cd6df7c6ad0ade8694d6d93bc3a35509 100644 (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
diff --git a/libsrc/gamate/header.s b/libsrc/gamate/header.s
new file mode 100644 (file)
index 0000000..da15a51
--- /dev/null
@@ -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 (file)
index 0000000..9184313
--- /dev/null
@@ -0,0 +1,7 @@
+;
+; NMI handling (Gamate version)
+;
+        .export NMIStub
+
+NMIStub:
+        rts
\ No newline at end of file
index 2fa38a500a8cb456a48791dc04d0f9b88488db23..1b5d22767e26d3a7718fb3a54d47f1f6ad52ca9a 100644 (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
index da81bf240c6d7613928eb5f642d2400e475733e0..dfebd9befc8a12e31db163bbb96a0e0415554a4d 100644 (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;
index 41242a982e3809a8e9b814a93f58c43b06991971..3ac8f968bb48f51531b66f1e31d123287339848f 100644 (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
index a994838440a37eb64e7adcdef7b2e59bf752abd8..e3883246136d1e97f6e0ac0a0ccec544531f89fb 100644 (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);
 }