Is there a simple PEEK (or machine language equivalent) which will tell if the SCPU is running at "enhanced" 20MHz speed or "stock" 1MHz/2MHz speed ?
I need to know this to make SAM 128 friendly and reliable for any C128 user. You'll get credit in the source code and my web page. Thanks!
If all else fails, I could try counting CPU cycles during a VIC raster. If an insane value like 1280 cycles occurs (normally only 63 or 65 for PAL/NTSC) then I could assume the user is running an SCPU at full speed. But that would require a moderate amount of code, and I would prefer to keep SAM 128 compact.
I don't know if this is any help but, here is what I dug up on it.
Detecting a SuperCPU
With the knowledge we have gained so far we are able to write programs that are 100% compatible to CMD's accelerator board and even can benefit from the presence of a SuperCPU. If you want to let your program "know" whether it is executed by a SuperCPU or a plain Commodore system, this can be done in a simple way: Just check whether bit 7 of $D0BC (a special SuperCPU register) is zero. A plain C64 always returns a one, like every read from an I/O address that is not used. But on a SuperCPU, this bit is zero - thus giving us the possibility to easily detect a SuperCPU. Once detected, we are able to select alternative routines for SuperCPU owners, or even use full SuperCPU only programs which could take advantage of all the powerful new opcodes and addressing modes the 65816 offers.
$D0B0 6 (53424) - SuperCPU Mode Detect Register 00xxxxxx - SuperCPU V2 in 128 mode 01xxxxxx - SuperCPU V2 in 64 mode 11xxxxxx - SuperCPU V1, No SuperCPU or SuperCPU disabled.
$D0B2 4 (53426) - Bit 7: Hardware Register Enable Flag (1=Enabled) - Bit 6: System 1 MHZ Flag (1=Enabled)
$D0B3 3,7 (53427) - Enhanced Optimization Register (V2 Only) 00xxx1BZ - VIC Bank 0, $0000-$3FFFF 01xxx0B0 - VIC Bank 1, $4000-$7FFFF 00xxx0B0 - VIC Bank 2/GEOS, $8000-$BFFF 01xxx1B0 - VIC Bank 3, $C000-$FFFF 10xxx0B0 - BASIC Opt., $0400-$07FF 11xxx00Z - No Opt. All Mem., $0:0000-$1:FFFF (V2 deafult) 11xxx1BZ - No Opt. per Bank, $0000-$FFFF 10xxx100 - Full Optimization (no mirroring of any memory)
$D0B4 5 (53428) - Bits 7 & 6: Optimization Mode Flags: 00xxxxxx - VIC Bank2/GEOS Optimization Enabled 01xxxxxx - VIC Bank 1 Optimization Enabled 10xxxxxx - BASIC Optimization Enabled 11xxxxxx - No Optimization $D0B5 6 (53429) - Bit 7: JiffyDOS Switch Flag (1=Enabled) Bit 6: Speed Switch Flag (1=Normal, 0=Turbo) $D0B6 6 (53430) - Bit 7: Processor Emulation Mode Flag (1=Emulation) Bit 6: Reset Switch Flag (1=Switch Pressed)(V1 only) $D0B8 4 (53432) - Bit 7: Software Speed Flag (1=Normal, 0=Turbo) Bit 6: Master Speed Flag (1=Normal via any source) $D0BC 6 (53436) - Bit 7: DOS Extension Mode Flag (1=Enabled) Bit 6: RAMLink Hardware Register Flag (1=Enabled)
$D200 - $D2FF 4 - System Ram (53760 - 54015) $D300 - $D3FF 5 - User RAM (available for user programs) (54016 - 54271)
1 Write only, hardware registers must be enabled to activate location. 2 Write only, active with hardware registers enabled or disabled. 3 Write only, active with hardware registers enabled or disabled, but does not override hardware Speed switch. 4 Read only with hardware registers disabled, Read/Write with hardware registers enabled, write access reserved for system use only. 5 Read only with hardware registers disabled, Read/Write with hardware registers enabled. 6 Read only with hardware registers enabled or disabled (write with hardware registers enabled has no effect). 7 Changing values in this area affects all other optimization mode registers, and changing other optimization mode registers affect this location. The B flag assigns control of this register to a specific Commodore 128 Bank (0=Bank 0, 1=Bank 1), while the Z flag controls mirroring of Zero Page and Stack memory ($0000-$01ff)(0=mirroring on, 1=mirroring off). The default for Z is 1, B is 0. * Denotes a duplicate register location.
IMPORTANT NOTE: Enabling the SuperCPU hardware registers also causes some changes in the Kernal ROM memory map ($E000-$FFFF). To avoid problems, do not leave the hardware registers enabled any longer than necessary. Also, note that mirroring of I/O is always performed when I/O is mapped in.