Merge pull request #1424 from ghoulslash/popup
Ability Pop Up Apostrophes
This commit is contained in:
commit
2034d6eb32
1 changed files with 108 additions and 81 deletions
|
@ -2857,7 +2857,34 @@ static void PrintOnAbilityPopUp(const u8 *str, u8 *spriteTileData1, u8 *spriteTi
|
|||
|
||||
static void PrintBattlerOnAbilityPopUp(u8 battlerId, u8 spriteId1, u8 spriteId2)
|
||||
{
|
||||
PrintOnAbilityPopUp(gBattleMons[battlerId].nickname,
|
||||
int i;
|
||||
u8 lastChar;
|
||||
u8* name;
|
||||
u8 monName[POKEMON_NAME_LENGTH + 3] = {0};
|
||||
u8* nick = gBattleMons[battlerId].nickname;
|
||||
|
||||
for (i = 0; i < POKEMON_NAME_LENGTH; ++i)
|
||||
{
|
||||
monName[i] = nick[i];
|
||||
if (nick[i] == EOS || i + 1 == POKEMON_NAME_LENGTH)
|
||||
break;
|
||||
}
|
||||
|
||||
name = monName + i + 1;
|
||||
if (*(name - 1) == EOS)
|
||||
name--;
|
||||
|
||||
lastChar = *(name - 1);
|
||||
name[0] = CHAR_SGL_QUOT_RIGHT; // apostraphe
|
||||
name++;
|
||||
if (lastChar != CHAR_S && lastChar != CHAR_s)
|
||||
{
|
||||
name[0] = CHAR_s;
|
||||
name++;
|
||||
}
|
||||
|
||||
name[0] = EOS;
|
||||
PrintOnAbilityPopUp((const u8 *)monName,
|
||||
(void*)(OBJ_VRAM0) + (gSprites[spriteId1].oam.tileNum * 32),
|
||||
(void*)(OBJ_VRAM0) + (gSprites[spriteId2].oam.tileNum * 32),
|
||||
7, 0,
|
||||
|
@ -2875,106 +2902,106 @@ static void PrintAbilityOnAbilityPopUp(u32 ability, u8 spriteId1, u8 spriteId2)
|
|||
7, 9, 1);
|
||||
}
|
||||
|
||||
#define PIXEL_COORDS_TO_OFFSET(x, y)( \
|
||||
/*Add tiles by X*/ \
|
||||
((y / 8) * 32 * 8) \
|
||||
/*Add tiles by X*/ \
|
||||
+ ((x / 8) * 32) \
|
||||
/*Add pixels by Y*/ \
|
||||
+ ((((y) - ((y / 8) * 8))) * 4) \
|
||||
/*Add pixels by X*/ \
|
||||
#define PIXEL_COORDS_TO_OFFSET(x, y)( \
|
||||
/*Add tiles by X*/ \
|
||||
((y / 8) * 32 * 8) \
|
||||
/*Add tiles by X*/ \
|
||||
+ ((x / 8) * 32) \
|
||||
/*Add pixels by Y*/ \
|
||||
+ ((((y) - ((y / 8) * 8))) * 4) \
|
||||
/*Add pixels by X*/ \
|
||||
+ ((((x) - ((x / 8) * 8)) / 2)))
|
||||
|
||||
static const u16 sOverwrittenPixelsTable[][2] =
|
||||
{
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 0), 5},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 1), 5},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 2), 5},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 3), 5},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 4), 5},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 5), 5},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 6), 5},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 7), 3},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 8), 3},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 9), 3},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 10), 3},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 11), 3},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 12), 3},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 13), 8},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 0), 5},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 1), 5},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 2), 5},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 3), 5},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 4), 5},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 5), 5},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 6), 5},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 7), 3},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 8), 3},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 9), 3},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 10), 3},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 11), 3},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 12), 3},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 13), 8},
|
||||
|
||||
{PIXEL_COORDS_TO_OFFSET(8, 13), 8},
|
||||
{PIXEL_COORDS_TO_OFFSET(16, 13), 8},
|
||||
{PIXEL_COORDS_TO_OFFSET(24, 13), 8},
|
||||
{PIXEL_COORDS_TO_OFFSET(32, 13), 8},
|
||||
{PIXEL_COORDS_TO_OFFSET(40, 13), 8},
|
||||
{PIXEL_COORDS_TO_OFFSET(48, 13), 8},
|
||||
{PIXEL_COORDS_TO_OFFSET(56, 13), 8},
|
||||
{PIXEL_COORDS_TO_OFFSET(8, 13), 8},
|
||||
{PIXEL_COORDS_TO_OFFSET(16, 13), 8},
|
||||
{PIXEL_COORDS_TO_OFFSET(24, 13), 8},
|
||||
{PIXEL_COORDS_TO_OFFSET(32, 13), 8},
|
||||
{PIXEL_COORDS_TO_OFFSET(40, 13), 8},
|
||||
{PIXEL_COORDS_TO_OFFSET(48, 13), 8},
|
||||
{PIXEL_COORDS_TO_OFFSET(56, 13), 8},
|
||||
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 14), 8},
|
||||
{PIXEL_COORDS_TO_OFFSET(8, 14), 8},
|
||||
{PIXEL_COORDS_TO_OFFSET(16, 14), 8},
|
||||
{PIXEL_COORDS_TO_OFFSET(24, 14), 8},
|
||||
{PIXEL_COORDS_TO_OFFSET(32, 14), 8},
|
||||
{PIXEL_COORDS_TO_OFFSET(40, 14), 8},
|
||||
{PIXEL_COORDS_TO_OFFSET(48, 14), 8},
|
||||
{PIXEL_COORDS_TO_OFFSET(56, 14), 8},
|
||||
{PIXEL_COORDS_TO_OFFSET(8, 14), 8},
|
||||
{PIXEL_COORDS_TO_OFFSET(16, 14), 8},
|
||||
{PIXEL_COORDS_TO_OFFSET(24, 14), 8},
|
||||
{PIXEL_COORDS_TO_OFFSET(32, 14), 8},
|
||||
{PIXEL_COORDS_TO_OFFSET(40, 14), 8},
|
||||
{PIXEL_COORDS_TO_OFFSET(48, 14), 8},
|
||||
{PIXEL_COORDS_TO_OFFSET(56, 14), 8},
|
||||
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 15), 3},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 16), 3},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 17), 3},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 18), 3},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 19), 3},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 20), 3},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 21), 3},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 22), 3},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 23), 3},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 24), 3},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 25), 3},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 26), 3},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 15), 3},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 16), 3},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 17), 3},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 18), 3},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 19), 3},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 20), 3},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 21), 3},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 22), 3},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 23), 3},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 24), 3},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 25), 3},
|
||||
{PIXEL_COORDS_TO_OFFSET(0, 26), 3},
|
||||
};
|
||||
|
||||
static inline void CopyPixels(u8 *dest, const u8 *src, u32 pixelCount)
|
||||
{
|
||||
u32 i = 0;
|
||||
u32 i = 0;
|
||||
|
||||
if (pixelCount & 1)
|
||||
{
|
||||
while (pixelCount != 0)
|
||||
{
|
||||
dest[i] &= ~(0xF);
|
||||
dest[i] |= (src[i] & 0xF);
|
||||
if (--pixelCount != 0)
|
||||
{
|
||||
dest[i] &= ~(0xF0);
|
||||
dest[i] |= (src[i] & 0xF0);
|
||||
pixelCount--;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < pixelCount / 2; i++)
|
||||
dest[i] = src[i];
|
||||
}
|
||||
if (pixelCount & 1)
|
||||
{
|
||||
while (pixelCount != 0)
|
||||
{
|
||||
dest[i] &= ~(0xF);
|
||||
dest[i] |= (src[i] & 0xF);
|
||||
if (--pixelCount != 0)
|
||||
{
|
||||
dest[i] &= ~(0xF0);
|
||||
dest[i] |= (src[i] & 0xF0);
|
||||
pixelCount--;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < pixelCount / 2; i++)
|
||||
dest[i] = src[i];
|
||||
}
|
||||
}
|
||||
|
||||
static void RestoreOverwrittenPixels(u8 *tiles)
|
||||
{
|
||||
u32 i;
|
||||
u8 *buffer = Alloc(sizeof(sAbilityPopUpGfx) * 2);
|
||||
u32 i;
|
||||
u8 *buffer = Alloc(sizeof(sAbilityPopUpGfx) * 2);
|
||||
|
||||
CpuCopy32(tiles, buffer, sizeof(sAbilityPopUpGfx));
|
||||
CpuCopy32(tiles, buffer, sizeof(sAbilityPopUpGfx));
|
||||
|
||||
for (i = 0; i < ARRAY_COUNT(sOverwrittenPixelsTable); i++)
|
||||
{
|
||||
CopyPixels(buffer + sOverwrittenPixelsTable[i][0],
|
||||
sAbilityPopUpGfx + sOverwrittenPixelsTable[i][0],
|
||||
sOverwrittenPixelsTable[i][1]);
|
||||
}
|
||||
for (i = 0; i < ARRAY_COUNT(sOverwrittenPixelsTable); i++)
|
||||
{
|
||||
CopyPixels(buffer + sOverwrittenPixelsTable[i][0],
|
||||
sAbilityPopUpGfx + sOverwrittenPixelsTable[i][0],
|
||||
sOverwrittenPixelsTable[i][1]);
|
||||
}
|
||||
|
||||
CpuCopy32(buffer, tiles, sizeof(sAbilityPopUpGfx));
|
||||
Free(buffer);
|
||||
CpuCopy32(buffer, tiles, sizeof(sAbilityPopUpGfx));
|
||||
Free(buffer);
|
||||
}
|
||||
|
||||
void CreateAbilityPopUp(u8 battlerId, u32 ability, bool32 isDoubleBattle)
|
||||
|
|
Loading…
Reference in a new issue