From 47090a52fd244efe101f019793f74bf52b413efe Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Tue, 7 Jan 2020 18:52:11 +0100 Subject: [PATCH] work on character inserting --- STATUS.md | 2 +- c64/kernal/keyboard/chrin_keyboard.s | 3 +- c64/kernal/screen/chrout_screen_del.s | 11 ++- c64/kernal/screen/chrout_screen_ins.s | 46 +++++------ .../screen/screen_check_space_ends_line.s | 8 ++ .../screen_get_current_line_logical_length.s | 17 ---- .../screen/screen_get_logical_line_end_ptr.s | 26 ++++++ c64/kernal/screen/screen_grow_logical_line.s | 2 +- c64/kernal/screen/screen_normalize_xy.s | 79 ------------------- 9 files changed, 63 insertions(+), 131 deletions(-) create mode 100644 c64/kernal/screen/screen_check_space_ends_line.s delete mode 100644 c64/kernal/screen/screen_get_current_line_logical_length.s create mode 100644 c64/kernal/screen/screen_get_logical_line_end_ptr.s delete mode 100644 c64/kernal/screen/screen_normalize_xy.s diff --git a/STATUS.md b/STATUS.md index f3574c3c..8ad2dd17 100644 --- a/STATUS.md +++ b/STATUS.md @@ -4,7 +4,7 @@ Here are the features of the Open ROMs not found in the original ROMs from the 80s (many of them are [configurable](CONFIG.md) during compilation): -* improved keyboard scanning, resistant to ghosting and joystick interference (one variant even supports multi-keyy rollover), supports additional C128 keys +* improved keyboard scanning, resistant to ghosting and joystick interference (one variant even supports multi-key rollover), supports additional C128 keys * joystick can be used to move text cursor * pre-defined function keys diff --git a/c64/kernal/keyboard/chrin_keyboard.s b/c64/kernal/keyboard/chrin_keyboard.s index 40966536..77403a84 100644 --- a/c64/kernal/keyboard/chrin_keyboard.s +++ b/c64/kernal/keyboard/chrin_keyboard.s @@ -90,8 +90,7 @@ chrin_enter: sta LXSP+1 // Calculate length - jsr screen_get_current_line_logical_length - tay + jsr screen_get_logical_line_end_ptr iny !: dey bmi empty_line diff --git a/c64/kernal/screen/chrout_screen_del.s b/c64/kernal/screen/chrout_screen_del.s index 0a5521f8..c79d9b3a 100644 --- a/c64/kernal/screen/chrout_screen_del.s +++ b/c64/kernal/screen/chrout_screen_del.s @@ -3,10 +3,7 @@ // CHROUT routine - screen support, DEL key handling // -chrout_screen_DEL: - jmp chrout_screen_done -/* YYY disabled for rework chrout_screen_DEL: // In insert mode it embeds control character @@ -14,6 +11,14 @@ chrout_screen_DEL: beq !+ jmp chrout_screen_quote !: + + + + jmp chrout_screen_done + +/* YYY disabled for rework +chrout_screen_DEL: + ldx PNTR bne chrout_screen_del_column_non_0 diff --git a/c64/kernal/screen/chrout_screen_ins.s b/c64/kernal/screen/chrout_screen_ins.s index 311637f3..20d99a06 100644 --- a/c64/kernal/screen/chrout_screen_ins.s +++ b/c64/kernal/screen/chrout_screen_ins.s @@ -3,39 +3,30 @@ // CHROUT routine - screen support, INS key handling // -chrout_screen_INS: - jmp chrout_screen_done -/* YYY disabled for rework +// YYY does not work properly on growing logical line +// YYY implement LNMX + + chrout_screen_INS: - // Insert (shift-DELETE) + // First check if last character of the line is space - // Abort if line already max length, ie 79th char is not a space - jsr screen_get_current_line_logical_length - cmp #79 - bne !+ - tay - lda (PNT),y - cmp #$20 - beq !+ + jsr screen_check_space_ends_line + beq chrout_screen_ins_possible - // Line is too long to extend - jmp chrout_screen_done - -!: - // Work out if line needs to be expanded, and if so expand it - ldy #39 - lda (PNT),y - cmp #$20 - beq !+ + // Not space, try to grow logical line and check once again jsr screen_grow_logical_line + jsr screen_check_space_ends_line + bne_far chrout_screen_done -!: - // Shuffle chars towards end of line - jsr screen_get_current_line_logical_length - tay + // FALLTROUGH + +chrout_screen_ins_possible: + + // Move chars towards end of the line + jsr screen_get_logical_line_end_ptr !: // Note: While the following routine is obvious to any skilled // in the art as the most obvious simple and efficient solution, @@ -43,7 +34,7 @@ chrout_screen_INS: // in a relatively long verbatim stretch of bytes when compared to // the C64 KERNAL. Thus we have swapped the order, just to reduce // the potential for any argument of copyright infringement, even - // though we really don't believe that the routine can be copyrighted + // though we really do not believe that the routine can be copyrighted // due to the lack of creativity. dey lda (USER),y @@ -63,7 +54,6 @@ chrout_screen_INS: // Put space in the inserted gap lda #$20 - sta (PNT),y + sta (PNT), y jmp chrout_screen_done -*/ \ No newline at end of file diff --git a/c64/kernal/screen/screen_check_space_ends_line.s b/c64/kernal/screen/screen_check_space_ends_line.s new file mode 100644 index 00000000..245ced8d --- /dev/null +++ b/c64/kernal/screen/screen_check_space_ends_line.s @@ -0,0 +1,8 @@ + +screen_check_space_ends_line: + + jsr screen_get_logical_line_end_ptr + lda (PNT), y + cmp #$20 + + rts diff --git a/c64/kernal/screen/screen_get_current_line_logical_length.s b/c64/kernal/screen/screen_get_current_line_logical_length.s deleted file mode 100644 index e81640fe..00000000 --- a/c64/kernal/screen/screen_get_current_line_logical_length.s +++ /dev/null @@ -1,17 +0,0 @@ - -screen_get_current_line_logical_length: - rts - -/* YYY disabled for rework - -screen_get_current_line_logical_length: - ldy TBLX - lda LDTBL,y - bpl !+ - lda #79 - .byte $2c // BIT absolute mode, which we use to skip the next two instruction bytes -!: - lda #39 - sta LNMX - rts -*/ \ No newline at end of file diff --git a/c64/kernal/screen/screen_get_logical_line_end_ptr.s b/c64/kernal/screen/screen_get_logical_line_end_ptr.s new file mode 100644 index 00000000..c6949170 --- /dev/null +++ b/c64/kernal/screen/screen_get_logical_line_end_ptr.s @@ -0,0 +1,26 @@ + + +screen_get_logical_line_end_ptr: + + ldy TBLX + cpy #24 + bcs screen_get_logical_line_end_39 // last line of the screen + + lda LDTBL, y + bpl screen_get_logical_line_end_39 // current line continues previous one + + iny + lda LDTBL, y + bmi screen_get_logical_line_end_39 // current line is not continued + + // FALLTROUGH + +screen_get_logical_line_end_79: + + ldy #79 + rts + +screen_get_logical_line_end_39: + + ldy #39 + rts \ No newline at end of file diff --git a/c64/kernal/screen/screen_grow_logical_line.s b/c64/kernal/screen/screen_grow_logical_line.s index 0f930bd9..096e6bdd 100644 --- a/c64/kernal/screen/screen_grow_logical_line.s +++ b/c64/kernal/screen/screen_grow_logical_line.s @@ -1,5 +1,5 @@ -// YYY test all the cases! +// YYY test all the cases, does not work correctly yet! screen_grow_logical_line_screen_up: diff --git a/c64/kernal/screen/screen_normalize_xy.s b/c64/kernal/screen/screen_normalize_xy.s deleted file mode 100644 index 90486ed3..00000000 --- a/c64/kernal/screen/screen_normalize_xy.s +++ /dev/null @@ -1,79 +0,0 @@ - -// -// Normalise X and Y values -// If X < 0, then make X = X + 40 (or 80, if previous line is linked) -// - -/* YYY disabled for rework - -screen_normalize_xy: - - lda PNTR - bpl x_not_negative - dec TBLX - // Check that we didn't go backwards off the top of the screen - bpl !+ - lda #0 - sta TBLX - -!: jsr screen_add_40_to_PNTR - - // Check if line is linked, if so, add 40 again - ldy TBLX - lda LDTBL,y - bpl !+ - jsr screen_add_40_to_PNTR -!: - -x_not_negative: - // Work out if X is too big - ldy TBLX - lda LDTBL,y - bpl !+ - lda #79 - skip_2_bytes_trash_nvz -!: lda #39 - cmp PNTR - bcs x_not_too_big - - // X value is too big, so subtract 40 and increment Y - lda PNTR - sec - sbc #40 - sta PNTR - inc TBLX - -x_not_too_big: - - // Make sure Y isn't negative - lda TBLX - bpl !+ - lda #0 - sta TBLX -!: - // Make sure Y isn't too large for absolute size of - // screen - cmp #24 - bcc !+ - lda #24 - sta TBLX -!: - // Make sure Y isn't too much for the screen, taking - // into account the line link table - ldy #24 // max allowable line - ldx #0 -link_count_loop: - lda LDTBL,x - bpl !+ - dey -!: inx - cpx #25 - bne link_count_loop - tya - cmp TBLX - bcs y_ok - sta TBLX -y_ok: - rts - -*/ \ No newline at end of file