Skip to content

Commit

Permalink
Merge pull request #1786 from tustin2121/patch-spritestuff
Browse files Browse the repository at this point in the history
Subsprite Tables Documentation
  • Loading branch information
GriffinRichards authored Oct 7, 2022
2 parents e293986 + ea168d1 commit bb2e64b
Show file tree
Hide file tree
Showing 6 changed files with 265 additions and 43 deletions.
60 changes: 44 additions & 16 deletions src/battle_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,17 @@ static const struct SpriteTemplate sHealthbarSpriteTemplates[MAX_BATTLERS_COUNT]
}
};

/* v-- Origin
[0 + ][1 ]
[ ][ ]
[ ][ ]
[______________][______] 96x40
[2 ][3 ][4 ]
*/
static const struct Subsprite sUnused_Subsprites_0[] =
{
{
.x = DISPLAY_WIDTH,
.x = -16,
.y = 0,
.shape = SPRITE_SHAPE(64x32),
.size = SPRITE_SIZE(64x32),
Expand All @@ -337,7 +344,7 @@ static const struct Subsprite sUnused_Subsprites_0[] =
.priority = 1
},
{
.x = DISPLAY_WIDTH,
.x = -16,
.y = 32,
.shape = SPRITE_SHAPE(32x8),
.size = SPRITE_SIZE(32x8),
Expand All @@ -362,10 +369,11 @@ static const struct Subsprite sUnused_Subsprites_0[] =
}
};

// This subsprite table has the same layout as above, but offset by 64 base tiles.
static const struct Subsprite sUnused_Subsprites_2[] =
{
{
.x = DISPLAY_WIDTH,
.x = -16,
.y = 0,
.shape = SPRITE_SHAPE(64x32),
.size = SPRITE_SIZE(64x32),
Expand All @@ -381,7 +389,7 @@ static const struct Subsprite sUnused_Subsprites_2[] =
.priority = 1
},
{
.x = DISPLAY_WIDTH,
.x = -16,
.y = 32,
.shape = SPRITE_SHAPE(32x8),
.size = SPRITE_SIZE(32x8),
Expand All @@ -406,10 +414,16 @@ static const struct Subsprite sUnused_Subsprites_2[] =
}
};

/* v-- Origin
[0 + ][1 ]
[ ][ ]
[ ][ ]
[ ][ ] 96x32
*/
static const struct Subsprite sUnused_Subsprites_1[] =
{
{
.x = DISPLAY_WIDTH,
.x = -16,
.y = 0,
.shape = SPRITE_SHAPE(64x32),
.size = SPRITE_SIZE(64x32),
Expand All @@ -426,10 +440,11 @@ static const struct Subsprite sUnused_Subsprites_1[] =
}
};

// Same as above
static const struct Subsprite sUnused_Subsprites_3[] =
{
{
.x = DISPLAY_WIDTH,
.x = -16,
.y = 0,
.shape = SPRITE_SHAPE(64x32),
.size = SPRITE_SIZE(64x32),
Expand All @@ -446,10 +461,13 @@ static const struct Subsprite sUnused_Subsprites_3[] =
}
};

/* v-- Origin
[0 + ][1 ] 64x8
*/
static const struct Subsprite sHealthBar_Subsprites_Player[] =
{
{
.x = DISPLAY_WIDTH,
.x = -16,
.y = 0,
.shape = SPRITE_SHAPE(32x8),
.size = SPRITE_SIZE(32x8),
Expand All @@ -466,10 +484,14 @@ static const struct Subsprite sHealthBar_Subsprites_Player[] =
}
};

