From ffdc67d5ca9ab934e98090e3a8fa5ebf4968b798 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sat, 8 Aug 2020 16:09:03 +0200 Subject: [PATCH] improved tape support with Mega65 native mode --- src/aliases/,aliases_hardware.s | 4 +-- src/aliases/,aliases_hardware_m65.s | 6 +++- src/kernal/board_m65/mega65_imports.s | 5 ++++ src/kernal/extapi_m65/mega65_mode64.s | 11 ++++++- src/kernal/extapi_m65/mega65_mode65.s | 9 ++++++ src/kernal/screen/screen_on.s | 2 +- src/kernal/screen_m65/mega65_scrmodeset.s | 35 ++++++----------------- src/kernal/tape/tape_common_screen.s | 27 ++++++----------- 8 files changed, 49 insertions(+), 50 deletions(-) diff --git a/src/aliases/,aliases_hardware.s b/src/aliases/,aliases_hardware.s index 3a334740..ae0ae762 100644 --- a/src/aliases/,aliases_hardware.s +++ b/src/aliases/,aliases_hardware.s @@ -183,9 +183,9 @@ .label C65_EXTKEYS_PR = $D607 .label C65_EXTKEYS_DDR = $D608 - .label M65_BADL_SLI = $D710 +#endif -#else +#if !CONFIG_MB_MEGA_65 // SuperCPU registers diff --git a/src/aliases/,aliases_hardware_m65.s b/src/aliases/,aliases_hardware_m65.s index 349862c2..e6ca17c8 100644 --- a/src/aliases/,aliases_hardware_m65.s +++ b/src/aliases/,aliases_hardware_m65.s @@ -12,7 +12,7 @@ .label VIC_KEY = $D02F - .label VIC_SCFLAGS = $D031 + .label VIC_CTRLB = $D031 .label VIC_XPOS = $D050 @@ -21,4 +21,8 @@ .label VIC_CHARPTR = $D068 // 3 bytes + // MISC registers + + .label MISC_EMU = $D710 // to enable badlines and slow interrupts + #endif diff --git a/src/kernal/board_m65/mega65_imports.s b/src/kernal/board_m65/mega65_imports.s index 7bd3e874..2fad26b1 100644 --- a/src/kernal/board_m65/mega65_imports.s +++ b/src/kernal/board_m65/mega65_imports.s @@ -11,7 +11,12 @@ .label STOP = KERNAL_0.STOP .label M65_SLOW = KERNAL_0.M65_SLOW .label M65_FAST = KERNAL_0.M65_FAST +.label M65_ISMODE65 = KERNAL_0.M65_ISMODE65 +#if (CONFIG_TAPE_NORMAL || CONFIG_TAPE_TURBO) || (CONFIG_IEC_JIFFYDOS && !CONFIG_MEMORY_MODEL_60K) +.label screen_on = KERNAL_0.screen_on +.label screen_off = KERNAL_0.screen_off +#endif .label hw_entry_reset = KERNAL_0.hw_entry_reset .label return_from_interrupt = KERNAL_0.return_from_interrupt diff --git a/src/kernal/extapi_m65/mega65_mode64.s b/src/kernal/extapi_m65/mega65_mode64.s index 5f534b20..6bbf1847 100644 --- a/src/kernal/extapi_m65/mega65_mode64.s +++ b/src/kernal/extapi_m65/mega65_mode64.s @@ -8,7 +8,7 @@ M65_MODE64: sei - // XXX provide full implementation + // XXX provide full implementation - switch back to normal text mode // Set the magic string to mark legacy mode @@ -17,6 +17,15 @@ M65_MODE64: sta M65_MAGICSTR+1 sta M65_MAGICSTR+2 + // Reenable badlines and slow interrupt emulation + + lda #$03 + sta MISC_EMU + + // Switch to VIC-II mode + + sta VIC_KEY + // Reenable interrupts cli diff --git a/src/kernal/extapi_m65/mega65_mode65.s b/src/kernal/extapi_m65/mega65_mode65.s index fbd26d1b..c48fd2ac 100644 --- a/src/kernal/extapi_m65/mega65_mode65.s +++ b/src/kernal/extapi_m65/mega65_mode65.s @@ -21,10 +21,19 @@ M65_MODE65: lda #$35 // '5' sta M65_MAGICSTR+2 + // XXX find a better place for code below + // Switch VIC to VIC-IV mode jsr viciv_unhide + // Disable badlines and slow interrupt emulation + + lda #$00 + sta MISC_EMU + + // XXX + // Set screen mode to 80x25 lda #$01 diff --git a/src/kernal/screen/screen_on.s b/src/kernal/screen/screen_on.s index 22853c22..57e81c02 100644 --- a/src/kernal/screen/screen_on.s +++ b/src/kernal/screen/screen_on.s @@ -8,7 +8,7 @@ // -#if (CONFIG_TAPE_NORMAL || CONFIG_TAPE_TURBO) && !CONFIG_MB_MEGA_65 +#if (CONFIG_TAPE_NORMAL || CONFIG_TAPE_TURBO) || (CONFIG_IEC_JIFFYDOS && !CONFIG_MEMORY_MODEL_60K) screen_on: diff --git a/src/kernal/screen_m65/mega65_scrmodeset.s b/src/kernal/screen_m65/mega65_scrmodeset.s index 31c37c54..cee7dfa9 100644 --- a/src/kernal/screen_m65/mega65_scrmodeset.s +++ b/src/kernal/screen_m65/mega65_scrmodeset.s @@ -60,38 +60,19 @@ m65_scrmodeset_internal: // entry point for M65_MODE65 stx VIC_SCRNPTR+1 stx M65_SCRTXTBASE+1 - // Set flags for 40/80 columns and 25/50 rows + // Set flags/varaibles for 40/80 columns and 25/50 rows - asl tax - lda VIC_SCFLAGS - jsr_ind_x m65_scrmodeset_flagtab + + lda m65_scrtab_vic_ctrlb,x + sta VIC_CTRLB rts -m65_scrmodeset_flagtab: - - .word m65_scrmodeset_40x25 - .word m65_scrmodeset_80x25 - .word m65_scrmodeset_80x50 -m65_scrmodeset_40x25: +m65_scrtab_vic_ctrlb: - and #$77 - bra !+ - -m65_scrmodeset_80x25: - - and #$F7 - ora #$80 - skip_2_bytes_trash_nvz - - // FALLTROUGH - -m65_scrmodeset_80x50: - - ora #$88 -!: - sta VIC_SCFLAGS - rts + .byte %00000000 // 40x25 + .byte %10000000 // 80x25 + .byte %10000100 // 80x50 diff --git a/src/kernal/tape/tape_common_screen.s b/src/kernal/tape/tape_common_screen.s index 77fd0b95..083e917c 100644 --- a/src/kernal/tape/tape_common_screen.s +++ b/src/kernal/tape/tape_common_screen.s @@ -11,8 +11,6 @@ #if CONFIG_TAPE_NORMAL || CONFIG_TAPE_TURBO -// XXX for Mega65 do not disable screen, just disable badline emulation - tape_screen_on_motor_off: @@ -21,18 +19,14 @@ tape_screen_on_motor_off: lda COLSTORE sta VIC_EXTCOL -#if !CONFIG_MB_MEGA_65 +#if !ROM_LAYOUT_M65 jmp screen_on #else - // On Mega65 just reenable badline emulation - - lda #$FF - sta M65_BADL_SLI - sta VIC_KEY - + jsr M65_ISMODE65 + bne_16 screen_on // MEGA65 native mode does not have badlines, no need to enable/disable screen rts #endif @@ -51,22 +45,19 @@ tape_screen_off_motor_on: lda VIC_EXTCOL sta COLSTORE -#if !CONFIG_MB_MEGA_65 - +#if !ROM_LAYOUT_M65 + jsr screen_off #else - // On Mega65 we do not have to turn the screen off; - // it is enough to disable badline emulation - - jsr viciv_unhide - lda #$00 - sta M65_BADL_SLI + jsr M65_ISMODE65 + beq !+ // MEGA65 native mode does not have badlines, no need to enable/disable screen + jsr screen_off +!: #endif - jmp tape_motor_on #endif