1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-23 04:30:10 +00:00

move internal text/bgcolor variables into the file that also contains the init code for them. also rename them to avoid namespace pollution

This commit is contained in:
mrdudz 2015-10-12 15:04:55 +02:00
parent 07f1879f85
commit 7f2df8e8e6
4 changed files with 42 additions and 32 deletions

View File

@ -7,7 +7,7 @@
;
.export soft80_textcolor, soft80_bgcolor, soft80_bordercolor
.export __textcolor, __bgcolor
.import soft80_internal_textcolor, soft80_internal_bgcolor
.importzp tmp1, tmp2
@ -15,8 +15,8 @@
.include "soft80.inc"
soft80_textcolor:
ldx __textcolor ; get old value
sta __textcolor ; set new value
ldx soft80_internal_textcolor ; get old value
sta soft80_internal_textcolor ; set new value
jsr mkcharcolor
@ -24,9 +24,9 @@ soft80_textcolor:
rts
soft80_bgcolor:
ldx __bgcolor ; get old value
ldx soft80_internal_bgcolor ; get old value
stx tmp2 ; save old value
sta __bgcolor ; set new value
sta soft80_internal_bgcolor ; set new value
jsr mkcharcolor
@ -43,7 +43,7 @@ lp1:
and #$0f
cmp tmp2 ; old bg color
bne @sk1
lda __bgcolor ; new bg color
lda soft80_internal_bgcolor ; new bg color
sta soft80_colram+(page*250),x
@sk1:
.endscope
@ -69,7 +69,7 @@ lp2:
and #$0f
cmp tmp2 ; old bg color
bne @sk2
lda __bgcolor ; new bg color
lda soft80_internal_bgcolor ; new bg color
@sk2:
ora tmp1 ; new bg color (high nibble)
sta soft80_vram+(page*250),x
@ -86,13 +86,13 @@ lp2:
rts
mkcharcolor:
lda __bgcolor
lda soft80_internal_bgcolor
asl a
asl a
asl a
asl a
sta tmp1 ; remember new bg color (high nibble)
ora __textcolor
ora soft80_internal_textcolor
sta CHARCOLOR ; text/bg combo for new chars
rts
@ -102,12 +102,6 @@ soft80_bordercolor:
txa
rts
.bss
__textcolor:
.res 1
__bgcolor:
.res 1
;-------------------------------------------------------------------------------
; force the init constructor to be imported

View File

@ -8,7 +8,7 @@
.destructor soft80_shutdown
.import soft80_kclrscr, soft80_charset
.import __textcolor, __bgcolor
.export soft80_internal_textcolor, soft80_internal_bgcolor
.importzp ptr1, ptr2, ptr3
@ -71,16 +71,16 @@ soft80_init:
lda 646 ; use current textcolor
and #$0f
sta __textcolor
sta soft80_internal_textcolor
lda VIC_BG_COLOR0 ; use current bgcolor
and #$0f
sta __bgcolor
sta soft80_internal_bgcolor
asl a
asl a
asl a
asl a
ora __textcolor
ora soft80_internal_textcolor
sta CHARCOLOR
jmp soft80_kclrscr
@ -94,3 +94,14 @@ soft80_shutdown:
sta VIC_VIDEO_ADR
rts
;-------------------------------------------------------------------------------
; FIXME: when the code is fixed to use the "init" segment, these variables must
; be moved into a section other than .bss so they survive after the init
; code has been run.
.bss
soft80_internal_textcolor:
.res 1
soft80_internal_bgcolor:
.res 1

View File

@ -12,7 +12,7 @@
.import popa, _gotoxy
.import xsize
.import soft80_kplot
.import __bgcolor, __textcolor
.import soft80_internal_bgcolor, soft80_internal_textcolor
.importzp tmp4,tmp3
@ -70,6 +70,9 @@ L1: cmp #$0D ; LF?
and #$7F
L10:
; entry point for direct output of a character. the value passed in
; akku must match the offset in the charset.
; - the following may not modify tmp1
soft80_cputdirect:
jsr soft80_putchar ; Write the character to the screen
@ -103,6 +106,7 @@ L3:
sty CURS_X
jmp soft80_plot
; - the following may not modify tmp1
soft80_newline:
lda SCREEN_PTR
@ -204,8 +208,9 @@ _spaceinvers:
jmp _back
.endif
; output a character
; entry point for outputting one character in internal encoding
; without advancing cursor position
; - the following may not modify tmp1
soft80_putchar:
sta tmp3 ; remember charcode
@ -340,7 +345,7 @@ remcolor:
; immediately.
lda (CRAM_PTR),y ; vram (textcolor)
and #$0f
cmp __bgcolor
cmp soft80_internal_bgcolor
beq @sk1 ; yes, vram==bgcolor
; now check if the textcolor in color ram is equal the background color,
@ -349,7 +354,7 @@ remcolor:
lda (CRAM_PTR),y ; colram (2nd textcolor)
stx $01 ; $34
and #$0f
cmp __bgcolor
cmp soft80_internal_bgcolor
beq @sk2 ; yes, colram==bgcolor
; two characters in the current cell, of which one will get removed
@ -372,7 +377,7 @@ remcolor:
sta (CRAM_PTR),y ; vram
@sk3:
; colram = bgcolor
lda __bgcolor
lda soft80_internal_bgcolor
inc $01 ; $35
sta (CRAM_PTR),y ; colram
stx $01 ; $34
@ -389,7 +394,7 @@ remcolor:
; vram (textcolor) = bgcolor
lda (CRAM_PTR),y ; vram
and #$f0
ora __bgcolor
ora soft80_internal_bgcolor
sta (CRAM_PTR),y ; vram
@sk1:
rts
@ -417,7 +422,7 @@ soft80_putcolor:
lda (CRAM_PTR),y ; vram
and #$0f
cmp __bgcolor
cmp soft80_internal_bgcolor
beq @sk1 ; vram==bgcolor => first char in cell
; vram!=bgcolor => second char in cell
@ -426,7 +431,7 @@ soft80_putcolor:
lda (CRAM_PTR),y ; colram
stx $01 ; $34
and #$0f
cmp __bgcolor
cmp soft80_internal_bgcolor
beq @l2s ; colram==bgcolor -> second char in cell
; botch characters in the cell are used
@ -450,7 +455,7 @@ soft80_putcolor:
beq @sk3 ; jump if even xpos
@sk2:
; colram = textcol
lda __textcolor
lda soft80_internal_textcolor
inc $01 ; $35
sta (CRAM_PTR),y ; colram
stx $01 ; $34

View File

@ -6,7 +6,7 @@
.export soft80_kclrscr
.import soft80_kplot
.import __bgcolor
.import soft80_internal_bgcolor
.importzp ptr1
.include "c64.inc"
@ -39,7 +39,7 @@ soft80_kclrscr:
bne @lp3
.if SOFT80COLORVOODOO = 1
lda __bgcolor
lda soft80_internal_bgcolor
jsr clear ; clear color ram
.endif
@ -50,7 +50,7 @@ soft80_kclrscr:
lda CHARCOLOR
and #$f0
ora __bgcolor
ora soft80_internal_bgcolor
jsr clear ; clear vram
sty $01