From c8bd57cd4da2987eec776978526c84e3e2b9a10e Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Fri, 21 Jan 2022 22:06:17 +0100 Subject: [PATCH] fixed signature of mouse_get(): it returns the buttonstatus in A. Added convenience cx16.mouse_pos() routine. --- compiler/res/prog8lib/cx16/syslib.p8 | 14 ++++++++- compiler/res/version.txt | 2 +- docs/source/todo.rst | 4 ++- examples/test.p8 | 44 +++++----------------------- 4 files changed, 25 insertions(+), 39 deletions(-) diff --git a/compiler/res/prog8lib/cx16/syslib.p8 b/compiler/res/prog8lib/cx16/syslib.p8 index cb10c0553..4673dda18 100644 --- a/compiler/res/prog8lib/cx16/syslib.p8 +++ b/compiler/res/prog8lib/cx16/syslib.p8 @@ -307,13 +307,25 @@ romsub $ff7d = primm() romsub $ff44 = macptr() clobbers(A,X,Y) romsub $ff47 = enter_basic(ubyte cold_or_warm @Pc) clobbers(A,X,Y) romsub $ff68 = mouse_config(ubyte shape @A, ubyte scale @X) clobbers (A, X, Y) -romsub $ff6b = mouse_get(ubyte zpdataptr @X) clobbers(A) +romsub $ff6b = mouse_get(ubyte zpdataptr @X) -> ubyte @A romsub $ff71 = mouse_scan() clobbers(A, X, Y) romsub $ff53 = joystick_scan() clobbers(A, X, Y) romsub $ff56 = joystick_get(ubyte joynr @A) -> ubyte @A, ubyte @X, ubyte @Y romsub $ff4d = clock_set_date_time(uword yearmonth @R0, uword dayhours @R1, uword minsecs @R2, ubyte jiffies @R3) clobbers(A, X, Y) romsub $ff50 = clock_get_date_time() clobbers(A, X, Y) -> uword @R0, uword @R1, uword @R2, ubyte @R3 ; result registers see clock_set_date_time() +asmsub mouse_pos() -> ubyte @A { + ; -- short wrapper around mouse_get() kernal routine: + ; -- gets the position of the mouse cursor in cx16.r0 and cx16.r1 (x/y coordinate), returns mouse button status. + %asm {{ + phx + ldx #cx16.r0 + jsr cx16.mouse_get + plx + rts + }} +} + ; It's not documented what registers are clobbered, so we assume the worst for all following kernal routines...: diff --git a/compiler/res/version.txt b/compiler/res/version.txt index 25b629b0a..fa234972b 100644 --- a/compiler/res/version.txt +++ b/compiler/res/version.txt @@ -1 +1 @@ -7.7 +7.8-dev diff --git a/docs/source/todo.rst b/docs/source/todo.rst index c03691838..21985fac5 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -3,7 +3,9 @@ TODO For next release ^^^^^^^^^^^^^^^^ -... +- allow goto pointervar (goto $a000 already works...) then use this in cx16assem's run_file() +- allow "xxx" * constexpr (where constexpr is not a number literal, now gives expression error not same type) +- is * lower prio than bitwise & ? fix prios if so! Need help with diff --git a/examples/test.p8 b/examples/test.p8 index ec450a81d..e5647e373 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -2,45 +2,17 @@ %zeropage basicsafe main { - str s1 = "Irmen_" - str s2 = @"IRMEN_" - str s3 = sc:"IRMEN_" - str s4 = iso:"Käse, Straße" - sub start() { - txt.iso() - ; txt.lowercase() - txt.nl() - txt.nl() - txt.nl() - txt.nl() - txt.nl() - txt.print(s1) - txt.nl() - txt.print(s2) - txt.nl() - txt.print(s3) - txt.nl() - txt.print(s4) - txt.nl() + cx16.mouse_config(1, 0) - sc(1, s1) - sc(2, s2) - sc(3, s3) - sc(4, s4) - } - - sub sc(ubyte row, str text) { - uword addr = 1024+row*40 - ubyte ix = 0 - ubyte ss repeat { - ss = text[ix] - if not ss - return - @(addr) = ss - addr++ - ix++ + ubyte mb = cx16.mouse_pos() + txt.print_uw(cx16.r0) + txt.spc() + txt.print_uw(cx16.r1) + txt.spc() + txt.print_ub(mb) + txt.nl() } } }