mirror of
				https://github.com/irmen/prog8.git
				synced 2025-11-04 10:16:13 +00:00 
			
		
		
		
	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:
		@@ -406,6 +406,7 @@ asmsub width() clobbers(X,Y) -> ubyte @A {
 | 
				
			|||||||
    ; -- returns the text screen width (number of columns)
 | 
					    ; -- returns the text screen width (number of columns)
 | 
				
			||||||
    %asm {{
 | 
					    %asm {{
 | 
				
			||||||
        jsr  cbm.SCREEN
 | 
					        jsr  cbm.SCREEN
 | 
				
			||||||
 | 
					        inx
 | 
				
			||||||
        txa
 | 
					        txa
 | 
				
			||||||
        rts
 | 
					        rts
 | 
				
			||||||
    }}
 | 
					    }}
 | 
				
			||||||
@@ -415,11 +416,22 @@ asmsub height() clobbers(X, Y) -> ubyte @A {
 | 
				
			|||||||
    ; -- returns the text screen height (number of rows)
 | 
					    ; -- returns the text screen height (number of rows)
 | 
				
			||||||
    %asm {{
 | 
					    %asm {{
 | 
				
			||||||
        jsr  cbm.SCREEN
 | 
					        jsr  cbm.SCREEN
 | 
				
			||||||
 | 
					        iny
 | 
				
			||||||
        tya
 | 
					        tya
 | 
				
			||||||
        rts
 | 
					        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 {{
 | 
				
			||||||
 | 
					        jsr  cbm.SCREEN
 | 
				
			||||||
 | 
					        inx
 | 
				
			||||||
 | 
					        iny
 | 
				
			||||||
 | 
					        rts
 | 
				
			||||||
 | 
					    }}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
asmsub waitkey() -> ubyte @A {
 | 
					asmsub waitkey() -> ubyte @A {
 | 
				
			||||||
    %asm {{
 | 
					    %asm {{
 | 
				
			||||||
-       jsr cbm.GETIN
 | 
					-       jsr cbm.GETIN
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -424,6 +424,14 @@ asmsub height() clobbers(X, Y) -> ubyte @A {
 | 
				
			|||||||
    }}
 | 
					    }}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					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 {{
 | 
				
			||||||
 | 
					        jmp  cbm.SCREEN
 | 
				
			||||||
 | 
					    }}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
asmsub waitkey() -> ubyte @A {
 | 
					asmsub waitkey() -> ubyte @A {
 | 
				
			||||||
    %asm {{
 | 
					    %asm {{
 | 
				
			||||||
-       jsr cbm.GETIN
 | 
					-       jsr cbm.GETIN
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -615,6 +615,13 @@ asmsub height() clobbers(X, Y) -> ubyte @A {
 | 
				
			|||||||
    }}
 | 
					    }}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					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 {{
 | 
				
			||||||
 | 
					        jmp  cbm.SCREEN
 | 
				
			||||||
 | 
					    }}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
asmsub waitkey() -> ubyte @A {
 | 
					asmsub waitkey() -> ubyte @A {
 | 
				
			||||||
    %asm {{
 | 
					    %asm {{
 | 
				
			||||||
-       jsr cbm.GETIN
 | 
					-       jsr cbm.GETIN
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -236,6 +236,17 @@ asmsub height() clobbers(X, Y) -> ubyte @A {
 | 
				
			|||||||
    }}
 | 
					    }}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					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 {{
 | 
				
			||||||
 | 
					        jsr  width
 | 
				
			||||||
 | 
					        tax
 | 
				
			||||||
 | 
					        jsr  height
 | 
				
			||||||
 | 
					        tay
 | 
				
			||||||
 | 
					        rts
 | 
				
			||||||
 | 
					    }}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
asmsub waitkey() -> ubyte @A {
 | 
					asmsub waitkey() -> ubyte @A {
 | 
				
			||||||
    %asm {{
 | 
					    %asm {{
 | 
				
			||||||
-       jsr cbm.GETIN
 | 
					-       jsr cbm.GETIN
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -21,6 +21,11 @@ sub height() -> ubyte {
 | 
				
			|||||||
    }}
 | 
					    }}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					sub size() -> ubyte, ubyte {
 | 
				
			||||||
 | 
					    ; -- returns the text screen width and height (number of columns and rows)
 | 
				
			||||||
 | 
					    return width(), height()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
sub  clear_screen() {
 | 
					sub  clear_screen() {
 | 
				
			||||||
    str @shared sequence = "\x1b[2J\x1B[H"
 | 
					    str @shared sequence = "\x1b[2J\x1B[H"
 | 
				
			||||||
    %ir {{
 | 
					    %ir {{
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -825,6 +825,7 @@ txt  {
 | 
				
			|||||||
    setcc  (ubyte col, ubyte row, ubyte character, ubyte charcolor) 
 | 
					    setcc  (ubyte col, ubyte row, ubyte character, ubyte charcolor) 
 | 
				
			||||||
    setchr  (ubyte col @X, ubyte row @Y, ubyte character @A)  clobbers (A,Y) 
 | 
					    setchr  (ubyte col @X, ubyte row @Y, ubyte character @A)  clobbers (A,Y) 
 | 
				
			||||||
    setclr  (ubyte col @X, ubyte row @Y, ubyte color @A)  clobbers (A,Y) 
 | 
					    setclr  (ubyte col @X, ubyte row @Y, ubyte color @A)  clobbers (A,Y) 
 | 
				
			||||||
 | 
					    size  ()  clobbers (A) -> ubyte @X, ubyte @Y 
 | 
				
			||||||
    spc  () 
 | 
					    spc  () 
 | 
				
			||||||
    uppercase  () 
 | 
					    uppercase  () 
 | 
				
			||||||
    waitkey  () -> ubyte @A 
 | 
					    waitkey  () -> ubyte @A 
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -938,6 +938,7 @@ txt  {
 | 
				
			|||||||
    setcc  (ubyte col, ubyte row, ubyte character, ubyte charcolor) 
 | 
					    setcc  (ubyte col, ubyte row, ubyte character, ubyte charcolor) 
 | 
				
			||||||
    setchr  (ubyte col @X, ubyte row @Y, ubyte character @A)  clobbers (A,Y) 
 | 
					    setchr  (ubyte col @X, ubyte row @Y, ubyte character @A)  clobbers (A,Y) 
 | 
				
			||||||
    setclr  (ubyte col @X, ubyte row @Y, ubyte color @A)  clobbers (A,Y) 
 | 
					    setclr  (ubyte col @X, ubyte row @Y, ubyte color @A)  clobbers (A,Y) 
 | 
				
			||||||
 | 
					    size  ()  clobbers (A) -> ubyte @X, ubyte @Y 
 | 
				
			||||||
    spc  () 
 | 
					    spc  () 
 | 
				
			||||||
    uppercase  () 
 | 
					    uppercase  () 
 | 
				
			||||||
    waitkey  () -> ubyte @A 
 | 
					    waitkey  () -> ubyte @A 
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1422,6 +1422,7 @@ txt  {
 | 
				
			|||||||
    setcc2  (ubyte col, ubyte row, ubyte character, ubyte colors) 
 | 
					    setcc2  (ubyte col, ubyte row, ubyte character, ubyte colors) 
 | 
				
			||||||
    setchr  (ubyte col @X, ubyte row @Y, ubyte character @A)  clobbers (A) 
 | 
					    setchr  (ubyte col @X, ubyte row @Y, ubyte character @A)  clobbers (A) 
 | 
				
			||||||
    setclr  (ubyte col @X, ubyte row @Y, ubyte color @A)  clobbers (A) 
 | 
					    setclr  (ubyte col @X, ubyte row @Y, ubyte color @A)  clobbers (A) 
 | 
				
			||||||
 | 
					    size  ()  clobbers (A) -> ubyte @X, ubyte @Y 
 | 
				
			||||||
    spc  () 
 | 
					    spc  () 
 | 
				
			||||||
    t256c  (bool enable) 
 | 
					    t256c  (bool enable) 
 | 
				
			||||||
    uppercase  () 
 | 
					    uppercase  () 
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -540,6 +540,7 @@ txt  {
 | 
				
			|||||||
    setcc  (ubyte col, ubyte row, ubyte character, ubyte charcolor_ignored) 
 | 
					    setcc  (ubyte col, ubyte row, ubyte character, ubyte charcolor_ignored) 
 | 
				
			||||||
    setchr  (ubyte col @X, ubyte row @Y, ubyte character @A)  clobbers (A,Y) 
 | 
					    setchr  (ubyte col @X, ubyte row @Y, ubyte character @A)  clobbers (A,Y) 
 | 
				
			||||||
    setclr  (ubyte col, ubyte row, ubyte color) 
 | 
					    setclr  (ubyte col, ubyte row, ubyte color) 
 | 
				
			||||||
 | 
					    size  ()  clobbers (A) -> ubyte @X, ubyte @Y 
 | 
				
			||||||
    spc  () 
 | 
					    spc  () 
 | 
				
			||||||
    uppercase  () 
 | 
					    uppercase  () 
 | 
				
			||||||
    waitkey  () -> ubyte @A 
 | 
					    waitkey  () -> ubyte @A 
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -559,6 +559,7 @@ txt  {
 | 
				
			|||||||
    rvs_off  () 
 | 
					    rvs_off  () 
 | 
				
			||||||
    rvs_on  () 
 | 
					    rvs_on  () 
 | 
				
			||||||
    setchr  (ubyte col, ubyte row, ubyte char) 
 | 
					    setchr  (ubyte col, ubyte row, ubyte char) 
 | 
				
			||||||
 | 
					    size  () -> ubyte, ubyte 
 | 
				
			||||||
    spc  () 
 | 
					    spc  () 
 | 
				
			||||||
    uppercase  () 
 | 
					    uppercase  () 
 | 
				
			||||||
    width  () -> ubyte 
 | 
					    width  () -> ubyte 
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -412,20 +412,28 @@ asmsub waitkey() -> ubyte @A {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
asmsub width() clobbers(X,Y) -> ubyte @A {
 | 
					asmsub width() clobbers(X,Y) -> ubyte @A {
 | 
				
			||||||
    ; -- returns the text screen width (number of columns)
 | 
					    ; -- returns the text screen width (number of columns)
 | 
				
			||||||
    ; TODO
 | 
					 | 
				
			||||||
    %asm {{
 | 
					    %asm {{
 | 
				
			||||||
        lda  #0
 | 
					        lda  #DEFAULT_WIDTH
 | 
				
			||||||
        rts
 | 
					        rts
 | 
				
			||||||
    }}
 | 
					    }}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
asmsub height() clobbers(X, Y) -> ubyte @A {
 | 
					asmsub height() clobbers(X, Y) -> ubyte @A {
 | 
				
			||||||
    ; -- returns the text screen height (number of rows)
 | 
					    ; -- returns the text screen height (number of rows)
 | 
				
			||||||
    ; TODO
 | 
					 | 
				
			||||||
    %asm {{
 | 
					    %asm {{
 | 
				
			||||||
        lda  #0
 | 
					        lda  #DEFAULT_HEIGHT
 | 
				
			||||||
        rts
 | 
					        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
 | 
				
			||||||
 | 
					    }}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -417,7 +417,7 @@ asmsub  plot  (ubyte col @ Y, ubyte row @ X) {
 | 
				
			|||||||
asmsub width() clobbers(X,Y) -> ubyte @A {
 | 
					asmsub width() clobbers(X,Y) -> ubyte @A {
 | 
				
			||||||
    ; -- returns the text screen width (number of columns)
 | 
					    ; -- returns the text screen width (number of columns)
 | 
				
			||||||
    %asm {{
 | 
					    %asm {{
 | 
				
			||||||
        lda  DEFAULT_WIDTH
 | 
					        lda  #DEFAULT_WIDTH
 | 
				
			||||||
        rts
 | 
					        rts
 | 
				
			||||||
    }}
 | 
					    }}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -425,11 +425,21 @@ asmsub width() clobbers(X,Y) -> ubyte @A {
 | 
				
			|||||||
asmsub height() clobbers(X, Y) -> ubyte @A {
 | 
					asmsub height() clobbers(X, Y) -> ubyte @A {
 | 
				
			||||||
    ; -- returns the text screen height (number of rows)
 | 
					    ; -- returns the text screen height (number of rows)
 | 
				
			||||||
    %asm {{
 | 
					    %asm {{
 | 
				
			||||||
        lda  DEFAULT_HEIGHT
 | 
					        lda  #DEFAULT_HEIGHT
 | 
				
			||||||
        rts
 | 
					        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?
 | 
					; TODO: jmp to cbm.CHRIN?
 | 
				
			||||||
asmsub waitkey() -> ubyte @A {
 | 
					asmsub waitkey() -> ubyte @A {
 | 
				
			||||||
    %asm {{
 | 
					    %asm {{
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,18 +1,32 @@
 | 
				
			|||||||
%import textio
 | 
					%import textio
 | 
				
			||||||
%import math
 | 
					 | 
				
			||||||
%zeropage basicsafe
 | 
					%zeropage basicsafe
 | 
				
			||||||
%option no_sysinit
 | 
					%option no_sysinit
 | 
				
			||||||
 | 
					
 | 
				
			||||||
main {
 | 
					main {
 | 
				
			||||||
    sub start() {
 | 
					    sub start() {
 | 
				
			||||||
        long @shared lv, lv2
 | 
					        ubyte w,h
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        lv = $11111111
 | 
					        w,h = txt.size()
 | 
				
			||||||
        lv2 = $55555555
 | 
					        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
 | 
					;        long @shared lv1 = $12345678
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user