mirror of
https://github.com/irmen/prog8.git
synced 2024-12-22 18:30:01 +00:00
added cx16.mouse_present() routine to check for presence of mouse
This commit is contained in:
parent
2396f707c6
commit
f7feaf158d
@ -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:
|
||||
|
||||
asmsub mouse_set_pos(uword xpos @R0, uword ypos @R1) clobbers(X) {
|
||||
|
@ -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().
|
||||
|
||||
|
||||
Regenerate skeletons in doc.
|
||||
|
||||
|
||||
Future Things and Ideas
|
||||
^^^^^^^^^^^^^^^^^^^^^^^
|
||||
Compiler:
|
||||
|
@ -5,23 +5,6 @@
|
||||
|
||||
main {
|
||||
sub start() {
|
||||
uword active_world = memory("world", 80*50, 0)
|
||||
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]
|
||||
}
|
||||
txt.print_bool(cx16.mouse_present())
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user