]> git.sur5r.net Git - cc65/commitdiff
Added basic frame for new target 'creativision'.
authorOliver Schmidt <ol.sc@web.de>
Mon, 25 Nov 2013 21:52:04 +0000 (22:52 +0100)
committerOliver Schmidt <ol.sc@web.de>
Mon, 25 Nov 2013 21:52:04 +0000 (22:52 +0100)
Kym Greenshields <kym.greenshields@gmail.com> has expressed interest
in contributing and maintaining support for the VTech CreatiVision system.

cfg/creativision.cfg [new file with mode: 0644]
libsrc/Makefile
libsrc/creativision/crt0.s [new file with mode: 0644]
src/ca65/main.c
src/cc65/main.c
src/common/target.c
src/common/target.h

diff --git a/cfg/creativision.cfg b/cfg/creativision.cfg
new file mode 100644 (file)
index 0000000..9122ccd
--- /dev/null
@@ -0,0 +1,35 @@
+SYMBOLS {
+    __STACKSIZE__: type = weak, value = $0180;
+}
+MEMORY {
+    ZP:  file = "", define = yes, start = $0020, size = $00E0;
+    RAM: file = "", define = yes, start = $01FA, size = $0206;
+    ROM: file = %O, define = yes, start = $B000, size = $1000;
+}
+SEGMENTS {
+    ZEROPAGE: load = ZP,             type = zp;
+    ZP:       load = ZP,             type = zp,                optional = yes;
+    VECTORS:  load = ROM, run = RAM, type = rw,  define = yes;
+    DATA:     load = ROM, run = RAM, type = rw,  define = yes,                 start = $0204;
+    BSS:      load = RAM,            type = bss, define = yes;
+    CODE:     load = ROM,            type = ro;
+    INIT:     load = ROM,            type = ro;
+    RODATA:   load = ROM,            type = ro;
+    AUDIO:    load = ROM,            type = ro,                optional = yes, start = $BF00;
+    SETUP:    load = ROM,            type = ro,                                start = $BFE8;
+}
+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__;
+}
index d855d15807fb59febe0a91600223405a9c93d647..f65515abc0dbb81b67a9303e0bb3d5403e3f8d8f 100644 (file)
@@ -10,17 +10,18 @@ CBMS = c128   \
 GEOS = geos-apple \
        geos-cbm
 
-TARGETS = apple2    \
-          apple2enh \
-          atari     \
-          atarixl   \
-          atmos     \
-          $(CBMS)   \
-          $(GEOS)   \
-          lynx      \
-          nes       \
-          sim6502   \
-          sim65c02  \
+TARGETS = apple2       \
+          apple2enh    \
+          atari        \
+          atarixl      \
+          atmos        \
+          creativision \
+          $(CBMS)      \
+          $(GEOS)      \
+          lynx         \
+          nes          \
+          sim6502      \
+          sim65c02     \
           supervision
 
 DRVTYPES = emd \
