Merge pull request #1573 from GriffinRichards/tilesetanim

Clean up tileset_anims
This commit is contained in:
GriffinR 2021-12-15 09:47:54 -05:00 committed by GitHub
commit 6e5520207f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -632,45 +632,45 @@ void InitTilesetAnim_Building(void)
static void TilesetAnim_General(u16 timer) static void TilesetAnim_General(u16 timer)
{ {
if (timer % 16 == 0) if (timer % 16 == 0)
QueueAnimTiles_General_Flower(timer >> 4); QueueAnimTiles_General_Flower(timer / 16);
if (timer % 16 == 1) if (timer % 16 == 1)
QueueAnimTiles_General_Water(timer >> 4); QueueAnimTiles_General_Water(timer / 16);
if (timer % 16 == 2) if (timer % 16 == 2)
QueueAnimTiles_General_SandWaterEdge(timer >> 4); QueueAnimTiles_General_SandWaterEdge(timer / 16);
if (timer % 16 == 3) if (timer % 16 == 3)
QueueAnimTiles_General_Waterfall(timer >> 4); QueueAnimTiles_General_Waterfall(timer / 16);
if (timer % 16 == 4) if (timer % 16 == 4)
QueueAnimTiles_General_LandWaterEdge(timer >> 4); QueueAnimTiles_General_LandWaterEdge(timer / 16);
} }
static void TilesetAnim_Building(u16 timer) static void TilesetAnim_Building(u16 timer)
{ {
if (timer % 8 == 0) if (timer % 8 == 0)
QueueAnimTiles_Building_TVTurnedOn(timer >> 3); QueueAnimTiles_Building_TVTurnedOn(timer / 8);
} }
static void QueueAnimTiles_General_Flower(u16 timer) static void QueueAnimTiles_General_Flower(u16 timer)
{ {
u16 i = timer % 4; u16 i = timer % ARRAY_COUNT(gTilesetAnims_General_Flower);
AppendTilesetAnimToBuffer(gTilesetAnims_General_Flower[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(508)), 0x80); AppendTilesetAnimToBuffer(gTilesetAnims_General_Flower[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(508)), 4 * TILE_SIZE_4BPP);
} }
static void QueueAnimTiles_General_Water(u16 timer) static void QueueAnimTiles_General_Water(u16 timer)
{ {
u8 i = timer % 8; u8 i = timer % ARRAY_COUNT(gTilesetAnims_General_Water);
AppendTilesetAnimToBuffer(gTilesetAnims_General_Water[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(432)), 0x3C0); AppendTilesetAnimToBuffer(gTilesetAnims_General_Water[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(432)), 30 * TILE_SIZE_4BPP);
} }
static void QueueAnimTiles_General_SandWaterEdge(u16 timer) static void QueueAnimTiles_General_SandWaterEdge(u16 timer)
{ {
u16 i = timer % 8; u16 i = timer % ARRAY_COUNT(gTilesetAnims_General_SandWaterEdge);
AppendTilesetAnimToBuffer(gTilesetAnims_General_SandWaterEdge[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(464)), 0x140); AppendTilesetAnimToBuffer(gTilesetAnims_General_SandWaterEdge[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(464)), 10 * TILE_SIZE_4BPP);
} }
static void QueueAnimTiles_General_Waterfall(u16 timer) static void QueueAnimTiles_General_Waterfall(u16 timer)
{ {
u16 i = timer % 4; u16 i = timer % ARRAY_COUNT(gTilesetAnims_General_Waterfall);
AppendTilesetAnimToBuffer(gTilesetAnims_General_Waterfall[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(496)), 0xc0); AppendTilesetAnimToBuffer(gTilesetAnims_General_Waterfall[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(496)), 6 * TILE_SIZE_4BPP);
} }
void InitTilesetAnim_Petalburg(void) void InitTilesetAnim_Petalburg(void)
@ -838,336 +838,336 @@ static void TilesetAnim_Rustboro(u16 timer)
{ {
if (timer % 8 == 0) if (timer % 8 == 0)
{ {
QueueAnimTiles_Rustboro_WindyWater(timer >> 3, 0); QueueAnimTiles_Rustboro_WindyWater(timer / 8, 0);
QueueAnimTiles_Rustboro_Fountain(timer >> 3); QueueAnimTiles_Rustboro_Fountain(timer / 8);
} }
if (timer % 8 == 1) if (timer % 8 == 1)
QueueAnimTiles_Rustboro_WindyWater(timer >> 3, 1); QueueAnimTiles_Rustboro_WindyWater(timer / 8, 1);
if (timer % 8 == 2) if (timer % 8 == 2)
QueueAnimTiles_Rustboro_WindyWater(timer >> 3, 2); QueueAnimTiles_Rustboro_WindyWater(timer / 8, 2);
if (timer % 8 == 3) if (timer % 8 == 3)
QueueAnimTiles_Rustboro_WindyWater(timer >> 3, 3); QueueAnimTiles_Rustboro_WindyWater(timer / 8, 3);
if (timer % 8 == 4) if (timer % 8 == 4)
QueueAnimTiles_Rustboro_WindyWater(timer >> 3, 4); QueueAnimTiles_Rustboro_WindyWater(timer / 8, 4);
if (timer % 8 == 5) if (timer % 8 == 5)
QueueAnimTiles_Rustboro_WindyWater(timer >> 3, 5); QueueAnimTiles_Rustboro_WindyWater(timer / 8, 5);
if (timer % 8 == 6) if (timer % 8 == 6)
QueueAnimTiles_Rustboro_WindyWater(timer >> 3, 6); QueueAnimTiles_Rustboro_WindyWater(timer / 8, 6);
if (timer % 8 == 7) if (timer % 8 == 7)
QueueAnimTiles_Rustboro_WindyWater(timer >> 3, 7); QueueAnimTiles_Rustboro_WindyWater(timer / 8, 7);
} }
static void TilesetAnim_Dewford(u16 timer) static void TilesetAnim_Dewford(u16 timer)
{ {
if (timer % 8 == 0) if (timer % 8 == 0)
QueueAnimTiles_Dewford_Flag(timer >> 3); QueueAnimTiles_Dewford_Flag(timer / 8);
} }
static void TilesetAnim_Slateport(u16 timer) static void TilesetAnim_Slateport(u16 timer)
{ {
if (timer % 16 == 0) if (timer % 16 == 0)
QueueAnimTiles_Slateport_Balloons(timer >> 4); QueueAnimTiles_Slateport_Balloons(timer / 16);
} }
static void TilesetAnim_Mauville(u16 timer) static void TilesetAnim_Mauville(u16 timer)
{ {
if (timer % 8 == 0) if (timer % 8 == 0)
QueueAnimTiles_Mauville_Flowers(timer >> 3, 0); QueueAnimTiles_Mauville_Flowers(timer / 8, 0);
if (timer % 8 == 1) if (timer % 8 == 1)
QueueAnimTiles_Mauville_Flowers(timer >> 3, 1); QueueAnimTiles_Mauville_Flowers(timer / 8, 1);
if (timer % 8 == 2) if (timer % 8 == 2)
QueueAnimTiles_Mauville_Flowers(timer >> 3, 2); QueueAnimTiles_Mauville_Flowers(timer / 8, 2);
if (timer % 8 == 3) if (timer % 8 == 3)
QueueAnimTiles_Mauville_Flowers(timer >> 3, 3); QueueAnimTiles_Mauville_Flowers(timer / 8, 3);
if (timer % 8 == 4) if (timer % 8 == 4)
QueueAnimTiles_Mauville_Flowers(timer >> 3, 4); QueueAnimTiles_Mauville_Flowers(timer / 8, 4);
if (timer % 8 == 5) if (timer % 8 == 5)
QueueAnimTiles_Mauville_Flowers(timer >> 3, 5); QueueAnimTiles_Mauville_Flowers(timer / 8, 5);
if (timer % 8 == 6) if (timer % 8 == 6)
QueueAnimTiles_Mauville_Flowers(timer >> 3, 6); QueueAnimTiles_Mauville_Flowers(timer / 8, 6);
if (timer % 8 == 7) if (timer % 8 == 7)
QueueAnimTiles_Mauville_Flowers(timer >> 3, 7); QueueAnimTiles_Mauville_Flowers(timer / 8, 7);
} }
static void TilesetAnim_Lavaridge(u16 timer) static void TilesetAnim_Lavaridge(u16 timer)
{ {
if (timer % 16 == 0) if (timer % 16 == 0)
QueueAnimTiles_Lavaridge_Steam(timer >> 4); QueueAnimTiles_Lavaridge_Steam(timer / 16);
if (timer % 16 == 1) if (timer % 16 == 1)
QueueAnimTiles_Lavaridge_Lava(timer >> 4); QueueAnimTiles_Lavaridge_Lava(timer / 16);
} }
static void TilesetAnim_EverGrande(u16 timer) static void TilesetAnim_EverGrande(u16 timer)
{ {
if (timer % 8 == 0) if (timer % 8 == 0)
QueueAnimTiles_EverGrande_Flowers(timer >> 3, 0); QueueAnimTiles_EverGrande_Flowers(timer / 8, 0);
if (timer % 8 == 1) if (timer % 8 == 1)
QueueAnimTiles_EverGrande_Flowers(timer >> 3, 1); QueueAnimTiles_EverGrande_Flowers(timer / 8, 1);
if (timer % 8 == 2) if (timer % 8 == 2)
QueueAnimTiles_EverGrande_Flowers(timer >> 3, 2); QueueAnimTiles_EverGrande_Flowers(timer / 8, 2);
if (timer % 8 == 3) if (timer % 8 == 3)
QueueAnimTiles_EverGrande_Flowers(timer >> 3, 3); QueueAnimTiles_EverGrande_Flowers(timer / 8, 3);
if (timer % 8 == 4) if (timer % 8 == 4)
QueueAnimTiles_EverGrande_Flowers(timer >> 3, 4); QueueAnimTiles_EverGrande_Flowers(timer / 8, 4);
if (timer % 8 == 5) if (timer % 8 == 5)
QueueAnimTiles_EverGrande_Flowers(timer >> 3, 5); QueueAnimTiles_EverGrande_Flowers(timer / 8, 5);
if (timer % 8 == 6) if (timer % 8 == 6)
QueueAnimTiles_EverGrande_Flowers(timer >> 3, 6); QueueAnimTiles_EverGrande_Flowers(timer / 8, 6);
if (timer % 8 == 7) if (timer % 8 == 7)
QueueAnimTiles_EverGrande_Flowers(timer >> 3, 7); QueueAnimTiles_EverGrande_Flowers(timer / 8, 7);
} }
static void TilesetAnim_Pacifidlog(u16 timer) static void TilesetAnim_Pacifidlog(u16 timer)
{ {
if (timer % 16 == 0) if (timer % 16 == 0)
QueueAnimTiles_Pacifidlog_LogBridges(timer >> 4); QueueAnimTiles_Pacifidlog_LogBridges(timer / 16);
if (timer % 16 == 1) if (timer % 16 == 1)
QueueAnimTiles_Pacifidlog_WaterCurrents(timer >> 4); QueueAnimTiles_Pacifidlog_WaterCurrents(timer / 16);
} }
static void TilesetAnim_Sootopolis(u16 timer) static void TilesetAnim_Sootopolis(u16 timer)
{ {
if (timer % 16 == 0) if (timer % 16 == 0)
QueueAnimTiles_Sootopolis_StormyWater(timer >> 4); QueueAnimTiles_Sootopolis_StormyWater(timer / 16);
} }
static void TilesetAnim_Underwater(u16 timer) static void TilesetAnim_Underwater(u16 timer)
{ {
if (timer % 16 == 0) if (timer % 16 == 0)
QueueAnimTiles_Underwater_Seaweed(timer >> 4); QueueAnimTiles_Underwater_Seaweed(timer / 16);
} }
static void TilesetAnim_Cave(u16 timer) static void TilesetAnim_Cave(u16 timer)
{ {
if (timer % 16 == 1) if (timer % 16 == 1)
QueueAnimTiles_Cave_Lava(timer >> 4); QueueAnimTiles_Cave_Lava(timer / 16);
} }
static void TilesetAnim_BattleFrontierOutsideWest(u16 timer) static void TilesetAnim_BattleFrontierOutsideWest(u16 timer)
{ {
if (timer % 8 == 0) if (timer % 8 == 0)
QueueAnimTiles_BattleFrontierOutsideWest_Flag(timer >> 3); QueueAnimTiles_BattleFrontierOutsideWest_Flag(timer / 8);
} }
static void TilesetAnim_BattleFrontierOutsideEast(u16 timer) static void TilesetAnim_BattleFrontierOutsideEast(u16 timer)
{ {
if (timer % 8 == 0) if (timer % 8 == 0)
QueueAnimTiles_BattleFrontierOutsideEast_Flag(timer >> 3); QueueAnimTiles_BattleFrontierOutsideEast_Flag(timer / 8);
} }
static void QueueAnimTiles_General_LandWaterEdge(u16 timer) static void QueueAnimTiles_General_LandWaterEdge(u16 timer)
{ {
u16 i = timer % 4; u16 i = timer % ARRAY_COUNT(gTilesetAnims_General_LandWaterEdge);
AppendTilesetAnimToBuffer(gTilesetAnims_General_LandWaterEdge[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(480)), 0x140); AppendTilesetAnimToBuffer(gTilesetAnims_General_LandWaterEdge[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(480)), 10 * TILE_SIZE_4BPP);
} }
static void QueueAnimTiles_Lavaridge_Steam(u8 timer) static void QueueAnimTiles_Lavaridge_Steam(u8 timer)
{ {
u8 i = timer % 4; u8 i = timer % ARRAY_COUNT(gTilesetAnims_Lavaridge_Steam);
AppendTilesetAnimToBuffer(gTilesetAnims_Lavaridge_Steam[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(NUM_TILES_IN_PRIMARY + 288)), 0x80); AppendTilesetAnimToBuffer(gTilesetAnims_Lavaridge_Steam[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(NUM_TILES_IN_PRIMARY + 288)), 4 * TILE_SIZE_4BPP);
i = (timer + 2) % 4; i = (timer + 2) % (int)ARRAY_COUNT(gTilesetAnims_Lavaridge_Steam);
AppendTilesetAnimToBuffer(gTilesetAnims_Lavaridge_Steam[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(NUM_TILES_IN_PRIMARY + 292)), 0x80); AppendTilesetAnimToBuffer(gTilesetAnims_Lavaridge_Steam[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(NUM_TILES_IN_PRIMARY + 292)), 4 * TILE_SIZE_4BPP);
} }
static void QueueAnimTiles_Pacifidlog_LogBridges(u8 timer) static void QueueAnimTiles_Pacifidlog_LogBridges(u8 timer)
{ {
u8 i = timer % 4; u8 i = timer % ARRAY_COUNT(gTilesetAnims_Pacifidlog_LogBridges);
AppendTilesetAnimToBuffer(gTilesetAnims_Pacifidlog_LogBridges[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(NUM_TILES_IN_PRIMARY + 464)), 0x3C0); AppendTilesetAnimToBuffer(gTilesetAnims_Pacifidlog_LogBridges[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(NUM_TILES_IN_PRIMARY + 464)), 30 * TILE_SIZE_4BPP);
} }
static void QueueAnimTiles_Underwater_Seaweed(u8 timer) static void QueueAnimTiles_Underwater_Seaweed(u8 timer)
{ {
u8 i = timer % 4; u8 i = timer % ARRAY_COUNT(gTilesetAnims_Underwater_Seaweed);
AppendTilesetAnimToBuffer(gTilesetAnims_Underwater_Seaweed[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(NUM_TILES_IN_PRIMARY + 496)), 0x80); AppendTilesetAnimToBuffer(gTilesetAnims_Underwater_Seaweed[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(NUM_TILES_IN_PRIMARY + 496)), 4 * TILE_SIZE_4BPP);
} }
static void QueueAnimTiles_Pacifidlog_WaterCurrents(u8 timer) static void QueueAnimTiles_Pacifidlog_WaterCurrents(u8 timer)
{ {
u8 i = timer % 8; u8 i = timer % ARRAY_COUNT(gTilesetAnims_Pacifidlog_WaterCurrents);
AppendTilesetAnimToBuffer(gTilesetAnims_Pacifidlog_WaterCurrents[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(NUM_TILES_IN_PRIMARY + 496)), 0x100); AppendTilesetAnimToBuffer(gTilesetAnims_Pacifidlog_WaterCurrents[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(NUM_TILES_IN_PRIMARY + 496)), 8 * TILE_SIZE_4BPP);
} }
static void QueueAnimTiles_Mauville_Flowers(u16 timer_div, u8 timer_mod) static void QueueAnimTiles_Mauville_Flowers(u16 timer_div, u8 timer_mod)
{ {
timer_div -= timer_mod; timer_div -= timer_mod;
if (timer_div < 12) // almost certainly a typo if (timer_div < min(ARRAY_COUNT(gTilesetAnims_Mauville_Flower1), ARRAY_COUNT(gTilesetAnims_Mauville_Flower2)))
{ {
timer_div %= 12; timer_div %= min(ARRAY_COUNT(gTilesetAnims_Mauville_Flower1), ARRAY_COUNT(gTilesetAnims_Mauville_Flower2));
AppendTilesetAnimToBuffer(gTilesetAnims_Mauville_Flower1[timer_div], gTilesetAnims_Mauville_Flower1_VDests[timer_mod], 0x80); AppendTilesetAnimToBuffer(gTilesetAnims_Mauville_Flower1[timer_div], gTilesetAnims_Mauville_Flower1_VDests[timer_mod], 4 * TILE_SIZE_4BPP);
AppendTilesetAnimToBuffer(gTilesetAnims_Mauville_Flower2[timer_div], gTilesetAnims_Mauville_Flower2_VDests[timer_mod], 0x80); AppendTilesetAnimToBuffer(gTilesetAnims_Mauville_Flower2[timer_div], gTilesetAnims_Mauville_Flower2_VDests[timer_mod], 4 * TILE_SIZE_4BPP);
} }
else else
{ {
timer_div %= 4; timer_div %= min(ARRAY_COUNT(gTilesetAnims_Mauville_Flower1_B), ARRAY_COUNT(gTilesetAnims_Mauville_Flower2_B));
AppendTilesetAnimToBuffer(gTilesetAnims_Mauville_Flower1_B[timer_div], gTilesetAnims_Mauville_Flower1_VDests[timer_mod], 0x80); AppendTilesetAnimToBuffer(gTilesetAnims_Mauville_Flower1_B[timer_div], gTilesetAnims_Mauville_Flower1_VDests[timer_mod], 4 * TILE_SIZE_4BPP);
AppendTilesetAnimToBuffer(gTilesetAnims_Mauville_Flower2_B[timer_div], gTilesetAnims_Mauville_Flower2_VDests[timer_mod], 0x80); AppendTilesetAnimToBuffer(gTilesetAnims_Mauville_Flower2_B[timer_div], gTilesetAnims_Mauville_Flower2_VDests[timer_mod], 4 * TILE_SIZE_4BPP);
} }
} }
static void QueueAnimTiles_Rustboro_WindyWater(u16 timer_div, u8 timer_mod) static void QueueAnimTiles_Rustboro_WindyWater(u16 timer_div, u8 timer_mod)
{ {
timer_div -= timer_mod; timer_div -= timer_mod;
timer_div %= 8; timer_div %= ARRAY_COUNT(gTilesetAnims_Rustboro_WindyWater);
if (gTilesetAnims_Rustboro_WindyWater[timer_div]) if (gTilesetAnims_Rustboro_WindyWater[timer_div])
AppendTilesetAnimToBuffer(gTilesetAnims_Rustboro_WindyWater[timer_div], gTilesetAnims_Rustboro_WindyWater_VDests[timer_mod], 0x80); AppendTilesetAnimToBuffer(gTilesetAnims_Rustboro_WindyWater[timer_div], gTilesetAnims_Rustboro_WindyWater_VDests[timer_mod], 4 * TILE_SIZE_4BPP);
} }
static void QueueAnimTiles_Rustboro_Fountain(u16 timer) static void QueueAnimTiles_Rustboro_Fountain(u16 timer)
{ {
u16 i = timer % 2; u16 i = timer % ARRAY_COUNT(gTilesetAnims_Rustboro_Fountain);
AppendTilesetAnimToBuffer(gTilesetAnims_Rustboro_Fountain[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(NUM_TILES_IN_PRIMARY + 448)), 0x80); AppendTilesetAnimToBuffer(gTilesetAnims_Rustboro_Fountain[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(NUM_TILES_IN_PRIMARY + 448)), 4 * TILE_SIZE_4BPP);
} }
static void QueueAnimTiles_Lavaridge_Lava(u16 timer) static void QueueAnimTiles_Lavaridge_Lava(u16 timer)
{ {
u16 i = timer % 4; u16 i = timer % ARRAY_COUNT(gTilesetAnims_Lavaridge_Cave_Lava);
AppendTilesetAnimToBuffer(gTilesetAnims_Lavaridge_Cave_Lava[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(NUM_TILES_IN_PRIMARY + 160)), 0x80); AppendTilesetAnimToBuffer(gTilesetAnims_Lavaridge_Cave_Lava[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(NUM_TILES_IN_PRIMARY + 160)), 4 * TILE_SIZE_4BPP);
} }
static void QueueAnimTiles_EverGrande_Flowers(u16 timer_div, u8 timer_mod) static void QueueAnimTiles_EverGrande_Flowers(u16 timer_div, u8 timer_mod)
{ {
timer_div -= timer_mod; timer_div -= timer_mod;
timer_div %= 8; timer_div %= ARRAY_COUNT(gTilesetAnims_EverGrande_Flowers);
AppendTilesetAnimToBuffer(gTilesetAnims_EverGrande_Flowers[timer_div], gTilesetAnims_EverGrande_VDests[timer_mod], 0x80); AppendTilesetAnimToBuffer(gTilesetAnims_EverGrande_Flowers[timer_div], gTilesetAnims_EverGrande_VDests[timer_mod], 4 * TILE_SIZE_4BPP);
} }
static void QueueAnimTiles_Cave_Lava(u16 timer) static void QueueAnimTiles_Cave_Lava(u16 timer)
{ {
u16 i = timer % 4; u16 i = timer % ARRAY_COUNT(gTilesetAnims_Lavaridge_Cave_Lava);
AppendTilesetAnimToBuffer(gTilesetAnims_Lavaridge_Cave_Lava[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(NUM_TILES_IN_PRIMARY + 416)), 0x80); AppendTilesetAnimToBuffer(gTilesetAnims_Lavaridge_Cave_Lava[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(NUM_TILES_IN_PRIMARY + 416)), 4 * TILE_SIZE_4BPP);
} }
static void QueueAnimTiles_Dewford_Flag(u16 timer) static void QueueAnimTiles_Dewford_Flag(u16 timer)
{ {
u16 id = timer % 4; u16 i = timer % ARRAY_COUNT(gTilesetAnims_Dewford_Flag);
AppendTilesetAnimToBuffer(gTilesetAnims_Dewford_Flag[id], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(NUM_TILES_IN_PRIMARY + 170)), 0xC0); AppendTilesetAnimToBuffer(gTilesetAnims_Dewford_Flag[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(NUM_TILES_IN_PRIMARY + 170)), 6 * TILE_SIZE_4BPP);
} }
static void QueueAnimTiles_BattleFrontierOutsideWest_Flag(u16 timer) static void QueueAnimTiles_BattleFrontierOutsideWest_Flag(u16 timer)
{ {
u16 i = timer % 4; u16 i = timer % ARRAY_COUNT(gTilesetAnims_BattleFrontierOutsideWest_Flag);
AppendTilesetAnimToBuffer(gTilesetAnims_BattleFrontierOutsideWest_Flag[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(NUM_TILES_IN_PRIMARY + 218)), 0xC0); AppendTilesetAnimToBuffer(gTilesetAnims_BattleFrontierOutsideWest_Flag[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(NUM_TILES_IN_PRIMARY + 218)), 6 * TILE_SIZE_4BPP);
} }
static void QueueAnimTiles_BattleFrontierOutsideEast_Flag(u16 timer) static void QueueAnimTiles_BattleFrontierOutsideEast_Flag(u16 timer)
{ {
u16 i = timer % 4; u16 i = timer % ARRAY_COUNT(gTilesetAnims_BattleFrontierOutsideEast_Flag);
AppendTilesetAnimToBuffer(gTilesetAnims_BattleFrontierOutsideEast_Flag[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(NUM_TILES_IN_PRIMARY + 218)), 0xC0); AppendTilesetAnimToBuffer(gTilesetAnims_BattleFrontierOutsideEast_Flag[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(NUM_TILES_IN_PRIMARY + 218)), 6 * TILE_SIZE_4BPP);
} }
static void QueueAnimTiles_Slateport_Balloons(u16 timer) static void QueueAnimTiles_Slateport_Balloons(u16 timer)
{ {
u16 i = timer % 4; u16 i = timer % ARRAY_COUNT(gTilesetAnims_Slateport_Balloons);
AppendTilesetAnimToBuffer(gTilesetAnims_Slateport_Balloons[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(NUM_TILES_IN_PRIMARY + 224)), 0x80); AppendTilesetAnimToBuffer(gTilesetAnims_Slateport_Balloons[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(NUM_TILES_IN_PRIMARY + 224)), 4 * TILE_SIZE_4BPP);
} }
static void TilesetAnim_MauvilleGym(u16 timer) static void TilesetAnim_MauvilleGym(u16 timer)
{ {
if (timer % 2 == 0) if (timer % 2 == 0)
QueueAnimTiles_MauvilleGym_ElectricGates(timer >> 1); QueueAnimTiles_MauvilleGym_ElectricGates(timer / 2);
} }
static void TilesetAnim_SootopolisGym(u16 timer) static void TilesetAnim_SootopolisGym(u16 timer)
{ {
if (timer % 8 == 0) if (timer % 8 == 0)
QueueAnimTiles_SootopolisGym_Waterfalls(timer >> 3); QueueAnimTiles_SootopolisGym_Waterfalls(timer / 8);
} }
static void TilesetAnim_EliteFour(u16 timer) static void TilesetAnim_EliteFour(u16 timer)
{ {
if (timer % 64 == 1) if (timer % 64 == 1)
QueueAnimTiles_EliteFour_GroundLights(timer >> 6); QueueAnimTiles_EliteFour_GroundLights(timer / 64);
if (timer % 8 == 1) if (timer % 8 == 1)
QueueAnimTiles_EliteFour_WallLights(timer >> 3); QueueAnimTiles_EliteFour_WallLights(timer / 8);
} }
static void TilesetAnim_BikeShop(u16 timer) static void TilesetAnim_BikeShop(u16 timer)
{ {
if (timer % 4 == 0) if (timer % 4 == 0)
QueueAnimTiles_BikeShop_BlinkingLights(timer >> 2); QueueAnimTiles_BikeShop_BlinkingLights(timer / 4);
} }
static void TilesetAnim_BattlePyramid(u16 timer) static void TilesetAnim_BattlePyramid(u16 timer)
{ {
if (timer % 8 == 0) if (timer % 8 == 0)
{ {
QueueAnimTiles_BattlePyramid_Torch(timer >> 3); QueueAnimTiles_BattlePyramid_Torch(timer / 8);
QueueAnimTiles_BattlePyramid_StatueShadow(timer >> 3); QueueAnimTiles_BattlePyramid_StatueShadow(timer / 8);
} }
} }
static void TilesetAnim_BattleDome(u16 timer) static void TilesetAnim_BattleDome(u16 timer)
{ {
if (timer % 4 == 0) if (timer % 4 == 0)
BlendAnimPalette_BattleDome_FloorLights(timer >> 2); BlendAnimPalette_BattleDome_FloorLights(timer / 4);
} }
static void TilesetAnim_BattleDome2(u16 timer) static void TilesetAnim_BattleDome2(u16 timer)
{ {
if (timer % 4 == 0) if (timer % 4 == 0)
BlendAnimPalette_BattleDome_FloorLightsNoBlend(timer >> 2); BlendAnimPalette_BattleDome_FloorLightsNoBlend(timer / 4);
} }
static void QueueAnimTiles_Building_TVTurnedOn(u16 timer) static void QueueAnimTiles_Building_TVTurnedOn(u16 timer)
{ {
u16 i = timer % 2; u16 i = timer % ARRAY_COUNT(gTilesetAnims_Building_TvTurnedOn);
AppendTilesetAnimToBuffer(gTilesetAnims_Building_TvTurnedOn[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(496)), 0x80); AppendTilesetAnimToBuffer(gTilesetAnims_Building_TvTurnedOn[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(496)), 4 * TILE_SIZE_4BPP);
} }
static void QueueAnimTiles_SootopolisGym_Waterfalls(u16 timer) static void QueueAnimTiles_SootopolisGym_Waterfalls(u16 timer)
{ {
u16 i = timer % 3; u16 i = timer % min(ARRAY_COUNT(gTilesetAnims_SootopolisGym_SideWaterfall), ARRAY_COUNT(gTilesetAnims_SootopolisGym_FrontWaterfall));
AppendTilesetAnimToBuffer(gTilesetAnims_SootopolisGym_SideWaterfall[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(NUM_TILES_IN_PRIMARY + 496)), 0x180); AppendTilesetAnimToBuffer(gTilesetAnims_SootopolisGym_SideWaterfall[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(NUM_TILES_IN_PRIMARY + 496)), 12 * TILE_SIZE_4BPP);
AppendTilesetAnimToBuffer(gTilesetAnims_SootopolisGym_FrontWaterfall[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(NUM_TILES_IN_PRIMARY + 464)), 0x280); AppendTilesetAnimToBuffer(gTilesetAnims_SootopolisGym_FrontWaterfall[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(NUM_TILES_IN_PRIMARY + 464)), 20 * TILE_SIZE_4BPP);
} }
static void QueueAnimTiles_EliteFour_WallLights(u16 timer) static void QueueAnimTiles_EliteFour_WallLights(u16 timer)
{ {
u16 i = timer % 4; u16 i = timer % ARRAY_COUNT(gTilesetAnims_EliteFour_WallLights);
AppendTilesetAnimToBuffer(gTilesetAnims_EliteFour_WallLights[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(NUM_TILES_IN_PRIMARY + 504)), 0x20); AppendTilesetAnimToBuffer(gTilesetAnims_EliteFour_WallLights[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(NUM_TILES_IN_PRIMARY + 504)), 1 * TILE_SIZE_4BPP);
} }
static void QueueAnimTiles_EliteFour_GroundLights(u16 timer) static void QueueAnimTiles_EliteFour_GroundLights(u16 timer)
{ {
u16 i = timer % 2; u16 i = timer % ARRAY_COUNT(gTilesetAnims_EliteFour_FloorLight);
AppendTilesetAnimToBuffer(gTilesetAnims_EliteFour_FloorLight[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(NUM_TILES_IN_PRIMARY + 480)), 0x80); AppendTilesetAnimToBuffer(gTilesetAnims_EliteFour_FloorLight[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(NUM_TILES_IN_PRIMARY + 480)), 4 * TILE_SIZE_4BPP);
} }
static void QueueAnimTiles_MauvilleGym_ElectricGates(u16 timer) static void QueueAnimTiles_MauvilleGym_ElectricGates(u16 timer)
{ {
u16 i = timer % 2; u16 i = timer % ARRAY_COUNT(gTilesetAnims_MauvilleGym_ElectricGates);
AppendTilesetAnimToBuffer(gTilesetAnims_MauvilleGym_ElectricGates[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(NUM_TILES_IN_PRIMARY + 144)), 0x200); AppendTilesetAnimToBuffer(gTilesetAnims_MauvilleGym_ElectricGates[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(NUM_TILES_IN_PRIMARY + 144)), 16 * TILE_SIZE_4BPP);
} }
static void QueueAnimTiles_BikeShop_BlinkingLights(u16 timer) static void QueueAnimTiles_BikeShop_BlinkingLights(u16 timer)
{ {
u16 i = timer % 2; u16 i = timer % ARRAY_COUNT(gTilesetAnims_BikeShop_BlinkingLights);
AppendTilesetAnimToBuffer(gTilesetAnims_BikeShop_BlinkingLights[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(NUM_TILES_IN_PRIMARY + 496)), 0x120); AppendTilesetAnimToBuffer(gTilesetAnims_BikeShop_BlinkingLights[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(NUM_TILES_IN_PRIMARY + 496)), 9 * TILE_SIZE_4BPP);
} }
static void QueueAnimTiles_Sootopolis_StormyWater(u16 timer) static void QueueAnimTiles_Sootopolis_StormyWater(u16 timer)
{ {
u16 i = timer % 8; u16 i = timer % ARRAY_COUNT(gTilesetAnims_Sootopolis_StormyWater);
AppendTilesetAnimToBuffer(gTilesetAnims_Sootopolis_StormyWater[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(NUM_TILES_IN_PRIMARY + 240)), 0xc00); AppendTilesetAnimToBuffer(gTilesetAnims_Sootopolis_StormyWater[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(NUM_TILES_IN_PRIMARY + 240)), 96 * TILE_SIZE_4BPP);
} }
static void QueueAnimTiles_BattlePyramid_Torch(u16 timer) static void QueueAnimTiles_BattlePyramid_Torch(u16 timer)
{ {
u16 i = timer % 3; u16 i = timer % ARRAY_COUNT(gTilesetAnims_BattlePyramid_Torch);
AppendTilesetAnimToBuffer(gTilesetAnims_BattlePyramid_Torch[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(NUM_TILES_IN_PRIMARY + 151)), 0x100); AppendTilesetAnimToBuffer(gTilesetAnims_BattlePyramid_Torch[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(NUM_TILES_IN_PRIMARY + 151)), 8 * TILE_SIZE_4BPP);
} }
static void QueueAnimTiles_BattlePyramid_StatueShadow(u16 timer) static void QueueAnimTiles_BattlePyramid_StatueShadow(u16 timer)
{ {
u16 i = timer % 3; u16 i = timer % ARRAY_COUNT(gTilesetAnims_BattlePyramid_StatueShadow);
AppendTilesetAnimToBuffer(gTilesetAnims_BattlePyramid_StatueShadow[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(NUM_TILES_IN_PRIMARY + 135)), 0x100); AppendTilesetAnimToBuffer(gTilesetAnims_BattlePyramid_StatueShadow[i], (u16 *)(BG_VRAM + TILE_OFFSET_4BPP(NUM_TILES_IN_PRIMARY + 135)), 8 * TILE_SIZE_4BPP);
} }
static void BlendAnimPalette_BattleDome_FloorLights(u16 timer) static void BlendAnimPalette_BattleDome_FloorLights(u16 timer)
{ {
CpuCopy16(gTilesetAnims_BattleDomeFloorLightPals[timer % 4], gPlttBufferUnfaded + 0x80, 32); CpuCopy16(gTilesetAnims_BattleDomeFloorLightPals[timer % ARRAY_COUNT(gTilesetAnims_BattleDomeFloorLightPals)], &gPlttBufferUnfaded[0x80], 32);
BlendPalette(0x80, 16, gPaletteFade.y, gPaletteFade.blendColor & 0x7FFF); BlendPalette(0x80, 16, gPaletteFade.y, gPaletteFade.blendColor & 0x7FFF);
if ((u8)FindTaskIdByFunc(Task_BattleTransition_Intro) != TASK_NONE) if ((u8)FindTaskIdByFunc(Task_BattleTransition_Intro) != TASK_NONE)
{ {
@ -1178,7 +1178,7 @@ static void BlendAnimPalette_BattleDome_FloorLights(u16 timer)
static void BlendAnimPalette_BattleDome_FloorLightsNoBlend(u16 timer) static void BlendAnimPalette_BattleDome_FloorLightsNoBlend(u16 timer)
{ {
CpuCopy16(gTilesetAnims_BattleDomeFloorLightPals[timer % 4], gPlttBufferUnfaded + 0x80, 32); CpuCopy16(gTilesetAnims_BattleDomeFloorLightPals[timer % ARRAY_COUNT(gTilesetAnims_BattleDomeFloorLightPals)], &gPlttBufferUnfaded[0x80], 32);
if ((u8)FindTaskIdByFunc(Task_BattleTransition_Intro) == TASK_NONE) if ((u8)FindTaskIdByFunc(Task_BattleTransition_Intro) == TASK_NONE)
{ {
BlendPalette(0x80, 16, gPaletteFade.y, gPaletteFade.blendColor & 0x7FFF); BlendPalette(0x80, 16, gPaletteFade.y, gPaletteFade.blendColor & 0x7FFF);