mirror of
https://github.com/irmen/prog8.git
synced 2024-09-07 19:54:26 +00:00
updated vtui example
This commit is contained in:
parent
0991131fa8
commit
1505fe686a
Binary file not shown.
BIN
examples/cx16/vtui/VTUI0.8.BIN
Normal file
BIN
examples/cx16/vtui/VTUI0.8.BIN
Normal file
Binary file not shown.
@ -2,11 +2,16 @@
|
|||||||
%import textio
|
%import textio
|
||||||
%option no_sysinit
|
%option no_sysinit
|
||||||
|
|
||||||
|
|
||||||
|
; simple test program for the "VTUI" text user interface library
|
||||||
|
; see: https://github.com/JimmyDansbo/VTUIlib
|
||||||
|
|
||||||
main {
|
main {
|
||||||
sub start() {
|
sub start() {
|
||||||
txt.lowercase()
|
|
||||||
|
|
||||||
vtui.initialize()
|
vtui.initialize()
|
||||||
|
store_logo()
|
||||||
|
|
||||||
|
txt.lowercase()
|
||||||
vtui.screen_set(2)
|
vtui.screen_set(2)
|
||||||
vtui.clr_scr('%', $50)
|
vtui.clr_scr('%', $50)
|
||||||
vtui.gotoxy(5,5)
|
vtui.gotoxy(5,5)
|
||||||
@ -14,29 +19,42 @@ main {
|
|||||||
vtui.gotoxy(10,10)
|
vtui.gotoxy(10,10)
|
||||||
vtui.border(1, 40, 6, $47)
|
vtui.border(1, 40, 6, $47)
|
||||||
vtui.gotoxy(12,12)
|
vtui.gotoxy(12,12)
|
||||||
vtui.print_str(@"Hello, world! vtui from Prog8!", $f2, $80)
|
vtui.print_str2(@"Hello, world! vtui from Prog8!", $f2, $80)
|
||||||
vtui.gotoxy(12,13)
|
vtui.gotoxy(12,13)
|
||||||
vtui.print_str("Hello, world! vtui from Prog8!", $f2, $00)
|
vtui.print_str2("Hello, world! vtui from Prog8!", $f2, $00)
|
||||||
|
|
||||||
|
vtui.gotoxy(5,20)
|
||||||
|
vtui.print_str2(@"Enter your name: ", $e3, $80)
|
||||||
|
str inputbuffer = "?" * 20
|
||||||
|
ubyte length = vtui.input_str(inputbuffer, len(inputbuffer), $21)
|
||||||
|
|
||||||
|
vtui.gotoxy(8,22)
|
||||||
|
vtui.print_str2(@"Your name is: ", $e3, $80)
|
||||||
|
vtui.print_str(inputbuffer, length, $67, $00)
|
||||||
|
|
||||||
|
; txt.uppercase() ; kills vtui?
|
||||||
|
logo_mover()
|
||||||
|
|
||||||
repeat {
|
repeat {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub store_logo() {
|
||||||
|
vtui.gotoxy(0, 0)
|
||||||
|
vtui.save_rect($80, 1, $0000, 7, 7)
|
||||||
|
vtui.gotoxy(0, 0)
|
||||||
|
vtui.save_rect($80, 1, $0100, 7, 7)
|
||||||
|
}
|
||||||
|
|
||||||
sub logo_mover() {
|
sub logo_mover() {
|
||||||
ubyte xcoord
|
ubyte xcoord = 0
|
||||||
ubyte ycoord
|
ubyte ycoord = 0
|
||||||
ubyte newx
|
ubyte newx = 0
|
||||||
ubyte newy
|
ubyte newy = 0
|
||||||
|
|
||||||
vtui.initialize()
|
|
||||||
;vtui.screen_set(2)
|
;vtui.screen_set(2)
|
||||||
vtui.gotoxy(30, 32)
|
vtui.gotoxy(30, 32)
|
||||||
vtui.print_str("arrow keys to move!", $61, 0)
|
vtui.print_str2("arrow keys to move!", $61, 0)
|
||||||
vtui.gotoxy(0, 0)
|
|
||||||
vtui.save_rect(1, 1, $0000, 7, 7)
|
|
||||||
vtui.gotoxy(0, 0)
|
|
||||||
vtui.save_rect(1, 1, $0100, 7, 7)
|
|
||||||
|
|
||||||
char_loop:
|
char_loop:
|
||||||
ubyte char = c64.GETIN()
|
ubyte char = c64.GETIN()
|
||||||
@ -74,11 +92,11 @@ char_loop:
|
|||||||
|
|
||||||
sub move_logo() {
|
sub move_logo() {
|
||||||
vtui.gotoxy(xcoord, ycoord)
|
vtui.gotoxy(xcoord, ycoord)
|
||||||
vtui.rest_rect(1, 1, $0100, 7, 7)
|
vtui.rest_rect($80, 1, $0100, 7, 7)
|
||||||
vtui.gotoxy(newx, newy)
|
vtui.gotoxy(newx, newy)
|
||||||
vtui.save_rect(1, 1, $0100, 7, 7)
|
vtui.save_rect($80, 1, $0100, 7, 7)
|
||||||
vtui.gotoxy(newx, newy)
|
vtui.gotoxy(newx, newy)
|
||||||
vtui.rest_rect(1, 1, $0000, 7, 7)
|
vtui.rest_rect($80, 1, $0000, 7, 7)
|
||||||
xcoord = newx
|
xcoord = newx
|
||||||
ycoord = newy
|
ycoord = newy
|
||||||
}
|
}
|
||||||
@ -89,7 +107,7 @@ char_loop:
|
|||||||
|
|
||||||
vtui $1000 {
|
vtui $1000 {
|
||||||
|
|
||||||
%asmbinary "VTUI0.6.BIN", 2 ; skip the 2 dummy load address bytes
|
%asmbinary "VTUI0.8.BIN", 2 ; skip the 2 dummy load address bytes
|
||||||
|
|
||||||
; NOTE: base address $1000 here must be the same as the block's memory address, for obvious reasons!
|
; NOTE: base address $1000 here must be the same as the block's memory address, for obvious reasons!
|
||||||
romsub $1000 = initialize() clobbers(A, X, Y)
|
romsub $1000 = initialize() clobbers(A, X, Y)
|
||||||
@ -103,11 +121,24 @@ vtui $1000 {
|
|||||||
romsub $1017 = scan_char() -> ubyte @A, ubyte @X
|
romsub $1017 = scan_char() -> ubyte @A, ubyte @X
|
||||||
romsub $101a = hline(ubyte char @A, ubyte length @Y, ubyte colors @X) clobbers(A)
|
romsub $101a = hline(ubyte char @A, ubyte length @Y, ubyte colors @X) clobbers(A)
|
||||||
romsub $101d = vline(ubyte char @A, ubyte height @Y, ubyte colors @X) clobbers(A)
|
romsub $101d = vline(ubyte char @A, ubyte height @Y, ubyte colors @X) clobbers(A)
|
||||||
romsub $1020 = print_str(str string @R0, ubyte colors @X, ubyte convertchars @A) clobbers(A, Y)
|
romsub $1020 = print_str(str txtstring @R0, ubyte length @Y, ubyte colors @X, ubyte convertchars @A) clobbers(A, Y)
|
||||||
romsub $1023 = fill_box(ubyte char @A, ubyte width @R1, ubyte height @R2, ubyte colors @X) clobbers(A, Y)
|
romsub $1023 = fill_box(ubyte char @A, ubyte width @R1, ubyte height @R2, ubyte colors @X) clobbers(A, Y)
|
||||||
romsub $1026 = pet2scr(ubyte char @A) -> ubyte @A
|
romsub $1026 = pet2scr(ubyte char @A) -> ubyte @A
|
||||||
romsub $1029 = scr2pet(ubyte char @A) -> ubyte @A
|
romsub $1029 = scr2pet(ubyte char @A) -> ubyte @A
|
||||||
romsub $102c = border(ubyte mode @A, ubyte width @R1, ubyte height @R2, ubyte colors @X) clobbers(Y) ; NOTE: mode 6 means 'custom' characters taken from r3 - r6
|
romsub $102c = border(ubyte mode @A, ubyte width @R1, ubyte height @R2, ubyte colors @X) clobbers(Y) ; NOTE: mode 6 means 'custom' characters taken from r3 - r6
|
||||||
romsub $102f = save_rect(ubyte ramtype @A, ubyte vbank @Pc, uword address @R0, ubyte width @R1, ubyte height @R2) clobbers(A, X, Y)
|
romsub $102f = save_rect(ubyte ramtype @A, ubyte vbank @Pc, uword address @R0, ubyte width @R1, ubyte height @R2) clobbers(A, X, Y)
|
||||||
romsub $1032 = rest_rect(ubyte ramtype @A, ubyte vbank @Pc, uword address @R0, ubyte width @R1, ubyte height @R2) clobbers(A, X, Y)
|
romsub $1032 = rest_rect(ubyte ramtype @A, ubyte vbank @Pc, uword address @R0, ubyte width @R1, ubyte height @R2) clobbers(A, X, Y)
|
||||||
|
romsub $1035 = input_str(uword buffer @R0, ubyte buflen @Y, ubyte colors @X) clobbers (A) -> ubyte @Y
|
||||||
|
|
||||||
|
; -- helper function to do string length counting for you internally
|
||||||
|
asmsub print_str2(str txtstring @R0, ubyte colors @X, ubyte convertchars @A) clobbers(A, Y) {
|
||||||
|
%asm {{
|
||||||
|
pha
|
||||||
|
lda cx16.r0
|
||||||
|
ldy cx16.r0+1
|
||||||
|
jsr prog8_lib.strlen
|
||||||
|
pla
|
||||||
|
jmp print_str
|
||||||
|
}}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user