mirror of
https://github.com/pret/pokefirered.git
synced 2026-10-01 13:29:23 -05:00
refactoring
This commit is contained in:
@@ -36,6 +36,12 @@ struct SpriteCopyRequest
|
||||
u16 size;
|
||||
};
|
||||
|
||||
struct OamDimensions32
|
||||
{
|
||||
s32 width;
|
||||
s32 height;
|
||||
};
|
||||
|
||||
struct OamDimensions
|
||||
{
|
||||
s8 width;
|
||||
@@ -197,6 +203,31 @@ static const AffineAnimCmdFunc sAffineAnimCmdFuncs[] =
|
||||
AffineAnimCmd_frame,
|
||||
};
|
||||
|
||||
static const struct OamDimensions32 sOamDimensions32[3][4] =
|
||||
{
|
||||
[ST_OAM_SQUARE] =
|
||||
{
|
||||
[SPRITE_SIZE(8x8)] = { 8, 8 },
|
||||
[SPRITE_SIZE(16x16)] = { 16, 16 },
|
||||
[SPRITE_SIZE(32x32)] = { 32, 32 },
|
||||
[SPRITE_SIZE(64x64)] = { 64, 64 },
|
||||
},
|
||||
[ST_OAM_H_RECTANGLE] =
|
||||
{
|
||||
[SPRITE_SIZE(16x8)] = { 16, 8 },
|
||||
[SPRITE_SIZE(32x8)] = { 32, 8 },
|
||||
[SPRITE_SIZE(32x16)] = { 32, 16 },
|
||||
[SPRITE_SIZE(64x32)] = { 64, 32 },
|
||||
},
|
||||
[ST_OAM_V_RECTANGLE] =
|
||||
{
|
||||
[SPRITE_SIZE(8x16)] = { 8, 16 },
|
||||
[SPRITE_SIZE(8x32)] = { 8, 32 },
|
||||
[SPRITE_SIZE(16x32)] = { 16, 32 },
|
||||
[SPRITE_SIZE(32x64)] = { 32, 64 },
|
||||
},
|
||||
};
|
||||
|
||||
static const s32 sOamDimensionsCopy[3][4][2] =
|
||||
{
|
||||
[ST_OAM_SQUARE] = {
|
||||
@@ -1166,22 +1197,22 @@ static s32 GetAnchorCoord(s32 baseDim, s32 xformed, s32 modifier)
|
||||
|
||||
static void UpdateSpriteMatrixAnchorPos(struct Sprite *sprite, s32 x, s32 y)
|
||||
{
|
||||
s32 dim, baseDim, xFormed;
|
||||
s32 dimension, var1, var2;
|
||||
|
||||
u32 matrixNum = sprite->oam.matrixNum;
|
||||
if (x != NO_ANCHOR)
|
||||
{
|
||||
dim = sOamDimensionsCopy[sprite->oam.shape][sprite->oam.size][0];
|
||||
baseDim = dim << 8;
|
||||
xFormed = (dim << 16) / gOamMatrices[matrixNum].a;
|
||||
sprite->x2 = GetAnchorCoord(baseDim, xFormed, x);
|
||||
dimension = sOamDimensions32[sprite->oam.shape][sprite->oam.size].width;
|
||||
var1 = dimension << 8;
|
||||
var2 = (dimension << 16) / gOamMatrices[matrixNum].a;
|
||||
sprite->x2 = GetAnchorCoord(var1, var2, x);
|
||||
}
|
||||
if (y != NO_ANCHOR)
|
||||
{
|
||||
dim = sOamDimensionsCopy[sprite->oam.shape][sprite->oam.size][1];
|
||||
baseDim = dim << 8;
|
||||
xFormed = (dim << 16) / gOamMatrices[matrixNum].d;
|
||||
sprite->y2 = GetAnchorCoord(baseDim, xFormed, y);
|
||||
dimension = sOamDimensions32[sprite->oam.shape][sprite->oam.size].height;
|
||||
var1 = dimension << 8;
|
||||
var2 = (dimension << 16) / gOamMatrices[matrixNum].d;
|
||||
sprite->y2 = GetAnchorCoord(var1, var2, y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
#define OW_SUBSTITUTE_PLACEHOLDER TRUE // Use a substitute OW for Pokémon that are missing overworld sprites
|
||||
#define OW_LARGE_OW_SUPPORT TRUE // If true, adds a small amount of overhead to OW code so that large (48x48, 64x64) OWs will display correctly under bridges, etc.
|
||||
#define OW_PKMN_OBJECTS_SHARE_PALETTES FALSE // [WIP!! NOT ALL PALETTES HAVE BEEN ADJUSTED FOR THIS!!] If TRUE, follower palettes are taken from battle sprites.
|
||||
#define OW_GFX_COMPRESS FALSE // Adds support for compressed OW graphics, (Also compresses pokemon follower graphics).
|
||||
#define OW_GFX_COMPRESS TRUE // Adds support for compressed OW graphics, (Also compresses pokemon follower graphics).
|
||||
// Compressed gfx are incompatible with non-power-of-two sprite sizes:
|
||||
// (You should not use 48x48 sprites/tables for compressed gfx)
|
||||
// 16x32, 32x32, 64x64 etc are fine
|
||||
|
||||
@@ -29,6 +29,6 @@ void HandleLoadSpecialPokePic(bool32 isFrontPic, void *dest, s32 species, u32 pe
|
||||
|
||||
void LoadSpecialPokePic(void *dest, s32 species, u32 personality, bool8 isFrontPic);
|
||||
|
||||
u32 GetDecompressedDataSize(const u8 *ptr);
|
||||
u32 GetDecompressedDataSize(const u32 *ptr);
|
||||
|
||||
#endif // GUARD_DECOMPRESS_H
|
||||
|
||||
@@ -97,13 +97,13 @@ void LoadCompressedSpritePaletteWithTag(const u32 *pal, u16 tag)
|
||||
LoadSpritePalette(&dest);
|
||||
}
|
||||
|
||||
void LoadCompressedSpritePaletteOverrideBuffer(const struct CompressedSpritePalette *a, void *buffer)
|
||||
void LoadCompressedSpritePaletteOverrideBuffer(const struct CompressedSpritePalette *src, void *buffer)
|
||||
{
|
||||
struct SpritePalette dest;
|
||||
|
||||
LZ77UnCompWram(a->data, buffer);
|
||||
LZ77UnCompWram(src->data, buffer);
|
||||
dest.data = buffer;
|
||||
dest.tag = a->tag;
|
||||
dest.tag = src->tag;
|
||||
LoadSpritePalette(&dest);
|
||||
}
|
||||
|
||||
@@ -123,14 +123,17 @@ void LoadSpecialPokePic(void *dest, s32 species, u32 personality, bool8 isFrontP
|
||||
if (species == SPECIES_UNOWN)
|
||||
species = GetUnownSpeciesId(personality);
|
||||
|
||||
if (isFrontPic) {
|
||||
if (isFrontPic)
|
||||
{
|
||||
if (gSpeciesInfo[species].frontPicFemale != NULL && IsPersonalityFemale(species, personality))
|
||||
LZ77UnCompWram(gSpeciesInfo[species].frontPicFemale, dest);
|
||||
else if (gSpeciesInfo[species].frontPic != NULL)
|
||||
LZ77UnCompWram(gSpeciesInfo[species].frontPic, dest);
|
||||
else
|
||||
LZ77UnCompWram(gSpeciesInfo[SPECIES_NONE].frontPic, dest);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gSpeciesInfo[species].backPicFemale != NULL && IsPersonalityFemale(species, personality))
|
||||
LZ77UnCompWram(gSpeciesInfo[species].backPicFemale, dest);
|
||||
else if (gSpeciesInfo[species].backPic != NULL)
|
||||
@@ -141,18 +144,18 @@ void LoadSpecialPokePic(void *dest, s32 species, u32 personality, bool8 isFrontP
|
||||
DrawSpindaSpots(species, personality, dest, isFrontPic);
|
||||
}
|
||||
|
||||
bool8 LoadCompressedSpriteSheetUsingHeap(const struct CompressedSpriteSheet* src)
|
||||
bool8 LoadCompressedSpriteSheetUsingHeap(const struct CompressedSpriteSheet *src)
|
||||
{
|
||||
struct SpriteSheet dest;
|
||||
void *buffer;
|
||||
|
||||
buffer = AllocZeroed(*((u32 *)src->data) >> 8);
|
||||
if (!buffer)
|
||||
return TRUE;
|
||||
buffer = AllocZeroed(src->data[0] >> 8);
|
||||
LZ77UnCompWram(src->data, buffer);
|
||||
|
||||
dest.data = buffer;
|
||||
dest.size = src->size;
|
||||
dest.tag = src->tag;
|
||||
|
||||
LoadSpriteSheet(&dest);
|
||||
Free(buffer);
|
||||
return FALSE;
|
||||
@@ -163,12 +166,11 @@ bool8 LoadCompressedSpritePaletteUsingHeap(const struct CompressedSpritePalette
|
||||
struct SpritePalette dest;
|
||||
void *buffer;
|
||||
|
||||
buffer = AllocZeroed(*((u32 *)src->data) >> 8);
|
||||
if (!buffer)
|
||||
return TRUE;
|
||||
buffer = AllocZeroed(src->data[0] >> 8);
|
||||
LZ77UnCompWram(src->data, buffer);
|
||||
dest.data = buffer;
|
||||
dest.tag = src->tag;
|
||||
|
||||
LoadSpritePalette(&dest);
|
||||
Free(buffer);
|
||||
return FALSE;
|
||||
@@ -190,14 +192,8 @@ bool8 LoadCompressedSpritePaletteUsingHeapWithTag(const u32 *pal, u16 tag)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
u32 GetDecompressedDataSize(const u8 *ptr)
|
||||
u32 GetDecompressedDataSize(const u32 *ptr)
|
||||
{
|
||||
u32 ptr32[1];
|
||||
u8 *ptr8 = (u8 *)ptr32;
|
||||
|
||||
ptr8[0] = ptr[1];
|
||||
ptr8[1] = ptr[2];
|
||||
ptr8[2] = ptr[3];
|
||||
ptr8[3] = 0;
|
||||
return ptr32[0];
|
||||
const u8 *ptr8 = (const u8 *)ptr;
|
||||
return (ptr8[3] << 16) | (ptr8[2] << 8) | (ptr8[1]);
|
||||
}
|
||||
|
||||
@@ -1789,7 +1789,7 @@ static u8 LoadDynamicFollowerPaletteFromGraphicsId(u16 graphicsId, bool8 shiny,
|
||||
}
|
||||
|
||||
// Used to create a sprite using a graphicsId associated with object events.
|
||||
u8 CreateObjectGraphicsSprite(u16 graphicsId, SpriteCallback callback, s16 x, s16 y, u8 subpriority)
|
||||
u8 CreateObjectGraphicsSprite(u16 graphicsId, void (*callback)(struct Sprite *), s16 x, s16 y, u8 subpriority)
|
||||
{
|
||||
struct SpriteTemplate *spriteTemplate;
|
||||
const struct SubspriteTable *subspriteTables;
|
||||
@@ -1993,7 +1993,6 @@ static void FollowerSetGraphics(struct ObjectEvent *objEvent, u16 species, u8 fo
|
||||
ObjectEventSetGraphics(objEvent, graphicsInfo);
|
||||
objEvent->graphicsId = (OBJ_EVENT_GFX_MON_BASE + species) & OBJ_EVENT_GFX_SPECIES_MASK;
|
||||
objEvent->graphicsId |= form << OBJ_EVENT_GFX_SPECIES_BITS;
|
||||
DebugPrintfLevel(MGBA_LOG_ERROR, "graphicsId = %u", objEvent->graphicsId);
|
||||
objEvent->shiny = shiny;
|
||||
if (graphicsInfo->paletteTag == OBJ_EVENT_PAL_TAG_DYNAMIC) // Use palette from species palette table
|
||||
{
|
||||
|
||||
@@ -501,29 +501,29 @@ void FieldEffectStop(struct Sprite *sprite, u8 fldeff)
|
||||
void FieldEffectFreeTilesIfUnused(u16 tileStart)
|
||||
{
|
||||
u8 i;
|
||||
u16 tileTag = GetSpriteTileTagByTileStart(tileStart);
|
||||
if (tileTag == TAG_NONE)
|
||||
return;
|
||||
for (i = 0; i < MAX_SPRITES; i++)
|
||||
u16 tag = GetSpriteTileTagByTileStart(tileStart);
|
||||
|
||||
if (tag != TAG_NONE)
|
||||
{
|
||||
if (gSprites[i].inUse && gSprites[i].usingSheet && tileStart == gSprites[i].sheetTileStart)
|
||||
return;
|
||||
for (i = 0; i < MAX_SPRITES; i++)
|
||||
if (gSprites[i].inUse && gSprites[i].usingSheet && tileStart == gSprites[i].sheetTileStart)
|
||||
return;
|
||||
FreeSpriteTilesByTag(tag);
|
||||
}
|
||||
FreeSpriteTilesByTag(tileTag);
|
||||
}
|
||||
|
||||
void FieldEffectFreePaletteIfUnused(u8 paletteNum)
|
||||
{
|
||||
u8 i;
|
||||
u16 paletteTag = GetSpritePaletteTagByPaletteNum(paletteNum);
|
||||
if (paletteTag == TAG_NONE)
|
||||
return;
|
||||
for (i = 0; i < MAX_SPRITES; i++)
|
||||
u16 tag = GetSpritePaletteTagByPaletteNum(paletteNum);
|
||||
|
||||
if (tag != TAG_NONE)
|
||||
{
|
||||
if (gSprites[i].inUse && gSprites[i].oam.paletteNum == paletteNum)
|
||||
return;
|
||||
for (i = 0; i < MAX_SPRITES; i++)
|
||||
if (gSprites[i].inUse && gSprites[i].oam.paletteNum == paletteNum)
|
||||
return;
|
||||
FreeSpritePaletteByTag(tag);
|
||||
}
|
||||
FreeSpritePaletteByTag(paletteTag);
|
||||
}
|
||||
|
||||
void FieldEffectActiveListClear(void)
|
||||
|
||||
Reference in New Issue
Block a user