]> git.sur5r.net Git - cc65/commitdiff
Added C64/C128 SuperCPU accelerator functions and started on a generic framework...
authorMarco van den Heuvel <blackystardust68@yahoo.com>
Tue, 10 Apr 2018 02:36:53 +0000 (19:36 -0700)
committerMarco van den Heuvel <blackystardust68@yahoo.com>
Tue, 10 Apr 2018 02:36:53 +0000 (19:36 -0700)
asminc/accelerator.inc [new file with mode: 0644]
doc/c128.sgml
doc/c64.sgml
doc/funcref.sgml
include/accelerator.h [new file with mode: 0644]
libsrc/c128/acc_detect_scpu.s [new file with mode: 0755]
libsrc/c128/acc_scpu_speed.s [new file with mode: 0755]
libsrc/c64/acc_detect_scpu.s [new file with mode: 0644]
libsrc/c64/acc_scpu_speed.s [new file with mode: 0644]

diff --git a/asminc/accelerator.inc b/asminc/accelerator.inc
new file mode 100644 (file)
index 0000000..1bc8fb1
--- /dev/null
@@ -0,0 +1,34 @@
+;
+; Accelerator definitions.
+;
+
+; ---------------------------------------------------------------------------
+; Speed definitions for all accelerator, to be used as input for the 'set'
+; functions.
+
+
+SPEED_SLOW := $00
+SPEED_FAST := $FF
+
+SPEED_1X    := SPEED_SLOW
+SPEED_2X    :=  2 - 1
+SPEED_3X    :=  3 - 1
+SPEED_4X    :=  4 - 1
+SPEED_5X    :=  5 - 1
+SPEED_6X    :=  6 - 1
+SPEED_7X    :=  7 - 1
+SPEED_8X    :=  8 - 1
+SPEED_10X   := 10 - 1
+SPEED_12X   := 12 - 1
+SPEED_16X   := 16 - 1
+SPEED_20X   := 20 - 1
+
+
+; ---------------------------------------------------------------------------
+; C64/C128 Super CPU cartridge
+
+SuperCPU_Slow       := $D07A
+SuperCPU_Fast       := $D07B
+SuperCPU_Speed_Mode := $D0B8
+SuperCPU_Detect     := $D0BC
+
index 2bfb37a3db38dbcb7ff6b72cacf596e8a1fe4c5c..9af66d62bc529b49153f1cafbe5516db347558d8 100644 (file)
@@ -88,6 +88,18 @@ url="funcref.html" name="function reference"> for declaration and usage.
 </itemize>
 
 
+<sect1>C128-specific accelerator functions<p>
+
+The functions listed below are accelerator functions for the C128. See the <url
+url="funcref.html" name="function reference"> for declaration and usage.
+
+<itemize>
+<item>detect_scpu
+<item>scpu_get_speed
+<item>scpu_set_speed
+</itemize>
+
+
 <sect1>CBM-specific functions<p>
 
 Some functions are available for all (or at least most) of the Commodore
index 7cca1aa0959d9a4a16aa6260b47280df5fca5ac3..05b87a22bb6500b231dbf19899dcb10a85572a63 100644 (file)
@@ -169,6 +169,18 @@ url="funcref.html" name="function reference"> for declaration and usage.
 </itemize>
 
 
+<sect1>C64-specific accelerator functions<p>
+
+The functions listed below are accelerator functions for the C64. See the <url
+url="funcref.html" name="function reference"> for declaration and usage.
+
+<itemize>
+<item>detect_scpu
+<item>scpu_get_speed
+<item>scpu_set_speed
+</itemize>
+
+
 <sect1>CBM-specific functions<p>
 
 Some functions are available for all (or at least most) of the Commodore
index 5f90cfd3e0c2cb14cb9a557453b83eea1549c612..e47a0c0a9ebe00094159ee003a21e03393ec6ba5 100644 (file)
@@ -65,6 +65,15 @@ function.
 </itemize>
 
 
