Add textcolor and bgcolor.s

This commit is contained in:
jede
2019-07-06 10:16:57 +02:00
committed by greg-king5
parent 14ac1a7ff6
commit 7f9e73a1ce
8 changed files with 129 additions and 14 deletions

View File

@@ -0,0 +1,28 @@
; 2019-07-02, Jede (jede@oric.org)
;
.export _bgcolor
.import BGCOLOR
.import BGCOLOR_CHANGE
.include "telestrat.inc"
.proc _bgcolor
cmp BGCOLOR ; Do we set the same color? if we don't detect it, we loose one char on the screen for each textcolor call with the same color
bne out ; Yes
lda #$00
sta BGCOLOR_CHANGE
lda BGCOLOR ; Return last color
rts
out:
ldx BGCOLOR ; Get last color in order to return it
sta BGCOLOR
lda #$01 ; Notify the change color
sta BGCOLOR_CHANGE
txa ; Return previous color
rts
.endproc

View File

@@ -4,15 +4,15 @@
.export _clrscr
.importzp sp
.import CHARCOLOR_CHANGE, CHARCOLOR, BGCOLOR, BGCOLOR_CHANGE
.include "telestrat.inc"
.proc _clrscr
; Switch to text mode
BRK_TELEMON(XTEXT)
lda #<SCREEN
lda #<SCREEN ; Get position screen
ldy #>SCREEN
sta RES
sty RES+1
@@ -20,7 +20,7 @@
ldy #<(SCREEN+SCREEN_XSIZE*SCREEN_YSIZE)
ldx #>(SCREEN+SCREEN_XSIZE*SCREEN_YSIZE)
lda #' '
BRK_TELEMON XFILLM
BRK_TELEMON XFILLM ; Calls XFILLM : it fills A value from RES address and size of X and Y value
; reset prompt position
@@ -34,5 +34,14 @@
sta SCRY
lda #$00
sta SCRX
lda #$00
sta CHARCOLOR_CHANGE
sta BGCOLOR_CHANGE
lda #$07
sta CHARCOLOR
sta BGCOLOR
rts
.endproc

View File

@@ -4,12 +4,43 @@
; void cputc (char c);
;
.export _cputc
.export _cputc, CHARCOLOR, CHARCOLOR_CHANGE, BGCOLOR, BGCOLOR_CHANGE
.include "telestrat.inc"
.proc _cputc
BRK_TELEMON XWR0 ; macro send char to screen (channel 0 in telemon terms)
ldx CHARCOLOR_CHANGE
beq do_not_change_color_foreground
pha
lda CHARCOLOR
BRK_TELEMON $4E ; Change color on the screen (foreground)
lda #$00
sta CHARCOLOR_CHANGE
pla
do_not_change_color_foreground:
ldx BGCOLOR_CHANGE
beq do_not_change_color
pha
lda BGCOLOR
ORA #%00010000 ; Add 16 because background color is an attribute between 16 and 23. 17 is red background for example
BRK_TELEMON XFWR ; Change color on the screen (background)
lda #$00
sta BGCOLOR_CHANGE
pla
do_not_change_color:
BRK_TELEMON XFWR ; Macro send char to screen (channel 0)
rts
.endproc
CHARCOLOR:
.res 1
CHARCOLOR_CHANGE:
.res 1
BGCOLOR:
.res 1
BGCOLOR_CHANGE:
.res 1

View File

@@ -5,10 +5,10 @@
; void gotoxy (unsigned char x, unsigned char y);
;
.export gotoxy, _gotoxy
.export gotoxy, _gotoxy, _update_adscr
.import popa,CHARCOLOR_CHANGE,BGCOLOR_CHANGE
.import popa
.importzp sp
.include "telestrat.inc"
@@ -22,6 +22,16 @@ gotoxy: jsr popa ; Get Y
jsr popa
sta SCRX
jsr _update_adscr ; Update adress video ram position when SCRY et SCRX are modified
; Force to put again attribute when it moves on the screen
lda #$01
sta CHARCOLOR_CHANGE
sta BGCOLOR_CHANGE
rts
.endproc
.proc _update_adscr
lda #<SCREEN
sta ADSCRL
@@ -29,6 +39,7 @@ gotoxy: jsr popa ; Get Y
sta ADSCRL+1
ldy SCRY
beq out
loop:
lda ADSCRL
clc
@@ -39,6 +50,6 @@ skip:
sta ADSCRL
dey
bne loop
out:
rts
.endproc
.endproc

View File

@@ -3,11 +3,12 @@
;
.export _gotoy
.importzp sp
.import _update_adscr
.include "telestrat.inc"
.proc _gotoy
sta SCRY
jsr _update_adscr
rts
.endproc

View File

@@ -0,0 +1,28 @@
; 2019-07-02, Jede (jede@oric.org)
;
.export _textcolor
.import CHARCOLOR
.import CHARCOLOR_CHANGE
.include "telestrat.inc"
.proc _textcolor
cmp CHARCOLOR ; Do we set the same color? if we don't detect it, we loose one char on the screen for each textcolor call with the same color
bne out ; yes
lda #$00
sta CHARCOLOR_CHANGE
lda CHARCOLOR ; return last color
rts
out:
ldx CHARCOLOR ; get last color in order to return it
sta CHARCOLOR
lda #$01
sta CHARCOLOR_CHANGE
txa ; return previous color
rts
.endproc