mirror of
https://github.com/irmen/prog8.git
synced 2024-11-18 19:12:44 +00:00
tweaks to c64 txtio. Fixed expression evaluation of bitwise invert.
This commit is contained in:
parent
0f7454059c
commit
2deb18beb2
@ -68,6 +68,14 @@ sub color (ubyte txtcol) {
|
||||
c64.COLOR = txtcol
|
||||
}
|
||||
|
||||
sub lowercase() {
|
||||
c64.VMCSB |= 2
|
||||
}
|
||||
|
||||
sub uppercase() {
|
||||
c64.VMCSB &= ~2
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -259,9 +259,14 @@ asmsub init_system() {
|
||||
jsr c64.IOINIT
|
||||
jsr c64.RESTOR
|
||||
jsr c64.CINT
|
||||
lda #$90 ; black
|
||||
jsr c64.CHROUT
|
||||
lda #1 ; swap fg/bg
|
||||
jsr c64.CHROUT
|
||||
lda #$9e ; yellow
|
||||
jsr c64.CHROUT
|
||||
; TODO select black background color
|
||||
lda #147 ; clear screen
|
||||
jsr c64.CHROUT
|
||||
lda #0
|
||||
tax
|
||||
tay
|
||||
|
@ -83,7 +83,6 @@ asmsub clear_screenchars (ubyte char @ A) clobbers(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) {
|
||||
@ -96,6 +95,14 @@ sub color2 (ubyte txtcol, ubyte bgcol) {
|
||||
c64.CHROUT(color_to_charcode[txtcol & 15])
|
||||
}
|
||||
|
||||
sub lowercase() {
|
||||
cx16.screen_set_charset(3, 0) ; lowercase charset
|
||||
}
|
||||
|
||||
sub uppercase() {
|
||||
cx16.screen_set_charset(2, 0) ; uppercase charset
|
||||
}
|
||||
|
||||
romsub $FFD2 = chrout(ubyte char @ A) ; for consistency. You can also use c64.CHROUT directly ofcourse.
|
||||
|
||||
asmsub print (str text @ AY) clobbers(A,Y) {
|
||||
|
@ -216,9 +216,24 @@ internal class ConstantFoldingOptimizer(private val program: Program) : AstWalke
|
||||
else -> throw ExpressionError("can only take negative of int or float", subexpr.position)
|
||||
}
|
||||
"~" -> when (subexpr.type) {
|
||||
in IntegerDatatypes -> {
|
||||
DataType.BYTE -> {
|
||||
listOf(IAstModification.ReplaceNode(expr,
|
||||
NumericLiteralValue.optimalInteger(subexpr.number.toInt().inv(), subexpr.position),
|
||||
NumericLiteralValue(DataType.BYTE, subexpr.number.toInt().inv(), subexpr.position),
|
||||
parent))
|
||||
}
|
||||
DataType.UBYTE -> {
|
||||
listOf(IAstModification.ReplaceNode(expr,
|
||||
NumericLiteralValue(DataType.UBYTE, subexpr.number.toInt().inv() and 255, subexpr.position),
|
||||
parent))
|
||||
}
|
||||
DataType.WORD -> {
|
||||
listOf(IAstModification.ReplaceNode(expr,
|
||||
NumericLiteralValue(DataType.WORD, subexpr.number.toInt().inv(), subexpr.position),
|
||||
parent))
|
||||
}
|
||||
DataType.UWORD -> {
|
||||
listOf(IAstModification.ReplaceNode(expr,
|
||||
NumericLiteralValue(DataType.UWORD, subexpr.number.toInt().inv() and 65535, subexpr.position),
|
||||
parent))
|
||||
}
|
||||
else -> throw ExpressionError("can only take bitwise inversion of int", subexpr.position)
|
||||
|
@ -14,7 +14,7 @@ main {
|
||||
cx16.r2 = mkword(0, 16)
|
||||
cx16.r3 = 0
|
||||
cx16.clock_set_date_time()
|
||||
cx16.screen_set_charset(3, 0) ; lowercase charset
|
||||
txt.lowercase()
|
||||
|
||||
repeat {
|
||||
c64.CHROUT(19) ; HOME
|
||||
|
@ -8,9 +8,7 @@ main {
|
||||
|
||||
sub start() {
|
||||
|
||||
; set text color and activate lowercase charset
|
||||
txt.color(13)
|
||||
c64.VMCSB |= 2
|
||||
txt.lowercase()
|
||||
|
||||
; use optimized routine to write text
|
||||
txt.print("Hello!\n")
|
||||
|
@ -13,7 +13,7 @@ main {
|
||||
ubyte secretnumber = rnd() % 99 + 1 ; random number 1..100
|
||||
ubyte attempts_left
|
||||
|
||||
c64.VMCSB |= 2 ; switch lowercase chars
|
||||
txt.lowercase()
|
||||
txt.print("Please introduce yourself: ")
|
||||
void txt.input_chars(name)
|
||||
txt.print("\n\nHello, ")
|
||||
|
@ -7,7 +7,7 @@ main {
|
||||
|
||||
sub start() {
|
||||
|
||||
c64.VMCSB |= 2 ; switch to lowercase charset
|
||||
txt.lowercase()
|
||||
|
||||
str s1 = "HELLO hello 1234 @[/]" ; regular strings have default encoding (petscii on c64)
|
||||
str s2 = @"HELLO hello 1234 @[/]" ; alternative encoding (screencodes on c64)
|
||||
|
@ -1,10 +1,10 @@
|
||||
;%import c64lib
|
||||
;%import c64graphics
|
||||
%import c64textio
|
||||
; %import c64textio
|
||||
;%import c64flt
|
||||
;%option enable_floats
|
||||
;%target cx16
|
||||
;%import cx16textio
|
||||
%target cx16
|
||||
%import cx16textio
|
||||
%zeropage basicsafe
|
||||
|
||||
|
||||
@ -12,41 +12,44 @@ main {
|
||||
|
||||
sub start() {
|
||||
|
||||
txt.lowercase()
|
||||
txt.print("Hello there")
|
||||
|
||||
txt.setchr(5, 5, '*')
|
||||
txt.setchr(6, 5, '*')
|
||||
txt.setchr(7, 5, '*')
|
||||
txt.setchr(7, 6, '+')
|
||||
txt.setchr(7, 7, '+')
|
||||
|
||||
txt.setclr(5, 5, 1)
|
||||
txt.setclr(6, 5, 2)
|
||||
txt.setclr(7, 5, 3)
|
||||
txt.setclr(7, 6, 4)
|
||||
txt.setclr(7, 7, 5)
|
||||
|
||||
; txt.setclr(5, 5, 1)
|
||||
; txt.setclr(6, 5, 2)
|
||||
; txt.setclr(7, 5, 3)
|
||||
; txt.setclr(7, 6, 4)
|
||||
; txt.setclr(7, 7, 5)
|
||||
;
|
||||
txt.plot(15,10)
|
||||
txt.chrout('!')
|
||||
|
||||
txt.print_ub(txt.getchr(4,5))
|
||||
txt.chrout(',')
|
||||
txt.print_ub(txt.getchr(5,5))
|
||||
txt.chrout(',')
|
||||
txt.print_ub(txt.getchr(6,5))
|
||||
txt.chrout(',')
|
||||
txt.print_ub(txt.getchr(7,5))
|
||||
txt.chrout(',')
|
||||
txt.print_ub(txt.getchr(8,5))
|
||||
txt.chrout('\n')
|
||||
txt.print_ub(txt.getclr(4,5))
|
||||
txt.chrout(',')
|
||||
txt.print_ub(txt.getclr(5,5))
|
||||
txt.chrout(',')
|
||||
txt.print_ub(txt.getclr(6,5))
|
||||
txt.chrout(',')
|
||||
txt.print_ub(txt.getclr(7,5))
|
||||
txt.chrout(',')
|
||||
txt.print_ub(txt.getclr(8,5))
|
||||
txt.chrout('\n')
|
||||
;
|
||||
; txt.print_ub(txt.getchr(4,5))
|
||||
; txt.chrout(',')
|
||||
; txt.print_ub(txt.getchr(5,5))
|
||||
; txt.chrout(',')
|
||||
; txt.print_ub(txt.getchr(6,5))
|
||||
; txt.chrout(',')
|
||||
; txt.print_ub(txt.getchr(7,5))
|
||||
; txt.chrout(',')
|
||||
; txt.print_ub(txt.getchr(8,5))
|
||||
; txt.chrout('\n')
|
||||
; txt.print_ub(txt.getclr(4,5))
|
||||
; txt.chrout(',')
|
||||
; txt.print_ub(txt.getclr(5,5))
|
||||
; txt.chrout(',')
|
||||
; txt.print_ub(txt.getclr(6,5))
|
||||
; txt.chrout(',')
|
||||
; txt.print_ub(txt.getclr(7,5))
|
||||
; txt.chrout(',')
|
||||
; txt.print_ub(txt.getclr(8,5))
|
||||
; txt.chrout('\n')
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user