diff --git a/compiler/res/prog8lib/cx16/syslib.p8 b/compiler/res/prog8lib/cx16/syslib.p8 index 50ce43ed5..cd9b63f81 100644 --- a/compiler/res/prog8lib/cx16/syslib.p8 +++ b/compiler/res/prog8lib/cx16/syslib.p8 @@ -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) { diff --git a/docs/source/todo.rst b/docs/source/todo.rst index 6970397ea..4288315a5 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -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: diff --git a/examples/test.p8 b/examples/test.p8 index b9ef68dcc..1d6aeadfe 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -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()) } }