From 60d08c61d53c8d88f2af091cdcd3b94643da45f0 Mon Sep 17 00:00:00 2001 From: Gwenhael Le Moine Date: Thu, 13 Jun 2024 16:34:43 +0200 Subject: [PATCH] one less variable --- src/ui_sdl.c | 18 +++++++++--------- src/ui_text.c | 8 ++++---- src/ui_x11.c | 7 +++---- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/ui_sdl.c b/src/ui_sdl.c index d038c63..e2f5e34 100644 --- a/src/ui_sdl.c +++ b/src/ui_sdl.c @@ -95,7 +95,7 @@ static SDL_Surface* bitmap_to_surface( unsigned int w, unsigned int h, unsigned // Look for the bit in that byte char b = c & ( 1 << ( x & 7 ) ); - lineptr[ x ] = (b) ? coloron : coloroff; + lineptr[ x ] = ( b ) ? coloron : coloroff; } } @@ -169,7 +169,7 @@ static void colors_setup( void ) // This should be called once to setup the surfaces. Calling it multiple // times is fine, it won't do anything on subsequent calls. -static void create_annunc( void ) +static void create_annunciators_surfaces( void ) { for ( int i = 0; i < NB_ANNUNCIATORS; i++ ) { // If the SDL surface does not exist yet, we create it on the fly @@ -1367,17 +1367,16 @@ void sdl_menu_draw_nibble( word_20 addr, word_4 val ) void sdl_draw_annunc( void ) { - int val = saturn.annunc; - if ( val == last_annunc_state ) + if ( saturn.annunc == last_annunc_state ) return; - last_annunc_state = val; + last_annunc_state = saturn.annunc; - create_annunc(); + create_annunciators_surfaces(); bool annunc_state; for ( int i = 0; i < NB_ANNUNCIATORS; i++ ) { - annunc_state = ( ( annunciators_bits[ i ] & val ) == annunciators_bits[ i ] ); + annunc_state = ( ( annunciators_bits[ i ] & saturn.annunc ) == annunciators_bits[ i ] ); SDL_Rect srect; SDL_Rect drect; @@ -1390,7 +1389,8 @@ void sdl_draw_annunc( void ) drect.w = ann_tbl[ i ].width; drect.h = ann_tbl[ i ].height; - SDL_BlitSurface( ( annunc_state ) ? annunciators_surfaces[ i ].surfaceon : annunciators_surfaces[ i ].surfaceoff, &srect, sdlwindow, &drect ); + SDL_BlitSurface( ( annunc_state ) ? annunciators_surfaces[ i ].surfaceon : annunciators_surfaces[ i ].surfaceoff, &srect, sdlwindow, + &drect ); } // Always immediately update annunciators @@ -1401,7 +1401,7 @@ void sdl_draw_annunc( void ) void sdl_adjust_contrast( void ) { colors_setup(); - create_annunc(); + create_annunciators_surfaces(); // redraw LCD ui_init_LCD(); diff --git a/src/ui_text.c b/src/ui_text.c index 84a1774..49a46d1 100644 --- a/src/ui_text.c +++ b/src/ui_text.c @@ -349,15 +349,15 @@ void text_menu_draw_nibble( word_20 addr, word_4 val ) void text_draw_annunc( void ) { const wchar_t* annunciators_icons[ 6 ] = { L"↰", L"↱", L"α", L"🪫", L"⌛", L"⇄" }; - int val = saturn.annunc; - if ( val == last_annunc_state ) + if ( saturn.annunc == last_annunc_state ) return; - last_annunc_state = val; + last_annunc_state = saturn.annunc; for ( int i = 0; i < NB_ANNUNCIATORS; i++ ) - mvaddwstr( 0, 4 + ( i * 4 ), ( ( annunciators_bits[ i ] & val ) == annunciators_bits[ i ] ) ? annunciators_icons[ i ] : L" " ); + mvaddwstr( 0, 4 + ( i * 4 ), + ( ( annunciators_bits[ i ] & saturn.annunc ) == annunciators_bits[ i ] ) ? annunciators_icons[ i ] : L" " ); } void text_adjust_contrast( void ) { text_update_LCD(); } diff --git a/src/ui_x11.c b/src/ui_x11.c index 68b7ddc..7a3fe2c 100644 --- a/src/ui_x11.c +++ b/src/ui_x11.c @@ -3168,14 +3168,13 @@ void x11_menu_draw_nibble( word_20 addr, word_4 val ) void x11_draw_annunc( void ) { - int val = saturn.annunc; - if ( val == last_annunc_state ) + if ( saturn.annunc == last_annunc_state ) return; - last_annunc_state = val; + last_annunc_state = saturn.annunc; for ( int i = 0; i < NB_ANNUNCIATORS; i++ ) - if ( ( annunciators_bits[ i ] & val ) == annunciators_bits[ i ] ) + if ( ( annunciators_bits[ i ] & saturn.annunc ) == annunciators_bits[ i ] ) XCopyPlane( dpy, x11_ann_pixmaps[ i ], lcd.win, lcd.gc, 0, 0, ann_tbl[ i ].width, ann_tbl[ i ].height, ann_tbl[ i ].x, ann_tbl[ i ].y, 1 ); else