From 6dc461d184d178cefb4d6084ee8739489a40b970 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Thu, 22 Oct 2020 20:07:53 +0200 Subject: [PATCH] small tape support + turbo mode tweaks --- Makefile | 1 + src/aliases/,aliases_ram_lowmem.s | 2 +- src/basic/,imports.s | 7 +++++ src/basic/basic_commands_01/cmd_fast_slow.s | 13 ++------- src/kernal/board_m65/mega65_tape_fast_cpu.s | 31 +++++++++++++++++++++ src/kernal/board_u64/ultimate64_slow_fast.s | 22 +++++++++++++++ src/kernal/init/fce2.hw_entry_reset.s | 6 ++++ src/kernal/tape/tape_common_screen.s | 20 ++----------- src/kernal/tape/tape_head_align.s | 11 ++++++++ 9 files changed, 84 insertions(+), 29 deletions(-) create mode 100644 src/kernal/board_m65/mega65_tape_fast_cpu.s create mode 100644 src/kernal/board_u64/ultimate64_slow_fast.s diff --git a/Makefile b/Makefile index c08d2f56..01e8a236 100644 --- a/Makefile +++ b/Makefile @@ -45,6 +45,7 @@ SRCDIR_KERNAL = $(SRCDIR_COMMON) \ src/kernal/assets \ src/kernal/board_crt \ src/kernal/board_m65 \ + src/kernal/board_u64 \ src/kernal/board_x16 \ src/kernal/extapi_m65 \ src/kernal/iec \ diff --git a/src/aliases/,aliases_ram_lowmem.s b/src/aliases/,aliases_ram_lowmem.s index f8e53af8..151c261a 100644 --- a/src/aliases/,aliases_ram_lowmem.s +++ b/src/aliases/,aliases_ram_lowmem.s @@ -121,7 +121,7 @@ !ifndef CONFIG_LEGACY_SCNKEY { !addr BITTS = $B4 ; -- NOT IMPLEMENTED -- } - !addr NXTBIT = $B5 ; -- NOT IMPLEMENTED -- [!] also used by tape routine, we use it only for Ultimate 64 turbo handling + !addr NXTBIT = $B5 ; -- NOT IMPLEMENTED -- [!] also used by tape routine to store CPU turbo settings !ifndef CONFIG_LEGACY_SCNKEY { !addr RODATA = $B6 ; -- NOT IMPLEMENTED -- } diff --git a/src/basic/,imports.s b/src/basic/,imports.s index 1ccbe2c2..fa3bb638 100644 --- a/src/basic/,imports.s +++ b/src/basic/,imports.s @@ -41,3 +41,10 @@ ;; #ALIAS# M65_MODEGET = KERNAL_0.M65_MODEGET ;; #ALIAS# M65_MODESET = KERNAL_0.M65_MODESET ;; #ALIAS# M65_SETWIN_Y = KERNAL_0.M65_SETWIN_Y + +; +; Ultimate 64 specific parts +; + +;; #ALIAS# U64_SLOW = KERNAL_0.U64_SLOW +;; #ALIAS# U64_FAST = KERNAL_0.U64_FAST diff --git a/src/basic/basic_commands_01/cmd_fast_slow.s b/src/basic/basic_commands_01/cmd_fast_slow.s index 891494fe..84e33241 100644 --- a/src/basic/basic_commands_01/cmd_fast_slow.s +++ b/src/basic/basic_commands_01/cmd_fast_slow.s @@ -39,22 +39,13 @@ cmd_slow_fast_common: cmd_slow: - lda #$00 ; for U64_TURBOCTL - badlines, 1MHz sta SCPU_SPEED_NORMAL ; any value will do - - ; FALLTROUGH - -cmd_slow_fast_common: - - sta U64_TURBOCTL - rts + jmp U64_SLOW ; to set turbo in $D031 too cmd_fast: - lda #$0F ; for U64_TURBOCTL - badlines, 48MHz sta SCPU_SPEED_TURBO ; any value will do - - bne cmd_slow_fast_common ; branch always + jmp U64_FAST ; to set turbo in $D031 too } else ifdef CONFIG_PLATFORM_COMMODORE_64 { diff --git a/src/kernal/board_m65/mega65_tape_fast_cpu.s b/src/kernal/board_m65/mega65_tape_fast_cpu.s new file mode 100644 index 00000000..0be56175 --- /dev/null +++ b/src/kernal/board_m65/mega65_tape_fast_cpu.s @@ -0,0 +1,31 @@ +;; #LAYOUT# M65 KERNAL_1 #TAKE +;; #LAYOUT# * * #IGNORE + +; +; Tape helper routine +; +; - unlocks VIC-IV +; - switches CPU to fast processing mode and disables badlines +; - stores previous VIC_CTRLB in NXTBIN +; + +!ifdef HAS_TAPE { + + +tape_fast_cpu: + + jsr M65_MODEGET + bcc @1 + + jsr viciv_unhide +@1: + lda VIC_CTRLB + ora #%01000000 + sta VIC_CTRLB + sta NXTBIT + + lda #$00 + sta MISC_EMU + + rts +} diff --git a/src/kernal/board_u64/ultimate64_slow_fast.s b/src/kernal/board_u64/ultimate64_slow_fast.s new file mode 100644 index 00000000..8d68f5c1 --- /dev/null +++ b/src/kernal/board_u64/ultimate64_slow_fast.s @@ -0,0 +1,22 @@ +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * KERNAL_0 #TAKE +;; #LAYOUT# * * #IGNORE + + +!ifdef CONFIG_MB_U64 { + +U64_SLOW: + + lda #$00 ; for U64_TURBOCTL - badlines, 1MHz + + +skip_2_bytes_trash_nvz + + ; FALLTROUGH + +U64_FAST: + + lda #$0F ; for U64_TURBOCTL - badlines, 48MHz + sta SCPU_SPEED_TURBO ; any value will do + + rts +} diff --git a/src/kernal/init/fce2.hw_entry_reset.s b/src/kernal/init/fce2.hw_entry_reset.s index 3867c990..3f4ac748 100644 --- a/src/kernal/init/fce2.hw_entry_reset.s +++ b/src/kernal/init/fce2.hw_entry_reset.s @@ -32,6 +32,12 @@ hw_entry_reset: jsr m65_reset_part } +!ifdef CONFIG_MB_U64 { + + jsr U64_SLOW + sta SCPU_SPEED_NORMAL +} + !ifdef CONFIG_PLATFORM_COMMODORE_64 { ; The following routine is based on reading the public KERNAL jumptable routine diff --git a/src/kernal/tape/tape_common_screen.s b/src/kernal/tape/tape_common_screen.s index 4b51f55d..51e251cd 100644 --- a/src/kernal/tape/tape_common_screen.s +++ b/src/kernal/tape/tape_common_screen.s @@ -30,8 +30,7 @@ tape_screen_on_motor_off: lda #$03 sta MISC_EMU - lda VIC_CTRLB - and #%10111111 + lda NXTBIT sta VIC_CTRLB sta VIC_KEY @@ -70,18 +69,7 @@ tape_screen_off_motor_on: ; to be handled by 1 MHz CPU - so in case of compatibility mode, switch CPU to fast speed ; (and disable badlines, so we will not have to blank the screen) - jsr M65_MODEGET - bcc @2 - - jsr viciv_unhide - - lda VIC_CTRLB - ora #%01000000 - sta VIC_CTRLB - - lda #$00 - sta MISC_EMU -@2: + jsr tape_fast_cpu } else ifdef CONFIG_MB_U64 { @@ -90,10 +78,8 @@ tape_screen_off_motor_on: cmp #$FF beq @2 ; branch if no turbo control available - lda #$8F ; max speed, no badlines - sta U64_TURBOCTL + jsr U64_FAST ; max speed, no badlines bne @3 ; branch always - @2: jsr screen_off @3: diff --git a/src/kernal/tape/tape_head_align.s b/src/kernal/tape/tape_head_align.s index 71fec45e..2c3144e9 100644 --- a/src/kernal/tape/tape_head_align.s +++ b/src/kernal/tape/tape_head_align.s @@ -45,6 +45,17 @@ tape_head_align: jsr nmi_lock + ; Switch CPU to fast mode + +!ifdef CONFIG_MB_M65 { + jsr tape_fast_cpu +} + +!ifdef CONFIG_MB_U64 { + jsr U64_FAST + sta SCPU_SPEED_TURBO +} + ; Prepare CIA timers ldx #$02 ; set timer A to 3 ticks