From 6eb4aef0e8e96c0b4a97544a7ebb0a2c25302b41 Mon Sep 17 00:00:00 2001
From: Oliver Schmidt
Date: Fri, 27 Jul 2018 22:03:26 +0200
Subject: [PATCH] Enhanced C interface to user input control.
---
inc/ip65.h | 15 +++++++++++++--
ip65/input_c.s | 14 +++++++++++++-
2 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/inc/ip65.h b/inc/ip65.h
index 0760af2..007086f 100644
--- a/inc/ip65.h
+++ b/inc/ip65.h
@@ -373,7 +373,14 @@ uint16_t timer_read(void);
//
bool __fastcall__ timer_timeout(uint16_t time);
-// User abort control
+// Check whether the abort key is being pressed
+//
+// Inputs: None
+// Output: true if abort key pressed, false otherwise
+//
+bool input_check_for_abort_key(void);
+
+// Control abort key
//
// Control if the user can abort blocking functions with the abort key
// (making them return IP65_ERROR_ABORTED_BY_USER). Initially the abort
@@ -382,6 +389,10 @@ bool __fastcall__ timer_timeout(uint16_t time);
// Inputs: enable: false to disable the key, true to enable the key
// Output: None
//
-void __fastcall__ abort_key(bool enable);
+void __fastcall__ input_set_abort_key(bool enable);
+
+// Access to actual abort key code
+//
+extern uint8_t abort_key;
#endif
diff --git a/ip65/input_c.s b/ip65/input_c.s
index ae05f36..363c503 100644
--- a/ip65/input_c.s
+++ b/ip65/input_c.s
@@ -1,15 +1,27 @@
.include "../inc/common.inc"
+.export _input_check_for_abort_key
+.export _input_set_abort_key
.export _abort_key
+.import check_for_abort_key
.import abort_key
.importzp abort_key_default
.importzp abort_key_disable
-_abort_key:
+_input_check_for_abort_key:
+ jsr check_for_abort_key
+ ldx #$00
+ txa
+ rol
+ rts
+
+_input_set_abort_key:
lsr
lda #abort_key_default
bcs :+
lda #abort_key_disable
: sta abort_key
rts
+
+_abort_key := abort_key