From 8cda8a727ca37a001d337075327826975f732651 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Tue, 24 Jan 2023 00:58:16 +0100 Subject: [PATCH 1/3] update vtui example to vtui 1.0 --- examples/cx16/vtui/VTUI0.9.BIN | Bin 953 -> 0 bytes examples/cx16/vtui/VTUI1.0.BIN | Bin 0 -> 971 bytes examples/cx16/vtui/testvtui.p8 | 7 +++++-- examples/test.p8 | 5 ----- 4 files changed, 5 insertions(+), 7 deletions(-) delete mode 100644 examples/cx16/vtui/VTUI0.9.BIN create mode 100644 examples/cx16/vtui/VTUI1.0.BIN diff --git a/examples/cx16/vtui/VTUI0.9.BIN b/examples/cx16/vtui/VTUI0.9.BIN deleted file mode 100644 index 86c086bf5e1d38fa10b241b26ce0bf34dc921e97..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 953 zcma)4&ubGw7@eJ+jcIDzjj1*LahNpep%>{f2ce;-)DGB-3cYkLm0iIf2eA+kB4i+k zM%sdqLtz%lmaa6K_8(BNN>`z*hk}%Xf>Kk2a!x~;GhX5TOyRT)C`Xx%tkx9>i< zmC1~Zj9wkP9Q?SrD) zQCT)?rG(@zoo#h9vn?*Kss1o`u5mY0JLA%tW@fl^p9@mZ942(pZ7ikzb`dqQkifZe z+$5sMfU$Zlw5HWNR&a_8sk9qW9j)hgxmBA<$OS5`@dB|f6++8Y7H|d6P+1}17$zxt zd*J6y$n&`ys-;BCSc;o%LN~IY8lBjBg6tS%v$Uc=4zGXx6!v}|1QvRZEu{TU(b=$b zzMS@>;(`Ir;tjJg(N(1qVogY)R!Grq0b51;ER7*M4BO*4DxqT0?x0=B#*m4v_CO|p z+3f&rB&6L6alb+B_Y<+u)oy{#Ic$;&>YA@TNCulVeY_f ztB<*zUf)Yp-z_>6IFO;QLN1L4VCOg2Nd5gBhDY-b9!&@y%`1PnDfXx6dj4rcf&T_B Ct8qR6 diff --git a/examples/cx16/vtui/VTUI1.0.BIN b/examples/cx16/vtui/VTUI1.0.BIN new file mode 100644 index 0000000000000000000000000000000000000000..6d36bb86cc4c585702a24351973b10e9f19536d8 GIT binary patch literal 971 zcma)4O=uHA6rP=(jcID_#?%^W50fSZd#kq|goYj@rUUK8OD>&DB~koAM6n>`kbzJd zX$wjYg$a@^U1?-nya*l?i*!}W3ie>ZAFPxvXvxV+1?$_S)LMIR*qwRvz3+X@d~XoS zUSqEja}axv*al*=3L8+^PsAD()~>Kq3cIDSCkjg`?4m;7DQpz8bo)kObKEpgl2N#qZswL zqXHLQBvb>3GpZnlnn6MT1@o2Y6XOWH-G{Au7Gp4_kNCJ5kAJ_v{}=Wzi!f_A=6W=j%V< z5|!|6L?mQad7waLF=G`XlG}9LZ^z;1DKqt_nmGr`<9oiv51_avNV_@rPDdzER{K2#$!~L3DDsVd1n(&^1|o1-1b>95lYX5 zGp#~TC&0;IYUMsMLg2~FoPO88xc ubyte @Y + romsub $1038 = get_bank() clobbers (A) -> ubyte @Pc + romsub $103b = get_stride() -> ubyte @A + romsub $103e = get_decr() clobbers (A) -> ubyte @Pc ; -- 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) { diff --git a/examples/test.p8 b/examples/test.p8 index c8278e132..b1cadbd5f 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -12,11 +12,6 @@ main { str name="irmen" sub start() { - - for cx16.r0 in 0 to 10 { - cx16.r1++ - } - txt.print("= 10 ") txt.print_ub(zpvar) txt.nl() From 74b69e191ef416b4eaef3a632016ea6db9a36cce Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Tue, 24 Jan 2023 01:30:57 +0100 Subject: [PATCH 2/3] restructure keyboardhandler example due to X register bug, discussed in #94 --- examples/cx16/keyboardhandler.p8 | 69 +++++++++++++++++++++++--------- 1 file changed, 49 insertions(+), 20 deletions(-) diff --git a/examples/cx16/keyboardhandler.p8 b/examples/cx16/keyboardhandler.p8 index ae224bd90..2a4d266f8 100644 --- a/examples/cx16/keyboardhandler.p8 +++ b/examples/cx16/keyboardhandler.p8 @@ -10,56 +10,85 @@ main { sys.set_irqd() uword old_keyhdl = cx16.KEYHDL - cx16.KEYHDL = &main.keyboard_scancode_handler.asm_shim + cx16.KEYHDL = &keyboard_scancode_handler sys.clear_irqd() bool escape_pressed while not escape_pressed { - ; just sit here + handle_keyboard_event() } sys.set_irqd() cx16.KEYHDL = old_keyhdl sys.clear_irqd() } - sub keyboard_scancode_handler(ubyte prefix, ubyte scancode, bool updown) -> bool { - txt.print_ubhex(prefix, true) + ; Keyboard handler communication variables. + ; these need to be in block scope instead of in a subroutine, + ; so that they won't get overwritten with initialization values every time. + ; The assembly keyboard handler will set these, prog8 will read them. + bool @shared keyhdl_event ; is there a keyboard event to handle? + ubyte @shared keyhdl_prefix + ubyte @shared keyhdl_scancode + ubyte @shared keyhdl_updown + + sub handle_keyboard_event() { + ; Potentially handle keyboard event. + ; Note that we do this from the program's main loop instead of + ; the actual keyboard handler routine itself. + ; The reason for this is documented below in the handler assembly routine. + if not keyhdl_event + return + keyhdl_event = false + txt.print_ubhex(keyhdl_prefix, true) txt.chrout(':') - txt.print_ubhex(scancode, true) + txt.print_ubhex(keyhdl_scancode, true) txt.spc() - if updown + if keyhdl_updown txt.chrout('u') else txt.chrout('d') txt.nl() - if prefix==0 and scancode==119 and updown { + if keyhdl_prefix==0 and keyhdl_scancode==119 and keyhdl_updown { ; escape was pressed! exit back to basic main.start.escape_pressed = true } - return true ; true = consume key event, false = continue processing it + } + + asmsub keyboard_scancode_handler() { + + ; NOTE that the keyboard handler is an asm subroutine. + ; Unfortunately is it not possible to use prog8 code or calls here, + ; because the X register gets overwritten here (to store the prefix byte) + ; and prog8 uses the X register internally (for the evaluation stack). + ; So it is unsafe to call prog8 code from here because the evaluation stack pointer + ; will be invalid which produces undefined results. + ; So, instead, we store the various keyboard event bytes and signal + ; the main prog8 program that a keyboard event has occurred. + ; It then processes it independently from the assembly code here. + ; + ; Unfortunately this also means you cannot decide from that prog8 code + ; if the keyboard press should be consumed/ignored or put into the keyboard queue + ; (this is controlled by returning 0 or 1 in register A here) -asm_shim: %asm {{ php pha phx - stz updown + stz keyhdl_updown bcc + - inc updown -+ stx prefix - sta scancode - jsr keyboard_scancode_handler - beq + + inc keyhdl_updown ++ stx keyhdl_prefix + sta keyhdl_scancode + lda #1 + sta keyhdl_event + ; we can do additional stuff here and decide if we want to + ; consume the key event or not (A=0 or A!=0) plx pla - lda #0 ;By setting A=0 we will consume this key event + lda #0 ;By setting A=0 we will remove this key event for now tax plp rts -+ plx - pla ; leave A untouched, continue processing - plp - rts }} } } From 224278e07a59929d86800c8085d9809deda4416b Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Tue, 24 Jan 2023 01:49:38 +0100 Subject: [PATCH 3/3] correct openjdk-11 sdk setting in project files instead of just 11 --- .idea/misc.xml | 2 +- codeGenVirtual/codeGenVirtual.iml | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 codeGenVirtual/codeGenVirtual.iml diff --git a/.idea/misc.xml b/.idea/misc.xml index a73ef3d0a..cd58425e0 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -19,7 +19,7 @@ - + \ No newline at end of file diff --git a/codeGenVirtual/codeGenVirtual.iml b/codeGenVirtual/codeGenVirtual.iml new file mode 100644 index 000000000..99e1bf4ce --- /dev/null +++ b/codeGenVirtual/codeGenVirtual.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file