Move 'blend_palette'.c to util.c

This commit is contained in:
DizzyEggg 2018-10-14 14:43:19 +02:00
parent 0c1d33da4f
commit 7a008a944a
18 changed files with 29 additions and 39 deletions

View File

@ -1,6 +0,0 @@
#ifndef GUARD_BLEND_PALETTE_H
#define GUARD_BLEND_PALETTE_H
void BlendPalette(u16 palOffset, u16 numEntries, u8 coeff, u16 blendColor);
#endif // GUARD_BLEND_PALETTE_H

View File

@ -13,5 +13,6 @@ int CountTrailingZeroBits(u32 value);
u16 CalcCRC16(u8 *data, s32 length);
u16 CalcCRC16WithTable(u8 *data, u32 length);
u32 CalcByteArraySum(const u8* data, u32 length);
void BlendPalette(u16 palOffset, u16 numEntries, u8 coeff, u16 blendColor);
#endif // GUARD_UTIL_H

View File

@ -76,7 +76,6 @@ SECTIONS {
src/trig.o(.text);
src/random.o(.text);
src/util.o(.text);
src/blend_palette.o(.text);
src/daycare.o(.text);
src/egg_hatch.o(.text);
src/battle_interface.o(.text);

View File

@ -3,7 +3,6 @@
#include "constants/species.h"
#include "battle.h"
#include "battle_anim.h"
#include "blend_palette.h"
#include "contest.h"
#include "data2.h"
#include "decompress.h"

View File

@ -3,7 +3,7 @@
#include "battle_anim.h"
#include "constants/battle_anim.h"
#include "constants/rgb.h"
#include "blend_palette.h"
#include "util.h"
#include "decompress.h"
#include "palette.h"
#include "sprite.h"

View File

@ -20,7 +20,7 @@
#include "pokemon_summary_screen.h"
#include "sound.h"
#include "pokedex.h"
#include "blend_palette.h"
#include "util.h"
#include "trainer_pokemon_sprites.h"
#include "constants/battle_frontier.h"
#include "constants/songs.h"

View File

@ -19,7 +19,6 @@
#include "decompress.h"
#include "data2.h"
#include "palette.h"
#include "blend_palette.h"
#include "contest.h"
#include "constants/songs.h"
#include "constants/rgb.h"

View File

@ -19,7 +19,7 @@
#include "gpu_regs.h"
#include "decompress.h"
#include "bg.h"
#include "blend_palette.h"
#include "util.h"
struct TransitionData
{

View File

@ -1,19 +0,0 @@
#include "global.h"
#include "palette.h"
void BlendPalette(u16 palOffset, u16 numEntries, u8 coeff, u16 blendColor)
{
u16 i;
for (i = 0; i < numEntries; i++)
{
u16 index = i + palOffset;
struct PlttData *data1 = (struct PlttData *)&gPlttBufferUnfaded[index];
s8 r = data1->r;
s8 g = data1->g;
s8 b = data1->b;
struct PlttData *data2 = (struct PlttData *)&blendColor;
gPlttBufferFaded[index] = ((r + (((data2->r - r) * coeff) >> 4)) << 0)
| ((g + (((data2->g - g) * coeff) >> 4)) << 5)
| ((b + (((data2->b - b) * coeff) >> 4)) << 10);
}
}

View File

@ -10,7 +10,6 @@
#include "constants/flags.h"
#include "battle.h"
#include "battle_anim.h"
#include "blend_palette.h"
#include "contest.h"
#include "data2.h"
#include "decompress.h"

View File

@ -25,7 +25,7 @@
#include "gpu_regs.h"
#include "bg.h"
#include "link.h"
#include "blend_palette.h"
#include "util.h"
#include "trig.h"
struct EvoInfo

View File

@ -17,7 +17,7 @@
#include "bg.h"
#include "constants/species.h"
#include "constants/game_stat.h"
#include "blend_palette.h"
#include "util.h"
#include "string_util.h"
#include "m4a.h"
#include "international_string_util.h"

View File

@ -22,7 +22,7 @@
#include "graphics.h"
#include "sound.h"
#include "constants/species.h"
#include "blend_palette.h"
#include "util.h"
#include "title_screen.h"
#include "constants/rgb.h"
#include "constants/battle_anim.h"

View File

@ -1,6 +1,6 @@
#include "global.h"
#include "blend_palette.h"
#include "palette.h"
#include "util.h"
#include "decompress.h"
#include "gpu_regs.h"
#include "task.h"

View File

@ -6,7 +6,7 @@
#include "menu.h"
#include "malloc.h"
#include "pokemon.h"
#include "blend_palette.h"
#include "util.h"
#include "main.h"
#include "menu_helpers.h"
#include "bg.h"

View File

@ -4,7 +4,7 @@
#include "pokemon_animation.h"
#include "trig.h"
#include "task.h"
#include "blend_palette.h"
#include "util.h"
#include "constants/rgb.h"
struct UnkAnimStruct

View File

@ -1,7 +1,7 @@
// Includes
#include "global.h"
#include "palette.h"
#include "blend_palette.h"
#include "util.h"
#include "battle_transition.h"
#include "task.h"
#include "battle_transition.h"

View File

@ -1,6 +1,7 @@
#include "global.h"
#include "util.h"
#include "sprite.h"
#include "palette.h"
const u32 gBitTable[] =
{
@ -258,3 +259,20 @@ u32 CalcByteArraySum(const u8* data, u32 length)
sum += data[i];
return sum;
}
void BlendPalette(u16 palOffset, u16 numEntries, u8 coeff, u16 blendColor)
{
u16 i;
for (i = 0; i < numEntries; i++)
{
u16 index = i + palOffset;
struct PlttData *data1 = (struct PlttData *)&gPlttBufferUnfaded[index];
s8 r = data1->r;
s8 g = data1->g;
s8 b = data1->b;
struct PlttData *data2 = (struct PlttData *)&blendColor;
gPlttBufferFaded[index] = ((r + (((data2->r - r) * coeff) >> 4)) << 0)
| ((g + (((data2->g - g) * coeff) >> 4)) << 5)
| ((b + (((data2->b - b) * coeff) >> 4)) << 10);
}
}