conio
+Functions textcolor and bgcolor are available only with Telemon 3.0 (Orix).
+Telemon 2.4 primitives can't handle any change of colors in text mode except with XINK or
+XPAPER primitives which put on the first and second columns ink and paper attributes.
+The only way to change color on the same line for text is to handle it in pure assembly
+without systems calls.
Other hints
diff --git a/libsrc/telestrat/bgcolor.s b/libsrc/telestrat/bgcolor.s
new file mode 100644
index 000000000..4af0ef763
--- /dev/null
+++ b/libsrc/telestrat/bgcolor.s
@@ -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
+
+
diff --git a/libsrc/telestrat/clrscr.s b/libsrc/telestrat/clrscr.s
index 1f90a7ca5..a24647f86 100644
--- a/libsrc/telestrat/clrscr.s
+++ b/libsrc/telestrat/clrscr.s
@@ -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
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
diff --git a/libsrc/telestrat/cputc.s b/libsrc/telestrat/cputc.s
index b4f2966a4..f38db8a13 100644
--- a/libsrc/telestrat/cputc.s
+++ b/libsrc/telestrat/cputc.s
@@ -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
diff --git a/libsrc/telestrat/gotoxy.s b/libsrc/telestrat/gotoxy.s
index 03d0a215c..0a3db00b7 100644
--- a/libsrc/telestrat/gotoxy.s
+++ b/libsrc/telestrat/gotoxy.s
@@ -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 #