diff --git a/libsrc/creativision/crt0.s b/libsrc/creativision/crt0.s
new file mode 100644 (file)
index 0000000..ccae38e
--- /dev/null
@@ -0,0 +1,102 @@
+;
+; Startup code for cc65 (CreatiVision version)
+;
+
+        .export         _exit
+        .export         __STARTUP__ : absolute = 1      ; Mark as startup
+        .import         zerobss, copydata
+        .import         initlib, donelib, callmain
+        .import         __VECTORS_LOAD__, __VECTORS_RUN__, __VECTORS_SIZE__
+        .import         __ZP_LAST__, __STACKSIZE__, __RAM_START__
+
+        .include        "zeropage.inc"
+
+; ------------------------------------------------------------------------
+
+entry:
+        ; Init the CPU
+        sei
+        cld
+
+        ; Copy the IRQ vectors
+        ldx     #<__VECTORS_SIZE__ - 1
+:       lda     __VECTORS_LOAD__,x
+        sta     __VECTORS_RUN__,x
+        dex
+        bpl     :-
+
+        ; Setup the CPU stack ptr
+        ldx     #<__RAM_START__ - 1
+        txs
+
+        ; Start interrupts
+        cli
+
+        ; Clear the BSS data
+        jsr     zerobss
+
+        ; Copy data from ROM to RAM
+        jsr     copydata
+
+        ; Setup the argument stack ptr
+        lda     #<(__ZP_LAST__ + __STACKSIZE__)
+        ldx     #>(__ZP_LAST__ + __STACKSIZE__)
+        sta     sp
+        stx     sp+1
+
+        ; Call module constructors
+        jsr     initlib
+
+        ; Call main()
+        jsr     callmain
+
+        ; Call module destructors. This is also the _exit entry.
+_exit:  jsr     donelib
+
+        ; TODO: Replace with some sort of reset
+loop:   jmp loop
+
+; ------------------------------------------------------------------------
+; Define the IRQ vectors.
+
+.segment        "VECTORS"
+
+irq1:   jmp     $FF3F
+irq2:   jmp     $FF52
+
+; ------------------------------------------------------------------------
+; Define CART setup values for BIOS.
+
+.segment        "SETUP"
+
+        ; BIOS Jump Start
+        ; This is where the entry point of the program needs to be
+        .addr   entry
+        .addr   irq2
+
+        .res    4
+
+        ; VDP Setup
+        ; This sets to Graphics Mode 1
+        .byte   $00             ; Register 0
+        .byte   $C0             ; Register 1 16K RAM, Active Display, Mode 1
+        .byte   $04             ; Register 2 Name Table at $1000 - $12FF
+        .byte   $60             ; Register 3 Colour Table at $1800 - $181F
+        .byte   $00             ; Register 4 Pattern Table at $0000 - $07FF
+        .byte   $10             ; Register 5 Sprite Attribute at $0800 - $087F
+        .byte   $01             ; Register 6 Sprite Pattern
+        .byte   $F1             ; Register 7 Text colour Foreground / background
+
+        .res    4
+
+        ; BIOS Vector after NMI or RESET
+        ; Keeping with retail cartridges, we jump back to BIOS ROM and have it
+        ; setup zeropage etc, and show the Creativision logo and copyright.
+        .addr $F808
+
+        ; BIOS Short Interrupt Handler
+        ; Vectored from BIOS ROM:FE2C. This should contain a pointer to the user's
+        ; BIOS interrupt handler.
+        .addr irq1
+
+; ------------------------------------------------------------------------
index 4b2f9d1781a8ac6083b094c347ad4f05d2cb40e2..3b68d30fae7885bee5d78cb35b6f2153ffc9d191 100644 (file)
@@ -246,10 +246,6 @@ static void SetSys (const char* Sys)
             CBMSystem ("__PET__");
             break;
 
-        case TGT_BBC:
-            NewSymbol ("__BBC__", 1);
-            break;
-
         case TGT_APPLE2:
             NewSymbol ("__APPLE2__", 1);
             break;
@@ -259,10 +255,16 @@ static void SetSys (const char* Sys)
             NewSymbol ("__APPLE2ENH__", 1);
             break;
 
-        case TGT_GEOS_CBM:
-            /* Do not handle as a CBM system */
-            NewSymbol ("__GEOS__", 1);
-            NewSymbol ("__GEOS_CBM__", 1);
+        case TGT_ATMOS:
+            NewSymbol ("__ATMOS__", 1);
+            break;
+
+        case TGT_BBC:
+            NewSymbol ("__BBC__", 1);
+            break;
+
+        case TGT_CREATIVISION:
+            NewSymbol ("__CREATIVISION__", 1);
             break;
 
         case TGT_GEOS_APPLE:
@@ -270,26 +272,24 @@ static void SetSys (const char* Sys)
             NewSymbol ("__GEOS_APPLE__", 1);
             break;
 
+        case TGT_GEOS_CBM:
+            /* Do not handle as a CBM system */
+            NewSymbol ("__GEOS__", 1);
+            NewSymbol ("__GEOS_CBM__", 1);
+            break;
+
         case TGT_LUNIX:
             NewSymbol ("__LUNIX__", 1);
             break;
 
