Skip to content

Commit

Permalink
update cx16.mouse_get() and mouse_pos() to also return scroll wheel in X
Browse files Browse the repository at this point in the history
  • Loading branch information
irmen committed May 29, 2024
1 parent 22c9e99 commit 15867ab
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions compiler/res/prog8lib/cx16/syslib.p8
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ romsub $fec0 = kbdbuf_get_modifiers() -> ubyte @A
romsub $fec3 = kbdbuf_put(ubyte key @A) clobbers(X)
romsub $fed2 = keymap(uword identifier @XY, bool read @Pc) -> bool @Pc
romsub $ff68 = mouse_config(byte shape @A, ubyte resX @X, ubyte resY @Y) clobbers (A, X, Y)
romsub $ff6b = mouse_get(ubyte zpdataptr @X) -> ubyte @A ; use mouse_pos() instead
romsub $ff6b = mouse_get(ubyte zdataptr @X) -> ubyte @A, byte @X ; use mouse_pos() instead
romsub $ff71 = mouse_scan() clobbers(A, X, Y)
romsub $ff53 = joystick_scan() clobbers(A, X, Y)
romsub $ff56 = joystick_get(ubyte joynr @A) -> uword @AX, bool @Y ; note: everything is inverted
Expand Down Expand Up @@ -587,9 +587,9 @@ asmsub mouse_config2(byte shape @A) clobbers (A, X, Y) {
}}
}

asmsub mouse_pos() clobbers(X) -> ubyte @A, uword @R0, uword @R1 {
asmsub mouse_pos() -> ubyte @A, uword @R0, uword @R1, byte @X {
; -- 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 in A.
; -- gets the position of the mouse cursor in cx16.r0 and cx16.r1 (x/y coordinate), returns mouse button status in A, scroll wheel in X.
; Note: mouse pointer needs to be enabled for this to do anything.
%asm {{
ldx #cx16.r0
Expand Down
2 changes: 1 addition & 1 deletion examples/cx16/spotlight.p8
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ main {

; spotlight
repeat {
void, cx16.r0, cx16.r1 = cx16.mouse_pos()
void, cx16.r0, cx16.r1, void = cx16.mouse_pos()
new_direction = math.direction(128, HEIGHT/2, clampx(cx16.r0), cx16.r1L)
if new_direction != previous_direction {
sys.waitvsync()
Expand Down

0 comments on commit 15867ab

Please sign in to comment.