@@ -185,13 +185,14 @@ static void load_controller_base(void)
185185 }
186186
187187 if (controller_base ) {
188+ int y , x ;
188189 for (y = 0 ; y < height ; y ++ ) {
189190 for (x = 0 ; x < width ; x ++ ) {
190- pixel = img_data + (y * width + x ) * 4 ;
191- alpha = pixel [3 ];
192- r = pixel [0 ];
193- g = pixel [1 ];
194- b = pixel [2 ];
191+ unsigned char * pixel = img_data + (y * width + x ) * 4 ;
192+ unsigned int alpha = pixel [3 ];
193+ unsigned int r = pixel [0 ];
194+ unsigned int g = pixel [1 ];
195+ unsigned int b = pixel [2 ];
195196 controller_base [y * width + x ] = (alpha << 24 ) | (r << 16 ) | (g << 8 ) | b ;
196197 }
197198 }
@@ -326,13 +327,14 @@ static void load_overlay_for_rom(const char* rom_path, const char* system_dir)
326327 overlay_buffer = (unsigned int * )malloc (width * height * sizeof (unsigned int ));
327328
328329 if (overlay_buffer ) {
330+ int y , x ;
329331 for (y = 0 ; y < height ; y ++ ) {
330332 for (x = 0 ; x < width ; x ++ ) {
331- pixel = img_data + (y * width + x ) * 4 ;
332- alpha = pixel [3 ];
333- r = pixel [0 ];
334- g = pixel [1 ];
335- b = pixel [2 ];
333+ unsigned char * pixel = img_data + (y * width + x ) * 4 ;
334+ unsigned int alpha = pixel [3 ];
335+ unsigned int r = pixel [0 ];
336+ unsigned int g = pixel [1 ];
337+ unsigned int b = pixel [2 ];
336338 overlay_buffer [y * width + x ] = (alpha << 24 ) | (r << 16 ) | (g << 8 ) | b ;
337339 }
338340 }
@@ -347,6 +349,7 @@ static void load_overlay_for_rom(const char* rom_path, const char* system_dir)
347349 overlay_height = 600 ;
348350 overlay_buffer = (unsigned int * )malloc (overlay_width * overlay_height * sizeof (unsigned int ));
349351 if (overlay_buffer ) {
352+ int y , x ;
350353 for (y = 0 ; y < overlay_height ; y ++ ) {
351354 for (x = 0 ; x < overlay_width ; x ++ ) {
352355 if (y < overlay_height / 2 && x < overlay_width / 2 )
@@ -379,30 +382,18 @@ static void render_multi_screen(void)
379382 int src_y , src_x , workspace_x , workspace_y ;
380383 unsigned int bg_color ;
381384 int overlay_x , overlay_y , overlay_workspace_x , overlay_workspace_y ;
382- unsigned int overlay_pixel , overlay_pixel_val ;
385+ unsigned int overlay_pixel ;
383386 int banner_start_x , banner_start_y ;
384387 int banner_x , banner_y ;
385388 int banner_workspace_x , banner_workspace_y ;
386389 unsigned int banner_pixel ;
387390 unsigned int existing ;
388391 int blended_r , blended_g , blended_b ;
389392 float alpha ;
390- int button_idx , btn_y , btn_x ;
393+ int button_idx , btn_y , btn_x , utility_bg_color ;
391394 int color ;
392395 int hotspot_idx , workspace_idx ;
393- int layer , offset , corner_cut ;
394- unsigned int border_colors [7 ];
395- int util_border_x1 , util_border_x2 , util_border_y1 , util_border_y2 ;
396- unsigned int pixel , base_pixel ;
397- unsigned int inv_alpha ;
398- unsigned int base_r , base_g , base_b ;
399- unsigned int bg_r , bg_g , bg_b ;
400- int ctrl_base_x_offset , overlay_x_offset , ctrl_x ;
401- unsigned int utility_bg_color ;
402- unsigned int r , g , b ;
403- unsigned int existing_r , existing_g , existing_b ;
404- int hotspot_x_adjust ;
405- unsigned int highlight_color ;
396+ int layer ;
406397
407398 if (!multi_screen_enabled ) return ;
408399
@@ -584,7 +575,7 @@ static void render_multi_screen(void)
584575 }
585576 } else {
586577 /* Fallback: Draw dark background if banner not loaded */
587- utility_bg_color = 0xFF1a2a3a ; /* Dark blue-gray */
578+ unsigned int utility_bg_color = 0xFF1a2a3a ; /* Dark blue-gray */
588579 for (y = 448 ; y < 600 ; y ++ ) {
589580 if (y >= WORKSPACE_HEIGHT ) break ;
590581 for (x = game_x_offset ; x < game_x_offset + GAME_SCREEN_WIDTH ; x ++ ) {
@@ -612,9 +603,10 @@ static void render_multi_screen(void)
612603
613604 /* Draw each layer from outside to inside */
614605 for (layer = 0 ; layer < 7 ; layer ++ ) {
615- offset = layer ;
616- color = border_colors [layer ];
617- corner_cut = offset ; /* Amount to cut corners at 45° angle */
606+ int offset = layer ;
607+ unsigned int color = border_colors [layer ];
608+ int corner_cut = offset ; /* Amount to cut corners at 45° angle */
609+ int i ;
618610
619611 /* Top border line */
620612 for (y = util_border_y1 + offset ; y < util_border_y1 + offset + 1 ; y ++ ) {
@@ -688,12 +680,12 @@ static void render_multi_screen(void)
688680 /* === HOTSPOT HIGHLIGHTING - Show which buttons are pressed by touch === */
689681 /* Highlight all pressed hotspots (from touch input detection) */
690682 /* When display_swap is true, hotspots translate from right side to left side */
691- hotspot_x_adjust = display_swap ? (- GAME_SCREEN_WIDTH ) : 0 ;
683+ int hotspot_x_adjust = display_swap ? (- GAME_SCREEN_WIDTH ) : 0 ;
692684
693685 for (i = 0 ; i < OVERLAY_HOTSPOT_COUNT ; i ++ ) {
694686 if (hotspot_pressed [i ]) {
695687 overlay_hotspot_t * h = & overlay_hotspots [i ];
696- highlight_color = 0xAA00FF00 ; /* Green highlight for touch-pressed */
688+ unsigned int highlight_color = 0xAA00FF00 ; /* Green highlight for touch-pressed */
697689
698690 for (y = h -> y ; y < h -> y + h -> height ; ++ y ) {
699691 if (y >= WORKSPACE_HEIGHT ) continue ;
0 commit comments