From 48cc5e941cef08f440fc60c9fba072db52fa4e44 Mon Sep 17 00:00:00 2001 From: Gwenhael Le Moine Date: Thu, 7 Sep 2023 16:01:46 +0200 Subject: [PATCH] reduce the number of #ifdef X11/SDL1 --- src/hp48_device.c | 267 +++--- src/hp48_emulate.c | 2 +- src/hp48emu_actions.c | 2 +- src/hp48emu_memory.c | 2 +- src/x48.c | 1878 ++++++++++++++++++++++------------------- src/x48.h | 78 +- 6 files changed, 1233 insertions(+), 996 deletions(-) diff --git a/src/hp48_device.c b/src/hp48_device.c index 8189327..1c48027 100644 --- a/src/hp48_device.c +++ b/src/hp48_device.c @@ -11,7 +11,7 @@ #include "hp48.h" #include "hp48emu.h" #include "timer.h" -#include "x48.h" +#include "x48.h" /* adjust_contrast(); ann_struct_t; DISP_ROWS; NIBS_PER_BUFFER_ROW */ saturn_t saturn; @@ -78,6 +78,16 @@ display_t display; unsigned char disp_buf[ DISP_ROWS ][ NIBS_PER_BUFFER_ROW ]; unsigned char lcd_buffer[ DISP_ROWS ][ NIBS_PER_BUFFER_ROW ]; +ann_struct_t ann_tbl[] = { + { ANN_LEFT, 16, 4, ann_left_width, ann_left_height, ann_left_bitmap }, + { ANN_RIGHT, 61, 4, ann_right_width, ann_right_height, ann_right_bitmap }, + { ANN_ALPHA, 106, 4, ann_alpha_width, ann_alpha_height, ann_alpha_bitmap }, + { ANN_BATTERY, 151, 4, ann_battery_width, ann_battery_height, + ann_battery_bitmap }, + { ANN_BUSY, 196, 4, ann_busy_width, ann_busy_height, ann_busy_bitmap }, + { ANN_IO, 241, 4, ann_io_width, ann_io_height, ann_io_bitmap }, + { 0 } }; + #if defined( GUI_IS_X11 ) Pixmap nibble_maps[ 16 ]; @@ -101,55 +111,8 @@ unsigned char nibbles[ 16 ][ 2 ] = { }; static unsigned char nibble_bitmap[ 16 ]; -#endif -ann_struct_t ann_tbl[] = { - { ANN_LEFT, 16, 4, ann_left_width, ann_left_height, ann_left_bitmap }, - { ANN_RIGHT, 61, 4, ann_right_width, ann_right_height, ann_right_bitmap }, - { ANN_ALPHA, 106, 4, ann_alpha_width, ann_alpha_height, ann_alpha_bitmap }, - { ANN_BATTERY, 151, 4, ann_battery_width, ann_battery_height, - ann_battery_bitmap }, - { ANN_BUSY, 196, 4, ann_busy_width, ann_busy_height, ann_busy_bitmap }, - { ANN_IO, 241, 4, ann_io_width, ann_io_height, ann_io_bitmap }, - { 0 } }; - -void init_display( void ) { - display.on = ( int )( saturn.disp_io & 0x8 ) >> 3; - - display.disp_start = ( saturn.disp_addr & 0xffffe ); - display.offset = ( saturn.disp_io & 0x7 ); - disp.offset = 2 * display.offset; - - display.lines = ( saturn.line_count & 0x3f ); - if ( display.lines == 0 ) - display.lines = 63; - disp.lines = 2 * display.lines; - if ( disp.lines < 110 ) - disp.lines = 110; - - if ( display.offset > 3 ) - display.nibs_per_line = - ( NIBBLES_PER_ROW + saturn.line_offset + 2 ) & 0xfff; - else - display.nibs_per_line = - ( NIBBLES_PER_ROW + saturn.line_offset ) & 0xfff; - - display.disp_end = - display.disp_start + ( display.nibs_per_line * ( display.lines + 1 ) ); - - display.menu_start = saturn.menu_addr; - display.menu_end = saturn.menu_addr + 0x110; - - display.contrast = saturn.contrast_ctrl; - display.contrast |= ( ( saturn.disp_test & 0x1 ) << 4 ); - - display.annunc = saturn.annunc; - - memset( disp_buf, 0xf0, sizeof( disp_buf ) ); - memset( lcd_buffer, 0xf0, sizeof( lcd_buffer ) ); - -#if defined( GUI_IS_X11 ) - /* init nibble_maps */ +static inline void init_nibble_maps( void ) { int i; for ( i = 0; i < 16; i++ ) { @@ -194,10 +157,8 @@ void init_display( void ) { nibble_bitmap[ 0xf ] = 0xff; /* **** */ } } -#endif } -#if defined( GUI_IS_X11 ) static inline void draw_nibble( int c, int r, int val ) { int x, y; @@ -217,6 +178,8 @@ static inline void draw_nibble( int c, int r, int val ) { lcd_buffer[ r ][ c ] = val; } #elif defined( GUI_IS_SDL1 ) +static inline void init_nibble_maps( void ) {} + static inline void draw_nibble( int c, int r, int val ) { int x, y; @@ -253,26 +216,22 @@ static inline void draw_row( long addr, int row ) { } } +#if defined( GUI_IS_X11 ) void update_display( void ) { int i, j; long addr; static int old_offset = -1; static int old_lines = -1; -#if defined( GUI_IS_X11 ) int addr_pad; int val, line_pad, line_length; word_20 data_addr, data_addr_2; -#endif if ( !disp.mapped ) { -#if defined( GUI_IS_X11 ) refresh_icon(); -#endif return; } if ( display.on ) { addr = display.disp_start; -#if defined( GUI_IS_X11 ) if ( shm_flag ) { data_addr = 0; data_addr_2 = disp.disp_image->bytes_per_line; @@ -294,7 +253,6 @@ void update_display( void ) { } disp.display_update |= UPDATE_DISP; } else { -#endif if ( display.offset != old_offset ) { memset( disp_buf, 0xf0, @@ -315,12 +273,10 @@ void update_display( void ) { draw_row( addr, i ); addr += display.nibs_per_line; } -#if defined( GUI_IS_X11 ) } -#endif + if ( i < DISP_ROWS ) { addr = display.menu_start; -#if defined( GUI_IS_X11 ) if ( shm_flag ) { data_addr = 0; data_addr_2 = disp.menu_image->bytes_per_line; @@ -339,17 +295,13 @@ void update_display( void ) { } disp.display_update |= UPDATE_MENU; } else { -#endif for ( ; i < DISP_ROWS; i++ ) { draw_row( addr, i ); addr += NIBBLES_PER_ROW; } -#if defined( GUI_IS_X11 ) } -#endif } } else { -#if defined( GUI_IS_X11 ) if ( shm_flag ) { memset( disp.disp_image->data, 0, ( size_t )( disp.disp_image->bytes_per_line * @@ -359,23 +311,19 @@ void update_display( void ) { disp.menu_image->height ) ); disp.display_update = UPDATE_DISP | UPDATE_MENU; } else { -#endif memset( disp_buf, 0xf0, sizeof( disp_buf ) ); for ( i = 0; i < 64; i++ ) { for ( j = 0; j < NIBBLES_PER_ROW; j++ ) { draw_nibble( j, i, 0x00 ); } } -#if defined( GUI_IS_X11 ) } -#endif } } void redraw_display( void ) { -#if defined( GUI_IS_X11 ) XClearWindow( dpy, disp.win ); -#endif + memset( disp_buf, 0, sizeof( disp_buf ) ); memset( lcd_buffer, 0, sizeof( lcd_buffer ) ); update_display(); @@ -383,9 +331,7 @@ void redraw_display( void ) { void disp_draw_nibble( word_20 addr, word_4 val ) { long offset; -#if defined( GUI_IS_X11 ) int shm_addr; -#endif int x, y; offset = ( addr - display.disp_start ); @@ -396,7 +342,6 @@ void disp_draw_nibble( word_20 addr, word_4 val ) { y = offset / display.nibs_per_line; if ( y < 0 || y > 63 ) return; -#if defined( GUI_IS_X11 ) if ( shm_flag ) { shm_addr = ( 2 * y * disp.disp_image->bytes_per_line ) + x; disp.disp_image->data[ shm_addr ] = nibble_bitmap[ val ]; @@ -405,16 +350,12 @@ void disp_draw_nibble( word_20 addr, word_4 val ) { nibble_bitmap[ val ]; disp.display_update |= UPDATE_DISP; } else { -#endif if ( val != disp_buf[ y ][ x ] ) { disp_buf[ y ][ x ] = val; draw_nibble( x, y, val ); } -#if defined( GUI_IS_X11 ) } -#endif } else { -#if defined( GUI_IS_X11 ) if ( shm_flag ) { shm_addr = x; for ( y = 0; y < display.lines; y++ ) { @@ -425,28 +366,22 @@ void disp_draw_nibble( word_20 addr, word_4 val ) { } disp.display_update |= UPDATE_DISP; } else { -#endif for ( y = 0; y < display.lines; y++ ) { if ( val != disp_buf[ y ][ x ] ) { disp_buf[ y ][ x ] = val; draw_nibble( x, y, val ); } } -#if defined( GUI_IS_X11 ) } -#endif } } void menu_draw_nibble( word_20 addr, word_4 val ) { long offset; -#if defined( GUI_IS_X11 ) int shm_addr; -#endif int x, y; offset = ( addr - display.menu_start ); -#if defined( GUI_IS_X11 ) if ( shm_flag ) { shm_addr = 2 * ( offset / NIBBLES_PER_ROW ) * disp.menu_image->bytes_per_line + @@ -456,16 +391,13 @@ void menu_draw_nibble( word_20 addr, word_4 val ) { nibble_bitmap[ val ]; disp.display_update |= UPDATE_MENU; } else { -#endif x = offset % NIBBLES_PER_ROW; y = display.lines + ( offset / NIBBLES_PER_ROW ) + 1; if ( val != disp_buf[ y ][ x ] ) { disp_buf[ y ][ x ] = val; draw_nibble( x, y, val ); } -#if defined( GUI_IS_X11 ) } -#endif } void draw_annunc( void ) { @@ -477,11 +409,7 @@ void draw_annunc( void ) { return; last_annunc_state = val; -#if defined( GUI_IS_SDL1 ) - char sdl_annuncstate[ 6 ]; -#endif for ( int i = 0; ann_tbl[ i ].bit; i++ ) { -#if defined( GUI_IS_X11 ) if ( ( ann_tbl[ i ].bit & val ) == ann_tbl[ i ].bit ) XCopyPlane( dpy, ann_tbl[ i ].pixmap, disp.win, disp.gc, 0, 0, ann_tbl[ i ].width, ann_tbl[ i ].height, ann_tbl[ i ].x, @@ -490,28 +418,171 @@ void draw_annunc( void ) { XClearArea( dpy, disp.win, ann_tbl[ i ].x, ann_tbl[ i ].y, ann_tbl[ i ].width, ann_tbl[ i ].height, False ); -#elif defined( GUI_IS_SDL1 ) - sdl_annuncstate[ i ] = - ( ( ann_tbl[ i ].bit & val ) == ann_tbl[ i ].bit ) ? 1 : 0; -#endif } -#if defined( GUI_IS_X11 ) + refresh_icon(); -#elif defined( GUI_IS_SDL1 ) - SDLDrawAnnunc( sdl_annuncstate ); -#endif } -#if defined( GUI_IS_X11 ) void init_annunc( void ) { for ( int i = 0; ann_tbl[ i ].bit; i++ ) ann_tbl[ i ].pixmap = XCreateBitmapFromData( dpy, disp.win, ( char* )ann_tbl[ i ].bits, ann_tbl[ i ].width, ann_tbl[ i ].height ); } + +#elif defined( GUI_IS_SDL1 ) + +void update_display( void ) { + int i, j; + long addr; + static int old_offset = -1; + static int old_lines = -1; + + if ( !disp.mapped ) + return; + + if ( display.on ) { + addr = display.disp_start; + if ( display.offset != old_offset ) { + memset( + disp_buf, 0xf0, + ( size_t )( ( display.lines + 1 ) * NIBS_PER_BUFFER_ROW ) ); + memset( + lcd_buffer, 0xf0, + ( size_t )( ( display.lines + 1 ) * NIBS_PER_BUFFER_ROW ) ); + old_offset = display.offset; + } + if ( display.lines != old_lines ) { + memset( &disp_buf[ 56 ][ 0 ], 0xf0, + ( size_t )( 8 * NIBS_PER_BUFFER_ROW ) ); + memset( &lcd_buffer[ 56 ][ 0 ], 0xf0, + ( size_t )( 8 * NIBS_PER_BUFFER_ROW ) ); + old_lines = display.lines; + } + for ( i = 0; i <= display.lines; i++ ) { + draw_row( addr, i ); + addr += display.nibs_per_line; + } + if ( i < DISP_ROWS ) { + addr = display.menu_start; + for ( ; i < DISP_ROWS; i++ ) { + draw_row( addr, i ); + addr += NIBBLES_PER_ROW; + } + } + } else { + memset( disp_buf, 0xf0, sizeof( disp_buf ) ); + for ( i = 0; i < 64; i++ ) { + for ( j = 0; j < NIBBLES_PER_ROW; j++ ) { + draw_nibble( j, i, 0x00 ); + } + } + } +} + +void redraw_display( void ) { + memset( disp_buf, 0, sizeof( disp_buf ) ); + memset( lcd_buffer, 0, sizeof( lcd_buffer ) ); + update_display(); +} + +void disp_draw_nibble( word_20 addr, word_4 val ) { + long offset; + int x, y; + + offset = ( addr - display.disp_start ); + x = offset % display.nibs_per_line; + if ( x < 0 || x > 35 ) + return; + if ( display.nibs_per_line != 0 ) { + y = offset / display.nibs_per_line; + if ( y < 0 || y > 63 ) + return; + if ( val != disp_buf[ y ][ x ] ) { + disp_buf[ y ][ x ] = val; + draw_nibble( x, y, val ); + } + } else { + for ( y = 0; y < display.lines; y++ ) { + if ( val != disp_buf[ y ][ x ] ) { + disp_buf[ y ][ x ] = val; + draw_nibble( x, y, val ); + } + } + } +} + +void menu_draw_nibble( word_20 addr, word_4 val ) { + long offset; + int x, y; + + offset = ( addr - display.menu_start ); + x = offset % NIBBLES_PER_ROW; + y = display.lines + ( offset / NIBBLES_PER_ROW ) + 1; + if ( val != disp_buf[ y ][ x ] ) { + disp_buf[ y ][ x ] = val; + draw_nibble( x, y, val ); + } +} + +void draw_annunc( void ) { + int val; + + val = display.annunc; + + if ( val == last_annunc_state ) + return; + last_annunc_state = val; + + char sdl_annuncstate[ 6 ]; + for ( int i = 0; ann_tbl[ i ].bit; i++ ) { + sdl_annuncstate[ i ] = + ( ( ann_tbl[ i ].bit & val ) == ann_tbl[ i ].bit ) ? 1 : 0; + } + + SDLDrawAnnunc( sdl_annuncstate ); +} #endif void redraw_annunc( void ) { last_annunc_state = -1; draw_annunc(); } + +void init_display( void ) { + display.on = ( int )( saturn.disp_io & 0x8 ) >> 3; + + display.disp_start = ( saturn.disp_addr & 0xffffe ); + display.offset = ( saturn.disp_io & 0x7 ); + disp.offset = 2 * display.offset; + + display.lines = ( saturn.line_count & 0x3f ); + if ( display.lines == 0 ) + display.lines = 63; + disp.lines = 2 * display.lines; + if ( disp.lines < 110 ) + disp.lines = 110; + + if ( display.offset > 3 ) + display.nibs_per_line = + ( NIBBLES_PER_ROW + saturn.line_offset + 2 ) & 0xfff; + else + display.nibs_per_line = + ( NIBBLES_PER_ROW + saturn.line_offset ) & 0xfff; + + display.disp_end = + display.disp_start + ( display.nibs_per_line * ( display.lines + 1 ) ); + + display.menu_start = saturn.menu_addr; + display.menu_end = saturn.menu_addr + 0x110; + + display.contrast = saturn.contrast_ctrl; + display.contrast |= ( ( saturn.disp_test & 0x1 ) << 4 ); + + display.annunc = saturn.annunc; + + memset( disp_buf, 0xf0, sizeof( disp_buf ) ); + memset( lcd_buffer, 0xf0, sizeof( lcd_buffer ) ); + + init_nibble_maps(); +} diff --git a/src/hp48_emulate.c b/src/hp48_emulate.c index ff19cc9..da501e7 100644 --- a/src/hp48_emulate.c +++ b/src/hp48_emulate.c @@ -4,7 +4,7 @@ #include "hp48.h" #include "hp48emu.h" #include "timer.h" -#include "x48.h" +#include "x48.h" /* disp; refresh_display(); get_ui_event() */ extern int throttle; diff --git a/src/hp48emu_actions.c b/src/hp48emu_actions.c index aa40fa9..8fa87a4 100644 --- a/src/hp48emu_actions.c +++ b/src/hp48emu_actions.c @@ -6,7 +6,7 @@ #include "hp48emu.h" #include "romio.h" #include "timer.h" -#include "x48.h" +#include "x48.h" /* disp; refresh_display(); get_ui_event() */ static int interrupt_called = 0; extern long nibble_masks[ 16 ]; diff --git a/src/hp48emu_memory.c b/src/hp48emu_memory.c index 9947dd0..8e46dfe 100644 --- a/src/hp48emu_memory.c +++ b/src/hp48emu_memory.c @@ -7,7 +7,7 @@ #include "hp48.h" #include "hp48emu.h" #include "romio.h" -#include "x48.h" +#include "x48.h" /* disp */ #include "options.h" extern int device_check; diff --git a/src/x48.c b/src/x48.c index 885fbc2..3728893 100644 --- a/src/x48.c +++ b/src/x48.c @@ -126,233 +126,186 @@ int direct_color; int does_backing_store; int color_mode; int icon_color_mode; -#elif defined( GUI_IS_SDL1 ) -// This will take the value of the defines, but can be run-time modified -unsigned KEYBOARD_HEIGHT, KEYBOARD_WIDTH, TOP_SKIP, SIDE_SKIP, BOTTOM_SKIP, - DISP_KBD_SKIP, DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_OFFSET_X, - DISPLAY_OFFSET_Y, DISP_FRAME, KEYBOARD_OFFSET_X, KEYBOARD_OFFSET_Y, - KBD_UPLINE; -#endif color_t colors_sx[] = { { "white", 255, 255, 255 -#if defined( GUI_IS_X11 ) , 255, 255, { 0, 0, 0, 0, DoRed | DoGreen | DoBlue, 0 } -#endif }, { "left", 255, 166, 0 -#if defined( GUI_IS_X11 ) , 255, 230, { 0, 0, 0, 0, DoRed | DoGreen | DoBlue, 0 } -#endif }, { "right", 0, 210, 255 -#if defined( GUI_IS_X11 ) , 255, 169, { 0, 0, 0, 0, DoRed | DoGreen | DoBlue, 0 } -#endif }, { "but_top", 109, 93, 93 -#if defined( GUI_IS_X11 ) , 0, 91, { 0, 0, 0, 0, DoRed | DoGreen | DoBlue, 0 } -#endif }, { "button", 90, 77, 77 -#if defined( GUI_IS_X11 ) , 0, 81, { 0, 0, 0, 0, DoRed | DoGreen | DoBlue, 0 } -#endif }, { "but_bot", 76, 65, 65 -#if defined( GUI_IS_X11 ) , 0, 69, { 0, 0, 0, 0, DoRed | DoGreen | DoBlue, 0 } -#endif }, { "lcd_col", 202, 221, 92 -#if defined( GUI_IS_X11 ) , 255, 205, { 0, 0, 0, 0, DoRed | DoGreen | DoBlue, 0 } -#endif }, { "pix_col", 0, 0, 128 -#if defined( GUI_IS_X11 ) , 0, 20, { 0, 0, 0, 0, DoRed | DoGreen | DoBlue, 0 } -#endif }, { "pad_top", 109, 78, 78 -#if defined( GUI_IS_X11 ) , 0, 88, { 0, 0, 0, 0, DoRed | DoGreen | DoBlue, 0 } -#endif }, { "pad", 90, 64, 64 -#if defined( GUI_IS_X11 ) , 0, 73, { 0, 0, 0, 0, DoRed | DoGreen | DoBlue, 0 } -#endif }, { "pad_bot", 76, 54, 54 -#if defined( GUI_IS_X11 ) , 0, 60, { 0, 0, 0, 0, DoRed | DoGreen | DoBlue, 0 } -#endif }, { "disp_pad_top", 155, 118, 84 -#if defined( GUI_IS_X11 ) , 0, 124, { 0, 0, 0, 0, DoRed | DoGreen | DoBlue, 0 } -#endif }, { "disp_pad", 124, 94, 67 -#if defined( GUI_IS_X11 ) , 0, 99, { 0, 0, 0, 0, DoRed | DoGreen | DoBlue, 0 } -#endif }, { "disp_pad_bot", 100, 75, 53 -#if defined( GUI_IS_X11 ) , 0, 79, { 0, 0, 0, 0, DoRed | DoGreen | DoBlue, 0 } -#endif }, { "logo", 204, 169, 107 -#if defined( GUI_IS_X11 ) , 255, 172, { 0, 0, 0, 0, DoRed | DoGreen | DoBlue, 0 } -#endif }, { "logo_back", 64, 64, 64 -#if defined( GUI_IS_X11 ) , 0, 65, { 0, 0, 0, 0, DoRed | DoGreen | DoBlue, 0 } -#endif }, { "label", 202, 184, 144 -#if defined( GUI_IS_X11 ) , 255, 185, { 0, 0, 0, 0, DoRed | DoGreen | DoBlue, 0 } -#endif }, { "frame", 0, 0, 0 -#if defined( GUI_IS_X11 ) , 255, 0, { 0, 0, 0, 0, DoRed | DoGreen | DoBlue, 0 } -#endif }, { "underlay", 60, 42, 42 -#if defined( GUI_IS_X11 ) , 0, 48, { 0, 0, 0, 0, DoRed | DoGreen | DoBlue, 0 } -#endif }, { "black", 0, 0, 0 -#if defined( GUI_IS_X11 ) , 0, 0, { 0, 0, 0, 0, DoRed | DoGreen | DoBlue, 0 } -#endif }, { 0 } }; @@ -360,225 +313,395 @@ color_t colors_gx[] = { { "white", 255, 255, 255 -#if defined( GUI_IS_X11 ) , 255, 255, { 0, 0, 0, 0, DoRed | DoGreen | DoBlue, 0 } -#endif }, { "left", 255, 186, 255 -#if defined( GUI_IS_X11 ) , 255, 220, { 0, 0, 0, 0, DoRed | DoGreen | DoBlue, 0 } -#endif }, { "right", 0, 255, 204 -#if defined( GUI_IS_X11 ) , 255, 169, { 0, 0, 0, 0, DoRed | DoGreen | DoBlue, 0 } -#endif }, { "but_top", 104, 104, 104 -#if defined( GUI_IS_X11 ) , 0, 104, { 0, 0, 0, 0, DoRed | DoGreen | DoBlue, 0 } -#endif }, { "button", 88, 88, 88 -#if defined( GUI_IS_X11 ) , 0, 88, { 0, 0, 0, 0, DoRed | DoGreen | DoBlue, 0 } -#endif }, { "but_bot", 74, 74, 74 -#if defined( GUI_IS_X11 ) , 0, 74, { 0, 0, 0, 0, DoRed | DoGreen | DoBlue, 0 } -#endif }, { "lcd_col", 202, 221, 92 -#if defined( GUI_IS_X11 ) , 255, 205, { 0, 0, 0, 0, DoRed | DoGreen | DoBlue, 0 } -#endif }, { "pix_col", 0, 0, 128 -#if defined( GUI_IS_X11 ) , 0, 20, { 0, 0, 0, 0, DoRed | DoGreen | DoBlue, 0 } -#endif }, { "pad_top", 88, 88, 88 -#if defined( GUI_IS_X11 ) , 0, 88, { 0, 0, 0, 0, DoRed | DoGreen | DoBlue, 0 } -#endif }, { "pad", 74, 74, 74 -#if defined( GUI_IS_X11 ) , 0, 74, { 0, 0, 0, 0, DoRed | DoGreen | DoBlue, 0 } -#endif }, { "pad_bot", 64, 64, 64 -#if defined( GUI_IS_X11 ) , 0, 64, { 0, 0, 0, 0, DoRed | DoGreen | DoBlue, 0 } -#endif }, { "disp_pad_top", 128, 128, 138 -#if defined( GUI_IS_X11 ) , 0, 128, { 0, 0, 0, 0, DoRed | DoGreen | DoBlue, 0 } -#endif }, { "disp_pad", 104, 104, 110 -#if defined( GUI_IS_X11 ) , 0, 104, { 0, 0, 0, 0, DoRed | DoGreen | DoBlue, 0 } -#endif }, { "disp_pad_bot", 84, 84, 90 -#if defined( GUI_IS_X11 ) , 0, 84, { 0, 0, 0, 0, DoRed | DoGreen | DoBlue, 0 } -#endif }, { "logo", 176, 176, 184 -#if defined( GUI_IS_X11 ) , 255, 176, { 0, 0, 0, 0, DoRed | DoGreen | DoBlue, 0 } -#endif }, { "logo_back", 104, 104, 110 -#if defined( GUI_IS_X11 ) , 0, 104, { 0, 0, 0, 0, DoRed | DoGreen | DoBlue, 0 } -#endif }, { "label", 240, 240, 240 -#if defined( GUI_IS_X11 ) , 255, 240, { 0, 0, 0, 0, DoRed | DoGreen | DoBlue, 0 } -#endif }, { "frame", 0, 0, 0 -#if defined( GUI_IS_X11 ) , 255, 0, { 0, 0, 0, 0, DoRed | DoGreen | DoBlue, 0 } -#endif }, { "underlay", 104, 104, 110 -#if defined( GUI_IS_X11 ) , 0, 104, { 0, 0, 0, 0, DoRed | DoGreen | DoBlue, 0 } -#endif }, { "black", 0, 0, 0 -#if defined( GUI_IS_X11 ) , 0, 0, { 0, 0, 0, 0, DoRed | DoGreen | DoBlue, 0 } -#endif }, { 0 } }; -#if defined( GUI_IS_SDL1 ) +#elif defined( GUI_IS_SDL1 ) + +// This will take the value of the defines, but can be run-time modified +unsigned KEYBOARD_HEIGHT, KEYBOARD_WIDTH, TOP_SKIP, SIDE_SKIP, BOTTOM_SKIP, + DISP_KBD_SKIP, DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_OFFSET_X, + DISPLAY_OFFSET_Y, DISP_FRAME, KEYBOARD_OFFSET_X, KEYBOARD_OFFSET_Y, + KBD_UPLINE; + +color_t colors_sx[] = { { "white", + 255, + 255, + 255 + }, + { "left", + 255, + 166, + 0 + }, + { "right", + 0, + 210, + 255 + }, + { "but_top", + 109, + 93, + 93 + }, + { "button", + 90, + 77, + 77 + }, + { "but_bot", + 76, + 65, + 65 + }, + { "lcd_col", + 202, + 221, + 92 + }, + { "pix_col", + 0, + 0, + 128 + }, + { "pad_top", + 109, + 78, + 78 + }, + { "pad", + 90, + 64, + 64 + }, + { "pad_bot", + 76, + 54, + 54 + }, + { "disp_pad_top", + 155, + 118, + 84 + }, + { "disp_pad", + 124, + 94, + 67 + }, + { "disp_pad_bot", + 100, + 75, + 53 + }, + { "logo", + 204, + 169, + 107 + }, + { "logo_back", + 64, + 64, + 64 + }, + { "label", + 202, + 184, + 144 + }, + { "frame", + 0, + 0, + 0 + }, + { "underlay", + 60, + 42, + 42 + }, + { "black", + 0, + 0, + 0 + }, + { 0 } }; + +color_t colors_gx[] = { { "white", + 255, + 255, + 255 + }, + { "left", + 255, + 186, + 255 + }, + { "right", + 0, + 255, + 204 + }, + { "but_top", + 104, + 104, + 104 + }, + { "button", + 88, + 88, + 88 + }, + { "but_bot", + 74, + 74, + 74 + }, + { "lcd_col", + 202, + 221, + 92 + }, + { "pix_col", + 0, + 0, + 128 + }, + { "pad_top", + 88, + 88, + 88 + }, + { "pad", + 74, + 74, + 74 + }, + { "pad_bot", + 64, + 64, + 64 + }, + { "disp_pad_top", + 128, + 128, + 138 + }, + { "disp_pad", + 104, + 104, + 110 + }, + { "disp_pad_bot", + 84, + 84, + 90 + }, + { "logo", + 176, + 176, + 184 + }, + { "logo_back", + 104, + 104, + 110 + }, + { "label", + 240, + 240, + 240 + }, + { "frame", + 0, + 0, + 0 + }, + { "underlay", + 104, + 104, + 110 + }, + { "black", + 0, + 0, + 0 + }, + { 0 } }; // Control how the screen update is performed: at regular intervals (delayed) // or immediatly Note: this is only for the LCD. The annunciators and the @@ -1682,6 +1805,23 @@ sdltohpkeymap_t sdltohpkeymap[] = { { ( SDLKey )0, ( SDLKey )0 } }; #endif +int SmallTextWidth( const char* string, unsigned int length ) { + int i, w; + + w = 0; + for ( i = 0; i < length; i++ ) { + if ( small_font[ ( int )string[ i ] ].h != 0 ) { + w += small_font[ ( int )string[ i ] ].w + 1; + } else { + if ( verbose ) + fprintf( stderr, "Unknown small letter 0x00%x\n", + ( int )string[ i ] ); + w += 5; + } + } + return w; +} + #if defined( GUI_IS_X11 ) void adjust_contrast( int contrast ) { int gray = 0; @@ -1751,35 +1891,17 @@ void adjust_contrast( int contrast ) { } #endif -int SmallTextWidth( const char* string, unsigned int length ) { - int i, w; - - w = 0; - for ( i = 0; i < length; i++ ) { - if ( small_font[ ( int )string[ i ] ].h != 0 ) { - w += small_font[ ( int )string[ i ] ].w + 1; - } else { - if ( verbose ) - fprintf( stderr, "Unknown small letter 0x00%x\n", - ( int )string[ i ] ); - w += 5; - } - } - return w; -} +#if defined( GUI_IS_X11 ) void exit_x48( int tell_x11 ) { exit_emulator(); -#if defined( GUI_IS_X11 ) if ( tell_x11 ) XCloseDisplay( dpy ); -#endif exit( 0 ); } -#if defined( GUI_IS_X11 ) int DrawSmallString( Display* the_dpy, Drawable d, GC the_gc, int x, int y, const char* string, unsigned int length ) { int i; @@ -4037,7 +4159,780 @@ int decode_key( XEvent* xev, KeySym sym, char* buf, int buflen ) { } return wake; } +#endif + +int button_pressed( int b ) { + int code; + int i, r, c; + + if ( buttons[ b ].pressed == 1 ) // Check not already pressed (may be + // important: avoids a useless do_kbd_int) + return 0; + + buttons[ b ].pressed = 1; + + code = buttons[ b ].code; + + if ( code == 0x8000 ) { + for ( i = 0; i < 9; i++ ) + saturn.keybuf.rows[ i ] |= 0x8000; + do_kbd_int(); + } else { + r = code >> 4; + c = 1 << ( code & 0xf ); + if ( ( saturn.keybuf.rows[ r ] & c ) == 0 ) { + if ( saturn.kbd_ien ) + do_kbd_int(); + if ( ( saturn.keybuf.rows[ r ] & c ) ) + fprintf( stderr, "bug\n" ); + + saturn.keybuf.rows[ r ] |= c; + } + } + + return 0; +} + +int button_released( int b ) { + int code; + + if ( buttons[ b ].pressed == + 0 ) // Check not already released (not critical) + return 0; + + buttons[ b ].pressed = 0; + + code = buttons[ b ].code; + if ( code == 0x8000 ) { + int i; + for ( i = 0; i < 9; i++ ) + saturn.keybuf.rows[ i ] &= ~0x8000; + } else { + int r, c; + r = code >> 4; + c = 1 << ( code & 0xf ); + saturn.keybuf.rows[ r ] &= ~c; + } + + return 0; +} + +#if defined( GUI_IS_X11 ) +static int button_release_all( void ) { + for ( int b = BUTTON_A; b <= LAST_BUTTON; b++ ) + if ( buttons[ b ].pressed ) { + int code = buttons[ b ].code; + if ( code == 0x8000 ) { + int i; + for ( i = 0; i < 9; i++ ) + saturn.keybuf.rows[ i ] &= ~0x8000; + } else { + int r, c; + r = code >> 4; + c = 1 << ( code & 0xf ); + saturn.keybuf.rows[ r ] &= ~c; + } + buttons[ b ].pressed = 0; + DrawButton( b ); + } + + return 0; +} + +void ShowConnections( char* wire, char* ir ) { + char name[ 128 ]; + int x, y, w, h; + int conn_top; + XFontStruct* finfo; + XGCValues val; + unsigned long gc_mask; + XCharStruct xchar; + int dir, fa, fd; + Pixmap pix; + + finfo = get_font_resource( dpy, "connectionFont", "ConnectionFont" ); + val.font = finfo->fid; + gc_mask = GCFont; + XChangeGC( dpy, gc, gc_mask, &val ); + + conn_top = DISPLAY_OFFSET_Y + DISPLAY_HEIGHT + 18; + + XTextExtents( finfo, "TEST", ( int )strlen( "TEST" ), &dir, &fa, &fd, + &xchar ); + w = DISPLAY_WIDTH; + h = fa + fd; + + pix = XCreatePixmap( dpy, keypad.pixmap, w, h, depth ); /* FIXME keypad? */ + XSetForeground( dpy, gc, COLOR( DISP_PAD ) ); + XFillRectangle( dpy, pix, gc, 0, 0, w, h ); + + XSetBackground( dpy, gc, COLOR( DISP_PAD ) ); + XSetForeground( dpy, gc, COLOR( LABEL ) ); + + sprintf( name, "wire: %s", wire ? wire : "none" ); + XTextExtents( finfo, name, ( int )strlen( name ), &dir, &fa, &fd, &xchar ); + x = 0; + y = fa; + XDrawImageString( dpy, pix, gc, x, y, name, ( int )strlen( name ) ); + + sprintf( name, "IR: %s", ir ? ir : "none" ); + XTextExtents( finfo, name, ( int )strlen( name ), &dir, &fa, &fd, &xchar ); + x = w - xchar.width - 1; + y = fa; + XDrawImageString( dpy, pix, gc, x, y, name, ( int )strlen( name ) ); + + x = DISPLAY_OFFSET_X; + y = conn_top; + XCopyArea( dpy, pix, keypad.pixmap, gc, 0, 0, w, h, x, + y ); /* FIXME keypad? */ + + DrawKeypad( &keypad ); + + XFreePixmap( dpy, pix ); + XFreeFont( dpy, finfo ); +} + +int get_ui_event( void ) { + XEvent xev; + XClientMessageEvent* cm; + int i, wake, bufs = 2; + char buf[ 2 ]; + KeySym sym; + // int button_expose; + // static int button_leave = -1; + static int release_pending = 0; + static XKeyEvent release_event; + static Time last_release_time = 0; + + wake = 0; + if ( paste_last_key ) { + button_released( paste[ paste_count - 1 ] ); + paste_last_key = 0; + return 1; + } else if ( paste_count < paste_size ) { + button_pressed( paste[ paste_count ] ); + paste_last_key = 1; + paste_count++; + return 1; + } + + if ( release_pending ) { + i = XLookupString( &release_event, buf, bufs, &sym, NULL ); + wake = decode_key( ( XEvent* )&release_event, sym, buf, i ); + release_pending = 0; + return wake; + } + + do { + while ( XPending( dpy ) > 0 ) { + + XNextEvent( dpy, &xev ); + + switch ( ( int )xev.type ) { + + case KeyPress: + + release_pending = 0; + if ( ( xev.xkey.time - last_release_time ) <= 1 ) { + release_pending = 0; + break; + } + + i = XLookupString( &xev.xkey, buf, bufs, &sym, NULL ); + wake = decode_key( &xev, sym, buf, i ); + first_key = 1; + break; + + case KeyRelease: + + i = XLookupString( &xev.xkey, buf, bufs, &sym, NULL ); + first_key = 0; + release_pending = 1; + last_release_time = xev.xkey.time; + memcpy( &release_event, &xev, sizeof( XKeyEvent ) ); + break; + + case NoExpose: + + break; + + case Expose: + + if ( xev.xexpose.count == 0 ) { + if ( xev.xexpose.window == disp.win ) { + DrawDisp(); + } else if ( xev.xexpose.window == iconW ) { + DrawIcon(); + } else if ( xev.xexpose.window == mainW ) { + DrawKeypad( &keypad ); + } else + for ( i = BUTTON_A; i <= LAST_BUTTON; i++ ) { + if ( xev.xexpose.window == buttons[ i ].xwin ) { + DrawButton( i ); + break; + } + } + } + break; + case UnmapNotify: + + disp.mapped = 0; + break; + + case MapNotify: + + if ( !disp.mapped ) { + disp.mapped = 1; + update_display(); + redraw_annunc(); + } + break; + + case ButtonPress: + + if ( xev.xbutton.subwindow == disp.win ) { + if ( xev.xbutton.button == Button2 ) { + if ( xev.xbutton.subwindow == disp.win ) { + int x; + int flag = 0; + char* paste_in = XFetchBuffer( dpy, &x, 0 ); + + char* p = paste_in; + if ( x > MAX_PASTE ) { + x = 0; + printf( "input too long. limit is %d " + "characters\n", + MAX_PASTE ); + } + paste_count = 0; + paste_size = 0; + while ( x-- ) { + char c = *p++; + switch ( c ) { + case '.': + paste[ paste_size++ ] = + BUTTON_PERIOD; + break; + case '0': + paste[ paste_size++ ] = BUTTON_0; + break; + case '1': + paste[ paste_size++ ] = BUTTON_1; + break; + case '2': + paste[ paste_size++ ] = BUTTON_2; + break; + case '3': + paste[ paste_size++ ] = BUTTON_3; + break; + case '4': + paste[ paste_size++ ] = BUTTON_4; + break; + case '5': + paste[ paste_size++ ] = BUTTON_5; + break; + case '6': + paste[ paste_size++ ] = BUTTON_6; + break; + case '7': + paste[ paste_size++ ] = BUTTON_7; + break; + case '8': + paste[ paste_size++ ] = BUTTON_8; + break; + case '9': + paste[ paste_size++ ] = BUTTON_9; + break; + case '\n': + paste[ paste_size++ ] = BUTTON_SHR; + paste[ paste_size++ ] = + BUTTON_PERIOD; + break; + case '!': + paste[ paste_size++ ] = + BUTTON_ALPHA; + paste[ paste_size++ ] = BUTTON_SHL; + paste[ paste_size++ ] = BUTTON_DEL; + break; + case '+': + paste[ paste_size++ ] = + BUTTON_ALPHA; + paste[ paste_size++ ] = BUTTON_PLUS; + break; + case '-': + paste[ paste_size++ ] = + BUTTON_ALPHA; + paste[ paste_size++ ] = + BUTTON_MINUS; + break; + case '*': + paste[ paste_size++ ] = + BUTTON_ALPHA; + paste[ paste_size++ ] = BUTTON_MUL; + break; + case '/': + paste[ paste_size++ ] = + BUTTON_ALPHA; + paste[ paste_size++ ] = BUTTON_DIV; + break; + case ' ': + paste[ paste_size++ ] = 47; + break; + case '(': + paste[ paste_size++ ] = BUTTON_SHL; + paste[ paste_size++ ] = BUTTON_DIV; + break; + case '[': + paste[ paste_size++ ] = BUTTON_SHL; + paste[ paste_size++ ] = BUTTON_MUL; + break; + case '<': + if ( x > 1 && *p == '<' ) { + paste[ paste_size++ ] = + BUTTON_SHL; + paste[ paste_size++ ] = + BUTTON_MINUS; + x--; + p++; + } else { + paste[ paste_size++ ] = + BUTTON_ALPHA; + paste[ paste_size++ ] = + BUTTON_SHL; + paste[ paste_size++ ] = + BUTTON_2; + } + break; + case '{': + paste[ paste_size++ ] = BUTTON_SHL; + paste[ paste_size++ ] = BUTTON_PLUS; + break; + case ')': + case ']': + case '}': + paste[ paste_size++ ] = + BUTTON_RIGHT; + break; + case '>': + if ( x > 1 && *p == '>' ) { + paste[ paste_size++ ] = + BUTTON_RIGHT; + paste[ paste_size++ ] = + BUTTON_RIGHT; + paste[ paste_size++ ] = + BUTTON_RIGHT; + x--; + p++; + } else { + paste[ paste_size++ ] = + BUTTON_ALPHA; + paste[ paste_size++ ] = + BUTTON_SHR; + paste[ paste_size++ ] = + BUTTON_2; + } + break; + case '#': + paste[ paste_size++ ] = BUTTON_SHR; + paste[ paste_size++ ] = BUTTON_DIV; + break; + case '_': + paste[ paste_size++ ] = BUTTON_SHR; + paste[ paste_size++ ] = BUTTON_MUL; + break; + case '"': + if ( flag & 1 ) { + flag &= ~1; + paste[ paste_size++ ] = + BUTTON_RIGHT; + } else { + flag |= 1; + paste[ paste_size++ ] = + BUTTON_SHR; + paste[ paste_size++ ] = + BUTTON_MINUS; + } + break; + case ':': + if ( flag & 2 ) { + flag &= ~2; + paste[ paste_size++ ] = + BUTTON_RIGHT; + } else { + flag |= 2; + paste[ paste_size++ ] = + BUTTON_SHR; + paste[ paste_size++ ] = + BUTTON_PLUS; + } + break; + case '\'': + if ( flag & 4 ) { + flag &= ~4; + paste[ paste_size++ ] = + BUTTON_RIGHT; + } else { + flag |= 4; + paste[ paste_size++ ] = + BUTTON_COLON; + } + break; + case 'a': + case 'A': + paste[ paste_size++ ] = + BUTTON_ALPHA; + if ( islower( c ) ) + paste[ paste_size++ ] = + BUTTON_SHL; + paste[ paste_size++ ] = BUTTON_A; + break; + case 'b': + case 'B': + paste[ paste_size++ ] = + BUTTON_ALPHA; + if ( islower( c ) ) + paste[ paste_size++ ] = + BUTTON_SHL; + paste[ paste_size++ ] = BUTTON_B; + break; + case 'c': + case 'C': + paste[ paste_size++ ] = + BUTTON_ALPHA; + if ( islower( c ) ) + paste[ paste_size++ ] = + BUTTON_SHL; + paste[ paste_size++ ] = BUTTON_C; + break; + case 'd': + case 'D': + paste[ paste_size++ ] = + BUTTON_ALPHA; + if ( islower( c ) ) + paste[ paste_size++ ] = + BUTTON_SHL; + paste[ paste_size++ ] = BUTTON_D; + break; + case 'e': + case 'E': + paste[ paste_size++ ] = + BUTTON_ALPHA; + if ( islower( c ) ) + paste[ paste_size++ ] = + BUTTON_SHL; + paste[ paste_size++ ] = BUTTON_E; + break; + case 'f': + case 'F': + paste[ paste_size++ ] = + BUTTON_ALPHA; + if ( islower( c ) ) + paste[ paste_size++ ] = + BUTTON_SHL; + paste[ paste_size++ ] = BUTTON_F; + break; + case 'g': + case 'G': + paste[ paste_size++ ] = + BUTTON_ALPHA; + if ( islower( c ) ) + paste[ paste_size++ ] = + BUTTON_SHL; + paste[ paste_size++ ] = BUTTON_MTH; + break; + case 'h': + case 'H': + paste[ paste_size++ ] = + BUTTON_ALPHA; + if ( islower( c ) ) + paste[ paste_size++ ] = + BUTTON_SHL; + paste[ paste_size++ ] = BUTTON_PRG; + break; + case 'i': + case 'I': + paste[ paste_size++ ] = + BUTTON_ALPHA; + if ( islower( c ) ) + paste[ paste_size++ ] = + BUTTON_SHL; + paste[ paste_size++ ] = BUTTON_CST; + break; + case 'j': + case 'J': + paste[ paste_size++ ] = + BUTTON_ALPHA; + if ( islower( c ) ) + paste[ paste_size++ ] = + BUTTON_SHL; + paste[ paste_size++ ] = BUTTON_VAR; + break; + case 'k': + case 'K': + paste[ paste_size++ ] = + BUTTON_ALPHA; + if ( islower( c ) ) + paste[ paste_size++ ] = + BUTTON_SHL; + paste[ paste_size++ ] = BUTTON_UP; + break; + case 'l': + case 'L': + paste[ paste_size++ ] = + BUTTON_ALPHA; + if ( islower( c ) ) + paste[ paste_size++ ] = + BUTTON_SHL; + paste[ paste_size++ ] = BUTTON_NXT; + break; + + case 'm': + case 'M': + paste[ paste_size++ ] = + BUTTON_ALPHA; + if ( islower( c ) ) + paste[ paste_size++ ] = + BUTTON_SHL; + paste[ paste_size++ ] = + BUTTON_COLON; + break; + case 'n': + case 'N': + paste[ paste_size++ ] = + BUTTON_ALPHA; + if ( islower( c ) ) + paste[ paste_size++ ] = + BUTTON_SHL; + paste[ paste_size++ ] = BUTTON_STO; + break; + case 'o': + case 'O': + paste[ paste_size++ ] = + BUTTON_ALPHA; + if ( islower( c ) ) + paste[ paste_size++ ] = + BUTTON_SHL; + paste[ paste_size++ ] = BUTTON_EVAL; + break; + case 'p': + case 'P': + paste[ paste_size++ ] = + BUTTON_ALPHA; + if ( islower( c ) ) + paste[ paste_size++ ] = + BUTTON_SHL; + paste[ paste_size++ ] = BUTTON_LEFT; + break; + case 'q': + case 'Q': + paste[ paste_size++ ] = + BUTTON_ALPHA; + if ( islower( c ) ) + paste[ paste_size++ ] = + BUTTON_SHL; + paste[ paste_size++ ] = BUTTON_DOWN; + break; + case 'r': + case 'R': + paste[ paste_size++ ] = + BUTTON_ALPHA; + if ( islower( c ) ) + paste[ paste_size++ ] = + BUTTON_SHL; + paste[ paste_size++ ] = + BUTTON_RIGHT; + break; + case 's': + case 'S': + paste[ paste_size++ ] = + BUTTON_ALPHA; + if ( islower( c ) ) + paste[ paste_size++ ] = + BUTTON_SHL; + paste[ paste_size++ ] = BUTTON_SIN; + break; + case 't': + case 'T': + paste[ paste_size++ ] = + BUTTON_ALPHA; + if ( islower( c ) ) + paste[ paste_size++ ] = + BUTTON_SHL; + paste[ paste_size++ ] = BUTTON_COS; + break; + case 'u': + case 'U': + paste[ paste_size++ ] = + BUTTON_ALPHA; + if ( islower( c ) ) + paste[ paste_size++ ] = + BUTTON_SHL; + paste[ paste_size++ ] = BUTTON_TAN; + break; + case 'v': + case 'V': + paste[ paste_size++ ] = + BUTTON_ALPHA; + if ( islower( c ) ) + paste[ paste_size++ ] = + BUTTON_SHL; + paste[ paste_size++ ] = BUTTON_SQRT; + break; + case 'w': + case 'W': + paste[ paste_size++ ] = + BUTTON_ALPHA; + if ( islower( c ) ) + paste[ paste_size++ ] = + BUTTON_SHL; + paste[ paste_size++ ] = + BUTTON_POWER; + break; + case 'x': + case 'X': + paste[ paste_size++ ] = + BUTTON_ALPHA; + if ( islower( c ) ) + paste[ paste_size++ ] = + BUTTON_SHL; + paste[ paste_size++ ] = BUTTON_INV; + break; + case 'y': + case 'Y': + paste[ paste_size++ ] = + BUTTON_ALPHA; + if ( islower( c ) ) + paste[ paste_size++ ] = + BUTTON_SHL; + paste[ paste_size++ ] = BUTTON_NEG; + break; + case 'z': + case 'Z': + paste[ paste_size++ ] = + BUTTON_ALPHA; + if ( islower( c ) ) + paste[ paste_size++ ] = + BUTTON_SHL; + paste[ paste_size++ ] = BUTTON_EEX; + break; + default: + printf( "unknown %c %d\n", c, *p ); + break; + } + } + if ( paste_in ) + XFree( paste_in ); + if ( paste_size ) { + return 1; + } + } + } + } else { + if ( xev.xbutton.button == Button1 || + xev.xbutton.button == Button2 || + xev.xbutton.button == Button3 ) { + for ( i = BUTTON_A; i <= LAST_BUTTON; i++ ) { + if ( xev.xbutton.subwindow == + buttons[ i ].xwin ) { + if ( buttons[ i ].pressed ) { + if ( xev.xbutton.button == Button3 ) { + button_released( i ); + DrawButton( i ); + } + } else { + last_button = i; + button_pressed( i ); + wake = 1; + first_key = 1; + DrawButton( i ); + } + break; + } + } + } + } + break; + + case ButtonRelease: + + first_key = 0; + if ( xev.xbutton.button == Button1 ) { + button_release_all(); + } + if ( xev.xbutton.button == Button2 ) { + if ( last_button >= 0 ) { + button_released( last_button ); + DrawButton( last_button ); + } + last_button = -1; + } + break; + + case FocusOut: + first_key = 0; + button_release_all(); + break; + + case MappingNotify: + + switch ( xev.xmapping.request ) { + case MappingModifier: + case MappingKeyboard: + XRefreshKeyboardMapping( &xev.xmapping ); + break; + case MappingPointer: + default: + break; + } + break; + + case EnterNotify: + case LeaveNotify: + + break; + + case ClientMessage: + + cm = ( XClientMessageEvent* )&xev; + + if ( cm->message_type == wm_protocols ) { + if ( cm->data.l[ 0 ] == wm_delete_window ) { + /* + * Quit selected from window managers menu + */ + exit_x48( 1 ); + } + + if ( cm->data.l[ 0 ] == wm_save_yourself ) { + save_command_line(); + } + } + break; + + default: + + case KeymapNotify: + case ConfigureNotify: + case ReparentNotify: + break; + } + } + } while ( first_key > 1 ); + + if ( first_key ) + first_key++; + + return wake; +} + #elif defined( GUI_IS_SDL1 ) + +void exit_x48( int tell_x11 ) { + exit_emulator(); + + exit( 0 ); +} + void SDLCreateHP( void ) { /* int x, y, w, h; */ unsigned int width, height; @@ -5691,86 +6586,7 @@ void SDLShowInformation( void ) { SDLMessageBox( 310, 280, info_title, info_text2, 0xf0c0c0e0, 0xff000000, 0 ); } -#endif -int button_pressed( int b ) { - int code; - int i, r, c; - - if ( buttons[ b ].pressed == 1 ) // Check not already pressed (may be - // important: avoids a useless do_kbd_int) - return 0; - - buttons[ b ].pressed = 1; - - code = buttons[ b ].code; - - if ( code == 0x8000 ) { - for ( i = 0; i < 9; i++ ) - saturn.keybuf.rows[ i ] |= 0x8000; - do_kbd_int(); - } else { - r = code >> 4; - c = 1 << ( code & 0xf ); - if ( ( saturn.keybuf.rows[ r ] & c ) == 0 ) { - if ( saturn.kbd_ien ) - do_kbd_int(); - if ( ( saturn.keybuf.rows[ r ] & c ) ) - fprintf( stderr, "bug\n" ); - - saturn.keybuf.rows[ r ] |= c; - } - } - - return 0; -} - -int button_released( int b ) { - int code; - - if ( buttons[ b ].pressed == - 0 ) // Check not already released (not critical) - return 0; - - buttons[ b ].pressed = 0; - - code = buttons[ b ].code; - if ( code == 0x8000 ) { - int i; - for ( i = 0; i < 9; i++ ) - saturn.keybuf.rows[ i ] &= ~0x8000; - } else { - int r, c; - r = code >> 4; - c = 1 << ( code & 0xf ); - saturn.keybuf.rows[ r ] &= ~c; - } - - return 0; -} - -#if defined( GUI_IS_X11 ) -static int button_release_all( void ) { - for ( int b = BUTTON_A; b <= LAST_BUTTON; b++ ) - if ( buttons[ b ].pressed ) { - int code = buttons[ b ].code; - if ( code == 0x8000 ) { - int i; - for ( i = 0; i < 9; i++ ) - saturn.keybuf.rows[ i ] &= ~0x8000; - } else { - int r, c; - r = code >> 4; - c = 1 << ( code & 0xf ); - saturn.keybuf.rows[ r ] &= ~c; - } - buttons[ b ].pressed = 0; - DrawButton( b ); - } - - return 0; -} -#elif defined( GUI_IS_SDL1 ) static int button_release_all( void ) { for ( int b = BUTTON_A; b <= LAST_BUTTON; b++ ) if ( buttons[ b ].pressed ) { @@ -5779,702 +6595,12 @@ static int button_release_all( void ) { return 0; } -#endif -#if defined( GUI_IS_X11 ) -void ShowConnections( char* wire, char* ir ) { - char name[ 128 ]; - int x, y, w, h; - int conn_top; - XFontStruct* finfo; - XGCValues val; - unsigned long gc_mask; - XCharStruct xchar; - int dir, fa, fd; - Pixmap pix; - - finfo = get_font_resource( dpy, "connectionFont", "ConnectionFont" ); - val.font = finfo->fid; - gc_mask = GCFont; - XChangeGC( dpy, gc, gc_mask, &val ); - - conn_top = DISPLAY_OFFSET_Y + DISPLAY_HEIGHT + 18; - - XTextExtents( finfo, "TEST", ( int )strlen( "TEST" ), &dir, &fa, &fd, - &xchar ); - w = DISPLAY_WIDTH; - h = fa + fd; - - pix = XCreatePixmap( dpy, keypad.pixmap, w, h, depth ); /* FIXME keypad? */ - XSetForeground( dpy, gc, COLOR( DISP_PAD ) ); - XFillRectangle( dpy, pix, gc, 0, 0, w, h ); - - XSetBackground( dpy, gc, COLOR( DISP_PAD ) ); - XSetForeground( dpy, gc, COLOR( LABEL ) ); - - sprintf( name, "wire: %s", wire ? wire : "none" ); - XTextExtents( finfo, name, ( int )strlen( name ), &dir, &fa, &fd, &xchar ); - x = 0; - y = fa; - XDrawImageString( dpy, pix, gc, x, y, name, ( int )strlen( name ) ); - - sprintf( name, "IR: %s", ir ? ir : "none" ); - XTextExtents( finfo, name, ( int )strlen( name ), &dir, &fa, &fd, &xchar ); - x = w - xchar.width - 1; - y = fa; - XDrawImageString( dpy, pix, gc, x, y, name, ( int )strlen( name ) ); - - x = DISPLAY_OFFSET_X; - y = conn_top; - XCopyArea( dpy, pix, keypad.pixmap, gc, 0, 0, w, h, x, - y ); /* FIXME keypad? */ - - DrawKeypad( &keypad ); - - XFreePixmap( dpy, pix ); - XFreeFont( dpy, finfo ); -} -#elif defined( GUI_IS_SDL1 ) void ShowConnections( char* wire, char* ir ) { char name[ 128 ]; fprintf( stderr, "%s\n", name ); } -#endif -#if defined( GUI_IS_X11 ) -int get_ui_event( void ) { - XEvent xev; - XClientMessageEvent* cm; - int i, wake, bufs = 2; - char buf[ 2 ]; - KeySym sym; - // int button_expose; - // static int button_leave = -1; - static int release_pending = 0; - static XKeyEvent release_event; - static Time last_release_time = 0; - - wake = 0; - if ( paste_last_key ) { - button_released( paste[ paste_count - 1 ] ); - paste_last_key = 0; - return 1; - } else if ( paste_count < paste_size ) { - button_pressed( paste[ paste_count ] ); - paste_last_key = 1; - paste_count++; - return 1; - } - - if ( release_pending ) { - i = XLookupString( &release_event, buf, bufs, &sym, NULL ); - wake = decode_key( ( XEvent* )&release_event, sym, buf, i ); - release_pending = 0; - return wake; - } - - do { - while ( XPending( dpy ) > 0 ) { - - XNextEvent( dpy, &xev ); - - switch ( ( int )xev.type ) { - - case KeyPress: - - release_pending = 0; - if ( ( xev.xkey.time - last_release_time ) <= 1 ) { - release_pending = 0; - break; - } - - i = XLookupString( &xev.xkey, buf, bufs, &sym, NULL ); - wake = decode_key( &xev, sym, buf, i ); - first_key = 1; - break; - - case KeyRelease: - - i = XLookupString( &xev.xkey, buf, bufs, &sym, NULL ); - first_key = 0; - release_pending = 1; - last_release_time = xev.xkey.time; - memcpy( &release_event, &xev, sizeof( XKeyEvent ) ); - break; - - case NoExpose: - - break; - - case Expose: - - if ( xev.xexpose.count == 0 ) { - if ( xev.xexpose.window == disp.win ) { - DrawDisp(); - } else if ( xev.xexpose.window == iconW ) { - DrawIcon(); - } else if ( xev.xexpose.window == mainW ) { - DrawKeypad( &keypad ); - } else - for ( i = BUTTON_A; i <= LAST_BUTTON; i++ ) { - if ( xev.xexpose.window == buttons[ i ].xwin ) { - DrawButton( i ); - break; - } - } - } - break; - case UnmapNotify: - - disp.mapped = 0; - break; - - case MapNotify: - - if ( !disp.mapped ) { - disp.mapped = 1; - update_display(); - redraw_annunc(); - } - break; - - case ButtonPress: - - if ( xev.xbutton.subwindow == disp.win ) { - if ( xev.xbutton.button == Button2 ) { - if ( xev.xbutton.subwindow == disp.win ) { - int x; - int flag = 0; - char* paste_in = XFetchBuffer( dpy, &x, 0 ); - - char* p = paste_in; - if ( x > MAX_PASTE ) { - x = 0; - printf( "input too long. limit is %d " - "characters\n", - MAX_PASTE ); - } - paste_count = 0; - paste_size = 0; - while ( x-- ) { - char c = *p++; - switch ( c ) { - case '.': - paste[ paste_size++ ] = - BUTTON_PERIOD; - break; - case '0': - paste[ paste_size++ ] = BUTTON_0; - break; - case '1': - paste[ paste_size++ ] = BUTTON_1; - break; - case '2': - paste[ paste_size++ ] = BUTTON_2; - break; - case '3': - paste[ paste_size++ ] = BUTTON_3; - break; - case '4': - paste[ paste_size++ ] = BUTTON_4; - break; - case '5': - paste[ paste_size++ ] = BUTTON_5; - break; - case '6': - paste[ paste_size++ ] = BUTTON_6; - break; - case '7': - paste[ paste_size++ ] = BUTTON_7; - break; - case '8': - paste[ paste_size++ ] = BUTTON_8; - break; - case '9': - paste[ paste_size++ ] = BUTTON_9; - break; - case '\n': - paste[ paste_size++ ] = BUTTON_SHR; - paste[ paste_size++ ] = - BUTTON_PERIOD; - break; - case '!': - paste[ paste_size++ ] = - BUTTON_ALPHA; - paste[ paste_size++ ] = BUTTON_SHL; - paste[ paste_size++ ] = BUTTON_DEL; - break; - case '+': - paste[ paste_size++ ] = - BUTTON_ALPHA; - paste[ paste_size++ ] = BUTTON_PLUS; - break; - case '-': - paste[ paste_size++ ] = - BUTTON_ALPHA; - paste[ paste_size++ ] = - BUTTON_MINUS; - break; - case '*': - paste[ paste_size++ ] = - BUTTON_ALPHA; - paste[ paste_size++ ] = BUTTON_MUL; - break; - case '/': - paste[ paste_size++ ] = - BUTTON_ALPHA; - paste[ paste_size++ ] = BUTTON_DIV; - break; - case ' ': - paste[ paste_size++ ] = 47; - break; - case '(': - paste[ paste_size++ ] = BUTTON_SHL; - paste[ paste_size++ ] = BUTTON_DIV; - break; - case '[': - paste[ paste_size++ ] = BUTTON_SHL; - paste[ paste_size++ ] = BUTTON_MUL; - break; - case '<': - if ( x > 1 && *p == '<' ) { - paste[ paste_size++ ] = - BUTTON_SHL; - paste[ paste_size++ ] = - BUTTON_MINUS; - x--; - p++; - } else { - paste[ paste_size++ ] = - BUTTON_ALPHA; - paste[ paste_size++ ] = - BUTTON_SHL; - paste[ paste_size++ ] = - BUTTON_2; - } - break; - case '{': - paste[ paste_size++ ] = BUTTON_SHL; - paste[ paste_size++ ] = BUTTON_PLUS; - break; - case ')': - case ']': - case '}': - paste[ paste_size++ ] = - BUTTON_RIGHT; - break; - case '>': - if ( x > 1 && *p == '>' ) { - paste[ paste_size++ ] = - BUTTON_RIGHT; - paste[ paste_size++ ] = - BUTTON_RIGHT; - paste[ paste_size++ ] = - BUTTON_RIGHT; - x--; - p++; - } else { - paste[ paste_size++ ] = - BUTTON_ALPHA; - paste[ paste_size++ ] = - BUTTON_SHR; - paste[ paste_size++ ] = - BUTTON_2; - } - break; - case '#': - paste[ paste_size++ ] = BUTTON_SHR; - paste[ paste_size++ ] = BUTTON_DIV; - break; - case '_': - paste[ paste_size++ ] = BUTTON_SHR; - paste[ paste_size++ ] = BUTTON_MUL; - break; - case '"': - if ( flag & 1 ) { - flag &= ~1; - paste[ paste_size++ ] = - BUTTON_RIGHT; - } else { - flag |= 1; - paste[ paste_size++ ] = - BUTTON_SHR; - paste[ paste_size++ ] = - BUTTON_MINUS; - } - break; - case ':': - if ( flag & 2 ) { - flag &= ~2; - paste[ paste_size++ ] = - BUTTON_RIGHT; - } else { - flag |= 2; - paste[ paste_size++ ] = - BUTTON_SHR; - paste[ paste_size++ ] = - BUTTON_PLUS; - } - break; - case '\'': - if ( flag & 4 ) { - flag &= ~4; - paste[ paste_size++ ] = - BUTTON_RIGHT; - } else { - flag |= 4; - paste[ paste_size++ ] = - BUTTON_COLON; - } - break; - case 'a': - case 'A': - paste[ paste_size++ ] = - BUTTON_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = - BUTTON_SHL; - paste[ paste_size++ ] = BUTTON_A; - break; - case 'b': - case 'B': - paste[ paste_size++ ] = - BUTTON_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = - BUTTON_SHL; - paste[ paste_size++ ] = BUTTON_B; - break; - case 'c': - case 'C': - paste[ paste_size++ ] = - BUTTON_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = - BUTTON_SHL; - paste[ paste_size++ ] = BUTTON_C; - break; - case 'd': - case 'D': - paste[ paste_size++ ] = - BUTTON_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = - BUTTON_SHL; - paste[ paste_size++ ] = BUTTON_D; - break; - case 'e': - case 'E': - paste[ paste_size++ ] = - BUTTON_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = - BUTTON_SHL; - paste[ paste_size++ ] = BUTTON_E; - break; - case 'f': - case 'F': - paste[ paste_size++ ] = - BUTTON_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = - BUTTON_SHL; - paste[ paste_size++ ] = BUTTON_F; - break; - case 'g': - case 'G': - paste[ paste_size++ ] = - BUTTON_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = - BUTTON_SHL; - paste[ paste_size++ ] = BUTTON_MTH; - break; - case 'h': - case 'H': - paste[ paste_size++ ] = - BUTTON_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = - BUTTON_SHL; - paste[ paste_size++ ] = BUTTON_PRG; - break; - case 'i': - case 'I': - paste[ paste_size++ ] = - BUTTON_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = - BUTTON_SHL; - paste[ paste_size++ ] = BUTTON_CST; - break; - case 'j': - case 'J': - paste[ paste_size++ ] = - BUTTON_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = - BUTTON_SHL; - paste[ paste_size++ ] = BUTTON_VAR; - break; - case 'k': - case 'K': - paste[ paste_size++ ] = - BUTTON_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = - BUTTON_SHL; - paste[ paste_size++ ] = BUTTON_UP; - break; - case 'l': - case 'L': - paste[ paste_size++ ] = - BUTTON_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = - BUTTON_SHL; - paste[ paste_size++ ] = BUTTON_NXT; - break; - - case 'm': - case 'M': - paste[ paste_size++ ] = - BUTTON_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = - BUTTON_SHL; - paste[ paste_size++ ] = - BUTTON_COLON; - break; - case 'n': - case 'N': - paste[ paste_size++ ] = - BUTTON_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = - BUTTON_SHL; - paste[ paste_size++ ] = BUTTON_STO; - break; - case 'o': - case 'O': - paste[ paste_size++ ] = - BUTTON_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = - BUTTON_SHL; - paste[ paste_size++ ] = BUTTON_EVAL; - break; - case 'p': - case 'P': - paste[ paste_size++ ] = - BUTTON_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = - BUTTON_SHL; - paste[ paste_size++ ] = BUTTON_LEFT; - break; - case 'q': - case 'Q': - paste[ paste_size++ ] = - BUTTON_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = - BUTTON_SHL; - paste[ paste_size++ ] = BUTTON_DOWN; - break; - case 'r': - case 'R': - paste[ paste_size++ ] = - BUTTON_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = - BUTTON_SHL; - paste[ paste_size++ ] = - BUTTON_RIGHT; - break; - case 's': - case 'S': - paste[ paste_size++ ] = - BUTTON_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = - BUTTON_SHL; - paste[ paste_size++ ] = BUTTON_SIN; - break; - case 't': - case 'T': - paste[ paste_size++ ] = - BUTTON_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = - BUTTON_SHL; - paste[ paste_size++ ] = BUTTON_COS; - break; - case 'u': - case 'U': - paste[ paste_size++ ] = - BUTTON_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = - BUTTON_SHL; - paste[ paste_size++ ] = BUTTON_TAN; - break; - case 'v': - case 'V': - paste[ paste_size++ ] = - BUTTON_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = - BUTTON_SHL; - paste[ paste_size++ ] = BUTTON_SQRT; - break; - case 'w': - case 'W': - paste[ paste_size++ ] = - BUTTON_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = - BUTTON_SHL; - paste[ paste_size++ ] = - BUTTON_POWER; - break; - case 'x': - case 'X': - paste[ paste_size++ ] = - BUTTON_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = - BUTTON_SHL; - paste[ paste_size++ ] = BUTTON_INV; - break; - case 'y': - case 'Y': - paste[ paste_size++ ] = - BUTTON_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = - BUTTON_SHL; - paste[ paste_size++ ] = BUTTON_NEG; - break; - case 'z': - case 'Z': - paste[ paste_size++ ] = - BUTTON_ALPHA; - if ( islower( c ) ) - paste[ paste_size++ ] = - BUTTON_SHL; - paste[ paste_size++ ] = BUTTON_EEX; - break; - default: - printf( "unknown %c %d\n", c, *p ); - break; - } - } - if ( paste_in ) - XFree( paste_in ); - if ( paste_size ) { - return 1; - } - } - } - } else { - if ( xev.xbutton.button == Button1 || - xev.xbutton.button == Button2 || - xev.xbutton.button == Button3 ) { - for ( i = BUTTON_A; i <= LAST_BUTTON; i++ ) { - if ( xev.xbutton.subwindow == - buttons[ i ].xwin ) { - if ( buttons[ i ].pressed ) { - if ( xev.xbutton.button == Button3 ) { - button_released( i ); - DrawButton( i ); - } - } else { - last_button = i; - button_pressed( i ); - wake = 1; - first_key = 1; - DrawButton( i ); - } - break; - } - } - } - } - break; - - case ButtonRelease: - - first_key = 0; - if ( xev.xbutton.button == Button1 ) { - button_release_all(); - } - if ( xev.xbutton.button == Button2 ) { - if ( last_button >= 0 ) { - button_released( last_button ); - DrawButton( last_button ); - } - last_button = -1; - } - break; - - case FocusOut: - first_key = 0; - button_release_all(); - break; - - case MappingNotify: - - switch ( xev.xmapping.request ) { - case MappingModifier: - case MappingKeyboard: - XRefreshKeyboardMapping( &xev.xmapping ); - break; - case MappingPointer: - default: - break; - } - break; - - case EnterNotify: - case LeaveNotify: - - break; - - case ClientMessage: - - cm = ( XClientMessageEvent* )&xev; - - if ( cm->message_type == wm_protocols ) { - if ( cm->data.l[ 0 ] == wm_delete_window ) { - /* - * Quit selected from window managers menu - */ - exit_x48( 1 ); - } - - if ( cm->data.l[ 0 ] == wm_save_yourself ) { - save_command_line(); - } - } - break; - - default: - - case KeymapNotify: - case ConfigureNotify: - case ReparentNotify: - break; - } - } - } while ( first_key > 1 ); - - if ( first_key ) - first_key++; - - return wake; -} -#elif defined( GUI_IS_SDL1 ) int get_ui_event( void ) { SDL_Event event; int hpkey; diff --git a/src/x48.h b/src/x48.h index c0f35a3..85b9c9b 100644 --- a/src/x48.h +++ b/src/x48.h @@ -1130,44 +1130,35 @@ static letter_t small_font[] = { /* #endif /\* !_SMALL_H *\/ */ +#if defined( GUI_IS_X11 ) + typedef struct color_t { const char* name; int r, g, b; -#if defined( GUI_IS_X11 ) int mono_rgb; int gray_rgb; XColor xcolor; -#endif } color_t; -extern color_t* colors; - typedef struct keypad_t { unsigned int width; unsigned int height; -#if defined( GUI_IS_X11 ) Pixmap pixmap; -#endif } keypad_t; typedef struct disp_t { unsigned int w, h; -#if defined( GUI_IS_X11 ) Window win; GC gc; -#endif short mapped; int offset; int lines; -#if defined( GUI_IS_X11 ) int display_update; XShmSegmentInfo disp_info; XImage* disp_image; XShmSegmentInfo menu_info; XImage* menu_image; -#endif } disp_t; -extern disp_t disp; typedef struct button_t { const char* name; @@ -1191,15 +1182,66 @@ typedef struct button_t { const char* right; const char* sub; -#if defined( GUI_IS_X11 ) Pixmap map; Pixmap down; Window xwin; +} button_t; + +typedef struct ann_struct { + int bit; + int x; + int y; + unsigned int width; + unsigned int height; + unsigned char* bits; + + Pixmap pixmap; +} ann_struct_t; + #elif defined( GUI_IS_SDL1 ) + +typedef struct color_t { + const char* name; + int r, g, b; +} color_t; + +typedef struct keypad_t { + unsigned int width; + unsigned int height; +} keypad_t; + +typedef struct disp_t { + unsigned int w, h; + short mapped; + int offset; + int lines; +} disp_t; + +typedef struct button_t { + const char* name; + short pressed; + short extra; + + int code; + int x, y; + unsigned int w, h; + + int lc; + const char* label; + short font_size; + unsigned int lw, lh; + unsigned char* lb; + + const char* letter; + + const char* left; + short is_menu; + const char* right; + const char* sub; + SDL_Surface* surfaceup; SDL_Surface* surfacedown; int __dummy; -#endif } button_t; // This mimicks the structure formerly lcd.c, except with SDL surfaces instead @@ -1212,22 +1254,20 @@ typedef struct ann_struct { unsigned int height; unsigned char* bits; -#if defined( GUI_IS_X11 ) - Pixmap pixmap; -#elif defined( GUI_IS_SDL1 ) SDL_Surface* surfaceon; SDL_Surface* surfaceoff; -#endif } ann_struct_t; -extern ann_struct_t ann_tbl[]; -#if defined( GUI_IS_SDL1 ) typedef struct SDLWINDOW { SDL_Surface *oldsurf, *surf; int x, y; } SDLWINDOW_t; #endif +extern color_t* colors; +extern disp_t disp; +extern ann_struct_t ann_tbl[]; + #if defined( GUI_IS_X11 ) extern int shm_flag;