From 8701d684e69a74065449311116c33318cda7392d Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Thu, 18 Feb 2021 03:45:06 +0100 Subject: [PATCH] added cx16 vtui example --- examples/cx16/vtui/VTUI0.3.BIN | Bin 0 -> 935 bytes examples/cx16/vtui/testvtui.p8 | 59 +++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 examples/cx16/vtui/VTUI0.3.BIN create mode 100644 examples/cx16/vtui/testvtui.p8 diff --git a/examples/cx16/vtui/VTUI0.3.BIN b/examples/cx16/vtui/VTUI0.3.BIN new file mode 100644 index 0000000000000000000000000000000000000000..1855dbbbe6723c325755ff34e2eb0292e3313cbf GIT binary patch literal 935 zcmb_ZO=uHA6rP=(O?I~_LcIh8-6Rd#vmU$|yr}~UV!>1AV1)?&9JGQU?BziYO^H3J z2vej}959mhD2g|6dMI=7ASe_MrsQB*Pq|s&W@9XAk1os1_rCewyl>tkBtFfb6aI?u z4}@F7Lx*n@-X;7e;eEo-IDFROQx2~>{DH%tQGUYZgy^?G^?Pu&0}MRy^*hLE3VAIc zh$uPRy9)GakASOavF-v>Zk>R);uJSnQkbX9Y@N-!Pgp#}$T>WGnIwZduf@ z{UO?lB>uZ4*|57}u_VK0B!!7u1ygHFtv_vqE4<}!*D^Ykae0IJE+U9 z|75?5b|ir+iq|Q3m5s_`rH`K75yr7h-;5Uwwa4`x?A<-=-DB+IZ3uJ?LYUC!p#YQd z4ddD=eE}8MP;m(r7a@qh8D`7+3bL1xeS|E>yoV6#yO?<&3i=l2o-!Wh&Y`M~svfGg zG53p(AP0HyAxP__RR(6;B?)M?q4GnwDjeBXxeSilwdyq*YI2Ok9u8mJETug~kt!V2 zY?Y)6GCD0ckwKhEcDwR3LcES->-tM)sVWa2y>`ZD|F8Oss$663ifm5HY~8fK*4W}; v)Hr}2@yWsQGVM}JyDn<}!cDugPx$pexR{psp!Q%r#Ki{1)6B&_IPT&PYomXx literal 0 HcmV?d00001 diff --git a/examples/cx16/vtui/testvtui.p8 b/examples/cx16/vtui/testvtui.p8 new file mode 100644 index 000000000..154750409 --- /dev/null +++ b/examples/cx16/vtui/testvtui.p8 @@ -0,0 +1,59 @@ +%target cx16 +%import textio +%zeropage dontuse + +main { + sub start() { + txt.lowercase() + vtui.initialize() + vtui.screen_set(2) + vtui.gotoxy(0,0) + vtui.fill_box(mkword(':',0), mkword(60, 80), $c6) + vtui.gotoxy(10,10) + vtui.border(1, mkword(10, 40), $47) + vtui.gotoxy(12,12) + vtui.print_str("Hello, world! VTUI from Prog8!", $f2) + + vtui.set_decr(1) + vtui.gotoxy(41,14) + vtui.print_str("Hello, world! VTUI from Prog8!", $f2) + + repeat { + } + } +} + +; TODO VTUI ideas: +; - question/bit of a problem: any particular reason fill_box() require the character to be in R0H (instead of R0L)? This complicates things for me because Prog8 treats the R-registers as words. Can't it be in A, like the mode for border()? +; - question/bit of a problem: any particular reason fill_box(), border(), save_rect() and rest_rect() require the dimensions to be in a single R1 register rather than splitting it across say R1L and R2L? (same reason as above) +; - suggestion: add a few more box types that look nice with the Upper+Lowercase characters charset. Currently only border mode 0 and 1 are ok in this case. Perhaps let the user specify the box character? +; - suggestion: let the initialize function set the 'sane' / most used default settings for vera stride and increment, without requiring screen_set() ? +; - suggestion: the petscii-to-screencode translation and vice versa, is now quite restrictive. My "Hello, world! VTUI from Prog8!" is printed as "Vello world! VVVV from Vrog8!" Can this perhaps be improved to map more characters +; - bug: calling initialize twice makes other calls crash +; - bug in doc: rest_rest() documentation is incorrect in the register table, 'Purpose' column seems copied from save_rect() +; - bug: a set_decr() with C=1 (decrement) seems to misalign character+color output for instance when using print_str() afterwards in an attempt to print in reverse. + + +vtui $4000 { + + %asmbinary "VTUI0.3.BIN", 2 ; skip the 2 dummy load address bytes + + ; NOTE: base address $4000 here must be the same as the block's memory address, for obvious reasons! + romsub $4000 = initialize() clobbers(A, X, Y) + romsub $4002 = screen_set(ubyte mode @A) clobbers(A, X, Y) + romsub $4005 = set_bank(ubyte bank @A) clobbers(A) + romsub $4008 = set_stride(ubyte stride @A) clobbers(A) + romsub $400b = set_decr(ubyte incrdecr @Pc) clobbers(A) + romsub $400e = gotoxy(ubyte column @A, ubyte row @Y) + romsub $4011 = plot_char(ubyte char @A, ubyte colors @X) + romsub $4014 = scan_char() -> ubyte @A, ubyte @X + romsub $4017 = hline(ubyte char @A, ubyte length @Y, ubyte colors @X) clobbers(A) + romsub $401a = vline(ubyte char @A, ubyte length @Y, ubyte colors @X) clobbers(A) + romsub $401d = print_str(str string @R0, ubyte colors @X) clobbers(A, Y) + romsub $4020 = fill_box(uword char @R0, uword dimensions @R1, ubyte colors @X) clobbers(A, Y) ; TODO : char must be in R0h.... R1L/R1H = width/height... + romsub $4023 = pet2scr(ubyte char @A) -> ubyte @A + romsub $4026 = scr2pet(ubyte char @A) -> ubyte @A + romsub $4029 = border(ubyte mode @A, uword dimensions @R1, ubyte colors @X) clobbers(Y) ; TODO : R1L/R1H = width/height... + romsub $402c = save_rect(ubyte vbank @A, uword address @R0, uword dimensions @R1, ubyte ramtype @Pc) clobbers(A, X, Y) ; TODO : R1L/R1H = width/height... move ramtype to first param once possible + romsub $402f = rest_rect(ubyte vbank @A, uword address @R0, uword dimensions @R1, ubyte ramtype @Pc) clobbers(A, X, Y) ; TODO : R1L/R1H = width/height... move ramtype to first param once possible +}