+<sect1><tt/accelerator.h/<label id="accelerator.h"><p>
+
+<itemize>
+<item><ref id="detect_scpu" name="detect_scpu">
+<item><ref id="get_scpu_speed" name="get_scpu_speed">
+<item><ref id="set_scpu_speed" name="set_scpu_speed">
+</itemize>
+
+
 <sect1><tt/apple2.h/<label id="apple2.h"><p>
 
 <itemize>
@@ -2911,6 +2920,26 @@ used in presence of a prototype.
 </quote>
 
 
+<sect1>detect_scpu<label id="detect_scpu"><p>
+
+<quote>
+<descrip>
+<tag/Function/Check for the presence of the C64/C128 SuperCPU cartridge.
+<tag/Header/<tt/<ref id="accelerator.h" name="accelerator.h">/
+<tag/Declaration/<tt/unsigned char detect_scpu (void);/
+<tag/Description/The function returns a 1 if a SuperCPU cartridge has been detected.
+<tag/Notes/<itemize>
+<item>The function is specific to the C128 and C64.
+</itemize>
+<tag/Availability/cc65 (not all platforms)
+<tag/See also/
+<ref id="get_scpu_speed" name="get_scpu_speed">,
+<ref id="set_scpu_speed" name="set_scpu_speed">,
+<tag/Example/None.
+</descrip>
+</quote>
+
+
 <sect1>div<label id="div"><p>
 
 <quote>
@@ -3450,6 +3479,28 @@ header files define constants that can be used to check the return code.
 </quote>
 
 
+<sect1>get_scpu_speed<label id="get_scpu_speed"><p>
+
+<quote>
+<descrip>
+<tag/Function/Get the current speed of the C64/C128 SuperCPU cartridge.
+<tag/Header/<tt/<ref id="accelerator.h" name="accelerator.h">/
+<tag/Declaration/<tt/unsigned char get_scpu_speed (void);/
+<tag/Description/The function returns the current speed of the SuperCPU cartridge.
+<tag/Notes/<itemize>
+<item>The function is specific to the C128 and C64.
+<item>The function does not check for the presence of the cartridge.
+<item>See the accelerator.h header for the speed definitions.
+</itemize>
+<tag/Availability/cc65 (not all platforms)
+<tag/See also/
+<ref id="detect_scpu" name="detect_scpu">,
+<ref id="set_scpu_speed" name="set_scpu_speed">,
+<tag/Example/None.
+</descrip>
+</quote>
+
+
 <sect1>getcpu<label id="getcpu"><p>
 
 <quote>
@@ -6001,6 +6052,28 @@ clean-up when exitting the program.
 </quote>
 
 
+<sect1>set_scpu_speed<label id="set_scpu_speed"><p>
+
+<quote>
+<descrip>
+<tag/Function/Set the current speed of the C64/C128 SuperCPU cartridge.
+<tag/Header/<tt/<ref id="accelerator.h" name="accelerator.h">/
+<tag/Declaration/<tt/unsigned char set_scpu_speed (unsigned char speed);/
+<tag/Description/The function returns the speed after trying to set the speed of the SuperCPU cartridge.
+<tag/Notes/<itemize>
+<item>The function is specific to the C128 and C64.
+<item>The function does not check for the presence of the cartridge.
+<item>See the accelerator.h header for the speed definitions.
+</itemize>
+<tag/Availability/cc65 (not all platforms)
+<tag/See also/
+<ref id="detect_scpu" name="detect_scpu">,
+<ref id="get_scpu_speed" name="get_scpu_speed">,
+<tag/Example/None.
+</descrip>
+</quote>
+
+
 <sect1>setjmp<label id="setjmp"><p>
 
 <quote>