-        case TGT_ATMOS:
-            NewSymbol ("__ATMOS__", 1);
+        case TGT_LYNX:
+            NewSymbol ("__LYNX__", 1);
             break;
 
         case TGT_NES:
             NewSymbol ("__NES__", 1);
             break;
 
-        case TGT_SUPERVISION:
-            NewSymbol ("__SUPERVISION__", 1);
-            break;
-
-        case TGT_LYNX:
-            NewSymbol ("__LYNX__", 1);
-            break;
-
         case TGT_SIM6502:
             NewSymbol ("__SIM6502__", 1);
             break;
@@ -298,6 +298,10 @@ static void SetSys (const char* Sys)
             NewSymbol ("__SIM65C02__", 1);
             break;
 
+        case TGT_SUPERVISION:
+            NewSymbol ("__SUPERVISION__", 1);
+            break;
+
         default:
             AbEnd ("Invalid target name: `%s'", Sys);
 
index a27822ed8718fe58d700fd7125ae00987bb81b38..0e7a4d05dc9b088cbbe2ea7910049278e0f735f3 100644 (file)
@@ -202,10 +202,6 @@ static void SetSys (const char* Sys)
             cbmsys ("__PET__");
             break;
 
-        case TGT_BBC:
-            DefineNumericMacro ("__BBC__", 1);
-            break;
-
         case TGT_APPLE2:
             DefineNumericMacro ("__APPLE2__", 1);
             break;
@@ -215,10 +211,16 @@ static void SetSys (const char* Sys)
             DefineNumericMacro ("__APPLE2ENH__", 1);
             break;
 
-        case TGT_GEOS_CBM:
-            /* Do not handle as a CBM system */
-            DefineNumericMacro ("__GEOS__", 1);
-            DefineNumericMacro ("__GEOS_CBM__", 1);
+        case TGT_ATMOS:
+            DefineNumericMacro ("__ATMOS__", 1);
+            break;
+
+        case TGT_BBC:
+            DefineNumericMacro ("__BBC__", 1);
+            break;
+
+        case TGT_CREATIVISION:
+            DefineNumericMacro ("__CREATIVISION__", 1);
             break;
 
         case TGT_GEOS_APPLE:
@@ -226,26 +228,24 @@ static void SetSys (const char* Sys)
             DefineNumericMacro ("__GEOS_APPLE__", 1);
             break;
 
+        case TGT_GEOS_CBM:
+            /* Do not handle as a CBM system */
+            DefineNumericMacro ("__GEOS__", 1);
+            DefineNumericMacro ("__GEOS_CBM__", 1);
+            break;
+
         case TGT_LUNIX:
             DefineNumericMacro ("__LUNIX__", 1);
             break;
 
-        case TGT_ATMOS:
-            DefineNumericMacro ("__ATMOS__", 1);
+        case TGT_LYNX:
+            DefineNumericMacro ("__LYNX__", 1);
             break;
 
         case TGT_NES:
             DefineNumericMacro ("__NES__", 1);
             break;
 
-        case TGT_SUPERVISION:
-            DefineNumericMacro ("__SUPERVISION__", 1);
-            break;
-
-        case TGT_LYNX:
-            DefineNumericMacro ("__LYNX__", 1);
-            break;
-
         case TGT_SIM6502:
             DefineNumericMacro ("__SIM6502__", 1);
             break;
@@ -254,6 +254,10 @@ static void SetSys (const char* Sys)
             DefineNumericMacro ("__SIM65C02__", 1);
             break;
 
+        case TGT_SUPERVISION:
+            DefineNumericMacro ("__SUPERVISION__", 1);
+            break;
+
         default:
             AbEnd ("Unknown target system type %d", Target);
     }
