back to ( void ), I have seen the errors in my ways
https://stackoverflow.com/questions/29326149/is-it-mandatory-to-use-return-and-void-in-the-functions-in-c
This commit is contained in:
parent
bf9af92b91
commit
5f18956212
15 changed files with 112 additions and 378 deletions
|
@ -22,7 +22,7 @@ int first_press = 1; // PATCH
|
|||
int conf_bank1 = 0x00000;
|
||||
int conf_bank2 = 0x00000;
|
||||
|
||||
void do_in() {
|
||||
void do_in( void ) {
|
||||
int i, in, out;
|
||||
|
||||
out = 0;
|
||||
|
@ -99,7 +99,7 @@ void swap_register_status( unsigned char* r ) {
|
|||
}
|
||||
}
|
||||
|
||||
void clear_status() {
|
||||
void clear_status( void ) {
|
||||
int i;
|
||||
|
||||
for ( i = 0; i < 12; i++ ) {
|
||||
|
@ -130,7 +130,7 @@ int get_register_bit( unsigned char* reg, int n ) {
|
|||
short conf_tab_sx[] = { 1, 2, 2, 2, 2, 0 };
|
||||
short conf_tab_gx[] = { 1, 2, 2, 2, 2, 0 };
|
||||
|
||||
void do_reset() {
|
||||
void do_reset( void ) {
|
||||
int i;
|
||||
|
||||
for ( i = 0; i < 6; i++ ) {
|
||||
|
@ -143,11 +143,11 @@ void do_reset() {
|
|||
}
|
||||
}
|
||||
|
||||
void do_inton() { saturn.kbd_ien = 1; }
|
||||
void do_inton( void ) { saturn.kbd_ien = 1; }
|
||||
|
||||
void do_intoff() { saturn.kbd_ien = 0; }
|
||||
void do_intoff( void ) { saturn.kbd_ien = 0; }
|
||||
|
||||
void do_return_interupt() {
|
||||
void do_return_interupt( void ) {
|
||||
if ( saturn.int_pending ) {
|
||||
saturn.int_pending = 0;
|
||||
saturn.intenable = 0;
|
||||
|
@ -163,7 +163,7 @@ void do_return_interupt() {
|
|||
}
|
||||
}
|
||||
|
||||
void do_interupt() {
|
||||
void do_interupt( void ) {
|
||||
interrupt_called = 1;
|
||||
if ( saturn.intenable ) {
|
||||
push_return_addr( saturn.PC );
|
||||
|
@ -172,7 +172,7 @@ void do_interupt() {
|
|||
}
|
||||
}
|
||||
|
||||
void do_kbd_int() {
|
||||
void do_kbd_int( void ) {
|
||||
interrupt_called = 1;
|
||||
if ( saturn.intenable ) {
|
||||
push_return_addr( saturn.PC );
|
||||
|
@ -183,7 +183,7 @@ void do_kbd_int() {
|
|||
}
|
||||
}
|
||||
|
||||
void do_reset_interrupt_system() {
|
||||
void do_reset_interrupt_system( void ) {
|
||||
int i, gen_intr;
|
||||
|
||||
saturn.kbd_ien = 1;
|
||||
|
@ -199,7 +199,7 @@ void do_reset_interrupt_system() {
|
|||
}
|
||||
}
|
||||
|
||||
void do_unconfigure() {
|
||||
void do_unconfigure( void ) {
|
||||
int i;
|
||||
unsigned int conf;
|
||||
|
||||
|
@ -222,7 +222,7 @@ void do_unconfigure() {
|
|||
}
|
||||
}
|
||||
|
||||
void do_configure() {
|
||||
void do_configure( void ) {
|
||||
int i;
|
||||
unsigned long conf;
|
||||
|
||||
|
@ -242,7 +242,7 @@ void do_configure() {
|
|||
}
|
||||
}
|
||||
|
||||
int get_identification() {
|
||||
int get_identification( void ) {
|
||||
int i;
|
||||
static int chip_id[] = { 0, 0, 0, 0, 0x05, 0xf6,
|
||||
0x07, 0xf8, 0x01, 0xf2, 0, 0 };
|
||||
|
@ -264,7 +264,7 @@ int get_identification() {
|
|||
return 0;
|
||||
}
|
||||
|
||||
void do_shutdown() {
|
||||
void do_shutdown( void ) {
|
||||
int wake, alarms;
|
||||
t1_t2_ticks ticks;
|
||||
|
||||
|
@ -412,7 +412,7 @@ void push_return_addr( long addr ) {
|
|||
saturn.rstk[ saturn.rstkp ] = addr;
|
||||
}
|
||||
|
||||
long pop_return_addr() {
|
||||
long pop_return_addr( void ) {
|
||||
if ( saturn.rstkp < 0 )
|
||||
return 0;
|
||||
return saturn.rstk[ saturn.rstkp-- ];
|
||||
|
|
|
@ -145,7 +145,7 @@ cmd_tbl[] = {
|
|||
|
||||
{ 0, 0, 0 } };
|
||||
|
||||
void init_debugger() {
|
||||
void init_debugger( void ) {
|
||||
int i;
|
||||
|
||||
num_bkpts = 0;
|
||||
|
@ -620,7 +620,7 @@ static void set_st( word_64 val ) {
|
|||
#endif
|
||||
}
|
||||
|
||||
static void dump_st() {
|
||||
static void dump_st( void ) {
|
||||
int i;
|
||||
int val;
|
||||
|
||||
|
@ -670,7 +670,7 @@ static void set_hst( word_64 val ) {
|
|||
#endif
|
||||
}
|
||||
|
||||
static void dump_hst() {
|
||||
static void dump_hst( void ) {
|
||||
short hst = 0;
|
||||
if ( saturn.XM != 0 )
|
||||
hst |= 1;
|
||||
|
@ -923,7 +923,7 @@ struct se {
|
|||
struct se* se_next;
|
||||
};
|
||||
|
||||
char* get_stack() {
|
||||
char* get_stack( void ) {
|
||||
word_20 dsktop, dskbot;
|
||||
word_20 sp = 0, end = 0, ent = 0;
|
||||
word_20 ram_base, ram_mask;
|
||||
|
@ -1135,7 +1135,7 @@ static void do_rstk( int argc, char** argv ) {
|
|||
}
|
||||
}
|
||||
|
||||
int debug() {
|
||||
int debug( void ) {
|
||||
t1_t2_ticks ticks;
|
||||
struct cmd* cmdp;
|
||||
char* cp;
|
||||
|
@ -1322,7 +1322,7 @@ int debug() {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int emulate_debug() {
|
||||
int emulate_debug( void ) {
|
||||
do {
|
||||
|
||||
step_instruction();
|
||||
|
|
|
@ -12,7 +12,7 @@ extern int device_check;
|
|||
|
||||
device_t device;
|
||||
|
||||
void check_devices() {
|
||||
void check_devices( void ) {
|
||||
if ( device.display_touched > 0 && device.display_touched-- == 1 ) {
|
||||
device.display_touched = 0;
|
||||
update_display();
|
||||
|
|
|
@ -64,7 +64,7 @@ word_64 run;
|
|||
static word_20 jumpmasks[] = { 0xffffffff, 0xfffffff0, 0xffffff00, 0xfffff000,
|
||||
0xffff0000, 0xfff00000, 0xff000000, 0xf0000000 };
|
||||
|
||||
int decode_group_80() {
|
||||
int decode_group_80( void ) {
|
||||
int t, op3, op4, op5, op6;
|
||||
unsigned char* REG;
|
||||
long addr;
|
||||
|
@ -233,7 +233,7 @@ int decode_group_80() {
|
|||
}
|
||||
}
|
||||
|
||||
int decode_group_1() {
|
||||
int decode_group_1( void ) {
|
||||
int op, op2, op3, op4;
|
||||
|
||||
op2 = read_nibble( saturn.PC + 1 );
|
||||
|
@ -1987,7 +1987,7 @@ static inline int decode_8_thru_f( int op1 ) {
|
|||
}
|
||||
}
|
||||
|
||||
inline int step_instruction() {
|
||||
inline int step_instruction( void ) {
|
||||
int op0, op1, op2, op3;
|
||||
int stop = 0;
|
||||
|
||||
|
@ -2230,7 +2230,7 @@ inline int step_instruction() {
|
|||
return stop;
|
||||
}
|
||||
|
||||
inline void schedule() {
|
||||
inline void schedule( void ) {
|
||||
t1_t2_ticks ticks;
|
||||
unsigned long steps;
|
||||
static unsigned long old_stat_instr;
|
||||
|
@ -2392,7 +2392,7 @@ inline void schedule() {
|
|||
}
|
||||
}
|
||||
|
||||
int emulate() {
|
||||
int emulate( void ) {
|
||||
struct timeval tv;
|
||||
#if defined( GUI_IS_X11 )
|
||||
struct timeval tv2;
|
||||
|
|
|
@ -11,7 +11,7 @@ char fixbuf[ 1024 ] = {
|
|||
0,
|
||||
};
|
||||
|
||||
void fatal_exit() {
|
||||
void fatal_exit( void ) {
|
||||
if ( quiet )
|
||||
exit( 1 );
|
||||
|
||||
|
|
14
src/init.c
14
src/init.c
|
@ -166,7 +166,7 @@ saturn_0_3_0_t saturn_0_3_0;
|
|||
|
||||
#include "config.h"
|
||||
|
||||
void saturn_config_init() {
|
||||
void saturn_config_init( void ) {
|
||||
saturn.version[ 0 ] = VERSION_MAJOR;
|
||||
saturn.version[ 1 ] = VERSION_MINOR;
|
||||
saturn.version[ 2 ] = PATCHLEVEL;
|
||||
|
@ -181,7 +181,7 @@ void saturn_config_init() {
|
|||
saturn.lbr = 0x0;
|
||||
}
|
||||
|
||||
void init_saturn() {
|
||||
void init_saturn( void ) {
|
||||
int i;
|
||||
|
||||
memset( &saturn, 0, sizeof( saturn ) - 4 * sizeof( unsigned char* ) );
|
||||
|
@ -1023,7 +1023,7 @@ void get_home_directory( char* path ) {
|
|||
}
|
||||
}
|
||||
|
||||
int read_files() {
|
||||
int read_files( void ) {
|
||||
char path[ 1024 ];
|
||||
char fnam[ 1024 ];
|
||||
unsigned long v1, v2;
|
||||
|
@ -1379,7 +1379,7 @@ int write_mem_file( char* name, word_4* mem, int size ) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int write_files() {
|
||||
int write_files( void ) {
|
||||
char path[ 1024 ];
|
||||
char fnam[ 1024 ];
|
||||
struct stat st;
|
||||
|
@ -1558,7 +1558,7 @@ int write_files() {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int init_emulator() {
|
||||
int init_emulator( void ) {
|
||||
if ( !initialize )
|
||||
if ( read_files() ) {
|
||||
if ( resetOnStartup )
|
||||
|
@ -1573,7 +1573,7 @@ int init_emulator() {
|
|||
return 0;
|
||||
}
|
||||
|
||||
void init_active_stuff() {
|
||||
void init_active_stuff( void ) {
|
||||
serial_init();
|
||||
#if defined( GUI_IS_X11 )
|
||||
init_annunc();
|
||||
|
@ -1581,7 +1581,7 @@ void init_active_stuff() {
|
|||
init_display();
|
||||
}
|
||||
|
||||
int exit_emulator() {
|
||||
int exit_emulator( void ) {
|
||||
write_files();
|
||||
return 1;
|
||||
}
|
||||
|
|
14
src/lcd.c
14
src/lcd.c
|
@ -51,7 +51,7 @@ unsigned char nibbles[ 16 ][ 2 ] = {
|
|||
|
||||
static unsigned char nibble_bits[ 16 ];
|
||||
|
||||
void init_nibble_maps() {
|
||||
void init_nibble_maps( void ) {
|
||||
int i;
|
||||
|
||||
for ( i = 0; i < 16; i++ ) {
|
||||
|
@ -111,7 +111,7 @@ ann_struct_t ann_tbl[] = {
|
|||
{ 0 } };
|
||||
#endif
|
||||
|
||||
void init_display() {
|
||||
void init_display( void ) {
|
||||
display.on = ( int )( saturn.disp_io & 0x8 ) >> 3;
|
||||
|
||||
display.disp_start = ( saturn.disp_addr & 0xffffe );
|
||||
|
@ -201,7 +201,7 @@ static inline void draw_row( long addr, int row ) {
|
|||
}
|
||||
}
|
||||
|
||||
void update_display() {
|
||||
void update_display( void ) {
|
||||
int i, j;
|
||||
long addr;
|
||||
static int old_offset = -1;
|
||||
|
@ -333,7 +333,7 @@ void update_display() {
|
|||
}
|
||||
}
|
||||
|
||||
void redraw_display() {
|
||||
void redraw_display( void ) {
|
||||
#if defined( GUI_IS_X11 )
|
||||
XClearWindow( dpy, disp.win );
|
||||
#endif
|
||||
|
@ -465,7 +465,7 @@ struct ann_struct {
|
|||
{ 0 } };
|
||||
#endif
|
||||
|
||||
void draw_annunc() {
|
||||
void draw_annunc( void ) {
|
||||
int val;
|
||||
int i;
|
||||
|
||||
|
@ -501,7 +501,7 @@ void draw_annunc() {
|
|||
}
|
||||
|
||||
#if defined( GUI_IS_X11 )
|
||||
void init_annunc() {
|
||||
void init_annunc( void ) {
|
||||
int i;
|
||||
|
||||
for ( i = 0; ann_tbl[ i ].bit; i++ ) {
|
||||
|
@ -512,7 +512,7 @@ void init_annunc() {
|
|||
}
|
||||
#endif
|
||||
|
||||
void redraw_annunc() {
|
||||
void redraw_annunc( void ) {
|
||||
last_annunc_state = -1;
|
||||
draw_annunc();
|
||||
}
|
||||
|
|
|
@ -1154,7 +1154,7 @@ void write_nibbles( long addr, long val, int len ) {
|
|||
}
|
||||
}
|
||||
|
||||
void dev_memory_init() {
|
||||
void dev_memory_init( void ) {
|
||||
if ( opt_gx ) {
|
||||
read_nibble = read_nibble_gx;
|
||||
read_nibble_crc = read_nibble_crc_gx;
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include "constants.h"
|
||||
#include "resources.h"
|
||||
|
||||
void usage() {
|
||||
void usage( void ) {
|
||||
fprintf( stdout, "\n\
|
||||
%s Version %d.%d.%d\n\
|
||||
\n\
|
||||
|
@ -55,13 +55,13 @@ where options include:\n\
|
|||
exit( 1 );
|
||||
}
|
||||
|
||||
void show_version() {
|
||||
void show_version( void ) {
|
||||
fprintf( stdout, "\n\
|
||||
%s Version %d.%d.%d",
|
||||
progname, VERSION_MAJOR, VERSION_MINOR, PATCHLEVEL );
|
||||
}
|
||||
|
||||
void show_copyright() {
|
||||
void show_copyright( void ) {
|
||||
fprintf( stdout, "\n\
|
||||
COPYRIGHT\n\
|
||||
\n\
|
||||
|
@ -82,7 +82,7 @@ along with this program; if not, write to the Free Software\n\
|
|||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n\n" );
|
||||
}
|
||||
|
||||
void show_warranty() {
|
||||
void show_warranty( void ) {
|
||||
fprintf( stdout, "\n\
|
||||
NO WARRANTY\n\
|
||||
\n\
|
||||
|
|
|
@ -5,20 +5,10 @@
|
|||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#if defined( GUI_IS_X11 )
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xresource.h>
|
||||
#include <X11/Xutil.h>
|
||||
#endif
|
||||
|
||||
#include "resources.h"
|
||||
#include "disasm.h"
|
||||
#include "errors.h"
|
||||
|
||||
#if defined( GUI_IS_X11 )
|
||||
XrmDatabase rdb = ( XrmDatabase )0;
|
||||
#endif
|
||||
|
||||
int verbose;
|
||||
int quiet;
|
||||
int useTerminal;
|
||||
|
@ -40,7 +30,13 @@ char homeDirectory[ 1024 ];
|
|||
#endif
|
||||
|
||||
#if defined( GUI_IS_X11 )
|
||||
void get_resources() {
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xresource.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
XrmDatabase rdb = ( XrmDatabase )0;
|
||||
|
||||
void get_resources( void ) {
|
||||
if ( get_boolean_resource( "printVersion", "PrintVersion" ) )
|
||||
show_version();
|
||||
if ( get_boolean_resource( "printCopyright", "PrintCopyright" ) )
|
||||
|
@ -294,21 +290,12 @@ XFontStruct* get_font_resource( Display* dpy, char* name, char* class ) {
|
|||
|
||||
#elif defined( GUI_IS_SDL1 )
|
||||
|
||||
void get_resources(
|
||||
void ) { /*
|
||||
if (get_boolean_resource("printVersion", "PrintVersion"))
|
||||
show_version();
|
||||
if (get_boolean_resource("printCopyright", "PrintCopyright"))
|
||||
show_copyright();
|
||||
if (get_boolean_resource("printWarranty", "PrintWarranty"))
|
||||
show_warranty();*/
|
||||
|
||||
void get_resources( void ) {
|
||||
verbose = 0;
|
||||
quiet = 0;
|
||||
useTerminal = 1;
|
||||
useSerial = 0;
|
||||
strcpy( serialLine, "/dev/ttyS0" );
|
||||
// initialize=0;
|
||||
initialize = 0;
|
||||
resetOnStartup = 0;
|
||||
|
||||
|
@ -322,10 +309,7 @@ void get_resources(
|
|||
// emulator instead initializes the state and ram from scratch, and attempts
|
||||
// to load the ROM
|
||||
// romFileName. This is just for bootstrapping: afterwards then the emulator
|
||||
// will save the
|
||||
// state
|
||||
// to
|
||||
// homeDirectory
|
||||
// will save the state to homeDirectory
|
||||
|
||||
// Have homeDirectory in the user's home
|
||||
strcpy( homeDirectory, ".x48ng" ); // live files are stored in ~/.x48ng
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
extern unsigned int opt_gx;
|
||||
extern unsigned int rom_size;
|
||||
|
||||
extern int read_rom_file( const char* name, unsigned char** mem, unsigned int* size );
|
||||
extern int read_rom_file( const char* name, unsigned char** mem,
|
||||
unsigned int* size );
|
||||
|
||||
#endif /* !_ROMIO_H */
|
||||
|
|
|
@ -24,7 +24,7 @@ extern int rece_instr;
|
|||
static char* wire_name = ( char* )0;
|
||||
static char* ir_name = ( char* )0;
|
||||
|
||||
void update_connection_display() {
|
||||
void update_connection_display( void ) {
|
||||
if ( wire_fd == -1 ) {
|
||||
if ( wire_name )
|
||||
free( wire_name );
|
||||
|
@ -38,7 +38,7 @@ void update_connection_display() {
|
|||
ShowConnections( wire_name, ir_name );
|
||||
}
|
||||
|
||||
int serial_init() {
|
||||
int serial_init( void ) {
|
||||
int c;
|
||||
int n;
|
||||
char tty_dev_name[ 128 ];
|
||||
|
@ -381,7 +381,7 @@ void serial_baud( int baud ) {
|
|||
update_connection_display();
|
||||
}
|
||||
|
||||
void transmit_char() {
|
||||
void transmit_char( void ) {
|
||||
if ( saturn.ir_ctrl & 0x04 ) {
|
||||
if ( ir_fd == -1 ) {
|
||||
saturn.tcs &= 0x0e;
|
||||
|
@ -438,7 +438,7 @@ void transmit_char() {
|
|||
|
||||
#define NR_BUFFER 256
|
||||
|
||||
void receive_char() {
|
||||
void receive_char( void ) {
|
||||
struct timeval tout;
|
||||
fd_set rfds;
|
||||
int nfd;
|
||||
|
|
|
@ -66,7 +66,7 @@ word_64 time_offset = 0x0;
|
|||
* 8. Prevent AutoOff by setting TIMEOUT
|
||||
*
|
||||
*/
|
||||
void set_accesstime() {
|
||||
void set_accesstime( void ) {
|
||||
struct timeval tv;
|
||||
#if defined( GUI_IS_X11 )
|
||||
struct timezone tz;
|
||||
|
@ -310,7 +310,7 @@ word_64 get_timer( int timer ) {
|
|||
*
|
||||
*/
|
||||
|
||||
t1_t2_ticks get_t1_t2() {
|
||||
t1_t2_ticks get_t1_t2( void ) {
|
||||
struct timeval tv;
|
||||
#if defined( GUI_IS_X11 )
|
||||
struct timezone tz;
|
||||
|
|
324
src/x48_gui.c
324
src/x48_gui.c
|
@ -348,37 +348,8 @@ color_t colors_gx[] = {
|
|||
{ "black", 0, 0, 0, 0, 0, { 0, 0, 0, 0, DoRed | DoGreen | DoBlue, 0 } },
|
||||
{ 0 } };
|
||||
|
||||
typedef struct button_t {
|
||||
#elif defined( GUI_IS_SDL1 )
|
||||
|
||||
char* name;
|
||||
short pressed;
|
||||
short extra;
|
||||
|
||||
int code;
|
||||
int x, y;
|
||||
unsigned int w, h;
|
||||
|
||||
int lc;
|
||||
char* label;
|
||||
short font_size;
|
||||
unsigned int lw, lh;
|
||||
unsigned char* lb;
|
||||
|
||||
char* letter;
|
||||
|
||||
char* left;
|
||||
short is_menu;
|
||||
char* right;
|
||||
char* sub;
|
||||
|
||||
Pixmap map;
|
||||
Pixmap down;
|
||||
Window xwin;
|
||||
|
||||
} button_t;
|
||||
#endif
|
||||
|
||||
#if defined( GUI_IS_SDL1 )
|
||||
// Control how the screen update is performed: at regular intervals (delayed)
|
||||
// or immediatly Note: this is only for the LCD. The annunciators and the
|
||||
// buttons are always immediately updated
|
||||
|
@ -980,7 +951,7 @@ icon_map_t icon_maps_gx[] = {
|
|||
#define KEYBOARD_OFFSET_X SIDE_SKIP
|
||||
#define KEYBOARD_OFFSET_Y ( TOP_SKIP + DISPLAY_HEIGHT + DISP_KBD_SKIP )
|
||||
|
||||
int AllocColors() {
|
||||
int AllocColors( void ) {
|
||||
int c, error, dyn;
|
||||
int r_shift = 0, g_shift = 0, b_shift = 0;
|
||||
XSetWindowAttributes xswa;
|
||||
|
@ -1442,8 +1413,9 @@ int InitDisplay( int argc, char** argv ) {
|
|||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
#if defined( GUI_IS_SDL1 )
|
||||
|
||||
#elif defined( GUI_IS_SDL1 )
|
||||
|
||||
typedef struct sdltohpkeymap_t {
|
||||
SDLKey sdlkey;
|
||||
int hpkey;
|
||||
|
@ -1940,7 +1912,7 @@ void CreateButton( int i, int off_x, int off_y, XFontStruct* f_small,
|
|||
return;
|
||||
}
|
||||
|
||||
void DrawButtons() {
|
||||
void DrawButtons( void ) {
|
||||
int i;
|
||||
|
||||
for ( i = BUTTON_A; i <= LAST_BUTTON; i++ ) {
|
||||
|
@ -2698,7 +2670,7 @@ void DrawKeypad( keypad_t* keypad ) {
|
|||
return;
|
||||
}
|
||||
|
||||
void CreateIcon() {
|
||||
void CreateIcon( void ) {
|
||||
XSetWindowAttributes xswa;
|
||||
XWindowAttributes xwa;
|
||||
Pixmap tmp_pix;
|
||||
|
@ -2779,7 +2751,7 @@ void CreateIcon() {
|
|||
return;
|
||||
}
|
||||
|
||||
void refresh_icon() {
|
||||
void refresh_icon( void ) {
|
||||
int icon_state;
|
||||
|
||||
icon_state =
|
||||
|
@ -2821,7 +2793,7 @@ void refresh_icon() {
|
|||
}
|
||||
}
|
||||
|
||||
void DrawIcon() {
|
||||
void DrawIcon( void ) {
|
||||
XCopyArea( dpy, icon_pix, iconW, gc, 0, 0, hp48_icon_width,
|
||||
hp48_icon_height, 0, 0 );
|
||||
return;
|
||||
|
@ -2834,7 +2806,7 @@ int handle_xerror( Display* the_dpy, XErrorEvent* eev ) {
|
|||
}
|
||||
#endif
|
||||
|
||||
void CreateDispWindow() {
|
||||
void CreateDispWindow( void ) {
|
||||
XSetWindowAttributes xswa;
|
||||
XGCValues val;
|
||||
unsigned long gc_mask;
|
||||
|
@ -2870,7 +2842,6 @@ void CreateDispWindow() {
|
|||
XSetForeground( dpy, disp.gc, COLOR( PIXEL ) );
|
||||
|
||||
#ifdef HAVE_XSHM
|
||||
|
||||
disp.display_update = UPDATE_DISP | UPDATE_MENU;
|
||||
|
||||
xerror_flag = 0;
|
||||
|
@ -3450,7 +3421,7 @@ int button_released( int b ) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int button_release_all() {
|
||||
static int button_release_all( void ) {
|
||||
int code;
|
||||
int b;
|
||||
|
||||
|
@ -3516,7 +3487,7 @@ int key_event( int b, XEvent* xev ) {
|
|||
}
|
||||
|
||||
#ifdef HAVE_XSHM
|
||||
void refresh_display() {
|
||||
void refresh_display( void ) {
|
||||
if ( shm_flag ) {
|
||||
if ( disp.display_update & UPDATE_DISP ) {
|
||||
XShmPutImage( dpy, disp.win, disp.gc, disp.disp_image, disp.offset,
|
||||
|
@ -3533,7 +3504,7 @@ void refresh_display() {
|
|||
}
|
||||
#endif
|
||||
|
||||
void DrawDisp() {
|
||||
void DrawDisp( void ) {
|
||||
#ifdef HAVE_XSHM
|
||||
if ( shm_flag ) {
|
||||
XShmPutImage( dpy, disp.win, disp.gc, disp.disp_image, disp.offset, 0,
|
||||
|
@ -3603,7 +3574,7 @@ void get_geometry_string( Window win, char* s, int allow_off_screen ) {
|
|||
x, ( y_s > 0 ) ? "+" : "-", y );
|
||||
}
|
||||
|
||||
void save_command_line() {
|
||||
void save_command_line( void ) {
|
||||
XWindowAttributes xwa;
|
||||
int wm_argc, ac;
|
||||
char **wm_argv, geom[ 128 ], icon_geom[ 128 ];
|
||||
|
@ -3981,7 +3952,7 @@ int last_button = -1;
|
|||
|
||||
extern char* get_stack();
|
||||
#elif defined( GUI_IS_SDL1 )
|
||||
void SDLCreateHP() {
|
||||
void SDLCreateHP( void ) {
|
||||
/* int x, y, w, h; */
|
||||
unsigned int width, height;
|
||||
|
||||
|
@ -4022,8 +3993,6 @@ void SDLCreateHP() {
|
|||
keypad.width = width;
|
||||
keypad.height = height;
|
||||
|
||||
printf( "Screen size: %d %d\n", width, height );
|
||||
|
||||
cut = buttons[ BUTTON_MTH ].y + KEYBOARD_OFFSET_Y - 19;
|
||||
SDLDrawBackground( width, cut, width, height );
|
||||
SDLDrawMore( width, height, cut, KEYBOARD_OFFSET_Y, KEYBOARD_OFFSET_X,
|
||||
|
@ -4142,7 +4111,7 @@ int button_released( int b ) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int button_release_all() {
|
||||
static int button_release_all( void ) {
|
||||
int b;
|
||||
|
||||
for ( b = BUTTON_A; b <= LAST_BUTTON; b++ )
|
||||
|
@ -4151,7 +4120,7 @@ static int button_release_all() {
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* void DrawDisp() { */
|
||||
/* void DrawDisp( void ) { */
|
||||
/* redraw_display(); */
|
||||
/* redraw_annunc(); */
|
||||
/* } */
|
||||
|
@ -4205,18 +4174,10 @@ int SDLKeyToKey( SDLKey k ) {
|
|||
void SDLDrawMore( unsigned int w, unsigned int h, unsigned int cut,
|
||||
unsigned int offset_y, unsigned int offset_x,
|
||||
int keypad_width, int keypad_height ) {
|
||||
/* int x, y; */
|
||||
/* SDL_Surface *surf; */
|
||||
|
||||
int display_height = DISPLAY_HEIGHT;
|
||||
int display_width = DISPLAY_WIDTH;
|
||||
|
||||
printf( "display: %d %d\n", display_height, display_width );
|
||||
printf( "keypad: %d %d\n", keypad_height, keypad_width );
|
||||
printf( "wh: %d %d\n", w, h );
|
||||
printf( "cut: %d\n", cut );
|
||||
printf( "offset: %d %d\n", offset_y, offset_x );
|
||||
|
||||
// lower the whole thing
|
||||
|
||||
// bottom lines
|
||||
|
@ -4354,7 +4315,6 @@ void SDLDrawLogo( unsigned int w, unsigned int h, unsigned int cut,
|
|||
int x, y;
|
||||
SDL_Surface* surf;
|
||||
|
||||
/* int display_height = DISPLAY_HEIGHT; */
|
||||
int display_width = DISPLAY_WIDTH;
|
||||
|
||||
// insert the HP Logo
|
||||
|
@ -4500,7 +4460,7 @@ void SDLDrawLogo( unsigned int w, unsigned int h, unsigned int cut,
|
|||
///////////////////////////////////////////////
|
||||
// SDL PORT
|
||||
///////////////////////////////////////////////
|
||||
void SDLCreateColors() {
|
||||
void SDLCreateColors( void ) {
|
||||
unsigned i;
|
||||
|
||||
for ( i = WHITE; i < BLACK; i++ )
|
||||
|
@ -4525,9 +4485,8 @@ void SDLCreateColors() {
|
|||
///////////////////////////////////////////////
|
||||
// SDL PORT
|
||||
///////////////////////////////////////////////
|
||||
void SDLCreateKeys() {
|
||||
void SDLCreateKeys( void ) {
|
||||
unsigned i, x, y;
|
||||
/* SDL_Rect srect, drect; */
|
||||
unsigned pixel;
|
||||
|
||||
for ( i = BUTTON_A; i <= LAST_BUTTON; i++ ) {
|
||||
|
@ -4542,17 +4501,6 @@ void SDLCreateKeys() {
|
|||
SDL_SWSURFACE, buttons[ i ].w, buttons[ i ].h, 32, 0x00ff0000,
|
||||
0x0000ff00, 0x000000ff, 0xff000000 );
|
||||
}
|
||||
/*
|
||||
if (i < BUTTON_MTH)
|
||||
pixel = ARGBColors[DISP_PAD];
|
||||
else
|
||||
{
|
||||
if (opt_gx && buttons[i].is_menu)
|
||||
pixel = ARGBColors[UNDERLAY];
|
||||
else
|
||||
pixel = ARGBColors[PAD];
|
||||
}
|
||||
*/
|
||||
// Use alpha channel
|
||||
pixel = 0x00000000;
|
||||
// pixel = 0xffff0000;
|
||||
|
@ -4570,7 +4518,6 @@ void SDLCreateKeys() {
|
|||
SDL_FillRect( buttons[ i ].surfacedown, &rect, ARGBColors[ BUTTON ] );
|
||||
|
||||
// draw the released button
|
||||
#if defined( GUI_IS_SDL1 )
|
||||
// draw edge of button
|
||||
lineColor( buttons[ i ].surfaceup, 1, buttons[ i ].h - 2, 1, 1,
|
||||
SDLBGRA2ARGB( ARGBColors[ BUT_TOP ] ) );
|
||||
|
@ -4731,7 +4678,6 @@ void SDLCreateKeys() {
|
|||
stringColor( buttons[ i ].surfacedown, x, y, buttons[ i ].label,
|
||||
0xffffffff );
|
||||
}
|
||||
#endif
|
||||
// Pixmap centered in button
|
||||
if ( buttons[ i ].lw != 0 ) {
|
||||
// If there's a bitmap, try to plot this
|
||||
|
@ -4763,7 +4709,7 @@ void SDLCreateKeys() {
|
|||
}
|
||||
|
||||
// Draw the left labels (violet on GX)
|
||||
void SDLDrawKeyLabelLeft() {
|
||||
void SDLDrawKeyLabelLeft( void ) {
|
||||
int i, x, y;
|
||||
unsigned int pw /* , ph */;
|
||||
int wl, wr, ws;
|
||||
|
@ -4783,17 +4729,10 @@ void SDLDrawKeyLabelLeft() {
|
|||
|
||||
if ( opt_gx ) {
|
||||
pw = 58;
|
||||
/* ph = 48; */
|
||||
} else {
|
||||
pw = 46;
|
||||
/* ph = 11; */
|
||||
}
|
||||
|
||||
// pix = XCreatePixmap(dpy, keypad->pixmap, pw, ph, depth);
|
||||
// XSetForeground(dpy, gc, COLOR(UNDERLAY));
|
||||
// XFillRectangle(dpy, pix, gc, 0, 0, pw, ph);
|
||||
// XSetBackground(dpy, gc, COLOR(UNDERLAY));
|
||||
// XSetForeground(dpy, gc, COLOR(LEFT));
|
||||
colorbg = ARGBColors[ UNDERLAY ];
|
||||
colorfg = ARGBColors[ LEFT ];
|
||||
|
||||
|
@ -4806,14 +4745,6 @@ void SDLDrawKeyLabelLeft() {
|
|||
else
|
||||
y = 9;
|
||||
|
||||
if ( !opt_gx ) {
|
||||
// Removed some sx draw code
|
||||
// XDrawPoint(dpy, pix, gc, 0, 0);
|
||||
// XDrawPoint(dpy, pix, gc, 0, ph - 1);
|
||||
// XDrawPoint(dpy, pix, gc, pw - 1, 0);
|
||||
// XDrawPoint(dpy, pix, gc, pw - 1, ph - 1);
|
||||
}
|
||||
|
||||
// Set the coordinates to absolute
|
||||
if ( opt_gx ) {
|
||||
x += offset_x + buttons[ i ].x - 6;
|
||||
|
@ -4833,7 +4764,6 @@ void SDLDrawKeyLabelLeft() {
|
|||
|
||||
if ( buttons[ i ].right == ( char* )0 ) {
|
||||
// centered label
|
||||
|
||||
x = offset_x + buttons[ i ].x +
|
||||
( 1 + buttons[ i ].w -
|
||||
SmallTextWidth( buttons[ i ].left,
|
||||
|
@ -4841,7 +4771,6 @@ void SDLDrawKeyLabelLeft() {
|
|||
2;
|
||||
} else {
|
||||
// label to the left
|
||||
|
||||
wl = SmallTextWidth( buttons[ i ].left,
|
||||
strlen( buttons[ i ].left ) );
|
||||
wr = SmallTextWidth( buttons[ i ].right,
|
||||
|
@ -4862,7 +4791,7 @@ void SDLDrawKeyLabelLeft() {
|
|||
}
|
||||
|
||||
// Draw the right labels (green on GX)
|
||||
void SDLDrawKeyLabelRight() {
|
||||
void SDLDrawKeyLabelRight( void ) {
|
||||
int i, x, y;
|
||||
unsigned int pw /* , ph */;
|
||||
int wl, wr, ws;
|
||||
|
@ -4873,12 +4802,6 @@ void SDLDrawKeyLabelRight() {
|
|||
// draw the right labels
|
||||
|
||||
for ( i = BUTTON_A; i <= LAST_BUTTON; i++ ) {
|
||||
|
||||
// if (i < BUTTON_MTH)
|
||||
// pixel = COLOR(DISP_PAD);
|
||||
// else
|
||||
// pixel = COLOR(PAD);
|
||||
|
||||
if ( buttons[ i ].right == ( char* )0 )
|
||||
continue;
|
||||
|
||||
|
@ -4886,10 +4809,8 @@ void SDLDrawKeyLabelRight() {
|
|||
// draw the dark shade under the label
|
||||
if ( opt_gx ) {
|
||||
pw = 58;
|
||||
/* ph = 48; */
|
||||
} else {
|
||||
pw = 44;
|
||||
/* ph = 9; */
|
||||
}
|
||||
|
||||
colorbg = ARGBColors[ UNDERLAY ];
|
||||
|
@ -4904,14 +4825,6 @@ void SDLDrawKeyLabelRight() {
|
|||
else
|
||||
y = 8;
|
||||
|
||||
if ( !opt_gx ) {
|
||||
// Removed some sx draw code
|
||||
// XDrawPoint(dpy, pix, gc, 0, 0);
|
||||
// XDrawPoint(dpy, pix, gc, 0, ph - 1);
|
||||
// XDrawPoint(dpy, pix, gc, pw - 1, 0);
|
||||
// XDrawPoint(dpy, pix, gc, pw - 1, ph - 1);
|
||||
}
|
||||
|
||||
// Set the coordinates to absolute
|
||||
if ( opt_gx ) {
|
||||
x += offset_x + buttons[ i ].x - 6;
|
||||
|
@ -4927,9 +4840,6 @@ void SDLDrawKeyLabelRight() {
|
|||
colorbg );
|
||||
} // buttons[i].is_menu
|
||||
else {
|
||||
|
||||
// XSetBackground(dpy, gc, pixel);
|
||||
// XSetForeground(dpy, gc, COLOR(RIGHT));
|
||||
colorbg = ARGBColors[ BLACK ];
|
||||
colorfg = ARGBColors[ RIGHT ];
|
||||
|
||||
|
@ -4942,7 +4852,6 @@ void SDLDrawKeyLabelRight() {
|
|||
2;
|
||||
} else {
|
||||
// label to the right
|
||||
|
||||
wl = SmallTextWidth( buttons[ i ].left,
|
||||
strlen( buttons[ i ].left ) );
|
||||
wr = SmallTextWidth( buttons[ i ].right,
|
||||
|
@ -4955,8 +4864,6 @@ void SDLDrawKeyLabelRight() {
|
|||
|
||||
y = offset_y + buttons[ i ].y - small_descent;
|
||||
|
||||
// DrawSmallString(dpy, keypad->pixmap, gc, x, y,
|
||||
// buttons[i].right, strlen(buttons[i].right));
|
||||
SDLDrawSmallString( x, y, buttons[ i ].right,
|
||||
strlen( buttons[ i ].right ), colorfg,
|
||||
colorbg );
|
||||
|
@ -4966,7 +4873,7 @@ void SDLDrawKeyLabelRight() {
|
|||
}
|
||||
|
||||
// Draw the letter bottom right of the key
|
||||
void SDLDrawKeyLetter() {
|
||||
void SDLDrawKeyLetter( void ) {
|
||||
int i, x, y;
|
||||
int offset_y = KEYBOARD_OFFSET_Y;
|
||||
int offset_x = KEYBOARD_OFFSET_X;
|
||||
|
@ -4997,7 +4904,7 @@ void SDLDrawKeyLetter() {
|
|||
}
|
||||
|
||||
// Bottom label: the only one is the cancel button
|
||||
void SDLDrawKeyLabelBottom() {
|
||||
void SDLDrawKeyLabelBottom( void ) {
|
||||
int i, x, y;
|
||||
int offset_y = KEYBOARD_OFFSET_Y;
|
||||
int offset_x = KEYBOARD_OFFSET_X;
|
||||
|
@ -5026,7 +4933,7 @@ void SDLDrawKeyLabelBottom() {
|
|||
}
|
||||
|
||||
// Draws the greyish area around keys that trigger menus
|
||||
void SDLDrawKeyMenu() {
|
||||
void SDLDrawKeyMenu( void ) {
|
||||
int i, x, y;
|
||||
int offset_y = KEYBOARD_OFFSET_Y;
|
||||
int offset_x = KEYBOARD_OFFSET_X;
|
||||
|
@ -5065,7 +4972,7 @@ void SDLDrawKeyMenu() {
|
|||
}
|
||||
}
|
||||
|
||||
void SDLDrawButtons() {
|
||||
void SDLDrawButtons( void ) {
|
||||
int i;
|
||||
|
||||
for ( i = BUTTON_A; i <= LAST_BUTTON; i++ ) {
|
||||
|
@ -5096,9 +5003,8 @@ void SDLDrawButtons() {
|
|||
buttons[ LAST_BUTTON ].x + buttons[ LAST_BUTTON ].w - buttons[ 0 ].x,
|
||||
buttons[ LAST_BUTTON ].y + buttons[ LAST_BUTTON ].h - buttons[ 0 ].y );
|
||||
}
|
||||
void SDLDrawKeypad() {
|
||||
/* int i, x, y; */
|
||||
|
||||
void SDLDrawKeypad( void ) {
|
||||
SDLDrawKeyMenu();
|
||||
SDLDrawKeyLetter();
|
||||
SDLDrawKeyLabelBottom();
|
||||
|
@ -5112,7 +5018,6 @@ void SDLDrawSmallString( int x, int y, const char* string, unsigned int length,
|
|||
unsigned int coloron, unsigned int coloroff ) {
|
||||
int i;
|
||||
|
||||
// printf("draw string: %d, %d, %s\n",x,y,string);
|
||||
for ( i = 0; i < length; i++ ) {
|
||||
if ( small_font[ ( int )string[ i ] ].h != 0 ) {
|
||||
int w = small_font[ ( int )string[ i ] ].w;
|
||||
|
@ -5141,7 +5046,7 @@ void SDLDrawSmallString( int x, int y, const char* string, unsigned int length,
|
|||
|
||||
void SDLDrawBezel( unsigned int width, unsigned int height,
|
||||
unsigned int offset_y, unsigned int offset_x ) {
|
||||
int i /* , x, y*/;
|
||||
int i;
|
||||
int display_height = DISPLAY_HEIGHT;
|
||||
int display_width = DISPLAY_WIDTH;
|
||||
|
||||
|
@ -5268,22 +5173,10 @@ void SDLDrawBackground( int width, int height, int w_top, int h_top ) {
|
|||
SDL_FillRect( sdlwindow, &rect, ARGBColors[ LCD ] );
|
||||
}
|
||||
|
||||
// SDL stuff
|
||||
SDL_Surface* sdlwindow;
|
||||
SDL_Surface* sdlsurface;
|
||||
|
||||
/* SDL_TimerCallback */
|
||||
/* SDLTimerCallback () */
|
||||
/* { */
|
||||
/* } */
|
||||
|
||||
/******************************************************************************
|
||||
InitSDL InitSDL InitSDL InitSDL InitSDL InitSDL InitSDL
|
||||
*******************************************************************************
|
||||
Basic SDL Initialization and atexit assignment.
|
||||
******************************************************************************/
|
||||
|
||||
void SDLInit() {
|
||||
void SDLInit( void ) {
|
||||
SDL_version compiled;
|
||||
|
||||
// Initialize SDL
|
||||
|
@ -5299,16 +5192,6 @@ void SDLInit() {
|
|||
// On exit: clean SDL
|
||||
atexit( SDL_Quit );
|
||||
|
||||
// icon
|
||||
/*SDL_Surface *icon;
|
||||
icon =
|
||||
SDLCreateARGBSurfFromData(sdlicon_width,sdlicon_height,sdlicon_bits,SDLToARGB(255,sdlicon_bits[0],sdlicon_bits[1],sdlicon_bits[2]));
|
||||
|
||||
SDL_WM_SetIcon(icon, 0);
|
||||
SDL_FreeSurface(icon);
|
||||
|
||||
*/
|
||||
/* SDL_WM_SetCaption( "x48ng: HP48 emulator", "x48ng" ); */
|
||||
// Initialize the geometric values
|
||||
KEYBOARD_HEIGHT = _KEYBOARD_HEIGHT;
|
||||
KEYBOARD_WIDTH = _KEYBOARD_WIDTH;
|
||||
|
@ -5332,36 +5215,19 @@ void SDLInit() {
|
|||
buttons_gx[ LAST_BUTTON ].y +
|
||||
buttons_gx[ LAST_BUTTON ].h + BOTTOM_SKIP;
|
||||
|
||||
// unsigned width = (buttons_sx[LAST_BUTTON].x +
|
||||
// buttons_sx[LAST_BUTTON].w)
|
||||
// + 2 * SIDE_SKIP; unsigned height = DISPLAY_OFFSET_Y + DISPLAY_HEIGHT
|
||||
// + DISP_KBD_SKIP + buttons_sx[LAST_BUTTON].y +
|
||||
// buttons_sx[LAST_BUTTON].h + BOTTOM_SKIP;
|
||||
printf( "w/h: %d %d\n", width, height );
|
||||
|
||||
sdlwindow = SDL_SetVideoMode( width, height, 32, SDL_SWSURFACE );
|
||||
|
||||
if ( sdlwindow == NULL ) {
|
||||
printf( "Couldn't set video mode: %s\n", SDL_GetError() );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
/*sdlsurface =
|
||||
SDL_CreateRGBSurface(SDL_SWSURFACE,360,800,32,0x000000ff,0x0000ff00,0x00ff0000,0xff000000);
|
||||
if(sdlsurface==NULL)
|
||||
{
|
||||
printf("Can't create another surface\n");
|
||||
exit(1);
|
||||
}*/
|
||||
|
||||
// SDL_SetTimer(100, SDLTimerCallback);
|
||||
}
|
||||
|
||||
// This should be called once to setup the surfaces. Calling it multiple
|
||||
// times is fine, it won't do anything on subsequent calls.
|
||||
void SDLCreateAnnunc() {
|
||||
void SDLCreateAnnunc( void ) {
|
||||
int i;
|
||||
/* int x, y, idx; */
|
||||
|
||||
for ( i = 0; i < 6; i++ ) {
|
||||
|
||||
// If the SDL surface does not exist yet, we create it on the fly
|
||||
|
@ -5417,59 +5283,10 @@ void SDLDrawAnnunc( char* annunc ) {
|
|||
ann_tbl[ 5 ].y + ann_tbl[ 5 ].height - ann_tbl[ 0 ].y );
|
||||
}
|
||||
|
||||
// lcd_buffer contains one nibble per byte (4 useful bit of data per byte)
|
||||
|
||||
// void SDLDrawLcd(unsigned char lcd_buffer[DISP_ROWS][NIBS_PER_BUFFER_ROW])
|
||||
/*void SDLDrawLcd()
|
||||
{
|
||||
// Do something here
|
||||
int x,y;
|
||||
int xoffset = DISPLAY_OFFSET_X+5;
|
||||
int yoffset = DISPLAY_OFFSET_Y+20;
|
||||
|
||||
SDL_LockSurface(sdlwindow);
|
||||
unsigned char *buffer=sdlwindow->pixels;
|
||||
unsigned int pitch = sdlwindow->pitch;
|
||||
|
||||
unsigned char c = lcd_buffer[0][0];
|
||||
|
||||
for(y=0;y<2*DISP_ROWS;y++)
|
||||
{
|
||||
unsigned int *lineptr;
|
||||
lineptr = (unsigned int*)(buffer + pitch*(yoffset + y));
|
||||
|
||||
for(x=0;x<131;x++)
|
||||
{
|
||||
// Check if bit is on
|
||||
char c = lcd_buffer[y/2][x>>2]; // The 4
|
||||
lower bits in a byte are used (1 nibble per byte) char b = c & (1<<(x&3));
|
||||
if(b)
|
||||
{
|
||||
lineptr[xoffset+2*x]=ARGBColors[PIXEL];
|
||||
lineptr[xoffset+2*x+1]=ARGBColors[PIXEL];
|
||||
}
|
||||
else
|
||||
{
|
||||
lineptr[xoffset+2*x]=ARGBColors[LCD];
|
||||
lineptr[xoffset+2*x+1]=ARGBColors[LCD];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
SDL_UnlockSurface(sdlwindow);
|
||||
SDL_UpdateRect(sdlwindow, 0,0,0,0); // Should optimize:
|
||||
only update the area of the icons
|
||||
}*/
|
||||
|
||||
void SDLDrawNibble( int _x, int _y, int val ) {
|
||||
int x, y;
|
||||
int xoffset = DISPLAY_OFFSET_X + 5;
|
||||
int yoffset = DISPLAY_OFFSET_Y + 20;
|
||||
/* static unsigned ctr = 0; */
|
||||
|
||||
SDL_LockSurface( sdlwindow );
|
||||
unsigned char* buffer = ( unsigned char* )sdlwindow->pixels;
|
||||
|
@ -5582,7 +5399,6 @@ unsigned SDLBGRA2ARGB( unsigned color ) {
|
|||
unsigned a, r, g, b;
|
||||
SDLARGBTo( color, &a, &r, &g, &b );
|
||||
|
||||
// color = a | (b<<24) | (g<<16) | (r<<8);
|
||||
color = a | ( r << 24 ) | ( g << 16 ) | ( b << 8 );
|
||||
return color;
|
||||
}
|
||||
|
@ -5618,11 +5434,7 @@ void SDLUIShowKey( int hpkey ) {
|
|||
ssurf = buttons[ hpkey ].surfaceup;
|
||||
|
||||
// Zoomed surface
|
||||
// zsurf = zoomSurface(ssurf,1.5,1.9,1);
|
||||
/* unsigned t1, t2; */
|
||||
/* t1 = SDL_GetTicks (); */
|
||||
zsurf = zoomSurface( ssurf, zoomfactor, zoomfactor, 0 );
|
||||
/* t2 = SDL_GetTicks (); */
|
||||
|
||||
// Background backup
|
||||
showkeylastsurf =
|
||||
|
@ -5669,7 +5481,7 @@ void SDLUIShowKey( int hpkey ) {
|
|||
// Update
|
||||
SDL_UpdateRect( sdlwindow, x, y, zsurf->w, zsurf->h );
|
||||
}
|
||||
void SDLUIHideKey() {
|
||||
void SDLUIHideKey( void ) {
|
||||
SDL_Rect drect;
|
||||
|
||||
if ( showkeylastsurf == 0 )
|
||||
|
@ -5688,7 +5500,7 @@ void SDLUIHideKey() {
|
|||
showkeylastsurf = 0;
|
||||
}
|
||||
|
||||
void SDLUIFeedback() {
|
||||
void SDLUIFeedback( void ) {
|
||||
// This function should give some UI feedback to indicate that a key was
|
||||
// pressed E.g. by beeping, vibrating or flashing something
|
||||
|
||||
|
@ -5781,10 +5593,6 @@ SDLWINDOW_t SDLCreateWindow( int x, int y, int w, int h, unsigned color,
|
|||
colordark = t;
|
||||
}
|
||||
|
||||
printf( "color: %08X\n", color );
|
||||
printf( "colorlight: %08X\n", colorlight );
|
||||
printf( "colordark: %08X\n", colordark );
|
||||
|
||||
// Draw the frame
|
||||
int i;
|
||||
for ( i = 0; i < framewidth; i++ ) {
|
||||
|
@ -5864,7 +5672,6 @@ void SDLMessageBox( int w, int h, const char* title, const char* text[],
|
|||
y = ( sdlwindow->h - h ) / 2;
|
||||
|
||||
SDLWINDOW_t win;
|
||||
printf( "ShowWindow\n" );
|
||||
win = SDLCreateWindow( x, y, w, h, color, framewidth, 0 );
|
||||
|
||||
stringColor( win.surf, ( w - strlen( title ) * 8 ) / 2,
|
||||
|
@ -5892,7 +5699,7 @@ void SDLMessageBox( int w, int h, const char* title, const char* text[],
|
|||
SDLHideWindow( &win );
|
||||
}
|
||||
|
||||
void SDLEventWaitClickOrKey() {
|
||||
void SDLEventWaitClickOrKey( void ) {
|
||||
SDL_Event event;
|
||||
while ( 1 ) {
|
||||
SDL_WaitEvent( &event );
|
||||
|
@ -5912,7 +5719,7 @@ void SDLEventWaitClickOrKey() {
|
|||
}
|
||||
}
|
||||
|
||||
void SDLShowInformation() {
|
||||
void SDLShowInformation( void ) {
|
||||
const char* info_title = "x48ng - HP48 emulator";
|
||||
|
||||
const char* info_text[] = { //"12345678901234567890123456789012345",
|
||||
|
@ -5952,7 +5759,7 @@ void SDLShowInformation() {
|
|||
}
|
||||
#endif
|
||||
|
||||
int get_ui_event() {
|
||||
int get_ui_event( void ) {
|
||||
#if defined( GUI_IS_X11 )
|
||||
XEvent xev;
|
||||
XClientMessageEvent* cm;
|
||||
|
@ -5993,9 +5800,6 @@ int get_ui_event() {
|
|||
|
||||
case KeyPress:
|
||||
|
||||
if ( 0 && release_pending ) {
|
||||
printf( "xxx release_pending\n" );
|
||||
}
|
||||
release_pending = 0;
|
||||
if ( ( xev.xkey.time - last_release_time ) <= 1 ) {
|
||||
release_pending = 0;
|
||||
|
@ -6594,7 +6398,6 @@ int get_ui_event() {
|
|||
|
||||
#elif defined( GUI_IS_SDL1 )
|
||||
|
||||
// printf("Get event\n");
|
||||
SDL_Event event;
|
||||
int hpkey;
|
||||
int rv;
|
||||
|
@ -6602,43 +6405,26 @@ int get_ui_event() {
|
|||
static int lastticks =
|
||||
-1; // time at which a key was pressed or -1 if timer expired
|
||||
static int lastislongpress = 0; // last key press was a long press
|
||||
/* static unsigned ctr = 0; */
|
||||
static int keyispressed = -1; // Indicate if a key is being held down by
|
||||
// a finger (not set for long presses)
|
||||
static int keyneedshow = 0; // Indicates if the buttons need to be shown
|
||||
static int keyispressed = -1; // Indicate if a key is being held down by
|
||||
// a finger (not set for long presses)
|
||||
static int keyneedshow = 0; // Indicates if the buttons need to be shown
|
||||
static int dispupdate_t1 = -1,
|
||||
dispupdate_t2; // Logic to display at regular intervals
|
||||
// printf("SDLGetEvent %08X\n",ctr++);
|
||||
/* unsigned t1, t2; */
|
||||
|
||||
/* unsigned ticks = SDL_GetTicks (); */
|
||||
// printf("%u\n",ticks);
|
||||
|
||||
// make keys that last only one cycle
|
||||
// button_release_all();
|
||||
|
||||
rv = 0; // nothing to do
|
||||
|
||||
// Check whether long pres on key
|
||||
if ( lastticks > 0 && ( SDL_GetTicks() - lastticks > 750 ) ) {
|
||||
// time elapsed
|
||||
printf( "Timer expired\n" );
|
||||
lastticks = -1;
|
||||
|
||||
// Check that the mouse is still on the same last key
|
||||
int x, y, state;
|
||||
// int hpkeykbd;
|
||||
// char *kstate;
|
||||
state = SDL_GetMouseState( &x, &y );
|
||||
// kstate = SDL_GetKeyState(0);
|
||||
// hpkeykbd = SDLKeyToKey(event.key.keysym.sym);
|
||||
// if(state&SDL_BUTTON(1) && ((SDLCoordinateToKey(x,y)==lasthpkey)
|
||||
// ||()
|
||||
// ))
|
||||
|
||||
if ( state & SDL_BUTTON( 1 ) &&
|
||||
SDLCoordinateToKey( x, y ) == lasthpkey ) {
|
||||
lastislongpress = 1;
|
||||
printf( "\tlong press\n" );
|
||||
SDLUIFeedback();
|
||||
}
|
||||
}
|
||||
|
@ -6646,10 +6432,8 @@ int get_ui_event() {
|
|||
// Iterate as long as there are events
|
||||
// while( SDL_PollEvent( &event ) )
|
||||
if ( SDL_PollEvent( &event ) ) {
|
||||
// printf("PollEvent got %d\n",event.type);
|
||||
switch ( event.type ) {
|
||||
case SDL_QUIT:
|
||||
printf( "Got SDL_QUIT event\n" );
|
||||
exit_x48( 0 );
|
||||
break;
|
||||
|
||||
|
@ -6657,9 +6441,6 @@ int get_ui_event() {
|
|||
// pressed
|
||||
case SDL_MOUSEMOTION:
|
||||
hpkey = SDLCoordinateToKey( event.motion.x, event.motion.y );
|
||||
// printf("Mouse move %d,%d: %d hpkey: %d lasthpkey %d long
|
||||
// %d\n", event.motion.x, event.motion.y,
|
||||
// event.motion.state, hpkey,lasthpkey,lastislongpress);
|
||||
if ( event.motion.state & SDL_BUTTON( 1 ) ) {
|
||||
// Mouse moves on a key different from the last key
|
||||
// (state change):
|
||||
|
@ -6670,11 +6451,9 @@ int get_ui_event() {
|
|||
|
||||
if ( lasthpkey != -1 ) {
|
||||
if ( !lastislongpress ) {
|
||||
// button_released(lasthpkey);
|
||||
button_release_all();
|
||||
rv = 1;
|
||||
SDLUIFeedback();
|
||||
printf( "release all\n" );
|
||||
}
|
||||
// Stop timer, clear long key press
|
||||
lastticks = -1;
|
||||
|
@ -6691,7 +6470,6 @@ int get_ui_event() {
|
|||
// Start timer
|
||||
lastticks = SDL_GetTicks();
|
||||
SDLUIFeedback();
|
||||
printf( "press %d\n", hpkey );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6715,9 +6493,6 @@ int get_ui_event() {
|
|||
// no space above offset_y...clicking on
|
||||
// the screen has to do something
|
||||
SDLShowInformation();
|
||||
// printf("l button up/down at %d %d. hpkey: %d lastkey:
|
||||
// %d long:
|
||||
// %d\n",event.button.x,event.button.y,hpkey,lasthpkey,lastislongpress);
|
||||
}
|
||||
hpkey = SDLCoordinateToKey( event.button.x, event.button.y );
|
||||
|
||||
|
@ -6736,7 +6511,6 @@ int get_ui_event() {
|
|||
// Start timer
|
||||
lastticks = SDL_GetTicks();
|
||||
SDLUIFeedback();
|
||||
printf( "press %d\n", hpkey );
|
||||
}
|
||||
} else {
|
||||
keyispressed = -1;
|
||||
|
@ -6746,7 +6520,6 @@ int get_ui_event() {
|
|||
rv = 1;
|
||||
lasthpkey = -1; // No key is pressed anymore
|
||||
SDLUIFeedback();
|
||||
printf( "release all\n" );
|
||||
}
|
||||
|
||||
// Stop timer, clear long key press
|
||||
|
@ -6757,9 +6530,6 @@ int get_ui_event() {
|
|||
break;
|
||||
case SDL_KEYDOWN:
|
||||
case SDL_KEYUP:
|
||||
printf( "Key: %d hpkey: %d\n", event.key.keysym.sym,
|
||||
SDLKeyToKey( event.key.keysym.sym ) );
|
||||
|
||||
if ( event.type == SDL_KEYDOWN &&
|
||||
event.key.keysym.sym == SDLK_F1 ) {
|
||||
SDLShowInformation();
|
||||
|
@ -6775,7 +6545,6 @@ int get_ui_event() {
|
|||
button_pressed( hpkey );
|
||||
rv = 1;
|
||||
SDLUIFeedback();
|
||||
printf( "press kbd %d\n", hpkey );
|
||||
}
|
||||
} else {
|
||||
keyispressed = -1;
|
||||
|
@ -6783,7 +6552,6 @@ int get_ui_event() {
|
|||
button_released( hpkey );
|
||||
rv = 1;
|
||||
SDLUIFeedback();
|
||||
printf( "release kbd %d\n", hpkey );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6792,10 +6560,7 @@ int get_ui_event() {
|
|||
}
|
||||
|
||||
// Display button being pressed, if any
|
||||
/* t1 = SDL_GetTicks (); */
|
||||
SDLUIShowKey( keyispressed );
|
||||
/* t2 = SDL_GetTicks (); */
|
||||
// printf("Draw zoomed button: %03d\n",t2-t1);
|
||||
|
||||
// If we press long, then the button releases makes SDLUIShowKey restore
|
||||
// the old key, but rv does not indicate that we need to update the
|
||||
|
@ -6807,32 +6572,21 @@ int get_ui_event() {
|
|||
// button is pressed (otherwise it overwrites the zoomed button)
|
||||
if ( keyneedshow && keyispressed == -1 ) {
|
||||
keyneedshow = 0;
|
||||
/* t1 = SDL_GetTicks (); */
|
||||
SDLDrawButtons();
|
||||
/* t2 = SDL_GetTicks (); */
|
||||
// printf("Draw all buttons: %03d\n",t2-t1);
|
||||
}
|
||||
|
||||
#ifdef DELAYEDDISPUPDATE
|
||||
dispupdate_t2 = SDL_GetTicks();
|
||||
if ( dispupdate_t2 - dispupdate_t1 > DISPUPDATEINTERVAL ) {
|
||||
/* t1 = SDL_GetTicks (); */
|
||||
|
||||
int xoffset = DISPLAY_OFFSET_X + 5;
|
||||
int yoffset = DISPLAY_OFFSET_Y + 20;
|
||||
|
||||
// LCD
|
||||
SDL_UpdateRect( sdlwindow, xoffset, yoffset, 131 * 2, 64 * 2 );
|
||||
|
||||
// SDL_UpdateRect(sdlwindow,0,0,0,0);
|
||||
|
||||
/* t2 = SDL_GetTicks (); */
|
||||
// printf("Update rect %03d\t%03d\n",ctr++,t2-t1);
|
||||
dispupdate_t1 = dispupdate_t2;
|
||||
}
|
||||
#endif
|
||||
|
||||
// return rv;
|
||||
return 1;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -103,8 +103,6 @@
|
|||
#define UPDATE_MENU 1
|
||||
#define UPDATE_DISP 2
|
||||
|
||||
// Screen size
|
||||
|
||||
#define _KEYBOARD_HEIGHT \
|
||||
( buttons_gx[ LAST_BUTTON ].y + buttons_gx[ LAST_BUTTON ].h )
|
||||
#define _KEYBOARD_WIDTH \
|
||||
|
@ -189,7 +187,6 @@ extern int InitDisplay( int argc, char** argv );
|
|||
extern int CreateWindows( int argc, char** argv );
|
||||
#endif
|
||||
|
||||
#if defined( GUI_IS_SDL1 )
|
||||
typedef struct button_t {
|
||||
const char* name;
|
||||
short pressed;
|
||||
|
@ -212,13 +209,18 @@ typedef struct button_t {
|
|||
const char* right;
|
||||
const char* sub;
|
||||
|
||||
///////////////////////////////////////////////
|
||||
// SDL PORT
|
||||
///////////////////////////////////////////////
|
||||
SDL_Surface *surfaceup, *surfacedown;
|
||||
|
||||
#if defined( GUI_IS_X11 )
|
||||
Pixmap map;
|
||||
Pixmap down;
|
||||
Window xwin;
|
||||
#elif defined( GUI_IS_SDL1 )
|
||||
SDL_Surface* surfaceup;
|
||||
SDL_Surface* surfacedown;
|
||||
int __dummy;
|
||||
#endif
|
||||
} button_t;
|
||||
|
||||
#if defined( GUI_IS_SDL1 )
|
||||
// This mimicks the structure formerly lcd.c, except with SDL surfaces instead
|
||||
// of Pixmaps.
|
||||
typedef struct ann_struct {
|
||||
|
@ -228,9 +230,6 @@ typedef struct ann_struct {
|
|||
unsigned int width;
|
||||
unsigned int height;
|
||||
unsigned char* bits;
|
||||
///////////////////////////////////////////////
|
||||
// SDL PORT
|
||||
///////////////////////////////////////////////
|
||||
|
||||
SDL_Surface* surfaceon;
|
||||
SDL_Surface* surfaceoff;
|
||||
|
@ -282,8 +281,6 @@ void SDLDrawAnnunc( char* annunc );
|
|||
#define NIBS_PER_BUFFER_ROW ( NIBBLES_PER_ROW + 2 )
|
||||
|
||||
void SDLCreateAnnunc();
|
||||
// void SDLDrawLcd(unsigned char lcd_buffer[DISP_ROWS][NIBS_PER_BUFFER_ROW]);
|
||||
// void SDLDrawLcd();
|
||||
void SDLDrawNibble( int nx, int ny, int val );
|
||||
void SDLDrawKeypad();
|
||||
void SDLDrawButtons();
|
||||
|
@ -293,8 +290,6 @@ SDL_Surface* SDLCreateSurfFromData( unsigned int w, unsigned int h,
|
|||
SDL_Surface* SDLCreateARGBSurfFromData( unsigned int w, unsigned int h,
|
||||
unsigned char* data,
|
||||
unsigned int xpcolor );
|
||||
// void SDLDrawSmallString(int x, int y, const char *string, unsigned int
|
||||
// length);
|
||||
void SDLDrawSmallString( int x, int y, const char* string, unsigned int length,
|
||||
unsigned int coloron, unsigned int coloroff );
|
||||
void SDLCreateColors();
|
||||
|
|
Loading…
Add table
Reference in a new issue