From dd51ede578932b1eb1a6cd57be109f39d6901a0b Mon Sep 17 00:00:00 2001 From: Gwenhael Le Moine Date: Wed, 10 Apr 2024 08:27:26 +0200 Subject: [PATCH] refactor ui_init_LCD() use --- src/debugger.c | 3 +-- src/main.c | 1 - src/runtime_options.c | 5 ++--- src/ui.c | 2 ++ src/ui.h | 5 ----- src/ui_inner.h | 1 + src/ui_sdl.c | 5 ++--- src/ui_text.c | 1 + src/ui_x11.c | 4 ++-- 9 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/debugger.c b/src/debugger.c index e0bfbc4..f36476d 100644 --- a/src/debugger.c +++ b/src/debugger.c @@ -10,7 +10,7 @@ #include "runtime_options.h" #include "emulator.h" #include "romio.h" -#include "ui.h" /* ui_init_LCD(); ui_update_LCD(); */ +#include "ui.h" /* ui_update_LCD(); */ #include "debugger.h" #define MAX_ARGS 16 @@ -3553,7 +3553,6 @@ static void cmd_load( int argc, char** argv ) free( tmp_saturn.port2 ); /* After reloading state we need to refresh the UI's LCD */ - ui_init_LCD(); ui_update_LCD(); } else { printf( "Loading emulator-state from files failed.\n" ); diff --git a/src/main.c b/src/main.c index 06f070c..89a600c 100644 --- a/src/main.c +++ b/src/main.c @@ -106,7 +106,6 @@ int main( int argc, char** argv ) init_display(); /* (G)UI */ - ui_init_LCD(); setup_frontend(); /* points init_ui to the correct function */ init_ui( argc, argv ); diff --git a/src/runtime_options.c b/src/runtime_options.c index e1f6262..4313d80 100644 --- a/src/runtime_options.c +++ b/src/runtime_options.c @@ -467,10 +467,9 @@ int parse_args( int argc, char* argv[] ) if ( !normalize_config_dir() ) { fprintf( stderr, "Configuration directory doesn't exist!\n" ); - exit(1); + exit( 1 ); } - /**********************/ /* 1. read config.lua */ /**********************/ @@ -655,7 +654,7 @@ int parse_args( int argc, char* argv[] ) /* normalize config_dir again in case it's been modified */ if ( !normalize_config_dir() ) { fprintf( stderr, "Configuration directory doesn't exist!\n" ); - exit(1); + exit( 1 ); } normalize_filenames(); diff --git a/src/ui.c b/src/ui.c index 759a8c1..c275e3a 100644 --- a/src/ui.c +++ b/src/ui.c @@ -178,6 +178,8 @@ void setup_frontend( void ) init_ui = init_text_ui; break; } + + ui_init_LCD(); } int SmallTextWidth( const char* string, unsigned int length ) diff --git a/src/ui.h b/src/ui.h index 3bb8616..49bd6f3 100644 --- a/src/ui.h +++ b/src/ui.h @@ -67,10 +67,5 @@ extern void ( *ui_draw_annunc )( void ); /*******************/ extern void ( *init_ui )( int argc, char** argv ); -/*********************************/ -/* used in: debugger.c */ -/*********************************/ -extern void ui_init_LCD( void ); - extern void setup_frontend( void ); #endif /* !_UI_H */ diff --git a/src/ui_inner.h b/src/ui_inner.h index 27e28e4..c078db8 100644 --- a/src/ui_inner.h +++ b/src/ui_inner.h @@ -566,5 +566,6 @@ static unsigned char equal_gx_bitmap[] = { 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0 /* functions */ /*************/ extern int SmallTextWidth( const char* string, unsigned int length ); +extern void ui_init_LCD( void ); #endif /* _UI_INNER_H */ diff --git a/src/ui_sdl.c b/src/ui_sdl.c index 71f7cc1..ef5ce88 100644 --- a/src/ui_sdl.c +++ b/src/ui_sdl.c @@ -1956,7 +1956,7 @@ void sdl_update_LCD( void ) } } } else - memset( lcd_nibbles_buffer, 0xf0, sizeof( lcd_nibbles_buffer ) ); + ui_init_LCD(); } void sdl_refresh_LCD( void ) {} @@ -2029,8 +2029,7 @@ void sdl_adjust_contrast() SDLCreateAnnunc(); // redraw LCD - memset( lcd_nibbles_buffer, 0, sizeof( lcd_nibbles_buffer ) ); - + ui_init_LCD(); sdl_update_LCD(); // redraw annunc diff --git a/src/ui_text.c b/src/ui_text.c index 94c6cfa..da78697 100644 --- a/src/ui_text.c +++ b/src/ui_text.c @@ -16,6 +16,7 @@ #include "runtime_options.h" /* mono, gray, small, tiny, progname */ #include "ui.h" /* last_annunc_state, lcd_nibbles_buffer, DISP_ROWS */ +#include "ui_inner.h" #define LCD_WIDTH 131 #define LCD_HEIGHT 64 diff --git a/src/ui_x11.c b/src/ui_x11.c index da3ee95..e42f468 100644 --- a/src/ui_x11.c +++ b/src/ui_x11.c @@ -2411,7 +2411,7 @@ void refresh_display( void ) void redraw_display( void ) { XClearWindow( dpy, lcd.win ); - memset( lcd_nibbles_buffer, 0, sizeof( lcd_nibbles_buffer ) ); + ui_init_LCD(); x11_update_LCD(); } @@ -3597,7 +3597,7 @@ void x11_update_LCD( void ) memset( lcd.menu_image->data, 0, ( size_t )( lcd.menu_image->bytes_per_line * lcd.menu_image->height ) ); lcd.display_update = UPDATE_DISP | UPDATE_MENU; } else { - memset( lcd_nibbles_buffer, 0xf0, sizeof( lcd_nibbles_buffer ) ); + ui_init_LCD(); for ( i = 0; i < 64; i++ ) { for ( j = 0; j < NIBBLES_PER_ROW; j++ ) { draw_nibble( j, i, 0x00 );