added cx16.mouse_present() routine to check for presence of mouse

This commit is contained in:
Irmen de Jong 2024-09-06 18:21:13 +02:00
parent 2396f707c6
commit f7feaf158d
3 changed files with 12 additions and 18 deletions

View File

@ -603,6 +603,14 @@ asmsub mouse_pos() -> ubyte @A, uword @R0, uword @R1, byte @X {
}} }}
} }
sub mouse_present() -> bool {
; -- check if a mouse is connected to the machine
cx16.r0L, void = cx16.i2c_read_byte($42, $22) ; $22 = I2C_GET_MOUSE_DEVICE_ID
if_cs
return false
return cx16.r0L != $fc ; $fc = BAT_FAIL
}
; shims for the kernal routines called via the extapi call: ; shims for the kernal routines called via the extapi call:
asmsub mouse_set_pos(uword xpos @R0, uword ypos @R1) clobbers(X) { asmsub mouse_set_pos(uword xpos @R0, uword ypos @R1) clobbers(X) {

View File

@ -7,6 +7,9 @@ in overwriting registers that already got their value, which requires a lot of s
Maybe this routine can be made more intelligent. See usesOtherRegistersWhileEvaluating() and argumentsViaRegisters(). Maybe this routine can be made more intelligent. See usesOtherRegistersWhileEvaluating() and argumentsViaRegisters().
Regenerate skeletons in doc.
Future Things and Ideas Future Things and Ideas
^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^
Compiler: Compiler:

View File

@ -5,23 +5,6 @@
main { main {
sub start() { sub start() {
uword active_world = memory("world", 80*50, 0) txt.print_bool(cx16.mouse_present())
uword @shared cell_off = 500
uword @shared cell_off_1 = cell_off+1
const uword STRIDE = 40
sys.memset(active_world, 80*50, 1)
txt.print_ub(active_world[500] + active_world[501]) ; 2
txt.nl()
txt.print_ub(active_world[cell_off] + active_world[cell_off_1]) ; 2
txt.nl()
txt.print_ub(count()) ; 8
txt.nl()
sub count() -> ubyte {
return active_world[cell_off-STRIDE-1] + active_world[cell_off-STRIDE] + active_world[cell_off-STRIDE+1] +
active_world[cell_off-1] + active_world[cell_off+1] +
active_world[cell_off+STRIDE-1] + active_world[cell_off+STRIDE] + active_world[cell_off+STRIDE+1]
}
} }
} }