Final cleanup
This commit is contained in:
parent
5b734d420b
commit
d5268b9f01
15 changed files with 2022 additions and 1971 deletions
|
@ -932,12 +932,16 @@ void AnimCmd_frame(struct Sprite *sprite)
|
||||||
if (!(sprite->oam.affineMode & ST_OAM_AFFINE_ON_MASK))
|
if (!(sprite->oam.affineMode & ST_OAM_AFFINE_ON_MASK))
|
||||||
SetSpriteOamFlipBits(sprite, hFlip, vFlip);
|
SetSpriteOamFlipBits(sprite, hFlip, vFlip);
|
||||||
|
|
||||||
if (sprite->usingSheet) {
|
if (sprite->usingSheet)
|
||||||
|
{
|
||||||
if (OW_GFX_COMPRESS && sprite->sheetSpan)
|
if (OW_GFX_COMPRESS && sprite->sheetSpan)
|
||||||
imageValue = (imageValue + 1) << sprite->sheetSpan;
|
imageValue = (imageValue + 1) << sprite->sheetSpan;
|
||||||
sprite->oam.tileNum = sprite->sheetTileStart + imageValue;
|
sprite->oam.tileNum = sprite->sheetTileStart + imageValue;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
RequestSpriteFrameImageCopy(imageValue, sprite->oam.tileNum, sprite->images);
|
RequestSpriteFrameImageCopy(imageValue, sprite->oam.tileNum, sprite->images);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimCmd_end(struct Sprite *sprite)
|
void AnimCmd_end(struct Sprite *sprite)
|
||||||
|
@ -968,12 +972,16 @@ void AnimCmd_jump(struct Sprite *sprite)
|
||||||
if (!(sprite->oam.affineMode & ST_OAM_AFFINE_ON_MASK))
|
if (!(sprite->oam.affineMode & ST_OAM_AFFINE_ON_MASK))
|
||||||
SetSpriteOamFlipBits(sprite, hFlip, vFlip);
|
SetSpriteOamFlipBits(sprite, hFlip, vFlip);
|
||||||
|
|
||||||
if (sprite->usingSheet) {
|
if (sprite->usingSheet)
|
||||||
|
{
|
||||||
if (OW_GFX_COMPRESS && sprite->sheetSpan)
|
if (OW_GFX_COMPRESS && sprite->sheetSpan)
|
||||||
imageValue = (imageValue + 1) << sprite->sheetSpan;
|
imageValue = (imageValue + 1) << sprite->sheetSpan;
|
||||||
sprite->oam.tileNum = sprite->sheetTileStart + imageValue;
|
sprite->oam.tileNum = sprite->sheetTileStart + imageValue;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
RequestSpriteFrameImageCopy(imageValue, sprite->oam.tileNum, sprite->images);
|
RequestSpriteFrameImageCopy(imageValue, sprite->oam.tileNum, sprite->images);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimCmd_loop(struct Sprite *sprite)
|
void AnimCmd_loop(struct Sprite *sprite)
|
||||||
|
@ -1449,7 +1457,8 @@ u16 LoadSpriteSheet(const struct SpriteSheet *sheet)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Like LoadSpriteSheet, but checks if already loaded, and uses template image frames
|
// Like LoadSpriteSheet, but checks if already loaded, and uses template image frames
|
||||||
u16 LoadSpriteSheetByTemplate(const struct SpriteTemplate *template, u32 frame, s32 offset) {
|
u16 LoadSpriteSheetByTemplate(const struct SpriteTemplate *template, u32 frame, s32 offset)
|
||||||
|
{
|
||||||
u16 tileStart;
|
u16 tileStart;
|
||||||
struct SpriteSheet sheet;
|
struct SpriteSheet sheet;
|
||||||
// error if template is null or tile tag or images not set
|
// error if template is null or tile tag or images not set
|
||||||
|
@ -1750,6 +1759,7 @@ static const u8 sSpanPerImage[4][4] =
|
||||||
// For a given sprite shape & size, returns
|
// For a given sprite shape & size, returns
|
||||||
// the value for sheetSpan:
|
// the value for sheetSpan:
|
||||||
// i.e, a 32x32 sprite has span 4, because 1 << 4 == 16 == 4x4 tiles
|
// i.e, a 32x32 sprite has span 4, because 1 << 4 == 16 == 4x4 tiles
|
||||||
u32 GetSpanPerImage(u32 shape, u32 size) {
|
u32 GetSpanPerImage(u32 shape, u32 size)
|
||||||
|
{
|
||||||
return sSpanPerImage[shape][size];
|
return sSpanPerImage[shape][size];
|
||||||
}
|
}
|
||||||
|
|
0
palette.py → migration_scripts/followers/palette.py
Executable file → Normal file
0
palette.py → migration_scripts/followers/palette.py
Executable file → Normal file
|
@ -4,8 +4,14 @@ import json
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
# get compatibility from jsons
|
# THIS IS A TEMPORARY SCRIPT MADE TO MOVE EXISTING FOLLOWER GRAPHICS FROM A SINGLE DIRECTORY.
|
||||||
def construct_compatibility_dict():
|
# IT TAKES FOLLOWER GRAPHICS FROM a 'followers' FOLDER IN THE ROOT FOLDER AND MOVES THEM BASED ON THEIR NAME.
|
||||||
|
# EG. 'followers/bulbasaur.png' WILL BE MOVED to 'graphics/pokemon/bulbasaur/follower.png'.
|
||||||
|
#
|
||||||
|
# I'M SAVING IT HERE IN CASE IT'S NEEDED SOMEWHERE IN THE FUTURE, THOUGH TWEAKING MIGHT BE NEEDED.
|
||||||
|
# - AsparagusEduardo
|
||||||
|
|
||||||
|
def rellocate_follower_graphics():
|
||||||
dict_out = {}
|
dict_out = {}
|
||||||
count = 0
|
count = 0
|
||||||
for pth in sorted(glob.glob('followers/*.png')):
|
for pth in sorted(glob.glob('followers/*.png')):
|
||||||
|
@ -55,4 +61,4 @@ def construct_compatibility_dict():
|
||||||
#print(pth)
|
#print(pth)
|
||||||
#subprocess.run(["tools/gbagfx/gbagfx " + name +".png " + name + "_normal.pal'" + str(count) + "'"])
|
#subprocess.run(["tools/gbagfx/gbagfx " + name +".png " + name + "_normal.pal'" + str(count) + "'"])
|
||||||
|
|
||||||
construct_compatibility_dict()
|
rellocate_follower_graphics()
|
|
@ -3243,21 +3243,29 @@ void SpriteCB_PlayerMonFromBall(struct Sprite *sprite)
|
||||||
BattleAnimateBackSprite(sprite, sprite->sSpeciesId);
|
BattleAnimateBackSprite(sprite, sprite->sSpeciesId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpriteCB_PlayerMonSlideIn(struct Sprite *sprite) {
|
void SpriteCB_PlayerMonSlideIn(struct Sprite *sprite)
|
||||||
if (sprite->data[3] == 0) {
|
{
|
||||||
|
if (sprite->data[3] == 0)
|
||||||
|
{
|
||||||
PlaySE(SE_BALL_TRAY_ENTER);
|
PlaySE(SE_BALL_TRAY_ENTER);
|
||||||
sprite->data[3]++;
|
sprite->data[3]++;
|
||||||
} else if (sprite->data[3] == 1) {
|
}
|
||||||
|
else if (sprite->data[3] == 1)
|
||||||
|
{
|
||||||
if (sprite->animEnded)
|
if (sprite->animEnded)
|
||||||
return;
|
return;
|
||||||
sprite->data[4] = sprite->x;
|
sprite->data[4] = sprite->x;
|
||||||
sprite->x = -33;
|
sprite->x = -33;
|
||||||
sprite->invisible = FALSE;
|
sprite->invisible = FALSE;
|
||||||
sprite->data[3]++;
|
sprite->data[3]++;
|
||||||
} else if (sprite->data[3] < 27) {
|
}
|
||||||
|
else if (sprite->data[3] < 27)
|
||||||
|
{
|
||||||
sprite->x += 4;
|
sprite->x += 4;
|
||||||
sprite->data[3]++;
|
sprite->data[3]++;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
sprite->data[3] = 0;
|
sprite->data[3] = 0;
|
||||||
sprite->x = sprite->data[4];
|
sprite->x = sprite->data[4];
|
||||||
sprite->data[4] = 0;
|
sprite->data[4] = 0;
|
||||||
|
|
|
@ -28,13 +28,45 @@ static const struct SpriteFrameImage sPicTable_ShadowExtraLarge[] = {
|
||||||
obj_frame_tiles(gFieldEffectObjectPic_ShadowExtraLarge),
|
obj_frame_tiles(gFieldEffectObjectPic_ShadowExtraLarge),
|
||||||
};
|
};
|
||||||
|
|
||||||
const struct SpriteTemplate gFieldEffectObjectTemplate_ShadowSmall = {TAG_NONE, TAG_WEATHER_START, &gObjectEventBaseOam_8x8, sAnimTable_Shadow, sPicTable_ShadowSmall, gDummySpriteAffineAnimTable, UpdateShadowFieldEffect};
|
const struct SpriteTemplate gFieldEffectObjectTemplate_ShadowSmall = {
|
||||||
|
.tileTag = TAG_NONE,
|
||||||
|
.paletteTag = TAG_WEATHER_START,
|
||||||
|
.oam = &gObjectEventBaseOam_8x8,
|
||||||
|
.anims = sAnimTable_Shadow,
|
||||||
|
.images = sPicTable_ShadowSmall,
|
||||||
|
.affineAnims = gDummySpriteAffineAnimTable,
|
||||||
|
.callback = UpdateShadowFieldEffect,
|
||||||
|
};
|
||||||
|
|
||||||
const struct SpriteTemplate gFieldEffectObjectTemplate_ShadowMedium = {TAG_NONE, TAG_WEATHER_START, &gObjectEventBaseOam_16x8, sAnimTable_Shadow, sPicTable_ShadowMedium, gDummySpriteAffineAnimTable, UpdateShadowFieldEffect};
|
const struct SpriteTemplate gFieldEffectObjectTemplate_ShadowMedium = {
|
||||||
|
.tileTag = TAG_NONE,
|
||||||
|
.paletteTag = TAG_WEATHER_START,
|
||||||
|
.oam = &gObjectEventBaseOam_16x8,
|
||||||
|
.anims = sAnimTable_Shadow,
|
||||||
|
.images = sPicTable_ShadowMedium,
|
||||||
|
.affineAnims = gDummySpriteAffineAnimTable,
|
||||||
|
.callback = UpdateShadowFieldEffect,
|
||||||
|
};
|
||||||
|
|
||||||
const struct SpriteTemplate gFieldEffectObjectTemplate_ShadowLarge = {TAG_NONE, TAG_WEATHER_START, &gObjectEventBaseOam_32x8, sAnimTable_Shadow, sPicTable_ShadowLarge, gDummySpriteAffineAnimTable, UpdateShadowFieldEffect};
|
const struct SpriteTemplate gFieldEffectObjectTemplate_ShadowLarge = {
|
||||||
|
.tileTag = TAG_NONE,
|
||||||
|
.paletteTag = TAG_WEATHER_START,
|
||||||
|
.oam = &gObjectEventBaseOam_32x8,
|
||||||
|
.anims = sAnimTable_Shadow,
|
||||||
|
.images = sPicTable_ShadowLarge,
|
||||||
|
.affineAnims = gDummySpriteAffineAnimTable,
|
||||||
|
.callback = UpdateShadowFieldEffect,
|
||||||
|
};
|
||||||
|
|
||||||
const struct SpriteTemplate gFieldEffectObjectTemplate_ShadowExtraLarge = {TAG_NONE, TAG_WEATHER_START, &gObjectEventBaseOam_64x32, sAnimTable_Shadow, sPicTable_ShadowExtraLarge, gDummySpriteAffineAnimTable, UpdateShadowFieldEffect};
|
const struct SpriteTemplate gFieldEffectObjectTemplate_ShadowExtraLarge = {
|
||||||
|
.tileTag = TAG_NONE,
|
||||||
|
.paletteTag = TAG_WEATHER_START,
|
||||||
|
.oam = &gObjectEventBaseOam_64x32,
|
||||||
|
.anims = sAnimTable_Shadow,
|
||||||
|
.images = sPicTable_ShadowExtraLarge,
|
||||||
|
.affineAnims = gDummySpriteAffineAnimTable,
|
||||||
|
.callback = UpdateShadowFieldEffect,
|
||||||
|
};
|
||||||
|
|
||||||
static const struct SpriteFrameImage sPicTable_TallGrass[] = {
|
static const struct SpriteFrameImage sPicTable_TallGrass[] = {
|
||||||
overworld_frame(gFieldEffectObjectPic_TallGrass, 2, 2, 0),
|
overworld_frame(gFieldEffectObjectPic_TallGrass, 2, 2, 0),
|
||||||
|
|
|
@ -31,17 +31,12 @@ const struct ObjectEventGraphicsInfo gPokeballGraphics[POKEBALL_COUNT] = {
|
||||||
POKEBALL_GFX_INFO(LUXURY),
|
POKEBALL_GFX_INFO(LUXURY),
|
||||||
POKEBALL_GFX_INFO(PREMIER),
|
POKEBALL_GFX_INFO(PREMIER),
|
||||||
// Gen IV/Sinnoh pokeballs
|
// Gen IV/Sinnoh pokeballs
|
||||||
#ifdef ITEM_DUSK_BALL
|
|
||||||
POKEBALL_GFX_INFO(DUSK),
|
POKEBALL_GFX_INFO(DUSK),
|
||||||
POKEBALL_GFX_INFO(HEAL),
|
POKEBALL_GFX_INFO(HEAL),
|
||||||
POKEBALL_GFX_INFO(QUICK),
|
POKEBALL_GFX_INFO(QUICK),
|
||||||
POKEBALL_GFX_INFO(CHERISH),
|
POKEBALL_GFX_INFO(CHERISH),
|
||||||
#endif
|
|
||||||
#ifdef ITEM_PARK_BALL
|
|
||||||
POKEBALL_GFX_INFO(PARK),
|
POKEBALL_GFX_INFO(PARK),
|
||||||
#endif
|
|
||||||
// Gen II/Johto Apricorn pokeballs
|
// Gen II/Johto Apricorn pokeballs
|
||||||
#ifdef ITEM_FAST_BALL
|
|
||||||
POKEBALL_GFX_INFO(FAST),
|
POKEBALL_GFX_INFO(FAST),
|
||||||
POKEBALL_GFX_INFO(LEVEL),
|
POKEBALL_GFX_INFO(LEVEL),
|
||||||
POKEBALL_GFX_INFO(LURE),
|
POKEBALL_GFX_INFO(LURE),
|
||||||
|
@ -50,15 +45,10 @@ const struct ObjectEventGraphicsInfo gPokeballGraphics[POKEBALL_COUNT] = {
|
||||||
POKEBALL_GFX_INFO(FRIEND),
|
POKEBALL_GFX_INFO(FRIEND),
|
||||||
POKEBALL_GFX_INFO(MOON),
|
POKEBALL_GFX_INFO(MOON),
|
||||||
POKEBALL_GFX_INFO(SPORT),
|
POKEBALL_GFX_INFO(SPORT),
|
||||||
#endif
|
|
||||||
// Gen V
|
// Gen V
|
||||||
#ifdef ITEM_DREAM_BALL
|
|
||||||
POKEBALL_GFX_INFO(DREAM),
|
POKEBALL_GFX_INFO(DREAM),
|
||||||
#endif
|
|
||||||
// Gen VII
|
// Gen VII
|
||||||
#ifdef ITEM_BEAST_BALL
|
|
||||||
POKEBALL_GFX_INFO(BEAST),
|
POKEBALL_GFX_INFO(BEAST),
|
||||||
#endif
|
|
||||||
// Gen VIII
|
// Gen VIII
|
||||||
#ifdef ITEM_STRANGE_BALL
|
#ifdef ITEM_STRANGE_BALL
|
||||||
POKEBALL_GFX_INFO(STRANGE),
|
POKEBALL_GFX_INFO(STRANGE),
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -21,7 +21,8 @@ void LZDecompressVram(const u32 *src, void *dest)
|
||||||
// Checks if `ptr` is likely LZ77 data
|
// Checks if `ptr` is likely LZ77 data
|
||||||
// Checks word-alignment, min/max size, and header byte
|
// Checks word-alignment, min/max size, and header byte
|
||||||
// Returns uncompressed size if true, 0 otherwise
|
// Returns uncompressed size if true, 0 otherwise
|
||||||
u32 IsLZ77Data(const void *ptr, u32 minSize, u32 maxSize) {
|
u32 IsLZ77Data(const void *ptr, u32 minSize, u32 maxSize)
|
||||||
|
{
|
||||||
const u8 *data = ptr;
|
const u8 *data = ptr;
|
||||||
u32 size;
|
u32 size;
|
||||||
// Compressed data must be word aligned
|
// Compressed data must be word aligned
|
||||||
|
@ -51,7 +52,8 @@ u16 LoadCompressedSpriteSheet(const struct CompressedSpriteSheet *src)
|
||||||
}
|
}
|
||||||
|
|
||||||
// This can be used for either compressed or uncompressed sprite sheets
|
// This can be used for either compressed or uncompressed sprite sheets
|
||||||
u16 LoadCompressedSpriteSheetByTemplate(const struct SpriteTemplate *template, s32 offset) {
|
u16 LoadCompressedSpriteSheetByTemplate(const struct SpriteTemplate *template, s32 offset)
|
||||||
|
{
|
||||||
struct SpriteTemplate myTemplate;
|
struct SpriteTemplate myTemplate;
|
||||||
struct SpriteFrameImage myImage;
|
struct SpriteFrameImage myImage;
|
||||||
u32 size;
|
u32 size;
|
||||||
|
|
|
@ -1628,7 +1628,8 @@ static bool8 CanPlaceDecoration(u8 taskId, const struct Decoration *decoration)
|
||||||
}
|
}
|
||||||
|
|
||||||
// If sprite(like), check if there is an available object event slot for it
|
// If sprite(like), check if there is an available object event slot for it
|
||||||
if (decoration->permission == DECORPERM_SPRITE) {
|
if (decoration->permission == DECORPERM_SPRITE)
|
||||||
|
{
|
||||||
for (i = 0; i < NUM_DECORATION_FLAGS; i++)
|
for (i = 0; i < NUM_DECORATION_FLAGS; i++)
|
||||||
if (FlagGet(FLAG_DECORATION_1 + i) == TRUE)
|
if (FlagGet(FLAG_DECORATION_1 + i) == TRUE)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
|
@ -1464,16 +1464,19 @@ void RemoveAllObjectEventsExceptPlayer(void)
|
||||||
|
|
||||||
// Free a sprite's current tiles and reallocate with a new size
|
// Free a sprite's current tiles and reallocate with a new size
|
||||||
// Used when changing to a gfx info with a larger size
|
// Used when changing to a gfx info with a larger size
|
||||||
static s16 ReallocSpriteTiles(struct Sprite *sprite, u32 byteSize) {
|
static s16 ReallocSpriteTiles(struct Sprite *sprite, u32 byteSize)
|
||||||
|
{
|
||||||
s16 i;
|
s16 i;
|
||||||
bool32 wasVisible = sprite->invisible;
|
bool32 wasVisible = sprite->invisible;
|
||||||
sprite->invisible = TRUE;
|
sprite->invisible = TRUE;
|
||||||
|
|
||||||
i = CopySprite(sprite, sprite->x, sprite->y, 0xFF);
|
i = CopySprite(sprite, sprite->x, sprite->y, 0xFF);
|
||||||
if (i < MAX_SPRITES) {
|
if (i < MAX_SPRITES)
|
||||||
|
{
|
||||||
DestroySprite(&gSprites[i]);
|
DestroySprite(&gSprites[i]);
|
||||||
i = AllocSpriteTiles(byteSize / TILE_SIZE_4BPP);
|
i = AllocSpriteTiles(byteSize / TILE_SIZE_4BPP);
|
||||||
if (i >= 0) {
|
if (i >= 0)
|
||||||
|
{
|
||||||
// Fill the allocated area with zeroes
|
// Fill the allocated area with zeroes
|
||||||
// To avoid visual glitches if the frame hasn't been copied yet
|
// To avoid visual glitches if the frame hasn't been copied yet
|
||||||
CpuFastFill16(0, (u8 *)OBJ_VRAM0 + TILE_SIZE_4BPP * i, byteSize);
|
CpuFastFill16(0, (u8 *)OBJ_VRAM0 + TILE_SIZE_4BPP * i, byteSize);
|
||||||
|
@ -1490,14 +1493,17 @@ static s16 ReallocSpriteTiles(struct Sprite *sprite, u32 byteSize) {
|
||||||
u16 LoadSheetGraphicsInfo(const struct ObjectEventGraphicsInfo *info, u16 uuid, struct Sprite *sprite)
|
u16 LoadSheetGraphicsInfo(const struct ObjectEventGraphicsInfo *info, u16 uuid, struct Sprite *sprite)
|
||||||
{
|
{
|
||||||
u16 tag = info->tileTag;
|
u16 tag = info->tileTag;
|
||||||
if (tag != TAG_NONE || info->compressed) { // sheet-based gfx
|
if (tag != TAG_NONE || info->compressed)
|
||||||
|
{
|
||||||
|
// sheet-based gfx
|
||||||
u32 sheetSpan = GetSpanPerImage(info->oam->shape, info->oam->size);
|
u32 sheetSpan = GetSpanPerImage(info->oam->shape, info->oam->size);
|
||||||
u16 oldTiles = 0;
|
u16 oldTiles = 0;
|
||||||
u16 tileStart;
|
u16 tileStart;
|
||||||
if (tag == TAG_NONE)
|
if (tag == TAG_NONE)
|
||||||
tag = COMP_OW_TILE_TAG_BASE + uuid;
|
tag = COMP_OW_TILE_TAG_BASE + uuid;
|
||||||
|
|
||||||
if (sprite) {
|
if (sprite)
|
||||||
|
{
|
||||||
oldTiles = sprite->sheetTileStart;
|
oldTiles = sprite->sheetTileStart;
|
||||||
sprite->sheetTileStart = 0; // mark unused
|
sprite->sheetTileStart = 0; // mark unused
|
||||||
// Note: If sprite was not allocated to use a sheet,
|
// Note: If sprite was not allocated to use a sheet,
|
||||||
|
@ -1508,18 +1514,22 @@ u16 LoadSheetGraphicsInfo(const struct ObjectEventGraphicsInfo *info, u16 uuid,
|
||||||
|
|
||||||
tileStart = GetSpriteTileStartByTag(tag);
|
tileStart = GetSpriteTileStartByTag(tag);
|
||||||
// sheet not loaded; unload any old tiles and load it
|
// sheet not loaded; unload any old tiles and load it
|
||||||
if (tileStart == TAG_NONE) {
|
if (tileStart == TAG_NONE)
|
||||||
|
{
|
||||||
struct SpriteFrameImage image = {.size = info->size, .data = info->images->data};
|
struct SpriteFrameImage image = {.size = info->size, .data = info->images->data};
|
||||||
struct SpriteTemplate template = {.tileTag = tag, .images = &image};
|
struct SpriteTemplate template = {.tileTag = tag, .images = &image};
|
||||||
if (oldTiles)
|
if (oldTiles)
|
||||||
FieldEffectFreeTilesIfUnused(oldTiles);
|
FieldEffectFreeTilesIfUnused(oldTiles);
|
||||||
tileStart = LoadCompressedSpriteSheetByTemplate(&template, TILE_SIZE_4BPP << sheetSpan);
|
tileStart = LoadCompressedSpriteSheetByTemplate(&template, TILE_SIZE_4BPP << sheetSpan);
|
||||||
// sheet loaded; unload any *other* sheet for sprite
|
// sheet loaded; unload any *other* sheet for sprite
|
||||||
} else if (oldTiles && oldTiles != tileStart) {
|
}
|
||||||
|
else if (oldTiles && oldTiles != tileStart)
|
||||||
|
{
|
||||||
FieldEffectFreeTilesIfUnused(oldTiles);
|
FieldEffectFreeTilesIfUnused(oldTiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sprite) {
|
if (sprite)
|
||||||
|
{
|
||||||
sprite->sheetTileStart = tileStart;
|
sprite->sheetTileStart = tileStart;
|
||||||
sprite->sheetSpan = sheetSpan;
|
sprite->sheetSpan = sheetSpan;
|
||||||
sprite->usingSheet = TRUE;
|
sprite->usingSheet = TRUE;
|
||||||
|
@ -1530,11 +1540,16 @@ u16 LoadSheetGraphicsInfo(const struct ObjectEventGraphicsInfo *info, u16 uuid,
|
||||||
// larger than the allocated prefix space,
|
// larger than the allocated prefix space,
|
||||||
// in which case we would have to realloc
|
// in which case we would have to realloc
|
||||||
// TODO: Realloc usingSheet -> !usingSheet larger gfx
|
// TODO: Realloc usingSheet -> !usingSheet larger gfx
|
||||||
} else if (sprite && sprite->usingSheet) {
|
}
|
||||||
|
else if (sprite && sprite->usingSheet)
|
||||||
|
{
|
||||||
sprite->oam.tileNum = sprite->sheetTileStart;
|
sprite->oam.tileNum = sprite->sheetTileStart;
|
||||||
sprite->usingSheet = FALSE;
|
sprite->usingSheet = FALSE;
|
||||||
// Not usingSheet and info size differs; realloc tiles
|
|
||||||
} else if (sprite && !sprite->sheetTileStart && sprite->oam.size != info->oam->size) {
|
}
|
||||||
|
else if (sprite && !sprite->sheetTileStart && sprite->oam.size != info->oam->size)
|
||||||
|
{
|
||||||
|
// Not usingSheet and info size differs; realloc tiles
|
||||||
ReallocSpriteTiles(sprite, info->images->size);
|
ReallocSpriteTiles(sprite, info->images->size);
|
||||||
}
|
}
|
||||||
return tag;
|
return tag;
|
||||||
|
@ -1947,7 +1962,8 @@ static void RefreshFollowerGraphics(struct ObjectEvent *objEvent)
|
||||||
struct Sprite *sprite = &gSprites[objEvent->spriteId];
|
struct Sprite *sprite = &gSprites[objEvent->spriteId];
|
||||||
u32 i = FindObjectEventPaletteIndexByTag(graphicsInfo->paletteTag);
|
u32 i = FindObjectEventPaletteIndexByTag(graphicsInfo->paletteTag);
|
||||||
|
|
||||||
if (graphicsInfo->oam->size != sprite->oam.size) {
|
if (graphicsInfo->oam->size != sprite->oam.size)
|
||||||
|
{
|
||||||
#if LARGE_OW_SUPPORT && !OW_GFX_COMPRESS
|
#if LARGE_OW_SUPPORT && !OW_GFX_COMPRESS
|
||||||
ReallocSpriteTiles(sprite, graphicsInfo->images->size);
|
ReallocSpriteTiles(sprite, graphicsInfo->images->size);
|
||||||
#endif
|
#endif
|
||||||
|
@ -2182,7 +2198,8 @@ static u32 FindMetatileBehaviorWithinRange(s32 x, s32 y, u32 mb, u8 distance)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check a single follower message condition
|
// Check a single follower message condition
|
||||||
bool32 CheckMsgCondition(const struct MsgCondition *cond, struct Pokemon *mon, u32 species, struct ObjectEvent *obj) {
|
bool32 CheckMsgCondition(const struct MsgCondition *cond, struct Pokemon *mon, u32 species, struct ObjectEvent *obj)
|
||||||
|
{
|
||||||
u32 multi;
|
u32 multi;
|
||||||
if (species == SPECIES_NONE)
|
if (species == SPECIES_NONE)
|
||||||
species = GetMonData(mon, MON_DATA_SPECIES);
|
species = GetMonData(mon, MON_DATA_SPECIES);
|
||||||
|
@ -2235,17 +2252,21 @@ bool32 CheckMsgCondition(const struct MsgCondition *cond, struct Pokemon *mon, u
|
||||||
|
|
||||||
// Check if follower info can be displayed in the current situation;
|
// Check if follower info can be displayed in the current situation;
|
||||||
// i.e, if all its conditions match
|
// i.e, if all its conditions match
|
||||||
bool32 CheckMsgInfo(const struct FollowerMsgInfoExtended *info, struct Pokemon *mon, u32 species, struct ObjectEvent *obj) {
|
bool32 CheckMsgInfo(const struct FollowerMsgInfoExtended *info, struct Pokemon *mon, u32 species, struct ObjectEvent *obj)
|
||||||
|
{
|
||||||
u32 i;
|
u32 i;
|
||||||
|
|
||||||
// any condition matches
|
if (info->orFlag)
|
||||||
if (info->orFlag) {
|
{
|
||||||
|
// any condition matches
|
||||||
for (i = 0; i < ARRAY_COUNT(info->conditions) && info->conditions[i].type; i++)
|
for (i = 0; i < ARRAY_COUNT(info->conditions) && info->conditions[i].type; i++)
|
||||||
if (CheckMsgCondition(&info->conditions[i], mon, species, obj))
|
if (CheckMsgCondition(&info->conditions[i], mon, species, obj))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
// all conditions must match
|
}
|
||||||
} else {
|
else
|
||||||
|
{
|
||||||
|
// all conditions must match
|
||||||
for (i = 0; i < ARRAY_COUNT(info->conditions) && info->conditions[i].type; i++)
|
for (i = 0; i < ARRAY_COUNT(info->conditions) && info->conditions[i].type; i++)
|
||||||
if (!CheckMsgCondition(&info->conditions[i], mon, species, obj))
|
if (!CheckMsgCondition(&info->conditions[i], mon, species, obj))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -5447,16 +5468,23 @@ bool8 FollowablePlayerMovement_Step(struct ObjectEvent *objectEvent, struct Spri
|
||||||
}
|
}
|
||||||
sprite->sActionFuncId = 0;
|
sprite->sActionFuncId = 0;
|
||||||
#else
|
#else
|
||||||
if (GetLedgeJumpDirection(x, y, direction) != DIR_NONE) {
|
if (GetLedgeJumpDirection(x, y, direction) != DIR_NONE)
|
||||||
|
{
|
||||||
// InitJumpRegular will set the proper speed
|
// InitJumpRegular will set the proper speed
|
||||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetJump2MovementAction(direction));
|
ObjectEventSetSingleMovement(objectEvent, sprite, GetJump2MovementAction(direction));
|
||||||
} else if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_DASH)) {
|
}
|
||||||
|
else if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_DASH))
|
||||||
|
{
|
||||||
// Set follow speed according to player's speed
|
// Set follow speed according to player's speed
|
||||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkFastMovementAction(direction));
|
ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkFastMovementAction(direction));
|
||||||
} else if (PlayerGetCopyableMovement() == COPY_MOVE_JUMP2) {
|
}
|
||||||
|
else if (PlayerGetCopyableMovement() == COPY_MOVE_JUMP2)
|
||||||
|
{
|
||||||
// If *player* jumps, make step take twice as long
|
// If *player* jumps, make step take twice as long
|
||||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkSlowMovementAction(direction));
|
ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkSlowMovementAction(direction));
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkNormalMovementAction(direction));
|
ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkNormalMovementAction(direction));
|
||||||
if (OW_MON_BOBBING == TRUE)
|
if (OW_MON_BOBBING == TRUE)
|
||||||
sprite->y2 = -1;
|
sprite->y2 = -1;
|
||||||
|
@ -7030,18 +7058,22 @@ static u8 LoadFillColorPalette(u16 color, u16 paletteTag, struct Sprite *sprite)
|
||||||
return UpdateSpritePalette(&dynamicPalette, sprite);
|
return UpdateSpritePalette(&dynamicPalette, sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ObjectEventSetPokeballGfx(struct ObjectEvent *objEvent) {
|
static void ObjectEventSetPokeballGfx(struct ObjectEvent *objEvent)
|
||||||
|
{
|
||||||
#if OW_MON_POKEBALLS
|
#if OW_MON_POKEBALLS
|
||||||
u32 ball = BALL_POKE;
|
u32 ball = BALL_POKE;
|
||||||
if (objEvent->localId == OBJ_EVENT_ID_FOLLOWER) {
|
if (objEvent->localId == OBJ_EVENT_ID_FOLLOWER)
|
||||||
|
{
|
||||||
struct Pokemon *mon = GetFirstLiveMon();
|
struct Pokemon *mon = GetFirstLiveMon();
|
||||||
if (mon)
|
if (mon)
|
||||||
ball = ItemIdToBallId(GetMonData(mon, MON_DATA_POKEBALL));
|
ball = ItemIdToBallId(GetMonData(mon, MON_DATA_POKEBALL));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ball != BALL_POKE && ball < POKEBALL_COUNT) {
|
if (ball != BALL_POKE && ball < POKEBALL_COUNT)
|
||||||
|
{
|
||||||
const struct ObjectEventGraphicsInfo *info = &gPokeballGraphics[ball];
|
const struct ObjectEventGraphicsInfo *info = &gPokeballGraphics[ball];
|
||||||
if (info->tileTag == TAG_NONE) {
|
if (info->tileTag == TAG_NONE)
|
||||||
|
{
|
||||||
ObjectEventSetGraphics(objEvent, info);
|
ObjectEventSetGraphics(objEvent, info);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -9232,7 +9264,8 @@ static void UpdateObjectEventElevationAndPriority(struct ObjectEvent *objEvent,
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ObjectEventUpdateElevation(objEvent, sprite);
|
ObjectEventUpdateElevation(objEvent, sprite);
|
||||||
if (objEvent->localId == OBJ_EVENT_ID_FOLLOWER) {
|
if (objEvent->localId == OBJ_EVENT_ID_FOLLOWER)
|
||||||
|
{
|
||||||
#if LARGE_OW_SUPPORT
|
#if LARGE_OW_SUPPORT
|
||||||
// keep subspriteMode synced with player's
|
// keep subspriteMode synced with player's
|
||||||
// so that it disappears under bridges when they do
|
// so that it disappears under bridges when they do
|
||||||
|
@ -9264,7 +9297,8 @@ void ObjectEventUpdateElevation(struct ObjectEvent *objEvent, struct Sprite *spr
|
||||||
u8 curElevation = MapGridGetElevationAt(objEvent->currentCoords.x, objEvent->currentCoords.y);
|
u8 curElevation = MapGridGetElevationAt(objEvent->currentCoords.x, objEvent->currentCoords.y);
|
||||||
u8 prevElevation = MapGridGetElevationAt(objEvent->previousCoords.x, objEvent->previousCoords.y);
|
u8 prevElevation = MapGridGetElevationAt(objEvent->previousCoords.x, objEvent->previousCoords.y);
|
||||||
|
|
||||||
if (curElevation == 15 || prevElevation == 15) {
|
if (curElevation == 15 || prevElevation == 15)
|
||||||
|
{
|
||||||
#if LARGE_OW_SUPPORT
|
#if LARGE_OW_SUPPORT
|
||||||
// Ignore subsprite priorities under bridges
|
// Ignore subsprite priorities under bridges
|
||||||
// so all subsprites will display below it
|
// so all subsprites will display below it
|
||||||
|
|
|
@ -112,12 +112,14 @@ static void LoadObjectReflectionPalette(struct ObjectEvent *objectEvent, struct
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply a blue tint effect to a palette
|
// Apply a blue tint effect to a palette
|
||||||
static void ApplyPondFilter(u8 paletteNum, u16 *dest) {
|
static void ApplyPondFilter(u8 paletteNum, u16 *dest)
|
||||||
|
{
|
||||||
u32 i, r, g, b;
|
u32 i, r, g, b;
|
||||||
// CpuCopy16(gPlttBufferUnfaded + 0x100 + paletteNum * 16, dest, 32);
|
// CpuCopy16(gPlttBufferUnfaded + 0x100 + paletteNum * 16, dest, 32);
|
||||||
u16 *src = gPlttBufferUnfaded + OBJ_PLTT_ID(paletteNum);
|
u16 *src = gPlttBufferUnfaded + OBJ_PLTT_ID(paletteNum);
|
||||||
*dest++ = *src++; // copy transparency
|
*dest++ = *src++; // copy transparency
|
||||||
for (i = 0; i < 16 - 1; i++) {
|
for (i = 0; i < 16 - 1; i++)
|
||||||
|
{
|
||||||
r = GET_R(src[i]);
|
r = GET_R(src[i]);
|
||||||
g = GET_G(src[i]);
|
g = GET_G(src[i]);
|
||||||
b = GET_B(src[i]);
|
b = GET_B(src[i]);
|
||||||
|
@ -129,12 +131,14 @@ static void ApplyPondFilter(u8 paletteNum, u16 *dest) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply a ice tint effect to a palette
|
// Apply a ice tint effect to a palette
|
||||||
static void ApplyIceFilter(u8 paletteNum, u16 *dest) {
|
static void ApplyIceFilter(u8 paletteNum, u16 *dest)
|
||||||
|
{
|
||||||
u32 i, r, g, b;
|
u32 i, r, g, b;
|
||||||
// CpuCopy16(gPlttBufferUnfaded + 0x100 + paletteNum * 16, dest, 32);
|
// CpuCopy16(gPlttBufferUnfaded + 0x100 + paletteNum * 16, dest, 32);
|
||||||
u16 *src = gPlttBufferUnfaded + OBJ_PLTT_ID(paletteNum);
|
u16 *src = gPlttBufferUnfaded + OBJ_PLTT_ID(paletteNum);
|
||||||
*dest++ = *src++; // copy transparency
|
*dest++ = *src++; // copy transparency
|
||||||
for (i = 0; i < 16 - 1; i++) {
|
for (i = 0; i < 16 - 1; i++)
|
||||||
|
{
|
||||||
r = GET_R(src[i]);
|
r = GET_R(src[i]);
|
||||||
r -= 5;
|
r -= 5;
|
||||||
if (r > 31)
|
if (r > 31)
|
||||||
|
@ -157,7 +161,9 @@ static void LoadObjectRegularReflectionPalette(struct ObjectEvent *objectEvent,
|
||||||
u16 baseTag = GetSpritePaletteTagByPaletteNum(mainSprite->oam.paletteNum);
|
u16 baseTag = GetSpritePaletteTagByPaletteNum(mainSprite->oam.paletteNum);
|
||||||
u16 paletteTag = REFLECTION_PAL_TAG(baseTag, mainSprite->oam.paletteNum);
|
u16 paletteTag = REFLECTION_PAL_TAG(baseTag, mainSprite->oam.paletteNum);
|
||||||
u8 paletteNum = IndexOfSpritePaletteTag(paletteTag);
|
u8 paletteNum = IndexOfSpritePaletteTag(paletteTag);
|
||||||
if (paletteNum <= 16) { // Load filtered palette
|
if (paletteNum <= 16)
|
||||||
|
{
|
||||||
|
// Load filtered palette
|
||||||
u16 filteredData[16];
|
u16 filteredData[16];
|
||||||
struct SpritePalette filteredPal = {.tag = paletteTag, .data = filteredData};
|
struct SpritePalette filteredPal = {.tag = paletteTag, .data = filteredData};
|
||||||
if (sprite->sIsStillReflection == FALSE)
|
if (sprite->sIsStillReflection == FALSE)
|
||||||
|
@ -196,22 +202,24 @@ static void UpdateObjectReflectionSprite(struct Sprite *reflectionSprite)
|
||||||
|
|
||||||
// Only filter palette if not using the high bridge blue palette
|
// Only filter palette if not using the high bridge blue palette
|
||||||
// This is basically a copy of LoadObjectRegularReflectionPalette
|
// This is basically a copy of LoadObjectRegularReflectionPalette
|
||||||
if (IndexOfSpritePaletteTag(HIGH_BRIDGE_PAL_TAG) != reflectionSprite->oam.paletteNum) {
|
if (IndexOfSpritePaletteTag(HIGH_BRIDGE_PAL_TAG) != reflectionSprite->oam.paletteNum)
|
||||||
|
{
|
||||||
u16 baseTag = GetSpritePaletteTagByPaletteNum(mainSprite->oam.paletteNum);
|
u16 baseTag = GetSpritePaletteTagByPaletteNum(mainSprite->oam.paletteNum);
|
||||||
u16 paletteTag = REFLECTION_PAL_TAG(baseTag, mainSprite->oam.paletteNum);
|
u16 paletteTag = REFLECTION_PAL_TAG(baseTag, mainSprite->oam.paletteNum);
|
||||||
u8 paletteNum = IndexOfSpritePaletteTag(paletteTag);
|
u8 paletteNum = IndexOfSpritePaletteTag(paletteTag);
|
||||||
if (paletteNum >= 16) { // Build filtered palette
|
if (paletteNum >= 16)
|
||||||
|
{
|
||||||
|
// Build filtered palette
|
||||||
u16 filteredData[16];
|
u16 filteredData[16];
|
||||||
struct SpritePalette filteredPal = {.tag = paletteTag, .data = filteredData};
|
struct SpritePalette filteredPal = {.tag = paletteTag, .data = filteredData};
|
||||||
// Free palette if unused
|
// Free palette if unused
|
||||||
reflectionSprite->inUse = FALSE;
|
reflectionSprite->inUse = FALSE;
|
||||||
FieldEffectFreePaletteIfUnused(reflectionSprite->oam.paletteNum);
|
FieldEffectFreePaletteIfUnused(reflectionSprite->oam.paletteNum);
|
||||||
reflectionSprite->inUse = TRUE;
|
reflectionSprite->inUse = TRUE;
|
||||||
if (reflectionSprite->sIsStillReflection == FALSE) {
|
if (reflectionSprite->sIsStillReflection == FALSE)
|
||||||
ApplyPondFilter(mainSprite->oam.paletteNum, filteredData);
|
ApplyPondFilter(mainSprite->oam.paletteNum, filteredData);
|
||||||
} else {
|
else
|
||||||
ApplyIceFilter(mainSprite->oam.paletteNum, filteredData);
|
ApplyIceFilter(mainSprite->oam.paletteNum, filteredData);
|
||||||
}
|
|
||||||
paletteNum = LoadSpritePalette(&filteredPal);
|
paletteNum = LoadSpritePalette(&filteredPal);
|
||||||
UpdateSpritePaletteWithWeather(paletteNum);
|
UpdateSpritePaletteWithWeather(paletteNum);
|
||||||
}
|
}
|
||||||
|
@ -236,7 +244,8 @@ static void UpdateObjectReflectionSprite(struct Sprite *reflectionSprite)
|
||||||
reflectionSprite->invisible = TRUE;
|
reflectionSprite->invisible = TRUE;
|
||||||
|
|
||||||
// Support "virtual" sprites which can't be rotated via affines
|
// Support "virtual" sprites which can't be rotated via affines
|
||||||
if (reflectionSprite->subspriteTables[0].subsprites) {
|
if (reflectionSprite->subspriteTables[0].subsprites)
|
||||||
|
{
|
||||||
reflectionSprite->oam.affineMode = ST_OAM_AFFINE_OFF;
|
reflectionSprite->oam.affineMode = ST_OAM_AFFINE_OFF;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue