From 3a7e279453b40bfe5d74005a7227df73ee5ce585 Mon Sep 17 00:00:00 2001 From: Dave Date: Sat, 4 Dec 2021 23:10:33 -0600 Subject: [PATCH] Add ID message and keyboard test for apple2 kbds --- firmware/asdf/src/Keymaps/asdf_keymap_apple2.c | 11 ++++++++++- firmware/asdf/src/Keymaps/asdf_keymap_apple2.h | 8 ++++---- .../asdf/src/Keymaps/asdf_keymap_apple2_add_map.c | 14 +++++++++++++- .../asdf/src/Keymaps/asdf_keymap_apple2_add_map.h | 2 ++ .../asdf/src/Keymaps/asdf_keymap_apple2_caps.c | 11 +++++++++-- firmware/asdf/src/asdf_hook.h | 10 ++++++++++ 6 files changed, 48 insertions(+), 8 deletions(-) diff --git a/firmware/asdf/src/Keymaps/asdf_keymap_apple2.c b/firmware/asdf/src/Keymaps/asdf_keymap_apple2.c index b1bdbed..b29584e 100644 --- a/firmware/asdf/src/Keymaps/asdf_keymap_apple2.c +++ b/firmware/asdf/src/Keymaps/asdf_keymap_apple2.c @@ -29,6 +29,7 @@ #include "asdf_virtual.h" #include "asdf_modifiers.h" #include "asdf_keymap_apple2_add_map.h" +#include "asdf_keymap_apple2.h" // PROCEDURE: // INPUTS: @@ -44,16 +45,24 @@ // // COMPLEXITY: // + +void apple2_id_message(void) { + asdf_print("[Keymap: Apple 2 (u/l case)]"); +} + void setup_apple2_keymap(void) { + asdf_set_print_delay(APPLE2_PRINT_DELAY); - asdf_print("[Keymap: Apple 2 (u/l case)]"); apple_add_map(APPLE_PLAIN_MAP, MOD_PLAIN_MAP); apple_add_map(APPLE_CAPS_MAP, MOD_CAPS_MAP); apple_add_map(APPLE_SHIFT_MAP, MOD_SHIFT_MAP); apple_add_map(APPLE_CTRL_MAP, MOD_CTRL_MAP); + asdf_hook_assign(APPLESOFT_KEYBOARD_TEST, applesoft_keyboard_test); + asdf_hook_assign(APPLE2_ID_MESSAGE, apple2_id_message); + asdf_virtual_init(); diff --git a/firmware/asdf/src/Keymaps/asdf_keymap_apple2.h b/firmware/asdf/src/Keymaps/asdf_keymap_apple2.h index 1b4e7d9..e97245f 100644 --- a/firmware/asdf/src/Keymaps/asdf_keymap_apple2.h +++ b/firmware/asdf/src/Keymaps/asdf_keymap_apple2.h @@ -39,11 +39,11 @@ #if !defined(ASDF_KEYMAP_DEFS_APPLE2_H) #define ASDF_KEYMAP_DEFS_APPLE2_H -// include DIP switch definitions -#include "asdf_keymap_defs_dipswitch.h" +#define APPLESOFT_KEYBOARD_TEST ASDF_HOOK_USER_9 +#define APPLE2_ID_MESSAGE ASDF_HOOK_USER_10 + +#define APPLE2_PRINT_DELAY 40 // msec -// Edit the number of rows and columns used in this map. If the number is less -// than the maxium, the unused elements will be initialized to 0. #endif /* !defined (ASDF_KEYMAP_DEFS_APPLE2_H) */ diff --git a/firmware/asdf/src/Keymaps/asdf_keymap_apple2_add_map.c b/firmware/asdf/src/Keymaps/asdf_keymap_apple2_add_map.c index bbd6c64..0ce52df 100644 --- a/firmware/asdf/src/Keymaps/asdf_keymap_apple2_add_map.c +++ b/firmware/asdf/src/Keymaps/asdf_keymap_apple2_add_map.c @@ -25,6 +25,7 @@ #include "asdf_arch.h" #include "asdf.h" +#include "asdf_print.h" #include "asdf_ascii.h" #include "asdf_keymaps.h" #include "asdf_keymap_apple2_add_map.h" @@ -149,7 +150,18 @@ static const apple_keycode_matrix_t *apple_maps[] = { [APPLE_CAPS_SHIFT_MAP] = &apple_caps_shift_matrix }; - void apple_add_map(const apple_map_index_t map_index, +void applesoft_keyboard_test(void) +{ + asdf_print("10 GET A$\r"); + asdf_print("20 A = ASC(A$)\r"); + asdf_print("30 IF A < 32 THEN A$=\"CTL+\"+CHR$(A + 64)\r"); + asdf_print("40 ?\"'\";A$;\"' = \";A:\r"); + asdf_print("50 IF A <> 3 GOTO 10\r"); + asdf_print("60 END\rRUN\r"); + +} + +void apple_add_map(const apple_map_index_t map_index, modifier_index_t modifier_index) { diff --git a/firmware/asdf/src/Keymaps/asdf_keymap_apple2_add_map.h b/firmware/asdf/src/Keymaps/asdf_keymap_apple2_add_map.h index a2b511a..0a758d3 100644 --- a/firmware/asdf/src/Keymaps/asdf_keymap_apple2_add_map.h +++ b/firmware/asdf/src/Keymaps/asdf_keymap_apple2_add_map.h @@ -70,6 +70,8 @@ typedef enum { // function prototypes +void applesoft_keyboard_test(void); + void apple_add_map(const apple_map_index_t map_index, modifier_index_t modifier_index); #endif /* !defined (ASDF_KEYMAP_APPLE_ADD_MAP_H) */ diff --git a/firmware/asdf/src/Keymaps/asdf_keymap_apple2_caps.c b/firmware/asdf/src/Keymaps/asdf_keymap_apple2_caps.c index 51d7ab9..7eabcb6 100644 --- a/firmware/asdf/src/Keymaps/asdf_keymap_apple2_caps.c +++ b/firmware/asdf/src/Keymaps/asdf_keymap_apple2_caps.c @@ -29,6 +29,11 @@ #include "asdf_virtual.h" #include "asdf_modifiers.h" #include "asdf_keymap_apple2_add_map.h" +#include "asdf_keymap_apple2_caps.h" + +void apple2_caps_id_message(void) { + asdf_print("[Keymap: Apple 2 CAPS]"); +} // PROCEDURE: setup_apple2_caps_keymap // INPUTS: none @@ -46,14 +51,16 @@ // void setup_apple2_caps_keymap(void) { - - asdf_print("[Keymap: Apple 2 CAPS]"); + asdf_set_print_delay(APPLE2_PRINT_DELAY); apple_add_map(APPLE_CAPS_MAP, MOD_PLAIN_MAP); apple_add_map(APPLE_CAPS_MAP, MOD_CAPS_MAP); apple_add_map(APPLE_CAPS_SHIFT_MAP, MOD_SHIFT_MAP); apple_add_map(APPLE_CTRL_MAP, MOD_CTRL_MAP); + asdf_hook_assign(APPLESOFT_KEYBOARD_TEST, applesoft_keyboard_test); + asdf_hook_assign(APPLE2_CAPS_ID_MESSAGE, apple2_caps_id_message); + asdf_virtual_init(); diff --git a/firmware/asdf/src/asdf_hook.h b/firmware/asdf/src/asdf_hook.h index 0546053..46dadd8 100644 --- a/firmware/asdf/src/asdf_hook.h +++ b/firmware/asdf/src/asdf_hook.h @@ -32,6 +32,16 @@ typedef enum { ASDF_HOOK_SCANNER, ASDF_HOOK_OUTPUT, ASDF_HOOK_EACH_SCAN, + ASDF_HOOK_USER_1, + ASDF_HOOK_USER_2, + ASDF_HOOK_USER_3, + ASDF_HOOK_USER_4, + ASDF_HOOK_USER_5, + ASDF_HOOK_USER_6, + ASDF_HOOK_USER_7, + ASDF_HOOK_USER_8, + ASDF_HOOK_USER_9, + ASDF_HOOK_USER_10, ASDF_NUM_HOOKS, } asdf_hook_id_t;