diff --git a/include/accelerator.h b/include/accelerator.h
new file mode 100644 (file)
index 0000000..7d12442
--- /dev/null
@@ -0,0 +1,102 @@
+/*****************************************************************************/
+/*                                                                           */
+/*                               accelerator.h                               */
+/*                                                                           */
+/*                      Accelerator specific definitions                     */
+/*                                                                           */
+/*                                                                           */
+/*                                                                           */
+/* (C) 2018 Marco van den Heuvel                                             */
+/* EMail:        blackystardust68@yahoo.com                                  */
+/*                                                                           */
+/*                                                                           */
+/* This software is provided 'as-is', without any expressed or implied       */
+/* warranty.  In no event will the authors be held liable for any damages    */
+/* arising from the use of this software.                                    */
+/*                                                                           */
+/* Permission is granted to anyone to use this software for any purpose,     */
+/* including commercial applications, and to alter it and redistribute it    */
+/* freely, subject to the following restrictions:                            */
+/*                                                                           */
+/* 1. The origin of this software must not be misrepresented; you must not   */
+/*    claim that you wrote the original software. If you use this software   */
+/*    in a product, an acknowledgment in the product documentation would be  */
+/*    appreciated but is not required.                                       */
+/* 2. Altered source versions must be plainly marked as such, and must not   */
+/*    be misrepresented as being the original software.                      */
+/* 3. This notice may not be removed or altered from any source              */
+/*    distribution.                                                          */
+/*                                                                           */
+/*****************************************************************************/
+
+
+
+#ifndef _ACCELERATOR_H
+#define _ACCELERATOR_H
+
+/*****************/
+/* Speed defines */
+/*****************/
+
+#define SPEED_SLOW   0x00
+#define SPEED_FAST   0xFF
+
+#define SPEED_1X   SPEED_SLOW
+#define SPEED_2X    2 - 1        /* C64 Chameleon, C64DTV, C128, PET 65816, Apple2 Fast Chip, Apple2 TransWarp, Apple2 Zip Chip */
+#define SPEED_3X    3 - 1        /* C64 Chameleon, C65, PET 65816, Apple2 Booster, Apple 2 Fast Chip, Apple2 Titan, Apple2 TransWarp, Apple2 Zip Chip */
+#define SPEED_4X    4 - 1        /* C64 Chameleon, C64 TurboMaster, C64 TurboProcess, PET 65816, Apple2 Fast Chip, Apple2 Zip Chip */
+#define SPEED_5X    5 - 1        /* C64 Chameleon, PET 65816, Apple2 Fast Chip */
+#define SPEED_6X    6 - 1        /* C64 Chameleon, PET 65816, Apple2 Fast Chip */
+#define SPEED_7X    7 - 1        /* PET 65816, Apple2 Fast Chip */
+#define SPEED_8X    8 - 1        /* C64 Flash8, PET 65816, Apple 2 Fast Chip */
+#define SPEED_10X  10 - 1        /* PET 65816, Apple2 Fast Chip */
+#define SPEED_12X  12 - 1        /* Apple2 Fast Chip */
+#define SPEED_16X  16 - 1        /* Apple2 Fast Chip */
+#define SPEED_20X  20 - 1        /* C64/C128 SuperCPU */
+
+/***********************************/
+/* Accelerator function prototypes */
+/***********************************/
+
+/* C64/C128 SuperCPU cartridge */
+
+extern unsigned char __fastcall__ set_scpu_speed (unsigned char speed);
+
+/* Set the speed of the SuperCPU cartridge, using SPEED_SLOW will switch to
+ * 1 Mhz mode, SPEED_20X or SPEED_FAST will switch to 20 Mhz mode.
+ *
+ * Note that any value lower than SPEED_20X will switch to 1 Mhz mode, and
+ * any value higher or equal to SPEED_20X will switch to 20 Mhz mode.
+ *
+ * This function will return the actual speed the CPU is at after trying
+ * to set the requested speed, if this is not the speed that was requested
+ * then possibly the hardware speed switch prevented any software speed
+ * switching.
+ *
+ * This function does not check for the presence of the SuperCPU cartridge,
+ * make sure you use 'detect_scpu();' before using.
+ */
+
+extern unsigned char get_scpu_speed (void);
+
+/* Get the speed of the SuperCPU cartridge.
+ *
+ * Possible return values:
+ * SPEED_1X    :  1 Mhz mode
+ * SPEED_20X   : 20 Mhz mode
+ *
+ * This function does not check for the presence of the SuperCPU cartridge,
+ * make sure you use 'detect_scpu();' before using.
+ */
+
+extern unsigned char detect_scpu (void);
+
+/* Check for the presence of the SuperCPU cartridge.
+ *
+ * Possible return values:
+ * 0x00  : SuperCPU cartridge not present
+ * 0x01  : SuperCPU cartridge present
+ */
+
+/* End of accelerator.h */
+#endif
diff --git a/libsrc/c128/acc_detect_scpu.s b/libsrc/c128/acc_detect_scpu.s
new file mode 100755 (executable)
index 0000000..e42d905
--- /dev/null
@@ -0,0 +1,34 @@
+;
+; Marco van den Heuvel, 2018-04-08
+;
+
+; unsigned char detect_scpu (void);
+;
+;/* Check for the presence of the SuperCPU cartridge.
+; *
+; * Possible return values:
+; * 0x00  : SuperCPU cartridge not present
+; * 0x01  : SuperCPU cartridge present
+; */
+
+        .export         _detect_scpu
+
+        .include        "accelerator.inc"
+_detect_scpu:
+        ldx     #$00
+        txa
+
+; Make sure the current CPU is a 65816
+        clc
+        .byte   $E2,$01                ; NOP #$01 on 6510 and 65(S)C02, LDA $(01,S),Y on 65CE02 and 4510, SEP #$01 on 65816
+        bcc     not_found              ; carry will be set on 65816
+
+; 65816 has been detected, make sure it's the SuperCPU cartridge
+
+        lda     SuperCPU_Detect
+        asl
+        bcs     not_found
+found:
+        lda     #$01
+not_found:
+        rts
diff --git a/libsrc/c128/acc_scpu_speed.s b/libsrc/c128/acc_scpu_speed.s
new file mode 100755 (executable)
index 0000000..4bd142b
--- /dev/null
@@ -0,0 +1,59 @@
+;
+; Marco van den Heuvel, 2018-04-09
+;
+
+; extern unsigned char __fastcall__ set_scpu_speed (unsigned char speed);
+;
+;/* Set the speed of the SuperCPU cartridge, using SPEED_SLOW will switch to
+; * 1 Mhz mode, SPEED_20X or SPEED_FAST will switch to 20 Mhz mode.
+; *
+; * Note that any value lower than SPEED_20X will switch to 1 Mhz mode, and
+; * any value higher or equal to SPEED_20X will switch to 20 Mhz mode.
+; *
+; * This function will return the actual speed the CPU is at after trying
+; * to set the requested speed, if this is not the speed that was requested
+; * then possibly the hardware speed switch prevented any software speed
+; * switching.
+; *
+; * This function does not check for the presence of the SuperCPU cartridge,
+; * make sure you use 'detect_scpu();' before using.
+; */
+
+; extern unsigned char get_scpu_speed (void);
+;
+;/* Get the speed of the SuperCPU cartridge.
+; *
+; * Possible return values:
+; * SPEED_1X    :  1 Mhz mode
+; * SPEED_20X   : 20 Mhz mode
+; *
+; * This function does not check for the presence of the SuperCPU cartridge,
+; * make sure you use 'detect_scpu();' before using.
+; */
+
+        .export         _set_scpu_speed
+        .export         _get_scpu_speed
+
+        .include        "accelerator.inc"
+
+_set_scpu_speed:
+        cmp     #SPEED_20X
+        bcs     high_speed
+low_speed:
+        sta     SuperCPU_Slow
+        jmp     _get_scpu_speed
+
+high_speed:
+        sta     SuperCPU_Fast
+
+_get_scpu_speed:
+        ldx     #$00
+        lda     SuperCPU_Speed_Mode
+        asl
+        asl
+        bcc     is_fast_speed
+        lda     #SPEED_1X
+        rts
+is_fast_speed:
+        lda     #SPEED_20X
+        rts
diff --git a/libsrc/c64/acc_detect_scpu.s b/libsrc/c64/acc_detect_scpu.s
new file mode 100644 (file)
index 0000000..e42d905
--- /dev/null
@@ -0,0 +1,34 @@
+;
+; Marco van den Heuvel, 2018-04-08
+;
+
+; unsigned char detect_scpu (void);
+;
+;/* Check for the presence of the SuperCPU cartridge.
+; *
+; * Possible return values:
+; * 0x00  : SuperCPU cartridge not present
+; * 0x01  : SuperCPU cartridge present
+; */
+
+        .export         _detect_scpu
+
+        .include        "accelerator.inc"
+_detect_scpu:
+        ldx     #$00
+        txa
+
+; Make sure the current CPU is a 65816
+        clc
+        .byte   $E2,$01                ; NOP #$01 on 6510 and 65(S)C02, LDA $(01,S),Y on 65CE02 and 4510, SEP #$01 on 65816
+        bcc     not_found              ; carry will be set on 65816
+
+; 65816 has been detected, make sure it's the SuperCPU cartridge
+
+        lda     SuperCPU_Detect
+        asl
+        bcs     not_found
+found:
+        lda     #$01
+not_found:
+        rts
diff --git a/libsrc/c64/acc_scpu_speed.s b/libsrc/c64/acc_scpu_speed.s
new file mode 100644 (file)
index 0000000..4bd142b
--- /dev/null
@@ -0,0 +1,59 @@
+;
+; Marco van den Heuvel, 2018-04-09
+;
+
+; extern unsigned char __fastcall__ set_scpu_speed (unsigned char speed);
+;
+;/* Set the speed of the SuperCPU cartridge, using SPEED_SLOW will switch to
+; * 1 Mhz mode, SPEED_20X or SPEED_FAST will switch to 20 Mhz mode.
+; *
+; * Note that any value lower than SPEED_20X will switch to 1 Mhz mode, and
+; * any value higher or equal to SPEED_20X will switch to 20 Mhz mode.
+; *
+; * This function will return the actual speed the CPU is at after trying
+; * to set the requested speed, if this is not the speed that was requested
+; * then possibly the hardware speed switch prevented any software speed
+; * switching.
+; *
+; * This function does not check for the presence of the SuperCPU cartridge,
+; * make sure you use 'detect_scpu();' before using.
+; */
+
+; extern unsigned char get_scpu_speed (void);
+;
+;/* Get the speed of the SuperCPU cartridge.
+; *
+; * Possible return values:
+; * SPEED_1X    :  1 Mhz mode
+; * SPEED_20X   : 20 Mhz mode
+; *
+; * This function does not check for the presence of the SuperCPU cartridge,
+; * make sure you use 'detect_scpu();' before using.
+; */
+
+        .export         _set_scpu_speed
+        .export         _get_scpu_speed
+
+        .include        "accelerator.inc"
+
+_set_scpu_speed:
+        cmp     #SPEED_20X
+        bcs     high_speed
+low_speed:
+        sta     SuperCPU_Slow
+        jmp     _get_scpu_speed
+
+high_speed:
+        sta     SuperCPU_Fast
+
+_get_scpu_speed:
+        ldx     #$00
+        lda     SuperCPU_Speed_Mode
+        asl
+        asl
+        bcc     is_fast_speed
+        lda     #SPEED_1X
+        rts
+is_fast_speed:
+        lda     #SPEED_20X
+        rts