1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-15 17:30:06 +00:00

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

@ -286,6 +286,7 @@ XZAP = $46 ; Send Zap sound to PSG
XSHOOT = $47
XMKDIR = $4B ; Create a folder. Only available in TELEMON 3.x (bank 7 of Orix)
XRM = $4D ; Remove a folder or a file. Only available in TELEMON 3.x (bank 7 of Orix)
XFWR = $4E ; Put a char on the first screen. Only available in TELEMON 3.x (bank 7 of Orix)
XGOKBD = $52
; Buffer management

View File

@ -212,7 +212,8 @@ RS232 port with Telemon calls (see XSOUT primitive for example)
Telemon 3.0 handles fopen, fread, fclose primitives. It means that this
function will crash the Telestrat because Telemon 2.4 does not have these
primitives. By the way, Telemon 3.0 uses an extension "ch376 card" which
handles sdcard and FAT 32 usb key. In the next version of Telemon, FT DOS, Sedoric, Stratsed will be handled in these 3 primitives (fopen, fread, fclose).
handles sdcard and FAT 32 usb key. In the next version of Telemon, FT DOS,
Sedoric, Stratsed will be handled in these 3 primitives (fopen, fread, fclose).
<itemize>
<item>fclose
@ -220,7 +221,12 @@ handles sdcard and FAT 32 usb key. In the next version of Telemon, FT DOS, Sedor
<item>fread
</itemize>
<sect1>conio<p>
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.
<sect>Other hints<p>

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