From 7a008a944aaac6e34d6425eb650a1886448395e1 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sun, 14 Oct 2018 14:43:19 +0200 Subject: [PATCH] Move 'blend_palette'.c to util.c --- include/blend_palette.h | 6 ------ include/util.h | 1 + ld_script.txt | 1 - src/battle_anim_80A5C6C.c | 1 - src/battle_anim_80A9C70.c | 2 +- src/battle_factory.c | 2 +- src/battle_gfx_sfx_util.c | 1 - src/battle_transition.c | 2 +- src/blend_palette.c | 19 ------------------- src/contest.c | 1 - src/evolution_scene.c | 2 +- src/hall_of_fame.c | 2 +- src/intro.c | 2 +- src/palette.c | 2 +- src/pokeblock_feed.c | 2 +- src/pokemon_animation.c | 2 +- src/tileset_anims.c | 2 +- src/util.c | 18 ++++++++++++++++++ 18 files changed, 29 insertions(+), 39 deletions(-) delete mode 100644 include/blend_palette.h delete mode 100644 src/blend_palette.c diff --git a/include/blend_palette.h b/include/blend_palette.h deleted file mode 100644 index a00847bc3e..0000000000 --- a/include/blend_palette.h +++ /dev/null @@ -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 diff --git a/include/util.h b/include/util.h index 63887b13f6..997c8f7131 100644 --- a/include/util.h +++ b/include/util.h @@ -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 diff --git a/ld_script.txt b/ld_script.txt index b77c50547f..779e1853dc 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -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); diff --git a/src/battle_anim_80A5C6C.c b/src/battle_anim_80A5C6C.c index f4a4946c38..a461d3d1db 100644 --- a/src/battle_anim_80A5C6C.c +++ b/src/battle_anim_80A5C6C.c @@ -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" diff --git a/src/battle_anim_80A9C70.c b/src/battle_anim_80A9C70.c index 1f8a53993f..9b9218b1ca 100644 --- a/src/battle_anim_80A9C70.c +++ b/src/battle_anim_80A9C70.c @@ -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" diff --git a/src/battle_factory.c b/src/battle_factory.c index 36c5ed2e8e..2c8ab1052b 100644 --- a/src/battle_factory.c +++ b/src/battle_factory.c @@ -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" diff --git a/src/battle_gfx_sfx_util.c b/src/battle_gfx_sfx_util.c index 80e1574a45..05958395dc 100644 --- a/src/battle_gfx_sfx_util.c +++ b/src/battle_gfx_sfx_util.c @@ -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" diff --git a/src/battle_transition.c b/src/battle_transition.c index d1d92cb50f..fc8c0eeeee 100644 --- a/src/battle_transition.c +++ b/src/battle_transition.c @@ -19,7 +19,7 @@ #include "gpu_regs.h" #include "decompress.h" #include "bg.h" -#include "blend_palette.h" +#include "util.h" struct TransitionData { diff --git a/src/blend_palette.c b/src/blend_palette.c deleted file mode 100644 index c9503388fe..0000000000 --- a/src/blend_palette.c +++ /dev/null @@ -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); - } -} diff --git a/src/contest.c b/src/contest.c index 8eacc89c30..473f77f9ca 100644 --- a/src/contest.c +++ b/src/contest.c @@ -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" diff --git a/src/evolution_scene.c b/src/evolution_scene.c index 91ac90b1b2..c00aaeb15f 100644 --- a/src/evolution_scene.c +++ b/src/evolution_scene.c @@ -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 diff --git a/src/hall_of_fame.c b/src/hall_of_fame.c index 2b09046725..f2975e7396 100644 --- a/src/hall_of_fame.c +++ b/src/hall_of_fame.c @@ -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" diff --git a/src/intro.c b/src/intro.c index e1d61242cd..fe5c012b04 100644 --- a/src/intro.c +++ b/src/intro.c @@ -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" diff --git a/src/palette.c b/src/palette.c index fd4ad32add..1e92f4bbaa 100644 --- a/src/palette.c +++ b/src/palette.c @@ -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" diff --git a/src/pokeblock_feed.c b/src/pokeblock_feed.c index 1449d4a00e..10f7d34d8e 100644 --- a/src/pokeblock_feed.c +++ b/src/pokeblock_feed.c @@ -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" diff --git a/src/pokemon_animation.c b/src/pokemon_animation.c index e75f2eeba0..6734fce069 100644 --- a/src/pokemon_animation.c +++ b/src/pokemon_animation.c @@ -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 diff --git a/src/tileset_anims.c b/src/tileset_anims.c index 454a2e4353..f7c3cd482c 100644 --- a/src/tileset_anims.c +++ b/src/tileset_anims.c @@ -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" diff --git a/src/util.c b/src/util.c index 9c8766a974..47112774a3 100644 --- a/src/util.c +++ b/src/util.c @@ -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); + } +}