diff --git a/src/bus.h b/src/bus.h index c78463e..af86006 100644 --- a/src/bus.h +++ b/src/bus.h @@ -1,6 +1,8 @@ #ifndef __BUS_H #define __BUS_H +#include + #include "types.h" typedef struct { diff --git a/src/cpu.h b/src/cpu.h index fcfa453..4911843 100644 --- a/src/cpu.h +++ b/src/cpu.h @@ -1,6 +1,8 @@ #ifndef __CPU_H #define __CPU_H +#include + #include "types.h" typedef struct { diff --git a/src/display.h b/src/display.h index ce5271f..65060a8 100644 --- a/src/display.h +++ b/src/display.h @@ -2,6 +2,7 @@ #define __DISPLAY_H #include +#include #include "types.h" diff --git a/src/emulator.h b/src/emulator.h index 2b182d3..8a81d52 100644 --- a/src/emulator.h +++ b/src/emulator.h @@ -1,6 +1,8 @@ #ifndef __EMULATOR_H #define __EMULATOR_H +#include + #include "types.h" enum EmulatorStates { EMULATOR_STOP, EMULATOR_STEP, EMULATOR_RUN }; diff --git a/src/files.c b/src/files.c index 83756fe..8f8b23c 100644 --- a/src/files.c +++ b/src/files.c @@ -15,6 +15,8 @@ #include "ports.h" #include "config.h" +#define MAX_LENGTH_FILENAME 2048 + extern byte current_bank; extern byte* port2; extern address port2mask; diff --git a/src/files.h b/src/files.h index ae059cd..a8659a4 100644 --- a/src/files.h +++ b/src/files.h @@ -1,10 +1,6 @@ #ifndef __PFILES_H #define __PFILES_H -#include "types.h" - -#define MAX_LENGTH_FILENAME 2048 - extern void get_absolute_working_dir_path(); extern int file_size( char* filename ); diff --git a/src/gui.c b/src/gui.c index c80bd9e..71b9c0f 100644 --- a/src/gui.c +++ b/src/gui.c @@ -14,10 +14,83 @@ #define PANEL_FLAG_VISIBLE 0x01 -extern SDL_Renderer* renderer; +#define UI_SCALE 4 -TTF_Font* ttffont = NULL; -TTF_Font* ttffont2 = NULL; +#define UI_PADDING 4 +#define UI_KEY_PADDING 4 + +#define ANNUNC_X UI_PADDING +#define ANNUNC_Y UI_PADDING +#define ANNUNC_HEIGHT 8 + +#define LCD_X UI_PADDING +#define LCD_Y ( UI_PADDING + ANNUNC_HEIGHT + UI_PADDING ) + +#define UI_K_WIDTH_1 22 +#define UI_K_HEIGHT_1 ( UI_K_WIDTH_1 * 0.65 ) +#define UI_K_WIDTH_2 26 +#define UI_K_HEIGHT_2 ( UI_K_WIDTH_2 * 0.65 ) + +#define UI_KB_OFFSET_Y ( UI_PADDING + ANNUNC_HEIGHT + LCD_HEIGHT + UI_PADDING ) + +#define UI_K_WIDTH_enter ( UI_K_WIDTH_1 * 2 ) + +#define Y_LINE( i ) ( UI_KB_OFFSET_Y + ( i * UI_K_HEIGHT_2 ) ) +#define X_COL( i ) ( UI_PADDING + ( UI_K_WIDTH_1 * i ) ) +#define X2_COL( i ) ( UI_PADDING + ( UI_K_WIDTH_2 * i ) ) + +#define UI_KB_HEIGHT ( UI_SCALE * Y_LINE( 9 ) ) + +/* Button flags: + * Use BUTTON_B1RELEASE for normal buttons. + * Use BUTTON_B1RELEASE | BUTTON_B2TOGGLE for calculator buttons. + * Use BUTTON_B1TOGGLE for toggle buttons + */ +// Set if button is pushed +#define BUTTON_PUSHED 0x01 +// If set the button will be grayed out +#define BUTTON_DISABLED 0x02 +// Mouse button 1 toggles this button +#define BUTTON_B1TOGGLE 0x04 +// Mouse button 2 toggles this button +#define BUTTON_B2TOGGLE 0x08 +// Releaseing mouse button 1 anywhere unpushes the button +#define BUTTON_B1RELEASE 0x10 + +typedef struct { + int index; + int x, y; + int w, h; + int flags; + char* label; + char* label_Lshift; + char* label_Rshift; + char* label_letter; + char* label_below; + void ( *down )( void ); + void ( *up )( void ); +} Button; + +typedef struct { + SDL_Color faceplate; + + SDL_Color lcd_pixoff; + SDL_Color lcd_pixgray1; + SDL_Color lcd_pixgray2; + SDL_Color lcd_pixon; + + SDL_Color button_bg; + SDL_Color button_active; + SDL_Color button_inactive; + SDL_Color label; + SDL_Color Lshift; + SDL_Color Rshift; + SDL_Color letter; + SDL_Color below; +} colors_t; + +static TTF_Font* ttffont = NULL; +static TTF_Font* ttffont2 = NULL; bool SDL_ready = false; @@ -41,9 +114,9 @@ SDL_Texture* textures_labels_below[ 49 ]; SDL_Surface* surfaces_labels_letter[ 49 ]; SDL_Texture* textures_labels_letter[ 49 ]; -const int std_flags = BUTTON_B1RELEASE | BUTTON_B2TOGGLE; +static const int std_flags = BUTTON_B1RELEASE | BUTTON_B2TOGGLE; -Button gui_buttons[] = { +static Button gui_buttons[] = { {0, X_COL( 0 ), Y_LINE( 0 ), UI_K_WIDTH_1, UI_K_HEIGHT_1, std_flags, "", "", "", "A", "", press_A, release_A }, {1, X_COL( 1 ), Y_LINE( 0 ), UI_K_WIDTH_1, UI_K_HEIGHT_1, std_flags, "", "", "", "B", "", press_B, release_B }, {2, X_COL( 2 ), Y_LINE( 0 ), UI_K_WIDTH_1, UI_K_HEIGHT_1, std_flags, "", "", "", "C", "", press_C, release_C }, @@ -106,7 +179,7 @@ Button gui_buttons[] = { {49, X_COL( 0 ), Y_LINE( 9 ), 40, UI_K_HEIGHT_2, std_flags, "load file", "", "", "", "", press_LoadFile, release_LoadFile}, }; -colors_t colors = { +static colors_t colors = { .faceplate = {.r = 48, .g = 68, .b = 90, .a = 255}, .lcd_pixoff = {.r = 119, .g = 153, .b = 136, .a = 255}, diff --git a/src/gui.h b/src/gui.h index 10caff1..542adb1 100644 --- a/src/gui.h +++ b/src/gui.h @@ -1,93 +1,10 @@ #ifndef __GUI_H #define __GUI_H -#include - -#include "types.h" - -#define UI_SCALE 4 - -#define UI_PADDING 4 -#define UI_KEY_PADDING 4 - -#define ANNUNC_X UI_PADDING -#define ANNUNC_Y UI_PADDING -#define ANNUNC_HEIGHT 8 - -#define LCD_X UI_PADDING -#define LCD_Y ( UI_PADDING + ANNUNC_HEIGHT + UI_PADDING ) - -#define UI_K_WIDTH_1 22 -#define UI_K_HEIGHT_1 ( UI_K_WIDTH_1 * 0.65 ) -#define UI_K_WIDTH_2 26 -#define UI_K_HEIGHT_2 ( UI_K_WIDTH_2 * 0.65 ) - -#define UI_KB_OFFSET_Y ( UI_PADDING + ANNUNC_HEIGHT + LCD_HEIGHT + UI_PADDING ) - -#define UI_K_WIDTH_enter ( UI_K_WIDTH_1 * 2 ) - -#define Y_LINE( i ) ( UI_KB_OFFSET_Y + ( i * UI_K_HEIGHT_2 ) ) -#define X_COL( i ) ( UI_PADDING + ( UI_K_WIDTH_1 * i ) ) -#define X2_COL( i ) ( UI_PADDING + ( UI_K_WIDTH_2 * i ) ) - -#define UI_KB_HEIGHT ( UI_SCALE * Y_LINE( 9 ) ) - -typedef struct { - int index; - int x, y; - int w, h; - int flags; - char* label; - char* label_Lshift; - char* label_Rshift; - char* label_letter; - char* label_below; - void ( *down )( void ); - void ( *up )( void ); -} Button; - -typedef struct { - SDL_Color faceplate; - - SDL_Color lcd_pixoff; - SDL_Color lcd_pixgray1; - SDL_Color lcd_pixgray2; - SDL_Color lcd_pixon; - - SDL_Color button_bg; - SDL_Color button_active; - SDL_Color button_inactive; - SDL_Color label; - SDL_Color Lshift; - SDL_Color Rshift; - SDL_Color letter; - SDL_Color below; -} colors_t; -extern colors_t colors; - -extern SDL_Renderer* renderer; -extern SDL_Window* window; -extern SDL_Texture* texTarget; -extern SDL_Texture* tex2Target; +#include extern bool SDL_ready; -/* Button flags: - * Use BUTTON_B1RELEASE for normal buttons. - * Use BUTTON_B1RELEASE | BUTTON_B2TOGGLE for calculator buttons. - * Use BUTTON_B1TOGGLE for toggle buttons - */ -// Set if button is pushed -#define BUTTON_PUSHED 0x01 -// If set the button will be grayed out -#define BUTTON_DISABLED 0x02 -// Mouse button 1 toggles this button -#define BUTTON_B1TOGGLE 0x04 -// Mouse button 2 toggles this button -#define BUTTON_B2TOGGLE 0x08 -// Releaseing mouse button 1 anywhere unpushes the button -#define BUTTON_B1RELEASE 0x10 - extern void SDL__display_show( void ); extern bool gui_events(); diff --git a/src/keyboard.h b/src/keyboard.h index 07b5fba..43b58f5 100644 --- a/src/keyboard.h +++ b/src/keyboard.h @@ -1,7 +1,7 @@ #ifndef __KEYBOARD_H #define __KEYBOARD_H -#include "types.h" +#include extern bool kbd_on; diff --git a/src/types.h b/src/types.h index 02e75c8..5744d37 100644 --- a/src/types.h +++ b/src/types.h @@ -1,8 +1,6 @@ #ifndef __TYPES_H #define __TYPES_H -#include - #define MIN( a, b ) ( ( a ) < ( b ) ? ( a ) : ( b ) ) typedef unsigned char nibble;