added txt.size() to return text screen width and height in 1 call. Also fixed txt.width/height on the C128 (where SCREEN reports 1 less for them...)

This commit is contained in:
Irmen de Jong
2025-10-16 00:28:59 +02:00
parent 513ee25432
commit c0286e3349
13 changed files with 92 additions and 12 deletions

View File

@@ -412,20 +412,28 @@ asmsub waitkey() -> ubyte @A {
asmsub width() clobbers(X,Y) -> ubyte @A {
; -- returns the text screen width (number of columns)
; TODO
%asm {{
lda #0
lda #DEFAULT_WIDTH
rts
}}
}
asmsub height() clobbers(X, Y) -> ubyte @A {
; -- returns the text screen height (number of rows)
; TODO
%asm {{
lda #0
lda #DEFAULT_HEIGHT
rts
}}
}
asmsub size() clobbers(A) -> ubyte @X, ubyte @Y {
; -- returns the text screen width in X and height in Y (number of columns and rows)
%asm {{
ldx #DEFAULT_WIDTH
ldy #DEFAULT_HEIGHT
rts
}}
}
}

View File

@@ -417,7 +417,7 @@ asmsub plot (ubyte col @ Y, ubyte row @ X) {
asmsub width() clobbers(X,Y) -> ubyte @A {
; -- returns the text screen width (number of columns)
%asm {{
lda DEFAULT_WIDTH
lda #DEFAULT_WIDTH
rts
}}
}
@@ -425,11 +425,21 @@ asmsub width() clobbers(X,Y) -> ubyte @A {
asmsub height() clobbers(X, Y) -> ubyte @A {
; -- returns the text screen height (number of rows)
%asm {{
lda DEFAULT_HEIGHT
lda #DEFAULT_HEIGHT
rts
}}
}
asmsub size() clobbers(A) -> ubyte @X, ubyte @Y {
; -- returns the text screen width in X and height in Y (number of columns and rows)
%asm {{
ldx #DEFAULT_HEIGHT
ldy #DEFAULT_HEIGHT
rts
}}
}
; TODO: jmp to cbm.CHRIN?
asmsub waitkey() -> ubyte @A {
%asm {{

View File

@@ -1,18 +1,32 @@
%import textio
%import math
%zeropage basicsafe
%option no_sysinit
main {
sub start() {
long @shared lv, lv2
ubyte w,h
lv = $11111111
lv2 = $55555555
w,h = txt.size()
txt.print("Screen size: ")
txt.print_ub(w)
txt.spc()
txt.print_ub(h)
txt.nl()
txt.print("width/height=")
txt.print_ub(txt.width())
txt.spc()
txt.print_ub(txt.height())
txt.nl()
lv = lv | lv2 ^ 999999
txt.print_ulhex(lv, true) ; $555b177b
; long @shared lv, lv2
;
; lv = $11111111
; lv2 = $55555555
;
; lv = lv | lv2 ^ 999999
;
; txt.print_ulhex(lv, true) ; $555b177b
; long @shared lv1 = $12345678