got floating points working in commanderx16, added txt.color() to set text color

This commit is contained in:
Irmen de Jong 2020-08-30 00:15:18 +02:00
parent 88a9e09918
commit 5d90871789
8 changed files with 43 additions and 38 deletions

View File

@ -11,7 +11,7 @@
txt {
asmsub clear_screen (ubyte char @ A, ubyte color @ Y) clobbers(A) {
asmsub clear_screen (ubyte char @ A, ubyte charcolor @ Y) clobbers(A) {
; ---- clear the character screen with the given fill character and character color.
; (assumes screen and color matrix are at their default addresses)
@ -41,7 +41,7 @@ _loop sta c64.Screen,y
}}
}
asmsub clear_screencolors (ubyte color @ A) clobbers(Y) {
asmsub clear_screencolors (ubyte scrcolor @ A) clobbers(Y) {
; ---- clear the character screen colors with the given color (leaves characters).
; (assumes color matrix is at the default address)
%asm {{
@ -56,6 +56,10 @@ _loop sta c64.Colors,y
}}
}
sub color (ubyte txtcol) {
c64.COLOR = txtcol
}
asmsub scroll_left_full (ubyte alsocolors @ Pc) clobbers(A, Y) {
; ---- scroll the whole screen 1 character to the left
; contents of the rightmost column are unchanged, you should clear/refill this yourself
@ -504,7 +508,7 @@ _mod lda $ffff ; modified
}}
}
sub setcc (ubyte column, ubyte row, ubyte char, ubyte color) {
sub setcc (ubyte column, ubyte row, ubyte char, ubyte charcolor) {
; ---- set char+color at the given position on the screen
%asm {{
lda row
@ -524,7 +528,7 @@ sub setcc (ubyte column, ubyte row, ubyte char, ubyte color) {
inc _colormod+2
+ lda char
_charmod sta $ffff ; modified
lda color
lda charcolor
_colormod sta $ffff ; modified
rts
}}

View File

@ -20,6 +20,18 @@ asmsub clear_screen (ubyte char @ A, ubyte txtcolor @ Y) clobbers(A) {
}
ubyte[16] color_to_charcode = [$90,$05,$1c,$9f,$9c,$1e,$1f,$9e,$81,$95,$96,$97,$98,$99,$9a,$9b]
sub color (ubyte txtcol) {
c64.CHROUT(color_to_charcode[txtcol & 15])
}
sub color2 (ubyte txtcol, ubyte bgcol) {
c64.CHROUT(color_to_charcode[bgcol & 15])
c64.CHROUT(1) ; switch fg and bg colors
c64.CHROUT(color_to_charcode[txtcol & 15])
}
asmsub print (str text @ AY) clobbers(A,Y) {
; ---- print null terminated string from A/Y
; note: the compiler contains an optimization that will replace
@ -224,30 +236,20 @@ asmsub print_w (word value @ AY) clobbers(A,Y) {
}}
}
ubyte[16] color_to_charcode = [$90,$05,$1c,$9f,$9c,$1e,$1f,$9e,$81,$95,$96,$97,$98,$99,$9a,$9b]
sub color (ubyte txtcol) {
c64.CHROUT(color_to_charcode[txtcol & 15])
}
sub color2 (ubyte txtcol, ubyte bgcol) {
c64.CHROUT(color_to_charcode[bgcol & 15])
c64.CHROUT(1) ; switch fg and bg colors
c64.CHROUT(color_to_charcode[txtcol & 15])
}
sub setc (ubyte column, ubyte row, ubyte char) {
sub setchr (ubyte column, ubyte row, ubyte char) {
; ---- set char at the given position on the screen
%asm {{
phx
ldy column
ldx row
clc
jsr c64.PLOT
plx
lda char
jmp c64.CHROUT
}}
; plot(column, row)
c64.CHROUT(char)
; %asm {{
; phx
; ldy column
; ldx row
; clc
; jsr c64.PLOT
; plx
; lda char
; jmp c64.CHROUT
; }}
}
asmsub plot (ubyte col @ Y, ubyte row @ A) clobbers(A) {

View File

@ -47,10 +47,10 @@ sub delay() {
sub print_notes(ubyte n1, ubyte n2) {
c64.CHROUT('\n')
txt.plot(n1/2, 24)
c64.COLOR=7
txt.color(7)
c64.CHROUT('Q')
txt.plot(n2/2, 24)
c64.COLOR=4
txt.color(4)
c64.CHROUT('Q')
}

View File

@ -32,7 +32,7 @@ main {
ysquared = y*y
iter++
}
; txt.setchr(pixelx, pixely, '*')
txt.color2(1, max_iter-iter)
c64.CHROUT(' ')
}

View File

@ -9,7 +9,7 @@ main {
sub start() {
; set text color and activate lowercase charset
c64.COLOR = 13
txt.color(13)
c64.VMCSB |= 2
; use optimized routine to write text

View File

@ -21,7 +21,7 @@ main {
const ubyte PAGE2 = ((SCREEN2 >> 6) & $F0) | ((CHARSET >> 10) & $0E)
sub start() {
c64.COLOR = 1
txt.color(1)
txt.print("creating charset...\n")
makechar()

View File

@ -280,12 +280,12 @@ waitkey:
sub drawBoard() {
c64.CLEARSCR()
c64.COLOR = 7
txt.color(7)
txt.plot(1,1)
txt.print("irmen's")
txt.plot(2,2)
txt.print("teh▁triz")
c64.COLOR = 5
txt.color(5)
txt.plot(6,4)
txt.print("hold:")
txt.plot(2,22)
@ -296,10 +296,10 @@ waitkey:
txt.print("lines:")
txt.plot(28,14)
txt.print("score:")
c64.COLOR = 12
txt.color(12)
txt.plot(27,18)
txt.print("controls:")
c64.COLOR = 11
txt.color(11)
txt.plot(28,19)
txt.print(",/ move")
txt.plot(28,20)
@ -342,7 +342,7 @@ waitkey:
}
sub drawScore() {
c64.COLOR=1
txt.color(1)
txt.plot(30,11)
txt.print_uw(lines)
txt.plot(30,15)

View File

@ -10,7 +10,6 @@ main {
; sub color(...) {}
; sub other(ubyte color) {} ; TODO don't cause name conflict
byte b1
byte b2
byte b3