mirror of
https://github.com/pret/pokeemerald.git
synced 2026-10-24 01:53:39 -05:00
Merge branch 'master' of https://github.com/pret/pokeemerald into dexnav
This commit is contained in:
@@ -1761,7 +1761,11 @@ static void Cmd_if_cant_faint(void)
|
||||
|
||||
gBattleMoveDamage = gBattleMoveDamage * AI_THINKING_STRUCT->simulatedRNG[AI_THINKING_STRUCT->movesetIndex] / 100;
|
||||
|
||||
// This macro is missing the damage 0 = 1 assumption.
|
||||
#ifdef BUGFIX
|
||||
// Moves always do at least 1 damage.
|
||||
if (gBattleMoveDamage == 0)
|
||||
gBattleMoveDamage = 1;
|
||||
#endif
|
||||
|
||||
if (gBattleMons[gBattlerTarget].hp > gBattleMoveDamage)
|
||||
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 1);
|
||||
@@ -2019,18 +2023,24 @@ static void Cmd_if_holds_item(void)
|
||||
{
|
||||
u8 battlerId = BattleAI_GetWantedBattler(gAIScriptPtr[1]);
|
||||
u16 item;
|
||||
u8 var1, var2;
|
||||
u8 itemLo, itemHi;
|
||||
|
||||
if ((battlerId & BIT_SIDE) == (sBattler_AI & BIT_SIDE))
|
||||
item = gBattleMons[battlerId].item;
|
||||
else
|
||||
item = BATTLE_HISTORY->itemEffects[battlerId];
|
||||
|
||||
// UB: doesn't properly read an unaligned u16
|
||||
var2 = gAIScriptPtr[2];
|
||||
var1 = gAIScriptPtr[3];
|
||||
itemHi = gAIScriptPtr[2];
|
||||
itemLo = gAIScriptPtr[3];
|
||||
|
||||
if ((var1 | var2) == item)
|
||||
#ifdef BUGFIX
|
||||
// This bug doesn't affect the vanilla game because this script command
|
||||
// is only used to check ITEM_PERSIM_BERRY, whose high byte happens to
|
||||
// be 0.
|
||||
if (((itemHi << 8) | itemLo) == item)
|
||||
#else
|
||||
if ((itemLo | itemHi) == item)
|
||||
#endif
|
||||
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 4);
|
||||
else
|
||||
gAIScriptPtr += 8;
|
||||
|
||||
@@ -870,7 +870,7 @@ void AnimTask_MetallicShine(u8 taskId)
|
||||
paletteNum = 16 + gSprites[spriteId].oam.paletteNum;
|
||||
|
||||
if (gBattleAnimArgs[1] == 0)
|
||||
SetGreyscaleOrOriginalPalette(paletteNum, FALSE);
|
||||
SetGrayscaleOrOriginalPalette(paletteNum, FALSE);
|
||||
else
|
||||
BlendPalette(paletteNum * 16, 16, 11, gBattleAnimArgs[2]);
|
||||
|
||||
@@ -900,7 +900,7 @@ static void AnimTask_MetallicShine_Step(u8 taskId)
|
||||
spriteId = GetAnimBattlerSpriteId(ANIM_ATTACKER);
|
||||
paletteNum = 16 + gSprites[spriteId].oam.paletteNum;
|
||||
if (gTasks[taskId].data[1] == 0)
|
||||
SetGreyscaleOrOriginalPalette(paletteNum, TRUE);
|
||||
SetGrayscaleOrOriginalPalette(paletteNum, TRUE);
|
||||
|
||||
DestroySprite(&gSprites[gTasks[taskId].data[0]]);
|
||||
GetBattleAnimBg1Data(&animBg);
|
||||
@@ -925,10 +925,10 @@ static void AnimTask_MetallicShine_Step(u8 taskId)
|
||||
}
|
||||
}
|
||||
|
||||
// Changes battler's palette to either greyscale or original.
|
||||
// Changes battler's palette to either grayscale or original.
|
||||
// arg0: which battler
|
||||
// arg1: FALSE grayscale, TRUE original
|
||||
void AnimTask_SetGreyscaleOrOriginalPal(u8 taskId)
|
||||
void AnimTask_SetGrayscaleOrOriginalPal(u8 taskId)
|
||||
{
|
||||
u8 spriteId;
|
||||
u8 battler;
|
||||
@@ -974,7 +974,7 @@ void AnimTask_SetGreyscaleOrOriginalPal(u8 taskId)
|
||||
}
|
||||
|
||||
if (spriteId != SPRITE_NONE)
|
||||
SetGreyscaleOrOriginalPalette(gSprites[spriteId].oam.paletteNum + 16, gBattleAnimArgs[1]);
|
||||
SetGrayscaleOrOriginalPalette(gSprites[spriteId].oam.paletteNum + 16, gBattleAnimArgs[1]);
|
||||
|
||||
DestroyAnimVisualTask(taskId);
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ static void AnimPerishSongMusicNote_Step1(struct Sprite *);
|
||||
static void AnimPerishSongMusicNote_Step2(struct Sprite *);
|
||||
static void AnimGuardRing(struct Sprite *);
|
||||
static void AnimTask_Withdraw_Step(u8);
|
||||
static void AnimTask_GrowAndGreyscale_Step(u8);
|
||||
static void AnimTask_GrowAndGrayscale_Step(u8);
|
||||
static void AnimTask_Minimize_Step(u8);
|
||||
static void CreateMinimizeSprite(struct Task *, u8);
|
||||
static void ClonedMinizeSprite_Step(struct Sprite *);
|
||||
@@ -1996,26 +1996,26 @@ static void AnimGuillotinePincer_Step3(struct Sprite *sprite)
|
||||
DestroyAnimSprite(sprite);
|
||||
}
|
||||
|
||||
// Scales up the target mon sprite, and sets the palette to greyscale.
|
||||
// Scales up the target mon sprite, and sets the palette to grayscale.
|
||||
// Used in MOVE_DISABLE.
|
||||
// No args.
|
||||
void AnimTask_GrowAndGreyscale(u8 taskId)
|
||||
void AnimTask_GrowAndGrayscale(u8 taskId)
|
||||
{
|
||||
u8 spriteId = GetAnimBattlerSpriteId(ANIM_TARGET);
|
||||
PrepareBattlerSpriteForRotScale(spriteId, ST_OAM_OBJ_BLEND);
|
||||
SetSpriteRotScale(spriteId, 0xD0, 0xD0, 0);
|
||||
SetGreyscaleOrOriginalPalette(gSprites[spriteId].oam.paletteNum + 16, FALSE);
|
||||
SetGrayscaleOrOriginalPalette(gSprites[spriteId].oam.paletteNum + 16, FALSE);
|
||||
gTasks[taskId].data[0] = 80;
|
||||
gTasks[taskId].func = AnimTask_GrowAndGreyscale_Step;
|
||||
gTasks[taskId].func = AnimTask_GrowAndGrayscale_Step;
|
||||
}
|
||||
|
||||
static void AnimTask_GrowAndGreyscale_Step(u8 taskId)
|
||||
static void AnimTask_GrowAndGrayscale_Step(u8 taskId)
|
||||
{
|
||||
if (--gTasks[taskId].data[0] == -1)
|
||||
{
|
||||
u8 spriteId = GetAnimBattlerSpriteId(ANIM_TARGET);
|
||||
ResetSpriteRotScale(spriteId);
|
||||
SetGreyscaleOrOriginalPalette(gSprites[spriteId].oam.paletteNum + 16, TRUE);
|
||||
SetGrayscaleOrOriginalPalette(gSprites[spriteId].oam.paletteNum + 16, TRUE);
|
||||
DestroyAnimVisualTask(taskId);
|
||||
}
|
||||
}
|
||||
@@ -3710,7 +3710,7 @@ static void AnimPerishSongMusicNote2(struct Sprite *sprite)
|
||||
}
|
||||
|
||||
if (++sprite->data[0] == sprite->data[1])
|
||||
SetGreyscaleOrOriginalPalette(sprite->oam.paletteNum + 16, 0);
|
||||
SetGrayscaleOrOriginalPalette(sprite->oam.paletteNum + 16, 0);
|
||||
|
||||
if (sprite->data[0] == sprite->data[1] + 80)
|
||||
DestroyAnimSprite(sprite);
|
||||
|
||||
@@ -1310,7 +1310,7 @@ u16 ArcTan2Neg(s16 a, s16 b)
|
||||
return -var;
|
||||
}
|
||||
|
||||
void SetGreyscaleOrOriginalPalette(u16 paletteNum, bool8 restoreOriginalColor)
|
||||
void SetGrayscaleOrOriginalPalette(u16 paletteNum, bool8 restoreOriginalColor)
|
||||
{
|
||||
int i;
|
||||
struct PlttData *originalColor;
|
||||
|
||||
@@ -38,7 +38,7 @@ static void GenerateInitialRentalMons(void);
|
||||
static void GetOpponentMostCommonMonType(void);
|
||||
static void GetOpponentBattleStyle(void);
|
||||
static void RestorePlayerPartyHeldItems(void);
|
||||
static u16 GetFactoryMonId(u8 lvlMode, u8 challengeNum, bool8 arg2);
|
||||
static u16 GetFactoryMonId(u8 lvlMode, u8 challengeNum, bool8 useBetterRange);
|
||||
static u8 GetMoveBattleStyle(u16 move);
|
||||
|
||||
// Number of moves needed on the team to be considered using a certain battle style
|
||||
|
||||
@@ -159,7 +159,7 @@ enum
|
||||
|
||||
// strings
|
||||
extern const u8 gText_Slash[];
|
||||
extern const u8 gText_HighlightDarkGrey[];
|
||||
extern const u8 gText_HighlightDarkGray[];
|
||||
extern const u8 gText_DynColor2[];
|
||||
extern const u8 gText_DynColor2Male[];
|
||||
extern const u8 gText_DynColor1Female[];
|
||||
@@ -1895,7 +1895,7 @@ static void UpdateNickInHealthbox(u8 healthboxSpriteId, struct Pokemon *mon)
|
||||
u16 species;
|
||||
u8 gender;
|
||||
|
||||
StringCopy(gDisplayedStringBattle, gText_HighlightDarkGrey);
|
||||
StringCopy(gDisplayedStringBattle, gText_HighlightDarkGray);
|
||||
GetMonData(mon, MON_DATA_NICKNAME, nickname);
|
||||
StringGetEnd10(nickname);
|
||||
ptr = StringAppend(gDisplayedStringBattle, nickname);
|
||||
|
||||
@@ -383,7 +383,7 @@ static const u8 sText_ThrewPokeblockAtPkmn[] = _("{B_PLAYER_NAME} threw a {POKEB
|
||||
static const u8 sText_OutOfSafariBalls[] = _("{PLAY_SE SE_DING_DONG}ANNOUNCER: You're out of\nSAFARI BALLS! Game over!\p");
|
||||
static const u8 sText_OpponentMon1Appeared[] = _("{B_OPPONENT_MON1_NAME} appeared!\p");
|
||||
static const u8 sText_WildPkmnAppeared[] = _("Wild {B_OPPONENT_MON1_NAME} appeared!\p");
|
||||
static const u8 sText_WildPkmnAppeared2[] = _("Wild {B_OPPONENT_MON1_NAME} appeared!\p");
|
||||
static const u8 sText_LegendaryPkmnAppeared[] = _("Wild {B_OPPONENT_MON1_NAME} appeared!\p");
|
||||
static const u8 sText_WildPkmnAppearedPause[] = _("Wild {B_OPPONENT_MON1_NAME} appeared!{PAUSE 127}");
|
||||
static const u8 sText_TwoWildPkmnAppeared[] = _("Wild {B_OPPONENT_MON1_NAME} and\n{B_OPPONENT_MON2_NAME} appeared!\p");
|
||||
static const u8 sText_Trainer1WantsToBattle[] = _("{B_TRAINER1_CLASS} {B_TRAINER1_NAME}\nwould like to battle!\p");
|
||||
@@ -2125,7 +2125,7 @@ void BufferStringBattle(u16 stringID)
|
||||
else
|
||||
{
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_LEGENDARY)
|
||||
stringPtr = sText_WildPkmnAppeared2;
|
||||
stringPtr = sText_LegendaryPkmnAppeared;
|
||||
else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) // interesting, looks like they had something planned for wild double battles
|
||||
stringPtr = sText_TwoWildPkmnAppeared;
|
||||
else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL)
|
||||
|
||||
@@ -3357,7 +3357,7 @@ static void Cmd_getexp(void)
|
||||
// get exp getter battlerId
|
||||
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
|
||||
{
|
||||
if (!(gBattlerPartyIndexes[2] != gBattleStruct->expGetterMonId) && !(gAbsentBattlerFlags & gBitTable[2]))
|
||||
if (gBattlerPartyIndexes[2] == gBattleStruct->expGetterMonId && !(gAbsentBattlerFlags & gBitTable[2]))
|
||||
gBattleStruct->expGetterBattlerId = 2;
|
||||
else
|
||||
{
|
||||
@@ -3431,14 +3431,13 @@ static void Cmd_getexp(void)
|
||||
gBattleMons[0].maxHP = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_MAX_HP);
|
||||
gBattleMons[0].attack = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_ATK);
|
||||
gBattleMons[0].defense = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_DEF);
|
||||
// Why is this duplicated?
|
||||
// Speed is duplicated, likely due to a copy-paste error.
|
||||
gBattleMons[0].speed = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_SPEED);
|
||||
gBattleMons[0].speed = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_SPEED);
|
||||
|
||||
gBattleMons[0].spAttack = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_SPATK);
|
||||
gBattleMons[0].spDefense = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_SPDEF);
|
||||
}
|
||||
// What is else if?
|
||||
|
||||
if (gBattlerPartyIndexes[2] == gBattleStruct->expGetterMonId && gBattleMons[2].hp && (gBattleTypeFlags & BATTLE_TYPE_DOUBLE))
|
||||
{
|
||||
gBattleMons[2].level = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_LEVEL);
|
||||
@@ -3446,10 +3445,13 @@ static void Cmd_getexp(void)
|
||||
gBattleMons[2].maxHP = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_MAX_HP);
|
||||
gBattleMons[2].attack = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_ATK);
|
||||
gBattleMons[2].defense = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_DEF);
|
||||
// Duplicated again, but this time there's no Sp Defense
|
||||
gBattleMons[2].speed = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_SPEED);
|
||||
// Speed is duplicated again, but Special Defense is missing.
|
||||
#ifdef BUGFIX
|
||||
gBattleMons[2].spDefense = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_SPDEF);
|
||||
#else
|
||||
gBattleMons[2].speed = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_SPEED);
|
||||
|
||||
#endif
|
||||
gBattleMons[2].spAttack = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_SPATK);
|
||||
}
|
||||
gBattleScripting.getexpState = 5;
|
||||
@@ -6168,7 +6170,13 @@ static void Cmd_recordlastability(void)
|
||||
{
|
||||
gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]);
|
||||
RecordAbilityBattle(gActiveBattler, gLastUsedAbility);
|
||||
gBattlescriptCurrInstr += 1; // UB: Should be + 2, one byte for command and one byte for battlerId argument.
|
||||
|
||||
#ifdef BUGFIX
|
||||
// This command occupies two bytes (one for the command id, and one for the battler id parameter).
|
||||
gBattlescriptCurrInstr += 2;
|
||||
#else
|
||||
gBattlescriptCurrInstr += 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
void BufferMoveToLearnIntoBattleTextBuff2(void)
|
||||
|
||||
@@ -1323,6 +1323,12 @@ static bool8 Phase2_BigPokeball_Func1(struct Task *task)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#define SOME_VRAM_STORE(ptr, posY, posX, toStore) \
|
||||
{ \
|
||||
u32 index = (posY) * 32 + posX; \
|
||||
ptr[index] = toStore; \
|
||||
}
|
||||
|
||||
static bool8 Phase2_BigPokeball_Func2(struct Task *task)
|
||||
{
|
||||
s16 i, j;
|
||||
@@ -1335,7 +1341,7 @@ static bool8 Phase2_BigPokeball_Func2(struct Task *task)
|
||||
{
|
||||
for (j = 0; j < 30; j++, BigPokeballMap++)
|
||||
{
|
||||
tilemap[i * 32 + j] = *BigPokeballMap | 0xF000;
|
||||
SOME_VRAM_STORE(tilemap, i, j, *BigPokeballMap | 0xF000);
|
||||
}
|
||||
}
|
||||
sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 132, task->tData5, 160);
|
||||
@@ -1675,12 +1681,6 @@ bool8 FldEff_Pokeball(void)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#define SOME_VRAM_STORE(ptr, posY, posX, toStore) \
|
||||
{ \
|
||||
u32 index = (posY) * 32 + posX; \
|
||||
ptr[index] = toStore; \
|
||||
}
|
||||
|
||||
static void sub_814713C(struct Sprite *sprite)
|
||||
{
|
||||
s16 arr0[ARRAY_COUNT(sUnknown_085C8B96)];
|
||||
@@ -2142,7 +2142,7 @@ static bool8 Phase2_Mugshot_Func2(struct Task *task)
|
||||
{
|
||||
for (j = 0; j < 32; j++, mugshotsMap++)
|
||||
{
|
||||
tilemap[i * 32 + j] = *mugshotsMap | 0xF000;
|
||||
SOME_VRAM_STORE(tilemap, i, j, *mugshotsMap | 0xF000);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2960,17 +2960,15 @@ static bool8 Phase2_RectangularSpiral_Func2(struct Task *task)
|
||||
|
||||
if (sub_8149048(gUnknown_085C8D38[j / 2], &sRectangularSpiralTransition[j]))
|
||||
{
|
||||
u32 one;
|
||||
done = FALSE;
|
||||
var = sRectangularSpiralTransition[j].field_2;
|
||||
one = 1;
|
||||
if ((j & 1) == one)
|
||||
if ((j % 2) == 1)
|
||||
var = 0x27D - var;
|
||||
|
||||
var2 = var % 32;
|
||||
var3 = var / 32 * 32;
|
||||
var3 = var / 32;
|
||||
|
||||
tilemap[var3 + var2] = 0xF002;
|
||||
SOME_VRAM_STORE(tilemap, var3, var2, 0xF002);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1526,7 +1526,7 @@ static void Task_ShowMoveSelectScreen(u8 taskId)
|
||||
&& eContestantStatus[gContestPlayerMonIndex].hasJudgesAttention)
|
||||
{
|
||||
// Highlight the text because it's a combo move
|
||||
moveNameBuffer = StringCopy(moveName, gText_ColorLightShadowDarkGrey);
|
||||
moveNameBuffer = StringCopy(moveName, gText_ColorLightShadowDarkGray);
|
||||
}
|
||||
else if (move != MOVE_NONE
|
||||
&& eContestantStatus[gContestPlayerMonIndex].prevMove == move
|
||||
|
||||
@@ -497,7 +497,7 @@ static void LoadContestMonName(u8 monIndex)
|
||||
struct ContestPokemon *mon = &gContestMons[monIndex];
|
||||
u8 *str = gDisplayedStringBattle;
|
||||
if (monIndex == gContestPlayerMonIndex)
|
||||
str = StringCopy(gDisplayedStringBattle, gText_ColorDarkGrey);
|
||||
str = StringCopy(gDisplayedStringBattle, gText_ColorDarkGray);
|
||||
|
||||
StringCopy(str, mon->nickname);
|
||||
AddContestTextPrinter(monIndex, gDisplayedStringBattle, 0);
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
#include "constants/moves.h"
|
||||
#include "constants/region_map_sections.h"
|
||||
|
||||
extern const struct Evolution gEvolutionTable[][EVOS_PER_MON];
|
||||
|
||||
// this file's functions
|
||||
static void ClearDaycareMonMail(struct DaycareMail *mail);
|
||||
static void SetInitialEggData(struct Pokemon *mon, u16 species, struct DayCare *daycare);
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
#include "constants/rgb.h"
|
||||
#include "constants/items.h"
|
||||
|
||||
extern struct Evolution gEvolutionTable[][EVOS_PER_MON];
|
||||
|
||||
struct EvoInfo
|
||||
{
|
||||
u8 preEvoSpriteId;
|
||||
@@ -550,8 +552,6 @@ static void CreateShedinja(u16 preEvoSpecies, struct Pokemon* mon)
|
||||
{
|
||||
s32 i;
|
||||
struct Pokemon* shedinja = &gPlayerParty[gPlayerPartyCount];
|
||||
const struct Evolution *evos;
|
||||
const struct Evolution *evos2;
|
||||
|
||||
CopyMon(&gPlayerParty[gPlayerPartyCount], mon, sizeof(struct Pokemon));
|
||||
SetMonData(&gPlayerParty[gPlayerPartyCount], MON_DATA_SPECIES, &gEvolutionTable[preEvoSpecies][1].targetSpecies);
|
||||
@@ -572,12 +572,8 @@ static void CreateShedinja(u16 preEvoSpecies, struct Pokemon* mon)
|
||||
CalculateMonStats(&gPlayerParty[gPlayerPartyCount]);
|
||||
CalculatePlayerPartyCount();
|
||||
|
||||
// can't match it otherwise, ehh
|
||||
evos2 = gEvolutionTable[0];
|
||||
evos = evos2 + EVOS_PER_MON * preEvoSpecies;
|
||||
|
||||
GetSetPokedexFlag(SpeciesToNationalPokedexNum(evos[1].targetSpecies), FLAG_SET_SEEN);
|
||||
GetSetPokedexFlag(SpeciesToNationalPokedexNum(evos[1].targetSpecies), FLAG_SET_CAUGHT);
|
||||
GetSetPokedexFlag(SpeciesToNationalPokedexNum(gEvolutionTable[preEvoSpecies][1].targetSpecies), FLAG_SET_SEEN);
|
||||
GetSetPokedexFlag(SpeciesToNationalPokedexNum(gEvolutionTable[preEvoSpecies][1].targetSpecies), FLAG_SET_CAUGHT);
|
||||
|
||||
if (GetMonData(shedinja, MON_DATA_SPECIES) == SPECIES_SHEDINJA
|
||||
&& GetMonData(shedinja, MON_DATA_LANGUAGE) == LANGUAGE_JAPANESE
|
||||
|
||||
@@ -1525,6 +1525,10 @@ void ply_xwave(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *track
|
||||
{
|
||||
u32 wav;
|
||||
|
||||
#ifdef UBFIX
|
||||
wav = 0;
|
||||
#endif
|
||||
|
||||
READ_XCMD_BYTE(wav, 0) // UB: uninitialized variable
|
||||
READ_XCMD_BYTE(wav, 1)
|
||||
READ_XCMD_BYTE(wav, 2)
|
||||
@@ -1592,6 +1596,10 @@ void ply_xcmd_0C(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *tra
|
||||
{
|
||||
u32 unk;
|
||||
|
||||
#ifdef UBFIX
|
||||
unk = 0;
|
||||
#endif
|
||||
|
||||
READ_XCMD_BYTE(unk, 0) // UB: uninitialized variable
|
||||
READ_XCMD_BYTE(unk, 1)
|
||||
|
||||
@@ -1611,6 +1619,7 @@ void ply_xcmd_0C(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *tra
|
||||
void ply_xcmd_0D(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *track)
|
||||
{
|
||||
u32 unk;
|
||||
|
||||
#ifdef UBFIX
|
||||
unk = 0;
|
||||
#endif
|
||||
|
||||
@@ -2604,9 +2604,9 @@ static void RotateUpSlamDown_0(struct Sprite *sprite)
|
||||
{
|
||||
TryFlipX(sprite);
|
||||
sprite->data[7]--;
|
||||
sprite->pos2.x = Cos(sprite->data[7], sprite->data[6]) + sprite->data[6];
|
||||
sprite->pos2.x = sprite->data[6] + Cos(sprite->data[7], sprite->data[6]);
|
||||
|
||||
sprite->pos2.y = -(Sin(sprite->data[7], sprite->data[6] += 0)); // dummy += 0 is needed to match
|
||||
sprite->pos2.y = -(Sin(sprite->data[7], sprite->data[6]));
|
||||
|
||||
HandleSetAffineData(sprite, 256, 256, (sprite->data[7] - 128) << 8);
|
||||
if (sprite->data[7] <= 120)
|
||||
@@ -2634,9 +2634,9 @@ static void RotateUpSlamDown_2(struct Sprite *sprite)
|
||||
{
|
||||
TryFlipX(sprite);
|
||||
sprite->data[7] += 2;
|
||||
sprite->pos2.x = Cos(sprite->data[7], sprite->data[6]) + sprite->data[6];
|
||||
sprite->pos2.x = sprite->data[6] + Cos(sprite->data[7], sprite->data[6]);
|
||||
|
||||
sprite->pos2.y = -(Sin(sprite->data[7], sprite->data[6] += 0)); // dummy += 0 is needed to match
|
||||
sprite->pos2.y = -(Sin(sprite->data[7], sprite->data[6]));
|
||||
|
||||
HandleSetAffineData(sprite, 256, 256, (sprite->data[7] - 128) << 8);
|
||||
if (sprite->data[7] >= 128)
|
||||
@@ -4066,16 +4066,15 @@ static void VerticalShakeLowTwice(struct Sprite *sprite)
|
||||
u8 var8 = sprite->data[2];
|
||||
u8 var9 = sprite->data[6];
|
||||
u8 var5 = sVerticalShakeData[sprite->data[5]][0];
|
||||
u8 var2 = var5;
|
||||
if (var5 != (u8)-1)
|
||||
var5 = sprite->data[7];
|
||||
else
|
||||
var5 = (u8)-1; // needed to match
|
||||
|
||||
var6 = sVerticalShakeData[sprite->data[5]][1];
|
||||
var7 = 0;
|
||||
if (var2 != (u8)-2)
|
||||
if (sVerticalShakeData[sprite->data[5]][0] != (u8)-2)
|
||||
var7 = (var6 - var9) * var5 / var6;
|
||||
else
|
||||
var7 = 0;
|
||||
|
||||
if (var5 == (u8)-1)
|
||||
{
|
||||
|
||||
@@ -5437,15 +5437,16 @@ static bool32 WaitForWallpaperGfxLoad(void)
|
||||
|
||||
static void DrawWallpaper(const void *tilemap, s8 direction, u8 offset)
|
||||
{
|
||||
s16 var = (offset * 2) + 3;
|
||||
s16 var = offset * 256;
|
||||
s16 var2 = (offset * 2) + 3;
|
||||
s16 x = ((sStorage->bg2_X / 8 + 10) + (direction * 24)) & 0x3F;
|
||||
|
||||
CopyRectToBgTilemapBufferRect(2, tilemap, 0, 0, 0x14, 0x12, x, 2, 0x14, 0x12, 0x11, offset << 8, var);
|
||||
CopyRectToBgTilemapBufferRect(2, tilemap, 0, 0, 0x14, 0x12, x, 2, 0x14, 0x12, 0x11, var, var2);
|
||||
|
||||
if (direction == 0)
|
||||
return;
|
||||
if (direction > 0)
|
||||
x *= 1, x += 0x14; // x * 1 is needed to match, but can be safely removed as it makes no functional difference
|
||||
x += 0x14;
|
||||
else
|
||||
x -= 4;
|
||||
|
||||
|
||||
30
src/siirtc.c
30
src/siirtc.c
@@ -71,6 +71,7 @@ static bool8 sLocked;
|
||||
static int WriteCommand(u8 value);
|
||||
static int WriteData(u8 value);
|
||||
static u8 ReadData();
|
||||
|
||||
static void EnableGpioPortRead();
|
||||
static void DisableGpioPortRead();
|
||||
|
||||
@@ -98,8 +99,12 @@ u8 SiiRtcProbe(void)
|
||||
|
||||
errorCode = 0;
|
||||
|
||||
#ifdef BUGFIX
|
||||
if (!(rtc.status & SIIRTCINFO_24HOUR) || (rtc.status & SIIRTCINFO_POWER))
|
||||
#else
|
||||
if ((rtc.status & (SIIRTCINFO_POWER | SIIRTCINFO_24HOUR)) == SIIRTCINFO_POWER
|
||||
|| (rtc.status & (SIIRTCINFO_POWER | SIIRTCINFO_24HOUR)) == 0)
|
||||
#endif
|
||||
{
|
||||
// The RTC is in 12-hour mode. Reset it and switch to 24-hour mode.
|
||||
|
||||
@@ -131,7 +136,7 @@ u8 SiiRtcProbe(void)
|
||||
|
||||
bool8 SiiRtcReset(void)
|
||||
{
|
||||
u8 result;
|
||||
bool8 result;
|
||||
struct SiiRtcInfo rtc;
|
||||
|
||||
if (sLocked == TRUE)
|
||||
@@ -392,7 +397,11 @@ static int WriteCommand(u8 value)
|
||||
GPIO_PORT_DATA = (temp << 1) | SCK_HI | CS_HI;
|
||||
}
|
||||
|
||||
// control reaches end of non-void function
|
||||
// Nothing uses the returned value from this function,
|
||||
// so the undefined behavior is harmless in the vanilla game.
|
||||
#ifdef UBFIX
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int WriteData(u8 value)
|
||||
@@ -409,7 +418,11 @@ static int WriteData(u8 value)
|
||||
GPIO_PORT_DATA = (temp << 1) | SCK_HI | CS_HI;
|
||||
}
|
||||
|
||||
// control reaches end of non-void function
|
||||
// Nothing uses the returned value from this function,
|
||||
// so the undefined behavior is harmless in the vanilla game.
|
||||
#ifdef UBFIX
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static u8 ReadData()
|
||||
@@ -417,9 +430,10 @@ static u8 ReadData()
|
||||
u8 i;
|
||||
u8 temp;
|
||||
u8 value;
|
||||
#ifdef UBFIX
|
||||
|
||||
#ifdef UBFIX
|
||||
value = 0;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
@@ -431,7 +445,7 @@ static u8 ReadData()
|
||||
GPIO_PORT_DATA = SCK_HI | CS_HI;
|
||||
|
||||
temp = ((GPIO_PORT_DATA & SIO_HI) >> 1);
|
||||
value = (value >> 1) | (temp << 7); // UB: value is uninitialized on first iteration
|
||||
value = (value >> 1) | (temp << 7);
|
||||
}
|
||||
|
||||
return value;
|
||||
@@ -439,10 +453,10 @@ static u8 ReadData()
|
||||
|
||||
static void EnableGpioPortRead()
|
||||
{
|
||||
GPIO_PORT_READ_ENABLE = 1;
|
||||
GPIO_PORT_READ_ENABLE = TRUE;
|
||||
}
|
||||
|
||||
static void DisableGpioPortRead()
|
||||
{
|
||||
GPIO_PORT_READ_ENABLE = 0;
|
||||
GPIO_PORT_READ_ENABLE = FALSE;
|
||||
}
|
||||
|
||||
@@ -1229,7 +1229,7 @@ ALIGNED(4) const u8 gText_Facility[] = _("{STR_VAR_1}");
|
||||
|
||||
const u8 gText_Give[] = _("Give");
|
||||
const u8 gText_NoNeed[] = _("No need");
|
||||
const u8 gText_ColorLightShadowDarkGrey[] = _("{COLOR LIGHT_GRAY}{SHADOW DARK_GRAY}");
|
||||
const u8 gText_ColorLightShadowDarkGray[] = _("{COLOR LIGHT_GRAY}{SHADOW DARK_GRAY}");
|
||||
const u8 gText_ColorBlue[] = _("{COLOR BLUE}");
|
||||
const u8 gText_ColorTransparent[] = _("{HIGHLIGHT TRANSPARENT}{COLOR TRANSPARENT}");
|
||||
const u8 gText_CDot[] = _("C.");
|
||||
@@ -1239,9 +1239,9 @@ const u8 gText_PreliminaryResults[] = _("The preliminary results!");
|
||||
const u8 gText_Round2Results[] = _("Round 2 results!");
|
||||
const u8 gText_ContestantsMonWon[] = _("{STR_VAR_1}'s {STR_VAR_2} won!");
|
||||
const u8 gText_CommunicationStandby[] = _("Communication standby…");
|
||||
const u8 gText_ColorDarkGrey[] = _("{COLOR DARK_GRAY}");
|
||||
const u8 gText_ColorDarkGray[] = _("{COLOR DARK_GRAY}");
|
||||
const u8 gText_ColorDynamic6WhiteDynamic5[] = _("{COLOR_HIGHLIGHT_SHADOW DYNAMIC_COLOR6 WHITE DYNAMIC_COLOR5}"); // Unused
|
||||
const u8 gText_HighlightDarkGrey[] = _("{HIGHLIGHT DARK_GRAY}");
|
||||
const u8 gText_HighlightDarkGray[] = _("{HIGHLIGHT DARK_GRAY}");
|
||||
const u8 gText_EmptySpace2[] = _(" "); // Unused
|
||||
const u8 gText_DynColor2Male[] = _("{COLOR DYNAMIC_COLOR2}♂");
|
||||
const u8 gText_DynColor1Female[] = _("{COLOR DYNAMIC_COLOR1}♀");
|
||||
|
||||
@@ -2984,7 +2984,7 @@ static void HideKeyboardSwapMenu(void)
|
||||
|
||||
static void PrintChatMessage(u16 row, u8 *str, u8 colorIdx)
|
||||
{
|
||||
// colorIdx: 0 = grey, 1 = red, 2 = green, 3 = blue
|
||||
// colorIdx: 0 = gray, 1 = red, 2 = green, 3 = blue
|
||||
u8 color[3];
|
||||
color[0] = TEXT_COLOR_WHITE;
|
||||
color[1] = colorIdx * 2 + 2;
|
||||
|
||||
Reference in New Issue
Block a user