diff --git a/src/dos_m65/dos_enter_exit.s b/src/dos_m65/dos_enter_exit.s index 12b524fe..f05635e9 100644 --- a/src/dos_m65/dos_enter_exit.s +++ b/src/dos_m65/dos_enter_exit.s @@ -5,6 +5,10 @@ dos_ENTER: ; enter DOS context + php + jsr m65_speed_tape_cbdos + plp + sta REG_A stx REG_X sty REG_Y @@ -26,12 +30,8 @@ dos_EXIT: ; exit DOS context with Carry clear dos_EXIT_common: - ldz REG_Z - ldy REG_Y - ldx REG_X lda REG_A - - rts + bra dos_EXIT_A_common dos_EXIT_A_SEC: ; exit DOS context with Carry set, return .A @@ -51,4 +51,8 @@ dos_EXIT_A_common: ldy REG_Y ldx REG_X + php + jsr m65_speed_restore + plp + rts diff --git a/src/dos_m65/dos_imports.s b/src/dos_m65/dos_imports.s index 00e611ae..825cd530 100644 --- a/src/dos_m65/dos_imports.s +++ b/src/dos_m65/dos_imports.s @@ -10,3 +10,5 @@ ;; #ALIAS# kernalstatus_EOI = KERNAL_0.kernalstatus_EOI ;; #ALIAS# kernalstatus_DEVICE_NOT_FOUND = KERNAL_0.kernalstatus_DEVICE_NOT_FOUND +;; #ALIAS# m65_speed_tape_cbdos = KERNAL_0.m65_speed_tape_cbdos +;; #ALIAS# m65_speed_restore = KERNAL_0.m65_speed_restore diff --git a/src/dos_m65/dos_init.s b/src/dos_m65/dos_init.s index 4654eda5..93397519 100644 --- a/src/dos_m65/dos_init.s +++ b/src/dos_m65/dos_init.s @@ -10,7 +10,12 @@ dos_INIT: - jsr dos_ENTER + ; Safer version of 'dos_ENTER' - does not affect speed related registers + + sta REG_A + stx REG_X + sty REG_Y + stz REG_Z ; Set the magic string 'CBDOS' @@ -60,6 +65,12 @@ dos_INIT: sta code_RTS_03 sta code_RTS_04 - ; Exit DOS context + ; Safer version of 'dos_EXIT' - does not affect speed related registers - jmp dos_EXIT + clc + ldz REG_Z + ldy REG_Y + ldx REG_X + lda REG_A + + rts diff --git a/src/kernal/board_m65/mega65_speed.s b/src/kernal/board_m65/mega65_speed.s index 3c274ca3..537671b0 100644 --- a/src/kernal/board_m65/mega65_speed.s +++ b/src/kernal/board_m65/mega65_speed.s @@ -30,13 +30,7 @@ m65_speed_iec: ; Disable badlines and slow interrupt emulation - lda #$00 - sta MISC_EMU - - ; Return - - pla - rts + bra m65_speed_tape_cbdos_ME } @@ -49,11 +43,22 @@ m65_speed_tape_cbdos: bcc @1 jsr viciv_unhide @1: - ; Just set the maximum possible speed + ; Set the maximum possible speed - pha - bra m65_speed_restore_native + lda #%01000000 + tsb VIC_CTRLB + ; FALLTROUGH + +m65_speed_tape_cbdos_ME: + + ; Disable badlines and slow interrupt emulation + + lda #$00 + sta MISC_EMU + + pla + rts m65_speed_restore: