mirror of
https://github.com/irmen/prog8.git
synced 2025-02-19 11:31:07 +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
|
c64.COLOR = txtcol
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub lowercase() {
|
||||||
|
c64.VMCSB |= 2
|
||||||
|
}
|
||||||
|
|
||||||
|
sub uppercase() {
|
||||||
|
c64.VMCSB &= ~2
|
||||||
|
}
|
||||||
|
|
||||||
asmsub scroll_left_full (ubyte alsocolors @ Pc) clobbers(A, Y) {
|
asmsub scroll_left_full (ubyte alsocolors @ Pc) clobbers(A, Y) {
|
||||||
; ---- scroll the whole screen 1 character to the left
|
; ---- scroll the whole screen 1 character to the left
|
||||||
; contents of the rightmost column are unchanged, you should clear/refill this yourself
|
; 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.IOINIT
|
||||||
jsr c64.RESTOR
|
jsr c64.RESTOR
|
||||||
jsr c64.CINT
|
jsr c64.CINT
|
||||||
|
lda #$90 ; black
|
||||||
|
jsr c64.CHROUT
|
||||||
|
lda #1 ; swap fg/bg
|
||||||
|
jsr c64.CHROUT
|
||||||
lda #$9e ; yellow
|
lda #$9e ; yellow
|
||||||
jsr c64.CHROUT
|
jsr c64.CHROUT
|
||||||
; TODO select black background color
|
lda #147 ; clear screen
|
||||||
|
jsr c64.CHROUT
|
||||||
lda #0
|
lda #0
|
||||||
tax
|
tax
|
||||||
tay
|
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]
|
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) {
|
sub color (ubyte txtcol) {
|
||||||
@ -96,6 +95,14 @@ sub color2 (ubyte txtcol, ubyte bgcol) {
|
|||||||
c64.CHROUT(color_to_charcode[txtcol & 15])
|
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.
|
romsub $FFD2 = chrout(ubyte char @ A) ; for consistency. You can also use c64.CHROUT directly ofcourse.
|
||||||
|
|
||||||
asmsub print (str text @ AY) clobbers(A,Y) {
|
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)
|
else -> throw ExpressionError("can only take negative of int or float", subexpr.position)
|
||||||
}
|
}
|
||||||
"~" -> when (subexpr.type) {
|
"~" -> when (subexpr.type) {
|
||||||
in IntegerDatatypes -> {
|
DataType.BYTE -> {
|
||||||
listOf(IAstModification.ReplaceNode(expr,
|
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))
|
parent))
|
||||||
}
|
}
|
||||||
else -> throw ExpressionError("can only take bitwise inversion of int", subexpr.position)
|
else -> throw ExpressionError("can only take bitwise inversion of int", subexpr.position)
|
||||||
|
@ -14,7 +14,7 @@ main {
|
|||||||
cx16.r2 = mkword(0, 16)
|
cx16.r2 = mkword(0, 16)
|
||||||
cx16.r3 = 0
|
cx16.r3 = 0
|
||||||
cx16.clock_set_date_time()
|
cx16.clock_set_date_time()
|
||||||
cx16.screen_set_charset(3, 0) ; lowercase charset
|
txt.lowercase()
|
||||||
|
|
||||||
repeat {
|
repeat {
|
||||||
c64.CHROUT(19) ; HOME
|
c64.CHROUT(19) ; HOME
|
||||||
|
@ -8,9 +8,7 @@ main {
|
|||||||
|
|
||||||
sub start() {
|
sub start() {
|
||||||
|
|
||||||
; set text color and activate lowercase charset
|
txt.lowercase()
|
||||||
txt.color(13)
|
|
||||||
c64.VMCSB |= 2
|
|
||||||
|
|
||||||
; use optimized routine to write text
|
; use optimized routine to write text
|
||||||
txt.print("Hello!\n")
|
txt.print("Hello!\n")
|
||||||
|
@ -13,7 +13,7 @@ main {
|
|||||||
ubyte secretnumber = rnd() % 99 + 1 ; random number 1..100
|
ubyte secretnumber = rnd() % 99 + 1 ; random number 1..100
|
||||||
ubyte attempts_left
|
ubyte attempts_left
|
||||||
|
|
||||||
c64.VMCSB |= 2 ; switch lowercase chars
|
txt.lowercase()
|
||||||
txt.print("Please introduce yourself: ")
|
txt.print("Please introduce yourself: ")
|
||||||
void txt.input_chars(name)
|
void txt.input_chars(name)
|
||||||
txt.print("\n\nHello, ")
|
txt.print("\n\nHello, ")
|
||||||
|
@ -7,7 +7,7 @@ main {
|
|||||||
|
|
||||||
sub start() {
|
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 s1 = "HELLO hello 1234 @[/]" ; regular strings have default encoding (petscii on c64)
|
||||||
str s2 = @"HELLO hello 1234 @[/]" ; alternative encoding (screencodes on c64)
|
str s2 = @"HELLO hello 1234 @[/]" ; alternative encoding (screencodes on c64)
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
;%import c64lib
|
;%import c64lib
|
||||||
;%import c64graphics
|
;%import c64graphics
|
||||||
%import c64textio
|
; %import c64textio
|
||||||
;%import c64flt
|
;%import c64flt
|
||||||
;%option enable_floats
|
;%option enable_floats
|
||||||
;%target cx16
|
%target cx16
|
||||||
;%import cx16textio
|
%import cx16textio
|
||||||
%zeropage basicsafe
|
%zeropage basicsafe
|
||||||
|
|
||||||
|
|
||||||
@ -12,41 +12,44 @@ main {
|
|||||||
|
|
||||||
sub start() {
|
sub start() {
|
||||||
|
|
||||||
|
txt.lowercase()
|
||||||
|
txt.print("Hello there")
|
||||||
|
|
||||||
txt.setchr(5, 5, '*')
|
txt.setchr(5, 5, '*')
|
||||||
txt.setchr(6, 5, '*')
|
txt.setchr(6, 5, '*')
|
||||||
txt.setchr(7, 5, '*')
|
txt.setchr(7, 5, '*')
|
||||||
txt.setchr(7, 6, '+')
|
txt.setchr(7, 6, '+')
|
||||||
txt.setchr(7, 7, '+')
|
txt.setchr(7, 7, '+')
|
||||||
|
|
||||||
txt.setclr(5, 5, 1)
|
; txt.setclr(5, 5, 1)
|
||||||
txt.setclr(6, 5, 2)
|
; txt.setclr(6, 5, 2)
|
||||||
txt.setclr(7, 5, 3)
|
; txt.setclr(7, 5, 3)
|
||||||
txt.setclr(7, 6, 4)
|
; txt.setclr(7, 6, 4)
|
||||||
txt.setclr(7, 7, 5)
|
; txt.setclr(7, 7, 5)
|
||||||
|
;
|
||||||
txt.plot(15,10)
|
txt.plot(15,10)
|
||||||
txt.chrout('!')
|
txt.chrout('!')
|
||||||
|
;
|
||||||
txt.print_ub(txt.getchr(4,5))
|
; txt.print_ub(txt.getchr(4,5))
|
||||||
txt.chrout(',')
|
; txt.chrout(',')
|
||||||
txt.print_ub(txt.getchr(5,5))
|
; txt.print_ub(txt.getchr(5,5))
|
||||||
txt.chrout(',')
|
; txt.chrout(',')
|
||||||
txt.print_ub(txt.getchr(6,5))
|
; txt.print_ub(txt.getchr(6,5))
|
||||||
txt.chrout(',')
|
; txt.chrout(',')
|
||||||
txt.print_ub(txt.getchr(7,5))
|
; txt.print_ub(txt.getchr(7,5))
|
||||||
txt.chrout(',')
|
; txt.chrout(',')
|
||||||
txt.print_ub(txt.getchr(8,5))
|
; txt.print_ub(txt.getchr(8,5))
|
||||||
txt.chrout('\n')
|
; txt.chrout('\n')
|
||||||
txt.print_ub(txt.getclr(4,5))
|
; txt.print_ub(txt.getclr(4,5))
|
||||||
txt.chrout(',')
|
; txt.chrout(',')
|
||||||
txt.print_ub(txt.getclr(5,5))
|
; txt.print_ub(txt.getclr(5,5))
|
||||||
txt.chrout(',')
|
; txt.chrout(',')
|
||||||
txt.print_ub(txt.getclr(6,5))
|
; txt.print_ub(txt.getclr(6,5))
|
||||||
txt.chrout(',')
|
; txt.chrout(',')
|
||||||
txt.print_ub(txt.getclr(7,5))
|
; txt.print_ub(txt.getclr(7,5))
|
||||||
txt.chrout(',')
|
; txt.chrout(',')
|
||||||
txt.print_ub(txt.getclr(8,5))
|
; txt.print_ub(txt.getclr(8,5))
|
||||||
txt.chrout('\n')
|
; txt.chrout('\n')
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user