diff --git a/src/kernal/screen_m65/mega65_cursor.s b/src/kernal/screen_m65/mega65_cursor.s index db0d6b8a..7c89e4ea 100644 --- a/src/kernal/screen_m65/mega65_cursor.s +++ b/src/kernal/screen_m65/mega65_cursor.s @@ -21,14 +21,17 @@ m65_cursor_undraw: // XXX provide implementation - rts + lda #$80 + sta BLNSW + rts m65_cursor_show_if_enabled: // XXX provide implementation - nop + lda #$00 + sta BLNSW // FALLTROUGH diff --git a/src/kernal/screen_m65/mega65_cursor_blink.s b/src/kernal/screen_m65/mega65_cursor_blink.s index ea8bfd9c..dfe40955 100644 --- a/src/kernal/screen_m65/mega65_cursor_blink.s +++ b/src/kernal/screen_m65/mega65_cursor_blink.s @@ -24,27 +24,31 @@ m65_cursor_blink: dec BLNCT bpl m65_cursor_blink_end - // Prepare .Z and long pointer to screen position + // Prepare .Z for offset within row ldz M65__TXTCOL - lda M65_SCRVIEW+0 - sta M65_LPNT_IRQ+0 - lda M65_SCRVIEW+1 - sta M65_LPNT_IRQ+1 - lda M65_SCRSEG+0 - sta M65_LPNT_IRQ+2 - lda M65_SCRSEG+1 - sta M65_LPNT_IRQ+3 - // Add row offset to the long pointer + // Prepare long pointer to color memory + lda #$0F + sta M65_LPNT_IRQ+3 + lda #$F8 + sta M65_LPNT_IRQ+2 + + lda M65_COLVIEW+1 + sta M65_LPNT_IRQ+1 + lda M65_COLVIEW+0 + sta M65_LPNT_IRQ+0 + + // Add screen row to the address ldy M65__TXTROW clc lda m65_scrtab_rowoffset_lo,y adc M65_LPNT_IRQ+0 - sta M65_LPNT_IRQ+0 + sta M65_LPNT_IRQ+0 lda m65_scrtab_rowoffset_hi,y 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 @@ -56,15 +60,22 @@ m65_cursor_blink_draw: lda #1 sta BLNON + // Cursor draw - color + lda_lp (M65_LPNT_IRQ),z + sta GDCOL + lda COLOR + and #$0F + sta_lp (M65_LPNT_IRQ),z + + // Rework pointer to point to screnn memory + jsr m65_cursor_blink_adapt_ptr + // Cursor draw - character lda_lp (M65_LPNT_IRQ),z sta GDBLN eor #$80 sta_lp (M65_LPNT_IRQ),z - // Cursor draw - color - // XXX provide implementation - m65_cursor_blink_timer_reset: // Rest blink counter (Mapping the 64, p39-40) @@ -83,11 +94,35 @@ m65_cursor_blink_undraw: lda #0 sta BLNON + // Cursor undraw - color + lda GDCOL + sta_lp (M65_LPNT_IRQ),z + + // Rework pointer to point to screnn memory + jsr m65_cursor_blink_adapt_ptr + // Cursor undraw - character lda GDBLN sta_lp (M65_LPNT_IRQ),z - // Cursor undraw - color - // XXX provide implementation - 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