Skip to content

Commit

Permalink
one less variable
Browse files Browse the repository at this point in the history
  • Loading branch information
gwenhael-le-moine committed Jun 13, 2024
1 parent 554aa45 commit 60d08c6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
18 changes: 9 additions & 9 deletions src/ui_sdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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();
Expand Down
8 changes: 4 additions & 4 deletions src/ui_text.c
Original file line number Diff line number Diff line change
Expand Up @@ -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(); }
Expand Down
7 changes: 3 additions & 4 deletions src/ui_x11.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 60d08c6

Please sign in to comment.