-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #579 from Eebit/colorfade
Decompile color fade effects
- Loading branch information
Showing
9 changed files
with
267 additions
and
527 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#ifndef GUARD_COLORFADE_H | ||
#define GUARD_COLORFADE_H | ||
|
||
struct ColFadeProc | ||
{ | ||
/* 00 */ PROC_HEADER; | ||
/* 29 */ STRUCT_PAD(0x29, 0x4E); | ||
|
||
/* 4E */ u16 current; | ||
|
||
/* 50 */ STRUCT_PAD(0x50, 0x58); | ||
|
||
/* 58 */ int color; | ||
/* 5C */ int start; | ||
/* 60 */ int amount; | ||
/* 64 */ u16 speed; | ||
}; | ||
|
||
// ??? ColFadeOut_Init(???); | ||
// ??? ColFadeIn_Init_Null(???); | ||
// ??? ColFadeOut_Loop(???); | ||
// ??? ColFadeIn_Loop(???); | ||
void NewColFadeOut(int, int, int, ProcPtr); | ||
void NewColFadeIn(int, int, int, ProcPtr); | ||
|
||
extern u16 gUnknown_02014EF4[]; | ||
|
||
// extern ??? ProcScr_ColFadeOut | ||
// extern ??? ProcScr_ColFadeIn | ||
|
||
#endif // GUARD_COLORFADE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,230 @@ | ||
#include "global.h" | ||
|
||
#include "hardware.h" | ||
#include "colorfade.h" | ||
|
||
extern u16 gUnknown_02014EF4[]; | ||
|
||
//! FE8U = 0x080B24DC | ||
void ColFadeOut_Init(struct ColFadeProc * proc) | ||
{ | ||
int i; | ||
|
||
for (i = proc->start; i < proc->start + proc->amount; i++) | ||
{ | ||
gUnknown_02014EF4[i] = gPaletteBuffer[i]; | ||
} | ||
|
||
return; | ||
} | ||
|
||
//! FE8U = 0x080B2518 | ||
void ColFadeIn_Init_Null(void) | ||
{ | ||
return; | ||
} | ||
|
||
//! FE8U = 0x080B251C | ||
void ColFadeOut_Loop(struct ColFadeProc * proc) | ||
{ | ||
int i; | ||
|
||
u16 val = 0x100 - proc->current; | ||
|
||
for (i = proc->start; i < proc->start + proc->amount; i++) | ||
{ | ||
int r, r1, r2; | ||
int g, g1, g2; | ||
int b, b1, b2; | ||
|
||
b1 = (gUnknown_02014EF4[i] & BLUE_MASK); | ||
b2 = (proc->color & BLUE_MASK); | ||
b2 = b1 - b2; | ||
b = ((b2 * val / 0x100) + proc->color) & BLUE_MASK; | ||
|
||
g1 = (gUnknown_02014EF4[i] & GREEN_MASK); | ||
g2 = (proc->color & GREEN_MASK); | ||
g2 = (g1 - g2); | ||
g = ((g2 * val / 0x100) + proc->color) & GREEN_MASK; | ||
|
||
r1 = (gUnknown_02014EF4[i] & RED_MASK); | ||
r2 = (proc->color & RED_MASK); | ||
r2 = r1 - r2; | ||
r = ((r2 * val / 0x100) + proc->color) & RED_MASK; | ||
|
||
gPaletteBuffer[i] = b | g | r; | ||
} | ||
|
||
EnablePaletteSync(); | ||
|
||
proc->current += proc->speed; | ||
|
||
if (val == 0) | ||
{ | ||
Proc_Break(proc); | ||
} | ||
|
||
return; | ||
} | ||
|
||
//! FE8U = 0x080B2608 | ||
void ColFadeIn_Loop(struct ColFadeProc * proc) | ||
{ | ||
int i; | ||
|
||
u16 val = 0x100 - proc->current; | ||
|
||
if (val != 0) | ||
{ | ||
for (i = proc->start; i < proc->start + proc->amount; i++) | ||
{ | ||
int r, r1, r2; | ||
int g, g1, g2; | ||
int b, b1, b2; | ||
|
||
b1 = (proc->color & BLUE_MASK); | ||
b2 = (gUnknown_02014EF4[i] & BLUE_MASK); | ||
b2 = b1 - b2; | ||
b = ((b2 * val / 0x100) + gUnknown_02014EF4[i]) & BLUE_MASK; | ||
|
||
g1 = (proc->color & GREEN_MASK); | ||
g2 = (gUnknown_02014EF4[i] & GREEN_MASK); | ||
g2 = (g1 - g2); | ||
g = ((g2 * val / 0x100) + gUnknown_02014EF4[i]) & GREEN_MASK; | ||
|
||
r1 = (proc->color & RED_MASK); | ||
r2 = (gUnknown_02014EF4[i] & RED_MASK); | ||
r2 = r1 - r2; | ||
r = ((r2 * val / 0x100) + gUnknown_02014EF4[i]) & RED_MASK; | ||
|
||
gPaletteBuffer[i] = b | g | r; | ||
} | ||
} | ||
|
||
EnablePaletteSync(); | ||
|
||
proc->current += proc->speed; | ||
|
||
if (val == 0) | ||
{ | ||
for (i = proc->start; i < proc->start + proc->amount; i++) | ||
{ | ||
gPaletteBuffer[i] = gUnknown_02014EF4[i]; | ||
gPaletteBuffer[i] = gUnknown_02014EF4[i]; | ||
gPaletteBuffer[i] = gUnknown_02014EF4[i]; | ||
} | ||
|
||
Proc_Break(proc); | ||
} | ||
|
||
return; | ||
} | ||
|
||
// clang-format off | ||
|
||
struct ProcCmd CONST_DATA ProcScr_ColFadeOut[] = | ||
{ | ||
PROC_NAME("ColFadeOut"), | ||
PROC_SLEEP(2), | ||
|
||
PROC_CALL(ColFadeOut_Init), | ||
PROC_YIELD, | ||
|
||
PROC_REPEAT(ColFadeOut_Loop), | ||
|
||
PROC_END, | ||
}; | ||
|
||
// clang-format on | ||
|
||
//! FE8U = 0x080B272C | ||
void NewColFadeOut(int speed, int kind, int color, ProcPtr parent) | ||
{ | ||
struct ColFadeProc * proc = Proc_StartBlocking(ProcScr_ColFadeOut, parent); | ||
|
||
proc->speed = speed; | ||
proc->color = color; | ||
proc->current = 0; | ||
|
||
switch (kind) | ||
{ | ||
case 0: | ||
proc->start = 0x80; | ||
proc->amount = 0x80; | ||
|
||
break; | ||
|
||
case 1: | ||
proc->start = 0; | ||
proc->amount = 0x200; | ||
|
||
break; | ||
|
||
case 2: | ||
proc->start = 0; | ||
proc->amount = 0x400; | ||
|
||
break; | ||
} | ||
|
||
return; | ||
} | ||
|
||
// clang-format off | ||
|
||
struct ProcCmd CONST_DATA ProcScr_ColFadeIn[] = | ||
{ | ||
PROC_NAME("ColFadeIn"), | ||
PROC_SLEEP(2), | ||
|
||
PROC_CALL(ColFadeIn_Init_Null), | ||
PROC_YIELD, | ||
|
||
PROC_REPEAT(ColFadeIn_Loop), | ||
|
||
PROC_END, | ||
}; | ||
|
||
// clang-format on | ||
|
||
//! FE8U = 0x080B2780 | ||
void NewColFadeIn(int speed, int kind, int color, ProcPtr parent) | ||
{ | ||
int i; | ||
|
||
struct ColFadeProc * proc = Proc_StartBlocking(ProcScr_ColFadeIn, parent); | ||
|
||
proc->speed = speed; | ||
proc->color = color; | ||
|
||
proc->current = 0; | ||
|
||
switch (kind) | ||
{ | ||
case 0: | ||
proc->start = 0x80; | ||
proc->amount = 0x80; | ||
|
||
break; | ||
|
||
case 1: | ||
proc->start = 0; | ||
proc->amount = 0x200; | ||
|
||
break; | ||
|
||
case 2: | ||
proc->start = 0; | ||
proc->amount = 0x400; | ||
|
||
break; | ||
} | ||
|
||
for (i = proc->start; i < proc->start + proc->amount; i++) | ||
{ | ||
gUnknown_02014EF4[i] = gPaletteBuffer[i]; | ||
gPaletteBuffer[i] = 0; | ||
} | ||
|
||
return; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters