From c32650f7f5a55682244cb13fd87da4a54950766c Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Wed, 26 Aug 2020 22:25:56 +0200 Subject: [PATCH] MEGA65 native screen fixes --- src/aliases/,aliases_ram_over64K_m65.s | 5 ++ .../screen_m65/mega65_clear_attributes.s | 11 ---- src/kernal/screen_m65/mega65_clrscr.s | 8 +-- src/kernal/screen_m65/mega65_clrwin.s | 2 +- src/kernal/screen_m65/mega65_screen_helpers.s | 51 ++++-------------- ...o_screen.s => mega65_screen_helpers_irq.s} | 0 .../mega65_screen_helpers_scrlpnt.s | 53 +++++++++++++++++++ .../screen_m65/mega65_screen_tables_misc.s | 12 ++--- .../screen_m65/mega65_screen_upd_txtrow_off.s | 13 ----- src/kernal/screen_m65/mega65_scrmodeset.s | 19 ++++--- 10 files changed, 88 insertions(+), 86 deletions(-) delete mode 100644 src/kernal/screen_m65/mega65_clear_attributes.s rename src/kernal/screen_m65/{mega65_cursor_blink_irqpnt_to_screen.s => mega65_screen_helpers_irq.s} (100%) create mode 100644 src/kernal/screen_m65/mega65_screen_helpers_scrlpnt.s delete mode 100644 src/kernal/screen_m65/mega65_screen_upd_txtrow_off.s diff --git a/src/aliases/,aliases_ram_over64K_m65.s b/src/aliases/,aliases_ram_over64K_m65.s index 354a085a..19ef2082 100644 --- a/src/aliases/,aliases_ram_over64K_m65.s +++ b/src/aliases/,aliases_ram_over64K_m65.s @@ -7,6 +7,11 @@ // $10000-$17FFF (32KB) - reserved for DOS // $18000-$18FFF (4KB) - chargen copied to RAM, to allow character redefinition // $19000-$1B7FF (10KB) - reserved for virtual text screenk, 80x128 + +.const MEMCONF_SCRBASE = $9000 +.const MEMCONF_SCRROWS = 128 + + // $1B800-$1DFFF (10KB) - reserved for a color RAM backup when switchin between text/graphics modes // (4KB) - reserved for sprites // (2KB) - reserved for future use diff --git a/src/kernal/screen_m65/mega65_clear_attributes.s b/src/kernal/screen_m65/mega65_clear_attributes.s deleted file mode 100644 index 7c5dc476..00000000 --- a/src/kernal/screen_m65/mega65_clear_attributes.s +++ /dev/null @@ -1,11 +0,0 @@ -// #LAYOUT# M65 KERNAL_1 #TAKE -// #LAYOUT# * * #IGNORE - - -m65_clear_attributes: - - lda COLOR - and #$0F - sta COLOR - - rts diff --git a/src/kernal/screen_m65/mega65_clrscr.s b/src/kernal/screen_m65/mega65_clrscr.s index ff143655..dc49e84b 100644 --- a/src/kernal/screen_m65/mega65_clrscr.s +++ b/src/kernal/screen_m65/mega65_clrscr.s @@ -7,7 +7,7 @@ M65_CLRSCR: // Clear additional attributes from the color code - jsr m65_clear_attributes + jsr m65_screen_clear_colorattr // Disable the window mode @@ -79,10 +79,10 @@ m65_clrscr_loop: // Check if we are allowed to progress further lda M65_COLVIEW+1 - cmp M65_COLVIEWMAX+1 + cmp M65_COLGUARD+1 bne m65_clrscr_loop lda M65_COLVIEW+0 - cmp M65_COLVIEWMAX+0 + cmp M65_COLGUARD+0 bne m65_clrscr_loop m65_clrscr_loop_done: @@ -111,7 +111,7 @@ m65_clrscr_loop_done: // FALLTROUGH -M65_HOME: +m65_home: // XXX reuse // XXX provide proper implementation diff --git a/src/kernal/screen_m65/mega65_clrwin.s b/src/kernal/screen_m65/mega65_clrwin.s index 11e73155..854c31d5 100644 --- a/src/kernal/screen_m65/mega65_clrwin.s +++ b/src/kernal/screen_m65/mega65_clrwin.s @@ -8,7 +8,7 @@ M65_CLRWIN: // Clear additional attributes from the color code - jsr m65_clear_attributes + jsr m65_screen_clear_colorattr // Check if windowed mode; if not, go to M65_CLRSCR diff --git a/src/kernal/screen_m65/mega65_screen_helpers.s b/src/kernal/screen_m65/mega65_screen_helpers.s index 91247a55..8418d92e 100644 --- a/src/kernal/screen_m65/mega65_screen_helpers.s +++ b/src/kernal/screen_m65/mega65_screen_helpers.s @@ -2,52 +2,21 @@ // #LAYOUT# * * #IGNORE -m65_helper_scrlpnt_color: +m65_screen_clear_colorattr: - // Set .Z to the current column - - ldz M65__TXTCOL - - // Setting M65_LPNT_SCR to point to colour memory (starts from $FF80000) - - lda #$0F - sta M65_LPNT_SCR+3 - lda #$F8 - sta M65_LPNT_SCR+2 - - lda M65_COLVIEW+1 - sta M65_LPNT_SCR+1 - lda M65_COLVIEW+0 - sta M65_LPNT_SCR+0 - - // Add screen row to the address - - clc - lda M65_TXTROW_OFF+0 - adc M65_LPNT_SCR+0 - sta M65_LPNT_SCR+0 - lda M65_TXTROW_OFF+1 - adc M65_LPNT_SCR+1 - sta M65_LPNT_SCR+1 + lda COLOR + and #$0F + sta COLOR rts -m65_helper_scrlpnt_to_screen: +m65_screen_upd_txtrow_off: - // Change M65_LPNT_SCR to point to screen memory (when it points to color memory) - - lda M65_SCRSEG+1 - sta M65_LPNT_SCR+3 - lda M65_SCRSEG+0 - sta M65_LPNT_SCR+2 - - clc - lda M65_SCRBASE+0 - adc M65_LPNT_SCR+0 - sta M65_LPNT_SCR+0 - lda M65_SCRBASE+1 - adc M65_LPNT_SCR+1 - sta M65_LPNT_SCR+1 + 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_cursor_blink_irqpnt_to_screen.s b/src/kernal/screen_m65/mega65_screen_helpers_irq.s similarity index 100% rename from src/kernal/screen_m65/mega65_cursor_blink_irqpnt_to_screen.s rename to src/kernal/screen_m65/mega65_screen_helpers_irq.s diff --git a/src/kernal/screen_m65/mega65_screen_helpers_scrlpnt.s b/src/kernal/screen_m65/mega65_screen_helpers_scrlpnt.s new file mode 100644 index 00000000..91247a55 --- /dev/null +++ b/src/kernal/screen_m65/mega65_screen_helpers_scrlpnt.s @@ -0,0 +1,53 @@ +// #LAYOUT# M65 KERNAL_1 #TAKE +// #LAYOUT# * * #IGNORE + + +m65_helper_scrlpnt_color: + + // Set .Z to the current column + + ldz M65__TXTCOL + + // Setting M65_LPNT_SCR to point to colour memory (starts from $FF80000) + + lda #$0F + sta M65_LPNT_SCR+3 + lda #$F8 + sta M65_LPNT_SCR+2 + + lda M65_COLVIEW+1 + sta M65_LPNT_SCR+1 + lda M65_COLVIEW+0 + sta M65_LPNT_SCR+0 + + // Add screen row to the address + + clc + lda M65_TXTROW_OFF+0 + adc M65_LPNT_SCR+0 + sta M65_LPNT_SCR+0 + lda M65_TXTROW_OFF+1 + adc M65_LPNT_SCR+1 + sta M65_LPNT_SCR+1 + + rts + + +m65_helper_scrlpnt_to_screen: + + // Change M65_LPNT_SCR to point to screen memory (when it points to color memory) + + lda M65_SCRSEG+1 + sta M65_LPNT_SCR+3 + lda M65_SCRSEG+0 + sta M65_LPNT_SCR+2 + + clc + lda M65_SCRBASE+0 + adc M65_LPNT_SCR+0 + sta M65_LPNT_SCR+0 + lda M65_SCRBASE+1 + adc M65_LPNT_SCR+1 + sta M65_LPNT_SCR+1 + + rts diff --git a/src/kernal/screen_m65/mega65_screen_tables_misc.s b/src/kernal/screen_m65/mega65_screen_tables_misc.s index c4a786e7..579d8b64 100644 --- a/src/kernal/screen_m65/mega65_screen_tables_misc.s +++ b/src/kernal/screen_m65/mega65_screen_tables_misc.s @@ -10,15 +10,15 @@ m65_scrtab_vic_ctrlb: // parameters for VIC control register B m65_scrtab_colviewmax_lo: // maximum allowed color viewport start - low byte - .byte <((128-25)*80) - .byte <((128-25)*80) - .byte <((128-50)*80) + .byte <((MEMCONF_SCRROWS - 25) * 80) + .byte <((MEMCONF_SCRROWS - 25) * 80) + .byte <((MEMCONF_SCRROWS - 50) * 80) m65_scrtab_colviewmax_hi: // maximum allowed color viewport start - high byte - .byte >((128-25)*80) - .byte >((128-25)*80) - .byte >((128-50)*80) + .byte >((MEMCONF_SCRROWS - 25) * 80) + .byte >((MEMCONF_SCRROWS - 25) * 80) + .byte >((MEMCONF_SCRROWS - 50) * 80) m65_scrtab_scrolx: // values for VIC_SCROLX diff --git a/src/kernal/screen_m65/mega65_screen_upd_txtrow_off.s b/src/kernal/screen_m65/mega65_screen_upd_txtrow_off.s deleted file mode 100644 index a3e16566..00000000 --- a/src/kernal/screen_m65/mega65_screen_upd_txtrow_off.s +++ /dev/null @@ -1,13 +0,0 @@ -// #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_scrmodeset.s b/src/kernal/screen_m65/mega65_scrmodeset.s index 0cbe613d..aaa3137d 100644 --- a/src/kernal/screen_m65/mega65_scrmodeset.s +++ b/src/kernal/screen_m65/mega65_scrmodeset.s @@ -54,9 +54,9 @@ m65_scrmodeset_internal: // entry point for M65_MODE65 // Set the logical row length to 80 ldx #$50 - // stx VIC_CHARSTEP+0 + stx VIC_CHARSTEP+0 ldx #$00 - // stx VIC_CHARSTEP+1 + stx VIC_CHARSTEP+1 // Set the following locations: // - M64_SCRWINMODE - for scroll-console mode @@ -74,13 +74,12 @@ m65_scrmodeset_internal: // entry point for M65_MODE65 // - VIC_SCRNPTR+0/+1 - for screen viewport start // - M65_COLVIEW, VIC_COLPTR - for using color memory from the start - ldx #>($9000) + ldx #>MEMCONF_SCRBASE stx M65_SCRBASE+1 stx VIC_SCRNPTR+1 - ldx #<($9000) + ldx #($9000 + 80 * 128) + ldx #>(MEMCONF_SCRBASE + 80 * MEMCONF_SCRROWS) stx M65_SCRGUARD+1 - ldx #<(80 * 128) + ldx #<(80 * MEMCONF_SCRROWS) stx M65_COLGUARD+0 - ldx #>(80 * 128) + ldx #>(80 * MEMCONF_SCRROWS) stx M65_COLGUARD+1 ldx M65_SCRMODE