Minor documentation

Some things I figured out while working on my hack.
- The Subsprite tables do not use `DISPLAY_WIDTH`, but rather use -16, since they are signed bytes. The negative numbers better illustrate what the tables are doing.
- Figured out the as-of-yet undocumented data in SpriteCB_FlygonSilhouette
This commit is contained in:
tustin2121
2022-09-17 13:33:10 -04:00
parent 36494c1c1d
commit 13877f71dc
2 changed files with 67 additions and 35 deletions

View File

@@ -318,10 +318,17 @@ static const struct SpriteTemplate sHealthbarSpriteTemplates[MAX_BATTLERS_COUNT]
}
};
/* v-- Origin
[0 + ][1 ]
[ ][ ] sUnused_Subsprites_0
[ ][ ]
[______________][______] 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),
@@ -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),
@@ -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),
@@ -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),
@@ -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),
@@ -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),
@@ -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),
@@ -466,10 +484,14 @@ static const struct Subsprite sHealthBar_Subsprites_Player[] =
}
};
/* v-- Origin
[] [0 + ][1 ] 72x8
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),
@@ -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),

View File

@@ -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);
}
@@ -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;