rewrote color voodoo
This commit is contained in:
@@ -4,23 +4,22 @@
|
|||||||
|
|
||||||
.export soft80_cgetc
|
.export soft80_cgetc
|
||||||
.import cursor
|
.import cursor
|
||||||
|
.importzp tmp1
|
||||||
|
|
||||||
.include "c64.inc"
|
.include "c64.inc"
|
||||||
.include "soft80.inc"
|
.include "soft80.inc"
|
||||||
|
|
||||||
.if SOFT80COLORVOODOO = 1
|
|
||||||
.import soft80_putcolor
|
|
||||||
.endif
|
|
||||||
|
|
||||||
soft80_cgetc:
|
soft80_cgetc:
|
||||||
lda KEY_COUNT ; Get number of characters
|
lda KEY_COUNT ; Get number of characters
|
||||||
bne L3 ; Jump if there are already chars waiting
|
bne L3 ; Jump if there are already chars waiting
|
||||||
|
|
||||||
|
ldx #1
|
||||||
jsr invertcursor ; set cursor on or off accordingly
|
jsr invertcursor ; set cursor on or off accordingly
|
||||||
|
|
||||||
L1: lda KEY_COUNT ; wait for key
|
L1: lda KEY_COUNT ; wait for key
|
||||||
beq L1
|
beq L1
|
||||||
|
|
||||||
|
ldx #0
|
||||||
jsr invertcursor ; set cursor on or off accordingly
|
jsr invertcursor ; set cursor on or off accordingly
|
||||||
|
|
||||||
L3: jsr KBDREAD ; Read char and return in A
|
L3: jsr KBDREAD ; Read char and return in A
|
||||||
@@ -36,18 +35,13 @@ invertcursor:
|
|||||||
@invert:
|
@invert:
|
||||||
|
|
||||||
sei
|
sei
|
||||||
lda $01
|
lda $01 ; enable RAM under I/O
|
||||||
pha
|
pha
|
||||||
lda #$34 ; enable RAM under I/O
|
lda #$34
|
||||||
sta $01
|
sta $01
|
||||||
|
|
||||||
ldy #$00
|
ldy #$00
|
||||||
.if SOFT80COLORVOODOO = 1
|
jsr setcolor
|
||||||
jsr soft80_putcolor
|
|
||||||
.else
|
|
||||||
lda CHARCOLOR
|
|
||||||
sta (CRAM_PTR),y ; vram
|
|
||||||
.endif
|
|
||||||
|
|
||||||
lda CURS_X
|
lda CURS_X
|
||||||
and #$01
|
and #$01
|
||||||
@@ -65,6 +59,24 @@ invertcursor:
|
|||||||
cli
|
cli
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
; do not use soft80_putcolor here to make sure the cursor is always
|
||||||
|
; shown using the current textcolor without disturbing the "color voodoo"
|
||||||
|
; in soft80_cputc
|
||||||
|
setcolor:
|
||||||
|
;ldy #0 ; is 0
|
||||||
|
txa
|
||||||
|
bne @set
|
||||||
|
; restore old value
|
||||||
|
lda tmp1
|
||||||
|
sta (CRAM_PTR),y ; vram
|
||||||
|
rts
|
||||||
|
@set:
|
||||||
|
lda (CRAM_PTR),y ; vram
|
||||||
|
sta tmp1
|
||||||
|
lda CHARCOLOR
|
||||||
|
sta (CRAM_PTR),y ; vram
|
||||||
|
rts
|
||||||
|
|
||||||
.rodata
|
.rodata
|
||||||
nibble: .byte $f0, $0f
|
nibble: .byte $f0, $0f
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
.import popa, _gotoxy
|
.import popa, _gotoxy
|
||||||
.import xsize
|
.import xsize
|
||||||
.import soft80_kplot
|
.import soft80_kplot
|
||||||
.import __bgcolor
|
.import __bgcolor, __textcolor
|
||||||
|
|
||||||
.importzp tmp4,tmp3
|
.importzp tmp4,tmp3
|
||||||
|
|
||||||
@@ -300,12 +300,36 @@ _invers:
|
|||||||
jmp _back
|
jmp _back
|
||||||
|
|
||||||
;-------------------------------------------------------------------------------
|
;-------------------------------------------------------------------------------
|
||||||
|
; optional "color voodoo". the problem is that each 8x8 cell can only contain
|
||||||
|
; two colors, one of which is used for the background color, so two characters
|
||||||
|
; have to share the same text color.
|
||||||
|
;
|
||||||
|
; - in a cell that contains two spaces, both the color ram and the text color
|
||||||
|
; in vram contain the background color
|
||||||
|
;
|
||||||
|
; - in a cell that contains one character, its text color goes into vram. the
|
||||||
|
; color ram contains the background color.
|
||||||
|
;
|
||||||
|
; - in a cell that contains two characters, the color of the left character goes
|
||||||
|
; to vram (and is shared by both for display). the "would be" color of the
|
||||||
|
; right character goes to color ram as a reminder and can be restored when one
|
||||||
|
; of the two characters is cleared by a space.
|
||||||
|
|
||||||
.if SOFT80COLORVOODOO = 1
|
.if SOFT80COLORVOODOO = 1
|
||||||
;--- start color vodoo
|
|
||||||
|
|
||||||
; remove color from cell, called before putting a "space" character to the bitmap
|
; remove color from cell, called before putting a "space" character to the bitmap
|
||||||
; y unmodified
|
;
|
||||||
|
; __ -> __ -
|
||||||
|
; _A -> _A -
|
||||||
|
; B_ -> B_ -
|
||||||
|
; _A -> __ vram = bgcol
|
||||||
|
; B_ -> __ vram = bgcol
|
||||||
|
; BA -> _A vram = colram, colram = bgcol
|
||||||
|
; BA -> B_ colram = bgcol
|
||||||
|
;
|
||||||
|
; in: x must be $34
|
||||||
|
; y must be $00
|
||||||
|
; out: y = $00
|
||||||
remcolor:
|
remcolor:
|
||||||
|
|
||||||
;ldy #$00 ; is still $00
|
;ldy #$00 ; is still $00
|
||||||
@@ -316,16 +340,16 @@ remcolor:
|
|||||||
lda (CRAM_PTR),y ; vram (textcolor)
|
lda (CRAM_PTR),y ; vram (textcolor)
|
||||||
and #$0f
|
and #$0f
|
||||||
cmp __bgcolor
|
cmp __bgcolor
|
||||||
jeq @l2b ; yes, vram==bgcolor
|
beq @sk1 ; yes, vram==bgcolor
|
||||||
|
|
||||||
; now check if the textcolor in color ram is equal the background color,
|
; 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
|
; if yes then there is only one (visible) character in the current cell
|
||||||
inc $01
|
inc $01 ; $35
|
||||||
lda (CRAM_PTR),y ; colram (2nd textcolor)
|
lda (CRAM_PTR),y ; colram (2nd textcolor)
|
||||||
stx $01 ;$34
|
stx $01 ; $34
|
||||||
and #$0f
|
and #$0f
|
||||||
cmp __bgcolor
|
cmp __bgcolor
|
||||||
beq @l2s ; yes, colram==bgcolor
|
beq @sk2 ; yes, colram==bgcolor
|
||||||
|
|
||||||
; two characters in the current cell, of which one will get removed
|
; two characters in the current cell, of which one will get removed
|
||||||
|
|
||||||
@@ -334,41 +358,58 @@ remcolor:
|
|||||||
;lda (CRAM_PTR),y ; colram
|
;lda (CRAM_PTR),y ; colram
|
||||||
;stx $01 ;$34
|
;stx $01 ;$34
|
||||||
;and #$0f
|
;and #$0f
|
||||||
|
sta tmp3 ; A contains colram
|
||||||
|
|
||||||
; move 2nd text color to vram
|
lda CURS_X
|
||||||
sta tmp3
|
and #$01
|
||||||
|
bne @sk3
|
||||||
|
|
||||||
|
; vram = colram
|
||||||
lda (CRAM_PTR),y ; vram
|
lda (CRAM_PTR),y ; vram
|
||||||
and #$f0
|
and #$f0
|
||||||
ora tmp3
|
ora tmp3
|
||||||
sta (CRAM_PTR),y ; vram
|
sta (CRAM_PTR),y ; vram
|
||||||
|
@sk3:
|
||||||
; colram = bgcolor
|
; colram = bgcolor
|
||||||
lda __bgcolor
|
lda __bgcolor
|
||||||
inc $01
|
inc $01 ; $35
|
||||||
sta (CRAM_PTR),y ; colram
|
sta (CRAM_PTR),y ; colram
|
||||||
stx $01 ;$34
|
stx $01 ; $34
|
||||||
|
|
||||||
jmp @l2b
|
rts
|
||||||
|
|
||||||
@l2s:
|
@sk2:
|
||||||
; colram is bgcolor
|
; colram is bgcolor
|
||||||
; => only one char in cell used
|
; => only one char in cell used
|
||||||
|
|
||||||
jsr soft80_checkchar
|
jsr soft80_checkchar
|
||||||
bcc @l2b ; space at current position
|
bcc @sk1 ; space at current position
|
||||||
|
|
||||||
; vram (textcolor) = bgcolor
|
; vram (textcolor) = bgcolor
|
||||||
lda (CRAM_PTR),y ; vram
|
lda (CRAM_PTR),y ; vram
|
||||||
and #$f0
|
and #$f0
|
||||||
ora __bgcolor
|
ora __bgcolor
|
||||||
sta (CRAM_PTR),y ; vram
|
sta (CRAM_PTR),y ; vram
|
||||||
@l2b:
|
@sk1:
|
||||||
rts
|
rts
|
||||||
|
|
||||||
; put color to cell
|
; put color to cell
|
||||||
; in: $01 is $34 (RAM under I/O) when entering
|
;
|
||||||
; y must be $00
|
; __ -> _A vram = textcol
|
||||||
; out: y = $00
|
; __ -> B_ vram = textcol
|
||||||
|
; _A -> BA colram = vram, vram = textcol
|
||||||
|
; B_ -> BA colram = textcol
|
||||||
|
;
|
||||||
|
; _A -> _C vram = textcol
|
||||||
|
; B_ -> C_ vram = textcol
|
||||||
|
; BA -> BC colram = textcol
|
||||||
|
; BA -> CA vram = textcol
|
||||||
|
;
|
||||||
|
; in: $01 is $34 (RAM under I/O) when entering
|
||||||
|
; x must be $34
|
||||||
|
; y must be $00
|
||||||
|
; out: x = $34
|
||||||
|
; y = $00
|
||||||
soft80_putcolor:
|
soft80_putcolor:
|
||||||
|
|
||||||
;ldy #$00 ; is still $00
|
;ldy #$00 ; is still $00
|
||||||
@@ -376,38 +417,54 @@ soft80_putcolor:
|
|||||||
lda (CRAM_PTR),y ; vram
|
lda (CRAM_PTR),y ; vram
|
||||||
and #$0f
|
and #$0f
|
||||||
cmp __bgcolor
|
cmp __bgcolor
|
||||||
beq @l2s ; vram==bgcolor => first char in cell
|
beq @sk1 ; vram==bgcolor => first char in cell
|
||||||
|
|
||||||
; vram!=bgcolor => second char in cell
|
; vram!=bgcolor => second char in cell
|
||||||
|
|
||||||
inc $01 ;$35
|
inc $01 ; $35
|
||||||
lda (CRAM_PTR),y ; colram
|
lda (CRAM_PTR),y ; colram
|
||||||
stx $01 ;$34
|
stx $01 ; $34
|
||||||
and #$0f
|
and #$0f
|
||||||
cmp __bgcolor
|
cmp __bgcolor
|
||||||
bne @l2s ; colram!=bgcolor
|
beq @l2s ; colram==bgcolor -> second char in cell
|
||||||
|
|
||||||
; colram==bgcolor => second char in cell or overwrite 1st char
|
; botch characters in the cell are used
|
||||||
|
|
||||||
jsr soft80_checkchar
|
lda CURS_X
|
||||||
bcs @l2a ; char at current position => overwrite 1st
|
and #$01
|
||||||
|
bne @sk2 ; jump if odd xpos
|
||||||
|
|
||||||
; colram=vram
|
; vram = textcol
|
||||||
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
|
lda CHARCOLOR
|
||||||
sta (CRAM_PTR),y ; vram
|
sta (CRAM_PTR),y ; vram
|
||||||
|
rts
|
||||||
|
|
||||||
|
@l2s:
|
||||||
|
; one character in cell is already used
|
||||||
|
jsr soft80_checkchar
|
||||||
|
bcs @sk1 ; char at current position => overwrite 1st
|
||||||
|
|
||||||
|
lda CURS_X
|
||||||
|
and #$01
|
||||||
|
beq @sk3 ; jump if even xpos
|
||||||
|
@sk2:
|
||||||
|
; colram = textcol
|
||||||
|
lda __textcolor
|
||||||
|
inc $01 ; $35
|
||||||
|
sta (CRAM_PTR),y ; colram
|
||||||
|
stx $01 ; $34
|
||||||
|
rts
|
||||||
|
|
||||||
|
@sk3:
|
||||||
|
; colram=vram
|
||||||
|
lda (CRAM_PTR),y ; vram
|
||||||
|
inc $01 ; $35
|
||||||
|
sta (CRAM_PTR),y ; colram
|
||||||
|
stx $01 ; $34
|
||||||
|
@sk1:
|
||||||
|
; vram = textcol
|
||||||
|
lda CHARCOLOR
|
||||||
|
sta (CRAM_PTR),y ; vram
|
||||||
rts
|
rts
|
||||||
|
|
||||||
; test if there is a space or a character at current position
|
; test if there is a space or a character at current position
|
||||||
@@ -457,5 +514,4 @@ soft80_checkchar:
|
|||||||
sec
|
sec
|
||||||
rts
|
rts
|
||||||
|
|
||||||
;--- end color vodoo
|
|
||||||
.endif
|
.endif
|
||||||
|
|||||||
Reference in New Issue
Block a user