Author Topic: Chrono Trigger Dialogue Box Gradient?  (Read 2297 times)

Crazy Jane

  • Iokan (+1)
  • *
  • Posts: 2
  • 64 Trains of Thought, all running at once
    • View Profile
Chrono Trigger Dialogue Box Gradient?
« on: April 15, 2024, 03:14:33 am »
EDIT 2: On further analysis, it seems that the eccentric behavior I mentioned pertaining to the lower extremities DOES follow a trend when I compare the Difference filter to the game: as soon as a color's shifted result nears True Black (RGB 0,0,0), it locks itself to True Black for any remaining shifts downwards. What this tells me is that this probably IS a manual palette shift and not an applied filter, tint or overlay, but the logic behind the palette choices was to use the Addition/Difference method I suggested, with individual preprogrammed choices accounting for when the colors hit black and began to shift brighter again as a different hue.

Which means all of this was completely useless to me and the work I'm trying to accomplish! Yay!

Sorry to waste everyone's time, you can lock this thread if you'd like. Or leave it open in case someone is able to prove me wrong. It doesn't really matter to me now that I've hit this conclusion.

To cut to the chase, how is the gradient applied to the Dialogue Boxes in Chrono Trigger? While trying to recreate the dialogue boxes in a different engine, I realized for the first time the gradient stretches to match the height of the box, always in 16 segments regardless of the box's height. Needless to say, this greatly complicates my attempts in rebuilding the boxes accurately.

I initially assumed it was an overlay, but can't find a corresponding layer when removing layers in an emulator. Then I took a guess that it might be a simple tint of some kind, but in some cases the exchanged colors are completely inconsistent in their hue/saturation shifting, something that probably wouldn't arise from a linear tint.

I eventually arrived at the conclusion that it might be a form of visual filtering, but while I was able to flawlessly recreate all of the lighter parts of the gradient in Paint.NET by applying an Additive Blend Mode to some shades of gray and even some of the darker gradient, but the bottom two or three steps always seem to veer sharply off the palette, with no other filters really being able to make up the difference.

The only theory I have left on my own is good ol' straight-up palette shifting, but given how wildly the intervals change it doesn't quite match up with my (admittedly limited) understanding of how tiles work in SNES games at all. Aren't palettes typically locked to a specific interval of around 8x8 pixels? But then again, the actual gradient itself isn't locked to this interval either, unless there are multiple sprites for each variant but that just seems like a waste of graphical space in a way that seems too uneconomical to be practical for an SNES game.

Anyway, this confusion and inability to efficiently recreate the effect on my own is why I'm asking here, on the foremost Chrono Trigger site that I know of, how CT's internal engine operates. With any luck, I may be able to employ whatever method they use in my recreation, but to do that I'd have to know how it was done in the first place.

EDIT: Sorry, I accidentally posted this in Kajar Laboraties originally... I've since deleted the original and put it here where it felt more apt since while asking does pertain to a fan project the question itself is about the operations of the game's rom.
« Last Edit: April 15, 2024, 12:56:50 pm by Crazy Jane »

inuksuk

  • Earthbound (+15)
  • *
  • Posts: 41
    • View Profile
Re: Chrono Trigger Dialogue Box Gradient?
« Reply #1 on: April 16, 2024, 03:08:10 am »
I haven't dug in to how the gradient is generated myself, but this page in the Encyclopedia discusses it in passing.
https://www.chronocompendium.com/Term/Menu_HDMA_Colors.html
Chickenlump mentions the game generating a table for the dialogue box gradient at runtime as opposed to the menu window colours which are read directly from the ROM. They were able to hijack the routine that reads the gradient and substitute an arbitrary one. I'm guessing the original routine that generates the HDMA table for dialogue boxes is responsible for the behaviour you observed while working in Paint.

Mauron

  • Guru of Reason Emeritus
  • Errare Explorer (+1500)
  • *
  • Posts: 1766
  • Nu-chan
    • View Profile
    • Maurtopia
Re: Chrono Trigger Dialogue Box Gradient?
« Reply #2 on: April 16, 2024, 03:59:04 pm »
The gradient is applied through HDMA - one of the two ways sprites and palettes can be modified.

Code: [Select]
__________________
| Main    |  o    |
| Screen  |  f    |
| Turn    |  f    |
| On      |       |
|_________|_______|
| off too | v off |
|_________|_______|

Let's assume the above is an SNES screen. "Main Screen Turn On" is what you see. "Off" is an area deliberately off screen, known as hBlank, or horizontal blank. "Off too" is vBlank, or vertical blank. "v off" is when both are happening.

New graphics, palettes, etc, can only be loaded in one of these blank periods, usually during vBlank.  Since the screen is rendered left to right, top to bottom, vBlank is much longer than hBlank, you have more time to work with, and the screen is about to be redrawn anyway.

If you change a palette during vBlank, it's going to effect the entire screen, as you'd expect. If you change a palette during hBlank, it's going to effect the lines below it.

Chrono Trigger does its shading during hBlank, and this is how it creates that effect.