diff --git a/STATUS.md b/STATUS.md index b3cff17c..283ab459 100644 --- a/STATUS.md +++ b/STATUS.md @@ -70,7 +70,7 @@ The following ROM features are currently missing: | :----------------: | :------: | :------------------------------------------------: | | VIC-II | DONE | | | 80 columns, VDC | NOT DONE | | -| 80 columns, Mega65 | PARTIAL | work-in-progress | +| 80 columns, Mega65 | PARTIAL | no windowing mode and C65/M65 extra keys support |
diff --git a/src/basic/,imports.s b/src/basic/,imports.s index f8e402dd..86959543 100644 --- a/src/basic/,imports.s +++ b/src/basic/,imports.s @@ -55,9 +55,8 @@ .label SELDEV = KERNAL().SELDEV #if ROM_LAYOUT_M65 -.label M65_MODE64 = KERNAL().M65_MODE64 -.label M65_MODE65 = KERNAL().M65_MODE65 -.label M65_ISMODE65 = KERNAL().M65_ISMODE65 +.label M65_MODEGET = KERNAL().M65_MODEGET +.label M65_MODESET = KERNAL().M65_MODESET .label M65_SLOW = KERNAL().M65_SLOW .label M65_FAST = KERNAL().M65_FAST .label M65_SETWIN_Y = KERNAL().M65_SETWIN_Y diff --git a/src/basic/basic_commands/cmd_go_goto_run.s b/src/basic/basic_commands/cmd_go_goto_run.s index 96744238..53b9eba9 100644 --- a/src/basic/basic_commands/cmd_go_goto_run.s +++ b/src/basic/basic_commands/cmd_go_goto_run.s @@ -31,12 +31,13 @@ cmd_go_syntax_error: // If in native mode - switch to C64 compatibilty - jsr M65_ISMODE65 + jsr M65_MODEGET bcs cmd_go_rts jsr helper_ask_if_sure bcs cmd_go_rts - jsr M65_MODE64 + sec + jsr M65_MODESET // Carry set = switch to C64 mode jmp_8 cmd_go_switchmode_clr_banner !: cmp #65 @@ -44,12 +45,12 @@ cmd_go_syntax_error: // If in C64 compatibility mode - switch to native mode - jsr M65_ISMODE65 + jsr M65_MODEGET bcc cmd_go_rts jsr helper_ask_if_sure bcs cmd_go_rts - jsr M65_MODE65 + jsr M65_MODESET // Carry clear = switch to M65 mode // FALLTROUGH diff --git a/src/basic/basic_commands/cmd_sys.s b/src/basic/basic_commands/cmd_sys.s index d689b488..8d151300 100644 --- a/src/basic/basic_commands/cmd_sys.s +++ b/src/basic/basic_commands/cmd_sys.s @@ -26,9 +26,10 @@ cmd_sys: // Make sure we are in C64 compatibility mode - jsr M65_ISMODE65 + jsr M65_MODEGET bcs cmd_sys_nsys_common - jsr M65_MODE64 + sec + jsr M65_MODESET // set legacy C64 compatibility mode // FALLTROUGH diff --git a/src/basic/basic_commands_02/cmd_sysinfo.s b/src/basic/basic_commands_02/cmd_sysinfo.s index d85cd9b2..094b6996 100644 --- a/src/basic/basic_commands_02/cmd_sysinfo.s +++ b/src/basic/basic_commands_02/cmd_sysinfo.s @@ -21,7 +21,7 @@ cmd_sysinfo: ldx #IDX__STR_SI_HEADER jsr print_packed_misc_str - jsr M65_ISMODE65 + jsr M65_MODEGET bcc !+ ldx #IDX__STR_SI_MODE64 @@ -39,7 +39,7 @@ cmd_sysinfo: jsr print_return - jsr M65_ISMODE65 + jsr M65_MODEGET bcs print_sysinfo_video jsr print_return diff --git a/src/basic/board_m65/mega65_imports.s b/src/basic/board_m65/mega65_imports.s index ce49e8c5..b9c24577 100644 --- a/src/basic/board_m65/mega65_imports.s +++ b/src/basic/board_m65/mega65_imports.s @@ -26,7 +26,7 @@ .label JREADST = KERNAL_0.JREADST .label JSCREEN = KERNAL_0.JSCREEN .label SELDEV = KERNAL_0.SELDEV -.label M65_ISMODE65 = KERNAL_0.M65_ISMODE65 +.label M65_MODEGET = KERNAL_0.M65_MODEGET .label M65_SETWIN_XY = KERNAL_0.M65_SETWIN_XY .label M65_SETWIN_WH = KERNAL_0.M65_SETWIN_WH .label M65_SETWIN_Y = BASIC_0.proxy_B1_M65_SETWIN_Y diff --git a/src/basic/init/initmsg_m65.s b/src/basic/init/initmsg_m65.s index 39d24c39..a59a44b7 100644 --- a/src/basic/init/initmsg_m65.s +++ b/src/basic/init/initmsg_m65.s @@ -22,10 +22,10 @@ INITMSG: // Display additional information, depending on the mode - jsr M65_ISMODE65 + jsr M65_MODEGET bcc !+ - // Legacy mode + // Legacy C64 compatibility mode ldx #$02 ldy #$21 diff --git a/src/kernal/board_m65/4000.mega65_vectable_kernal_1.s b/src/kernal/board_m65/4000.mega65_vectable_kernal_1.s index 07d924d1..ed13e66d 100644 --- a/src/kernal/board_m65/4000.mega65_vectable_kernal_1.s +++ b/src/kernal/board_m65/4000.mega65_vectable_kernal_1.s @@ -13,20 +13,19 @@ .label VK1__IOINIT = $4000 + 2 * 0 .label VK1__RAMTAS = $4000 + 2 * 1 - .label VK1__setup_vicii = $4000 + 2 * 2 + .label VK1__vicii_init = $4000 + 2 * 2 .label VK1__load_tape_normal = $4000 + 2 * 3 .label VK1__load_tape_turbo = $4000 + 2 * 4 .label VK1__load_tape_auto = $4000 + 2 * 5 .label VK1__tape_head_align = $4000 + 2 * 6 .label VK1__m65_chrout_screen = $4000 + 2 * 7 .label VK1__m65_chrin_keyboard = $4000 + 2 * 8 - .label VK1__M65_MODE64 = $4000 + 2 * 9 - .label VK1__M65_MODE65 = $4000 + 2 * 10 - .label VK1__M65_SCRMODEGET = $4000 + 2 * 11 - .label VK1__M65_SCRMODESET = $4000 + 2 * 12 - .label VK1__M65_CLRSCR = $4000 + 2 * 13 - .label VK1__M65_CLRWIN = $4000 + 2 * 14 - .label VK1__m65_screen_upd_txtrow_off = $4000 + 2 * 15 + .label VK1__M65_MODESET = $4000 + 2 * 9 + .label VK1__M65_SCRMODEGET = $4000 + 2 * 10 + .label VK1__M65_SCRMODESET = $4000 + 2 * 11 + .label VK1__M65_CLRSCR = $4000 + 2 * 12 + .label VK1__M65_CLRWIN = $4000 + 2 * 13 + .label VK1__m65_screen_upd_txtrow_off = $4000 + 2 * 14 #else @@ -34,7 +33,7 @@ .word IOINIT .word RAMTAS - .word setup_vicii + .word vicii_init #if CONFIG_TAPE_NORMAL && !CONFIG_TAPE_AUTODETECT .word load_tape_normal @@ -63,8 +62,7 @@ .word m65_chrout_screen .word m65_chrin_keyboard - .word M65_MODE64 - .word M65_MODE65 + .word M65_MODESET .word M65_SCRMODEGET .word M65_SCRMODESET .word M65_CLRSCR diff --git a/src/kernal/board_m65/mega65_imports.s b/src/kernal/board_m65/mega65_imports.s index 7077b18f..de974bb7 100644 --- a/src/kernal/board_m65/mega65_imports.s +++ b/src/kernal/board_m65/mega65_imports.s @@ -12,7 +12,7 @@ .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 +.label M65_MODEGET = KERNAL_0.M65_MODEGET .label M65_SETWIN_XY = KERNAL_0.M65_SETWIN_XY .label M65_SETWIN_WH = KERNAL_0.M65_SETWIN_WH .label M65_SETWIN_N = KERNAL_0.M65_SETWIN_N diff --git a/src/kernal/board_m65/mega65_redirect_api.s b/src/kernal/board_m65/mega65_redirect_api.s index 8c47f81c..1392852f 100644 --- a/src/kernal/board_m65/mega65_redirect_api.s +++ b/src/kernal/board_m65/mega65_redirect_api.s @@ -5,16 +5,10 @@ // ROM routine call redirect for Mega65 API routines // -M65_MODE64: +M65_MODESET: jsr map_KERNAL_1 - jsr_ind VK1__M65_MODE64 - bra m65_api_end - -M65_MODE65: - - jsr map_KERNAL_1 - jsr_ind VK1__M65_MODE65 + jsr_ind VK1__M65_MODESET bra m65_api_end M65_SCRMODEGET: diff --git a/src/kernal/board_x16/cx16_stubs.s b/src/kernal/board_x16/cx16_stubs.s index 2407b0e5..3a605a9e 100644 --- a/src/kernal/board_x16/cx16_stubs.s +++ b/src/kernal/board_x16/cx16_stubs.s @@ -10,7 +10,7 @@ scnkey_set_keytab: clear_screen: STUB_IMPLEMENTATION() -setup_vicii: +vicii_init: STUB_IMPLEMENTATION() cursor_blink: diff --git a/src/kernal/extapi_m65/mega65__jumptable.s b/src/kernal/extapi_m65/mega65__jumptable.s index 41eb1f5c..bce9afbf 100644 --- a/src/kernal/extapi_m65/mega65__jumptable.s +++ b/src/kernal/extapi_m65/mega65__jumptable.s @@ -8,19 +8,16 @@ // would copy the vector table to given memory location -M65_JMODE64: - jsr M65_MODE64 +M65_JMODEGET: + jsr M65_MODEGET -M65_JMODE65: // XXX consider combining with M65_JMODE64 - jsr M65_MODE65 - -M65_JISMODE65: - jsr M65_ISMODE65 +M65_JISMODESET: + jsr M65_MODESET M65_JSLOW: jsr M65_SLOW -M65_JFAST: // XXX consider combining with M65_JSLOW +M65_JFAST: jsr M65_FAST M65_JSELDEV: diff --git a/src/kernal/extapi_m65/mega65_mode64.s b/src/kernal/extapi_m65/mega65_mode64.s deleted file mode 100644 index 010e85ea..00000000 --- a/src/kernal/extapi_m65/mega65_mode64.s +++ /dev/null @@ -1,29 +0,0 @@ -// #LAYOUT# M65 KERNAL_1 #TAKE -// #LAYOUT# * * #IGNORE - - -M65_MODE64: - - // Disable interrupts, they might interfere - - sei - - // Set the magic string to mark legacy mode - - lda #$00 - sta M65_MAGICSTR+0 - sta M65_MAGICSTR+1 - sta M65_MAGICSTR+2 - - // Restore VIC-II configuration - - jsr viciv_shutdown - jsr setup_vicii - - // Reenable interrupts - - cli - - // Switch CPU speed back to slow and quit - - jmp M65_SLOW diff --git a/src/kernal/extapi_m65/mega65_mode65.s b/src/kernal/extapi_m65/mega65_mode65.s deleted file mode 100644 index 8dd88f24..00000000 --- a/src/kernal/extapi_m65/mega65_mode65.s +++ /dev/null @@ -1,36 +0,0 @@ -// #LAYOUT# M65 KERNAL_1 #TAKE -// #LAYOUT# * * #IGNORE - - -M65_MODE65: - - // Disable interrupts, they might interfere - - sei - - // Switch CPU speed to fast - - jsr M65_FAST - - // Set the magic string to mark native mode - - lda #$4D // 'M' - sta M65_MAGICSTR+0 - lda #$36 // '6' - sta M65_MAGICSTR+1 - lda #$35 // '5' - sta M65_MAGICSTR+2 - - // Initialize VIC-IV - - jsr setup_vicii - jsr viciv_init - - // Set screen mode to 80x50 - - lda #$02 - jsr m65_scrmodeset_internal - - // Clear the screen - - jmp M65_CLRSCR diff --git a/src/kernal/extapi_m65/mega65_ismode65.s b/src/kernal/extapi_m65/mega65_modeget.s similarity index 73% rename from src/kernal/extapi_m65/mega65_ismode65.s rename to src/kernal/extapi_m65/mega65_modeget.s index 428233d9..fbea3182 100644 --- a/src/kernal/extapi_m65/mega65_ismode65.s +++ b/src/kernal/extapi_m65/mega65_modeget.s @@ -2,7 +2,9 @@ // #LAYOUT# * * #IGNORE -M65_ISMODE65: // checks if mode is native M65 one, BCC = jump if native mode +M65_MODEGET: + + // Checks if mode is native M65 one; Carry clear = native mode, Carry set = legacy mode pha diff --git a/src/kernal/extapi_m65/mega65_modeset.s b/src/kernal/extapi_m65/mega65_modeset.s new file mode 100644 index 00000000..8a644bc4 --- /dev/null +++ b/src/kernal/extapi_m65/mega65_modeset.s @@ -0,0 +1,71 @@ +// #LAYOUT# M65 KERNAL_1 #TAKE +// #LAYOUT# * * #IGNORE + + +M65_MODESET: + + // Carry clear = set native mode; Carry set = set legacy mode + + bcc m65_mode65 + + // FALLTROUGH + +m65_mode64: + + // Disable interrupts, they might interfere + + sei + + // Set the magic string to mark legacy mode + + lda #$00 + sta M65_MAGICSTR+0 + sta M65_MAGICSTR+1 + sta M65_MAGICSTR+2 + + // Restore VIC-II configuration + + jsr viciv_shutdown + jsr vicii_init + + // Reenable interrupts + + cli + + // Switch CPU speed back to slow and quit + + jmp M65_SLOW + + +m65_mode65: + + // Disable interrupts, they might interfere + + sei + + // Switch CPU speed to fast + + jsr M65_FAST + + // Set the magic string to mark native mode + + lda #$4D // 'M' + sta M65_MAGICSTR+0 + lda #$36 // '6' + sta M65_MAGICSTR+1 + lda #$35 // '5' + sta M65_MAGICSTR+2 + + // Initialize VIC-IV + + jsr vicii_init + jsr viciv_init + + // Set screen mode to 80x50 + + lda #$02 + jsr m65_scrmodeset_internal + + // Clear the screen + + jmp M65_CLRSCR diff --git a/src/kernal/init/e518.cint_legacy.s b/src/kernal/init/e518.cint_legacy.s index a143692d..04815503 100644 --- a/src/kernal/init/e518.cint_legacy.s +++ b/src/kernal/init/e518.cint_legacy.s @@ -16,7 +16,7 @@ cint_legacy: // $E518 // Setup video and I/O // See here: https://csdb.dk/forums/index.php?roomid=11&topicid=17048&firstpost=22 - jsr setup_vicii + jsr vicii_init // Code below must be placed under $E51B, or some code will break - see here: // - https://csdb.dk/forums/index.php?roomid=11&topicid=17048&firstpost=2 diff --git a/src/kernal/init/e5a0.setup_vicii.s b/src/kernal/init/e5a0.vicii_init.s similarity index 97% rename from src/kernal/init/e5a0.setup_vicii.s rename to src/kernal/init/e5a0.vicii_init.s index 1358f461..5cb3d59c 100644 --- a/src/kernal/init/e5a0.setup_vicii.s +++ b/src/kernal/init/e5a0.vicii_init.s @@ -11,12 +11,12 @@ // -setup_vicii: +vicii_init: #if (ROM_LAYOUT_M65 && SEGMENT_KERNAL_0) jsr map_KERNAL_1 - jsr_ind VK1__setup_vicii + jsr_ind VK1__vicii_init jmp map_NORMAL #else diff --git a/src/kernal/interrupts/ea31.default_irq_handler.s b/src/kernal/interrupts/ea31.default_irq_handler.s index f15f2305..394b5c21 100644 --- a/src/kernal/interrupts/ea31.default_irq_handler.s +++ b/src/kernal/interrupts/ea31.default_irq_handler.s @@ -17,7 +17,7 @@ default_irq_handler: #if ROM_LAYOUT_M65 - jsr M65_ISMODE65 + jsr M65_MODEGET bcs !+ jsr m65_cursor_blink diff --git a/src/kernal/iostack/f333.clrchn.s b/src/kernal/iostack/f333.clrchn.s index 7e316739..b4829b11 100644 --- a/src/kernal/iostack/f333.clrchn.s +++ b/src/kernal/iostack/f333.clrchn.s @@ -22,7 +22,7 @@ CLRCHN: // FALLTROUGH -clrchn_reset: // entry needed by setup_vicii +clrchn_reset: // entry needed by vicii_init // Set input device number to keyboard lda #$00 diff --git a/src/kernal/panic.s b/src/kernal/panic.s index 45c1c4ac..1dbbf993 100644 --- a/src/kernal/panic.s +++ b/src/kernal/panic.s @@ -25,12 +25,13 @@ panic: // Make sure we are in legacy mode with normal memory mapping jsr map_NORMAL - jsr M65_MODE64 + sec + jsr M65_MODESET // switch to legacy C64 compatibility mode sei #else - jsr setup_vicii + jsr vicii_init #endif diff --git a/src/kernal/screen/chrin_keyboard.s b/src/kernal/screen/chrin_keyboard.s index 074fbdde..5cfe67e2 100644 --- a/src/kernal/screen/chrin_keyboard.s +++ b/src/kernal/screen/chrin_keyboard.s @@ -12,7 +12,7 @@ chrin_keyboard: #if ROM_LAYOUT_M65 - jsr M65_ISMODE65 + jsr M65_MODEGET bcc_16 m65_chrin_keyboard #endif diff --git a/src/kernal/screen/chrout_screen.s b/src/kernal/screen/chrout_screen.s index 596a3ce9..153425d9 100644 --- a/src/kernal/screen/chrout_screen.s +++ b/src/kernal/screen/chrout_screen.s @@ -12,7 +12,7 @@ chrout_screen: #if ROM_LAYOUT_M65 - jsr M65_ISMODE65 + jsr M65_MODEGET bcc_16 m65_chrout_screen #endif diff --git a/src/kernal/screen/e56c.screen_calculate_pointers.s b/src/kernal/screen/e56c.screen_calculate_pointers.s index ab0d632d..3c30b0b4 100644 --- a/src/kernal/screen/e56c.screen_calculate_pointers.s +++ b/src/kernal/screen/e56c.screen_calculate_pointers.s @@ -17,7 +17,7 @@ screen_calculate_pointers: #if ROM_LAYOUT_M65 - jsr M65_ISMODE65 + jsr M65_MODEGET bcc_16 m65_screen_upd_txtrow_off #endif diff --git a/src/kernal/screen/screen.s b/src/kernal/screen/screen.s index 9d11c38b..f83b39b1 100644 --- a/src/kernal/screen/screen.s +++ b/src/kernal/screen/screen.s @@ -28,7 +28,7 @@ SCREEN: #else php - jsr M65_ISMODE65 + jsr M65_MODEGET bcc !+ plp @@ -38,6 +38,8 @@ SCREEN: rts !: + // Screen dimensions depends on text mode + plp pha ldy M65_SCRMODE diff --git a/src/kernal/tape/tape_common_screen.s b/src/kernal/tape/tape_common_screen.s index bd44c5b3..9aa968e8 100644 --- a/src/kernal/tape/tape_common_screen.s +++ b/src/kernal/tape/tape_common_screen.s @@ -25,7 +25,7 @@ tape_screen_on_motor_off: #else - jsr M65_ISMODE65 + jsr M65_MODEGET bcs_16 screen_on // MEGA65 native mode does not have badlines, no need to enable/disable screen rts @@ -51,7 +51,8 @@ tape_screen_off_motor_on: #else - jsr M65_ISMODE65 + jsr M65_MODEGET + // XXX optimize this bcs !+ // MEGA65 native mode does not have badlines, no need to enable/disable screen jsr screen_off !: