mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2025-01-13 07:03:40 +01:00
Merge pull request #367 from DizzyEggg/move_blitmap
Move Bitmap struct and clear sprite/text files a bit
This commit is contained in:
commit
442baf1a00
@ -1,6 +1,13 @@
|
||||
#ifndef GUARD_BLIT_H
|
||||
#define GUARD_BLIT_H
|
||||
|
||||
struct Bitmap
|
||||
{
|
||||
u8* pixels;
|
||||
u32 width:16;
|
||||
u32 height:16;
|
||||
};
|
||||
|
||||
void BlitBitmapRect4BitWithoutColorKey(struct Bitmap *src, struct Bitmap *dst, u16 srcX, u16 srcY, u16 dstX, u16 dstY, u16 width, u16 height);
|
||||
void BlitBitmapRect4Bit(struct Bitmap *src, struct Bitmap *dst, u16 srcX, u16 srcY, u16 dstX, u16 dstY, u16 width, u16 height, u8 colorKey);
|
||||
void FillBitmapRect4Bit(struct Bitmap *surface, u16 x, u16 y, u16 width, u16 height, u8 fillValue);
|
||||
|
@ -976,13 +976,4 @@ struct UnkStruct_8054FF8
|
||||
u16 field_C;
|
||||
};
|
||||
|
||||
struct Bitmap // TODO: Find a better spot for this
|
||||
{
|
||||
u8* pixels;
|
||||
u32 width:16;
|
||||
u32 height:16;
|
||||
};
|
||||
|
||||
extern u8 gReservedSpritePaletteCount;
|
||||
|
||||
#endif // GUARD_GLOBAL_H
|
||||
|
@ -235,11 +235,15 @@ extern const struct OamData gDummyOamData;
|
||||
extern const union AnimCmd *const gDummySpriteAnimTable[];
|
||||
extern const union AffineAnimCmd *const gDummySpriteAffineAnimTable[];
|
||||
extern const struct SpriteTemplate gDummySpriteTemplate;
|
||||
|
||||
extern u8 gReservedSpritePaletteCount;
|
||||
extern struct Sprite gSprites[];
|
||||
extern u8 gOamLimit;
|
||||
extern u16 gReservedSpriteTileCount;
|
||||
extern s16 gSpriteCoordOffsetX;
|
||||
extern s16 gSpriteCoordOffsetY;
|
||||
|
||||
extern struct Sprite gSprites[];
|
||||
extern struct OamMatrix gOamMatrices[];
|
||||
extern bool8 gAffineAnimsDisabled;
|
||||
|
||||
void ResetSpriteData(void);
|
||||
void AnimateSprites(void);
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "link.h"
|
||||
#include "util.h"
|
||||
#include "trig.h"
|
||||
#include "data2.h"
|
||||
|
||||
struct EvoInfo
|
||||
{
|
||||
@ -48,8 +49,6 @@ extern u16 gBattle_BG2_X;
|
||||
extern u16 gBattle_BG2_Y;
|
||||
extern u16 gBattle_BG3_X;
|
||||
extern u16 gBattle_BG3_Y;
|
||||
extern bool8 gAffineAnimsDisabled;
|
||||
extern const u8 gSpeciesNames[][11];
|
||||
|
||||
#define sEvoCursorPos gBattleCommunication[1] // when learning a new move
|
||||
#define sEvoGraphicsTaskID gBattleCommunication[2]
|
||||
@ -60,12 +59,9 @@ extern const struct CompressedSpriteSheet gMonFrontPicTable[];
|
||||
// strings
|
||||
extern const u8 gText_CommunicationStandby5[];
|
||||
|
||||
extern void sub_80356D0(void);
|
||||
extern void sub_807B154(void);
|
||||
extern void sub_807F19C(void);
|
||||
extern void sub_807B140(void);
|
||||
extern void EvolutionRenameMon(struct Pokemon *mon, u16 oldSpecies, u16 newSpecies);
|
||||
extern void Overworld_PlaySpecialMapMusic(void);
|
||||
extern void ShowSelectMovePokemonSummaryScreen(struct Pokemon *party, u8 monId, u8 partyCount, void *CB2_ptr, u16 move);
|
||||
extern u8 sub_81C1B94(void);
|
||||
extern void sub_807F1A8(u8 arg0, const u8 *arg1, u8 arg2);
|
||||
|
@ -25,8 +25,6 @@
|
||||
#include "bg.h"
|
||||
#include "window.h"
|
||||
|
||||
extern u8 gOamLimit;
|
||||
|
||||
// Text
|
||||
extern const u8 gText_YouDontHaveThreeCoins[];
|
||||
extern const u8 gText_QuitTheGame[];
|
||||
|
100
src/sprite.c
100
src/sprite.c
@ -15,15 +15,15 @@
|
||||
|
||||
#define ALLOC_SPRITE_TILE(n) \
|
||||
{ \
|
||||
gSpriteTileAllocBitmap[(n) / 8] |= (1 << ((n) % 8)); \
|
||||
sSpriteTileAllocBitmap[(n) / 8] |= (1 << ((n) % 8)); \
|
||||
}
|
||||
|
||||
#define FREE_SPRITE_TILE(n) \
|
||||
{ \
|
||||
gSpriteTileAllocBitmap[(n) / 8] &= ~(1 << ((n) % 8)); \
|
||||
sSpriteTileAllocBitmap[(n) / 8] &= ~(1 << ((n) % 8)); \
|
||||
}
|
||||
|
||||
#define SPRITE_TILE_IS_ALLOCATED(n) ((gSpriteTileAllocBitmap[(n) / 8] >> ((n) % 8)) & 1)
|
||||
#define SPRITE_TILE_IS_ALLOCATED(n) ((sSpriteTileAllocBitmap[(n) / 8] >> ((n) % 8)) & 1)
|
||||
|
||||
|
||||
struct SpriteCopyRequest
|
||||
@ -295,18 +295,18 @@ u32 gOamMatrixAllocBitmap;
|
||||
u8 gReservedSpritePaletteCount;
|
||||
|
||||
EWRAM_DATA struct Sprite gSprites[MAX_SPRITES + 1] = {0};
|
||||
EWRAM_DATA u16 gSpritePriorities[MAX_SPRITES] = {0};
|
||||
EWRAM_DATA u8 gSpriteOrder[MAX_SPRITES] = {0};
|
||||
EWRAM_DATA bool8 gShouldProcessSpriteCopyRequests = 0;
|
||||
EWRAM_DATA u8 gSpriteCopyRequestCount = 0;
|
||||
EWRAM_DATA struct SpriteCopyRequest gSpriteCopyRequests[MAX_SPRITES] = {0};
|
||||
EWRAM_DATA static u16 sSpritePriorities[MAX_SPRITES] = {0};
|
||||
EWRAM_DATA static u8 sSpriteOrder[MAX_SPRITES] = {0};
|
||||
EWRAM_DATA static bool8 sShouldProcessSpriteCopyRequests = 0;
|
||||
EWRAM_DATA static u8 sSpriteCopyRequestCount = 0;
|
||||
EWRAM_DATA static struct SpriteCopyRequest sSpriteCopyRequests[MAX_SPRITES] = {0};
|
||||
EWRAM_DATA u8 gOamLimit = 0;
|
||||
EWRAM_DATA u16 gReservedSpriteTileCount = 0;
|
||||
EWRAM_DATA u8 gSpriteTileAllocBitmap[128] = {0};
|
||||
EWRAM_DATA static u8 sSpriteTileAllocBitmap[128] = {0};
|
||||
EWRAM_DATA s16 gSpriteCoordOffsetX = 0;
|
||||
EWRAM_DATA s16 gSpriteCoordOffsetY = 0;
|
||||
EWRAM_DATA struct OamMatrix gOamMatrices[OAM_MATRIX_COUNT] = {0};
|
||||
EWRAM_DATA bool8 gAffineAnimsDisabled = 0;
|
||||
EWRAM_DATA bool8 gAffineAnimsDisabled = FALSE;
|
||||
|
||||
void ResetSpriteData(void)
|
||||
{
|
||||
@ -350,7 +350,7 @@ void BuildOamBuffer(void)
|
||||
AddSpritesToOamBuffer();
|
||||
CopyMatricesToOamBuffer();
|
||||
gMain.oamLoadDisabled = temp;
|
||||
gShouldProcessSpriteCopyRequests = TRUE;
|
||||
sShouldProcessSpriteCopyRequests = TRUE;
|
||||
}
|
||||
|
||||
void UpdateOamCoords(void)
|
||||
@ -382,7 +382,7 @@ void BuildSpritePriorities(void)
|
||||
{
|
||||
struct Sprite *sprite = &gSprites[i];
|
||||
u16 priority = sprite->subpriority | (sprite->oam.priority << 8);
|
||||
gSpritePriorities[i] = priority;
|
||||
sSpritePriorities[i] = priority;
|
||||
}
|
||||
}
|
||||
|
||||
@ -392,10 +392,10 @@ void SortSprites(void)
|
||||
for (i = 1; i < MAX_SPRITES; i++)
|
||||
{
|
||||
u8 j = i;
|
||||
struct Sprite *sprite1 = &gSprites[gSpriteOrder[i - 1]];
|
||||
struct Sprite *sprite2 = &gSprites[gSpriteOrder[i]];
|
||||
u16 sprite1Priority = gSpritePriorities[gSpriteOrder[i - 1]];
|
||||
u16 sprite2Priority = gSpritePriorities[gSpriteOrder[i]];
|
||||
struct Sprite *sprite1 = &gSprites[sSpriteOrder[i - 1]];
|
||||
struct Sprite *sprite2 = &gSprites[sSpriteOrder[i]];
|
||||
u16 sprite1Priority = sSpritePriorities[sSpriteOrder[i - 1]];
|
||||
u16 sprite2Priority = sSpritePriorities[sSpriteOrder[i]];
|
||||
s16 sprite1Y = sprite1->oam.y;
|
||||
s16 sprite2Y = sprite2->oam.y;
|
||||
|
||||
@ -431,20 +431,20 @@ void SortSprites(void)
|
||||
&& ((sprite1Priority > sprite2Priority)
|
||||
|| (sprite1Priority == sprite2Priority && sprite1Y < sprite2Y)))
|
||||
{
|
||||
u8 temp = gSpriteOrder[j];
|
||||
gSpriteOrder[j] = gSpriteOrder[j - 1];
|
||||
gSpriteOrder[j - 1] = temp;
|
||||
u8 temp = sSpriteOrder[j];
|
||||
sSpriteOrder[j] = sSpriteOrder[j - 1];
|
||||
sSpriteOrder[j - 1] = temp;
|
||||
|
||||
// UB: If j equals 1, then j-- makes j equal 0.
|
||||
// Then, gSpriteOrder[-1] gets accessed below.
|
||||
// Then, sSpriteOrder[-1] gets accessed below.
|
||||
// Although this doesn't result in a bug in the ROM,
|
||||
// the behavior is undefined.
|
||||
j--;
|
||||
|
||||
sprite1 = &gSprites[gSpriteOrder[j - 1]];
|
||||
sprite2 = &gSprites[gSpriteOrder[j]];
|
||||
sprite1Priority = gSpritePriorities[gSpriteOrder[j - 1]];
|
||||
sprite2Priority = gSpritePriorities[gSpriteOrder[j]];
|
||||
sprite1 = &gSprites[sSpriteOrder[j - 1]];
|
||||
sprite2 = &gSprites[sSpriteOrder[j]];
|
||||
sprite1Priority = sSpritePriorities[sSpriteOrder[j - 1]];
|
||||
sprite2Priority = sSpritePriorities[sSpriteOrder[j]];
|
||||
sprite1Y = sprite1->oam.y;
|
||||
sprite2Y = sprite2->oam.y;
|
||||
|
||||
@ -499,7 +499,7 @@ void AddSpritesToOamBuffer(void)
|
||||
|
||||
while (i < MAX_SPRITES)
|
||||
{
|
||||
struct Sprite *sprite = &gSprites[gSpriteOrder[i]];
|
||||
struct Sprite *sprite = &gSprites[sSpriteOrder[i]];
|
||||
if (sprite->inUse && !sprite->invisible && AddSpriteToOamBuffer(sprite, &oamIndex))
|
||||
return;
|
||||
i++;
|
||||
@ -664,14 +664,14 @@ void ClearSpriteCopyRequests(void)
|
||||
{
|
||||
u8 i;
|
||||
|
||||
gShouldProcessSpriteCopyRequests = FALSE;
|
||||
gSpriteCopyRequestCount = 0;
|
||||
sShouldProcessSpriteCopyRequests = FALSE;
|
||||
sSpriteCopyRequestCount = 0;
|
||||
|
||||
for (i = 0; i < MAX_SPRITE_COPY_REQUESTS; i++)
|
||||
{
|
||||
gSpriteCopyRequests[i].src = 0;
|
||||
gSpriteCopyRequests[i].dest = 0;
|
||||
gSpriteCopyRequests[i].size = 0;
|
||||
sSpriteCopyRequests[i].src = 0;
|
||||
sSpriteCopyRequests[i].dest = 0;
|
||||
sSpriteCopyRequests[i].size = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -779,17 +779,17 @@ u8 SpriteTileAllocBitmapOp(u16 bit, u8 op)
|
||||
if (op == 0)
|
||||
{
|
||||
val = ~(1 << val);
|
||||
gSpriteTileAllocBitmap[index] &= val;
|
||||
sSpriteTileAllocBitmap[index] &= val;
|
||||
}
|
||||
else if (op == 1)
|
||||
{
|
||||
val = (1 << val);
|
||||
gSpriteTileAllocBitmap[index] |= val;
|
||||
sSpriteTileAllocBitmap[index] |= val;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal = 1 << shift;
|
||||
retVal &= gSpriteTileAllocBitmap[index];
|
||||
retVal &= sSpriteTileAllocBitmap[index];
|
||||
}
|
||||
|
||||
return retVal;
|
||||
@ -801,40 +801,40 @@ void SpriteCallbackDummy(struct Sprite *sprite)
|
||||
|
||||
void ProcessSpriteCopyRequests(void)
|
||||
{
|
||||
if (gShouldProcessSpriteCopyRequests)
|
||||
if (sShouldProcessSpriteCopyRequests)
|
||||
{
|
||||
u8 i = 0;
|
||||
|
||||
while (gSpriteCopyRequestCount > 0)
|
||||
while (sSpriteCopyRequestCount > 0)
|
||||
{
|
||||
CpuCopy16(gSpriteCopyRequests[i].src, gSpriteCopyRequests[i].dest, gSpriteCopyRequests[i].size);
|
||||
gSpriteCopyRequestCount--;
|
||||
CpuCopy16(sSpriteCopyRequests[i].src, sSpriteCopyRequests[i].dest, sSpriteCopyRequests[i].size);
|
||||
sSpriteCopyRequestCount--;
|
||||
i++;
|
||||
}
|
||||
|
||||
gShouldProcessSpriteCopyRequests = FALSE;
|
||||
sShouldProcessSpriteCopyRequests = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
void RequestSpriteFrameImageCopy(u16 index, u16 tileNum, const struct SpriteFrameImage *images)
|
||||
{
|
||||
if (gSpriteCopyRequestCount < MAX_SPRITE_COPY_REQUESTS)
|
||||
if (sSpriteCopyRequestCount < MAX_SPRITE_COPY_REQUESTS)
|
||||
{
|
||||
gSpriteCopyRequests[gSpriteCopyRequestCount].src = images[index].data;
|
||||
gSpriteCopyRequests[gSpriteCopyRequestCount].dest = (u8 *)OBJ_VRAM0 + TILE_SIZE_4BPP * tileNum;
|
||||
gSpriteCopyRequests[gSpriteCopyRequestCount].size = images[index].size;
|
||||
gSpriteCopyRequestCount++;
|
||||
sSpriteCopyRequests[sSpriteCopyRequestCount].src = images[index].data;
|
||||
sSpriteCopyRequests[sSpriteCopyRequestCount].dest = (u8 *)OBJ_VRAM0 + TILE_SIZE_4BPP * tileNum;
|
||||
sSpriteCopyRequests[sSpriteCopyRequestCount].size = images[index].size;
|
||||
sSpriteCopyRequestCount++;
|
||||
}
|
||||
}
|
||||
|
||||
void RequestSpriteCopy(const u8 *src, u8 *dest, u16 size)
|
||||
{
|
||||
if (gSpriteCopyRequestCount < MAX_SPRITE_COPY_REQUESTS)
|
||||
if (sSpriteCopyRequestCount < MAX_SPRITE_COPY_REQUESTS)
|
||||
{
|
||||
gSpriteCopyRequests[gSpriteCopyRequestCount].src = src;
|
||||
gSpriteCopyRequests[gSpriteCopyRequestCount].dest = dest;
|
||||
gSpriteCopyRequests[gSpriteCopyRequestCount].size = size;
|
||||
gSpriteCopyRequestCount++;
|
||||
sSpriteCopyRequests[sSpriteCopyRequestCount].src = src;
|
||||
sSpriteCopyRequests[sSpriteCopyRequestCount].dest = dest;
|
||||
sSpriteCopyRequests[sSpriteCopyRequestCount].size = size;
|
||||
sSpriteCopyRequestCount++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -869,7 +869,7 @@ void ResetAllSprites(void)
|
||||
for (i = 0; i < MAX_SPRITES; i++)
|
||||
{
|
||||
ResetSprite(&gSprites[i]);
|
||||
gSpriteOrder[i] = i;
|
||||
sSpriteOrder[i] = i;
|
||||
}
|
||||
|
||||
ResetSprite(&gSprites[i]);
|
||||
@ -1414,7 +1414,7 @@ void ResetAffineAnimData(void)
|
||||
{
|
||||
u8 i;
|
||||
|
||||
gAffineAnimsDisabled = 0;
|
||||
gAffineAnimsDisabled = FALSE;
|
||||
gOamMatrixAllocBitmap = 0;
|
||||
|
||||
ResetOamMatrices();
|
||||
|
@ -9,11 +9,11 @@
|
||||
#include "window.h"
|
||||
#include "text.h"
|
||||
#include "blit.h"
|
||||
#include "dynamic_placeholder_text_util.h"
|
||||
|
||||
extern u8 GetKeypadIconWidth(u8 keypadIconId);
|
||||
extern u16 Font6Func(struct TextPrinter *textPrinter);
|
||||
extern u32 GetGlyphWidthFont6(u16 glyphId, bool32 isJapanese);
|
||||
extern u8* DynamicPlaceholderTextUtil_GetPlaceholderPtr(u8 a1);
|
||||
extern int sub_8197964();
|
||||
|
||||
EWRAM_DATA struct TextPrinter gTempTextPrinter = {0};
|
||||
@ -24,8 +24,6 @@ static u16 gLastTextBgColor;
|
||||
static u16 gLastTextFgColor;
|
||||
static u16 gLastTextShadowColor;
|
||||
|
||||
extern struct MusicPlayerInfo gMPlayInfo_BGM;
|
||||
|
||||
const struct FontInfo *gFonts;
|
||||
u8 gUnknown_03002F84;
|
||||
u8 gUnknown_03002F90[0x20];
|
||||
@ -3170,7 +3168,7 @@ u32 (*GetFontWidthFunc(u8 glyphId))(u16, bool32)
|
||||
return gGlyphWidthFuncs[i].func;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
u32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing)
|
||||
@ -3181,7 +3179,7 @@ u32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing)
|
||||
s32 result;
|
||||
int localLetterSpacing;
|
||||
u32 lineWidth;
|
||||
u8 *bufferPointer;
|
||||
const u8 *bufferPointer;
|
||||
int glyphWidth;
|
||||
u32 width;
|
||||
|
||||
|
@ -20,7 +20,7 @@ EWRAM_DATA static u16 sWindowSize = 0;
|
||||
static u8 GetNumActiveWindowsOnBg(u8 bgId);
|
||||
static u8 GetNumActiveWindowsOnBg8Bit(u8 bgId);
|
||||
|
||||
static const struct WindowTemplate sDummyWindowTemplate = {0xFF, 0, 0, 0, 0, 0, 0};
|
||||
static const struct WindowTemplate sDummyWindowTemplate = DUMMY_WIN_TEMPLATE;
|
||||
|
||||
static void nullsub_8(void)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user