/* v-- Origin
[] [0 + ][1 ] 8x8 + 64x8
2^ ^--- Note 8px space
*/
static const struct Subsprite sHealthBar_Subsprites_Opponent[] =
{
{
.x = DISPLAY_WIDTH,
.x = -16,
.y = 0,
.shape = SPRITE_SHAPE(32x8),
.size = SPRITE_SIZE(32x8),
Expand All @@ -485,7 +507,7 @@ static const struct Subsprite sHealthBar_Subsprites_Opponent[] =
.priority = 1
},
{
.x = DISPLAY_WIDTH - 16,
.x = -32,
.y = 0,
.shape = SPRITE_SHAPE(8x8),
.size = SPRITE_SIZE(8x8),
Expand All @@ -507,27 +529,29 @@ static const struct SubspriteTable sHealthBar_SubspriteTables[] =
[B_SIDE_PLAYER] = {ARRAY_COUNT(sHealthBar_Subsprites_Player), sHealthBar_Subsprites_Player},
[B_SIDE_OPPONENT] = {ARRAY_COUNT(sHealthBar_Subsprites_Opponent), sHealthBar_Subsprites_Opponent}
};

/* v-- Origin
[0 ][1 ][2 ][3 ] 128x8
*/
static const struct Subsprite sStatusSummaryBar_Subsprites_Enter[] =
{
{
.x = 32 * 5,
.x = 32 * -3,
.y = 0,
.shape = SPRITE_SHAPE(32x8),
.size = SPRITE_SIZE(32x8),
.tileOffset = 0,
.priority = 1
},
{
.x = 32 * 6,
.x = 32 * -2,
.y = 0,
.shape = SPRITE_SHAPE(32x8),
.size = SPRITE_SIZE(32x8),
.tileOffset = 4,
.priority = 1
},
{
.x = 32 * 7,
.x = 32 * -1,
.y = 0,
.shape = SPRITE_SHAPE(32x8),
.size = SPRITE_SIZE(32x8),
Expand All @@ -544,26 +568,30 @@ static const struct Subsprite sStatusSummaryBar_Subsprites_Enter[] =
}
};

/* v-- Origin
[0 ][1 ][2 ][3 ][4 ][5 ] 192x8
^-- uses same tiles --^
*/
static const struct Subsprite sStatusSummaryBar_Subsprites_Exit[] =
{
{
.x = 32 * 5,
.x = 32 * -3,
.y = 0,
.shape = SPRITE_SHAPE(32x8),
.size = SPRITE_SIZE(32x8),
.tileOffset = 0,
.priority = 1
},
{
.x = 32 * 6,
.x = 32 * -2,
.y = 0,
.shape = SPRITE_SHAPE(32x8),
.size = SPRITE_SIZE(32x8),
.tileOffset = 4,
.priority = 1
},
{
.x = 32 * 7,
.x = 32 * -1,
.y = 0,
.shape = SPRITE_SHAPE(32x8),
.size = SPRITE_SIZE(32x8),
Expand Down
3 changes: 3 additions & 0 deletions src/contest.c
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,9 @@ static const struct SpriteTemplate sSpriteTemplates_NextTurn[CONTESTANT_COUNT] =
}
};

/* v-- Origin
[0 +][1 ] 64x8
*/
static const struct Subsprite sSubsprites_NextTurn[] =
{
{
Expand Down
10 changes: 10 additions & 0 deletions src/field_effect.c
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,11 @@ static const struct SpriteFrameImage sPicTable_HofMonitorSmall[] =
{.data = sHofMonitorSmall_Gfx, .size = 0x200} // the macro breaks down here
};

/*
[0_][] <-1 24x16
[2 ][] <-3
^-- Origin
*/
static const struct Subsprite sSubsprites_PokecenterMonitor[] =
{
{
Expand Down Expand Up @@ -443,6 +448,11 @@ static const struct Subsprite sSubsprites_PokecenterMonitor[] =

static const struct SubspriteTable sSubspriteTable_PokecenterMonitor = subsprite_table(sSubsprites_PokecenterMonitor);

/*
[0_____][1_____] 24x16
[2 ][3 ]
^-- Origin
*/
static const struct Subsprite sSubsprites_HofMonitorBig[] =
{
{
Expand Down
62 changes: 36 additions & 26 deletions src/intro.c
Original file line number Diff line number Diff line change
Expand Up @@ -3322,24 +3322,29 @@ static u8 CreateGameFreakLogoSprites(s16 x, s16 y, s16 unused)
#undef sLetterX
#undef COLOR_CHANGES

#define sScale data[1]
#define sRot data[2]
#define sPos data[3]
#define sTimer data[7]

static void SpriteCB_FlygonSilhouette(struct Sprite *sprite)
{
sprite->data[7]++;
sprite->sTimer++;

if (sprite->sState != 0)
{
s16 sin1;
s16 sin2;
s16 sin;
s16 cos;

s16 a, b, c, d;

sin1 = gSineTable[(u8)sprite->data[2]];
sin2 = gSineTable[(u8)(sprite->data[2] + 64)];

d = Q_8_8_TO_INT(sin2 * sprite->data[1]);
c = Q_8_8_TO_INT(-sin1 * sprite->data[1]);
b = Q_8_8_TO_INT(sin1 * sprite->data[1]);
a = Q_8_8_TO_INT(sin2 * sprite->data[1]);
// Determines rotation of the sprite
sin = gSineTable[(u8)sprite->sRot];
cos = gSineTable[(u8)(sprite->sRot + 64)];
// Converts rotation and scale into the OAM matrix
d = Q_8_8_TO_INT( cos * sprite->sScale);
c = Q_8_8_TO_INT(-sin * sprite->sScale);
b = Q_8_8_TO_INT( sin * sprite->sScale);
a = Q_8_8_TO_INT( cos * sprite->sScale);

SetOamMatrix(1, a, b, c, d);
}
Expand All @@ -3353,36 +3358,41 @@ static void SpriteCB_FlygonSilhouette(struct Sprite *sprite)
CalcCenterToCornerVec(sprite, SPRITE_SHAPE(64x32), SPRITE_SIZE(64x32), ST_OAM_AFFINE_DOUBLE);
sprite->invisible = FALSE;
sprite->sState = 1;
sprite->data[1] = 0x80;
sprite->data[2] = 0;
sprite->data[3] = 0;
sprite->sScale = 128;
sprite->sRot = 0;
sprite->sPos = 0;
break;
case 1:
sprite->x2 = -Sin((u8)sprite->data[3], 140);
sprite->y2 = -Sin((u8)sprite->data[3], 120);
sprite->data[1] += 7;
sprite->data[3] += 3;
sprite->x2 = -Sin((u8)sprite->sPos, 140);
sprite->y2 = -Sin((u8)sprite->sPos, 120);
sprite->sScale += 7;
sprite->sPos += 3;
if (sprite->x + sprite->x2 <= -16)
{
sprite->oam.priority = 3;
sprite->sState++;
sprite->x = 20;
sprite->y = 40;
sprite->data[1] = 0x200;
sprite->data[2] = 0;
sprite->data[3] = 0x10;
sprite->sScale = 512;
sprite->sRot = 0;
sprite->sPos = 16;
}
break;
case 2:
sprite->x2 = Sin((u8)sprite->data[3], 34);
sprite->y2 = -Cos((u8)sprite->data[3], 60);
sprite->data[1] += 2;
if (sprite->data[7] % 5 == 0)
sprite->data[3]++;
sprite->x2 = Sin((u8)sprite->sPos, 34);
sprite->y2 = -Cos((u8)sprite->sPos, 60);
sprite->sScale += 2;
if (sprite->sTimer % 5 == 0)
sprite->sPos++;
break;
}
}

#undef sScale
#undef sRot
#undef sPos
#undef sTimer

static void SpriteCB_RayquazaOrb(struct Sprite *sprite)
{
u16 foo;
Expand Down
20 changes: 20 additions & 0 deletions src/naming_screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -2179,6 +2179,12 @@ static const struct OamData sOam_32x16 =
.paletteNum = 0,
};

/*
[0_____][] <-1 40x32
[2_____][] <-3
[4___+_][] <-5/Origin
[6 ][] <-7
*/
static const struct Subsprite sSubsprites_PageSwapFrame[] =
{
{
Expand Down Expand Up @@ -2247,6 +2253,10 @@ static const struct Subsprite sSubsprites_PageSwapFrame[] =
}
};

/*
[0_][] <-1 24x8
^-- Origin
*/
static const struct Subsprite sSubsprites_PageSwapText[] =
{
{
Expand All @@ -2267,6 +2277,11 @@ static const struct Subsprite sSubsprites_PageSwapText[] =
}
};

/*
[0_____][] <-1 40x24
[2_____][] <-3
[4___+_][] <-5/Origin
*/
static const struct Subsprite sSubsprites_Button[] =
{
{
Expand Down Expand Up @@ -2319,6 +2334,11 @@ static const struct Subsprite sSubsprites_Button[] =
}
};

/*
[0_] 16x24
[1+] <--Origin
[2_]
*/
static const struct Subsprite sSubsprites_PCIcon[] =
{
{
Expand Down
Loading

0 comments on commit bb2e64b

Please sign in to comment.