index a4287ee5699a473827e5ffd08af89fd74f4e2f90..b40c3750e909f55d0c3b6d5986f23450912b30f1 100644 (file)
@@ -114,7 +114,7 @@ static const unsigned char CTPET [256] = {
 /* One entry in the target map */
 typedef struct TargetEntry TargetEntry;
 struct TargetEntry {
-    char        Name[12];               /* Target name */
+    char        Name[13];               /* Target name */
     target_t    Id;                     /* Target id */
 };
 
@@ -133,6 +133,7 @@ static const TargetEntry TargetMap[] = {
     {   "c64",          TGT_C64         },
     {   "cbm510",       TGT_CBM510      },
     {   "cbm610",       TGT_CBM610      },
+    {   "creativision", TGT_CREATIVISION},
     {   "geos",         TGT_GEOS_CBM    },
     {   "geos-apple",   TGT_GEOS_APPLE  },
     {   "geos-cbm",     TGT_GEOS_CBM    },
@@ -166,18 +167,19 @@ static const TargetProperties PropertyTable[TGT_COUNT] = {
     { "cbm510",         CPU_6502,       BINFMT_BINARY,      CTPET   },
     { "cbm610",         CPU_6502,       BINFMT_BINARY,      CTPET   },
     { "pet",            CPU_6502,       BINFMT_BINARY,      CTPET   },
-    { "bbc",            CPU_6502,       BINFMT_BINARY,      CTNone  },
     { "apple2",         CPU_6502,       BINFMT_BINARY,      CTNone  },
     { "apple2enh",      CPU_65C02,      BINFMT_BINARY,      CTNone  },
-    { "geos-cbm",       CPU_6502,       BINFMT_BINARY,      CTNone  },
+    { "atmos",          CPU_6502,       BINFMT_BINARY,      CTNone  },
+    { "bbc",            CPU_6502,       BINFMT_BINARY,      CTNone  },
+    { "creativision",   CPU_6502,       BINFMT_BINARY,      CTNone  },
     { "geos-apple",     CPU_65C02,      BINFMT_BINARY,      CTNone  },
+    { "geos-cbm",       CPU_6502,       BINFMT_BINARY,      CTNone  },
     { "lunix",          CPU_6502,       BINFMT_O65,         CTNone  },
-    { "atmos",          CPU_6502,       BINFMT_BINARY,      CTNone  },
-    { "nes",            CPU_6502,       BINFMT_BINARY,      CTNone  },
-    { "supervision",    CPU_65SC02,     BINFMT_BINARY,      CTNone  },
     { "lynx",           CPU_65C02,      BINFMT_BINARY,      CTNone  },
+    { "nes",            CPU_6502,       BINFMT_BINARY,      CTNone  },
     { "sim6502",        CPU_6502,       BINFMT_BINARY,      CTNone  },
     { "sim65c02",       CPU_65C02,      BINFMT_BINARY,      CTNone  },
+    { "supervision",    CPU_65SC02,     BINFMT_BINARY,      CTNone  },
 };
 
 /* Target system */
index e1675ad651c08e1f61fdcdec4530e1e8b7d4580d..803248d9c886101946555d381e9bcdd2e8d7b183 100644 (file)
@@ -64,25 +64,26 @@ typedef enum {
     TGT_CBM510,
     TGT_CBM610,
     TGT_PET,
-    TGT_BBC,
     TGT_APPLE2,
     TGT_APPLE2ENH,
-    TGT_GEOS_CBM,
+    TGT_ATMOS,
+    TGT_BBC,
+    TGT_CREATIVISION,
     TGT_GEOS_APPLE,
+    TGT_GEOS_CBM,
     TGT_LUNIX,
-    TGT_ATMOS,
-    TGT_NES,
-    TGT_SUPERVISION,
     TGT_LYNX,
+    TGT_NES,
     TGT_SIM6502,
     TGT_SIM65C02,
+    TGT_SUPERVISION,
     TGT_COUNT                   /* Number of target systems */
 } target_t;
 
 /* Collection of target properties */
 typedef struct TargetProperties TargetProperties;
 struct TargetProperties {
-    const char              Name[12];   /* Name of the target */
+    const char              Name[13];   /* Name of the target */
     cpu_t                   DefaultCPU; /* Default CPU for this target */
     unsigned char           BinFmt;     /* Default binary format for this target */
     const unsigned char*    CharMap;    /* Character translation table */