@@ -2531,32 +2531,21 @@ private void UpdateRom()
25312531
25322532 if ( props . ShuffleEnemyPalettes )
25332533 {
2534- List < int > doubleLocs = [ 0x40b4 , 0x80b4 , 0x100b4 , 0x100b8 , 0x100bc , 0x140b4 , 0x140b8 , 0x140bc ] ;
2535- List < int > singleLocs = [ 0x40b8 , 0x40bc , 0x80b8 , 0x80bc ] ;
2534+ Random customizationRng = new Random ( SeedHash ) ;
2535+ RerollPaletteTable ( RomMap . WEST_PALETTE_TABLE , customizationRng ) ;
2536+ RerollPaletteTable ( RomMap . EAST_PALETTE_TABLE , customizationRng ) ;
2537+ RerollPaletteTable ( RomMap . TOWN_PALETTE_TABLE , customizationRng ) ;
2538+ RerollPaletteTable ( RomMap . PALACE_PALETTE_TABLE_MAJOR , customizationRng ) ;
2539+ RerollPaletteTable ( RomMap . GP_PALETTE_TABLE_MAJOR , customizationRng ) ;
25362540
2537- foreach ( int i in doubleLocs )
2538- {
2539- int low = r . Next ( 12 ) + 1 ;
2540- int high = ( r . Next ( 2 ) + 1 ) * 16 ;
2541- int color = high + low ;
2542- ROMData . Put ( i , ( byte ) color ) ;
2543- ROMData . Put ( i + 16 , ( byte ) color ) ;
2544- ROMData . Put ( i - 1 , ( byte ) ( color - 15 ) ) ;
2545- ROMData . Put ( i + 16 - 1 , ( byte ) ( color - 15 ) ) ;
2546- }
2547- foreach ( int i in singleLocs )
2548- {
2549- int low = r . Next ( 13 ) ;
2550- int high = ( r . Next ( 3 ) ) * 16 ;
2551- int color = high + low ;
2552- ROMData . Put ( i , ( byte ) color ) ;
2553- ROMData . Put ( i + 16 , ( byte ) color ) ;
2554- ROMData . Put ( i + 16 - 1 , ( byte ) ( color - 15 ) ) ;
2555- }
2541+ /*
2542+ lets no longer shuffle orange/red/blue bits for enemies, it changes
2543+ what is visible in the dark and also doesn't add enough to be worth it imo.
2544+ I also prefer if we can have the palette shuffle as a customize (non-flag) option.
25562545
2557- for ( int i = 0x54e8 ; i < 0x5508 ; i ++ )
2546+ for (int i = RomMap.WEST_ENEMY_STATS_TABLE + 0x3 ; i < RomMap.WEST_ENEMY_STATS_TABLE + 0x23 ; i++)
25582547 {
2559- if ( i != 0x54f8 )
2548+ if (i != RomMap.WEST_ENEMY_STATS_TABLE + 0x13) // skip elevator
25602549 {
25612550 int b = ROMData.GetByte(i);
25622551 int p = b & 0x3F;
@@ -2565,7 +2554,6 @@ private void UpdateRom()
25652554 ROMData.Put(i, (byte)(n + p));
25662555 }
25672556 }
2568-
25692557 for (int i = 0x94e8; i < 0x9508; i++)
25702558 {
25712559 if (i != 0x94f8)
@@ -2610,6 +2598,7 @@ private void UpdateRom()
26102598 ROMData.Put(i, (byte)(n + p));
26112599 }
26122600 }
2601+ */
26132602 }
26142603
26152604 //WRITE UPDATES TO WIZARD/QUEST COLLECTABLES HERE
@@ -2827,6 +2816,104 @@ private void UpdateRom()
28272816 }
28282817 }
28292818
2819+ private void RerollPaletteTable ( int paletteTableAddr , Random r )
2820+ {
2821+ byte dark , middle , light ;
2822+
2823+ // we are NOT rolling the white color for magic/interface that should match the orange sprite light
2824+ // (white looks fine with all 2 other sprite colors anyway)
2825+ // int[] magicBgColorAddr = [paletteTableAddr + 0x01, paletteTableAddr + 0x11];
2826+ // we ARE rolling the red sprite and matching the red tile color for the life bars to it
2827+ // (it would limit the palette a lot if the red color has to stay red)
2828+ List < int > lifeBgColorAddr = [ .. Enumerable . Range ( 0 , 9 ) . Select ( i => paletteTableAddr + 0x10 * i + 0x03 ) ] ;
2829+ List < int > orangeSpriteColorAddr = [ paletteTableAddr + 0x94 ] ;
2830+ List < int > redSpriteColorAddr = [ paletteTableAddr + 0x98 ] ;
2831+ List < int > blueSpriteColorAddr = [ paletteTableAddr + 0x9c ] ;
2832+
2833+ List < int > darkRangeFull = [ .. Enumerable . Range ( 0x01 , 12 ) , .. Enumerable . Range ( 0x11 , 13 ) , 0x2d ] ;
2834+ // we make the life color range slightly narrower, to not make the HUD look too awful
2835+ List < int > darkRangeLife = [ .. Enumerable . Range ( 0x04 , 3 ) , .. Enumerable . Range ( 0x13 , 5 ) , .. Enumerable . Range ( 0x19 , 4 ) ] ;
2836+ // brighter dark colors do not look good in towns
2837+ List < int > darkRangeTown = [ .. Enumerable . Range ( 0x01 , 12 ) , 0x1d ] ;
2838+
2839+ if ( paletteTableAddr == RomMap . PALACE_PALETTE_TABLE_MAJOR )
2840+ {
2841+ orangeSpriteColorAddr . AddRange ( Enumerable . Range ( 0 , 3 ) . Select ( i => paletteTableAddr + 0xa4 + 0x10 * i ) ) ;
2842+ // additional per-palace palettes
2843+ lifeBgColorAddr . AddRange ( Enumerable . Range ( 0 , 6 ) . Select ( i => RomMap . PALACE_PALETTE_TABLE_ENTRANCES + 0x10 * i + 0x03 ) ) ;
2844+ lifeBgColorAddr . AddRange ( Enumerable . Range ( 0 , 6 ) . Select ( i => RomMap . PALACE_PALETTE_TABLE_PER_PALACE + 0x10 * i + 0x03 ) ) ;
2845+ }
2846+ if ( paletteTableAddr == RomMap . GP_PALETTE_TABLE_MAJOR )
2847+ {
2848+ lifeBgColorAddr . Add ( 0x1c48f + 0x03 ) ; // palette PPU cmd when fading to Dark Link
2849+ lifeBgColorAddr . Add ( 0x1c4a3 + 0x03 ) ; // palette PPU cmd when Dark Link has been defeated
2850+ orangeSpriteColorAddr . Add ( paletteTableAddr + 0xa4 ) ;
2851+ orangeSpriteColorAddr . Add ( paletteTableAddr + 0xc4 ) ;
2852+ redSpriteColorAddr . Add ( paletteTableAddr + 0xa8 ) ;
2853+ blueSpriteColorAddr . Add ( paletteTableAddr + 0xac ) ;
2854+ }
2855+ if ( paletteTableAddr == RomMap . TOWN_PALETTE_TABLE )
2856+ {
2857+ var stabguy = paletteTableAddr + 0xac ;
2858+ List < int > wizardAddr = [ .. Enumerable . Range ( 0 , 4 ) . Select ( i => paletteTableAddr + 0xa4 + 0x10 * i ) ] ;
2859+ orangeSpriteColorAddr . AddRange ( wizardAddr ) ;
2860+ ( dark , middle , light ) = NES . RollMatchingColorTriple ( r , darkRangeFull ) ;
2861+ ROMData . Put ( stabguy + 1 , dark ) ;
2862+ ROMData . Put ( stabguy + 2 , middle ) ;
2863+ ROMData . Put ( stabguy + 3 , light ) ;
2864+ }
2865+ if ( paletteTableAddr == RomMap . WEST_PALETTE_TABLE || paletteTableAddr == RomMap . EAST_PALETTE_TABLE )
2866+ {
2867+ orangeSpriteColorAddr . AddRange ( Enumerable . Range ( 0 , 4 ) . Select ( i => paletteTableAddr + 0xa4 + 0x10 * i ) ) ;
2868+ redSpriteColorAddr . Add ( paletteTableAddr + 0xa8 ) ;
2869+ blueSpriteColorAddr . Add ( paletteTableAddr + 0xac ) ;
2870+ }
2871+
2872+ List < List < int > > tripples = [ orangeSpriteColorAddr , redSpriteColorAddr , blueSpriteColorAddr ] ;
2873+ List < int > usedColors = [ ] ;
2874+ if ( paletteTableAddr == RomMap . TOWN_PALETTE_TABLE )
2875+ {
2876+ usedColors . Add ( 0x22 ) ; // blue sky
2877+ }
2878+
2879+ foreach ( List < int > list in tripples )
2880+ {
2881+ bool isOrange = list == orangeSpriteColorAddr ;
2882+
2883+ List < int > darkRange = ( paletteTableAddr , isOrange ) switch
2884+ {
2885+ ( RomMap . TOWN_PALETTE_TABLE , true ) => darkRangeTown . Intersect ( darkRangeLife ) . ToList ( ) ,
2886+ ( RomMap . TOWN_PALETTE_TABLE , false ) => darkRangeTown ,
2887+ ( RomMap . GP_PALETTE_TABLE_MAJOR , true ) => darkRangeLife . Where ( x => x != 0x14 && x != 0x15 ) . ToList ( ) ,
2888+ ( _, true ) => darkRangeLife ,
2889+ ( _, false ) => darkRangeFull ,
2890+ } ;
2891+
2892+ do
2893+ {
2894+ ( dark , middle , light ) = NES . RollMatchingColorTriple ( r , darkRange ) ;
2895+ } while ( ( dark != 0x2d && usedColors . Contains ( dark ) ) ||
2896+ usedColors . Contains ( middle ) ||
2897+ ( light != 0x30 && usedColors . Contains ( light ) ) ) ;
2898+
2899+ // prevent adjacent colors from being picked again
2900+ usedColors . AddRange ( Enumerable . Range ( - 1 , 3 ) . Select ( i => dark + i ) ) ;
2901+ usedColors . AddRange ( Enumerable . Range ( - 1 , 3 ) . Select ( i => middle + i ) ) ;
2902+ usedColors . AddRange ( Enumerable . Range ( - 1 , 3 ) . Select ( i => light + i ) ) ;
2903+
2904+ foreach ( var i in list )
2905+ {
2906+ ROMData . Put ( i + 1 , dark ) ;
2907+ ROMData . Put ( i + 2 , middle ) ;
2908+ if ( list != orangeSpriteColorAddr ) { ROMData . Put ( i + 3 , light ) ; }
2909+ }
2910+ if ( list == orangeSpriteColorAddr )
2911+ {
2912+ foreach ( var j in lifeBgColorAddr ) { ROMData . Put ( j , dark ) ; }
2913+ }
2914+ }
2915+ }
2916+
28302917 public void RandomizeSmallItems ( int world , bool first )
28312918 {
28322919 logger . Debug ( "World: " + world ) ;
0 commit comments