From fa7e66e8c0234871eb05ce1d34e87bef935354f2 Mon Sep 17 00:00:00 2001 From: Gwenhael Le Moine Date: Sun, 14 Apr 2024 21:41:11 +0200 Subject: [PATCH] move keys function from gui_buttons to keyboard --- src/gui.c | 3 +- src/gui_buttons.c | 103 -------------------------------------------- src/gui_buttons.h | 101 ------------------------------------------- src/keyboard.c | 106 ++++++++++++++++++++++++++++++++++++++++++++-- src/keyboard.h | 103 +++++++++++++++++++++++++++++++++++++++++++- 5 files changed, 206 insertions(+), 210 deletions(-) diff --git a/src/gui.c b/src/gui.c index d6fecd8..123de5c 100644 --- a/src/gui.c +++ b/src/gui.c @@ -6,11 +6,12 @@ #include #include "config.h" -#include "gui_buttons.h" +#include "keyboard.h" #include "files.h" #include "gui.h" #include "emulator.h" #include "display.h" +#include "gui_buttons.h" #define PANEL_FLAG_VISIBLE 0x01 diff --git a/src/gui_buttons.c b/src/gui_buttons.c index d5c6c04..948536c 100644 --- a/src/gui_buttons.c +++ b/src/gui_buttons.c @@ -4,7 +4,6 @@ #include "keyboard.h" #include "gui.h" #include "gui_buttons.h" -#include "files.h" const int std_flags = BUTTON_B1RELEASE | BUTTON_B2TOGGLE; @@ -70,105 +69,3 @@ Button calc_buttons[] = { {49, X_COL( 0 ), Y_LINE( 9 ), 40, UI_K_HEIGHT_2, std_flags, "load file", "", "", "", "", press_LoadFile, release_LoadFile}, }; - -void press_PLUS( void ) { kbd_key_pressed( 0, 0 ); } -void release_PLUS( void ) { kbd_key_released( 0, 0 ); } -void press_SPC( void ) { kbd_key_pressed( 0, 1 ); } -void release_SPC( void ) { kbd_key_released( 0, 1 ); } -void press_PERIOD( void ) { kbd_key_pressed( 0, 2 ); } -void release_PERIOD( void ) { kbd_key_released( 0, 2 ); } -void press_0( void ) { kbd_key_pressed( 0, 3 ); } -void release_0( void ) { kbd_key_released( 0, 3 ); } -void press_QUOTE( void ) { kbd_key_pressed( 0, 4 ); } -void release_QUOTE( void ) { kbd_key_released( 0, 4 ); } -void press_MINUS( void ) { kbd_key_pressed( 1, 0 ); } -void release_MINUS( void ) { kbd_key_released( 1, 0 ); } -void press_3( void ) { kbd_key_pressed( 1, 1 ); } -void release_3( void ) { kbd_key_released( 1, 1 ); } -void press_2( void ) { kbd_key_pressed( 1, 2 ); } -void release_2( void ) { kbd_key_released( 1, 2 ); } -void press_1( void ) { kbd_key_pressed( 1, 3 ); } -void release_1( void ) { kbd_key_released( 1, 3 ); } -void press_A( void ) { kbd_key_pressed( 1, 4 ); } -void release_A( void ) { kbd_key_released( 1, 4 ); } -void press_RSHIFT( void ) { kbd_key_pressed( 1, 5 ); } -void release_RSHIFT( void ) { kbd_key_released( 1, 5 ); } -void press_MULT( void ) { kbd_key_pressed( 2, 0 ); } -void release_MULT( void ) { kbd_key_released( 2, 0 ); } -void press_6( void ) { kbd_key_pressed( 2, 1 ); } -void release_6( void ) { kbd_key_released( 2, 1 ); } -void press_5( void ) { kbd_key_pressed( 2, 2 ); } -void release_5( void ) { kbd_key_released( 2, 2 ); } -void press_4( void ) { kbd_key_pressed( 2, 3 ); } -void release_4( void ) { kbd_key_released( 2, 3 ); } -void press_MTH( void ) { kbd_key_pressed( 2, 4 ); } -void release_MTH( void ) { kbd_key_released( 2, 4 ); } -void press_LSHIFT( void ) { kbd_key_pressed( 2, 5 ); } -void release_LSHIFT( void ) { kbd_key_released( 2, 5 ); } -void press_DIV( void ) { kbd_key_pressed( 3, 0 ); } -void release_DIV( void ) { kbd_key_released( 3, 0 ); } -void press_9( void ) { kbd_key_pressed( 3, 1 ); } -void release_9( void ) { kbd_key_released( 3, 1 ); } -void press_8( void ) { kbd_key_pressed( 3, 2 ); } -void release_8( void ) { kbd_key_released( 3, 2 ); } -void press_7( void ) { kbd_key_pressed( 3, 3 ); } -void release_7( void ) { kbd_key_released( 3, 3 ); } -void press_SIN( void ) { kbd_key_pressed( 3, 4 ); } -void release_SIN( void ) { kbd_key_released( 3, 4 ); } -void press_ALPHA( void ) { kbd_key_pressed( 3, 5 ); } -void release_ALPHA( void ) { kbd_key_released( 3, 5 ); } -void press_BKSP( void ) { kbd_key_pressed( 4, 0 ); } -void release_BKSP( void ) { kbd_key_released( 4, 0 ); } -void press_DEL( void ) { kbd_key_pressed( 4, 1 ); } -void release_DEL( void ) { kbd_key_released( 4, 1 ); } -void press_EEX( void ) { kbd_key_pressed( 4, 2 ); } -void release_EEX( void ) { kbd_key_released( 4, 2 ); } -void press_NEG( void ) { kbd_key_pressed( 4, 3 ); } -void release_NEG( void ) { kbd_key_released( 4, 3 ); } -void press_ENTER( void ) { kbd_key_pressed( 4, 4 ); } -void release_ENTER( void ) { kbd_key_released( 4, 4 ); } -void press_INV( void ) { kbd_key_pressed( 5, 0 ); } -void release_INV( void ) { kbd_key_released( 5, 0 ); } -void press_POW( void ) { kbd_key_pressed( 5, 1 ); } -void release_POW( void ) { kbd_key_released( 5, 1 ); } -void press_SQRT( void ) { kbd_key_pressed( 5, 2 ); } -void release_SQRT( void ) { kbd_key_released( 5, 2 ); } -void press_TAN( void ) { kbd_key_pressed( 5, 3 ); } -void release_TAN( void ) { kbd_key_released( 5, 3 ); } -void press_COS( void ) { kbd_key_pressed( 5, 4 ); } -void release_COS( void ) { kbd_key_released( 5, 4 ); } -void press_RIGHT( void ) { kbd_key_pressed( 6, 0 ); } -void release_RIGHT( void ) { kbd_key_released( 6, 0 ); } -void press_DOWN( void ) { kbd_key_pressed( 6, 1 ); } -void release_DOWN( void ) { kbd_key_released( 6, 1 ); } -void press_LEFT( void ) { kbd_key_pressed( 6, 2 ); } -void release_LEFT( void ) { kbd_key_released( 6, 2 ); } -void press_EVAL( void ) { kbd_key_pressed( 6, 3 ); } -void release_EVAL( void ) { kbd_key_released( 6, 3 ); } -void press_STO( void ) { kbd_key_pressed( 6, 4 ); } -void release_STO( void ) { kbd_key_released( 6, 4 ); } -void press_NXT( void ) { kbd_key_pressed( 7, 0 ); } -void release_NXT( void ) { kbd_key_released( 7, 0 ); } -void press_UP( void ) { kbd_key_pressed( 7, 1 ); } -void release_UP( void ) { kbd_key_released( 7, 1 ); } -void press_VAR( void ) { kbd_key_pressed( 7, 2 ); } -void release_VAR( void ) { kbd_key_released( 7, 2 ); } -void press_CST( void ) { kbd_key_pressed( 7, 3 ); } -void release_CST( void ) { kbd_key_released( 7, 3 ); } -void press_PRG( void ) { kbd_key_pressed( 7, 4 ); } -void release_PRG( void ) { kbd_key_released( 7, 4 ); } -void press_F( void ) { kbd_key_pressed( 8, 0 ); } -void release_F( void ) { kbd_key_released( 8, 0 ); } -void press_E( void ) { kbd_key_pressed( 8, 1 ); } -void release_E( void ) { kbd_key_released( 8, 1 ); } -void press_D( void ) { kbd_key_pressed( 8, 2 ); } -void release_D( void ) { kbd_key_released( 8, 2 ); } -void press_C( void ) { kbd_key_pressed( 8, 3 ); } -void release_C( void ) { kbd_key_released( 8, 3 ); } -void press_B( void ) { kbd_key_pressed( 8, 4 ); } -void release_B( void ) { kbd_key_released( 8, 4 ); } -void press_ON( void ) { kbd_on_pressed(); } -void release_ON( void ) { kbd_on_released(); } - -void press_LoadFile( void ) {} -void release_LoadFile( void ) { load_file_on_stack( "zeldahp.dir" ); } diff --git a/src/gui_buttons.h b/src/gui_buttons.h index ba41d6c..1fe9ec6 100644 --- a/src/gui_buttons.h +++ b/src/gui_buttons.h @@ -7,105 +7,4 @@ extern Button calc_buttons[]; -extern void press_PLUS( void ); -extern void release_PLUS( void ); -extern void press_SPC( void ); -extern void release_SPC( void ); -extern void press_PERIOD( void ); -extern void release_PERIOD( void ); -extern void press_0( void ); -extern void release_0( void ); -extern void press_QUOTE( void ); -extern void release_QUOTE( void ); -extern void press_MINUS( void ); -extern void release_MINUS( void ); -extern void press_3( void ); -extern void release_3( void ); -extern void press_2( void ); -extern void release_2( void ); -extern void press_1( void ); -extern void release_1( void ); -extern void press_A( void ); -extern void release_A( void ); -extern void press_RSHIFT( void ); -extern void release_RSHIFT( void ); -extern void press_MULT( void ); -extern void release_MULT( void ); -extern void press_6( void ); -extern void release_6( void ); -extern void press_5( void ); -extern void release_5( void ); -extern void press_4( void ); -extern void release_4( void ); -extern void press_MTH( void ); -extern void release_MTH( void ); -extern void press_LSHIFT( void ); -extern void release_LSHIFT( void ); -extern void press_DIV( void ); -extern void release_DIV( void ); -extern void press_9( void ); -extern void release_9( void ); -extern void press_8( void ); -extern void release_8( void ); -extern void press_7( void ); -extern void release_7( void ); -extern void press_SIN( void ); -extern void release_SIN( void ); -extern void press_ALPHA( void ); -extern void release_ALPHA( void ); -extern void press_BKSP( void ); -extern void release_BKSP( void ); -extern void press_DEL( void ); -extern void release_DEL( void ); -extern void press_EEX( void ); -extern void release_EEX( void ); -extern void press_NEG( void ); -extern void release_NEG( void ); -extern void press_ENTER( void ); -extern void release_ENTER( void ); -extern void press_INV( void ); -extern void release_INV( void ); -extern void press_POW( void ); -extern void release_POW( void ); -extern void press_SQRT( void ); -extern void release_SQRT( void ); -extern void press_TAN( void ); -extern void release_TAN( void ); -extern void press_COS( void ); -extern void release_COS( void ); -extern void press_RIGHT( void ); -extern void release_RIGHT( void ); -extern void press_DOWN( void ); -extern void release_DOWN( void ); -extern void press_LEFT( void ); -extern void release_LEFT( void ); -extern void press_EVAL( void ); -extern void release_EVAL( void ); -extern void press_STO( void ); -extern void release_STO( void ); -extern void press_NXT( void ); -extern void release_NXT( void ); -extern void press_UP( void ); -extern void release_UP( void ); -extern void press_VAR( void ); -extern void release_VAR( void ); -extern void press_CST( void ); -extern void release_CST( void ); -extern void press_PRG( void ); -extern void release_PRG( void ); -extern void press_F( void ); -extern void release_F( void ); -extern void press_E( void ); -extern void release_E( void ); -extern void press_D( void ); -extern void release_D( void ); -extern void press_C( void ); -extern void release_C( void ); -extern void press_B( void ); -extern void release_B( void ); -extern void press_ON( void ); -extern void release_ON( void ); -extern void press_LoadFile( void ); -extern void release_LoadFile( void ); - #endif diff --git a/src/keyboard.c b/src/keyboard.c index abea7f9..3870167 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -1,7 +1,7 @@ #include "types.h" #include "cpu.h" #include "keyboard.h" - +#include "files.h" bool kbd_on; static byte kbd_row[ 9 ]; @@ -66,7 +66,104 @@ void kbd_key_released( int row, int col ) cpu.keyintp = false; } -void kbd_on_pressed( void ) +void press_PLUS( void ) { kbd_key_pressed( 0, 0 ); } +void release_PLUS( void ) { kbd_key_released( 0, 0 ); } +void press_SPC( void ) { kbd_key_pressed( 0, 1 ); } +void release_SPC( void ) { kbd_key_released( 0, 1 ); } +void press_PERIOD( void ) { kbd_key_pressed( 0, 2 ); } +void release_PERIOD( void ) { kbd_key_released( 0, 2 ); } +void press_0( void ) { kbd_key_pressed( 0, 3 ); } +void release_0( void ) { kbd_key_released( 0, 3 ); } +void press_QUOTE( void ) { kbd_key_pressed( 0, 4 ); } +void release_QUOTE( void ) { kbd_key_released( 0, 4 ); } +void press_MINUS( void ) { kbd_key_pressed( 1, 0 ); } +void release_MINUS( void ) { kbd_key_released( 1, 0 ); } +void press_3( void ) { kbd_key_pressed( 1, 1 ); } +void release_3( void ) { kbd_key_released( 1, 1 ); } +void press_2( void ) { kbd_key_pressed( 1, 2 ); } +void release_2( void ) { kbd_key_released( 1, 2 ); } +void press_1( void ) { kbd_key_pressed( 1, 3 ); } +void release_1( void ) { kbd_key_released( 1, 3 ); } +void press_A( void ) { kbd_key_pressed( 1, 4 ); } +void release_A( void ) { kbd_key_released( 1, 4 ); } +void press_RSHIFT( void ) { kbd_key_pressed( 1, 5 ); } +void release_RSHIFT( void ) { kbd_key_released( 1, 5 ); } +void press_MULT( void ) { kbd_key_pressed( 2, 0 ); } +void release_MULT( void ) { kbd_key_released( 2, 0 ); } +void press_6( void ) { kbd_key_pressed( 2, 1 ); } +void release_6( void ) { kbd_key_released( 2, 1 ); } +void press_5( void ) { kbd_key_pressed( 2, 2 ); } +void release_5( void ) { kbd_key_released( 2, 2 ); } +void press_4( void ) { kbd_key_pressed( 2, 3 ); } +void release_4( void ) { kbd_key_released( 2, 3 ); } +void press_MTH( void ) { kbd_key_pressed( 2, 4 ); } +void release_MTH( void ) { kbd_key_released( 2, 4 ); } +void press_LSHIFT( void ) { kbd_key_pressed( 2, 5 ); } +void release_LSHIFT( void ) { kbd_key_released( 2, 5 ); } +void press_DIV( void ) { kbd_key_pressed( 3, 0 ); } +void release_DIV( void ) { kbd_key_released( 3, 0 ); } +void press_9( void ) { kbd_key_pressed( 3, 1 ); } +void release_9( void ) { kbd_key_released( 3, 1 ); } +void press_8( void ) { kbd_key_pressed( 3, 2 ); } +void release_8( void ) { kbd_key_released( 3, 2 ); } +void press_7( void ) { kbd_key_pressed( 3, 3 ); } +void release_7( void ) { kbd_key_released( 3, 3 ); } +void press_SIN( void ) { kbd_key_pressed( 3, 4 ); } +void release_SIN( void ) { kbd_key_released( 3, 4 ); } +void press_ALPHA( void ) { kbd_key_pressed( 3, 5 ); } +void release_ALPHA( void ) { kbd_key_released( 3, 5 ); } +void press_BKSP( void ) { kbd_key_pressed( 4, 0 ); } +void release_BKSP( void ) { kbd_key_released( 4, 0 ); } +void press_DEL( void ) { kbd_key_pressed( 4, 1 ); } +void release_DEL( void ) { kbd_key_released( 4, 1 ); } +void press_EEX( void ) { kbd_key_pressed( 4, 2 ); } +void release_EEX( void ) { kbd_key_released( 4, 2 ); } +void press_NEG( void ) { kbd_key_pressed( 4, 3 ); } +void release_NEG( void ) { kbd_key_released( 4, 3 ); } +void press_ENTER( void ) { kbd_key_pressed( 4, 4 ); } +void release_ENTER( void ) { kbd_key_released( 4, 4 ); } +void press_INV( void ) { kbd_key_pressed( 5, 0 ); } +void release_INV( void ) { kbd_key_released( 5, 0 ); } +void press_POW( void ) { kbd_key_pressed( 5, 1 ); } +void release_POW( void ) { kbd_key_released( 5, 1 ); } +void press_SQRT( void ) { kbd_key_pressed( 5, 2 ); } +void release_SQRT( void ) { kbd_key_released( 5, 2 ); } +void press_TAN( void ) { kbd_key_pressed( 5, 3 ); } +void release_TAN( void ) { kbd_key_released( 5, 3 ); } +void press_COS( void ) { kbd_key_pressed( 5, 4 ); } +void release_COS( void ) { kbd_key_released( 5, 4 ); } +void press_RIGHT( void ) { kbd_key_pressed( 6, 0 ); } +void release_RIGHT( void ) { kbd_key_released( 6, 0 ); } +void press_DOWN( void ) { kbd_key_pressed( 6, 1 ); } +void release_DOWN( void ) { kbd_key_released( 6, 1 ); } +void press_LEFT( void ) { kbd_key_pressed( 6, 2 ); } +void release_LEFT( void ) { kbd_key_released( 6, 2 ); } +void press_EVAL( void ) { kbd_key_pressed( 6, 3 ); } +void release_EVAL( void ) { kbd_key_released( 6, 3 ); } +void press_STO( void ) { kbd_key_pressed( 6, 4 ); } +void release_STO( void ) { kbd_key_released( 6, 4 ); } +void press_NXT( void ) { kbd_key_pressed( 7, 0 ); } +void release_NXT( void ) { kbd_key_released( 7, 0 ); } +void press_UP( void ) { kbd_key_pressed( 7, 1 ); } +void release_UP( void ) { kbd_key_released( 7, 1 ); } +void press_VAR( void ) { kbd_key_pressed( 7, 2 ); } +void release_VAR( void ) { kbd_key_released( 7, 2 ); } +void press_CST( void ) { kbd_key_pressed( 7, 3 ); } +void release_CST( void ) { kbd_key_released( 7, 3 ); } +void press_PRG( void ) { kbd_key_pressed( 7, 4 ); } +void release_PRG( void ) { kbd_key_released( 7, 4 ); } +void press_F( void ) { kbd_key_pressed( 8, 0 ); } +void release_F( void ) { kbd_key_released( 8, 0 ); } +void press_E( void ) { kbd_key_pressed( 8, 1 ); } +void release_E( void ) { kbd_key_released( 8, 1 ); } +void press_D( void ) { kbd_key_pressed( 8, 2 ); } +void release_D( void ) { kbd_key_released( 8, 2 ); } +void press_C( void ) { kbd_key_pressed( 8, 3 ); } +void release_C( void ) { kbd_key_released( 8, 3 ); } +void press_B( void ) { kbd_key_pressed( 8, 4 ); } +void release_B( void ) { kbd_key_released( 8, 4 ); } + +void press_ON( void ) { bool no_key = !cpu.in[ 3 ]; kbd_on = true; @@ -78,8 +175,11 @@ void kbd_on_pressed( void ) cpu_interrupt(); } -void kbd_on_released( void ) +void release_ON( void ) { kbd_on = false; cpu.in[ 3 ] &= ~8; } + +void press_LoadFile( void ) {} +void release_LoadFile( void ) { load_file_on_stack( "zeldahp.dir" ); } diff --git a/src/keyboard.h b/src/keyboard.h index 9e5caa5..07b5fba 100644 --- a/src/keyboard.h +++ b/src/keyboard.h @@ -8,7 +8,106 @@ extern bool kbd_on; extern void kbd_out_changed( void ); extern void kbd_key_pressed( int row, int col ); extern void kbd_key_released( int row, int col ); -extern void kbd_on_pressed( void ); -extern void kbd_on_released( void ); + +extern void press_PLUS( void ); +extern void release_PLUS( void ); +extern void press_SPC( void ); +extern void release_SPC( void ); +extern void press_PERIOD( void ); +extern void release_PERIOD( void ); +extern void press_0( void ); +extern void release_0( void ); +extern void press_QUOTE( void ); +extern void release_QUOTE( void ); +extern void press_MINUS( void ); +extern void release_MINUS( void ); +extern void press_3( void ); +extern void release_3( void ); +extern void press_2( void ); +extern void release_2( void ); +extern void press_1( void ); +extern void release_1( void ); +extern void press_A( void ); +extern void release_A( void ); +extern void press_RSHIFT( void ); +extern void release_RSHIFT( void ); +extern void press_MULT( void ); +extern void release_MULT( void ); +extern void press_6( void ); +extern void release_6( void ); +extern void press_5( void ); +extern void release_5( void ); +extern void press_4( void ); +extern void release_4( void ); +extern void press_MTH( void ); +extern void release_MTH( void ); +extern void press_LSHIFT( void ); +extern void release_LSHIFT( void ); +extern void press_DIV( void ); +extern void release_DIV( void ); +extern void press_9( void ); +extern void release_9( void ); +extern void press_8( void ); +extern void release_8( void ); +extern void press_7( void ); +extern void release_7( void ); +extern void press_SIN( void ); +extern void release_SIN( void ); +extern void press_ALPHA( void ); +extern void release_ALPHA( void ); +extern void press_BKSP( void ); +extern void release_BKSP( void ); +extern void press_DEL( void ); +extern void release_DEL( void ); +extern void press_EEX( void ); +extern void release_EEX( void ); +extern void press_NEG( void ); +extern void release_NEG( void ); +extern void press_ENTER( void ); +extern void release_ENTER( void ); +extern void press_INV( void ); +extern void release_INV( void ); +extern void press_POW( void ); +extern void release_POW( void ); +extern void press_SQRT( void ); +extern void release_SQRT( void ); +extern void press_TAN( void ); +extern void release_TAN( void ); +extern void press_COS( void ); +extern void release_COS( void ); +extern void press_RIGHT( void ); +extern void release_RIGHT( void ); +extern void press_DOWN( void ); +extern void release_DOWN( void ); +extern void press_LEFT( void ); +extern void release_LEFT( void ); +extern void press_EVAL( void ); +extern void release_EVAL( void ); +extern void press_STO( void ); +extern void release_STO( void ); +extern void press_NXT( void ); +extern void release_NXT( void ); +extern void press_UP( void ); +extern void release_UP( void ); +extern void press_VAR( void ); +extern void release_VAR( void ); +extern void press_CST( void ); +extern void release_CST( void ); +extern void press_PRG( void ); +extern void release_PRG( void ); +extern void press_F( void ); +extern void release_F( void ); +extern void press_E( void ); +extern void release_E( void ); +extern void press_D( void ); +extern void release_D( void ); +extern void press_C( void ); +extern void release_C( void ); +extern void press_B( void ); +extern void release_B( void ); +extern void press_ON( void ); +extern void release_ON( void ); +extern void press_LoadFile( void ); +extern void release_LoadFile( void ); #endif