2021-02-18 02:45:06 +00:00
|
|
|
%import textio
|
2021-02-27 02:30:21 +00:00
|
|
|
%option no_sysinit
|
2021-03-21 20:10:29 +00:00
|
|
|
%zeropage basicsafe
|
2021-03-21 18:55:54 +00:00
|
|
|
|
|
|
|
; simple test program for the "VTUI" text user interface library
|
|
|
|
; see: https://github.com/JimmyDansbo/VTUIlib
|
|
|
|
|
2021-02-18 02:45:06 +00:00
|
|
|
main {
|
|
|
|
sub start() {
|
|
|
|
vtui.initialize()
|
2021-03-21 18:55:54 +00:00
|
|
|
store_logo()
|
|
|
|
|
|
|
|
txt.lowercase()
|
2021-04-08 00:13:02 +00:00
|
|
|
vtui.screen_set(2)
|
2021-02-27 02:30:21 +00:00
|
|
|
vtui.clr_scr('%', $50)
|
|
|
|
vtui.gotoxy(5,5)
|
|
|
|
vtui.fill_box(':', 70, 50, $c6)
|
2021-02-18 02:45:06 +00:00
|
|
|
vtui.gotoxy(10,10)
|
2021-02-18 22:16:38 +00:00
|
|
|
vtui.border(1, 40, 6, $47)
|
2021-02-18 02:45:06 +00:00
|
|
|
vtui.gotoxy(12,12)
|
2021-04-08 00:13:02 +00:00
|
|
|
vtui.print_str2(@"Hello, world! vtui from Prog8!", $f2, false)
|
2021-02-23 22:27:44 +00:00
|
|
|
vtui.gotoxy(12,13)
|
2021-04-08 00:13:02 +00:00
|
|
|
vtui.print_str2("Hello, world! vtui from Prog8!", $f2, true)
|
2021-03-21 18:55:54 +00:00
|
|
|
|
2021-03-21 20:10:29 +00:00
|
|
|
str inputbuffer = "?" * 20
|
|
|
|
|
|
|
|
; txt.print_uwhex(inputbuffer, 1)
|
|
|
|
; txt.chrout(':')
|
|
|
|
; txt.print(inputbuffer)
|
|
|
|
; txt.chrout('\n')
|
|
|
|
|
2021-03-21 18:55:54 +00:00
|
|
|
vtui.gotoxy(5,20)
|
2021-04-08 00:13:02 +00:00
|
|
|
vtui.print_str2(@"Enter your name: ", $e3, false)
|
2021-03-21 18:55:54 +00:00
|
|
|
ubyte length = vtui.input_str(inputbuffer, len(inputbuffer), $21)
|
|
|
|
|
|
|
|
vtui.gotoxy(8,22)
|
2021-04-08 00:13:02 +00:00
|
|
|
vtui.print_str2(@"Your name is: ", $e3, false)
|
2021-03-21 20:10:29 +00:00
|
|
|
;vtui.print_str2(inputbuffer, $67, $00)
|
2021-03-21 18:55:54 +00:00
|
|
|
vtui.print_str(inputbuffer, length, $67, $00)
|
|
|
|
|
|
|
|
; txt.uppercase() ; kills vtui?
|
|
|
|
logo_mover()
|
2021-02-18 02:45:06 +00:00
|
|
|
}
|
2021-02-27 02:30:21 +00:00
|
|
|
|
2021-03-21 18:55:54 +00:00
|
|
|
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)
|
|
|
|
}
|
2021-02-27 02:30:21 +00:00
|
|
|
|
|
|
|
sub logo_mover() {
|
2021-03-21 18:55:54 +00:00
|
|
|
ubyte xcoord = 0
|
|
|
|
ubyte ycoord = 0
|
|
|
|
ubyte newx = 0
|
|
|
|
ubyte newy = 0
|
2021-02-27 02:30:21 +00:00
|
|
|
|
|
|
|
;vtui.screen_set(2)
|
|
|
|
vtui.gotoxy(30, 32)
|
2021-04-08 00:13:02 +00:00
|
|
|
vtui.print_str2("arrow keys to move!", $61, true)
|
2021-02-27 02:30:21 +00:00
|
|
|
|
|
|
|
char_loop:
|
|
|
|
ubyte char = c64.GETIN()
|
|
|
|
if not char
|
|
|
|
goto char_loop
|
|
|
|
|
|
|
|
when char {
|
|
|
|
$91 -> {
|
|
|
|
if newy {
|
|
|
|
newy--
|
|
|
|
move_logo()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$11 -> {
|
|
|
|
if newy<53 {
|
|
|
|
newy++
|
|
|
|
move_logo()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$9d -> {
|
|
|
|
if newx {
|
|
|
|
newx--
|
|
|
|
move_logo()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$1d -> {
|
|
|
|
if newx<70 {
|
|
|
|
newx++
|
|
|
|
move_logo()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
goto char_loop
|
|
|
|
|
|
|
|
sub move_logo() {
|
|
|
|
vtui.gotoxy(xcoord, ycoord)
|
2021-03-21 18:55:54 +00:00
|
|
|
vtui.rest_rect($80, 1, $0100, 7, 7)
|
2021-02-27 02:30:21 +00:00
|
|
|
vtui.gotoxy(newx, newy)
|
2021-03-21 18:55:54 +00:00
|
|
|
vtui.save_rect($80, 1, $0100, 7, 7)
|
2021-02-27 02:30:21 +00:00
|
|
|
vtui.gotoxy(newx, newy)
|
2021-03-21 18:55:54 +00:00
|
|
|
vtui.rest_rect($80, 1, $0000, 7, 7)
|
2021-02-27 02:30:21 +00:00
|
|
|
xcoord = newx
|
|
|
|
ycoord = newy
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-18 02:45:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-02-18 22:16:38 +00:00
|
|
|
vtui $1000 {
|
|
|
|
|
2021-03-21 18:55:54 +00:00
|
|
|
%asmbinary "VTUI0.8.BIN", 2 ; skip the 2 dummy load address bytes
|
2021-02-18 22:16:38 +00:00
|
|
|
|
|
|
|
; NOTE: base address $1000 here must be the same as the block's memory address, for obvious reasons!
|
2021-04-07 23:36:25 +00:00
|
|
|
; The routines below are for VTUI 0.8
|
2021-02-18 22:16:38 +00:00
|
|
|
romsub $1000 = initialize() clobbers(A, X, Y)
|
|
|
|
romsub $1002 = screen_set(ubyte mode @A) clobbers(A, X, Y)
|
|
|
|
romsub $1005 = set_bank(ubyte bank @Pc) clobbers(A)
|
|
|
|
romsub $1008 = set_stride(ubyte stride @A) clobbers(A)
|
|
|
|
romsub $100b = set_decr(ubyte incrdecr @Pc) clobbers(A)
|
2021-02-27 02:30:21 +00:00
|
|
|
romsub $100e = clr_scr(ubyte char @A, ubyte colors @X) clobbers(Y)
|
|
|
|
romsub $1011 = gotoxy(ubyte column @A, ubyte row @Y)
|
|
|
|
romsub $1014 = plot_char(ubyte char @A, ubyte colors @X)
|
|
|
|
romsub $1017 = scan_char() -> ubyte @A, ubyte @X
|
|
|
|
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)
|
2021-03-21 18:55:54 +00:00
|
|
|
romsub $1020 = print_str(str txtstring @R0, ubyte length @Y, ubyte colors @X, ubyte convertchars @A) clobbers(A, Y)
|
2021-02-27 02:30:21 +00:00
|
|
|
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 $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 $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)
|
2021-03-21 18:55:54 +00:00
|
|
|
romsub $1035 = input_str(uword buffer @R0, ubyte buflen @Y, ubyte colors @X) clobbers (A) -> ubyte @Y
|
|
|
|
|
2021-04-08 00:13:02 +00:00
|
|
|
; -- helper function to do string length counting for you internally, and turn the convertchars flag into a boolean again
|
|
|
|
asmsub print_str2(str txtstring @R0, ubyte colors @X, ubyte convertchars @Pc) clobbers(A, Y) {
|
2021-03-21 18:55:54 +00:00
|
|
|
%asm {{
|
2021-04-08 00:13:02 +00:00
|
|
|
lda #0
|
|
|
|
bcs +
|
|
|
|
lda #$80
|
|
|
|
+ pha
|
2021-03-21 18:55:54 +00:00
|
|
|
lda cx16.r0
|
|
|
|
ldy cx16.r0+1
|
|
|
|
jsr prog8_lib.strlen
|
|
|
|
pla
|
|
|
|
jmp print_str
|
|
|
|
}}
|
|
|
|
}
|
2021-02-18 02:45:06 +00:00
|
|
|
}
|