From 381a32d9aa44fc49c9d34e812212405bde24f4af Mon Sep 17 00:00:00 2001 From: compyx Date: Sat, 11 Jul 2020 13:18:14 +0200 Subject: [PATCH] C64 soft80-conio cgetc: save 14 cycles in `invertcursor` By 'inverting' the loop, we can save 16 cycles by removing the `cpy #8`, saving 16 cycles. But we need an extra `ldy #7` at the start of the loop, so the total cycles saved is 14. Code size doesn't increase due to the addition of the `ldy #7` negating the removal of the `cpy #xx`. --- libsrc/c64/soft80_cgetc.s | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/libsrc/c64/soft80_cgetc.s b/libsrc/c64/soft80_cgetc.s index 05e9e5b47..aa12cd8ca 100644 --- a/libsrc/c64/soft80_cgetc.s +++ b/libsrc/c64/soft80_cgetc.s @@ -46,17 +46,16 @@ invertcursor: lda #$34 sta $01 - ldy #$00 jsr setcolor ldx soft80_internal_cursorxlsb + ldy #7 @lp1: lda (SCREEN_PTR),y eor nibble,x sta (SCREEN_PTR),y - iny - cpy #8 - bne @lp1 + dey + bpl @lp1 pla sta $01 ; enable I/O @@ -67,7 +66,7 @@ invertcursor: ; shown using the current textcolor without disturbing the "color voodoo" ; in soft80_cputc setcolor: - ;ldy #0 ; is 0 + ldy #0 bcs @set ; restore old value lda tmp1