eliminate pcalc_* functions; try to make UI scalable

This commit is contained in:
Gwenhael Le Moine 2024-04-12 19:03:56 +02:00
parent d12a20df29
commit d6c7d17271
No known key found for this signature in database
GPG key ID: FDFE3669426707A7
8 changed files with 275 additions and 309 deletions

View file

@ -16,7 +16,7 @@ dist/hpemu: src/bus.o \
src/keyboard.o \ src/keyboard.o \
src/main.o \ src/main.o \
src/opcodes.o \ src/opcodes.o \
src/pcalc.o \ src/gui_buttons.o \
src/pfiles.o \ src/pfiles.o \
src/ports.o \ src/ports.o \
src/ram.o \ src/ram.o \

View file

@ -5,10 +5,8 @@
#include "types.h" #include "types.h"
#include "bus.h" #include "bus.h"
#include "pcalc.h" #include "gui_buttons.h"
#include "display.h"
#define LCD_X 0 // 76
#define LCD_Y 0 // 110 //150
address menu_base; address menu_base;
address display_base; address display_base;
@ -18,11 +16,11 @@ byte display_height;
byte display_offset; byte display_offset;
bool display_enable; bool display_enable;
byte lcdScreen[ 131 * 64 ]; byte lcdScreen[ LCD_WIDTH * LCD_HEIGHT ];
byte prev_lcdScreen[ 131 * 64 ]; byte prev_lcdScreen[ LCD_WIDTH * LCD_HEIGHT ];
byte prev2_lcdScreen[ 131 * 64 ]; byte prev2_lcdScreen[ LCD_WIDTH * LCD_HEIGHT ];
// byte prev3_lcdScreen[131*64]; // byte prev3_lcdScreen[LCD_WIDTH*LCD_HEIGHT];
byte lcdScreenGS[ 131 * 64 ]; byte lcdScreenGS[ LCD_WIDTH * LCD_HEIGHT ];
static address cur_adr; static address cur_adr;
static bool in_menu; static bool in_menu;
@ -59,7 +57,7 @@ static address draw_lcd_line( address adr, int y )
bit = 4 - ( display_offset & 3 ); bit = 4 - ( display_offset & 3 );
} }
while ( x < 131 ) { while ( x < LCD_WIDTH ) {
if ( bit == 0 ) { if ( bit == 0 ) {
data = *ptr++; data = *ptr++;
bit = 4; bit = 4;
@ -69,14 +67,14 @@ static address draw_lcd_line( address adr, int y )
if ( pixel != '\0' ) if ( pixel != '\0' )
pixel = '\3'; pixel = '\3';
byte pixelGS = lcdScreenGS[ x + y * 131 ]; byte pixelGS = lcdScreenGS[ x + y * LCD_WIDTH ];
prev2_lcdScreen[ x + y * 131 ] = prev_lcdScreen[ x + y * 131 ]; prev2_lcdScreen[ x + y * LCD_WIDTH ] = prev_lcdScreen[ x + y * LCD_WIDTH ];
prev_lcdScreen[ x + y * 131 ] = lcdScreen[ x + y * 131 ]; prev_lcdScreen[ x + y * LCD_WIDTH ] = lcdScreen[ x + y * LCD_WIDTH ];
lcdScreen[ x + y * 131 ] = pixel; lcdScreen[ x + y * LCD_WIDTH ] = pixel;
byte prev_pixel = prev_lcdScreen[ x + y * 131 ]; byte prev_pixel = prev_lcdScreen[ x + y * LCD_WIDTH ];
byte prev2_pixel = prev2_lcdScreen[ x + y * 131 ]; byte prev2_pixel = prev2_lcdScreen[ x + y * LCD_WIDTH ];
if ( drawGS == true ) { if ( drawGS == true ) {
if ( prev2_pixel == '\0' && prev_pixel == '\0' && pixel == '\0' ) if ( prev2_pixel == '\0' && prev_pixel == '\0' && pixel == '\0' )
@ -103,7 +101,7 @@ static address draw_lcd_line( address adr, int y )
if ( prev2_pixel == '\3' && prev_pixel == '\3' && pixel == '\3' ) if ( prev2_pixel == '\3' && prev_pixel == '\3' && pixel == '\3' )
pixelGS = '\3'; pixelGS = '\3';
lcdScreenGS[ x + y * 131 ] = pixelGS; lcdScreenGS[ x + y * LCD_WIDTH ] = pixelGS;
} }
data >>= 1; data >>= 1;
@ -141,13 +139,13 @@ void display_show()
SDL_PixelFormat* pixelFormat = SDL_AllocFormat( format ); SDL_PixelFormat* pixelFormat = SDL_AllocFormat( format );
// do stuff // do stuff
for ( int y = 0; y < 64; y++ ) { for ( int y = 0; y < LCD_HEIGHT; y++ ) {
for ( int x = 0; x < 131; x++ ) { for ( int x = 0; x < LCD_WIDTH; x++ ) {
int R = 0; int R = 0;
int G = 0; int G = 0;
int B = 0; int B = 0;
byte hp48pixel = lcdScreenGS[ x + y * 131 ]; byte hp48pixel = lcdScreenGS[ x + y * LCD_WIDTH ];
if ( hp48pixel == '\0' ) { if ( hp48pixel == '\0' ) {
R = 119; R = 119;
@ -185,11 +183,11 @@ void display_show()
} }
// Show rendered to texture // Show rendered to texture
SDL_Rect r1 = { 0, 0, 131, 64 }; SDL_Rect r1 = { 0, 0, LCD_WIDTH, LCD_HEIGHT };
SDL_Rect r2 = { LCD_X, LCD_Y, 524, 256 }; SDL_Rect r2 = { LCD_X, LCD_Y, LCD_WIDTH * LCD_SCALE, LCD_HEIGHT * LCD_SCALE };
SDL_RenderCopyEx( renderer, texTarget, &r1, &r2, 0, NULL, SDL_FLIP_NONE ); SDL_RenderCopyEx( renderer, texTarget, &r1, &r2, 0, NULL, SDL_FLIP_NONE );
pcalc_show(); button_draw_all( calc_buttons );
SDL_RenderPresent( renderer ); SDL_RenderPresent( renderer );
} }
@ -220,7 +218,7 @@ void display_update( void )
display_line_count++; display_line_count++;
if ( display_line_count == 64 ) { if ( display_line_count == LCD_HEIGHT ) {
display_line_count = 0; display_line_count = 0;
in_menu = 0; in_menu = 0;
cur_adr = display_base; cur_adr = display_base;

View file

@ -6,7 +6,7 @@
#include <SDL2/SDL_ttf.h> #include <SDL2/SDL_ttf.h>
#include "color.h" #include "color.h"
#include "pcalc.h" #include "gui_buttons.h"
#include "pfiles.h" #include "pfiles.h"
#include "gui.h" #include "gui.h"
@ -85,12 +85,14 @@ void gui_initKeyboard( Button* calcbuttons )
SDL_Color couleurGreen = { 125, 215, 235, 255 }; SDL_Color couleurGreen = { 125, 215, 235, 255 };
SDL_Color couleurPurple = { 191, 192, 236, 255 }; SDL_Color couleurPurple = { 191, 192, 236, 255 };
SDL_Color couleurYellow = { 128, 108, 29, 255 }; SDL_Color couleurYellow = { 128, 108, 29, 255 };
SDL_Surface* s = NULL;
SDL_Texture* t = NULL;
int i = 0; int i = 0;
Button* buttons = calcbuttons; Button* buttons = calcbuttons;
while ( buttons->label ) { while ( buttons->label ) {
SDL_Surface* s = NULL; s = NULL;
SDL_Texture* t = NULL; t = NULL;
if ( buttons->label && strcmp( buttons->label, "" ) != 0 ) { if ( buttons->label && strcmp( buttons->label, "" ) != 0 ) {
s = TTF_RenderUTF8_Blended( ttffont, buttons->label, couleurBlanche ); s = TTF_RenderUTF8_Blended( ttffont, buttons->label, couleurBlanche );
if ( s ) { if ( s ) {
@ -108,8 +110,8 @@ void gui_initKeyboard( Button* calcbuttons )
i = 0; i = 0;
buttons = calcbuttons; buttons = calcbuttons;
while ( buttons->label_Lshift ) { while ( buttons->label_Lshift ) {
SDL_Surface* s = NULL; s = NULL;
SDL_Texture* t = NULL; t = NULL;
if ( buttons->label_Lshift && strcmp( buttons->label_Lshift, "" ) != 0 ) { if ( buttons->label_Lshift && strcmp( buttons->label_Lshift, "" ) != 0 ) {
s = TTF_RenderUTF8_Blended( ttffont2, buttons->label_Lshift, couleurPurple ); s = TTF_RenderUTF8_Blended( ttffont2, buttons->label_Lshift, couleurPurple );
if ( s ) { if ( s ) {
@ -125,8 +127,8 @@ void gui_initKeyboard( Button* calcbuttons )
i = 0; i = 0;
buttons = calcbuttons; buttons = calcbuttons;
while ( buttons->label_Rshift ) { while ( buttons->label_Rshift ) {
SDL_Surface* s = NULL; s = NULL;
SDL_Texture* t = NULL; t = NULL;
if ( buttons->label_Rshift && strcmp( buttons->label_Rshift, "" ) != 0 ) { if ( buttons->label_Rshift && strcmp( buttons->label_Rshift, "" ) != 0 ) {
s = TTF_RenderUTF8_Blended( ttffont2, buttons->label_Rshift, couleurGreen ); s = TTF_RenderUTF8_Blended( ttffont2, buttons->label_Rshift, couleurGreen );
if ( s ) { if ( s ) {
@ -142,8 +144,8 @@ void gui_initKeyboard( Button* calcbuttons )
i = 0; i = 0;
buttons = calcbuttons; buttons = calcbuttons;
while ( buttons->label_Rshift ) { while ( buttons->label_Rshift ) {
SDL_Surface* s = NULL; s = NULL;
SDL_Texture* t = NULL; t = NULL;
if ( buttons->label_below && strcmp( buttons->label_below, "" ) != 0 ) { if ( buttons->label_below && strcmp( buttons->label_below, "" ) != 0 ) {
s = TTF_RenderUTF8_Blended( ttffont2, buttons->label_below, couleurYellow ); s = TTF_RenderUTF8_Blended( ttffont2, buttons->label_below, couleurYellow );
if ( s ) { if ( s ) {
@ -159,12 +161,12 @@ void gui_initKeyboard( Button* calcbuttons )
static inline void button_draw( Button* b ) static inline void button_draw( Button* b )
{ {
SDL_Rect rectToDraw = { b->x * 2, b->y * 2, b->w * 2, b->h * 2 }; SDL_Rect rectToDraw = { b->x * KB_UI_SCALE, b->y * KB_UI_SCALE, b->w * KB_UI_SCALE, b->h * KB_UI_SCALE };
SDL_SetRenderDrawColor( renderer, 0x00, 0x00, 0x00, 0x33 ); SDL_SetRenderDrawColor( renderer, 0x00, 0x00, 0x00, 0x33 );
SDL_RenderFillRect( renderer, &rectToDraw ); SDL_RenderFillRect( renderer, &rectToDraw );
drawText( b->index, b->x * 2, 10 + b->y * 2, b->w * 2, b->h * 2 ); drawText( b->index, b->x * KB_UI_SCALE, 10 + b->y * KB_UI_SCALE, b->w * KB_UI_SCALE, b->h * KB_UI_SCALE );
if ( b->flags & BUTTON_PUSHED ) { if ( b->flags & BUTTON_PUSHED ) {
SDL_SetRenderDrawColor( renderer, 0xFF, 0x00, 0x00, 0xFF ); SDL_SetRenderDrawColor( renderer, 0xFF, 0x00, 0x00, 0xFF );
@ -187,7 +189,8 @@ void button_draw_all( Button* buttons )
static inline Button* find_button( Button* b, int x, int y ) static inline Button* find_button( Button* b, int x, int y )
{ {
while ( b->label ) { while ( b->label ) {
if ( x >= b->x * 2 && x < b->x * 2 + b->w * 2 && y >= b->y * 2 && y < b->y * 2 + b->h * 2 ) if ( x >= b->x * KB_UI_SCALE && x < b->x * KB_UI_SCALE + b->w * KB_UI_SCALE && y >= b->y * KB_UI_SCALE &&
y < b->y * KB_UI_SCALE + b->h * KB_UI_SCALE )
return b; return b;
b++; b++;

View file

@ -5,6 +5,42 @@
#include "types.h" #include "types.h"
#define UI_PADDING 16
#define ANNUNC_X UI_PADDING
#define ANNUNC_Y UI_PADDING
#define ANNUNC_HEIGHT 32
#define LCD_X UI_PADDING
#define LCD_Y UI_PADDING + ANNUNC_HEIGHT
#define LCD_WIDTH 131
#define LCD_HEIGHT 64
#define LCD_SCALE 4
#define KB_UI_SCALE 2
#define UI_K_WIDTH_1 ( ( LCD_WIDTH * KB_UI_SCALE ) / 8 )
#define UI_K_HEIGHT_1 18
#define UI_K_WIDTH_2 ( ( ( LCD_WIDTH * KB_UI_SCALE ) - UI_KB_GAP_X ) / 6 )
#define UI_K_HEIGHT_2 22
#define UI_KB_OFFSET_X 10
#define UI_KB_GAP_X ( UI_K_WIDTH_1 / 3 )
#define UI_KB_GAP_X2 ( UI_K_WIDTH_2 / 4 )
#define UI_KB_OFFSET_Y ( LCD_Y + ( LCD_HEIGHT * KB_UI_SCALE ) )
#define UI_KB_GAP_Y 14
#define UI_K_WIDTH_enter ( ( UI_K_WIDTH_1 * 2 ) + UI_KB_GAP_X )
#define Y_LINE( i ) ( UI_KB_OFFSET_Y + ( i * ( UI_KB_GAP_Y + 10 ) ) )
#define X_COL( i ) ( UI_KB_OFFSET_X + ( UI_K_WIDTH_1 * i ) + ( UI_KB_GAP_X * i ) )
#define XE_COL( i ) ( UI_K_WIDTH_enter - UI_K_WIDTH_1 + X_COL( i ) )
#define X2_COL( i ) ( UI_KB_OFFSET_X + ( UI_K_WIDTH_2 * i ) + ( UI_KB_GAP_X2 * ( i - 1 ) ) )
#define UI_KB_HEIGHT ( KB_UI_SCALE * ( Y_LINE( 9 ) + UI_K_HEIGHT_2 + UI_KB_GAP_Y ) )
#define UI_KB_WIDTH ( KB_UI_SCALE * ( ( X_COL( 5 ) + UI_K_WIDTH_1 + UI_KB_OFFSET_X ) ) )
typedef struct { typedef struct {
int index; int index;
int x, y; int x, y;
@ -23,11 +59,16 @@ typedef struct {
* Use BUTTON_B1RELEASE | BUTTON_B2TOGGLE for calculator buttons. * Use BUTTON_B1RELEASE | BUTTON_B2TOGGLE for calculator buttons.
* Use BUTTON_B1TOGGLE for toggle buttons * Use BUTTON_B1TOGGLE for toggle buttons
*/ */
#define BUTTON_PUSHED 0x01 // Set if button is pushed // Set if button is pushed
#define BUTTON_DISABLED 0x02 // If set the button will be grayed out #define BUTTON_PUSHED 0x01
#define BUTTON_B1TOGGLE 0x04 // Mouse button 1 toggles this button // If set the button will be grayed out
#define BUTTON_B2TOGGLE 0x08 // Mouse button 2 toggles this button #define BUTTON_DISABLED 0x02
#define BUTTON_B1RELEASE 0x10 // Releaseing mouse button 1 anywhere unpushes the button // 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 gui_initKeyboard( Button* calcbuttons ); extern void gui_initKeyboard( Button* calcbuttons );

175
src/gui_buttons.c Normal file
View file

@ -0,0 +1,175 @@
#include <stdlib.h>
#include "color.h"
#include "display.h"
#include "keyboard.h"
#include "gui.h"
#include "gui_buttons.h"
#include "pfiles.h"
const int std_flags = BUTTON_B1RELEASE | BUTTON_B2TOGGLE;
Button calc_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 },
{3, X_COL( 3 ), Y_LINE( 0 ), UI_K_WIDTH_1, UI_K_HEIGHT_1, std_flags, "", "", "", "D", press_D, release_D },
{4, X_COL( 4 ), Y_LINE( 0 ), UI_K_WIDTH_1, UI_K_HEIGHT_1, std_flags, "", "", "", "E", press_E, release_E },
{5, X_COL( 5 ), Y_LINE( 0 ), UI_K_WIDTH_1, UI_K_HEIGHT_1, std_flags, "", "", "", "F", press_F, release_F },
{6, X_COL( 0 ), Y_LINE( 1 ), UI_K_WIDTH_1, UI_K_HEIGHT_2, std_flags, "MTH", "RAD", "POLAR", "G", press_MTH, release_MTH },
{7, X_COL( 1 ), Y_LINE( 1 ), UI_K_WIDTH_1, UI_K_HEIGHT_2, std_flags, "PRG", "", "CHARS", "H", press_PRG, release_PRG },
{8, X_COL( 2 ), Y_LINE( 1 ), UI_K_WIDTH_1, UI_K_HEIGHT_2, std_flags, "CST", "", "MODES", "I", press_CST, release_CST },
{9, X_COL( 3 ), Y_LINE( 1 ), UI_K_WIDTH_1, UI_K_HEIGHT_2, std_flags, "VAR", "", "MEMORY", "J", press_VAR, release_VAR },
{10, X_COL( 4 ), Y_LINE( 1 ), UI_K_WIDTH_1, UI_K_HEIGHT_2, std_flags, "", "", "STACK", "K", press_UP, release_UP },
{11, X_COL( 5 ), Y_LINE( 1 ), UI_K_WIDTH_1, UI_K_HEIGHT_2, std_flags, "NXT", "PREV", "MENU", "L", press_NXT, release_NXT },
{12, X_COL( 0 ), Y_LINE( 2 ), UI_K_WIDTH_1, UI_K_HEIGHT_2, std_flags, "'", "UP", "HOME", "M", press_QUOTE, release_QUOTE },
{13, X_COL( 1 ), Y_LINE( 2 ), UI_K_WIDTH_1, UI_K_HEIGHT_2, std_flags, "STO", "REF", "RCL", "N", press_STO, release_STO },
{14, X_COL( 2 ), Y_LINE( 2 ), UI_K_WIDTH_1, UI_K_HEIGHT_2, std_flags, "EVAL", "->NUM", "UNDO", "O", press_EVAL, release_EVAL },
{15, X_COL( 3 ), Y_LINE( 2 ), UI_K_WIDTH_1, UI_K_HEIGHT_2, std_flags, "", "PICTURE", "", "P", press_LEFT, release_LEFT },
{16, X_COL( 4 ), Y_LINE( 2 ), UI_K_WIDTH_1, UI_K_HEIGHT_2, std_flags, "", "VIEW", "", "Q", press_DOWN, release_DOWN },
{17, X_COL( 5 ), Y_LINE( 2 ), UI_K_WIDTH_1, UI_K_HEIGHT_2, std_flags, "", "SWAP", "", "R", press_RIGHT, release_RIGHT },
{18, X_COL( 0 ), Y_LINE( 3 ), UI_K_WIDTH_1, UI_K_HEIGHT_2, std_flags, "SIN", "ASIN", "tet", "S", press_SIN, release_SIN },
{19, X_COL( 1 ), Y_LINE( 3 ), UI_K_WIDTH_1, UI_K_HEIGHT_2, std_flags, "COS", "ACOS", "", "T", press_COS, release_COS },
{20, X_COL( 2 ), Y_LINE( 3 ), UI_K_WIDTH_1, UI_K_HEIGHT_2, std_flags, "TAN", "ATAN", "Sig", "U", press_TAN, release_TAN },
{21, X_COL( 3 ), Y_LINE( 3 ), UI_K_WIDTH_1, UI_K_HEIGHT_2, std_flags, "√x", "xx", "x√y", "V", press_SQRT, release_SQRT },
{22, X_COL( 4 ), Y_LINE( 3 ), UI_K_WIDTH_1, UI_K_HEIGHT_2, std_flags, "y^x", "⏨x", "LOG", "W", press_POW, release_POW },
{23, X_COL( 5 ), Y_LINE( 3 ), UI_K_WIDTH_1, UI_K_HEIGHT_2, std_flags, "1/x", "ex", "LN", "X", press_INV, release_INV },
{24, X_COL( 0 ), Y_LINE( 4 ), UI_K_WIDTH_enter, UI_K_HEIGHT_2, std_flags, "ENTER", "EQUATION", "MATRIX", "", press_ENTER,
release_ENTER },
{25, XE_COL( 1 ), Y_LINE( 4 ), UI_K_WIDTH_1, UI_K_HEIGHT_2, std_flags, "±", "EDIT", "CMD", "Y", press_NEG, release_NEG },
{26, XE_COL( 2 ), Y_LINE( 4 ), UI_K_WIDTH_1, UI_K_HEIGHT_2, std_flags, "EEX", "PURG", "ARG", "Z", press_EEX, release_EEX },
{27, XE_COL( 3 ), Y_LINE( 4 ), UI_K_WIDTH_1, UI_K_HEIGHT_2, std_flags, "DEL", "CLEAR", "", "", press_DEL, release_DEL },
{28, XE_COL( 4 ), Y_LINE( 4 ), UI_K_WIDTH_1, UI_K_HEIGHT_2, std_flags, "", "DROP", "", "", press_BKSP, release_BKSP },
{29, X_COL( 0 ), Y_LINE( 5 ), UI_K_WIDTH_1, UI_K_HEIGHT_2, std_flags, "α", "USER", "ENTRY", "", press_ALPHA, release_ALPHA },
{30, X2_COL( 1 ), Y_LINE( 5 ), UI_K_WIDTH_2, UI_K_HEIGHT_2, std_flags, "7", "", "SOLVE", "", press_7, release_7 },
{31, X2_COL( 2 ), Y_LINE( 5 ), UI_K_WIDTH_2, UI_K_HEIGHT_2, std_flags, "8", "", "PLOT", "", press_8, release_8 },
{32, X2_COL( 3 ), Y_LINE( 5 ), UI_K_WIDTH_2, UI_K_HEIGHT_2, std_flags, "9", "", "SYMBOLIC", "", press_9, release_9 },
{33, X2_COL( 4 ) + 2, Y_LINE( 5 ), UI_K_WIDTH_2, UI_K_HEIGHT_2, std_flags, "÷", "( )", "#", "", press_DIV, release_DIV },
{34, X_COL( 0 ), Y_LINE( 6 ), UI_K_WIDTH_1, UI_K_HEIGHT_2, std_flags, "", "red", "", "", press_LSHIFT, release_LSHIFT },
{35, X2_COL( 1 ), Y_LINE( 6 ), UI_K_WIDTH_2, UI_K_HEIGHT_2, std_flags, "4", "", "TIME", "", press_4, release_4 },
{36, X2_COL( 2 ), Y_LINE( 6 ), UI_K_WIDTH_2, UI_K_HEIGHT_2, std_flags, "5", "", "STAT", "", press_5, release_5 },
{37, X2_COL( 3 ), Y_LINE( 6 ), UI_K_WIDTH_2, UI_K_HEIGHT_2, std_flags, "6", "", "UNITS", "", press_6, release_6 },
{38, X2_COL( 4 ) + 2, Y_LINE( 6 ), UI_K_WIDTH_2, UI_K_HEIGHT_2, std_flags, "×", "[ ]", "_", "", press_MULT, release_MULT },
{39, X_COL( 0 ), Y_LINE( 7 ), UI_K_WIDTH_1, UI_K_HEIGHT_2, std_flags, "", "", "green", "", press_RSHIFT, release_RSHIFT },
{40, X2_COL( 1 ), Y_LINE( 7 ), UI_K_WIDTH_2, UI_K_HEIGHT_2, std_flags, "1", "", "I/O", "", press_1, release_1 },
{41, X2_COL( 2 ), Y_LINE( 7 ), UI_K_WIDTH_2, UI_K_HEIGHT_2, std_flags, "2", "", "LIBRARY", "", press_2, release_2 },
{42, X2_COL( 3 ), Y_LINE( 7 ), UI_K_WIDTH_2, UI_K_HEIGHT_2, std_flags, "3", "", "EQ LIB", "", press_3, release_3 },
{43, X2_COL( 4 ) + 2, Y_LINE( 7 ), UI_K_WIDTH_2, UI_K_HEIGHT_2, std_flags, "-", "« »", "\" \"", "", press_MINUS, release_MINUS },
{44, X_COL( 0 ), Y_LINE( 8 ), UI_K_WIDTH_1, UI_K_HEIGHT_2, std_flags, "ON", "CONT", "OFF", "CANCEL", press_ON, release_ON },
{45, X2_COL( 1 ), Y_LINE( 8 ), UI_K_WIDTH_2, UI_K_HEIGHT_2, std_flags, "0", "=", "->", "", press_0, release_0 },
{46, X2_COL( 2 ), Y_LINE( 8 ), UI_K_WIDTH_2, UI_K_HEIGHT_2, std_flags, ".", ",", "back", "", press_PERIOD, release_PERIOD },
{47, X2_COL( 3 ), Y_LINE( 8 ), UI_K_WIDTH_2, UI_K_HEIGHT_2, std_flags, "SPC", "pi", "rad", "", press_SPC, release_SPC },
{48, X2_COL( 4 ) + 2, Y_LINE( 8 ), UI_K_WIDTH_2, UI_K_HEIGHT_2, std_flags, "+", "{}", ": :", "", press_PLUS, release_PLUS },
{49, X_COL( 0 ), Y_LINE( 9 ), 130, 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( "zeldahp.dir" ); }

View file

@ -1,8 +1,12 @@
#ifndef __PCALC_H #ifndef __GUI_BUTTONS_H
#define __PCALC_H #define __GUI_BUTTONS_H
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include "gui.h"
extern Button calc_buttons[];
extern void press_PLUS( void ); extern void press_PLUS( void );
extern void release_PLUS( void ); extern void release_PLUS( void );
extern void press_SPC( void ); extern void press_SPC( void );
@ -101,14 +105,7 @@ extern void press_B( void );
extern void release_B( void ); extern void release_B( void );
extern void press_ON( void ); extern void press_ON( void );
extern void release_ON( void ); extern void release_ON( void );
extern void press_Zelda( void ); extern void press_LoadFile( void );
extern void release_Zelda( void ); extern void release_LoadFile( void );
extern void pcalc_init();
extern void pcalc_show();
extern void pcalc_down( int mx, int my, int mb );
extern void pcalc_up( int mx, int my, int mb );
extern void pcalc_kb_down( SDL_Keycode sdl_event );
extern void pcalc_kb_up( SDL_Keycode sdl_event );
#endif #endif

View file

@ -13,12 +13,9 @@
#include "gui.h" #include "gui.h"
#include "timers.h" #include "timers.h"
#include "keyboard.h" #include "keyboard.h"
#include "pcalc.h" #include "gui_buttons.h"
#include "pfiles.h" #include "pfiles.h"
const int SCREEN_WIDTH = 524;
const int SCREEN_HEIGHT = 750;
SDL_Window* window = NULL; SDL_Window* window = NULL;
SDL_Renderer* renderer = NULL; SDL_Renderer* renderer = NULL;
SDL_Texture* texTarget = NULL; SDL_Texture* texTarget = NULL;
@ -74,7 +71,10 @@ static void program_init( void )
ttffont = TTF_OpenFont( FONT_FILENAME, 16 ); ttffont = TTF_OpenFont( FONT_FILENAME, 16 );
ttffont2 = TTF_OpenFont( FONT_FILENAME, 12 ); ttffont2 = TTF_OpenFont( FONT_FILENAME, 12 );
window = SDL_CreateWindow( "hpemu", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN ); int window_width = LCD_WIDTH * LCD_SCALE + 2 * UI_PADDING;
int window_height = ( UI_KB_OFFSET_Y + UI_KB_HEIGHT ) + 2 * UI_PADDING;
window = SDL_CreateWindow( "hpemu", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, window_width, window_height, SDL_WINDOW_SHOWN );
if ( window == NULL ) { if ( window == NULL ) {
printf( "Window could not be created! SDL_Error: %s\n", SDL_GetError() ); printf( "Window could not be created! SDL_Error: %s\n", SDL_GetError() );
return; return;
@ -91,7 +91,7 @@ static void program_init( void )
SDL_UpdateWindowSurface( window ); SDL_UpdateWindowSurface( window );
pcalc_init(); gui_initKeyboard( calc_buttons );
printf( "init done\n" ); printf( "init done\n" );
@ -118,11 +118,11 @@ bool refreshSDL()
while ( SDL_PollEvent( &event ) ) { while ( SDL_PollEvent( &event ) ) {
switch ( event.type ) { switch ( event.type ) {
case SDL_MOUSEBUTTONUP: case SDL_MOUSEBUTTONUP:
pcalc_up( event.button.x, event.button.y, 1 ); button_mouse_up( calc_buttons, event.button.x, event.button.y, 1 );
break; break;
case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONDOWN:
pcalc_down( event.button.x, event.button.y, 1 ); button_mouse_down( calc_buttons, event.button.x, event.button.y, 1 );
break; break;
case SDL_KEYDOWN: case SDL_KEYDOWN:

View file

@ -1,248 +0,0 @@
#include <stdlib.h>
#include "color.h"
#include "display.h"
#include "keyboard.h"
#include "gui.h"
#include "pcalc.h"
#include "pfiles.h"
const int pox = 2;
const int poy = 55;
const int pow1 = 40;
const int poh1 = 18;
const int poh2 = 22;
const int pow2 = 48;
const int ystart = 80;
const int yspacing = 14;
const int xstart = 5;
const int xspacing = ( pow1 + 2 );
const int xspacing2 = ( pow2 + 2 );
const int enter_w = pow1 * 2 + 2;
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_Zelda( void ) {}
void release_Zelda( void ) { load_file( "zeldahp.dir" ); }
static Button calc_buttons[] = {
{0, pox + xstart + ( xspacing * 0 ), ystart + ( 0 * yspacing ) + poy, pow1, poh1, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "", "", "A",
press_A, release_A },
{1, pox + xstart + ( xspacing * 1 ), ystart + ( 0 * yspacing ) + poy, pow1, poh1, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "", "", "B",
press_B, release_B },
{2, pox + xstart + ( xspacing * 2 ), ystart + ( 0 * yspacing ) + poy, pow1, poh1, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "", "", "C",
press_C, release_C },
{3, pox + xstart + ( xspacing * 3 ), ystart + ( 0 * yspacing ) + poy, pow1, poh1, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "", "", "D",
press_D, release_D },
{4, pox + xstart + ( xspacing * 4 ), ystart + ( 0 * yspacing ) + poy, pow1, poh1, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "", "", "E",
press_E, release_E },
{5, pox + xstart + ( xspacing * 5 ), ystart + ( 0 * yspacing ) + poy, pow1, poh1, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "", "", "F",
press_F, release_F },
{6, pox + xstart + ( xspacing * 0 ), ystart + ( 1 * yspacing ) + poy + 10, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "MTH",
"RAD", "POLAR", "G", press_MTH, release_MTH },
{7, pox + xstart + ( xspacing * 1 ), ystart + ( 1 * yspacing ) + poy + 10, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "PRG", "",
"CHARS", "H", press_PRG, release_PRG },
{8, pox + xstart + ( xspacing * 2 ), ystart + ( 1 * yspacing ) + poy + 10, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "CST", "",
"MODES", "I", press_CST, release_CST },
{9, pox + xstart + ( xspacing * 3 ), ystart + ( 1 * yspacing ) + poy + 10, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "VAR", "",
"MEMORY", "J", press_VAR, release_VAR },
{10, pox + xstart + ( xspacing * 4 ), ystart + ( 1 * yspacing ) + poy + 10, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "",
"STACK", "K", press_UP, release_UP },
{11, pox + xstart + ( xspacing * 5 ), ystart + ( 1 * yspacing ) + poy + 10, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "NXT",
"PREV", "MENU", "L", press_NXT, release_NXT },
{12, pox + xstart + ( xspacing * 0 ), ystart + ( 2 * yspacing ) + poy + 20, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "'", "UP",
"HOME", "M", press_QUOTE, release_QUOTE },
{13, pox + xstart + ( xspacing * 1 ), ystart + ( 2 * yspacing ) + poy + 20, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "STO",
"REF", "RCL", "N", press_STO, release_STO },
{14, pox + xstart + ( xspacing * 2 ), ystart + ( 2 * yspacing ) + poy + 20, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "EVAL",
"->NUM", "UNDO", "O", press_EVAL, release_EVAL },
{15, pox + xstart + ( xspacing * 3 ), ystart + ( 2 * yspacing ) + poy + 20, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "",
"PICTURE", "", "P", press_LEFT, release_LEFT },
{16, pox + xstart + ( xspacing * 4 ), ystart + ( 2 * yspacing ) + poy + 20, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "",
"VIEW", "", "Q", press_DOWN, release_DOWN },
{17, pox + xstart + ( xspacing * 5 ), ystart + ( 2 * yspacing ) + poy + 20, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "",
"SWAP", "", "R", press_RIGHT, release_RIGHT },
{18, pox + xstart + ( xspacing * 0 ), ystart + ( 3 * yspacing ) + poy + 30, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "SIN",
"ASIN", "tet", "S", press_SIN, release_SIN },
{19, pox + xstart + ( xspacing * 1 ), ystart + ( 3 * yspacing ) + poy + 30, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "COS",
"ACOS", "", "T", press_COS, release_COS },
{20, pox + xstart + ( xspacing * 2 ), ystart + ( 3 * yspacing ) + poy + 30, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "TAN",
"ATAN", "Sig", "U", press_TAN, release_TAN },
{21, pox + xstart + ( xspacing * 3 ), ystart + ( 3 * yspacing ) + poy + 30, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "√x", "xx",
"x√y", "V", press_SQRT, release_SQRT },
{22, pox + xstart + ( xspacing * 4 ), ystart + ( 3 * yspacing ) + poy + 30, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "y^x",
"⏨x", "LOG", "W", press_POW, release_POW },
{23, pox + xstart + ( xspacing * 5 ), ystart + ( 3 * yspacing ) + poy + 30, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "1/x",
"ex", "LN", "X", press_INV, release_INV },
{24, pox + xstart + ( xspacing * 0 ), ystart + ( 4 * yspacing ) + poy + 40, enter_w, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "ENTER",
"EQUATION", "MATRIX", "", press_ENTER, release_ENTER },
{25, enter_w - pow1 + pox + xstart + ( xspacing * 1 ), ystart + ( 4 * yspacing ) + poy + 40, pow1, poh2,
BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "±", "EDIT", "CMD", "Y", press_NEG, release_NEG },
{26, enter_w - pow1 + pox + xstart + ( xspacing * 2 ), ystart + ( 4 * yspacing ) + poy + 40, pow1, poh2,
BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "EEX", "PURG", "ARG", "Z", press_EEX, release_EEX },
{27, enter_w - pow1 + pox + xstart + ( xspacing * 3 ), ystart + ( 4 * yspacing ) + poy + 40, pow1, poh2,
BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "DEL", "CLEAR", "", "", press_DEL, release_DEL },
{28, enter_w - pow1 + pox + xstart + ( xspacing * 4 ), ystart + ( 4 * yspacing ) + poy + 40, pow1, poh2,
BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "DROP", "", "", press_BKSP, release_BKSP },
{29, pox + xstart + ( xspacing * 0 ), ystart + ( 5 * yspacing ) + poy + 50, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "α",
"USER", "ENTRY", "", press_ALPHA, release_ALPHA },
{30, pox + xstart + ( xspacing2 * 1 ), ystart + ( 5 * yspacing ) + poy + 50, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "7", "",
"SOLVE", "", press_7, release_7 },
{31, pox + xstart + ( xspacing2 * 2 ), ystart + ( 5 * yspacing ) + poy + 50, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "8", "",
"PLOT", "", press_8, release_8 },
{32, pox + xstart + ( xspacing2 * 3 ), ystart + ( 5 * yspacing ) + poy + 50, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "9", "",
"SYMBOLIC", "", press_9, release_9 },
{33, pox + xstart + ( xspacing2 * 4 ), ystart + ( 5 * yspacing ) + poy + 50, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "÷",
"( )", "#", "", press_DIV, release_DIV },
{34, pox + xstart + ( xspacing * 0 ), ystart + ( 6 * yspacing ) + poy + 60, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "red",
"", "", press_LSHIFT, release_LSHIFT},
{35, pox + xstart + ( xspacing2 * 1 ), ystart + ( 6 * yspacing ) + poy + 60, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "4", "",
"TIME", "", press_4, release_4 },
{36, pox + xstart + ( xspacing2 * 2 ), ystart + ( 6 * yspacing ) + poy + 60, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "5", "",
"STAT", "", press_5, release_5 },
{37, pox + xstart + ( xspacing2 * 3 ), ystart + ( 6 * yspacing ) + poy + 60, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "6", "",
"UNITS", "", press_6, release_6 },
{38, pox + xstart + ( xspacing2 * 4 ), ystart + ( 6 * yspacing ) + poy + 60, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "×",
"[ ]", "_", "", press_MULT, release_MULT },
{39, pox + xstart + ( xspacing * 0 ), ystart + ( 7 * yspacing ) + poy + 70, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "",
"green", "", press_RSHIFT, release_RSHIFT},
{40, pox + xstart + ( xspacing2 * 1 ), ystart + ( 7 * yspacing ) + poy + 70, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "1", "",
"I/O", "", press_1, release_1 },
{41, pox + xstart + ( xspacing2 * 2 ), ystart + ( 7 * yspacing ) + poy + 70, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "2", "",
"LIBRARY", "", press_2, release_2 },
{42, pox + xstart + ( xspacing2 * 3 ), ystart + ( 7 * yspacing ) + poy + 70, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "3", "",
"EQ LIB", "", press_3, release_3 },
{43, pox + xstart + ( xspacing2 * 4 ), ystart + ( 7 * yspacing ) + poy + 70, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "-",
"<< >>", "\" \"", "", press_MINUS, release_MINUS },
{44, pox + xstart + ( xspacing * 0 ), ystart + ( 8 * yspacing ) + poy + 80, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "ON",
"CONT", "OFF", "CANCEL", press_ON, release_ON },
{45, pox + xstart + ( xspacing2 * 1 ), ystart + ( 8 * yspacing ) + poy + 80, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "0", "=",
"->", "", press_0, release_0 },
{46, pox + xstart + ( xspacing2 * 2 ), ystart + ( 8 * yspacing ) + poy + 80, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, ".", ",",
"back", "", press_PERIOD, release_PERIOD},
{47, pox + xstart + ( xspacing2 * 3 ), ystart + ( 8 * yspacing ) + poy + 80, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "SPC",
"pi", "rad", "", press_SPC, release_SPC },
{48, pox + xstart + ( xspacing2 * 4 ), ystart + ( 8 * yspacing ) + poy + 80, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "+", "{}",
": :", "", press_PLUS, release_PLUS },
{49, pox + xstart, ystart + ( 9 * yspacing ) + poy + 90, 130, 20, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "Game", "", "", "", press_Zelda,
release_Zelda },
{50, pox + xstart, poy, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL }
};
void pcalc_init() { gui_initKeyboard( calc_buttons ); }
void pcalc_show()
{
// clear_to_color(calc_bmp, color[C_PANEL_BACK]);
button_draw_all( calc_buttons );
}
void pcalc_down( int mx, int my, int mb ) { button_mouse_down( calc_buttons, mx, my, mb ); }
void pcalc_up( int mx, int my, int mb ) { button_mouse_up( calc_buttons, mx, my, mb ); }