From: mrdudz Date: Tue, 13 Oct 2015 02:14:04 +0000 (+0200) Subject: another size optimization, make bgcolor() much more robust X-Git-Tag: V2.16~210^2~15 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=08d7eefdd7178705628f3d8ad28e9f9041f2e511;p=cc65 another size optimization, make bgcolor() much more robust --- diff --git a/libsrc/c64/soft80_color.s b/libsrc/c64/soft80_color.s index ab4b4a01f..e84b6fa60 100644 --- a/libsrc/c64/soft80_color.s +++ b/libsrc/c64/soft80_color.s @@ -7,6 +7,8 @@ .export soft80_textcolor, soft80_bgcolor .import soft80_internal_textcolor, soft80_internal_bgcolor + .import soft80_internal_cursorxlsb + .import soft80_kplot, soft80_checkchar .importzp tmp1, tmp2 @@ -17,83 +19,135 @@ soft80_textcolor: ldx soft80_internal_textcolor ; get old value sta soft80_internal_textcolor ; set new value - jsr mkcharcolor +mkcharcolor: + lda soft80_internal_bgcolor + asl a + asl a + asl a + asl a + sta tmp1 ; remember new bg color (high nibble) + ora soft80_internal_textcolor + sta CHARCOLOR ; text/bg combo for new chars txa ; get old value rts soft80_bgcolor: ldx soft80_internal_bgcolor ; get old value + stx tmp2 ; save old value sta soft80_internal_bgcolor ; set new value jsr mkcharcolor - stx tmp2 ; save old value + lda CURS_X + pha + lda CURS_Y + pha + + ldy #0 + ldx #0 + clc + jsr soft80_kplot + + sei + lda $01 + pha + ldx #$34 + stx $01 ; $34 + + ;ldy #0 ; is still 0 + + lda #24 + sta CURS_Y +lpy: + lda #39 + sta CURS_X +lpx: .if SOFT80COLORVOODOO = 1 ; if the old bg color is equal to color ram of that cell, then also ; update the color ram to the new value. - ; FIXME: perhaps we must also check if the non visible character is not - ; a space, and NOT update the color ram in that case. - ldx #$00 -lp1: - .repeat $4,page - .scope - lda soft80_colram+(page*250),x + + inc $01 ; $35 + lda (CRAM_PTR),y ; colram + stx $01 ; $34 + and #$0f cmp tmp2 ; old bg color bne @sk1 + + ; if the left character in the cell is not a space, then dont update + ; the color ram + lda #1 + sta soft80_internal_cursorxlsb + jsr soft80_checkchar + bcc @sk1 lda soft80_internal_bgcolor ; new bg color - sta soft80_colram+(page*250),x -@sk1: - .endscope - .endrepeat - inx - bne lp1 + inc $01 ; $35 + sta (CRAM_PTR),y ; colram + stx $01 ; $34 +@sk1: .endif - - sei - ldy $01 - lda #$34 ; disable I/O - sta $01 - ; if the old bg color is equal to text color in this cell, then also ; update the text color to the new value. - ; FIXME: perhaps we need to check for space, see note above - ldx #$00 -lp2: - .repeat $4,page - .scope - lda soft80_vram+(page*250),x + + lda (CRAM_PTR),y ; vram and #$0f cmp tmp2 ; old bg color bne @sk2 + + ; if there are non space characters in the cell, do not update the + ; color ram + pha + lda #0 + sta soft80_internal_cursorxlsb + jsr soft80_checkchar + pla + bcc @sk2 + + pha + inc soft80_internal_cursorxlsb + jsr soft80_checkchar + pla + bcc @sk2 + lda soft80_internal_bgcolor ; new bg color @sk2: ora tmp1 ; new bg color (high nibble) - sta soft80_vram+(page*250),x - .endscope - .endrepeat + sta (CRAM_PTR),y ; vram - inx - bne lp2 + inc CRAM_PTR + bne @sk3 + inc CRAM_PTR+1 +@sk3: - sty $01 ; enable I/O + lda SCREEN_PTR + clc + adc #8 + sta SCREEN_PTR + bcc @sk4 + inc SCREEN_PTR+1 +@sk4: + + dec CURS_X + bpl lpx + + dec CURS_Y + bpl lpy + + pla + sta $01 ; enable I/O cli - lda tmp2 ; get old value - rts + pla ; CURS_Y + tax + pla ; CURS_X + tay + clc + jsr soft80_kplot -mkcharcolor: - lda soft80_internal_bgcolor - asl a - asl a - asl a - asl a - sta tmp1 ; remember new bg color (high nibble) - ora soft80_internal_textcolor - sta CHARCOLOR ; text/bg combo for new chars + lda tmp2 ; get old value rts ;------------------------------------------------------------------------------- diff --git a/libsrc/c64/soft80_cputc.s b/libsrc/c64/soft80_cputc.s index 0e8cb0bd8..92aa728de 100644 --- a/libsrc/c64/soft80_cputc.s +++ b/libsrc/c64/soft80_cputc.s @@ -8,6 +8,7 @@ .export soft80_cputcxy, soft80_cputc .export soft80_cputdirect, soft80_putchar .export soft80_newline, soft80_plot + .export soft80_checkchar .import popa, _gotoxy @@ -470,15 +471,14 @@ soft80_putcolor: ; test if there is a space or a character at current position ; ; in: x = $34 -; y must be $00 +; $01 must be $34 +; ; out: SEC: space ; CLC: character ; x = $34 ; y = $00 soft80_checkchar: - ;ldy #$00 ; is still $00 - lda soft80_internal_cursorxlsb bne @l1a