From 9e94b9d78c9749b69fb0c2eecb283b8ac78422bb Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sun, 23 Aug 2020 21:44:38 +0200 Subject: [PATCH] VIC-IV screen code optimizations --- src/aliases/,aliases_ram_lowmem_m65.s | 3 +- src/basic/,imports.s | 1 + src/basic/board_m65/mega65_imports.s | 4 +-- src/basic/board_m65/mega65_proxies.s | 14 ++++---- .../board_m65/4000.mega65_vectable_kernal_1.s | 32 ++++++++++--------- src/kernal/board_m65/mega65_imports.s | 2 -- src/kernal/board_m65/mega65_redirect_screen.s | 10 ++++-- .../screen/e56c.screen_calculate_pointers.s | 4 +++ src/kernal/screen_m65/mega65_chrout_screen.s | 13 +++++--- src/kernal/screen_m65/mega65_clrscr.s | 2 ++ src/kernal/screen_m65/mega65_cursor_blink.s | 30 +++-------------- .../mega65_cursor_blink_rework_ptr.s | 22 +++++++++++++ .../screen_m65/mega65_screen_table_roff_hi.s | 13 -------- .../screen_m65/mega65_screen_table_roff_lo.s | 13 -------- .../screen_m65/mega65_screen_tables_misc.s | 16 ++++++++++ .../screen_m65/mega65_screen_upd_txtrow_off.s | 13 ++++++++ src/kernal/screen_m65/mega65_setwin.s | 2 ++ 17 files changed, 109 insertions(+), 85 deletions(-) create mode 100644 src/kernal/screen_m65/mega65_cursor_blink_rework_ptr.s delete mode 100644 src/kernal/screen_m65/mega65_screen_table_roff_hi.s delete mode 100644 src/kernal/screen_m65/mega65_screen_table_roff_lo.s create mode 100644 src/kernal/screen_m65/mega65_screen_upd_txtrow_off.s diff --git a/src/aliases/,aliases_ram_lowmem_m65.s b/src/aliases/,aliases_ram_lowmem_m65.s index 1391e59d..1f8064db 100644 --- a/src/aliases/,aliases_ram_lowmem_m65.s +++ b/src/aliases/,aliases_ram_lowmem_m65.s @@ -49,6 +49,7 @@ .label M65_TXTWIN_Y0 = $58F // text window - top-left Y coordinate, starting from 0 .label M65_TXTWIN_X1 = $590 // text window - bottom-right X coordinate + 1 .label M65_TXTWIN_Y1 = $591 // text window - bottom-right Y coordinate + 1 - // $592-$5FF -- UNUSED -- + .label M65_TXTROW_OFF = $592 // $592-$594 offset to the current text row + // $594-$5FF -- UNUSED -- .label M65_RS232_INBUF = $600 // $600-$6FF -- reserved for RS-232 input buffer -- .label M65_RS232_OUTBUF = $700 // $700-$7FF -- reserved for RS-232 output buffer -- diff --git a/src/basic/,imports.s b/src/basic/,imports.s index 99d9333b..1e9b0319 100644 --- a/src/basic/,imports.s +++ b/src/basic/,imports.s @@ -36,6 +36,7 @@ .label hw_entry_reset = KERNAL().hw_entry_reset .label clear_screen = KERNAL().clear_screen +.label M65_SETWIN_Y = KERNAL().M65_SETWIN_Y #if CONFIG_DBG_PRINTF .label printf = KERNAL().printf diff --git a/src/basic/board_m65/mega65_imports.s b/src/basic/board_m65/mega65_imports.s index 8a2a80ae..f7d7af97 100644 --- a/src/basic/board_m65/mega65_imports.s +++ b/src/basic/board_m65/mega65_imports.s @@ -12,6 +12,7 @@ .label poke_via_OLDTXT = BASIC_0.proxy_B1_poke_via_OLDTXT .label JCHROUT = BASIC_0.proxy_B1_JCHROUT .label JCLALL = BASIC_0.proxy_B1_JCLALL +.label plot_set = BASIC_0.proxy_B1_plot_set #if CONFIG_DOS_WEDGE .label JCLOSE = BASIC_0.proxy_B1_JCLOSE .label JOPEN = BASIC_0.proxy_B1_JOPEN @@ -28,9 +29,8 @@ .label M65_ISMODE65 = KERNAL_0.M65_ISMODE65 .label M65_SETWIN_XY = KERNAL_0.M65_SETWIN_XY .label M65_SETWIN_WH = KERNAL_0.M65_SETWIN_WH -.label M65_SETWIN_Y = KERNAL_0.M65_SETWIN_Y +.label M65_SETWIN_Y = BASIC_0.proxy_B1_M65_SETWIN_Y .label M65_SETWIN_N = KERNAL_0.M65_SETWIN_N -.label plot_set = KERNAL_0.plot_set .label init_oldtxt = BASIC_0.init_oldtxt .label tmpstr_free_all_reset = BASIC_0.tmpstr_free_all_reset .label rom_revision_basic_string = BASIC_0.rom_revision_basic_string diff --git a/src/basic/board_m65/mega65_proxies.s b/src/basic/board_m65/mega65_proxies.s index 2891b466..29350754 100644 --- a/src/basic/board_m65/mega65_proxies.s +++ b/src/basic/board_m65/mega65_proxies.s @@ -29,7 +29,6 @@ proxy_B1_poke_via_OLDTXT: #endif jmp map_BASIC_1 - proxy_B1_JCLALL: jsr map_NORMAL @@ -85,16 +84,17 @@ proxy_B1_print_space: jsr print_space jmp map_BASIC_1 - -#if CONFIG_SHOW_FEATURES - -proxy_B1_print_features: +proxy_B1_plot_set: jsr map_NORMAL - jsr print_features + jsr plot_set jmp map_BASIC_1 -#endif +proxy_B1_M65_SETWIN_Y: + + jsr map_NORMAL + jsr M65_SETWIN_Y + jmp map_BASIC_1 #if CONFIG_DOS_WEDGE 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 6e6a7dd5..87d0a1f3 100644 --- a/src/kernal/board_m65/4000.mega65_vectable_kernal_1.s +++ b/src/kernal/board_m65/4000.mega65_vectable_kernal_1.s @@ -11,20 +11,21 @@ // Label definitions - .label VK1__IOINIT = $4000 + 2 * 0 - .label VK1__RAMTAS = $4000 + 2 * 1 - .label VK1__setup_vicii = $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_MODE64 = $4000 + 2 * 8 - .label VK1__M65_MODE65 = $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__IOINIT = $4000 + 2 * 0 + .label VK1__RAMTAS = $4000 + 2 * 1 + .label VK1__setup_vicii = $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_MODE64 = $4000 + 2 * 8 + .label VK1__M65_MODE65 = $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 @@ -65,6 +66,7 @@ .word M65_SCRMODEGET .word M65_SCRMODESET .word M65_CLRSCR - .word M65_CLRWIN + .word M65_CLRWIN + .word m65_screen_upd_txtrow_off #endif diff --git a/src/kernal/board_m65/mega65_imports.s b/src/kernal/board_m65/mega65_imports.s index 1bd3fb2a..bb9c3d10 100644 --- a/src/kernal/board_m65/mega65_imports.s +++ b/src/kernal/board_m65/mega65_imports.s @@ -34,8 +34,6 @@ .label wait_x_bars = KERNAL_0.wait_x_bars .label viciv_unhide = KERNAL_0.viciv_unhide -.label m65_scrtab_rowoffset_lo = KERNAL_0.m65_scrtab_rowoffset_lo -.label m65_scrtab_rowoffset_hi = KERNAL_0.m65_scrtab_rowoffset_hi .label m65_scrtab_txtwidth = KERNAL_0.m65_scrtab_txtwidth .label m65_scrtab_txtheight = KERNAL_0.m65_scrtab_txtheight diff --git a/src/kernal/board_m65/mega65_redirect_screen.s b/src/kernal/board_m65/mega65_redirect_screen.s index 9ca9c889..18dacdaf 100644 --- a/src/kernal/board_m65/mega65_redirect_screen.s +++ b/src/kernal/board_m65/mega65_redirect_screen.s @@ -2,7 +2,7 @@ // #LAYOUT# * * #IGNORE // -// ROM routine call redirect for Mega65 screen routines +// ROM routine call redirect for MEGA65 screen routines // @@ -11,4 +11,10 @@ m65_chrout_screen: jsr map_KERNAL_1 jsr_ind VK1__m65_chrout_screen jsr map_NORMAL - jmp chrout_done_success + jmp chrout_done_success + +m65_screen_upd_txtrow_off: + + jsr map_KERNAL_1 + jsr_ind VK1__m65_screen_upd_txtrow_off + jmp map_NORMAL diff --git a/src/kernal/screen/e56c.screen_calculate_pointers.s b/src/kernal/screen/e56c.screen_calculate_pointers.s index cb4194b9..87286443 100644 --- a/src/kernal/screen/e56c.screen_calculate_pointers.s +++ b/src/kernal/screen/e56c.screen_calculate_pointers.s @@ -15,5 +15,9 @@ screen_calculate_pointers: + jsr M65_ISMODE65 + bcs !+ + jmp m65_screen_upd_txtrow_off +!: jsr screen_calculate_PNT_USER jmp screen_calculate_PNTR_LNMX diff --git a/src/kernal/screen_m65/mega65_chrout_screen.s b/src/kernal/screen_m65/mega65_chrout_screen.s index 708a5272..b315630f 100644 --- a/src/kernal/screen_m65/mega65_chrout_screen.s +++ b/src/kernal/screen_m65/mega65_chrout_screen.s @@ -53,12 +53,11 @@ m65_chrout_screen_literal: // entry point for m65_chrout_screen_quote // Add screen row to the address - ldy M65__TXTROW clc - lda m65_scrtab_rowoffset_lo,y + lda M65_TXTROW_OFF+0 adc M65_LPNT_SCR+0 sta M65_LPNT_SCR+0 - lda m65_scrtab_rowoffset_hi,y + lda M65_TXTROW_OFF+1 adc M65_LPNT_SCR+1 sta M65_LPNT_SCR+1 @@ -113,7 +112,7 @@ m65_chrout_fix_column_row: // XXX provide implementation // XXX - jmp_8 m65_chrout_screen_done + jmp_8 m65_chrout_fix_txtrow_off m65_chrout_fix_column_row_win: @@ -127,6 +126,12 @@ m65_chrout_fix_column_row_win: // FALLTROUGH +m65_chrout_fix_txtrow_off: + + jsr m65_screen_upd_txtrow_off + + // FALLTROUGH + m65_chrout_screen_done: jsr m65_cursor_show_if_enabled diff --git a/src/kernal/screen_m65/mega65_clrscr.s b/src/kernal/screen_m65/mega65_clrscr.s index 6c252914..1168571c 100644 --- a/src/kernal/screen_m65/mega65_clrscr.s +++ b/src/kernal/screen_m65/mega65_clrscr.s @@ -118,5 +118,7 @@ m65_clrscr_loop: lda #$00 sta M65__TXTROW sta M65__TXTCOL + sta M65_TXTROW_OFF+0 + sta M65_TXTROW_OFF+1 rts diff --git a/src/kernal/screen_m65/mega65_cursor_blink.s b/src/kernal/screen_m65/mega65_cursor_blink.s index dfe40955..6fb5e549 100644 --- a/src/kernal/screen_m65/mega65_cursor_blink.s +++ b/src/kernal/screen_m65/mega65_cursor_blink.s @@ -39,16 +39,14 @@ m65_cursor_blink: sta M65_LPNT_IRQ+0 // Add screen row to the address - ldy M65__TXTROW clc - lda m65_scrtab_rowoffset_lo,y + lda M65_TXTROW_OFF+0 adc M65_LPNT_IRQ+0 sta M65_LPNT_IRQ+0 - lda m65_scrtab_rowoffset_hi,y + lda M65_TXTROW_OFF+1 adc M65_LPNT_IRQ+1 sta M65_LPNT_IRQ+1 - // Check if cursor was visible or not, and toggle lda BLNON bne m65_cursor_blink_undraw @@ -68,7 +66,7 @@ m65_cursor_blink_draw: sta_lp (M65_LPNT_IRQ),z // Rework pointer to point to screnn memory - jsr m65_cursor_blink_adapt_ptr + jsr m65_cursor_blink_rework_ptr // Cursor draw - character lda_lp (M65_LPNT_IRQ),z @@ -99,30 +97,10 @@ m65_cursor_blink_undraw: sta_lp (M65_LPNT_IRQ),z // Rework pointer to point to screnn memory - jsr m65_cursor_blink_adapt_ptr + jsr m65_cursor_blink_rework_ptr // Cursor undraw - character lda GDBLN sta_lp (M65_LPNT_IRQ),z jmp_8 m65_cursor_blink_timer_reset - - -m65_cursor_blink_adapt_ptr: - - // Adapt pointer to point to screen memory - - lda M65_SCRSEG+1 - sta M65_LPNT_IRQ+3 - lda M65_SCRSEG+0 - sta M65_LPNT_IRQ+2 - - clc - lda M65_SCRBASE+0 - adc M65_LPNT_IRQ+0 - sta M65_LPNT_IRQ+0 - lda M65_SCRBASE+1 - adc M65_LPNT_IRQ+1 - sta M65_LPNT_IRQ+1 - - rts diff --git a/src/kernal/screen_m65/mega65_cursor_blink_rework_ptr.s b/src/kernal/screen_m65/mega65_cursor_blink_rework_ptr.s new file mode 100644 index 00000000..7aaffcc0 --- /dev/null +++ b/src/kernal/screen_m65/mega65_cursor_blink_rework_ptr.s @@ -0,0 +1,22 @@ +// #LAYOUT# M65 KERNAL_0 #TAKE +// #LAYOUT# * * #IGNORE + + +m65_cursor_blink_rework_ptr: + + // Adapt pointer to point to screen memory + + lda M65_SCRSEG+1 + sta M65_LPNT_IRQ+3 + lda M65_SCRSEG+0 + sta M65_LPNT_IRQ+2 + + clc + lda M65_SCRBASE+0 + adc M65_LPNT_IRQ+0 + sta M65_LPNT_IRQ+0 + lda M65_SCRBASE+1 + adc M65_LPNT_IRQ+1 + sta M65_LPNT_IRQ+1 + + rts diff --git a/src/kernal/screen_m65/mega65_screen_table_roff_hi.s b/src/kernal/screen_m65/mega65_screen_table_roff_hi.s deleted file mode 100644 index 15435e4a..00000000 --- a/src/kernal/screen_m65/mega65_screen_table_roff_hi.s +++ /dev/null @@ -1,13 +0,0 @@ -// #LAYOUT# M65 KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE - - -// XXX consider moving this back to extended memory, and just store the offset in RAM - -m65_scrtab_rowoffset_hi: // row offsets - high bytes - - .byte >(80 * 0), >(80 * 1), >(80 * 2), >(80 * 3), >(80 * 4), >(80 * 5), >(80 * 6), >(80 * 7), >(80 * 8), >(80 * 9) - .byte >(80 * 10), >(80 * 11), >(80 * 12), >(80 * 13), >(80 * 14), >(80 * 15), >(80 * 16), >(80 * 17), >(80 * 18), >(80 * 19) - .byte >(80 * 20), >(80 * 21), >(80 * 22), >(80 * 23), >(80 * 24), >(80 * 25), >(80 * 26), >(80 * 27), >(80 * 28), >(80 * 29) - .byte >(80 * 30), >(80 * 31), >(80 * 32), >(80 * 33), >(80 * 34), >(80 * 35), >(80 * 36), >(80 * 37), >(80 * 38), >(80 * 39) - .byte >(80 * 40), >(80 * 41), >(80 * 42), >(80 * 43), >(80 * 44), >(80 * 45), >(80 * 46), >(80 * 47), >(80 * 48), >(80 * 49) \ No newline at end of file diff --git a/src/kernal/screen_m65/mega65_screen_table_roff_lo.s b/src/kernal/screen_m65/mega65_screen_table_roff_lo.s deleted file mode 100644 index 1327984f..00000000 --- a/src/kernal/screen_m65/mega65_screen_table_roff_lo.s +++ /dev/null @@ -1,13 +0,0 @@ -// #LAYOUT# M65 KERNAL_0 #TAKE -// #LAYOUT# * * #IGNORE - - -// XXX consider moving this back to extended memory, and just store the offset in RAM - -m65_scrtab_rowoffset_lo: // row offsets - low bytes - - .byte <(80 * 0), <(80 * 1), <(80 * 2), <(80 * 3), <(80 * 4), <(80 * 5), <(80 * 6), <(80 * 7), <(80 * 8), <(80 * 9) - .byte <(80 * 10), <(80 * 11), <(80 * 12), <(80 * 13), <(80 * 14), <(80 * 15), <(80 * 16), <(80 * 17), <(80 * 18), <(80 * 19) - .byte <(80 * 20), <(80 * 21), <(80 * 22), <(80 * 23), <(80 * 24), <(80 * 25), <(80 * 26), <(80 * 27), <(80 * 28), <(80 * 29) - .byte <(80 * 30), <(80 * 31), <(80 * 32), <(80 * 33), <(80 * 34), <(80 * 35), <(80 * 36), <(80 * 37), <(80 * 38), <(80 * 39) - .byte <(80 * 40), <(80 * 41), <(80 * 42), <(80 * 43), <(80 * 44), <(80 * 45), <(80 * 46), <(80 * 47), <(80 * 48), <(80 * 49) diff --git a/src/kernal/screen_m65/mega65_screen_tables_misc.s b/src/kernal/screen_m65/mega65_screen_tables_misc.s index 7dc0c5fd..51d0b7b6 100644 --- a/src/kernal/screen_m65/mega65_screen_tables_misc.s +++ b/src/kernal/screen_m65/mega65_screen_tables_misc.s @@ -26,6 +26,22 @@ m65_scrtab_scrolx: // values for VIC_SCROLX .byte $CA .byte $CA +m65_scrtab_rowoffset_lo: // row offsets - low bytes + + .byte <(80 * 0), <(80 * 1), <(80 * 2), <(80 * 3), <(80 * 4), <(80 * 5), <(80 * 6), <(80 * 7), <(80 * 8), <(80 * 9) + .byte <(80 * 10), <(80 * 11), <(80 * 12), <(80 * 13), <(80 * 14), <(80 * 15), <(80 * 16), <(80 * 17), <(80 * 18), <(80 * 19) + .byte <(80 * 20), <(80 * 21), <(80 * 22), <(80 * 23), <(80 * 24), <(80 * 25), <(80 * 26), <(80 * 27), <(80 * 28), <(80 * 29) + .byte <(80 * 30), <(80 * 31), <(80 * 32), <(80 * 33), <(80 * 34), <(80 * 35), <(80 * 36), <(80 * 37), <(80 * 38), <(80 * 39) + .byte <(80 * 40), <(80 * 41), <(80 * 42), <(80 * 43), <(80 * 44), <(80 * 45), <(80 * 46), <(80 * 47), <(80 * 48), <(80 * 49) + +m65_scrtab_rowoffset_hi: // row offsets - high bytes + + .byte >(80 * 0), >(80 * 1), >(80 * 2), >(80 * 3), >(80 * 4), >(80 * 5), >(80 * 6), >(80 * 7), >(80 * 8), >(80 * 9) + .byte >(80 * 10), >(80 * 11), >(80 * 12), >(80 * 13), >(80 * 14), >(80 * 15), >(80 * 16), >(80 * 17), >(80 * 18), >(80 * 19) + .byte >(80 * 20), >(80 * 21), >(80 * 22), >(80 * 23), >(80 * 24), >(80 * 25), >(80 * 26), >(80 * 27), >(80 * 28), >(80 * 29) + .byte >(80 * 30), >(80 * 31), >(80 * 32), >(80 * 33), >(80 * 34), >(80 * 35), >(80 * 36), >(80 * 37), >(80 * 38), >(80 * 39) + .byte >(80 * 40), >(80 * 41), >(80 * 42), >(80 * 43), >(80 * 44), >(80 * 45), >(80 * 46), >(80 * 47), >(80 * 48), >(80 * 49) + // Jumptable for screen control codes support. To improve performance, should be sorted // starting from the least probable routine. diff --git a/src/kernal/screen_m65/mega65_screen_upd_txtrow_off.s b/src/kernal/screen_m65/mega65_screen_upd_txtrow_off.s new file mode 100644 index 00000000..a3e16566 --- /dev/null +++ b/src/kernal/screen_m65/mega65_screen_upd_txtrow_off.s @@ -0,0 +1,13 @@ +// #LAYOUT# M65 KERNAL_1 #TAKE +// #LAYOUT# * * #IGNORE + + +m65_screen_upd_txtrow_off: + + ldy M65__TXTROW + lda m65_scrtab_rowoffset_lo,y + sta M65_TXTROW_OFF+0 + lda m65_scrtab_rowoffset_hi,y + sta M65_TXTROW_OFF+1 + + rts diff --git a/src/kernal/screen_m65/mega65_setwin.s b/src/kernal/screen_m65/mega65_setwin.s index f900c5b8..7204be16 100644 --- a/src/kernal/screen_m65/mega65_setwin.s +++ b/src/kernal/screen_m65/mega65_setwin.s @@ -52,5 +52,7 @@ M65_SETWIN_Y: lda M65_TXTWIN_Y0 sta M65__TXTROW + jsr m65_screen_upd_txtrow_off + pla rts