diff --git a/doc/Extended-BASIC.md b/doc/Extended-BASIC.md index eeccfae3..09e7dd35 100644 --- a/doc/Extended-BASIC.md +++ b/doc/Extended-BASIC.md @@ -67,13 +67,9 @@ Saves the binary data from the given memory area. NOTE: for now syntax differs f Resets the machine. In direct mode asks for confirmation first. -### `FAST` (all) +### `FAST`, `SLOW` (all) -Tries to switch the machine to turbo mode - details differ depending on the configured machine / motherboard. - -### `SLOW` (all) - -Tries to switch the machine back to 1 MHz operation mode. +Tries to switch the machine to turbo mode (or back to 1MHz operation mode) - details differ depending on the configured machine / motherboard. On MEGA65 motherboard this is not available in native mode, it is not designed to run in 1MHz due to using compound CPU instructions. ### `OLD` (all) diff --git a/src/basic/,imports.s b/src/basic/,imports.s index 62a37c08..225c956f 100644 --- a/src/basic/,imports.s +++ b/src/basic/,imports.s @@ -29,11 +29,13 @@ ;; #ALIAS# SELDEV = KERNAL_0.SELDEV +; +; MEGA65 specific parts +; + ;; #ALIAS# map_end = KERNAL_0.map_end ;; #ALIAS# map_NORMAL = KERNAL_0.map_NORMAL ;; #ALIAS# M65_MODEGET = KERNAL_0.M65_MODEGET ;; #ALIAS# M65_MODESET = KERNAL_0.M65_MODESET -;; #ALIAS# M65_SLOW = KERNAL_0.M65_SLOW -;; #ALIAS# M65_FAST = KERNAL_0.M65_FAST ;; #ALIAS# M65_SETWIN_Y = KERNAL_0.M65_SETWIN_Y diff --git a/src/basic/basic_commands_01/cmd__jumptable_01.s b/src/basic/basic_commands_01/cmd__jumptable_01.s index 12152493..31ebb526 100644 --- a/src/basic/basic_commands_01/cmd__jumptable_01.s +++ b/src/basic/basic_commands_01/cmd__jumptable_01.s @@ -6,18 +6,9 @@ ; Jumptable for BASIC commands with tokens prefixed by $01 ; -!ifdef CONFIG_MB_M65 { - -!set ITEM_00 = M65_SLOW -!set ITEM_01 = M65_FAST - -} else { !set ITEM_00 = cmd_slow !set ITEM_01 = cmd_fast - -} - !set ITEM_02 = cmd_old ; NOTE! These commands are temporarily placed here, they should be a part of list 02! diff --git a/src/basic/basic_commands_01/cmd_fast_slow.s b/src/basic/basic_commands_01/cmd_fast_slow.s index 7b7adb86..891494fe 100644 --- a/src/basic/basic_commands_01/cmd_fast_slow.s +++ b/src/basic/basic_commands_01/cmd_fast_slow.s @@ -5,6 +5,32 @@ !ifdef CONFIG_MB_M65 { +; NOTE: In native mode the system should not run at 1 MHz speed - it's dangerous, +; as it uses compound instructions, which are not safe in 1MHz mode + +cmd_slow: ; set CPU speed to 1 MHz + + jsr helper_ensure_legacy_mode + + lda #$40 + bra cmd_slow_fast_common + + ; FALLTROUGH + +cmd_fast: ; set CPU speed to 40 MHz + + jsr helper_ensure_legacy_mode + + lda #$41 + + ; FALLTROUGH + +cmd_slow_fast_common: + + sta CPU_D6510 + rts + + ; For MEGA65 Kernal routines are called directly } else ifdef CONFIG_MB_U64 { diff --git a/src/basic/basic_commands_01/helper_ensure_legacy_mode_m65.s b/src/basic/basic_commands_01/helper_ensure_legacy_mode_m65.s new file mode 100644 index 00000000..c49b21d2 --- /dev/null +++ b/src/basic/basic_commands_01/helper_ensure_legacy_mode_m65.s @@ -0,0 +1,10 @@ +;; #LAYOUT# M65 BASIC_0 #TAKE +;; #LAYOUT# * * #IGNORE + + +helper_ensure_legacy_mode: + + jsr M65_MODEGET + +bcc do_LEGACY_MODE_ONLY_error + + rts diff --git a/src/basic/engine_runtime/do_error.s b/src/basic/engine_runtime/do_error.s index baf57e47..acfafcea 100644 --- a/src/basic/engine_runtime/do_error.s +++ b/src/basic/engine_runtime/do_error.s @@ -52,6 +52,14 @@ do_kernal_error: ; .A = KERNAL error code, also almost mat ; Error messages specific to Open ROMs BASIC dialect +!ifdef CONFIG_MB_M65 { + +do_LEGACY_MODE_ONLY_error: + !byte $E6 +do_NATIVE_MODE_ONLY_error: + !byte $E6 +} + do_MEMORY_CORRUPT_error: !byte $E6 diff --git a/src/kernal/board_m65/mega65_imports.s b/src/kernal/board_m65/mega65_imports.s index 8f5a6e78..b74001ec 100644 --- a/src/kernal/board_m65/mega65_imports.s +++ b/src/kernal/board_m65/mega65_imports.s @@ -9,8 +9,6 @@ ;; #ALIAS# CHROUT = KERNAL_0.proxy_K1_CHROUT ;; #ALIAS# STOP = KERNAL_0.STOP -;; #ALIAS# M65_SLOW = KERNAL_0.M65_SLOW -;; #ALIAS# M65_FAST = KERNAL_0.M65_FAST ;; #ALIAS# M65_MODEGET = KERNAL_0.M65_MODEGET ;; #ALIAS# M65_SETWIN_XY = KERNAL_0.M65_SETWIN_XY ;; #ALIAS# M65_SETWIN_WH = KERNAL_0.M65_SETWIN_WH diff --git a/src/kernal/extapi_m65/mega65__jumptable.s b/src/kernal/extapi_m65/mega65__jumptable.s index c20b1b4f..301226a2 100644 --- a/src/kernal/extapi_m65/mega65__jumptable.s +++ b/src/kernal/extapi_m65/mega65__jumptable.s @@ -14,12 +14,6 @@ M65_JMODEGET: M65_JISMODESET: jsr M65_MODESET -M65_JSLOW: - jsr M65_SLOW - -M65_JFAST: - jsr M65_FAST - M65_JSELDEV: jsr SELDEV diff --git a/src/kernal/extapi_m65/mega65_modeset.s b/src/kernal/extapi_m65/mega65_modeset.s index 153a58a8..52a04236 100644 --- a/src/kernal/extapi_m65/mega65_modeset.s +++ b/src/kernal/extapi_m65/mega65_modeset.s @@ -25,13 +25,15 @@ m65_mode64: jsr viciv_shutdown jsr vicii_init - ; Reenable interrupts + ; Switch CPU speed back to normal + + lda #$40 + sta CPU_D6510 + + ; Reenable interrupts and quit cli - - ; Switch CPU speed back to slow and quit - - jmp M65_SLOW + rts m65_mode65: @@ -42,7 +44,8 @@ m65_mode65: ; Switch CPU speed to fast - jsr M65_FAST + lda #$41 + sta CPU_D6510 ; Set the magic string to mark native mode diff --git a/src/kernal/extapi_m65/mega65_slow_fast.s b/src/kernal/extapi_m65/mega65_slow_fast.s deleted file mode 100644 index 8e91796c..00000000 --- a/src/kernal/extapi_m65/mega65_slow_fast.s +++ /dev/null @@ -1,16 +0,0 @@ -;; #LAYOUT# M65 KERNAL_0 #TAKE -;; #LAYOUT# * * #IGNORE - - -M65_SLOW: ; set CPU speed to 1 MHz - - lda #$40 - +skip_2_bytes_trash_nvz - - ; FALLTROUGH - -M65_FAST: ; set CPU speed to 40 MHz - - lda #$41 - sta CPU_D6510 - rts diff --git a/tools/generate_strings.cc b/tools/generate_strings.cc index 43d95f34..65690641 100644 --- a/tools/generate_strings.cc +++ b/tools/generate_strings.cc @@ -276,7 +276,9 @@ const StringEntryList GLOBAL_Errors = { ListType::STRINGS_BASIC, "errors", { true, true, true, true, "EV7_28", "NOT IMPLEMENTED" }, // this message actually differs from the CBM one { false, false, false, false, "EV7_29", "FILE READ" }, // not used for now // STD M65 U64 X16 --- error strings specific to Open ROMs, not present in CBM BASIC dialects - { true, true, true, true, "EOR_2A", "MEMORY CORRUPT" }, + { true, true, true, true, "EOR_2A", "MEMORY CORRUPT" }, + { false, true, false, false, "EOR_2B", "NATIVE MODE ONLY" }, + { false, true, false, false, "EOR_2C", "LEGACY MODE ONLY" }, } }; // BASIC errors - miscelaneous strings