Golden Sun Hacking Community

Golden Sun Resources => Misc. GS Hacking => Topic started by: Triyence on 18, November, 2014, 03:13:20 PM

Title: Casting psynergy in TLA makes the BG fade to a random color, how does it work?
Post by: Triyence on 18, November, 2014, 03:13:20 PM
I'm getting nowhere asking color interpolation questions on forums so since the source of the effect I'm trying to duplicate comes from Golden Sun I figure I might as well ask here.

When you cast psynergy (I'm referencing GS:TLA) the background will fade to a random color, be it orange, blue, red, grey etc... I want to know how it does it. Specifically, how does it choose an end color and how does it determine at what rate the pixels should decrement their color components by.

Here is an example:

(http://i.imgur.com/vJrkC2Y.png)(http://i.imgur.com/cIuTFOB.png)
(http://i.imgur.com/tcpXnas.png)(http://i.imgur.com/kYqJHwc.png)
(http://i.imgur.com/7Xd29Ll.png)(http://i.imgur.com/6E8YCK9.png)

So obviously, it's fading to blue, but how is it doing it? Here is the data for 5 random, non-black pixels, changing over the 6 pictures:


╔══════════════════╦═════╦═════╦═════╦════════╦═══════╦═══════╦═════════╗
║ Sample.Iteration ║  R  ║  G  ║  B  ║   H    ║   S   ║   V   ║   X,Y   ║
╠══════════════════╬═════╬═════╬═════╬════════╬═══════╬═══════╬═════════╣
║ 1.1              ║ 104 ║ 168 ║ 144 ║ 157.50 ║ 38.10 ║ 65.88 ║ 121,81  ║
║ 1.2              ║  96 ║ 152 ║ 144 ║ 171.43 ║ 36.84 ║ 59.61 ║ 121,81  ║
║ 1.3              ║  80 ║ 120 ║ 152 ║ 206.67 ║ 47.37 ║ 59.61 ║ 121,81  ║
║ 1.4              ║  72 ║ 104 ║ 152 ║ 216.00 ║ 52.63 ║ 59.61 ║ 121,81  ║
║ 1.5              ║  56 ║  72 ║ 160 ║ 230.77 ║ 65.00 ║ 62.75 ║ 121,81  ║
║ 1.6              ║  40 ║  40 ║ 168 ║ 240.00 ║ 76.19 ║ 65.88 ║ 121,81  ║
║                  ║     ║     ║     ║        ║       ║       ║         ║
║ 2.1              ║  72 ║ 144 ║ 128 ║ 166.67 ║ 50.00 ║ 56.47 ║ 125,119 ║
║ 2.2              ║  64 ║ 128 ║ 128 ║ 180.00 ║ 50.00 ║ 50.20 ║ 125,119 ║
║ 2.3              ║  56 ║  96 ║ 128 ║ 206.67 ║ 56.25 ║ 50.20 ║ 125,119 ║
║ 2.4              ║  48 ║  88 ║ 128 ║ 210.00 ║ 62.50 ║ 50.20 ║ 125,119 ║
║ 2.5              ║  40 ║  56 ║ 136 ║ 230.00 ║ 70.59 ║ 53.33 ║ 125,119 ║
║ 2.6              ║  32 ║  32 ║ 136 ║ 240.00 ║ 76.47 ║ 53.33 ║ 125,119 ║
║                  ║     ║     ║     ║        ║       ║       ║         ║
║ 3.1              ║ 152 ║ 208 ║ 168 ║ 137.14 ║ 26.92 ║ 81.57 ║ 80,82   ║
║ 3.2              ║ 136 ║ 184 ║ 168 ║ 160.00 ║ 26.09 ║ 72.16 ║ 80,82   ║
║ 3.3              ║ 112 ║ 144 ║ 184 ║ 213.33 ║ 39.13 ║ 72.16 ║ 80,82   ║
║ 3.4              ║  96 ║ 128 ║ 192 ║ 220.00 ║ 50.00 ║ 75.29 ║ 80,82   ║
║ 3.5              ║  72 ║  88 ║ 200 ║ 232.50 ║ 64.00 ║ 78.43 ║ 80,82   ║
║ 3.6              ║  48 ║  48 ║ 216 ║ 240.00 ║ 77.78 ║ 84.71 ║ 80,82   ║
║                  ║     ║     ║     ║        ║       ║       ║         ║
║ 4.1              ║  40 ║  72 ║ 104 ║ 210.00 ║ 61.54 ║ 40.78 ║ 158,75  ║
║ 4.2              ║  32 ║  64 ║  96 ║ 210.00 ║ 66.67 ║ 37.65 ║ 158,75  ║
║ 4.3              ║  32 ║  48 ║  88 ║ 222.86 ║ 63.64 ║ 34.51 ║ 158,75  ║
║ 4.4              ║  24 ║  40 ║  88 ║ 225.00 ║ 72.73 ║ 34.51 ║ 158,75  ║
║ 4.5              ║  24 ║  32 ║  80 ║ 231.43 ║ 70.00 ║ 31.37 ║ 158,75  ║
║ 4.6              ║  16 ║  16 ║  72 ║ 240.00 ║ 77.78 ║ 28.24 ║ 158,75  ║
║                  ║     ║     ║     ║        ║       ║       ║         ║
║ 5.1              ║ 144 ║ 192 ║ 232 ║ 207.27 ║ 37.93 ║ 90.98 ║ 127,99  ║
║ 5.2              ║ 128 ║ 168 ║ 224 ║ 215.00 ║ 42.86 ║ 87.84 ║ 127,99  ║
║ 5.3              ║ 104 ║ 136 ║ 224 ║ 224.00 ║ 53.57 ║ 87.84 ║ 127,99  ║
║ 5.4              ║  96 ║ 120 ║ 216 ║ 228.00 ║ 55.56 ║ 84.71 ║ 127,99  ║
║ 5.5              ║  72 ║  88 ║ 216 ║ 233.33 ║ 66.67 ║ 84.71 ║ 127,99  ║
║ 5.6              ║  48 ║  48 ║ 208 ║ 240.00 ║ 76.92 ║ 81.57 ║ 127,99  ║
╚══════════════════╩═════╩═════╩═════╩════════╩═══════╩═══════╩═════════╝


Some things I've found interesting about this data.


I can't seem to figure out the pattern. Any help on this would be greatly appreciated.
Title: Re: Casting psynergy in TLA makes the BG fade to a random color, how does it work?
Post by: Daddy Poi's Oily Gorillas on 18, November, 2014, 04:23:04 PM
QuoteThe RGB colors are all a multiple of 8.
The decrement and increment amounts are also all a multiple of 8.
The GBA's color palette only supports 5-bits for red, green, and blue. Which means you should find them as multiples of 8 in all GBA games.

Quotehow does it choose an end color
I have looked into this once. If I recall, the color was likely chosen randomly, and I think it's the same colors you can get as the background of the in-game Sprite Viewer which is not normally accessible in-game.

[From documentation] 080F3954 - Area palette swaps during utility use (may have other uses as well); either 8 or 9 of them, and they are read as 32-bit values

Quotehow does it determine at what rate the pixels should decrement their color components by.
Can't remember/ not sure... Maybe it's based on number of frames to be blending for?
Title: Re: Casting psynergy in TLA makes the BG fade to a random color, how does it work?
Post by: Salanewt on 18, November, 2014, 07:52:46 PM
OH! I've played around with this before. There's basically a small list of colour values that are used in some sort of function; you can change the background fading by changing these. It's the one Fox posted. Anyway, only some of those are used 100% randomly as far as I know (I think Blaze consistently uses red for example).

As far as your actual question goes, I'm like Fox as far as not knowing exactly how the game does it. I haven't really looked into it yet, but I assume it actively changes the current map's palette by using some sort of calculation that is performed based on frames or something, likely with a counter that ticks every time it performs the calculation until that counter is equal to a certain value; basically a code loop. It might even be reasonable to expect that, if not for the counter, the code would keep looping forever and just make the map all one colour or something.

I have to say though, I kind of like the middle pictures more than the end result. I might just look into it later if I have any free time, since it would be cool to be able to alter this stuff more easily and maybe even assign certain background fades to certain spells. Could you imagine if something like Douse consistently made the surrounding area more gray or blue, as if you were creating extensive cloud cover?
Title: Re: Casting psynergy in TLA makes the BG fade to a random color, how does it work?
Post by: Daddy Poi's Oily Gorillas on 18, November, 2014, 10:06:17 PM
Oh! I almost forgot about that Blaze thing always using red... (Can't believe it slipped my mind.)  So here's some other stuff in the doc that is relevant, of which I forgot to post: (It's where the coding is.)


080DC1B0 = AreaPaletteSwap(?,color) ; ?=8 for Utilities. Might be number of frames?

080DC244
080DC294 = Utility area palette swaps / Blend screen to a color
Three sections determine the color blend from 8 colors: 0-7.
First: [0300122C] & 7 ; The counter value, so it's pretty much a random number where each color has an equal chance.
Second: Color determined by utility.
Third: Story flags 0x148-0x14F are checked.
0 = Blue (Pound, Grind, A??, Cyclone)
1 =
2 = Red (Blaze)
3 =
4 =
5 = (Scoop)
6 = (Tremor)
7 = Light Gray (Burst, Sand, Parch)
Title: Re: Casting psynergy in TLA makes the BG fade to a random color, how does it work?
Post by: Triyence on 23, November, 2014, 09:31:12 PM
Thanks guys, this helped and I was able to figure it out.
Title: Re: Casting psynergy in TLA makes the BG fade to a random color, how does it work?
Post by: football2015 on 09, January, 2015, 12:42:45 AM
very good

:happy: :happy: :happy: :happy: