From ca3b678578e6febd4168de40c4088a3787991fee Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Wed, 1 Jan 2020 20:47:18 +0100 Subject: [PATCH] tested cursor homing, started work on PNT recalculation --- STATUS.md | 3 +- c64/kernal/,stubs/e566.home_cursor.s | 4 -- c64/kernal/screen/e544.clear_screen.jmp.s | 7 +- c64/kernal/screen/e566.cursor_home.s | 15 ++++ c64/kernal/{,stubs => screen}/e566.interop | 0 c64/kernal/screen/e56c.interop | 4 ++ ...sor_home.s => e56c.screen_calculate_pnt.s} | 72 ++++++++++++++++--- .../screen/screen_calculate_line_pointer.s | 57 --------------- 8 files changed, 88 insertions(+), 74 deletions(-) delete mode 100644 c64/kernal/,stubs/e566.home_cursor.s create mode 100644 c64/kernal/screen/e566.cursor_home.s rename c64/kernal/{,stubs => screen}/e566.interop (100%) create mode 100644 c64/kernal/screen/e56c.interop rename c64/kernal/screen/{cursor_home.s => e56c.screen_calculate_pnt.s} (58%) delete mode 100644 c64/kernal/screen/screen_calculate_line_pointer.s diff --git a/STATUS.md b/STATUS.md index 1697e3ef..87559036 100644 --- a/STATUS.md +++ b/STATUS.md @@ -236,7 +236,8 @@ Not all of them - only these we want to have implemented. | `$E51B` | init screen keyboard, no VIC | DONE | | | `$E544` | clear screen | DONE | | | `$E50C` | set cursor position | PARTIAL | | -| `$E566` | home cursor | NOT DONE | | +| `$E566` | home cursor | DONE | | +| `$E56C` | set PNTR value | | | | `$E5A0` | setup VIC II & I/O | DONE | | | `$E6B6` | advance cursor | NOT DONE | | | `$E701` | previous line | NOT DONE | | diff --git a/c64/kernal/,stubs/e566.home_cursor.s b/c64/kernal/,stubs/e566.home_cursor.s deleted file mode 100644 index 4e5b7d5f..00000000 --- a/c64/kernal/,stubs/e566.home_cursor.s +++ /dev/null @@ -1,4 +0,0 @@ - -// XXX provide documentation and implementation - - STUB_IMPLEMENTATION() diff --git a/c64/kernal/screen/e544.clear_screen.jmp.s b/c64/kernal/screen/e544.clear_screen.jmp.s index 6adfba39..1e9b4a2e 100644 --- a/c64/kernal/screen/e544.clear_screen.jmp.s +++ b/c64/kernal/screen/e544.clear_screen.jmp.s @@ -1,6 +1,9 @@ -// Clear screen and initialise line link table -// (Compute's Mapping the 64 p215-216) +// +// Clear screen and initialise line link table, described in: +// +// - [CM64] Computes Mapping the Commodore 64 - pages 215-216 +// clear_screen: diff --git a/c64/kernal/screen/e566.cursor_home.s b/c64/kernal/screen/e566.cursor_home.s new file mode 100644 index 00000000..98566eb8 --- /dev/null +++ b/c64/kernal/screen/e566.cursor_home.s @@ -0,0 +1,15 @@ + +// +// Home the cursor, described in: +// +// - [CM64] Computes Mapping the Commodore 64 - page 216 +// + + +cursor_home: + + lda #$00 + sta PNTR // current column + sta TBLX // current row + + // FALLTROUGH to the next routine diff --git a/c64/kernal/,stubs/e566.interop b/c64/kernal/screen/e566.interop similarity index 100% rename from c64/kernal/,stubs/e566.interop rename to c64/kernal/screen/e566.interop diff --git a/c64/kernal/screen/e56c.interop b/c64/kernal/screen/e56c.interop new file mode 100644 index 00000000..6281847b --- /dev/null +++ b/c64/kernal/screen/e56c.interop @@ -0,0 +1,4 @@ + +This is a well-known address, probably used by lots of software. See for example here: + +- https://www.lemon64.com/forum/viewtopic.php?t=69526&sid=836d087e9759db667ba3bb1732eea266 diff --git a/c64/kernal/screen/cursor_home.s b/c64/kernal/screen/e56c.screen_calculate_pnt.s similarity index 58% rename from c64/kernal/screen/cursor_home.s rename to c64/kernal/screen/e56c.screen_calculate_pnt.s index c73d1237..eec4c250 100644 --- a/c64/kernal/screen/cursor_home.s +++ b/c64/kernal/screen/e56c.screen_calculate_pnt.s @@ -1,7 +1,16 @@ // -// Home the cursor (Compute's Mapping the 64 p216) +// Set pointer (PNT) to current screen line , described in: // +// - [CM64] Computes Mapping the Commodore 64 - page 216 +// + + +screen_calculate_PNT: + + // YYY implement this! + rts + // Variables: (http://sta.c64.org/cbm64mem.html) // - $C7 - RVS - reverse mode switch @@ -25,16 +34,59 @@ // - $02A5 - TLNIDX - number of line currently being scrolled during scrolling the screen -cursor_home: - jmp cursor_home - - /* YYY disabled for rework -cursor_home: - lda #$00 - sta PNTR // x position - sta TBLX // y position +screen_calculate_line_pointer: + jsr screen_normalize_xy + + // Reset pointer to start of screen + lda HIBASE + sta PNT+1 + lda #0 + sta PNT+0 - jmp screen_calculate_line_pointer + // Add 40 for every line, or 80 if the lines are linked + ldx TBLX + +!: + // Stop if we have counted enough lines + beq !+ + + // Add 40 or 80 based on whether the line is linked + // or not. + ldy #40 + // -1 offset is because we count down from N to 1, not + // N-1 to 0. + lda LDTBL-1,x + bpl sclp_l1 + ldy #80 +sclp_l1: + // Add computed line length to pointer value + tya + clc + adc PNT+0 + sta PNT+0 + lda PNT+1 + adc #0 + sta PNT+1 + + // Loop back to next line + dex + jmp !- +!: + + // FALLTHROUGH + +update_colour_line_pointer: + // Now setup pointer to colour RAM + lda PNT+0 + sta USER+0 + lda PNT+1 + sec + sbc HIBASE + clc + adc #>$d800 + sta USER+1 + + rts */ \ No newline at end of file diff --git a/c64/kernal/screen/screen_calculate_line_pointer.s b/c64/kernal/screen/screen_calculate_line_pointer.s deleted file mode 100644 index 9383646d..00000000 --- a/c64/kernal/screen/screen_calculate_line_pointer.s +++ /dev/null @@ -1,57 +0,0 @@ - -/* YYY disabled for rework - -screen_calculate_line_pointer: - jsr screen_normalize_xy - - // Reset pointer to start of screen - lda HIBASE - sta PNT+1 - lda #0 - sta PNT+0 - - // Add 40 for every line, or 80 if the lines are linked - ldx TBLX - -!: - // Stop if we have counted enough lines - beq !+ - - // Add 40 or 80 based on whether the line is linked - // or not. - ldy #40 - // -1 offset is because we count down from N to 1, not - // N-1 to 0. - lda LDTBL-1,x - bpl sclp_l1 - ldy #80 -sclp_l1: - // Add computed line length to pointer value - tya - clc - adc PNT+0 - sta PNT+0 - lda PNT+1 - adc #0 - sta PNT+1 - - // Loop back to next line - dex - jmp !- -!: - - // FALLTHROUGH - -update_colour_line_pointer: - // Now setup pointer to colour RAM - lda PNT+0 - sta USER+0 - lda PNT+1 - sec - sbc HIBASE - clc - adc #>$d800 - sta USER+1 - - rts -*/ \ No newline at end of file