@@ -501,65 +501,37 @@ void R_InitBuffer(int width, int height)
501
501
void R_FillBackColor (void )
502
502
{
503
503
extern patchnum_t stbarbg ;
504
- byte col , col_top ;
505
- int i , j , pixel_cnt ;
506
- int r , g , b ;
507
- int stbar_top = SCREENHEIGHT - ST_SCALED_HEIGHT ;
508
- int ST_SCALED_BORDER = brdr_b .height * patches_scaley /2 ;
509
- const unsigned char * playpal = V_GetPlaypal ();
510
-
511
- const byte * lump ;
512
- const byte * p ;
513
- short width ;
514
- byte length ;
515
- byte entry ;
516
-
517
- pixel_cnt = 0 ;
518
- r = g = b = 0 ;
519
-
520
- lump = W_LumpByNum (stbarbg .lumpnum );
521
- width = * ((const int16_t * ) lump );
522
- width = LittleShort (width );
523
-
524
- for (i = 0 ; i < width ; ++ i ) {
525
- // Skip irrelevant data in the doom patch header
526
- int32_t offset ;
527
- p = lump + 8 + 4 * i ;
528
- offset = * ((const int32_t * ) p );
529
- p = lump + LittleLong (offset );
530
-
531
- while (* p != 0xff ) {
532
- p ++ ;
533
- length = * p ++ ;
534
- p ++ ;
535
-
536
- // Get RGB values per pixel
537
- for (j = 0 ; j < length ; ++ j ) {
538
- entry = * p ++ ;
539
- r += playpal [3 * entry + 0 ];
540
- g += playpal [3 * entry + 1 ];
541
- b += playpal [3 * entry + 2 ];
542
- pixel_cnt ++ ;
543
- }
504
+ static byte col ;
505
+ static byte col_top ;
506
+ static int prevlump = -1 ;
507
+ const int stbar_top = SCREENHEIGHT - ST_SCALED_HEIGHT ;
508
+ const int ST_SCALED_BORDER = brdr_b .height * patches_scaley /2 ;
509
+ int lump = stbarbg .lumpnum ;
510
+
511
+ if (prevlump != lump )
512
+ {
513
+ const unsigned char * playpal = V_GetPlaypal ();
514
+ SDL_Color stbar_color = V_GetPatchColor (lump );
515
+ int r = stbar_color .r ;
516
+ int g = stbar_color .g ;
517
+ int b = stbar_color .b ;
544
518
545
- p ++ ;
546
- }
547
- }
519
+ // Convert to palette and tune down saturation
520
+ col = V_BestColor ( playpal , r / 3 , g / 3 , b / 3 );
521
+ col_top = V_BestColor ( playpal , r / 2 , g / 2 , b / 2 );
548
522
549
- // Average RGB values
550
- r /= pixel_cnt ;
551
- g /= pixel_cnt ;
552
- b /= pixel_cnt ;
523
+ // If colors are the same, brighten top
524
+ if (col_top == col )
525
+ col_top = V_BestColor (playpal , r , g , b );
553
526
554
- // Convert to palette and tune down saturation
555
- col = V_BestColor (playpal , r /3 , g /3 , b /3 );
556
- col_top = V_BestColor (playpal , r /2 , g /2 , b /2 );
527
+ prevlump = lump ;
528
+ }
557
529
558
530
V_BeginMenuDraw ();
559
- V_FillRect (1 , 0 , stbar_top , SCREENWIDTH , ST_SCALED_HEIGHT , col );
560
531
V_FillRect (1 , 0 , stbar_top , SCREENWIDTH , ST_SCALED_BORDER , col_top );
532
+ V_FillRect (1 , 0 , stbar_top + ST_SCALED_BORDER , SCREENWIDTH , ST_SCALED_HEIGHT - ST_SCALED_BORDER , col );
561
533
V_EndMenuDraw ();
562
- }
534
+ }
563
535
564
536
//
565
537
// R_FillBackScreen
0 commit comments