diff --git a/c64/kernal/screen/chrout_screen_ins.s b/c64/kernal/screen/chrout_screen_ins.s index d7576c2e..52861ba1 100644 --- a/c64/kernal/screen/chrout_screen_ins.s +++ b/c64/kernal/screen/chrout_screen_ins.s @@ -4,29 +4,24 @@ // -// YYY does not work properly when insertion no longer possible -// YYY does not work properlyy in second part of logical line +// YYY moves cursor down the first time no more insertion is possible +// YYY in second part of the logical line moves everything froom the start of the line chrout_screen_INS: - // First check if last character of the line is space + // First check if last character of the logiccall line is space jsr screen_check_space_ends_line beq chrout_screen_ins_possible - // Not space, try to grow logical line and check once again + // Not space, we cannot insert anything - jsr screen_grow_logical_line - jsr screen_check_space_ends_line bne_far chrout_screen_calc_lptr_done - - // FALLTROUGH chrout_screen_ins_possible: // Move chars towards end of the line - jsr screen_calculate_PNT_USER jsr screen_get_logical_line_end_ptr !: // Note: While the following routine is obvious to any skilled @@ -57,4 +52,11 @@ chrout_screen_ins_possible: lda #$20 sta (PNT), y + // If line does not end with space now, grow try to grow the logical line + + jsr screen_check_space_ends_line + beq !+ + + jsr screen_grow_logical_line +!: jmp chrout_screen_calc_lptr_done diff --git a/c64/kernal/screen/screen_check_space_ends_line.s b/c64/kernal/screen/screen_check_space_ends_line.s index 245ced8d..cbd641f3 100644 --- a/c64/kernal/screen/screen_check_space_ends_line.s +++ b/c64/kernal/screen/screen_check_space_ends_line.s @@ -1,8 +1,10 @@ - -screen_check_space_ends_line: - - jsr screen_get_logical_line_end_ptr - lda (PNT), y - cmp #$20 - - rts + +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_logical_line_end_ptr.s b/c64/kernal/screen/screen_get_logical_line_end_ptr.s index 1d09f70c..d396db35 100644 --- a/c64/kernal/screen/screen_get_logical_line_end_ptr.s +++ b/c64/kernal/screen/screen_get_logical_line_end_ptr.s @@ -1,25 +1,25 @@ - - -screen_get_logical_line_end_ptr: - - ldy TBLX - cpy #24 - bcs screen_get_logical_line_end_39 // last line of the screen - - lda LDTBL+0, y - bpl screen_get_logical_line_end_39 // current line continues previous one - - lda LDTBL+1, 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 + + +screen_get_logical_line_end_ptr: + + ldy TBLX + cpy #24 + bcs screen_get_logical_line_end_39 // last line of the screen + + lda LDTBL+0, y + bpl screen_get_logical_line_end_39 // current line continues previous one + + lda LDTBL+1, 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