Skip to content

Instantly share code, notes, and snippets.

@jeremyabel
Created September 16, 2018 03:00
Show Gist options
  • Save jeremyabel/848e66e2292ada97aa571481727ae758 to your computer and use it in GitHub Desktop.
Save jeremyabel/848e66e2292ada97aa571481727ae758 to your computer and use it in GitHub Desktop.
/**
* Class which handles the display of various palette-based move fx animations.
*
* These effects operate on a bitmap which stores a capture of the state of the screen,
* and then modifies the 4-color palettes used to draw specific areas of the screen.
*
* There are a number of palette effects available:
*
* INVERT: Inverts the palette's order.
* LIGHTEN1, 2, 3, 4: Lightens the palette, by 1, 2, 3, or 4 steps.
* DARKEN1, 2, 3, 4: Darkens the palette, by 1, 2, 3, or 4 steps.
* CYCLE: Cycles the normal palette.
* CYCLE_INV: Cycles the inverted-order palette.
*
* These effects emulate the way the Gameboy Color deals with sprite color palettes, which
* contain 4 unique colors, usually white, black, and two others, ordered by luminance from
* lightest to darkest. The palette effects operate by shifting and copying the entries in
* the palettes.
*
* For example: the "LIGHTEN1" effect is done by shifting all palette entries forward by 1:
*
* Before: 1 2 3 4
* After: 1 1 2 3
*
* If you picture color 1 being white, 2 being light grey, 3 being dark grey, and 4 being black,
* then in this case everything colored black becomes dark grey, everything dark grey becomes
* light grey, and so on. All palette effects work like this. "LIGHTEN2-4" repeats this step
* 2-4 times to simulate 4 different levels of lightening. "DARKEN1-4" works the same way, only
* from the other end of the palette:
*
* Before: 1 2 3 4
* After: 2 3 4 4
*
* The CYCLE and CYCLE_INV effects work by cycling the colors in the palette:
*
* Before: 1 2 3 4
* After: 2 3 4 1
*
* The battle screen is divided up into 2 areas: "player" and "enemy". These areas are further divided
* into 2 more areas: "mon" and "stat", resulting in 4 areas total. Each individual area uses a unique
* 4-color palette, and therefore has its own individual effected palette. Not all moves effect the
* entire screen, so it has to be divided like this in order to animate the effect properly. For example,
* the INVERT effect changes the entire screen, so it modifies the palettes of all 4 areas. But the LIGHTEN1
* effect only effects the player and enemy mons, so it only modifies those 2 "mon" areas and leaves the two
* "stat" areas unmodified.
*
* See also: {@link TinyBattlePalette}, {@link TinyFourColorPalette}.
*
* @author jeremyabel
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment