Technique · rendering
Color math
The Super NES's adding or subtracting of a second picture or a fixed color to the screen, for translucency, fades, tints and glows.
On this page
Color math combines the screen with a second picture or a fixed color. In Final Fantasy VI, 73 of the 565 attack animation scripts set it, adding the sprites to a background for the summons or a fixed color that changes line by line1, and the battle screen opens by subtracting white from all but a widening band2. EarthBound’s battle swirl subtracts a tint inside its window3.
- Add a colorFinal Fantasy VI (1994). 73 of 565 attack animation scripts set color math, some adding a fixed color line by line.1
- SubtractEarthBound (1994). The battle swirl subtracts a fixed color inside its window.3Final Fantasy VI (1994). The battle screen opens by subtracting white outside a widening band.2
Games
| Game | Year | How | Note |
|---|---|---|---|
| Final Fantasy VI | 1994 | Add a color | 73 of 565 attack animation scripts set color math, some adding a fixed color line by line |
| EarthBound | 1994 | Subtract | the battle swirl subtracts a fixed color inside its window |
| Final Fantasy VI | 1994 | Subtract | the battle screen opens by subtracting white outside a widening band |
Every claim about this mechanic, by game (8)
References
- ^ abCodeeverything8215, FF6 disassemblyanim_cmd.asm 7605–7621, 1822–1858; attack_anim_script.asm 14716–14744, 668–683, 5–22054; +1 files
How we know
7605; [ battle animation command $d4: set color math HDMA ] ⋮ 7610 lda [zAnimScriptPtr] 7611 sta $10 7612 lda [zAnimScriptPtr],y 7613 sta $11 7614 iny 7615 lda [zAnimScriptPtr],y ; main screen layers 7616 jsr SetColorMathHDMA
src/btlgfx/anim_cmd.asm lines 7605–7621 at 8130132 · upstream ↗ 1823; [ set color add/sub data ] ⋮ 1825; +$10: shbo4321 mmss--cd (+$2130) ⋮ 1836SetColorMathHDMA: ⋮ 1840 lda $10 1841@c243: sta near w7e8993+1,x ; set hdma data 1842 sta near w7e8993+101,x ⋮ 1853 sta near w7e898e ; set subscreen designation
src/btlgfx/anim_cmd.asm lines 1822–1858 at 8130132 · upstream ↗ 14716; [ hide characters for esper attack (bg1) ] ⋮ 14718_d05516: 14719 set_blank_frame 15 14720 sfx PRE_GENJU_B 14721 hide_bg1_thread 14722 disable_char_pal_update 14723 blank_frame 14724 wait_scanline 14725 color_math {ADD, SUBSCREEN}, BG2, SPRITE ⋮ 14729 loop 16 14730 mod_pal CHAR, SUB, WHITE, +1 14731 hide_chars ⋮
src/btlgfx/attack_anim_script.asm lines 14716–14744 at 8130132 · upstream ↗ - ^ abCodeeverything8215, FF6 disassemblyinit.asm 638–646, 738–743, 839–846; init_2.asm 199–240; +2 files
How we know
639 lda #$ff97 ; full subtract, all layers, white 640@1213: sta near w7eea32,x 641 inx2 642 cpx #$01c0 643 bne @1213 644 shorta0 645 lda #$80 646 sta near w7ee9f9
src/btlgfx/init.asm lines 638–646 at 8130132 · upstream ↗ 738; init fade in 739 lda #$4c 740 sta near w7ee9f7 741 stz near w7ee9f8 742 lda #1 743 sta near w7ee9f6 ; enable fade in
src/btlgfx/init.asm lines 738–743 at 8130132 · upstream ↗ 199; [ update screen fade in ] ⋮ 201UpdateFadeIn: ⋮ 207; increment screen brightness 208 lda near w7ee9f9 209 and #$0f 210 cmp #$0f 211 beq @b8b6 212 inc 213 sta near w7ee9f9 ⋮ 215; update hdma for fade bars 216@b8b6: shorti 217 lda near w7ee9f7 ⋮
src/btlgfx/init_2.asm lines 199–240 at 8130132 · upstream ↗ - ^ abCodeHerringway/ebsrc · SNESdev Wiki, “PPU registers”battle_swirl_sequence.asm 12–91; hardware.asm 70–94; +1 files
How we know
12 LDA #$0001 13 STA $16 14 LDA #$0004 15 STA @SWIRL_RED 16 STA @SWIRL_GREEN 17 LDY #$0000 18 STY @SWIRL_BLUE 19 LDA BATTLE_INITIATIVE 20 BEQ @UNKNOWN0 21 CMP #INITIATIVE::PARTY_FIRST 22 BEQ @UNKNOWN1 23 CMP #INITIATIVE::ENEMIES_FIRST ⋮
src/overworld/battle_swirl_sequence.asm lines 12–91 at 68aec5c · upstream ↗ 70.ENUM CGWSEL_BITS ⋮ 75 COLOUR_MATH_ENABLE_ALWAYS = 0 << 4 76 COLOUR_MATH_ENABLE_MATHWIN = 1 << 4 ⋮ 79 SUBSCREEN_BGOBJ_ENABLE = 1 << 1 80 SUBSCREEN_BGOBJ_DISABLE = 0 << 1 ⋮ 85.ENUM CGADSUB_BITS 86 COLOUR_MATH_ADDSUB = 1 << 7 87 COLOUR_MATH_DIV2 = 1 << 6
include/hardware.asm lines 70–94 at 68aec5c · upstream ↗ 451 BOSS_FRANK = 448include/constants/enemy_groups.asm line 451 at 68aec5c · upstream ↗ +--------- Operator type (0 = add, 1 = subtract) … |+-------- Half color math
CGADSUB - Color math designation ($2131 write) · archived copy ↗ |||| +-- Addend (0 = fixed color, 1 = subscreen) … ||++------ Sub screen color window transparent region … 1 |Outside color window … The sub-screen setting is for masking color math.
CGWSEL - Color addition select ($2130 write) · archived copy ↗
Sources
Code
- everything8215. 2026. “Final Fantasy VI Disassembly.” Commit 8130132. everything8215/ff6 @ 8130132 · licence, all uses
- Herringway. 2026. “ebsrc: Source code recreation for the game Earthbound.” Commit 68aec5c. Herringway/ebsrc @ 68aec5c · licence, all uses
Secondary
- SNESdev Wiki contributors. n.d. “PPU registers.” SNESdev Wiki. Version oldid 1507. original · archived · licence, all uses