jsr mkcharcolor
+.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 $3,page
+ .repeat $4,page
.scope
- lda soft80_colram+(page*$100),x
+ lda soft80_colram+(page*250),x
and #$0f
cmp tmp2 ; old bg color
bne @sk1
- lda __bgcolor
- sta soft80_colram+(page*$100),x
+ lda __bgcolor ; new bg color
+ sta soft80_colram+(page*250),x
@sk1:
.endscope
.endrepeat
- .scope
- lda soft80_colram+$2e8,x
- and #$0f
- cmp tmp2 ; old bg color
- bne @sk1
- lda __bgcolor
- sta soft80_colram+$2e8,x
-@sk1:
- .endscope
-
inx
bne lp1
+.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 $3,page
- lda soft80_vram+(page*$100),x
+lp2:
+ .repeat $4,page
+ .scope
+ lda soft80_vram+(page*250),x
and #$0f
+ cmp tmp2 ; old bg color
+ bne @sk2
+ lda __bgcolor ; new bg color
+@sk2:
ora tmp1 ; new bg color (high nibble)
- sta soft80_vram+(page*$100),x
+ sta soft80_vram+(page*250),x
+ .endscope
.endrepeat
- lda soft80_vram+$2e8,x
- and #$0f
- ora tmp1 ; new bg color (high nibble)
- sta soft80_vram+$2e8,x
inx
- bne @lp2
+ bne lp2
sty $01 ; enable I/O
cli
.export soft80_cputcxy, soft80_cputc
.export soft80_cputdirect, soft80_putchar
- .export soft80_putcolor
.export soft80_newline, soft80_plot
.import popa, _gotoxy
.include "c64.inc"
.include "soft80.inc"
+.if SOFT80COLORVOODOO = 1
+ .export soft80_putcolor
+.endif
+
soft80_cputcxy:
pha ; Save C
jsr popa ; Get Y
; returns: Y: cursor X position
; this function is going to be used a lot so we unroll it a bit for speed
-;--- start color vodoo
-
-; remove color from cell
-; y unmodified
-remcolor:
-
- ;ldy #$00 ; is still $00
-
- lda (CRAM_PTR),y ; vram
- and #$0f
- cmp __bgcolor
- jeq @l2b ; vram==bgcolor
-
- inc $01
- lda (CRAM_PTR),y ; colram
- stx $01 ;$34
- and #$0f
- cmp __bgcolor
- beq @l2s ; colram==bgcolor
-
- ; vram = colram
- ;inc $01
- ;lda (CRAM_PTR),y ; colram
- ;stx $01 ;$34
- ;and #$0f
-
- sta tmp3
- lda (CRAM_PTR),y ; vram
- and #$f0
- ora tmp3
- sta (CRAM_PTR),y ; vram
-
- ; colram = bgcolor
- lda __bgcolor
- inc $01
- sta (CRAM_PTR),y ; colram
- stx $01 ;$34
-
- jmp @l2b
-
-@l2s:
- ; colram is bgcolor
- ; => only one char in cell used
-
- jsr soft80_checkchar
- bcc @l2b ; space at current position
-
- ; vram = bgcolor
- lda (CRAM_PTR),y ; vram
- and #$f0
- ora __bgcolor
- sta (CRAM_PTR),y ; vram
-@l2b:
- rts
-
-; put color to cell
-; y unmodified
-soft80_putcolor:
-
- ;ldy #$00 ; is still $00
-
- lda (CRAM_PTR),y ; vram
- and #$0f
- cmp __bgcolor
- beq @l2s ; vram==bgcolor => first char in cell
-
- ; vram!=bgcolor => second char in cell
-
- inc $01 ;$35
- lda (CRAM_PTR),y ; colram
- stx $01 ;$34
- and #$0f
- cmp __bgcolor
- bne @l2s ; colram!=bgcolor
-
- ; colram==bgcolor => second char in cell or overwrite 1st char
-
- jsr soft80_checkchar
- bcs @l2a ; char at current position => overwrite 1st
-
- ; colram=vram
- lda (CRAM_PTR),y ; vram
- inc $01
- sta (CRAM_PTR),y ; colram
- stx $01 ;$34
-
- ;jmp @l2a
-
-@l2s:
- ; colram!=bgcolor => alread 2 chars in cell
-@l2a:
-
- ; Set color
- lda CHARCOLOR
- sta (CRAM_PTR),y ; vram
-
- rts
-
-
-;--- end color vodoo
-
- .export soft80_checkchar
-
-; test if there is a space or a character at current position
-; CLC: space SEC: character
-soft80_checkchar:
-
- ;ldy #$00 ; is still $00
-
- lda CURS_X
- and #$01
- jne @l1a
-
- .repeat 8,line
- lda (SCREEN_PTR),y
- and #$f0
- cmp #$f0
- bne @l2b
- .if (line < 7)
- iny
- .endif
- .endrepeat
-
- ldy #$00
- clc
- rts
-@l2b:
- ldy #$00
- sec
- rts
-@l1a:
- .repeat 8,line
- lda (SCREEN_PTR),y
- and #$0f
- cmp #$0f
- bne @l2bb
- .if line < 7
- iny
- .endif
- .endrepeat
- ldy #$00
- clc
- rts
-@l2bb:
- ldy #$00
- sec
- rts
-
+.if SOFT80FASTSPACE = 1
; output space
-
+; in: y must be $00
_space:
lda RVS
jne _spaceinvers
+.if SOFT80COLORVOODOO = 1
jsr remcolor
-
+.endif
;ldy #$00 ; is still $00
lda CURS_X
jmp _back
; output inverted space
-
+; in: y must be $00
_spaceinvers:
+.if SOFT80COLORVOODOO = 1
jsr soft80_putcolor
+.else
+ lda CHARCOLOR
+ sta (CRAM_PTR),y ; vram
+.endif
lda CURS_X
and #$01
.endrepeat
jmp _back
+.endif
; output a character
soft80_putchar:
- sta tmp3
+ sta tmp3 ; remember charcode
sei
ldx $01
stx $01 ; will stay $34 for space
ldy #$00 ; will be $00 from now on
+.if SOFT80FASTSPACE = 1
cmp #' ' ; space is a special (optimized) case
jeq _space
+.endif
+.if SOFT80COLORVOODOO = 1
jsr soft80_putcolor
+.else
+ lda CHARCOLOR
+ sta (CRAM_PTR),y ; vram
+.endif
+ ; output character
-; output character
-char:
- ldx tmp3
+ ldx tmp3 ; get charcode
lda RVS
jne _invers
.endif
.endrepeat
jmp _back
+
+;-------------------------------------------------------------------------------
+
+.if SOFT80COLORVOODOO = 1
+;--- start color vodoo
+
+; remove color from cell, called before putting a "space" character to the bitmap
+; y unmodified
+remcolor:
+
+ ;ldy #$00 ; is still $00
+
+ ; if the textcolor in vram is equal to the background color, then
+ ; no (visible) character is in the current cell and we can exit
+ ; immediately.
+ lda (CRAM_PTR),y ; vram (textcolor)
+ and #$0f
+ cmp __bgcolor
+ jeq @l2b ; yes, vram==bgcolor
+
+ ; now check if the textcolor in color ram is equal the background color,
+ ; if yes then there is only one (visible) character in the current cell
+ inc $01
+ lda (CRAM_PTR),y ; colram (2nd textcolor)
+ stx $01 ;$34
+ and #$0f
+ cmp __bgcolor
+ beq @l2s ; yes, colram==bgcolor
+
+ ; two characters in the current cell, of which one will get removed
+
+ ; vram = colram
+ ;inc $01
+ ;lda (CRAM_PTR),y ; colram
+ ;stx $01 ;$34
+ ;and #$0f
+
+ ; move 2nd text color to vram
+ sta tmp3
+ lda (CRAM_PTR),y ; vram
+ and #$f0
+ ora tmp3
+ sta (CRAM_PTR),y ; vram
+
+ ; colram = bgcolor
+ lda __bgcolor
+ inc $01
+ sta (CRAM_PTR),y ; colram
+ stx $01 ;$34
+
+ jmp @l2b
+
+@l2s:
+ ; colram is bgcolor
+ ; => only one char in cell used
+
+ jsr soft80_checkchar
+ bcc @l2b ; space at current position
+
+ ; vram (textcolor) = bgcolor
+ lda (CRAM_PTR),y ; vram
+ and #$f0
+ ora __bgcolor
+ sta (CRAM_PTR),y ; vram
+@l2b:
+ rts
+
+; put color to cell
+; in: $01 is $34 (RAM under I/O) when entering
+; y must be $00
+; out: y = $00
+soft80_putcolor:
+
+ ;ldy #$00 ; is still $00
+
+ lda (CRAM_PTR),y ; vram
+ and #$0f
+ cmp __bgcolor
+ beq @l2s ; vram==bgcolor => first char in cell
+
+ ; vram!=bgcolor => second char in cell
+
+ inc $01 ;$35
+ lda (CRAM_PTR),y ; colram
+ stx $01 ;$34
+ and #$0f
+ cmp __bgcolor
+ bne @l2s ; colram!=bgcolor
+
+ ; colram==bgcolor => second char in cell or overwrite 1st char
+
+ jsr soft80_checkchar
+ bcs @l2a ; char at current position => overwrite 1st
+
+ ; colram=vram
+ lda (CRAM_PTR),y ; vram
+ inc $01
+ sta (CRAM_PTR),y ; colram
+ stx $01 ;$34
+
+ ;jmp @l2a
+
+@l2s:
+ ; colram!=bgcolor => alread 2 chars in cell
+@l2a:
+
+ ; Set color
+ lda CHARCOLOR
+ sta (CRAM_PTR),y ; vram
+
+ rts
+
+ ;.export soft80_checkchar
+
+; test if there is a space or a character at current position
+; in: y must be $00
+; out: CLC: space SEC: character
+; y = $00
+soft80_checkchar:
+
+ ;ldy #$00 ; is still $00
+
+ lda CURS_X
+ and #$01
+ jne @l1a
+
+ .repeat 8,line
+ lda (SCREEN_PTR),y
+ and #$f0
+ cmp #$f0
+ bne @l2b
+ .if (line < 7)
+ iny
+ .endif
+ .endrepeat
+
+ ldy #$00
+ clc
+ rts
+@l2b:
+ ldy #$00
+ sec
+ rts
+@l1a:
+ .repeat 8,line
+ lda (SCREEN_PTR),y
+ and #$0f
+ cmp #$0f
+ bne @l2bb
+ .if line < 7
+ iny
+ .endif
+ .endrepeat
+ ldy #$00
+ clc
+ rts
+@l2bb:
+ ldy #$00
+ sec
+ rts
+
+;--- end color vodoo
+.endif