Skip to content

Commit

Permalink
variables declaration style
Browse files Browse the repository at this point in the history
  • Loading branch information
gwenhael-le-moine committed Jun 13, 2024
1 parent 60d08c6 commit 14fd31d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 42 deletions.
19 changes: 7 additions & 12 deletions src/ui_sdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1334,33 +1334,28 @@ void sdl_refresh_LCD( void ) {}

void sdl_disp_draw_nibble( word_20 addr, word_4 val )
{
long offset;
int x, y;
long offset = ( addr - display.disp_start );
int x = offset % display.nibs_per_line;

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;
int y = offset / display.nibs_per_line;
if ( y < 0 || y > 63 )
return;

draw_nibble( x, y, val );
} else
for ( y = 0; y < display.lines; y++ )
for ( int y = 0; y < display.lines; y++ )
draw_nibble( x, y, val );
}

void sdl_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;
long offset = ( addr - display.menu_start );
int x = offset % NIBBLES_PER_ROW;
int y = display.lines + ( offset / NIBBLES_PER_ROW ) + 1;

draw_nibble( x, y, val );
}
Expand Down
19 changes: 7 additions & 12 deletions src/ui_text.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,15 +304,13 @@ void text_update_LCD( void )
/* TODO: duplicate of ui_sdl.c:sdl_disp_draw_nibble() */
void text_disp_draw_nibble( word_20 addr, word_4 val )
{
long offset;
int x, y;
long offset = ( addr - display.disp_start );
int x = offset % display.nibs_per_line;

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;
int y = offset / display.nibs_per_line;
if ( y < 0 || y > 63 )
return;

Expand All @@ -321,7 +319,7 @@ void text_disp_draw_nibble( word_20 addr, word_4 val )

lcd_nibbles_buffer[ y ][ x ] = val;
} else {
for ( y = 0; y < display.lines; y++ ) {
for ( int y = 0; y < display.lines; y++ ) {
if ( val == lcd_nibbles_buffer[ y ][ x ] )
break;

Expand All @@ -333,12 +331,9 @@ void text_disp_draw_nibble( word_20 addr, word_4 val )
/* TODO: duplicate of ui_sdl.c:sdl_menu_draw_nibble() */
void text_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;
long offset = ( addr - display.menu_start );
int x = offset % NIBBLES_PER_ROW;
int y = display.lines + ( offset / NIBBLES_PER_ROW ) + 1;

if ( val == lcd_nibbles_buffer[ y ][ x ] )
return;
Expand Down
29 changes: 11 additions & 18 deletions src/ui_x11.c
Original file line number Diff line number Diff line change
Expand Up @@ -3109,58 +3109,51 @@ void x11_update_LCD( void )

void x11_disp_draw_nibble( word_20 addr, word_4 val )
{
long offset;
int shm_addr;
int x, y;
long offset = ( addr - display.disp_start );
int x = offset % display.nibs_per_line;

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;
int y = offset / display.nibs_per_line;
if ( y < 0 || y > 63 )
return;

if ( shm_flag ) {
shm_addr = ( 2 * y * lcd.disp_image->bytes_per_line ) + x;
int shm_addr = ( 2 * y * lcd.disp_image->bytes_per_line ) + x;
lcd.disp_image->data[ shm_addr ] = nibble_bitmap[ val ];
lcd.disp_image->data[ shm_addr + lcd.disp_image->bytes_per_line ] = nibble_bitmap[ val ];
lcd.display_update |= UPDATE_DISP;
} else
draw_nibble( x, y, val );
} else {
if ( shm_flag ) {
shm_addr = x;
for ( y = 0; y < display.lines; y++ ) {
int shm_addr = x;
for ( int y = 0; y < display.lines; y++ ) {
lcd.disp_image->data[ shm_addr ] = nibble_bitmap[ val ];
shm_addr += lcd.disp_image->bytes_per_line;
lcd.disp_image->data[ shm_addr ] = nibble_bitmap[ val ];
shm_addr += lcd.disp_image->bytes_per_line;
}
lcd.display_update |= UPDATE_DISP;
} else
for ( y = 0; y < display.lines; y++ )
for ( int y = 0; y < display.lines; y++ )
draw_nibble( x, y, val );
}
}

void x11_menu_draw_nibble( word_20 addr, word_4 val )
{
long offset;
int shm_addr;
int x, y;

offset = ( addr - display.menu_start );
long offset = ( addr - display.menu_start );
if ( shm_flag ) {
shm_addr = 2 * ( offset / NIBBLES_PER_ROW ) * lcd.menu_image->bytes_per_line + ( offset % NIBBLES_PER_ROW );
int shm_addr = 2 * ( offset / NIBBLES_PER_ROW ) * lcd.menu_image->bytes_per_line + ( offset % NIBBLES_PER_ROW );
lcd.menu_image->data[ shm_addr ] = nibble_bitmap[ val ];
lcd.menu_image->data[ shm_addr + lcd.menu_image->bytes_per_line ] = nibble_bitmap[ val ];
lcd.display_update |= UPDATE_MENU;
} else {
x = offset % NIBBLES_PER_ROW;
y = display.lines + ( offset / NIBBLES_PER_ROW ) + 1;
int x = offset % NIBBLES_PER_ROW;
int y = display.lines + ( offset / NIBBLES_PER_ROW ) + 1;

draw_nibble( x, y, val );
}
Expand Down

0 comments on commit 14fd31d

Please sign in to comment.