diff --git a/STATUS.md b/STATUS.md index 87559036..3ba2e3d0 100644 --- a/STATUS.md +++ b/STATUS.md @@ -237,7 +237,7 @@ Not all of them - only these we want to have implemented. | `$E544` | clear screen | DONE | | | `$E50C` | set cursor position | PARTIAL | | | `$E566` | home cursor | DONE | | -| `$E56C` | set PNTR value | | | +| `$E56C` | set PNT and USER values | DONE | | | `$E5A0` | setup VIC II & I/O | DONE | | | `$E6B6` | advance cursor | NOT DONE | | | `$E701` | previous line | NOT DONE | | diff --git a/c64/aliases/,aliases_ram_lowmem.s b/c64/aliases/,aliases_ram_lowmem.s index cf1f4ee8..5d5af9ba 100644 --- a/c64/aliases/,aliases_ram_lowmem.s +++ b/c64/aliases/,aliases_ram_lowmem.s @@ -153,10 +153,10 @@ .label BLNON = $CF // cursor visibility flag .label CRSW = $D0 // whether to input from screen or keyboard .label PNT = $D1 // $D1-$D2 pointer to the current screen line - .label PNTR = $D3 // current screen X position + .label PNTR = $D3 // current screen X position (logical column), 0-79 .label QTSW = $D4 // quote mode flag .label LNMX = $D5 // logical line length, [!] our usage probably differs in details - .label TBLX = $D6 // current screen Y position + .label TBLX = $D6 // current screen Y position (row), 0-24 .label SCHAR = $D7 // ASCII value of the last printed character .label INSRT = $D8 // insert mode flag/counter .label LDTBL = $D9 // $D9-$F2 screen line link table, [!] our usage is different XXX give more details diff --git a/c64/kernal/screen/clear_screen_real.s b/c64/kernal/screen/clear_screen_real.s index fc115b26..5766dbf6 100644 --- a/c64/kernal/screen/clear_screen_real.s +++ b/c64/kernal/screen/clear_screen_real.s @@ -8,9 +8,6 @@ clear_screen_real: - // YYY - do we need this? First disable the cursor - // jsr cursor_disable - // Clear the line link table - cheecked on original ROMs, // the highest bit set means that the line is NOT a logical // continuation of the previous one diff --git a/c64/kernal/screen/e566.cursor_home.s b/c64/kernal/screen/e566.cursor_home.s index 98566eb8..e5c22d17 100644 --- a/c64/kernal/screen/e566.cursor_home.s +++ b/c64/kernal/screen/e566.cursor_home.s @@ -9,7 +9,7 @@ cursor_home: lda #$00 - sta PNTR // current column + sta PNTR // current column (logical) sta TBLX // current row // FALLTROUGH to the next routine diff --git a/c64/kernal/screen/e56c.screen_calculate_pnt.s b/c64/kernal/screen/e56c.screen_calculate_pnt.s deleted file mode 100644 index eec4c250..00000000 --- a/c64/kernal/screen/e56c.screen_calculate_pnt.s +++ /dev/null @@ -1,92 +0,0 @@ - -// -// 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 -// - $C8 - INDX - length of line minus 1 during screen input. Values: $27, 39; $4F, 79. -// - $C9 - LXSP+0 - cursor row during screen input. Values: $00-$18, 0-24. -// - $CA - LXSP+1 - cursor column during screen input. Values: $00-$27, 0-39. -// - $CC - BLNSW - cursor visibility switch. Values: $01-$FF: Cursor is off. -// - $CD - BLNCT - delay counter for changing cursor phase. Values: -// - $CE - GDBLN - screen code of character under cursor -// - $CF - BLNON - cursor phase switch -// - $D0 - CRSW - end of line switch during screen input -// - $D1-$D2 - PNT - pointer to current line in screen memory. -// - $D3 - PNTR - current cursor column. Values: $00-$27, 0-39. -// - $D4 - QTSW - quotation mode switch -// - $D5 - LNMX - length of current screen line minus 1. Values: $27, 39; $4F, 79. -// - $D6 - TBLX - current cursor row. Values: $00-$18, 0-24. -// - $D8 - INSRT - number of insertions -// - $D9-$F1 - LDTBL - link table -// - $F2 - temporary value for screen scroll -// - $F3-$F4 - USER - pointer to current line in Color RAM. -// - $02A5 - TLNIDX - number of line currently being scrolled during scrolling the screen - - -/* 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 diff --git a/c64/kernal/screen/e56c.screen_calculate_pnt_user.s b/c64/kernal/screen/e56c.screen_calculate_pnt_user.s new file mode 100644 index 00000000..d1d247ce --- /dev/null +++ b/c64/kernal/screen/e56c.screen_calculate_pnt_user.s @@ -0,0 +1,51 @@ + +// +// Set pointer (PNT) to current screen line , described in: +// +// - [CM64] Computes Mapping the Commodore 64 - page 216 +// - http://sta.c64.org/cbm64scrfunc.html +// + + +screen_calculate_PNT_USER: + + // YYY jsr screen_normalize_xy - do we need this? probably not + + // Reset pointer to start of screen + + lda HIBASE + sta PNT+1 + lda #$00 + sta PNT+0 + + // Add 40 to PNT for every line + + ldx TBLX + beq screen_calculate_USER +!: + lda #40 + clc + adc PNT+0 + sta PNT+0 + bcc !+ + inc PNT+1 +!: + dex + bne !-- + + // FALLTROUGH + +screen_calculate_USER: + + // Calculate USER (pointer to the current line in color RAM) + + lda PNT+0 + sta USER+0 + lda PNT+1 + sec + sbc HIBASE + clc + adc #>$d800 + sta USER+1 + + rts