Skip to content

Commit

Permalink
Sync Spinda dot drawing formatting from pokeemerald
Browse files Browse the repository at this point in the history
  • Loading branch information
citrusbolt committed Feb 25, 2024
1 parent 6f21623 commit 3128bac
Showing 1 changed file with 26 additions and 13 deletions.
39 changes: 26 additions & 13 deletions payload/src/pokemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -728,11 +728,21 @@ u32 CheckPartyHasHadPokerus(struct Pokemon *party, u8 selection)
return retVal;
}

#define SPINDA_SPOT_HEIGHT 16
#define SPINDA_SPOT_WIDTH 16

// Spots can be drawn on Spinda's color indexes 1, 2, or 3
#define FIRST_SPOT_COLOR 1
#define LAST_SPOT_COLOR 3

// To draw a spot pixel, add 4 to the color index
#define SPOT_COLOR_ADJUSTMENT 4

void DrawSpindasSpots(u16 species, u32 personality, u8 *dest)
{
if (species == SPECIES_SPINDA)
{
s32 i, j, k;
s32 i, row, column;
u32 var;

if (gRomDetection_IsRubySapphire != FALSE)
Expand All @@ -745,29 +755,32 @@ void DrawSpindasSpots(u16 species, u32 personality, u8 *dest)
u8 x = gSpindaSpotGraphics[i].x + ((personality & 0x0F) - 8);
u8 y = gSpindaSpotGraphics[i].y + (((personality & 0xF0) >> 4) - 8) - var;

for (j = 0; j < 16; j++)
for (row = 0; row < SPINDA_SPOT_HEIGHT; row++)
{
s32 row = gSpindaSpotGraphics[i].image[j];
s32 spotPixelRow = gSpindaSpotGraphics[i].image[row];

for (k = x; k < x + 16; k++)
for (column = x; column < x + SPINDA_SPOT_WIDTH; column++)
{
u8 *val = dest + ((k / 8) * 32) + ((k % 8) / 2) + ((y >> 3) << 8) + ((y & 7) << 2);
u8 *destPixels = dest + ((column / 8) * TILE_SIZE_4BPP) +
((column % 8) / 2) +
((y / 8) * TILE_SIZE_4BPP * 8) +
((y % 8) * 4);

if (row & 1)
if (spotPixelRow & 1)
{
if (k & 1)
if (column & 1)
{
if ((u8)((*val & 0xF0) - 0x10) <= 0x20)
*val += 0x40;
if ((u8)((*destPixels & 0xF0) - (FIRST_SPOT_COLOR << 4)) <= ((LAST_SPOT_COLOR - FIRST_SPOT_COLOR) << 4))
*destPixels += (SPOT_COLOR_ADJUSTMENT << 4);
}
else
{
if ((u8)((*val & 0xF) - 0x01) <= 0x02)
*val += 0x04;
if ((u8)((*destPixels & 0xF) - FIRST_SPOT_COLOR) <= (LAST_SPOT_COLOR - FIRST_SPOT_COLOR))
*destPixels += SPOT_COLOR_ADJUSTMENT;
}
}

row >>= 1;
spotPixelRow >>= 1;
}

y++;
Expand Down Expand Up @@ -1209,7 +1222,7 @@ u16 FixUnownSpecies(u16 species, u32 personality)
else
{
if (species > SPECIES_EGG)
result = 260;
result = SPECIES_OLD_UNOWN_J; // ???
else
result = species;
}
Expand Down

0 comments on commit 3128bac

Please sign in to comment.