Merge branch 'master' into link
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
#include "main.h"
|
||||
#include "load_save.h"
|
||||
#include "gpu_regs.h"
|
||||
#include "unknown_task.h"
|
||||
#include "scanline_effect.h"
|
||||
#include "battle_setup.h"
|
||||
#include "battle_scripts.h"
|
||||
#include "pokemon.h"
|
||||
@@ -47,13 +47,6 @@
|
||||
#include "battle_string_ids.h"
|
||||
#include "data2.h"
|
||||
|
||||
struct UnknownStruct6
|
||||
{
|
||||
u16 unk0[0xA0];
|
||||
u8 fillerA0[0x640];
|
||||
u16 unk780[0xA0];
|
||||
};
|
||||
|
||||
struct UnknownPokemonStruct2
|
||||
{
|
||||
/*0x00*/ u16 species;
|
||||
@@ -91,8 +84,6 @@ extern void (*gBattleMainFunc)(void);
|
||||
extern void (*gCB2_AfterEvolution)(void);
|
||||
extern struct UnknownPokemonStruct2 gUnknown_02022FF8[3]; // what is it used for?
|
||||
extern struct UnknownPokemonStruct2* gUnknown_02023058; // what is it used for?
|
||||
extern u8 gUnknown_02039B28[]; // possibly a struct?
|
||||
extern struct UnknownStruct6 gUnknown_02038C28; // todo: identify & document
|
||||
extern struct MusicPlayerInfo gMPlayInfo_SE1;
|
||||
extern struct MusicPlayerInfo gMPlayInfo_SE2;
|
||||
extern u8 gDecompressionBuffer[];
|
||||
@@ -163,6 +154,7 @@ extern const u8 * const gBattlescriptsForBallThrow[];
|
||||
extern const u8 * const gBattlescriptsForRunningByItem[];
|
||||
extern const u8 * const gBattlescriptsForUsingItem[];
|
||||
extern const u8 * const gBattlescriptsForSafariActions[];
|
||||
extern const struct ScanlineEffectParams gUnknown_0831AC70;
|
||||
|
||||
// strings
|
||||
extern const u8 gText_LinkStandby3[];
|
||||
@@ -181,7 +173,7 @@ extern const u8 gText_Confusion[];
|
||||
extern const u8 gText_Love[];
|
||||
|
||||
// functions
|
||||
extern void dp12_8087EA4(void);
|
||||
extern void ScanlineEffect_Clear(void);
|
||||
extern void sub_80356D0(void);
|
||||
extern void GetFrontierTrainerName(u8* dst, u16 trainerId); // battle tower
|
||||
extern void sub_8166188(void); // battle tower, sets link battle mons level but why?
|
||||
@@ -384,24 +376,21 @@ static void CB2_InitBattleInternal(void)
|
||||
else
|
||||
{
|
||||
gBattle_WIN0V = 0x5051;
|
||||
dp12_8087EA4();
|
||||
ScanlineEffect_Clear();
|
||||
|
||||
for (i = 0; i < 80; i++)
|
||||
{
|
||||
gUnknown_02038C28.unk0[i] = 0xF0;
|
||||
gUnknown_02038C28.unk780[i] = 0xF0;
|
||||
gScanlineEffectRegBuffers[0][i] = 0xF0;
|
||||
gScanlineEffectRegBuffers[1][i] = 0xF0;
|
||||
}
|
||||
for (i = 80; i < 160; i++)
|
||||
{
|
||||
#ifndef NONMATCHING
|
||||
asm(""::"r"(i)); // needed to match
|
||||
#endif // NONMATCHING
|
||||
|
||||
gUnknown_02038C28.unk0[i] = 0xFF10;
|
||||
gUnknown_02038C28.unk780[i] = 0xFF10;
|
||||
asm(""::"r"(i));
|
||||
gScanlineEffectRegBuffers[0][i] = 0xFF10;
|
||||
gScanlineEffectRegBuffers[1][i] = 0xFF10;
|
||||
}
|
||||
|
||||
sub_80BA038(gUnknown_0831AC70);
|
||||
ScanlineEffect_SetParams(gUnknown_0831AC70);
|
||||
}
|
||||
|
||||
ResetPaletteFade();
|
||||
@@ -1597,7 +1586,7 @@ void BattleMainCB2(void)
|
||||
static void FreeRestoreBattleData(void)
|
||||
{
|
||||
gMain.callback1 = gPreBattleCallback1;
|
||||
gUnknown_02039B28[0x15] = 3;
|
||||
gScanlineEffect.state = 3;
|
||||
gMain.inBattle = 0;
|
||||
ZeroEnemyPartyMons();
|
||||
m4aSongNumStop(0x5A);
|
||||
@@ -1815,7 +1804,7 @@ void VBlankCB_Battle(void)
|
||||
LoadOam();
|
||||
ProcessSpriteCopyRequests();
|
||||
TransferPlttBuffer();
|
||||
sub_80BA0A8();
|
||||
ScanlineEffect_InitHBlankDmaTransfer();
|
||||
}
|
||||
|
||||
void nullsub_17(void)
|
||||
@@ -1953,18 +1942,18 @@ void sub_8038D64(void)
|
||||
SetGpuReg(REG_OFFSET_WINOUT, 0);
|
||||
gBattle_WIN0H = 0xF0;
|
||||
gBattle_WIN0V = 0x5051;
|
||||
dp12_8087EA4();
|
||||
ScanlineEffect_Clear();
|
||||
|
||||
for (i = 0; i < 80; i++)
|
||||
{
|
||||
gUnknown_02038C28.unk0[i] = 0xF0;
|
||||
gUnknown_02038C28.unk780[i] = 0xF0;
|
||||
gScanlineEffectRegBuffers[0][i] = 0xF0;
|
||||
gScanlineEffectRegBuffers[1][i] = 0xF0;
|
||||
}
|
||||
for (i = 80; i < 160; i++)
|
||||
{
|
||||
asm(""::"r"(i)); // Needed to stop the compiler from optimizing out the loop counter
|
||||
gUnknown_02038C28.unk0[i] = 0xFF10;
|
||||
gUnknown_02038C28.unk780[i] = 0xFF10;
|
||||
gScanlineEffectRegBuffers[0][i] = 0xFF10;
|
||||
gScanlineEffectRegBuffers[1][i] = 0xFF10;
|
||||
}
|
||||
|
||||
ResetPaletteFade();
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "international_string_util.h"
|
||||
#include "safari_zone.h"
|
||||
#include "battle_anim.h"
|
||||
#include "constants/rgb.h"
|
||||
|
||||
struct TestingBar
|
||||
{
|
||||
@@ -555,13 +556,13 @@ enum
|
||||
PAL_STATUS_BRN
|
||||
};
|
||||
|
||||
static const u16 sStatusIconPalettes[] =
|
||||
static const u16 sStatusIconColors[] =
|
||||
{
|
||||
0x6198, // PAL_STATUS_PSN
|
||||
0xEF7, // PAL_STATUS_PAR
|
||||
0x4694, // PAL_STATUS_SLP
|
||||
0x72D1, // PAL_STATUS_FRZ
|
||||
0x29DC // PAL_STATUS_BRN
|
||||
RGB(24, 12, 24), // PAL_STATUS_PSN
|
||||
RGB(23, 23, 3), // PAL_STATUS_PAR
|
||||
RGB(20, 20, 17), // PAL_STATUS_SLP
|
||||
RGB(17, 22, 28), // PAL_STATUS_FRZ
|
||||
RGB(28, 14, 10) // PAL_STATUS_BRN
|
||||
};
|
||||
|
||||
static const struct WindowTemplate sHealthboxWindowTemplate = {0, 0, 0, 8, 2, 0, 0}; // width = 8, height = 2
|
||||
@@ -2071,7 +2072,7 @@ static void UpdateStatusIconInHealthbox(u8 healthboxSpriteId)
|
||||
pltAdder = gSprites[healthboxSpriteId].oam.paletteNum * 16;
|
||||
pltAdder += bank + 12;
|
||||
|
||||
FillPalette(sStatusIconPalettes[statusPalId], pltAdder + 0x100, 2);
|
||||
FillPalette(sStatusIconColors[statusPalId], pltAdder + 0x100, 2);
|
||||
CpuCopy16(gPlttBufferUnfaded + 0x100 + pltAdder, (void*)(OBJ_PLTT + pltAdder * 2), 2);
|
||||
CpuCopy32(statusGfxPtr, (void*)(OBJ_VRAM0 + (gSprites[healthboxSpriteId].oam.tileNum + tileNumAdder) * 32), 96);
|
||||
if (IsDoubleBattle() == TRUE || GetBankSide(bank) == SIDE_OPPONENT)
|
||||
@@ -2575,7 +2576,7 @@ static u8* AddTextPrinterAndCreateWindowOnHealthbox(const u8 *str, u32 x, u32 y,
|
||||
color.bgColor = 1;
|
||||
color.shadowColor = 3;
|
||||
|
||||
AddTextPrinterParametrized2(winId, 0, x, y, 0, 0, &color, -1, str);
|
||||
AddTextPrinterParameterized2(winId, 0, x, y, 0, 0, &color, -1, str);
|
||||
|
||||
*windowId = winId;
|
||||
return (u8*)(GetWindowAttribute(winId, WINDOW_TILE_DATA));
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "constants/songs.h"
|
||||
#include "constants/trainers.h"
|
||||
#include "field_camera.h"
|
||||
#include "unknown_task.h"
|
||||
#include "scanline_effect.h"
|
||||
#include "malloc.h"
|
||||
#include "gpu_regs.h"
|
||||
#include "decompress.h"
|
||||
@@ -56,8 +56,6 @@ struct StructRectangularSpiral
|
||||
typedef bool8 (*TransitionStateFunc)(struct Task *task);
|
||||
typedef bool8 (*TransitionSpriteCallback)(struct Sprite *sprite);
|
||||
|
||||
extern u16 gUnknown_020393A8[];
|
||||
extern u16 gUnknown_02038C28[][0x3C0];
|
||||
extern u16 gBattle_BG0_X;
|
||||
extern u16 gBattle_BG0_Y;
|
||||
|
||||
@@ -65,7 +63,7 @@ extern const struct OamData gFieldObjectBaseOam_32x32;
|
||||
|
||||
extern void c2_exit_to_overworld_2_switch(void);
|
||||
extern void sub_80AC3D0(void);
|
||||
extern void dp12_8087EA4(void);
|
||||
extern void ScanlineEffect_Clear(void);
|
||||
|
||||
// this file's functions
|
||||
static void LaunchBattleTransitionTask(u8 transitionId);
|
||||
@@ -1110,9 +1108,9 @@ static void Phase2Task_Swirl(u8 taskId)
|
||||
static bool8 Phase2_Swirl_Func1(struct Task *task)
|
||||
{
|
||||
sub_8149F08();
|
||||
dp12_8087EA4();
|
||||
ScanlineEffect_Clear();
|
||||
BeginNormalPaletteFade(-1, 4, 0, 0x10, 0);
|
||||
sub_8149F98(gUnknown_020393A8, sTransitionStructPtr->field_14, 0, 2, 0, 160);
|
||||
sub_8149F98(gScanlineEffectRegBuffers[1], sTransitionStructPtr->field_14, 0, 2, 0, 160);
|
||||
|
||||
SetVBlankCallback(VBlankCB_Phase2_Swirl);
|
||||
SetHBlankCallback(HBlankCB_Phase2_Swirl);
|
||||
@@ -1129,7 +1127,7 @@ static bool8 Phase2_Swirl_Func2(struct Task *task)
|
||||
task->tData1 += 4;
|
||||
task->tData2 += 8;
|
||||
|
||||
sub_8149F98(gUnknown_02038C28[0], sTransitionStructPtr->field_14, task->tData1, 2, task->tData2, 160);
|
||||
sub_8149F98(gScanlineEffectRegBuffers[0], sTransitionStructPtr->field_14, task->tData1, 2, task->tData2, 160);
|
||||
|
||||
if (!gPaletteFade.active)
|
||||
{
|
||||
@@ -1145,12 +1143,12 @@ static void VBlankCB_Phase2_Swirl(void)
|
||||
{
|
||||
VBlankCB_BattleTransition();
|
||||
if (sTransitionStructPtr->VBlank_DMA)
|
||||
DmaCopy16(3, gUnknown_02038C28[0], gUnknown_02038C28[1], 320);
|
||||
DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320);
|
||||
}
|
||||
|
||||
static void HBlankCB_Phase2_Swirl(void)
|
||||
{
|
||||
u16 var = gUnknown_02038C28[1][REG_VCOUNT];
|
||||
u16 var = gScanlineEffectRegBuffers[1][REG_VCOUNT];
|
||||
REG_BG1HOFS = var;
|
||||
REG_BG2HOFS = var;
|
||||
REG_BG3HOFS = var;
|
||||
@@ -1164,10 +1162,10 @@ static void Phase2Task_Shuffle(u8 taskId)
|
||||
static bool8 Phase2_Shuffle_Func1(struct Task *task)
|
||||
{
|
||||
sub_8149F08();
|
||||
dp12_8087EA4();
|
||||
ScanlineEffect_Clear();
|
||||
|
||||
BeginNormalPaletteFade(-1, 4, 0, 0x10, 0);
|
||||
memset(gUnknown_020393A8, sTransitionStructPtr->field_16, 0x140);
|
||||
memset(gScanlineEffectRegBuffers[1], sTransitionStructPtr->field_16, 0x140);
|
||||
|
||||
SetVBlankCallback(VBlankCB_Phase2_Shuffle);
|
||||
SetHBlankCallback(HBlankCB_Phase2_Shuffle);
|
||||
@@ -1192,7 +1190,7 @@ static bool8 Phase2_Shuffle_Func2(struct Task *task)
|
||||
for (i = 0; i < 160; i++, r4 += 4224)
|
||||
{
|
||||
u16 var = r4 / 256;
|
||||
gUnknown_02038C28[0][i] = sTransitionStructPtr->field_16 + Sin(var, r3);
|
||||
gScanlineEffectRegBuffers[0][i] = sTransitionStructPtr->field_16 + Sin(var, r3);
|
||||
}
|
||||
|
||||
if (!gPaletteFade.active)
|
||||
@@ -1206,12 +1204,12 @@ static void VBlankCB_Phase2_Shuffle(void)
|
||||
{
|
||||
VBlankCB_BattleTransition();
|
||||
if (sTransitionStructPtr->VBlank_DMA)
|
||||
DmaCopy16(3, gUnknown_02038C28[0], gUnknown_02038C28[1], 320);
|
||||
DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320);
|
||||
}
|
||||
|
||||
static void HBlankCB_Phase2_Shuffle(void)
|
||||
{
|
||||
u16 var = gUnknown_02038C28[1][REG_VCOUNT];
|
||||
u16 var = gScanlineEffectRegBuffers[1][REG_VCOUNT];
|
||||
REG_BG1VOFS = var;
|
||||
REG_BG2VOFS = var;
|
||||
REG_BG3VOFS = var;
|
||||
@@ -1257,7 +1255,7 @@ static void sub_814669C(struct Task *task)
|
||||
s32 i;
|
||||
|
||||
sub_8149F08();
|
||||
dp12_8087EA4();
|
||||
ScanlineEffect_Clear();
|
||||
|
||||
task->tData1 = 16;
|
||||
task->tData2 = 0;
|
||||
@@ -1272,7 +1270,7 @@ static void sub_814669C(struct Task *task)
|
||||
|
||||
for (i = 0; i < 160; i++)
|
||||
{
|
||||
gUnknown_02038C28[1][i] = 240;
|
||||
gScanlineEffectRegBuffers[1][i] = 240;
|
||||
}
|
||||
|
||||
SetVBlankCallback(VBlankCB0_Phase2_BigPokeball);
|
||||
@@ -1351,7 +1349,7 @@ static bool8 Phase2_BigPokeball_Func2(struct Task *task)
|
||||
dst1[i * 32 + j] = *BigPokeballMap | 0xF000;
|
||||
}
|
||||
}
|
||||
sub_8149F98(gUnknown_02038C28[0], 0, task->tData4, 132, task->tData5, 160);
|
||||
sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 132, task->tData5, 160);
|
||||
|
||||
task->tState++;
|
||||
return TRUE;
|
||||
@@ -1363,7 +1361,7 @@ static bool8 Phase2_Aqua_Func2(struct Task *task)
|
||||
|
||||
sub_8149F58(&dst1, &dst2);
|
||||
LZ77UnCompVram(sTeamAqua_Tilemap, dst1);
|
||||
sub_8149F98(gUnknown_02038C28[0], 0, task->tData4, 132, task->tData5, 160);
|
||||
sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 132, task->tData5, 160);
|
||||
|
||||
task->tState++;
|
||||
return FALSE;
|
||||
@@ -1375,7 +1373,7 @@ static bool8 Phase2_Magma_Func2(struct Task *task)
|
||||
|
||||
sub_8149F58(&dst1, &dst2);
|
||||
LZ77UnCompVram(sTeamMagma_Tilemap, dst1);
|
||||
sub_8149F98(gUnknown_02038C28[0], 0, task->tData4, 132, task->tData5, 160);
|
||||
sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 132, task->tData5, 160);
|
||||
|
||||
task->tState++;
|
||||
return FALSE;
|
||||
@@ -1388,7 +1386,7 @@ static bool8 Phase2_Regice_Func2(struct Task *task)
|
||||
sub_8149F58(&dst1, &dst2);
|
||||
LoadPalette(gUnknown_085BC2B4, 0xF0, 0x20);
|
||||
CpuCopy16(gUnknown_085BC314, dst1, 0x500);
|
||||
sub_8149F98(gUnknown_02038C28[0], 0, task->tData4, 132, task->tData5, 160);
|
||||
sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 132, task->tData5, 160);
|
||||
|
||||
task->tState++;
|
||||
return FALSE;
|
||||
@@ -1401,7 +1399,7 @@ static bool8 Phase2_Registeel_Func2(struct Task *task)
|
||||
sub_8149F58(&dst1, &dst2);
|
||||
LoadPalette(gUnknown_085BC2D4, 0xF0, 0x20);
|
||||
CpuCopy16(gUnknown_085BCB14, dst1, 0x500);
|
||||
sub_8149F98(gUnknown_02038C28[0], 0, task->tData4, 132, task->tData5, 160);
|
||||
sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 132, task->tData5, 160);
|
||||
|
||||
task->tState++;
|
||||
return FALSE;
|
||||
@@ -1414,7 +1412,7 @@ static bool8 Phase2_Regirock_Func2(struct Task *task)
|
||||
sub_8149F58(&dst1, &dst2);
|
||||
LoadPalette(gUnknown_085BC2F4, 0xF0, 0x20);
|
||||
CpuCopy16(gUnknown_085BD314, dst1, 0x500);
|
||||
sub_8149F98(gUnknown_02038C28[0], 0, task->tData4, 132, task->tData5, 160);
|
||||
sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 132, task->tData5, 160);
|
||||
|
||||
task->tState++;
|
||||
return FALSE;
|
||||
@@ -1499,7 +1497,7 @@ static bool8 Phase2_BigPokeball_Func3(struct Task *task)
|
||||
task->tData4 += 8;
|
||||
task->tData5 -= 256;
|
||||
|
||||
sub_8149F98(gUnknown_02038C28[0], 0, task->tData4, 132, task->tData5 >> 8, 160);
|
||||
sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 132, task->tData5 >> 8, 160);
|
||||
|
||||
sTransitionStructPtr->VBlank_DMA++;
|
||||
return FALSE;
|
||||
@@ -1519,7 +1517,7 @@ static bool8 Phase2_BigPokeball_Func4(struct Task *task)
|
||||
task->tData4 += 8;
|
||||
task->tData5 -= 256;
|
||||
|
||||
sub_8149F98(gUnknown_02038C28[0], 0, task->tData4, 132, task->tData5 >> 8, 160);
|
||||
sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 132, task->tData5 >> 8, 160);
|
||||
|
||||
sTransitionStructPtr->VBlank_DMA++;
|
||||
return FALSE;
|
||||
@@ -1531,7 +1529,7 @@ static bool8 Phase2_BigPokeball_Func5(struct Task *task)
|
||||
task->tData4 += 8;
|
||||
task->tData5 -= 256;
|
||||
|
||||
sub_8149F98(gUnknown_02038C28[0], 0, task->tData4, 132, task->tData5 >> 8, 160);
|
||||
sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 132, task->tData5 >> 8, 160);
|
||||
|
||||
if (task->tData5 <= 0)
|
||||
{
|
||||
@@ -1577,7 +1575,7 @@ static bool8 Phase2_BigPokeball_Func6(struct Task *task)
|
||||
if (task->tData1 < 0)
|
||||
task->tData1 = 0;
|
||||
}
|
||||
sub_814A014(gUnknown_02038C28[0], 120, 80, task->tData1);
|
||||
sub_814A014(gScanlineEffectRegBuffers[0], 120, 80, task->tData1);
|
||||
if (task->tData1 == 0)
|
||||
{
|
||||
SetVBlankCallback(NULL);
|
||||
@@ -1604,7 +1602,7 @@ static void Transition_BigPokeball_Vblank(void)
|
||||
DmaStop(0);
|
||||
VBlankCB_BattleTransition();
|
||||
if (sTransitionStructPtr->VBlank_DMA)
|
||||
DmaCopy16(3, gUnknown_02038C28[0], gUnknown_02038C28[1], 320);
|
||||
DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320);
|
||||
REG_WININ = sTransitionStructPtr->WININ;
|
||||
REG_WINOUT = sTransitionStructPtr->WINOUT;
|
||||
REG_WIN0V = sTransitionStructPtr->WIN0V;
|
||||
@@ -1615,13 +1613,13 @@ static void Transition_BigPokeball_Vblank(void)
|
||||
static void VBlankCB0_Phase2_BigPokeball(void)
|
||||
{
|
||||
Transition_BigPokeball_Vblank();
|
||||
DmaSet(0, gUnknown_020393A8, ®_BG0HOFS, 0xA2400001);
|
||||
DmaSet(0, gScanlineEffectRegBuffers[1], ®_BG0HOFS, 0xA2400001);
|
||||
}
|
||||
|
||||
static void VBlankCB1_Phase2_BigPokeball(void)
|
||||
{
|
||||
Transition_BigPokeball_Vblank();
|
||||
DmaSet(0, gUnknown_020393A8, ®_WIN0H, 0xA2400001);
|
||||
DmaSet(0, gScanlineEffectRegBuffers[1], ®_WIN0H, 0xA2400001);
|
||||
}
|
||||
|
||||
static void Phase2Task_PokeballsTrail(u8 taskId)
|
||||
@@ -1741,7 +1739,7 @@ static bool8 Phase2_Clockwise_BlackFade_Func1(struct Task *task)
|
||||
u16 i;
|
||||
|
||||
sub_8149F08();
|
||||
dp12_8087EA4();
|
||||
ScanlineEffect_Clear();
|
||||
|
||||
sTransitionStructPtr->WININ = 0;
|
||||
sTransitionStructPtr->WINOUT = 63;
|
||||
@@ -1750,7 +1748,7 @@ static bool8 Phase2_Clockwise_BlackFade_Func1(struct Task *task)
|
||||
|
||||
for (i = 0; i < 160; i++)
|
||||
{
|
||||
gUnknown_020393A8[i] = 0xF3F4;
|
||||
gScanlineEffectRegBuffers[1][i] = 0xF3F4;
|
||||
}
|
||||
|
||||
SetVBlankCallback(VBlankCB_Phase2_Clockwise_BlackFade);
|
||||
@@ -1767,7 +1765,7 @@ static bool8 Phase2_Clockwise_BlackFade_Func2(struct Task *task)
|
||||
sub_814A1AC(sTransitionStructPtr->data, 120, 80, sTransitionStructPtr->data[4], -1, 1, 1);
|
||||
do
|
||||
{
|
||||
gUnknown_02038C28[0][sTransitionStructPtr->data[3]] = (sTransitionStructPtr->data[2] + 1) | 0x7800;
|
||||
gScanlineEffectRegBuffers[0][sTransitionStructPtr->data[3]] = (sTransitionStructPtr->data[2] + 1) | 0x7800;
|
||||
} while (!sub_814A228(sTransitionStructPtr->data, 1, 1));
|
||||
|
||||
sTransitionStructPtr->data[4] += 16;
|
||||
@@ -1795,7 +1793,7 @@ static bool8 Phase2_Clockwise_BlackFade_Func3(struct Task *task)
|
||||
r1 = 120, r3 = sTransitionStructPtr->data[2] + 1;
|
||||
if (sTransitionStructPtr->data[5] >= 80)
|
||||
r1 = sTransitionStructPtr->data[2], r3 = 240;
|
||||
gUnknown_02038C28[0][sTransitionStructPtr->data[3]] = (r3) | (r1 << 8);
|
||||
gScanlineEffectRegBuffers[0][sTransitionStructPtr->data[3]] = (r3) | (r1 << 8);
|
||||
if (var != 0)
|
||||
break;
|
||||
var = sub_814A228(sTransitionStructPtr->data, 1, 1);
|
||||
@@ -1811,7 +1809,7 @@ static bool8 Phase2_Clockwise_BlackFade_Func3(struct Task *task)
|
||||
{
|
||||
while (sTransitionStructPtr->data[3] < sTransitionStructPtr->data[5])
|
||||
{
|
||||
gUnknown_02038C28[0][++sTransitionStructPtr->data[3]] = (r3) | (r1 << 8);
|
||||
gScanlineEffectRegBuffers[0][++sTransitionStructPtr->data[3]] = (r3) | (r1 << 8);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1826,7 +1824,7 @@ static bool8 Phase2_Clockwise_BlackFade_Func4(struct Task *task)
|
||||
sub_814A1AC(sTransitionStructPtr->data, 120, 80, sTransitionStructPtr->data[4], 160, 1, 1);
|
||||
do
|
||||
{
|
||||
gUnknown_02038C28[0][sTransitionStructPtr->data[3]] = (sTransitionStructPtr->data[2] << 8) | 0xF0;
|
||||
gScanlineEffectRegBuffers[0][sTransitionStructPtr->data[3]] = (sTransitionStructPtr->data[2] << 8) | 0xF0;
|
||||
} while (!sub_814A228(sTransitionStructPtr->data, 1, 1));
|
||||
|
||||
sTransitionStructPtr->data[4] -= 16;
|
||||
@@ -1851,12 +1849,12 @@ static bool8 Phase2_Clockwise_BlackFade_Func5(struct Task *task)
|
||||
|
||||
while (1)
|
||||
{
|
||||
r1 = (gUnknown_02038C28[0][sTransitionStructPtr->data[3]]) & 0xFF;
|
||||
r1 = (gScanlineEffectRegBuffers[0][sTransitionStructPtr->data[3]]) & 0xFF;
|
||||
r2 = sTransitionStructPtr->data[2];
|
||||
if (sTransitionStructPtr->data[5] <= 80)
|
||||
r2 = 120, r1 = sTransitionStructPtr->data[2];
|
||||
var4 = (r1) | (r2 << 8);
|
||||
gUnknown_02038C28[0][sTransitionStructPtr->data[3]] = var4;
|
||||
gScanlineEffectRegBuffers[0][sTransitionStructPtr->data[3]] = var4;
|
||||
if (var != 0)
|
||||
break;
|
||||
var = sub_814A228(sTransitionStructPtr->data, 1, 1);
|
||||
@@ -1872,7 +1870,7 @@ static bool8 Phase2_Clockwise_BlackFade_Func5(struct Task *task)
|
||||
{
|
||||
while (sTransitionStructPtr->data[3] > sTransitionStructPtr->data[5])
|
||||
{
|
||||
gUnknown_02038C28[0][--sTransitionStructPtr->data[3]] = (r1) | (r2 << 8);
|
||||
gScanlineEffectRegBuffers[0][--sTransitionStructPtr->data[3]] = (r1) | (r2 << 8);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1892,7 +1890,7 @@ static bool8 Phase2_Clockwise_BlackFade_Func6(struct Task *task)
|
||||
r2 = 120, r3 = sTransitionStructPtr->data[2];
|
||||
if (sTransitionStructPtr->data[2] >= 120)
|
||||
r2 = 0, r3 = 240;
|
||||
gUnknown_02038C28[0][sTransitionStructPtr->data[3]] = (r3) | (r2 << 8);
|
||||
gScanlineEffectRegBuffers[0][sTransitionStructPtr->data[3]] = (r3) | (r2 << 8);
|
||||
|
||||
} while (!sub_814A228(sTransitionStructPtr->data, 1, 1));
|
||||
|
||||
@@ -1917,12 +1915,12 @@ static void VBlankCB_Phase2_Clockwise_BlackFade(void)
|
||||
DmaStop(0);
|
||||
VBlankCB_BattleTransition();
|
||||
if (sTransitionStructPtr->VBlank_DMA != 0)
|
||||
DmaCopy16(3, gUnknown_02038C28[0], gUnknown_02038C28[1], 320);
|
||||
DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320);
|
||||
REG_WININ = sTransitionStructPtr->WININ;
|
||||
REG_WINOUT = sTransitionStructPtr->WINOUT;
|
||||
REG_WIN0V = sTransitionStructPtr->WIN0V;
|
||||
REG_WIN0H = gUnknown_02038C28[1][0];
|
||||
DmaSet(0, gUnknown_02038C28[1], ®_WIN0H, 0xA2400001);
|
||||
REG_WIN0H = gScanlineEffectRegBuffers[1][0];
|
||||
DmaSet(0, gScanlineEffectRegBuffers[1], ®_WIN0H, 0xA2400001);
|
||||
}
|
||||
|
||||
static void Phase2Task_Ripple(u8 taskId)
|
||||
@@ -1935,11 +1933,11 @@ static bool8 Phase2_Ripple_Func1(struct Task *task)
|
||||
u8 i;
|
||||
|
||||
sub_8149F08();
|
||||
dp12_8087EA4();
|
||||
ScanlineEffect_Clear();
|
||||
|
||||
for (i = 0; i < 160; i++)
|
||||
{
|
||||
gUnknown_020393A8[i] = sTransitionStructPtr->field_16;
|
||||
gScanlineEffectRegBuffers[1][i] = sTransitionStructPtr->field_16;
|
||||
}
|
||||
|
||||
SetVBlankCallback(VBlankCB_Phase2_Ripple);
|
||||
@@ -1971,7 +1969,7 @@ static bool8 Phase2_Ripple_Func2(struct Task *task)
|
||||
// todo: fix the asm
|
||||
s16 var = r4 >> 8;
|
||||
asm("");
|
||||
gUnknown_02038C28[0][i] = sTransitionStructPtr->field_16 + Sin(var, r3);
|
||||
gScanlineEffectRegBuffers[0][i] = sTransitionStructPtr->field_16 + Sin(var, r3);
|
||||
}
|
||||
|
||||
if (++task->tData3 == 81)
|
||||
@@ -1991,12 +1989,12 @@ static void VBlankCB_Phase2_Ripple(void)
|
||||
{
|
||||
VBlankCB_BattleTransition();
|
||||
if (sTransitionStructPtr->VBlank_DMA)
|
||||
DmaCopy16(3, gUnknown_02038C28[0], gUnknown_02038C28[1], 320);
|
||||
DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320);
|
||||
}
|
||||
|
||||
static void HBlankCB_Phase2_Ripple(void)
|
||||
{
|
||||
u16 var = gUnknown_02038C28[1][REG_VCOUNT];
|
||||
u16 var = gScanlineEffectRegBuffers[1][REG_VCOUNT];
|
||||
REG_BG1VOFS = var;
|
||||
REG_BG2VOFS = var;
|
||||
REG_BG3VOFS = var;
|
||||
@@ -2012,7 +2010,7 @@ static bool8 Phase2_Wave_Func1(struct Task *task)
|
||||
u8 i;
|
||||
|
||||
sub_8149F08();
|
||||
dp12_8087EA4();
|
||||
ScanlineEffect_Clear();
|
||||
|
||||
sTransitionStructPtr->WININ = 63;
|
||||
sTransitionStructPtr->WINOUT = 0;
|
||||
@@ -2021,7 +2019,7 @@ static bool8 Phase2_Wave_Func1(struct Task *task)
|
||||
|
||||
for (i = 0; i < 160; i++)
|
||||
{
|
||||
gUnknown_02038C28[1][i] = 242;
|
||||
gScanlineEffectRegBuffers[1][i] = 242;
|
||||
}
|
||||
|
||||
SetVBlankCallback(VBlankCB_Phase2_Wave);
|
||||
@@ -2037,7 +2035,7 @@ static bool8 Phase2_Wave_Func2(struct Task *task)
|
||||
bool8 nextFunc;
|
||||
|
||||
sTransitionStructPtr->VBlank_DMA = FALSE;
|
||||
toStore = gUnknown_02038C28[0];
|
||||
toStore = gScanlineEffectRegBuffers[0];
|
||||
r5 = task->tData2;
|
||||
task->tData2 += 16;
|
||||
task->tData1 += 8;
|
||||
@@ -2073,11 +2071,11 @@ static void VBlankCB_Phase2_Wave(void)
|
||||
DmaStop(0);
|
||||
VBlankCB_BattleTransition();
|
||||
if (sTransitionStructPtr->VBlank_DMA != 0)
|
||||
DmaCopy16(3, gUnknown_02038C28[0], gUnknown_02038C28[1], 320);
|
||||
DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320);
|
||||
REG_WININ = sTransitionStructPtr->WININ;
|
||||
REG_WINOUT = sTransitionStructPtr->WINOUT;
|
||||
REG_WIN0V = sTransitionStructPtr->WIN0V;
|
||||
DmaSet(0, gUnknown_02038C28[1], ®_WIN0H, 0xA2400001);
|
||||
DmaSet(0, gScanlineEffectRegBuffers[1], ®_WIN0H, 0xA2400001);
|
||||
}
|
||||
|
||||
static void Phase2Task_Sydney(u8 taskId)
|
||||
@@ -2120,7 +2118,7 @@ static bool8 Phase2_Mugshot_Func1(struct Task *task)
|
||||
u8 i;
|
||||
|
||||
sub_8149F08();
|
||||
dp12_8087EA4();
|
||||
ScanlineEffect_Clear();
|
||||
Mugshots_CreateOpponentPlayerSprites(task);
|
||||
|
||||
task->tData1 = 0;
|
||||
@@ -2132,7 +2130,7 @@ static bool8 Phase2_Mugshot_Func1(struct Task *task)
|
||||
|
||||
for (i = 0; i < 160; i++)
|
||||
{
|
||||
gUnknown_02038C28[1][i] = 0xF0F1;
|
||||
gScanlineEffectRegBuffers[1][i] = 0xF0F1;
|
||||
}
|
||||
|
||||
SetVBlankCallback(VBlankCB0_Phase2_Mugshots);
|
||||
@@ -2177,7 +2175,7 @@ static bool8 Phase2_Mugshot_Func3(struct Task *task)
|
||||
|
||||
sTransitionStructPtr->VBlank_DMA = FALSE;
|
||||
|
||||
toStore = gUnknown_02038C28[0];
|
||||
toStore = gScanlineEffectRegBuffers[0];
|
||||
r5 = task->tData1;
|
||||
task->tData1 += 0x10;
|
||||
|
||||
@@ -2223,7 +2221,7 @@ static bool8 Phase2_Mugshot_Func4(struct Task *task)
|
||||
|
||||
sTransitionStructPtr->VBlank_DMA = FALSE;
|
||||
|
||||
for (i = 0, toStore = gUnknown_02038C28[0]; i < 160; i++, toStore++)
|
||||
for (i = 0, toStore = gScanlineEffectRegBuffers[0]; i < 160; i++, toStore++)
|
||||
{
|
||||
*toStore = 0xF0;
|
||||
}
|
||||
@@ -2266,8 +2264,8 @@ static bool8 Phase2_Mugshot_Func6(struct Task *task)
|
||||
sTransitionStructPtr->VBlank_DMA = FALSE;
|
||||
SetVBlankCallback(NULL);
|
||||
DmaStop(0);
|
||||
memset(gUnknown_02038C28[0], 0, 0x140);
|
||||
memset(gUnknown_02038C28[1], 0, 0x140);
|
||||
memset(gScanlineEffectRegBuffers[0], 0, 0x140);
|
||||
memset(gScanlineEffectRegBuffers[1], 0, 0x140);
|
||||
SetGpuReg(REG_OFFSET_WIN0H, 0xF0);
|
||||
SetGpuReg(REG_OFFSET_BLDY, 0);
|
||||
task->tState++;
|
||||
@@ -2300,15 +2298,15 @@ static bool8 Phase2_Mugshot_Func7(struct Task *task)
|
||||
{
|
||||
s16 index1 = 0x50 - i;
|
||||
s16 index2 = 0x50 + i;
|
||||
if (gUnknown_02038C28[0][index1] <= 15)
|
||||
if (gScanlineEffectRegBuffers[0][index1] <= 15)
|
||||
{
|
||||
r6 = TRUE;
|
||||
gUnknown_02038C28[0][index1]++;
|
||||
gScanlineEffectRegBuffers[0][index1]++;
|
||||
}
|
||||
if (gUnknown_02038C28[0][index2] <= 15)
|
||||
if (gScanlineEffectRegBuffers[0][index2] <= 15)
|
||||
{
|
||||
r6 = TRUE;
|
||||
gUnknown_02038C28[0][index2]++;
|
||||
gScanlineEffectRegBuffers[0][index2]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2336,7 +2334,7 @@ static bool8 Phase2_Mugshot_Func9(struct Task *task)
|
||||
sTransitionStructPtr->VBlank_DMA = FALSE;
|
||||
|
||||
task->tData3++;
|
||||
memset(gUnknown_02038C28[0], task->tData3, 0x140);
|
||||
memset(gScanlineEffectRegBuffers[0], task->tData3, 0x140);
|
||||
if (task->tData3 > 15)
|
||||
task->tState++;
|
||||
|
||||
@@ -2357,12 +2355,12 @@ static void VBlankCB0_Phase2_Mugshots(void)
|
||||
DmaStop(0);
|
||||
VBlankCB_BattleTransition();
|
||||
if (sTransitionStructPtr->VBlank_DMA != 0)
|
||||
DmaCopy16(3, gUnknown_02038C28[0], gUnknown_02038C28[1], 320);
|
||||
DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320);
|
||||
REG_BG0VOFS = sTransitionStructPtr->BG0VOFS;
|
||||
REG_WININ = sTransitionStructPtr->WININ;
|
||||
REG_WINOUT = sTransitionStructPtr->WINOUT;
|
||||
REG_WIN0V = sTransitionStructPtr->WIN0V;
|
||||
DmaSet(0, gUnknown_02038C28[1], ®_WIN0H, 0xA2400001);
|
||||
DmaSet(0, gScanlineEffectRegBuffers[1], ®_WIN0H, 0xA2400001);
|
||||
}
|
||||
|
||||
static void VBlankCB1_Phase2_Mugshots(void)
|
||||
@@ -2370,9 +2368,9 @@ static void VBlankCB1_Phase2_Mugshots(void)
|
||||
DmaStop(0);
|
||||
VBlankCB_BattleTransition();
|
||||
if (sTransitionStructPtr->VBlank_DMA != 0)
|
||||
DmaCopy16(3, gUnknown_02038C28[0], gUnknown_02038C28[1], 320);
|
||||
DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320);
|
||||
REG_BLDCNT = sTransitionStructPtr->BLDCNT;
|
||||
DmaSet(0, gUnknown_02038C28[1], ®_BLDY, 0xA2400001);
|
||||
DmaSet(0, gScanlineEffectRegBuffers[1], ®_BLDY, 0xA2400001);
|
||||
}
|
||||
|
||||
static void HBlankCB_Phase2_Mugshots(void)
|
||||
@@ -2500,7 +2498,7 @@ static bool8 Phase2_Slice_Func1(struct Task *task)
|
||||
u16 i;
|
||||
|
||||
sub_8149F08();
|
||||
dp12_8087EA4();
|
||||
ScanlineEffect_Clear();
|
||||
|
||||
task->tData2 = 256;
|
||||
task->tData3 = 1;
|
||||
@@ -2511,8 +2509,8 @@ static bool8 Phase2_Slice_Func1(struct Task *task)
|
||||
|
||||
for (i = 0; i < 160; i++)
|
||||
{
|
||||
gUnknown_02038C28[1][i] = sTransitionStructPtr->field_14;
|
||||
gUnknown_02038C28[1][160 + i] = 0xF0;
|
||||
gScanlineEffectRegBuffers[1][i] = sTransitionStructPtr->field_14;
|
||||
gScanlineEffectRegBuffers[1][160 + i] = 0xF0;
|
||||
}
|
||||
|
||||
EnableInterrupts(INTR_FLAG_HBLANK);
|
||||
@@ -2541,8 +2539,8 @@ static bool8 Phase2_Slice_Func2(struct Task *task)
|
||||
|
||||
for (i = 0; i < 160; i++)
|
||||
{
|
||||
u16 *storeLoc1 = &gUnknown_02038C28[0][i];
|
||||
u16 *storeLoc2 = &gUnknown_02038C28[0][i + 160];
|
||||
u16 *storeLoc1 = &gScanlineEffectRegBuffers[0][i];
|
||||
u16 *storeLoc2 = &gScanlineEffectRegBuffers[0][i + 160];
|
||||
if (i & 1)
|
||||
{
|
||||
*storeLoc1 = sTransitionStructPtr->field_14 + task->tData1;
|
||||
@@ -2578,15 +2576,15 @@ static void VBlankCB_Phase2_Slice(void)
|
||||
REG_WINOUT = sTransitionStructPtr->WINOUT;
|
||||
REG_WIN0V = sTransitionStructPtr->WIN0V;
|
||||
if (sTransitionStructPtr->VBlank_DMA)
|
||||
DmaCopy16(3, gUnknown_02038C28[0], gUnknown_02038C28[1], 640);
|
||||
DmaSet(0, &gUnknown_02038C28[1][160], ®_WIN0H, 0xA2400001);
|
||||
DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 640);
|
||||
DmaSet(0, &gScanlineEffectRegBuffers[1][160], ®_WIN0H, 0xA2400001);
|
||||
}
|
||||
|
||||
static void HBlankCB_Phase2_Slice(void)
|
||||
{
|
||||
if (REG_VCOUNT < 160)
|
||||
{
|
||||
u16 var = gUnknown_02038C28[1][REG_VCOUNT];
|
||||
u16 var = gScanlineEffectRegBuffers[1][REG_VCOUNT];
|
||||
REG_BG1HOFS = var;
|
||||
REG_BG2HOFS = var;
|
||||
REG_BG3HOFS = var;
|
||||
@@ -2603,7 +2601,7 @@ static bool8 Phase2_ShredSplit_Func1(struct Task *task)
|
||||
u16 i;
|
||||
|
||||
sub_8149F08();
|
||||
dp12_8087EA4();
|
||||
ScanlineEffect_Clear();
|
||||
|
||||
sTransitionStructPtr->WININ = 63;
|
||||
sTransitionStructPtr->WINOUT = 0;
|
||||
@@ -2611,13 +2609,13 @@ static bool8 Phase2_ShredSplit_Func1(struct Task *task)
|
||||
|
||||
for (i = 0; i < 0xA0; i++)
|
||||
{
|
||||
gUnknown_02038C28[1][i] = sTransitionStructPtr->field_14;
|
||||
gUnknown_02038C28[1][0xA0 + i] = 0xF0;
|
||||
gUnknown_02038C28[0][i] = sTransitionStructPtr->field_14;
|
||||
gUnknown_02038C28[0][0xA0 + i] = 0xF0;
|
||||
gUnknown_02038C28[0][0x140 + i] = 0;
|
||||
gUnknown_02038C28[0][0x1E0 + i] = 0x100;
|
||||
gUnknown_02038C28[0][0x280 + i] = 1;
|
||||
gScanlineEffectRegBuffers[1][i] = sTransitionStructPtr->field_14;
|
||||
gScanlineEffectRegBuffers[1][0xA0 + i] = 0xF0;
|
||||
gScanlineEffectRegBuffers[0][i] = sTransitionStructPtr->field_14;
|
||||
gScanlineEffectRegBuffers[0][0xA0 + i] = 0xF0;
|
||||
gScanlineEffectRegBuffers[0][0x140 + i] = 0;
|
||||
gScanlineEffectRegBuffers[0][0x1E0 + i] = 0x100;
|
||||
gScanlineEffectRegBuffers[0][0x280 + i] = 1;
|
||||
}
|
||||
|
||||
task->tData4 = 0;
|
||||
@@ -2657,9 +2655,9 @@ static bool8 Phase2_ShredSplit_Func2(struct Task *task)
|
||||
unkVar = (arr1[j]) + (arr2[k] * -(i) * 2);
|
||||
if (unkVar >= 0 && (unkVar != 79 || j != 1))
|
||||
{
|
||||
ptr4 = &gUnknown_02038C28[0][unkVar + 320];
|
||||
ptr3 = &gUnknown_02038C28[0][unkVar + 480];
|
||||
ptr1 = &gUnknown_02038C28[0][unkVar + 640];
|
||||
ptr4 = &gScanlineEffectRegBuffers[0][unkVar + 320];
|
||||
ptr3 = &gScanlineEffectRegBuffers[0][unkVar + 480];
|
||||
ptr1 = &gScanlineEffectRegBuffers[0][unkVar + 640];
|
||||
if (*ptr4 > 0xEF)
|
||||
{
|
||||
*ptr4 = 0xF0;
|
||||
@@ -2673,8 +2671,8 @@ static bool8 Phase2_ShredSplit_Func2(struct Task *task)
|
||||
if (*ptr3 <= 0xFFF)
|
||||
*ptr3 += *ptr1;
|
||||
}
|
||||
ptr2 = &gUnknown_02038C28[0][unkVar];
|
||||
ptr3 = &gUnknown_02038C28[0][unkVar + 160];
|
||||
ptr2 = &gScanlineEffectRegBuffers[0][unkVar];
|
||||
ptr3 = &gScanlineEffectRegBuffers[0][unkVar + 160];
|
||||
*ptr2 = sTransitionStructPtr->field_14 + *ptr4;
|
||||
*ptr3 = 0xF0 - *ptr4;
|
||||
|
||||
@@ -2691,9 +2689,9 @@ static bool8 Phase2_ShredSplit_Func2(struct Task *task)
|
||||
unkVar = (arr1[j] + 1) + (arr2[k] * -(i) * 2);
|
||||
if (unkVar <= 160 && (unkVar != 80 || j != 1))
|
||||
{
|
||||
ptr4 = &gUnknown_02038C28[0][unkVar + 320];
|
||||
ptr3 = &gUnknown_02038C28[0][unkVar + 480];
|
||||
ptr1 = &gUnknown_02038C28[0][unkVar + 640];
|
||||
ptr4 = &gScanlineEffectRegBuffers[0][unkVar + 320];
|
||||
ptr3 = &gScanlineEffectRegBuffers[0][unkVar + 480];
|
||||
ptr1 = &gScanlineEffectRegBuffers[0][unkVar + 640];
|
||||
if (*ptr4 > 0xEF)
|
||||
{
|
||||
*ptr4 = 0xF0;
|
||||
@@ -2707,8 +2705,8 @@ static bool8 Phase2_ShredSplit_Func2(struct Task *task)
|
||||
if (*ptr3 <= 0xFFF)
|
||||
*ptr3 += *ptr1;
|
||||
}
|
||||
ptr2 = &gUnknown_02038C28[0][unkVar];
|
||||
ptr3 = &gUnknown_02038C28[0][unkVar + 160];
|
||||
ptr2 = &gScanlineEffectRegBuffers[0][unkVar];
|
||||
ptr3 = &gScanlineEffectRegBuffers[0][unkVar + 160];
|
||||
*ptr2 = sTransitionStructPtr->field_14 - *ptr4;
|
||||
*ptr3 = (*ptr4 << 8) | (0xF1);
|
||||
|
||||
@@ -2732,7 +2730,7 @@ static bool8 Phase2_ShredSplit_Func2(struct Task *task)
|
||||
|
||||
// This function never increments the state counter, because the loop condition
|
||||
// is always false, resulting in the game being stuck in an infinite loop.
|
||||
// It's possible this transition is only partially
|
||||
// It's possible this transition is only partially
|
||||
// done and the second part was left out.
|
||||
static bool8 Phase2_ShredSplit_Func3(struct Task *task)
|
||||
{
|
||||
@@ -2742,7 +2740,7 @@ static bool8 Phase2_ShredSplit_Func3(struct Task *task)
|
||||
|
||||
for (i = 0; i < 0xA0; i++)
|
||||
{
|
||||
if (gUnknown_02038C28[1][i] != 0xF0 && gUnknown_02038C28[1][i] != checkVar2)
|
||||
if (gScanlineEffectRegBuffers[1][i] != 0xF0 && gScanlineEffectRegBuffers[1][i] != checkVar2)
|
||||
done = FALSE; // a break statement should be put here
|
||||
}
|
||||
|
||||
@@ -2775,7 +2773,7 @@ static bool8 Phase2_Blackhole_Func1(struct Task *task)
|
||||
s32 i;
|
||||
|
||||
sub_8149F08();
|
||||
dp12_8087EA4();
|
||||
ScanlineEffect_Clear();
|
||||
|
||||
sTransitionStructPtr->WININ = 0;
|
||||
sTransitionStructPtr->WINOUT = 63;
|
||||
@@ -2784,7 +2782,7 @@ static bool8 Phase2_Blackhole_Func1(struct Task *task)
|
||||
|
||||
for (i = 0; i < 0xA0; i++)
|
||||
{
|
||||
gUnknown_02038C28[1][i] = 0;
|
||||
gScanlineEffectRegBuffers[1][i] = 0;
|
||||
}
|
||||
|
||||
SetVBlankCallback(VBlankCB1_Phase2_BigPokeball);
|
||||
@@ -2814,7 +2812,7 @@ static bool8 Phase2_Blackhole1_Func3(struct Task *task)
|
||||
task->tData1 += (task->tData2 >> 8);
|
||||
if (task->tData1 > 0xA0)
|
||||
task->tData1 = 0xA0;
|
||||
sub_814A014(gUnknown_02038C28[0], 0x78, 0x50, task->tData1);
|
||||
sub_814A014(gScanlineEffectRegBuffers[0], 0x78, 0x50, task->tData1);
|
||||
if (task->tData1 == 0xA0)
|
||||
{
|
||||
task->tFuncState = 1;
|
||||
@@ -2840,7 +2838,7 @@ static bool8 Phase2_Blackhole1_Func2(struct Task *task)
|
||||
}
|
||||
task->tData1 += gUnknown_085C8C80[task->tData6];
|
||||
task->tData6 = (task->tData6 + 1) % 2;
|
||||
sub_814A014(gUnknown_02038C28[0], 0x78, 0x50, task->tData1);
|
||||
sub_814A014(gScanlineEffectRegBuffers[0], 0x78, 0x50, task->tData1);
|
||||
if (task->tData1 < 9)
|
||||
{
|
||||
task->tState++;
|
||||
@@ -2866,7 +2864,7 @@ static bool8 Phase2_Blackhole2_Func2(struct Task *task)
|
||||
if (task->tData1 > 0xA0)
|
||||
task->tData1 = 0xA0;
|
||||
|
||||
sub_814A014(gUnknown_02038C28[0], 0x78, 0x50, task->tData1);
|
||||
sub_814A014(gScanlineEffectRegBuffers[0], 0x78, 0x50, task->tData1);
|
||||
if (task->tData1 == 0xA0)
|
||||
{
|
||||
DmaStop(0);
|
||||
@@ -3113,7 +3111,7 @@ static bool8 Phase2_Rayquaza_Func3(struct Task *task)
|
||||
u16 i;
|
||||
|
||||
sub_8149F08();
|
||||
dp12_8087EA4();
|
||||
ScanlineEffect_Clear();
|
||||
|
||||
SetGpuReg(REG_OFFSET_BG0CNT, 0x9A08);
|
||||
sub_8149F58(&dst1, &dst2);
|
||||
@@ -3126,8 +3124,8 @@ static bool8 Phase2_Rayquaza_Func3(struct Task *task)
|
||||
|
||||
for (i = 0; i < 160; i++)
|
||||
{
|
||||
gUnknown_02038C28[0][i] = 0;
|
||||
gUnknown_02038C28[1][i] = 0x100;
|
||||
gScanlineEffectRegBuffers[0][i] = 0;
|
||||
gScanlineEffectRegBuffers[1][i] = 0x100;
|
||||
}
|
||||
|
||||
SetVBlankCallback(VBlankCB_Phase2_Rayquaza);
|
||||
@@ -3212,7 +3210,7 @@ static bool8 Phase2_Rayquaza_Func9(struct Task *task)
|
||||
|
||||
for (i = 0; i < 160; i++)
|
||||
{
|
||||
gUnknown_02038C28[1][i] = 0;
|
||||
gScanlineEffectRegBuffers[1][i] = 0;
|
||||
}
|
||||
|
||||
SetVBlankCallback(VBlankCB1_Phase2_BigPokeball);
|
||||
@@ -3233,11 +3231,11 @@ static void VBlankCB_Phase2_Rayquaza(void)
|
||||
VBlankCB_BattleTransition();
|
||||
|
||||
if (sTransitionStructPtr->field_20 == 0)
|
||||
dmaSrc = gUnknown_02038C28[0];
|
||||
dmaSrc = gScanlineEffectRegBuffers[0];
|
||||
else if (sTransitionStructPtr->field_20 == 1)
|
||||
dmaSrc = gUnknown_02038C28[1];
|
||||
dmaSrc = gScanlineEffectRegBuffers[1];
|
||||
else
|
||||
dmaSrc = gUnknown_02038C28[0];
|
||||
dmaSrc = gScanlineEffectRegBuffers[0];
|
||||
|
||||
DmaSet(0, dmaSrc, ®_BG0VOFS, 0xA2400001);
|
||||
}
|
||||
@@ -3252,7 +3250,7 @@ static bool8 Phase2_WhiteFade_Func1(struct Task *task)
|
||||
u16 i;
|
||||
|
||||
sub_8149F08();
|
||||
dp12_8087EA4();
|
||||
ScanlineEffect_Clear();
|
||||
|
||||
sTransitionStructPtr->BLDCNT = 0xBF;
|
||||
sTransitionStructPtr->BLDY = 0;
|
||||
@@ -3262,8 +3260,8 @@ static bool8 Phase2_WhiteFade_Func1(struct Task *task)
|
||||
|
||||
for (i = 0; i < 160; i++)
|
||||
{
|
||||
gUnknown_02038C28[1][i] = 0;
|
||||
gUnknown_02038C28[1][i + 160] = 0xF0;
|
||||
gScanlineEffectRegBuffers[1][i] = 0;
|
||||
gScanlineEffectRegBuffers[1][i + 160] = 0xF0;
|
||||
}
|
||||
|
||||
EnableInterrupts(INTR_FLAG_HBLANK);
|
||||
@@ -3343,8 +3341,8 @@ static void VBlankCB0_Phase2_WhiteFade(void)
|
||||
REG_WINOUT = sTransitionStructPtr->WINOUT;
|
||||
REG_WIN0V = sTransitionStructPtr->WIN0V;
|
||||
if (sTransitionStructPtr->VBlank_DMA)
|
||||
DmaCopy16(3, gUnknown_02038C28[0], gUnknown_02038C28[1], 640);
|
||||
DmaSet(0, &gUnknown_02038C28[1][160], ®_WIN0H, 0xA2400001);
|
||||
DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 640);
|
||||
DmaSet(0, &gScanlineEffectRegBuffers[1][160], ®_WIN0H, 0xA2400001);
|
||||
}
|
||||
|
||||
static void VBlankCB1_Phase2_WhiteFade(void)
|
||||
@@ -3360,7 +3358,7 @@ static void VBlankCB1_Phase2_WhiteFade(void)
|
||||
|
||||
static void HBlankCB_Phase2_WhiteFade(void)
|
||||
{
|
||||
REG_BLDY = gUnknown_02038C28[1][REG_VCOUNT];
|
||||
REG_BLDY = gScanlineEffectRegBuffers[1][REG_VCOUNT];
|
||||
}
|
||||
|
||||
static void sub_8149864(struct Sprite *sprite)
|
||||
@@ -3374,8 +3372,8 @@ static void sub_8149864(struct Sprite *sprite)
|
||||
else
|
||||
{
|
||||
u16 i;
|
||||
u16* ptr1 = &gUnknown_02038C28[0][sprite->pos1.y];
|
||||
u16* ptr2 = &gUnknown_02038C28[0][sprite->pos1.y + 160];
|
||||
u16* ptr1 = &gScanlineEffectRegBuffers[0][sprite->pos1.y];
|
||||
u16* ptr2 = &gScanlineEffectRegBuffers[0][sprite->pos1.y + 160];
|
||||
for (i = 0; i < 20; i++)
|
||||
{
|
||||
ptr1[i] = sprite->data[0] >> 8;
|
||||
@@ -3465,7 +3463,7 @@ static bool8 Phase2_Shards_Func1(struct Task *task)
|
||||
u16 i;
|
||||
|
||||
sub_8149F08();
|
||||
dp12_8087EA4();
|
||||
ScanlineEffect_Clear();
|
||||
|
||||
sTransitionStructPtr->WININ = 0x3F;
|
||||
sTransitionStructPtr->WINOUT = 0;
|
||||
@@ -3473,10 +3471,10 @@ static bool8 Phase2_Shards_Func1(struct Task *task)
|
||||
|
||||
for (i = 0; i < 160; i++)
|
||||
{
|
||||
gUnknown_02038C28[0][i] = 0xF0;
|
||||
gScanlineEffectRegBuffers[0][i] = 0xF0;
|
||||
}
|
||||
|
||||
CpuSet(gUnknown_02038C28[0], gUnknown_02038C28[1], 0xA0);
|
||||
CpuSet(gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 0xA0);
|
||||
SetVBlankCallback(VBlankCB_Phase2_Shards);
|
||||
|
||||
task->tState++;
|
||||
@@ -3505,8 +3503,8 @@ static bool8 Phase2_Shards_Func3(struct Task *task)
|
||||
|
||||
for (i = 0, nextFunc = FALSE; i < 16; i++)
|
||||
{
|
||||
s16 r3 = gUnknown_02038C28[0][sTransitionStructPtr->data[3]] >> 8;
|
||||
s16 r4 = gUnknown_02038C28[0][sTransitionStructPtr->data[3]] & 0xFF;
|
||||
s16 r3 = gScanlineEffectRegBuffers[0][sTransitionStructPtr->data[3]] >> 8;
|
||||
s16 r4 = gScanlineEffectRegBuffers[0][sTransitionStructPtr->data[3]] & 0xFF;
|
||||
if (task->tData2 == 0)
|
||||
{
|
||||
if (r3 < sTransitionStructPtr->data[2])
|
||||
@@ -3521,7 +3519,7 @@ static bool8 Phase2_Shards_Func3(struct Task *task)
|
||||
if (r4 <= r3)
|
||||
r4 = r3;
|
||||
}
|
||||
gUnknown_02038C28[0][sTransitionStructPtr->data[3]] = (r4) | (r3 << 8);
|
||||
gScanlineEffectRegBuffers[0][sTransitionStructPtr->data[3]] = (r4) | (r3 << 8);
|
||||
if (nextFunc)
|
||||
{
|
||||
task->tState++;
|
||||
@@ -3568,12 +3566,12 @@ static void VBlankCB_Phase2_Shards(void)
|
||||
DmaStop(0);
|
||||
VBlankCB_BattleTransition();
|
||||
if (sTransitionStructPtr->VBlank_DMA)
|
||||
DmaCopy16(3, gUnknown_02038C28[0], gUnknown_02038C28[1], 320);
|
||||
DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320);
|
||||
REG_WININ = sTransitionStructPtr->WININ;
|
||||
REG_WINOUT = sTransitionStructPtr->WINOUT;
|
||||
REG_WIN0V = sTransitionStructPtr->WIN0V;
|
||||
REG_WIN0H = gUnknown_02038C28[1][0];
|
||||
DmaSet(0, gUnknown_02038C28[1], ®_WIN0H, 0xA2400001);
|
||||
REG_WIN0H = gScanlineEffectRegBuffers[1][0];
|
||||
DmaSet(0, gScanlineEffectRegBuffers[1], ®_WIN0H, 0xA2400001);
|
||||
}
|
||||
|
||||
// sub-task for phase2
|
||||
@@ -3875,7 +3873,7 @@ static bool8 Phase2_29_Func2(struct Task *task)
|
||||
|
||||
sub_8149F58(&dst1, &dst2);
|
||||
LZ77UnCompVram(gUnknown_085C828C, dst1);
|
||||
sub_8149F98(gUnknown_02038C28[0], 0, task->tData4, 0x84, task->tData5, 160);
|
||||
sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 0x84, task->tData5, 160);
|
||||
|
||||
task->tState++;
|
||||
return TRUE;
|
||||
@@ -3896,7 +3894,7 @@ static bool8 Phase2_30_Func1(struct Task *task)
|
||||
u16 *dst1, *dst2;
|
||||
|
||||
sub_8149F08();
|
||||
dp12_8087EA4();
|
||||
ScanlineEffect_Clear();
|
||||
ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON | DISPCNT_WIN1_ON);
|
||||
task->tData2 = 0x2000;
|
||||
task->tData1 = 0x7FFF;
|
||||
@@ -3934,7 +3932,7 @@ static bool8 Phase2_30_Func3(struct Task *task)
|
||||
|
||||
for (i = 0; i < 160; i++)
|
||||
{
|
||||
gUnknown_02038C28[1][i] = sTransitionStructPtr->field_16;
|
||||
gScanlineEffectRegBuffers[1][i] = sTransitionStructPtr->field_16;
|
||||
}
|
||||
|
||||
SetVBlankCallback(VBlankCB_Phase2_30);
|
||||
@@ -3980,7 +3978,7 @@ static bool8 Phase2_30_Func4(struct Task *task)
|
||||
{
|
||||
s16 index = var6 / 256;
|
||||
asm("");
|
||||
gUnknown_02038C28[0][i] = sTransitionStructPtr->field_16 + Sin(index, amplitude);
|
||||
gScanlineEffectRegBuffers[0][i] = sTransitionStructPtr->field_16 + Sin(index, amplitude);
|
||||
}
|
||||
|
||||
if (++task->tData3 == 101)
|
||||
@@ -4004,12 +4002,12 @@ static void VBlankCB_Phase2_30(void)
|
||||
REG_BLDALPHA = sTransitionStructPtr->BLDALPHA;
|
||||
|
||||
if (sTransitionStructPtr->VBlank_DMA)
|
||||
DmaCopy16(3, gUnknown_02038C28[0], gUnknown_02038C28[1], 320);
|
||||
DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320);
|
||||
}
|
||||
|
||||
static void HBlankCB_Phase2_30(void)
|
||||
{
|
||||
u16 var = gUnknown_02038C28[1][REG_VCOUNT];
|
||||
u16 var = gScanlineEffectRegBuffers[1][REG_VCOUNT];
|
||||
REG_BG0VOFS = var;
|
||||
}
|
||||
|
||||
|
||||
@@ -3602,7 +3602,7 @@ static void Blender_AddTextPrinter(u8 windowId, const u8 *string, u8 x, u8 y, s3
|
||||
FillWindowPixelBuffer(windowId, txtColor.fgColor | (txtColor.fgColor << 4));
|
||||
}
|
||||
|
||||
AddTextPrinterParametrized2(windowId, 1, x, y, letterSpacing, 1, &txtColor, speed, string);
|
||||
AddTextPrinterParameterized2(windowId, 1, x, y, letterSpacing, 1, &txtColor, speed, string);
|
||||
}
|
||||
|
||||
static bool32 Blender_PrintText(s16 *textState, const u8 *string, s32 textSpeed)
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "main.h"
|
||||
#include "sprite.h"
|
||||
#include "task.h"
|
||||
#include "unknown_task.h"
|
||||
#include "scanline_effect.h"
|
||||
#include "window.h"
|
||||
#include "text.h"
|
||||
#include "menu.h"
|
||||
|
||||
119
src/coord_event_weather.c
Normal file
119
src/coord_event_weather.c
Normal file
@@ -0,0 +1,119 @@
|
||||
#include "global.h"
|
||||
#include "constants/weather.h"
|
||||
#include "coord_event_weather.h"
|
||||
#include "field_weather.h"
|
||||
|
||||
struct CoordEventWeather
|
||||
{
|
||||
u8 coordEventWeather;
|
||||
void (*func)(void);
|
||||
};
|
||||
|
||||
static void CoordEventWeather_Clouds(void);
|
||||
static void CoordEventWeather_Sunny(void);
|
||||
static void CoordEventWeather_LightRain(void);
|
||||
static void CoordEventWeather_Snow(void);
|
||||
static void CoordEventWeather_Thunderstorm(void);
|
||||
static void CoordEventWeather_Fog(void);
|
||||
static void CoordEventWeather_DiagonalFog(void);
|
||||
static void CoordEventWeather_Ash(void);
|
||||
static void CoordEventWeather_Sandstorm(void);
|
||||
static void CoordEventWeather_Dark(void);
|
||||
static void CoordEventWeather_Drought(void);
|
||||
static void CoordEventWeather_Route119Cycle(void);
|
||||
static void CoordEventWeather_Route123Cycle(void);
|
||||
|
||||
static const struct CoordEventWeather sCoordEventWeatherFuncs[] =
|
||||
{
|
||||
{ COORD_EVENT_WEATHER_CLOUDS, CoordEventWeather_Clouds },
|
||||
{ COORD_EVENT_WEATHER_SUNNY, CoordEventWeather_Sunny },
|
||||
{ COORD_EVENT_WEATHER_RAIN_LIGHT, CoordEventWeather_LightRain },
|
||||
{ COORD_EVENT_WEATHER_SNOW, CoordEventWeather_Snow },
|
||||
{ COORD_EVENT_WEATHER_RAIN_MED, CoordEventWeather_Thunderstorm },
|
||||
{ COORD_EVENT_WEATHER_FOG_1, CoordEventWeather_Fog },
|
||||
{ COORD_EVENT_WEATHER_FOG_2, CoordEventWeather_DiagonalFog },
|
||||
{ COORD_EVENT_WEATHER_ASH, CoordEventWeather_Ash },
|
||||
{ COORD_EVENT_WEATHER_SANDSTORM, CoordEventWeather_Sandstorm },
|
||||
{ COORD_EVENT_WEATHER_SHADE, CoordEventWeather_Dark },
|
||||
{ COORD_EVENT_WEATHER_DROUGHT, CoordEventWeather_Drought },
|
||||
{ COORD_EVENT_WEATHER_ROUTE119_CYCLE, CoordEventWeather_Route119Cycle },
|
||||
{ COORD_EVENT_WEATHER_ROUTE123_CYCLE, CoordEventWeather_Route123Cycle },
|
||||
};
|
||||
|
||||
static void CoordEventWeather_Clouds(void)
|
||||
{
|
||||
SetWeather(WEATHER_CLOUDS);
|
||||
}
|
||||
|
||||
static void CoordEventWeather_Sunny(void)
|
||||
{
|
||||
SetWeather(WEATHER_SUNNY);
|
||||
}
|
||||
|
||||
static void CoordEventWeather_LightRain(void)
|
||||
{
|
||||
SetWeather(WEATHER_RAIN_LIGHT);
|
||||
}
|
||||
|
||||
static void CoordEventWeather_Snow(void)
|
||||
{
|
||||
SetWeather(WEATHER_SNOW);
|
||||
}
|
||||
|
||||
static void CoordEventWeather_Thunderstorm(void)
|
||||
{
|
||||
SetWeather(WEATHER_RAIN_MED);
|
||||
}
|
||||
|
||||
static void CoordEventWeather_Fog(void)
|
||||
{
|
||||
SetWeather(WEATHER_FOG_1);
|
||||
}
|
||||
|
||||
static void CoordEventWeather_DiagonalFog(void)
|
||||
{
|
||||
SetWeather(WEATHER_FOG_2);
|
||||
}
|
||||
|
||||
static void CoordEventWeather_Ash(void)
|
||||
{
|
||||
SetWeather(WEATHER_ASH);
|
||||
}
|
||||
|
||||
static void CoordEventWeather_Sandstorm(void)
|
||||
{
|
||||
SetWeather(WEATHER_SANDSTORM);
|
||||
}
|
||||
|
||||
static void CoordEventWeather_Dark(void)
|
||||
{
|
||||
SetWeather(WEATHER_SHADE);
|
||||
}
|
||||
|
||||
static void CoordEventWeather_Drought(void)
|
||||
{
|
||||
SetWeather(WEATHER_DROUGHT);
|
||||
}
|
||||
|
||||
static void CoordEventWeather_Route119Cycle(void)
|
||||
{
|
||||
SetWeather(WEATHER_ROUTE119_CYCLE);
|
||||
}
|
||||
|
||||
static void CoordEventWeather_Route123Cycle(void)
|
||||
{
|
||||
SetWeather(WEATHER_ROUTE123_CYCLE);
|
||||
}
|
||||
|
||||
void DoCoordEventWeather(u8 coordEventWeather)
|
||||
{
|
||||
u8 i;
|
||||
for (i = 0; i < ARRAY_COUNT(sCoordEventWeatherFuncs); i++)
|
||||
{
|
||||
if (sCoordEventWeatherFuncs[i].coordEventWeather == coordEventWeather)
|
||||
{
|
||||
sCoordEventWeatherFuncs[i].func();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -500,7 +500,7 @@ void sub_8126B80(u8 taskId)
|
||||
void sub_8126C08(void)
|
||||
{
|
||||
FillWindowPixelBuffer(0, 0x11);
|
||||
AddTextPrinterParametrized(0, 1, sSecretBasePCMenuItemDescriptions[sSecretBasePCMenuCursorPos], 0, 0, 2, 1, 3);
|
||||
AddTextPrinterParameterized(0, 1, sSecretBasePCMenuItemDescriptions[sSecretBasePCMenuCursorPos], 0, 0, 2, 1, 3);
|
||||
}
|
||||
|
||||
void SecretBasePC_Decorate(u8 taskId)
|
||||
@@ -529,7 +529,7 @@ void SecretBasePC_PutAway(u8 taskId)
|
||||
{
|
||||
sub_8126A58(0);
|
||||
sub_8197434(0, 0);
|
||||
fade_screen(1, 0);
|
||||
FadeScreen(1, 0);
|
||||
gTasks[taskId].data[2] = 0;
|
||||
gTasks[taskId].func = sub_8129ABC;
|
||||
}
|
||||
@@ -1247,7 +1247,7 @@ void sub_8127F68(u8 taskId)
|
||||
{
|
||||
if (sub_8127F38() == TRUE)
|
||||
{
|
||||
fade_screen(1, 0);
|
||||
FadeScreen(1, 0);
|
||||
gTasks[taskId].data[2] = 0;
|
||||
gTasks[taskId].func = sub_8128060;
|
||||
}
|
||||
@@ -1661,7 +1661,7 @@ void sub_8128BA0(u8 taskId)
|
||||
|
||||
void sub_8128BBC(u8 taskId)
|
||||
{
|
||||
fade_screen(1, 0);
|
||||
FadeScreen(1, 0);
|
||||
gTasks[taskId].data[2] = 0;
|
||||
gTasks[taskId].func = c1_overworld_prev_quest;
|
||||
}
|
||||
@@ -2635,7 +2635,7 @@ void sub_812A1A0(u8 taskId)
|
||||
|
||||
void sub_812A1C0(u8 taskId)
|
||||
{
|
||||
fade_screen(1, 0);
|
||||
FadeScreen(1, 0);
|
||||
gTasks[taskId].data[2] = 0;
|
||||
gTasks[taskId].func = sub_81298EC;
|
||||
}
|
||||
@@ -2654,7 +2654,7 @@ void sub_812A210(u8 taskId)
|
||||
|
||||
void sub_812A22C(u8 taskId)
|
||||
{
|
||||
fade_screen(1, 0);
|
||||
FadeScreen(1, 0);
|
||||
gTasks[taskId].data[2] = 0;
|
||||
gTasks[taskId].func = sub_812A25C;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "palette.h"
|
||||
#include "main.h"
|
||||
#include "gpu_regs.h"
|
||||
#include "unknown_task.h"
|
||||
#include "scanline_effect.h"
|
||||
#include "task.h"
|
||||
#include "malloc.h"
|
||||
#include "decompress.h"
|
||||
@@ -17,7 +17,7 @@ extern int decompress_and_copy_tile_data_to_vram(u8 bg_id, void *src, int size,
|
||||
extern bool8 free_temp_tile_data_buffers_if_possible(void);
|
||||
extern void sub_80861E8(void); // rom4
|
||||
extern bool16 sub_80C0944(void);
|
||||
extern void AddTextPrinterParametrized2(u8 windowId, u8 fontId, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, struct TextColor *color, s8 speed, u8 *str);
|
||||
extern void AddTextPrinterParameterized2(u8 windowId, u8 fontId, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, struct TextColor *color, s8 speed, u8 *str);
|
||||
|
||||
extern u16 gUnknown_0860F074[];
|
||||
|
||||
@@ -215,5 +215,5 @@ static void PrintDiplomaText(u8 *text, u8 var1, u8 var2)
|
||||
.shadowColor = 3,
|
||||
};
|
||||
|
||||
AddTextPrinterParametrized2(0, 1, var1, var2, 0, 0, &color, -1, text);
|
||||
AddTextPrinterParameterized2(0, 1, var1, var2, 0, 0, &color, -1, text);
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ extern const u8 gText_NickHatchPrompt[];
|
||||
extern u8 sav1_map_get_name(void);
|
||||
extern void TVShowConvertInternationalString(u8* str1, u8* str2, u8);
|
||||
extern void sub_806A068(u16, u8);
|
||||
extern void fade_screen(u8, u8);
|
||||
extern void FadeScreen(u8, u8);
|
||||
extern void overworld_free_bg_tilemaps(void);
|
||||
extern void sub_80AF168(void);
|
||||
extern void ScanlineEffect_Stop(void);
|
||||
@@ -459,7 +459,7 @@ void EggHatch(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
CreateTask(Task_EggHatch, 10);
|
||||
fade_screen(1, 0);
|
||||
FadeScreen(1, 0);
|
||||
}
|
||||
|
||||
static void Task_EggHatch(u8 taskID)
|
||||
@@ -860,7 +860,7 @@ static void EggHatchPrintMessage(u8 windowId, u8* string, u8 x, u8 y, u8 speed)
|
||||
sEggHatchData->textColor.fgColor = 0;
|
||||
sEggHatchData->textColor.bgColor = 5;
|
||||
sEggHatchData->textColor.shadowColor = 6;
|
||||
AddTextPrinterParametrized2(windowId, 1, x, y, 0, 0, &sEggHatchData->textColor, speed, string);
|
||||
AddTextPrinterParameterized2(windowId, 1, x, y, 0, 0, &sEggHatchData->textColor, speed, string);
|
||||
}
|
||||
|
||||
u8 GetEggStepsToSubtract(void)
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "pokemon.h"
|
||||
#include "string_util.h"
|
||||
#include "battle.h"
|
||||
#include "unknown_task.h"
|
||||
#include "scanline_effect.h"
|
||||
#include "decompress.h"
|
||||
#include "m4a.h"
|
||||
#include "menu.h"
|
||||
@@ -1364,7 +1364,7 @@ static void VBlankCB_EvolutionScene(void)
|
||||
LoadOam();
|
||||
ProcessSpriteCopyRequests();
|
||||
TransferPlttBuffer();
|
||||
sub_80BA0A8();
|
||||
ScanlineEffect_InitHBlankDmaTransfer();
|
||||
}
|
||||
|
||||
static void VBlankCB_TradeEvolutionScene(void)
|
||||
@@ -1381,7 +1381,7 @@ static void VBlankCB_TradeEvolutionScene(void)
|
||||
LoadOam();
|
||||
ProcessSpriteCopyRequests();
|
||||
TransferPlttBuffer();
|
||||
sub_80BA0A8();
|
||||
ScanlineEffect_InitHBlankDmaTransfer();
|
||||
}
|
||||
|
||||
static void sub_813FDEC(u8 taskId)
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "rom_818CFC8.h"
|
||||
#include "rom_81BE66C.h"
|
||||
#include "field_ground_effect.h"
|
||||
#include "map_obj_8097404.h"
|
||||
#include "field_map_obj_helpers.h"
|
||||
#include "mauville_old_man.h"
|
||||
#include "metatile_behavior.h"
|
||||
#include "field_effect.h"
|
||||
|
||||
844
src/field_map_obj_helpers.c
Executable file
844
src/field_map_obj_helpers.c
Executable file
@@ -0,0 +1,844 @@
|
||||
#include "global.h"
|
||||
#include "field_ground_effect.h"
|
||||
#include "field_map_obj.h"
|
||||
#include "field_effect.h"
|
||||
#include "field_map_obj_helpers.h"
|
||||
#include "malloc.h"
|
||||
#include "task.h"
|
||||
#include "util.h"
|
||||
|
||||
typedef void (*SpriteStepFunc)(struct Sprite *sprite, u8 dir);
|
||||
|
||||
extern const struct Coords16 gUnknown_0850DB7C[4];
|
||||
extern s16 gUnknown_0850E768[];
|
||||
extern SpriteStepFunc *const gUnknown_0850E754[];
|
||||
extern const s8 gUnknown_0850E772[];
|
||||
extern const s8 gUnknown_0850E7BA[];
|
||||
extern const s8 *const gUnknown_0850E834[];
|
||||
extern s16 gUnknown_0850E840[];
|
||||
extern u8 gUnknown_0850E846[];
|
||||
extern s16 gUnknown_0850E84A[];
|
||||
extern u8 gUnknown_0850E850[];
|
||||
|
||||
void sub_8097D68(struct Sprite *sprite);
|
||||
void sub_8097FE4(u8);
|
||||
|
||||
bool8 FreezeMapObject(struct MapObject *mapObject)
|
||||
{
|
||||
if (mapObject->mapobj_bit_6 || mapObject->mapobj_bit_8)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
mapObject->mapobj_bit_8 = 1;
|
||||
mapObject->mapobj_bit_23 = gSprites[mapObject->spriteId].animPaused;
|
||||
mapObject->mapobj_bit_24 = gSprites[mapObject->spriteId].affineAnimPaused;
|
||||
gSprites[mapObject->spriteId].animPaused = 1;
|
||||
gSprites[mapObject->spriteId].affineAnimPaused = 1;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
void FreezeMapObjects(void)
|
||||
{
|
||||
u8 i;
|
||||
for (i = 0; i < MAP_OBJECTS_COUNT; i++)
|
||||
if (gMapObjects[i].active && i != gPlayerAvatar.mapObjectId)
|
||||
FreezeMapObject(&gMapObjects[i]);
|
||||
}
|
||||
|
||||
void FreezeMapObjectsExceptOne(u8 a1)
|
||||
{
|
||||
u8 i;
|
||||
for (i = 0; i < MAP_OBJECTS_COUNT; i++)
|
||||
if (i != a1 && gMapObjects[i].active && i != gPlayerAvatar.mapObjectId)
|
||||
FreezeMapObject(&gMapObjects[i]);
|
||||
}
|
||||
|
||||
void npc_sync_anim_pause_bits(struct MapObject *mapObject)
|
||||
{
|
||||
if (mapObject->active && mapObject->mapobj_bit_8)
|
||||
{
|
||||
mapObject->mapobj_bit_8 = 0;
|
||||
gSprites[mapObject->spriteId].animPaused = mapObject->mapobj_bit_23;
|
||||
gSprites[mapObject->spriteId].affineAnimPaused = mapObject->mapobj_bit_24;
|
||||
}
|
||||
}
|
||||
|
||||
void UnfreezeMapObjects(void)
|
||||
{
|
||||
u8 i;
|
||||
for (i = 0; i < MAP_OBJECTS_COUNT; i++)
|
||||
if (gMapObjects[i].active)
|
||||
npc_sync_anim_pause_bits(&gMapObjects[i]);
|
||||
}
|
||||
|
||||
void little_step(struct Sprite *sprite, u8 dir)
|
||||
{
|
||||
sprite->pos1.x += gUnknown_0850DB7C[dir].x;
|
||||
sprite->pos1.y += gUnknown_0850DB7C[dir].y;
|
||||
}
|
||||
|
||||
void double_little_steps(struct Sprite *sprite, u8 dir)
|
||||
{
|
||||
sprite->pos1.x += 2 * (u16) gUnknown_0850DB7C[dir].x;
|
||||
sprite->pos1.y += 2 * (u16) gUnknown_0850DB7C[dir].y;
|
||||
}
|
||||
|
||||
void triple_little_steps(struct Sprite *sprite, u8 dir)
|
||||
{
|
||||
sprite->pos1.x += 2 * (u16) gUnknown_0850DB7C[dir].x + (u16) gUnknown_0850DB7C[dir].x;
|
||||
sprite->pos1.y += 2 * (u16) gUnknown_0850DB7C[dir].y + (u16) gUnknown_0850DB7C[dir].y;
|
||||
}
|
||||
|
||||
void quad_little_steps(struct Sprite *sprite, u8 dir)
|
||||
{
|
||||
sprite->pos1.x += 4 * (u16) gUnknown_0850DB7C[dir].x;
|
||||
sprite->pos1.y += 4 * (u16) gUnknown_0850DB7C[dir].y;
|
||||
}
|
||||
|
||||
void oct_little_steps(struct Sprite *sprite, u8 dir)
|
||||
{
|
||||
sprite->pos1.x += 8 * (u16) gUnknown_0850DB7C[dir].x;
|
||||
sprite->pos1.y += 8 * (u16) gUnknown_0850DB7C[dir].y;
|
||||
}
|
||||
|
||||
void oamt_npc_ministep_reset(struct Sprite *sprite, u8 a2, u8 a3)
|
||||
{
|
||||
sprite->data[3] = a2;
|
||||
sprite->data[4] = a3;
|
||||
sprite->data[5] = 0;
|
||||
}
|
||||
|
||||
bool8 obj_npc_ministep(struct Sprite *sprite)
|
||||
{
|
||||
if (sprite->data[5] >= gUnknown_0850E768[sprite->data[4]])
|
||||
return FALSE;
|
||||
|
||||
gUnknown_0850E754[sprite->data[4]][sprite->data[5]](sprite, sprite->data[3]);
|
||||
|
||||
sprite->data[5]++;
|
||||
|
||||
if (sprite->data[5] < gUnknown_0850E768[sprite->data[4]])
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void sub_80976DC(struct Sprite *sprite, u8 a2)
|
||||
{
|
||||
sprite->data[3] = a2;
|
||||
sprite->data[4] = 0;
|
||||
sprite->data[5] = 0;
|
||||
}
|
||||
|
||||
bool8 sub_80976EC(struct Sprite *sprite)
|
||||
{
|
||||
if (!(sprite->data[4] & 1))
|
||||
{
|
||||
little_step(sprite, sprite->data[3]);
|
||||
sprite->data[5]++;
|
||||
}
|
||||
|
||||
sprite->data[4]++;
|
||||
|
||||
if (sprite->data[5] > 15)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// new helper added here in the middle. Perhaps Game Freak kept these organized in alphebetical order or some other heirarchy?
|
||||
|
||||
s16 sub_8097728(s16 a1)
|
||||
{
|
||||
return gUnknown_0850E7BA[a1];
|
||||
}
|
||||
|
||||
s16 sub_809773C(s16 a1)
|
||||
{
|
||||
return gUnknown_0850E772[a1];
|
||||
}
|
||||
|
||||
void sub_8097750(struct Sprite *sprite)
|
||||
{
|
||||
sprite->data[6] = 0;
|
||||
sprite->data[7] = 0;
|
||||
}
|
||||
|
||||
bool8 sub_8097758(struct Sprite *sprite)
|
||||
{
|
||||
bool8 result = FALSE;
|
||||
|
||||
switch(sprite->data[7])
|
||||
{
|
||||
case 0:
|
||||
sprite->pos2.x += sub_809773C(sprite->data[6]);
|
||||
sprite->pos2.y += sub_8097728(sprite->data[6]);
|
||||
break;
|
||||
case 1:
|
||||
sprite->pos2.x -= sub_809773C(0x47 - sprite->data[6]);
|
||||
sprite->pos2.y += sub_8097728(0x47 - sprite->data[6]);
|
||||
break;
|
||||
case 2:
|
||||
sprite->pos2.x -= sub_809773C(sprite->data[6]);
|
||||
sprite->pos2.y += sub_8097728(sprite->data[6]);
|
||||
break;
|
||||
case 3:
|
||||
sprite->pos2.x += sub_809773C(0x47 - sprite->data[6]);
|
||||
sprite->pos2.y += sub_8097728(0x47 - sprite->data[6]);
|
||||
break;
|
||||
}
|
||||
if(++sprite->data[6] == 0x48)
|
||||
{
|
||||
sprite->data[6] = 0;
|
||||
sprite->data[7]++;
|
||||
}
|
||||
if(sprite->data[7] == 0x4)
|
||||
{
|
||||
sprite->pos2.y = 0;
|
||||
sprite->pos2.x = 0;
|
||||
result = TRUE;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
s16 sub_8097820(s16 a1, u8 a2)
|
||||
{
|
||||
return gUnknown_0850E834[a2][a1];
|
||||
}
|
||||
|
||||
void sub_809783C(struct Sprite *sprite, u8 a2, u8 a3, u8 a4)
|
||||
{
|
||||
sprite->data[3] = a2;
|
||||
sprite->data[4] = a3;
|
||||
sprite->data[5] = a4;
|
||||
sprite->data[6] = 0;
|
||||
}
|
||||
|
||||
u8 sub_809785C(struct Sprite *sprite)
|
||||
{
|
||||
s16 v5[3];
|
||||
u8 v6[3];
|
||||
u8 v2;
|
||||
|
||||
memcpy(v5, gUnknown_0850E840, 6); // TODO: get rid of memcpy
|
||||
memcpy(v6, gUnknown_0850E846, 3);
|
||||
v2 = 0;
|
||||
|
||||
if (sprite->data[4])
|
||||
little_step(sprite, sprite->data[3]);
|
||||
|
||||
sprite->pos2.y = sub_8097820(sprite->data[6] >> v6[sprite->data[4]], sprite->data[5]);
|
||||
|
||||
sprite->data[6]++;
|
||||
|
||||
if (sprite->data[6] == (v5[sprite->data[4]] >> 1))
|
||||
v2 = 1;
|
||||
|
||||
if (sprite->data[6] >= v5[sprite->data[4]])
|
||||
{
|
||||
sprite->pos2.y = 0;
|
||||
v2 = -1;
|
||||
}
|
||||
|
||||
return v2;
|
||||
}
|
||||
|
||||
u8 sub_80978E4(struct Sprite *sprite)
|
||||
{
|
||||
s16 v5[3];
|
||||
u8 v6[3];
|
||||
u8 v2;
|
||||
|
||||
memcpy(v5, gUnknown_0850E84A, 6);
|
||||
memcpy(v6, gUnknown_0850E850, 3);
|
||||
v2 = 0;
|
||||
|
||||
if (sprite->data[4] && !(sprite->data[6] & 1))
|
||||
little_step(sprite, sprite->data[3]);
|
||||
|
||||
sprite->pos2.y = sub_8097820(sprite->data[6] >> v6[sprite->data[4]], sprite->data[5]);
|
||||
|
||||
sprite->data[6]++;
|
||||
|
||||
if (sprite->data[6] == (v5[sprite->data[4]] >> 1))
|
||||
v2 = 1;
|
||||
|
||||
if (sprite->data[6] >= v5[sprite->data[4]])
|
||||
{
|
||||
sprite->pos2.y = 0;
|
||||
v2 = -1;
|
||||
}
|
||||
|
||||
return v2;
|
||||
}
|
||||
|
||||
void SetFieldObjectStepTimer(struct Sprite *sprite, u16 timer)
|
||||
{
|
||||
sprite->data[3] = timer;
|
||||
}
|
||||
|
||||
|
||||
bool8 RunFieldObjectStepTimer(struct Sprite *sprite)
|
||||
{
|
||||
sprite->data[3]--;
|
||||
|
||||
if (sprite->data[3] == 0)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void obj_anim_image_set_and_seek(struct Sprite *sprite, u8 a2, u8 a3)
|
||||
{
|
||||
sprite->animNum = a2;
|
||||
sprite->animPaused = 0 ;
|
||||
SeekSpriteAnim(sprite, a3);
|
||||
}
|
||||
|
||||
bool8 sub_80979BC(struct Sprite *sprite)
|
||||
{
|
||||
if (sprite->animEnded)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void sub_80979D4(struct Sprite *sprite, bool8 invisible)
|
||||
{
|
||||
u16 x, y;
|
||||
s16 x2, y2;
|
||||
|
||||
sprite->invisible = invisible;
|
||||
|
||||
if (sprite->coordOffsetEnabled)
|
||||
{
|
||||
x = sprite->pos1.x + sprite->pos2.x + sprite->centerToCornerVecX + gSpriteCoordOffsetX;
|
||||
y = sprite->pos1.y + sprite->pos2.y + sprite->centerToCornerVecY + gSpriteCoordOffsetY;
|
||||
}
|
||||
else
|
||||
{
|
||||
x = sprite->pos1.x + sprite->pos2.x + sprite->centerToCornerVecX;
|
||||
y = sprite->pos1.y + sprite->pos2.y + sprite->centerToCornerVecY;
|
||||
}
|
||||
|
||||
x2 = x - (sprite->centerToCornerVecX >> 1);
|
||||
y2 = y - (sprite->centerToCornerVecY >> 1);
|
||||
|
||||
if ((s16)x > 255 || x2 < -16)
|
||||
sprite->invisible = 1;
|
||||
if ((s16)y > 175 || y2 < -16)
|
||||
sprite->invisible = 1;
|
||||
}
|
||||
|
||||
void sub_8097AC8(struct Sprite *sprite)
|
||||
{
|
||||
sub_8097D68(sprite);
|
||||
SetObjectSubpriorityByZCoord(sprite->data[1], sprite, 1);
|
||||
sub_80979D4(sprite, sprite->data[2]);
|
||||
}
|
||||
|
||||
void sub_8097AF0(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i = 0; i < MAX_SPRITES; i++)
|
||||
{
|
||||
struct Sprite *sprite = &gSprites[i];
|
||||
if(sprite->inUse && sprite->callback == sub_8097AC8)
|
||||
DestroySprite(sprite);
|
||||
}
|
||||
}
|
||||
|
||||
int sub_8097B2C(u8 var) // this should return a u8, because all that call this shifts to u8, but it wont match because it doesnt shift u8 at the end.
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i = 0; i < MAX_SPRITES; i++)
|
||||
{
|
||||
struct Sprite *sprite = &gSprites[i];
|
||||
if(sprite->inUse && sprite->callback == sub_8097AC8 && (u8)sprite->data[0] == var)
|
||||
return i;
|
||||
}
|
||||
return MAX_SPRITES;
|
||||
}
|
||||
|
||||
void sub_8097B78(u8 var1, u8 var2)
|
||||
{
|
||||
u8 spriteId = sub_8097B2C(var1);
|
||||
|
||||
if(spriteId != MAX_SPRITES)
|
||||
StartSpriteAnim(&gSprites[spriteId], FieldObjectDirectionToImageAnimId(var2));
|
||||
}
|
||||
|
||||
void sub_8097BB4(u8 var1, u8 var2)
|
||||
{
|
||||
int spriteId = sub_8097B2C(var1);
|
||||
|
||||
if(spriteId != MAX_SPRITES)
|
||||
{
|
||||
struct Sprite *sprite = &gSprites[spriteId];
|
||||
const struct MapObjectGraphicsInfo *gfxInfo = GetFieldObjectGraphicsInfo(var2);
|
||||
u16 tileNum = sprite->oam.tileNum;
|
||||
|
||||
sprite->oam = *gfxInfo->oam;
|
||||
sprite->oam.tileNum = tileNum;
|
||||
sprite->oam.paletteNum = gfxInfo->paletteSlot;
|
||||
sprite->images = gfxInfo->images;
|
||||
|
||||
if(gfxInfo->subspriteTables == NULL)
|
||||
{
|
||||
sprite->subspriteTables = NULL;
|
||||
sprite->subspriteTableNum = 0;
|
||||
sprite->subspriteMode = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetSubspriteTables(sprite, gfxInfo->subspriteTables);
|
||||
sprite->subspriteMode = 2;
|
||||
}
|
||||
StartSpriteAnim(sprite, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_8097C44(u8 var, bool32 var2)
|
||||
{
|
||||
u8 spriteId = sub_8097B2C(var);
|
||||
|
||||
if(spriteId == MAX_SPRITES)
|
||||
return;
|
||||
|
||||
if(var2)
|
||||
gSprites[spriteId].data[2] = 1;
|
||||
else
|
||||
gSprites[spriteId].data[2] = 0;
|
||||
}
|
||||
|
||||
bool32 sub_8097C8C(u8 var)
|
||||
{
|
||||
u8 spriteId = sub_8097B2C(var);
|
||||
|
||||
if(spriteId == MAX_SPRITES)
|
||||
return FALSE;
|
||||
|
||||
return (gSprites[spriteId].data[2] == TRUE);
|
||||
}
|
||||
|
||||
void sub_8097CC4(u8 var1, u8 var2)
|
||||
{
|
||||
u8 spriteId = sub_8097B2C(var1);
|
||||
|
||||
if(spriteId != MAX_SPRITES)
|
||||
{
|
||||
gSprites[spriteId].data[3] = var2;
|
||||
gSprites[spriteId].data[4] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void sub_8097CF4(struct Sprite *sprite)
|
||||
{
|
||||
switch(sprite->data[4])
|
||||
{
|
||||
case 0:
|
||||
sprite->pos2.y = 0;
|
||||
sprite->data[4]++;
|
||||
case 1:
|
||||
sprite->pos2.y -= 8;
|
||||
if(sprite->pos2.y == -160)
|
||||
{
|
||||
sprite->pos2.y = 0;
|
||||
sprite->data[2] = 1;
|
||||
sprite->data[3] = 0;
|
||||
sprite->data[4] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sub_8097D30(struct Sprite *sprite)
|
||||
{
|
||||
switch(sprite->data[4])
|
||||
{
|
||||
case 0:
|
||||
sprite->pos2.y = -160;
|
||||
sprite->data[4]++;
|
||||
case 1:
|
||||
sprite->pos2.y += 8;
|
||||
if(sprite->pos2.y == 0)
|
||||
{
|
||||
sprite->data[3] = 0;
|
||||
sprite->data[4] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sub_8097D68(struct Sprite *sprite)
|
||||
{
|
||||
switch(sprite->data[3])
|
||||
{
|
||||
case 1:
|
||||
sub_8097D30(sprite);
|
||||
break;
|
||||
case 2:
|
||||
sub_8097CF4(sprite);
|
||||
break;
|
||||
case 0:
|
||||
break;
|
||||
default:
|
||||
sprite->data[3] = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool32 sub_8097D9C(u8 var)
|
||||
{
|
||||
u8 spriteId = sub_8097B2C(var);
|
||||
|
||||
if(spriteId == MAX_SPRITES)
|
||||
return FALSE;
|
||||
|
||||
if(gSprites[spriteId].data[3] != FALSE)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
u32 oe_exec_and_other_stuff(u8 fieldEffectId, struct MapObject *mapObject)
|
||||
{
|
||||
FieldObjectGetLocalIdAndMap(mapObject, &gFieldEffectArguments[0], &gFieldEffectArguments[1], &gFieldEffectArguments[2]);
|
||||
return FieldEffectStart(fieldEffectId);
|
||||
}
|
||||
|
||||
void DoShadowFieldEffect(struct MapObject *mapObject)
|
||||
{
|
||||
if (!mapObject->mapobj_bit_22)
|
||||
{
|
||||
mapObject->mapobj_bit_22 = 1;
|
||||
oe_exec_and_other_stuff(FLDEFF_SHADOW, mapObject);
|
||||
}
|
||||
}
|
||||
|
||||
void DoRippleFieldEffect(struct MapObject *mapObject, struct Sprite *sprite)
|
||||
{
|
||||
const struct MapObjectGraphicsInfo *gfxInfo = GetFieldObjectGraphicsInfo(mapObject->graphicsId);
|
||||
gFieldEffectArguments[0] = sprite->pos1.x;
|
||||
gFieldEffectArguments[1] = sprite->pos1.y + (gfxInfo->height >> 1) - 2;
|
||||
gFieldEffectArguments[2] = 151;
|
||||
gFieldEffectArguments[3] = 3;
|
||||
FieldEffectStart(FLDEFF_RIPPLE);
|
||||
}
|
||||
|
||||
#ifdef NONMATCHING
|
||||
bool32 sub_8097E50(struct MapObject *mapObject, struct Sprite *sprite)
|
||||
{
|
||||
bool32 ableToStore = FALSE;
|
||||
if (gUnknown_020375B8 == NULL)
|
||||
{
|
||||
gUnknown_020375B8 = AllocZeroed(0x14);
|
||||
gUnknown_020375B8[0] = mapObject->localId;
|
||||
gUnknown_020375B8[16] = 1;
|
||||
ableToStore = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8 i;
|
||||
u8 firstFreeSlot;
|
||||
bool32 found;
|
||||
for (firstFreeSlot = 16, found = FALSE, i = 0; i < 16; i++)
|
||||
{
|
||||
if (firstFreeSlot == 16 && gUnknown_020375B8[i] == 0)
|
||||
firstFreeSlot = i;
|
||||
|
||||
if (gUnknown_020375B8[i] == mapObject->localId)
|
||||
{
|
||||
found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found && firstFreeSlot != 16)
|
||||
{
|
||||
gUnknown_020375B8[firstFreeSlot] = mapObject->localId;
|
||||
gUnknown_020375B8[16]++;
|
||||
ableToStore = TRUE; // the nonmatching problem is that ableToStore == TRUE isnt being merged with the above ableToStore = TRUE assignment.
|
||||
}
|
||||
}
|
||||
|
||||
if (ableToStore == TRUE)
|
||||
{
|
||||
mapObject->mapobj_bit_12 = TRUE;
|
||||
mapObject->mapobj_bit_9 = TRUE;
|
||||
}
|
||||
|
||||
sprite->data[2] = 1;
|
||||
return TRUE;
|
||||
}
|
||||
#else
|
||||
__attribute__((naked))
|
||||
bool32 sub_8097E50(struct MapObject *mapObject, struct Sprite *sprite)
|
||||
{
|
||||
asm(".syntax unified\n\
|
||||
push {r4-r7,lr}\n\
|
||||
mov r7, r8\n\
|
||||
push {r7}\n\
|
||||
adds r4, r0, 0\n\
|
||||
mov r8, r1\n\
|
||||
movs r0, 0\n\
|
||||
mov r12, r0\n\
|
||||
ldr r0, =gUnknown_020375B8\n\
|
||||
ldr r1, [r0]\n\
|
||||
adds r6, r0, 0\n\
|
||||
cmp r1, 0\n\
|
||||
bne _08097E80\n\
|
||||
movs r0, 0x14\n\
|
||||
bl AllocZeroed\n\
|
||||
str r0, [r6]\n\
|
||||
ldrb r1, [r4, 0x8]\n\
|
||||
strb r1, [r0]\n\
|
||||
ldr r1, [r6]\n\
|
||||
movs r0, 0x1\n\
|
||||
strb r0, [r1, 0x10]\n\
|
||||
b _08097ECC\n\
|
||||
.pool\n\
|
||||
_08097E80:\n\
|
||||
movs r2, 0x10\n\
|
||||
movs r5, 0\n\
|
||||
movs r1, 0\n\
|
||||
adds r3, r6, 0\n\
|
||||
b _08097E90\n\
|
||||
_08097E8A:\n\
|
||||
adds r0, r1, 0x1\n\
|
||||
lsls r0, 24\n\
|
||||
lsrs r1, r0, 24\n\
|
||||
_08097E90:\n\
|
||||
cmp r1, 0xF\n\
|
||||
bhi _08097EB2\n\
|
||||
cmp r2, 0x10\n\
|
||||
bne _08097EA4\n\
|
||||
ldr r0, [r3]\n\
|
||||
adds r0, r1\n\
|
||||
ldrb r0, [r0]\n\
|
||||
cmp r0, 0\n\
|
||||
bne _08097EA4\n\
|
||||
adds r2, r1, 0\n\
|
||||
_08097EA4:\n\
|
||||
ldr r0, [r3]\n\
|
||||
adds r0, r1\n\
|
||||
ldrb r0, [r0]\n\
|
||||
ldrb r7, [r4, 0x8]\n\
|
||||
cmp r0, r7\n\
|
||||
bne _08097E8A\n\
|
||||
movs r5, 0x1\n\
|
||||
_08097EB2:\n\
|
||||
cmp r5, 0\n\
|
||||
bne _08097ECE\n\
|
||||
cmp r2, 0x10\n\
|
||||
beq _08097ECE\n\
|
||||
ldr r0, [r6]\n\
|
||||
adds r0, r2\n\
|
||||
ldrb r1, [r4, 0x8]\n\
|
||||
strb r1, [r0]\n\
|
||||
ldr r1, [r6]\n\
|
||||
ldrb r0, [r1, 0x10]\n\
|
||||
adds r0, 0x1\n\
|
||||
strb r0, [r1, 0x10]\n\
|
||||
movs r0, 0x1\n\
|
||||
_08097ECC:\n\
|
||||
mov r12, r0\n\
|
||||
_08097ECE:\n\
|
||||
mov r1, r12\n\
|
||||
cmp r1, 0x1\n\
|
||||
bne _08097EE0\n\
|
||||
ldrb r0, [r4, 0x1]\n\
|
||||
movs r1, 0x10\n\
|
||||
orrs r0, r1\n\
|
||||
movs r1, 0x2\n\
|
||||
orrs r0, r1\n\
|
||||
strb r0, [r4, 0x1]\n\
|
||||
_08097EE0:\n\
|
||||
movs r0, 0x1\n\
|
||||
mov r7, r8\n\
|
||||
strh r0, [r7, 0x32]\n\
|
||||
pop {r3}\n\
|
||||
mov r8, r3\n\
|
||||
pop {r4-r7}\n\
|
||||
pop {r1}\n\
|
||||
bx r1\n\
|
||||
.syntax divided");
|
||||
}
|
||||
#endif
|
||||
|
||||
// this function is very similar to the above one and I don't want to decompile this one until the above is matching.
|
||||
__attribute__((naked))
|
||||
bool32 sub_8097EF0(struct MapObject *mapObject, struct Sprite *sprite)
|
||||
{
|
||||
asm(".syntax unified\n\
|
||||
push {r4-r7,lr}\n\
|
||||
mov r7, r8\n\
|
||||
push {r7}\n\
|
||||
adds r6, r0, 0\n\
|
||||
mov r8, r1\n\
|
||||
movs r0, 0x1\n\
|
||||
strh r0, [r1, 0x32]\n\
|
||||
ldr r5, =gUnknown_020375B8\n\
|
||||
ldr r0, [r5]\n\
|
||||
cmp r0, 0\n\
|
||||
beq _08097F68\n\
|
||||
movs r7, 0\n\
|
||||
adds r0, r6, 0\n\
|
||||
bl sub_8097F78\n\
|
||||
lsls r0, 24\n\
|
||||
lsrs r1, r0, 24\n\
|
||||
cmp r1, 0x10\n\
|
||||
beq _08097F28\n\
|
||||
ldr r0, [r5]\n\
|
||||
adds r0, r1\n\
|
||||
movs r1, 0\n\
|
||||
strb r1, [r0]\n\
|
||||
ldr r1, [r5]\n\
|
||||
ldrb r0, [r1, 0x10]\n\
|
||||
subs r0, 0x1\n\
|
||||
strb r0, [r1, 0x10]\n\
|
||||
movs r7, 0x1\n\
|
||||
_08097F28:\n\
|
||||
ldr r0, [r5]\n\
|
||||
ldrb r4, [r0, 0x10]\n\
|
||||
cmp r4, 0\n\
|
||||
bne _08097F36\n\
|
||||
bl Free\n\
|
||||
str r4, [r5]\n\
|
||||
_08097F36:\n\
|
||||
cmp r7, 0x1\n\
|
||||
bne _08097F68\n\
|
||||
ldrb r0, [r6, 0x5]\n\
|
||||
bl GetFieldObjectGraphicsInfo\n\
|
||||
ldrb r1, [r0, 0xC]\n\
|
||||
lsls r1, 25\n\
|
||||
lsrs r1, 31\n\
|
||||
lsls r1, 4\n\
|
||||
ldrb r2, [r6, 0x1]\n\
|
||||
movs r0, 0x11\n\
|
||||
negs r0, r0\n\
|
||||
ands r0, r2\n\
|
||||
orrs r0, r1\n\
|
||||
movs r1, 0x3\n\
|
||||
negs r1, r1\n\
|
||||
ands r0, r1\n\
|
||||
strb r0, [r6, 0x1]\n\
|
||||
mov r2, r8\n\
|
||||
adds r2, 0x2C\n\
|
||||
ldrb r1, [r2]\n\
|
||||
movs r0, 0x41\n\
|
||||
negs r0, r0\n\
|
||||
ands r0, r1\n\
|
||||
strb r0, [r2]\n\
|
||||
_08097F68:\n\
|
||||
movs r0, 0x1\n\
|
||||
pop {r3}\n\
|
||||
mov r8, r3\n\
|
||||
pop {r4-r7}\n\
|
||||
pop {r1}\n\
|
||||
bx r1\n\
|
||||
.pool\n\
|
||||
.syntax divided");
|
||||
}
|
||||
|
||||
u8 sub_8097F78(struct MapObject *mapObject)
|
||||
{
|
||||
u8 i;
|
||||
|
||||
for(i = 0; i < MAP_OBJECTS_COUNT; i++)
|
||||
{
|
||||
if(gUnknown_020375B8[i] == mapObject->localId)
|
||||
return i;
|
||||
}
|
||||
return MAP_OBJECTS_COUNT;
|
||||
}
|
||||
|
||||
void sub_8097FA4(struct MapObject *mapObject)
|
||||
{
|
||||
u8 taskId = CreateTask(sub_8097FE4, 0xFF);
|
||||
struct Task *task = &gTasks[taskId];
|
||||
|
||||
StoreWordInTwoHalfwords(&task->data[0], (u32)mapObject);
|
||||
mapObject->mapobj_unk_1B = taskId;
|
||||
task->data[3] = 0xFFFF;
|
||||
}
|
||||
|
||||
void sub_8097FE4(u8 taskId)
|
||||
{
|
||||
struct MapObject *mapObject;
|
||||
struct Sprite *sprite;
|
||||
struct Task *task = &gTasks[taskId];
|
||||
|
||||
LoadWordFromTwoHalfwords(&task->data[0], (u32 *)&mapObject); // load the map object pointer.
|
||||
sprite = &gSprites[mapObject->spriteId];
|
||||
|
||||
if(!(task->data[2] & 0x3))
|
||||
sprite->pos2.y += task->data[3];
|
||||
|
||||
if(!(task->data[2] & 0xF))
|
||||
task->data[3] = -task->data[3];
|
||||
|
||||
task->data[2]++;
|
||||
}
|
||||
|
||||
void sub_8098044(u8 taskId)
|
||||
{
|
||||
u32 word;
|
||||
struct Task *task = &gTasks[taskId];
|
||||
|
||||
LoadWordFromTwoHalfwords(&task->data[0], &word); // huh??? why does it load a word that never gets used???
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
|
||||
void sub_8098074(u8 var1, u8 var2)
|
||||
{
|
||||
u8 i;
|
||||
|
||||
for(i = 0; i < MAP_OBJECTS_COUNT; i++)
|
||||
{
|
||||
if(i != var1 && i != var2 &&
|
||||
gMapObjects[i].active && i != gPlayerAvatar.mapObjectId)
|
||||
FreezeMapObject(&gMapObjects[i]);
|
||||
}
|
||||
}
|
||||
|
||||
bool32 sub_80980C0(struct MapObject *mapObject, struct Sprite *sprite)
|
||||
{
|
||||
sprite->pos2.y = 0;
|
||||
sprite->data[2]++;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool32 sub_80980D0(struct MapObject *mapObject, struct Sprite *sprite)
|
||||
{
|
||||
sprite->pos2.y -= 8;
|
||||
|
||||
if(sprite->pos2.y == -160)
|
||||
sprite->data[2]++;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool32 sub_80980F4(struct MapObject *mapObject, struct Sprite *sprite)
|
||||
{
|
||||
sprite->pos2.y = -160;
|
||||
sprite->data[2]++;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool32 sub_8098108(struct MapObject *mapObject, struct Sprite *sprite)
|
||||
{
|
||||
sprite->pos2.y += 8;
|
||||
|
||||
if(!sprite->pos2.y)
|
||||
sprite->data[2]++;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// though this function returns TRUE without doing anything, this header is required due to being in an array of functions which needs it.
|
||||
bool32 sub_8098124(struct MapObject *mapObject, struct Sprite *sprite)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
154
src/field_message_box.c
Executable file
154
src/field_message_box.c
Executable file
@@ -0,0 +1,154 @@
|
||||
#include "global.h"
|
||||
#include "new_menu_helpers.h"
|
||||
#include "string.h"
|
||||
#include "string_util.h"
|
||||
#include "task.h"
|
||||
#include "text.h"
|
||||
|
||||
EWRAM_DATA u8 gUnknown_020375BC = 0;
|
||||
|
||||
void textbox_fdecode_auto_and_task_add(u8*, int);
|
||||
void textbox_auto_and_task_add(void);
|
||||
|
||||
void sub_8098128(void)
|
||||
{
|
||||
gUnknown_020375BC = 0;
|
||||
gTextFlags.flag_0 = 0;
|
||||
gTextFlags.flag_1 = 0;
|
||||
gTextFlags.flag_2 = 0;
|
||||
gTextFlags.flag_3 = 0;
|
||||
}
|
||||
|
||||
void sub_8098154(u8 taskId)
|
||||
{
|
||||
struct Task *task = &gTasks[taskId];
|
||||
|
||||
switch (task->data[0])
|
||||
{
|
||||
case 0:
|
||||
sub_81973A4();
|
||||
task->data[0]++;
|
||||
break;
|
||||
case 1:
|
||||
sub_81973C4(0, 1);
|
||||
task->data[0]++;
|
||||
break;
|
||||
case 2:
|
||||
if (sub_8197224() != 1)
|
||||
{
|
||||
gUnknown_020375BC = 0;
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void task_add_textbox(void)
|
||||
{
|
||||
CreateTask(sub_8098154, 0x50);
|
||||
}
|
||||
|
||||
void task_del_textbox(void)
|
||||
{
|
||||
u8 taskId = FindTaskIdByFunc(sub_8098154);
|
||||
if (taskId != 0xFF)
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
|
||||
bool8 ShowFieldMessage(u8 *str)
|
||||
{
|
||||
if (gUnknown_020375BC != 0)
|
||||
return FALSE;
|
||||
textbox_fdecode_auto_and_task_add(str, 1);
|
||||
gUnknown_020375BC = 2;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void sub_8098214(u8 taskId)
|
||||
{
|
||||
if (sub_8196094() == 0)
|
||||
{
|
||||
gUnknown_020375BC = 0;
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
}
|
||||
|
||||
bool8 sub_8098238(u8 *str)
|
||||
{
|
||||
if (gUnknown_020375BC != 0)
|
||||
return FALSE;
|
||||
StringExpandPlaceholders(gStringVar4, str);
|
||||
CreateTask(sub_8098214, 0);
|
||||
sub_8196080(str);
|
||||
gUnknown_020375BC = 2;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool8 ShowFieldAutoScrollMessage(u8 *str)
|
||||
{
|
||||
if (gUnknown_020375BC != 0)
|
||||
return FALSE;
|
||||
gUnknown_020375BC = 3;
|
||||
textbox_fdecode_auto_and_task_add(str, 0);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool8 sub_80982A0(u8 *str)
|
||||
{
|
||||
gUnknown_020375BC = 3;
|
||||
textbox_fdecode_auto_and_task_add(str, 1);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool8 sub_80982B8(void)
|
||||
{
|
||||
if (gUnknown_020375BC != 0)
|
||||
return FALSE;
|
||||
gUnknown_020375BC = 2;
|
||||
textbox_auto_and_task_add();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void textbox_fdecode_auto_and_task_add(u8* str, int a)
|
||||
{
|
||||
StringExpandPlaceholders(gStringVar4, str);
|
||||
AddTextPrinterForMessage(a);
|
||||
task_add_textbox();
|
||||
}
|
||||
|
||||
void textbox_auto_and_task_add(void)
|
||||
{
|
||||
AddTextPrinterForMessage(1);
|
||||
task_add_textbox();
|
||||
}
|
||||
|
||||
void HideFieldMessageBox(void)
|
||||
{
|
||||
task_del_textbox();
|
||||
sub_8197434(0, 1);
|
||||
gUnknown_020375BC = 0;
|
||||
}
|
||||
|
||||
u8 textbox_any_visible(void)
|
||||
{
|
||||
return gUnknown_020375BC;
|
||||
}
|
||||
|
||||
bool8 IsFieldMessageBoxHidden(void)
|
||||
{
|
||||
if (gUnknown_020375BC == 0)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void sub_8098358(void)
|
||||
{
|
||||
task_del_textbox();
|
||||
sub_81973FC(0, 1);
|
||||
gUnknown_020375BC = 0;
|
||||
}
|
||||
|
||||
void sub_8098374(void)
|
||||
{
|
||||
task_del_textbox();
|
||||
gUnknown_020375BC = 0;
|
||||
}
|
||||
@@ -20,11 +20,12 @@
|
||||
#include "string_util.h"
|
||||
#include "m4a.h"
|
||||
#include "international_string_util.h"
|
||||
#include "unknown_task.h"
|
||||
#include "scanline_effect.h"
|
||||
#include "trig.h"
|
||||
#include "random.h"
|
||||
#include "event_data.h"
|
||||
#include "overworld.h"
|
||||
#include "new_menu_helpers.h"
|
||||
|
||||
struct HallofFameMon
|
||||
{
|
||||
@@ -53,7 +54,6 @@ static EWRAM_DATA struct HofGfx *sHofGfxPtr = NULL;
|
||||
|
||||
extern bool8 gHasHallOfFameRecords;
|
||||
extern u32 gUnknown_0203BCD4;
|
||||
extern u8 gDecompressionBuffer[];
|
||||
extern struct MusicPlayerInfo gMPlayInfo_BGM;
|
||||
extern MainCallback gGameContinueCallback;
|
||||
extern u32 gDamagedSaveSectors;
|
||||
@@ -82,7 +82,6 @@ extern const u8 gContestConfetti_Gfx[];
|
||||
extern const u8 gContestConfetti_Pal[];
|
||||
|
||||
extern void sub_81973C4(u8, u8);
|
||||
extern u16 AddTextPrinterParametrized(u8 windowId, u8 fontId, const u8 *str, u8 speed, void ( *callback)(u16, struct TextPrinter *), u8 fgColor, u8 bgColor, u8 shadowColor);
|
||||
extern void sub_8175620(void);
|
||||
extern u8 TrySavingData(u8);
|
||||
extern u8 sub_818D3E4(u16 species, u32 trainerId, u32 personality, u8 flags, s16 x, s16 y, u8, u16);
|
||||
@@ -540,7 +539,7 @@ static void Task_Hof_InitTeamSaveData(u8 taskId)
|
||||
*lastSavedTeam = *sHofMonPtr;
|
||||
|
||||
sub_81973C4(0, 0);
|
||||
AddTextPrinterParametrized(0, 1, gText_SavingDontTurnOffPower, 0, NULL, 2, 1, 3);
|
||||
AddTextPrinterParameterized(0, 1, gText_SavingDontTurnOffPower, 0, NULL, 2, 1, 3);
|
||||
CopyWindowToVram(0, 3);
|
||||
gTasks[taskId].func = Task_Hof_TrySaveData;
|
||||
}
|
||||
@@ -747,7 +746,7 @@ static void Task_Hof_WaitAndPrintPlayerInfo(u8 taskId)
|
||||
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x20, 0x20);
|
||||
HallOfFame_PrintPlayerInfo(1, 2);
|
||||
sub_81973C4(0, 0);
|
||||
AddTextPrinterParametrized(0, 1, gText_LeagueChamp, 0, NULL, 2, 1, 3);
|
||||
AddTextPrinterParameterized(0, 1, gText_LeagueChamp, 0, NULL, 2, 1, 3);
|
||||
CopyWindowToVram(0, 3);
|
||||
gTasks[taskId].func = Task_Hof_ExitOnKeyPressed;
|
||||
}
|
||||
@@ -1116,7 +1115,7 @@ static void Task_HofPC_PrintDataIsCorrupted(u8 taskId)
|
||||
{
|
||||
sub_8198180(gText_UnkCtrlF800Exit, 8, 1);
|
||||
sub_81973C4(0, 0);
|
||||
AddTextPrinterParametrized(0, 1, gText_HOFCorrupted, 0, NULL, 2, 1, 3);
|
||||
AddTextPrinterParameterized(0, 1, gText_HOFCorrupted, 0, NULL, 2, 1, 3);
|
||||
CopyWindowToVram(0, 3);
|
||||
gTasks[taskId].func = Task_HofPC_ExitOnButtonPress;
|
||||
}
|
||||
|
||||
1271
src/item_use.c
Executable file
1271
src/item_use.c
Executable file
File diff suppressed because it is too large
Load Diff
@@ -17,7 +17,7 @@
|
||||
#include "gpu_regs.h"
|
||||
#include "palette.h"
|
||||
#include "task.h"
|
||||
#include "unknown_task.h"
|
||||
#include "scanline_effect.h"
|
||||
#include "menu.h"
|
||||
#include "new_menu_helpers.h"
|
||||
#include "text.h"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "main.h"
|
||||
#include "overworld.h"
|
||||
#include "task.h"
|
||||
#include "unknown_task.h"
|
||||
#include "scanline_effect.h"
|
||||
#include "palette.h"
|
||||
#include "text.h"
|
||||
#include "menu.h"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "m4a.h"
|
||||
#include "bg.h"
|
||||
#include "rtc.h"
|
||||
#include "unknown_task.h"
|
||||
#include "scanline_effect.h"
|
||||
#include "overworld.h"
|
||||
#include "play_time.h"
|
||||
#include "random.h"
|
||||
|
||||
303
src/mystery_event_menu.c
Normal file
303
src/mystery_event_menu.c
Normal file
@@ -0,0 +1,303 @@
|
||||
#include "global.h"
|
||||
#include "mystery_event_menu.h"
|
||||
#include "link.h"
|
||||
#include "main.h"
|
||||
#include "menu.h"
|
||||
#include "mystery_event_script.h"
|
||||
#include "palette.h"
|
||||
#include "save.h"
|
||||
#include "constants/songs.h"
|
||||
#include "sound.h"
|
||||
#include "sprite.h"
|
||||
#include "string_util.h"
|
||||
#include "strings.h"
|
||||
#include "task.h"
|
||||
#include "text.h"
|
||||
#include "bg.h"
|
||||
#include "window.h"
|
||||
#include "gpu_regs.h"
|
||||
#include "text_window.h"
|
||||
#include "new_menu_helpers.h"
|
||||
#include "decompress.h"
|
||||
|
||||
// this file's functions
|
||||
static void CB2_MysteryEventMenu(void);
|
||||
static void PrintMysteryMenuText(u8 windowId, const u8 *text, u8 x, u8 y, s32 speed);
|
||||
|
||||
// EWRAM vars
|
||||
static EWRAM_DATA u8 sUnknown_0203BCF8 = 0; // set but unused
|
||||
|
||||
// const rom data
|
||||
static const struct BgTemplate sBgTemplates[] =
|
||||
{
|
||||
{
|
||||
.bg = 0,
|
||||
.charBaseIndex = 2,
|
||||
.mapBaseIndex = 31,
|
||||
.screenSize = 0,
|
||||
.paletteMode = 0,
|
||||
.priority = 0,
|
||||
.baseTile = 0
|
||||
}
|
||||
};
|
||||
|
||||
static const struct WindowTemplate sWindowTemplates[] =
|
||||
{
|
||||
{0, 4, 15, 22, 4, 14, 20},
|
||||
{0, 7, 6, 16, 4, 14, 0x6C},
|
||||
DUMMY_WIN_TEMPLATE
|
||||
};
|
||||
|
||||
// code
|
||||
static void VBlankCB(void)
|
||||
{
|
||||
LoadOam();
|
||||
ProcessSpriteCopyRequests();
|
||||
TransferPlttBuffer();
|
||||
}
|
||||
|
||||
static bool8 CheckLanguageMatch(void)
|
||||
{
|
||||
return (gLinkPlayers[0].language == gLinkPlayers[1].language);
|
||||
}
|
||||
|
||||
void CB2_InitMysteryEventMenu(void)
|
||||
{
|
||||
ResetSpriteData();
|
||||
FreeAllSpritePalettes();
|
||||
ResetTasks();
|
||||
SetVBlankCallback(VBlankCB);
|
||||
ResetBgsAndClearDma3BusyFlags(0);
|
||||
InitBgsFromTemplates(0, sBgTemplates, ARRAY_COUNT(sBgTemplates));
|
||||
if (InitWindows(sWindowTemplates))
|
||||
{
|
||||
s32 i;
|
||||
|
||||
DeactivateAllTextPrinters();
|
||||
for (i = 0; i < 2; i++)
|
||||
FillWindowPixelBuffer(i, 0);
|
||||
|
||||
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x1E, 0x14);
|
||||
sub_809882C(0, 1u, 0xD0u);
|
||||
sub_81978B0(0xE0);
|
||||
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON);
|
||||
SetGpuReg(REG_OFFSET_BLDCNT, 0);
|
||||
CreateTask(Task_DestroySelf, 0);
|
||||
StopMapMusic();
|
||||
RunTasks();
|
||||
AnimateSprites();
|
||||
BuildOamBuffer();
|
||||
RunTextPrinters();
|
||||
UpdatePaletteFade();
|
||||
FillPalette(0, 0, 2);
|
||||
SetMainCallback2(CB2_MysteryEventMenu);
|
||||
}
|
||||
}
|
||||
|
||||
static bool8 GetEventLoadMessage(u8 *dest, u32 status)
|
||||
{
|
||||
bool8 retVal = TRUE;
|
||||
|
||||
if (status == 0)
|
||||
{
|
||||
StringCopy(dest, gText_EventSafelyLoaded);
|
||||
retVal = FALSE;
|
||||
}
|
||||
|
||||
if (status == 2)
|
||||
retVal = FALSE;
|
||||
|
||||
if (status == 1)
|
||||
StringCopy(dest, gText_LoadErrorEndingSession);
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
static void CB2_MysteryEventMenu(void)
|
||||
{
|
||||
switch (gMain.state)
|
||||
{
|
||||
case 0:
|
||||
SetWindowBorderStyle(0, 1, 1, 0xD);
|
||||
PutWindowTilemap(0);
|
||||
CopyWindowToVram(0, 3);
|
||||
ShowBg(0);
|
||||
BeginNormalPaletteFade(-1, 0, 0x10, 0, 0);
|
||||
gMain.state++;
|
||||
break;
|
||||
case 1:
|
||||
if (!gPaletteFade.active)
|
||||
{
|
||||
PrintMysteryMenuText(0, gText_LinkStandby2, 1, 2, 1);
|
||||
gMain.state++;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (!IsTextPrinterActive(0))
|
||||
{
|
||||
gMain.state++;
|
||||
gLinkType = 21761;
|
||||
OpenLink();
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if ((gLinkStatus & 0x20) && (gLinkStatus & 0x1C) > 4)
|
||||
{
|
||||
PlaySE(SE_PIN);
|
||||
PrintMysteryMenuText(0, gText_PressAToLoadEvent, 1, 2, 1);
|
||||
gMain.state++;
|
||||
}
|
||||
if (gMain.newKeys & B_BUTTON)
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
CloseLink();
|
||||
gMain.state = 15;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if (!IsTextPrinterActive(0))
|
||||
gMain.state++;
|
||||
break;
|
||||
case 5:
|
||||
if (GetLinkPlayerCount_2() == 2)
|
||||
{
|
||||
if (gMain.newKeys & A_BUTTON)
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
sub_800A620();
|
||||
SetWindowBorderStyle(1, 1, 1, 0xD);
|
||||
PrintMysteryMenuText(1, gText_LoadingEvent, 1, 2, 0);
|
||||
PutWindowTilemap(1);
|
||||
CopyWindowToVram(1, 3);
|
||||
gMain.state++;
|
||||
}
|
||||
else if (gMain.newKeys & B_BUTTON)
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
CloseLink();
|
||||
gMain.state = 15;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GetEventLoadMessage(gStringVar4, 1);
|
||||
PrintMysteryMenuText(0, gStringVar4, 1, 2, 1);
|
||||
gMain.state = 13;
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
if (IsLinkConnectionEstablished())
|
||||
{
|
||||
if (gReceivedRemoteLinkPlayers != 0)
|
||||
{
|
||||
if (GetLinkPlayerDataExchangeStatusTimed(2, 2) == 3)
|
||||
{
|
||||
sub_800AC34();
|
||||
GetEventLoadMessage(gStringVar4, 1);
|
||||
PrintMysteryMenuText(0, gStringVar4, 1, 2, 1);
|
||||
gMain.state = 13;
|
||||
}
|
||||
else if (CheckLanguageMatch())
|
||||
{
|
||||
PrintMysteryMenuText(0, gText_DontRemoveCableTurnOff, 1, 2, 1);
|
||||
gMain.state++;
|
||||
}
|
||||
else
|
||||
{
|
||||
CloseLink();
|
||||
GetEventLoadMessage(gStringVar4, 1);
|
||||
PrintMysteryMenuText(0, gStringVar4, 1, 2, 1);
|
||||
gMain.state = 13;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (gMain.newKeys & B_BUTTON)
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
CloseLink();
|
||||
gMain.state = 15;
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
if (!IsTextPrinterActive(0))
|
||||
gMain.state++;
|
||||
break;
|
||||
case 8:
|
||||
if (GetBlockReceivedStatus())
|
||||
{
|
||||
ResetBlockReceivedFlags();
|
||||
gMain.state++;
|
||||
}
|
||||
break;
|
||||
case 9:
|
||||
gMain.state++;
|
||||
break;
|
||||
case 10:
|
||||
sub_800AC34();
|
||||
gMain.state++;
|
||||
break;
|
||||
case 11:
|
||||
if (gReceivedRemoteLinkPlayers == 0)
|
||||
{
|
||||
u16 unkVal = RunMysteryEventScript(gDecompressionBuffer);
|
||||
CpuFill32(0, gDecompressionBuffer, 0x7D4);
|
||||
if (!GetEventLoadMessage(gStringVar4, unkVal))
|
||||
TrySavingData(NORMAL_SAVE);
|
||||
gMain.state++;
|
||||
}
|
||||
break;
|
||||
case 12:
|
||||
PrintMysteryMenuText(0, gStringVar4, 1, 2, 1);
|
||||
gMain.state++;
|
||||
break;
|
||||
case 13:
|
||||
if (!IsTextPrinterActive(0))
|
||||
{
|
||||
gMain.state++;
|
||||
sUnknown_0203BCF8 = 0;
|
||||
}
|
||||
break;
|
||||
case 14:
|
||||
if (gMain.newKeys & A_BUTTON)
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
gMain.state++;
|
||||
}
|
||||
break;
|
||||
case 15:
|
||||
BeginNormalPaletteFade(-1, 0, 0, 0x10, 0);
|
||||
gMain.state++;
|
||||
break;
|
||||
case 16:
|
||||
if (!gPaletteFade.active)
|
||||
DoSoftReset();
|
||||
break;
|
||||
}
|
||||
|
||||
if (gLinkStatus & 0x40 && !IsLinkMaster())
|
||||
{
|
||||
CloseLink();
|
||||
GetEventLoadMessage(gStringVar4, 1);
|
||||
PrintMysteryMenuText(0, gStringVar4, 1, 2, 1);
|
||||
gMain.state = 13;
|
||||
}
|
||||
|
||||
RunTasks();
|
||||
AnimateSprites();
|
||||
BuildOamBuffer();
|
||||
RunTextPrinters();
|
||||
UpdatePaletteFade();
|
||||
}
|
||||
|
||||
static void PrintMysteryMenuText(u8 windowId, const u8 *text, u8 x, u8 y, s32 speed)
|
||||
{
|
||||
struct TextColor textColor;
|
||||
u8 letterSpacing = 0;
|
||||
u8 lineSpacing = 1;
|
||||
textColor.fgColor = 1;
|
||||
textColor.bgColor = 2;
|
||||
textColor.shadowColor = 3;
|
||||
|
||||
FillWindowPixelBuffer(windowId, (textColor.fgColor) | (textColor.fgColor << 4));
|
||||
AddTextPrinterParameterized2(windowId, 1, x, y, letterSpacing, lineSpacing, &textColor, speed, text);
|
||||
}
|
||||
2177
src/naming_screen.c
Normal file
2177
src/naming_screen.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -2,7 +2,7 @@
|
||||
#include "option_menu.h"
|
||||
#include "main.h"
|
||||
#include "menu.h"
|
||||
#include "unknown_task.h"
|
||||
#include "scanline_effect.h"
|
||||
#include "palette.h"
|
||||
#include "sprite.h"
|
||||
#include "task.h"
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "decompress.h"
|
||||
#include "gpu_regs.h"
|
||||
#include "task.h"
|
||||
#include "constants/rgb.h"
|
||||
|
||||
enum
|
||||
{
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "battle.h"
|
||||
#include "battle_controllers.h"
|
||||
#include "palette.h"
|
||||
#include "unknown_task.h"
|
||||
#include "scanline_effect.h"
|
||||
#include "list_menu.h"
|
||||
#include "gpu_regs.h"
|
||||
#include "decompress.h"
|
||||
@@ -583,7 +583,7 @@ static void HandleInitWindows(void)
|
||||
|
||||
static void PrintOnPokeblockWindow(u8 windowId, const u8 *string, s32 x)
|
||||
{
|
||||
AddTextPrinterParametrized2(windowId, 1, x, 1, 0, 0, &sTextColorInPokeblockMenu, 0, string);
|
||||
AddTextPrinterParameterized2(windowId, 1, x, 1, 0, 0, &sTextColorInPokeblockMenu, 0, string);
|
||||
}
|
||||
|
||||
static void PutPokeblockInfoText(void)
|
||||
|
||||
@@ -792,7 +792,7 @@ static void Task_HandleMonAtePokeblock(u8 taskId)
|
||||
StringExpandPlaceholders(gStringVar4, gText_Var1DisdainfullyAteVar2);
|
||||
|
||||
gTextFlags.flag_0 = 1;
|
||||
AddTextPrinterParametrized(0, 1, gStringVar4, GetPlayerTextSpeed(), NULL, 2, 1, 3);
|
||||
AddTextPrinterParameterized(0, 1, gStringVar4, GetPlayerTextSpeed(), NULL, 2, 1, 3);
|
||||
gTasks[taskId].func = Task_WaitForAtePokeblockText;
|
||||
}
|
||||
|
||||
|
||||
@@ -74,8 +74,6 @@ extern u8 GetFrontierOpponentClass(u16 trainerId);
|
||||
extern u8 pokemon_order_func(u8 bankPartyId);
|
||||
extern void GetFrontierTrainerName(u8* dest, u16 trainerId);
|
||||
extern void sub_81C488C(u8);
|
||||
extern void sub_817F578(struct Sprite*, u8 frontAnimId);
|
||||
extern u8 GetSpeciesBackAnimId(u16 species);
|
||||
|
||||
static void sub_806E6CC(u8 taskId);
|
||||
|
||||
@@ -1508,7 +1506,7 @@ static void Task_PokemonSummaryAnimateAfterDelay(u8 taskId)
|
||||
{
|
||||
if (--gTasks[taskId].data[3] == 0)
|
||||
{
|
||||
sub_817F578(READ_PTR_FROM_TASK(taskId, 0), gTasks[taskId].data[2]);
|
||||
StartMonSummaryAnimation(READ_PTR_FROM_TASK(taskId, 0), gTasks[taskId].data[2]);
|
||||
sub_81C488C(0xFF);
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
@@ -1523,7 +1521,6 @@ void BattleAnimateFrontSprite(struct Sprite* sprite, u16 species, bool8 noCry, u
|
||||
}
|
||||
|
||||
extern void SpriteCallbackDummy_2(struct Sprite*);
|
||||
extern void sub_817F60C(struct Sprite*);
|
||||
|
||||
void DoMonFrontSpriteAnimation(struct Sprite* sprite, u16 species, bool8 noCry, u8 arg3)
|
||||
{
|
||||
@@ -1580,11 +1577,11 @@ void PokemonSummaryDoMonAnimation(struct Sprite* sprite, u16 species, bool8 oneF
|
||||
gTasks[taskId].data[2] = gMonFrontAnimIdsTable[species - 1];
|
||||
gTasks[taskId].data[3] = gMonAnimationDelayTable[species - 1];
|
||||
sub_81C488C(taskId);
|
||||
sub_817F60C(sprite);
|
||||
SetSpriteCB_MonAnimDummy(sprite);
|
||||
}
|
||||
else
|
||||
{
|
||||
sub_817F578(sprite, gMonFrontAnimIdsTable[species - 1]);
|
||||
StartMonSummaryAnimation(sprite, gMonFrontAnimIdsTable[species - 1]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1603,7 +1600,7 @@ void BattleAnimateBackSprite(struct Sprite* sprite, u16 species)
|
||||
}
|
||||
else
|
||||
{
|
||||
LaunchAnimationTaskForBackSprite(sprite, GetSpeciesBackAnimId(species));
|
||||
LaunchAnimationTaskForBackSprite(sprite, GetSpeciesBackAnimSet(species));
|
||||
sprite->callback = SpriteCallbackDummy_2;
|
||||
}
|
||||
}
|
||||
|
||||
5658
src/pokemon_animation.c
Normal file
5658
src/pokemon_animation.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -162,7 +162,7 @@ extern struct BattleMove gBattleMoves[];
|
||||
|
||||
extern u32 ChangeBgX(u8 bg, u32 value, u8 op);
|
||||
extern void sub_8199C30(u8 a, u8 b, u8 c, u8 d, u8 e, u8 f);
|
||||
extern void AddTextPrinterParametrized2(u8 windowId, u8 fontId, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, struct TextColor* colors, s8 speed, u8 *str);
|
||||
extern void AddTextPrinterParameterized2(u8 windowId, u8 fontId, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, struct TextColor* colors, s8 speed, u8 *str);
|
||||
extern s32 GetStringCenterAlignXOffset(u8 fontId, u8 *str, s32 totalWidth);
|
||||
extern s32 GetStringRightAlignXOffset(u8 fontId, u8 *str, s32 totalWidth);
|
||||
extern bool8 sub_81A6BF4();
|
||||
@@ -2557,7 +2557,7 @@ void sub_81C2554()
|
||||
|
||||
void sub_81C25A4(u8 a, u8 *b, u8 c, u8 d, u8 e, u8 f)
|
||||
{
|
||||
AddTextPrinterParametrized2(a, 1, c, d, 0, e, &gUnknown_0861CD2C[f], 0, b);
|
||||
AddTextPrinterParameterized2(a, 1, c, d, 0, e, &gUnknown_0861CD2C[f], 0, b);
|
||||
}
|
||||
|
||||
void sub_81C25E8()
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "battle.h"
|
||||
#include "palette.h"
|
||||
#include "main.h"
|
||||
#include "unknown_task.h"
|
||||
#include "scanline_effect.h"
|
||||
#include "text.h"
|
||||
#include "gpu_regs.h"
|
||||
#include "bg.h"
|
||||
@@ -34,7 +34,7 @@ extern struct SpriteTemplate gUnknown_0202499C;
|
||||
|
||||
extern const union AnimCmd * const * const gMonAnimationsSpriteAnimsPtrTable[];
|
||||
|
||||
extern void dp12_8087EA4(void);
|
||||
extern void ScanlineEffect_Clear(void);
|
||||
extern void sub_8035658(void);
|
||||
extern bool8 IsDoubleBattle(void);
|
||||
extern u8 GetSubstituteSpriteDefault_Y(u8 bank);
|
||||
@@ -72,7 +72,7 @@ static void CB2_ReshowBattleScreenAfterMenu(void)
|
||||
switch (gBattleScripting.reshowMainState)
|
||||
{
|
||||
case 0:
|
||||
dp12_8087EA4();
|
||||
ScanlineEffect_Clear();
|
||||
sub_8035658();
|
||||
SetBgAttribute(1, BG_CTRL_ATTR_VISIBLE, 0);
|
||||
SetBgAttribute(2, BG_CTRL_ATTR_VISIBLE, 0);
|
||||
|
||||
57
src/save.c
57
src/save.c
@@ -4,13 +4,68 @@
|
||||
#include "constants/game_stat.h"
|
||||
#include "task.h"
|
||||
|
||||
// for the chunk declarations
|
||||
extern struct SaveBlock2 gSaveblock2;
|
||||
extern struct SaveBlock1 gSaveblock1;
|
||||
extern struct PokemonStorage gPokemonStorage;
|
||||
|
||||
extern struct SaveSectionLocation gRamSaveSectionLocations[0xE];
|
||||
extern u8 gDecompressionBuffer[];
|
||||
extern u32 gFlashMemoryPresent;
|
||||
extern u16 gUnknown_03006294;
|
||||
extern bool8 gSoftResetDisabled;
|
||||
|
||||
extern const struct SaveSectionOffsets gSaveSectionOffsets[0xE];
|
||||
// Divide save blocks into individual chunks to be written to flash sectors
|
||||
|
||||
// Each 4 KiB flash sector contains 3968 bytes of actual data followed by a 128 byte footer
|
||||
#define SECTOR_DATA_SIZE 3968
|
||||
#define SECTOR_FOOTER_SIZE 128
|
||||
|
||||
/*
|
||||
* Sector Layout:
|
||||
*
|
||||
* Sectors 0 - 13: Save Slot 1
|
||||
* Sectors 14 - 27: Save Slot 2
|
||||
* Sectors 28 - 29: Hall of Fame
|
||||
* Sector 30: e-Reader/Mystery Gift Stuff (note: e-Reader is deprecated in Emerald US)
|
||||
* Sector 31: Recorded Battle
|
||||
*
|
||||
* There are two save slots for saving the player's game data. We alternate between
|
||||
* them each time the game is saved, so that if the current save slot is corrupt,
|
||||
* we can load the previous one. We also rotate the sectors in each save slot
|
||||
* so that the same data is not always being written to the same sector. This
|
||||
* might be done to reduce wear on the flash memory, but I'm not sure, since all
|
||||
* 14 sectors get written anyway.
|
||||
*/
|
||||
|
||||
// (u8 *)structure was removed from the first statement of the macro in Emerald.
|
||||
// This is because malloc is used to allocate addresses so storing the raw
|
||||
// addresses should not be done in the offsets information.
|
||||
#define SAVEBLOCK_CHUNK(structure, chunkNum) \
|
||||
{ \
|
||||
chunkNum * SECTOR_DATA_SIZE, \
|
||||
min(sizeof(structure) - chunkNum * SECTOR_DATA_SIZE, SECTOR_DATA_SIZE) \
|
||||
} \
|
||||
|
||||
const struct SaveSectionOffsets gSaveSectionOffsets[] =
|
||||
{
|
||||
SAVEBLOCK_CHUNK(gSaveblock2, 0),
|
||||
|
||||
SAVEBLOCK_CHUNK(gSaveblock1, 0),
|
||||
SAVEBLOCK_CHUNK(gSaveblock1, 1),
|
||||
SAVEBLOCK_CHUNK(gSaveblock1, 2),
|
||||
SAVEBLOCK_CHUNK(gSaveblock1, 3),
|
||||
|
||||
SAVEBLOCK_CHUNK(gPokemonStorage, 0),
|
||||
SAVEBLOCK_CHUNK(gPokemonStorage, 1),
|
||||
SAVEBLOCK_CHUNK(gPokemonStorage, 2),
|
||||
SAVEBLOCK_CHUNK(gPokemonStorage, 3),
|
||||
SAVEBLOCK_CHUNK(gPokemonStorage, 4),
|
||||
SAVEBLOCK_CHUNK(gPokemonStorage, 5),
|
||||
SAVEBLOCK_CHUNK(gPokemonStorage, 6),
|
||||
SAVEBLOCK_CHUNK(gPokemonStorage, 7),
|
||||
SAVEBLOCK_CHUNK(gPokemonStorage, 8),
|
||||
};
|
||||
|
||||
extern void DoSaveFailedScreen(u8); // save_failed_screen
|
||||
extern void LoadSerializedGame(void); // load_save
|
||||
|
||||
@@ -173,7 +173,7 @@ static void SaveFailedScreenTextPrint(u8 *text, u8 var1, u8 var2)
|
||||
color.fgColor = 0;
|
||||
color.bgColor = 15;
|
||||
color.shadowColor = 3;
|
||||
AddTextPrinterParametrized2(gSaveFailedWindowIds[TEXT_WIN_ID], 1, var1 * 8, var2 * 8 + 1, 0, 0, &color, 0, text);
|
||||
AddTextPrinterParameterized2(gSaveFailedWindowIds[TEXT_WIN_ID], 1, var1 * 8, var2 * 8 + 1, 0, 0, &color, 0, text);
|
||||
}
|
||||
|
||||
void DoSaveFailedScreen(u8 saveType)
|
||||
|
||||
262
src/scanline_effect.c
Normal file
262
src/scanline_effect.c
Normal file
@@ -0,0 +1,262 @@
|
||||
#include "global.h"
|
||||
#include "data2.h"
|
||||
#include "task.h"
|
||||
#include "trig.h"
|
||||
#include "scanline_effect.h"
|
||||
|
||||
static void CopyValue16Bit(void);
|
||||
static void CopyValue32Bit(void);
|
||||
|
||||
extern u16 gBattle_BG0_Y;
|
||||
extern u16 gBattle_BG0_X;
|
||||
extern u16 gBattle_BG1_X;
|
||||
extern u16 gBattle_BG1_Y;
|
||||
extern u16 gBattle_BG2_X;
|
||||
extern u16 gBattle_BG2_Y;
|
||||
extern u16 gBattle_BG3_X;
|
||||
extern u16 gBattle_BG3_Y;
|
||||
|
||||
// EWRAM vars
|
||||
|
||||
// Per-scanline register values.
|
||||
// This is double buffered so that it can be safely written to at any time
|
||||
// without overwriting the buffer that the DMA is currently reading
|
||||
EWRAM_DATA u16 gScanlineEffectRegBuffers[2][0x3C0] = {0};
|
||||
|
||||
EWRAM_DATA struct ScanlineEffect gScanlineEffect = {0};
|
||||
EWRAM_DATA static bool8 sShouldStopWaveTask = FALSE;
|
||||
|
||||
void ScanlineEffect_Stop(void)
|
||||
{
|
||||
gScanlineEffect.state = 0;
|
||||
DmaStop(0);
|
||||
if (gScanlineEffect.waveTaskId != 0xFF)
|
||||
{
|
||||
DestroyTask(gScanlineEffect.waveTaskId);
|
||||
gScanlineEffect.waveTaskId = 0xFF;
|
||||
}
|
||||
}
|
||||
|
||||
void ScanlineEffect_Clear(void)
|
||||
{
|
||||
CpuFill16(0, gScanlineEffectRegBuffers, sizeof(gScanlineEffectRegBuffers));
|
||||
gScanlineEffect.dmaSrcBuffers[0] = NULL;
|
||||
gScanlineEffect.dmaSrcBuffers[1] = NULL;
|
||||
gScanlineEffect.dmaDest = NULL;
|
||||
gScanlineEffect.dmaControl = 0;
|
||||
gScanlineEffect.srcBuffer = 0;
|
||||
gScanlineEffect.state = 0;
|
||||
gScanlineEffect.unused16 = 0;
|
||||
gScanlineEffect.unused17 = 0;
|
||||
gScanlineEffect.waveTaskId = 0xFF;
|
||||
}
|
||||
|
||||
void ScanlineEffect_SetParams(struct ScanlineEffectParams params)
|
||||
{
|
||||
if (params.dmaControl == SCANLINE_EFFECT_DMACNT_16BIT) // 16-bit
|
||||
{
|
||||
// Set the DMA src to the value for the second scanline because the
|
||||
// first DMA transfer occurs in HBlank *after* the first scanline is drawn
|
||||
gScanlineEffect.dmaSrcBuffers[0] = (u16 *)gScanlineEffectRegBuffers[0] + 1;
|
||||
gScanlineEffect.dmaSrcBuffers[1] = (u16 *)gScanlineEffectRegBuffers[1] + 1;
|
||||
gScanlineEffect.setFirstScanlineReg = CopyValue16Bit;
|
||||
}
|
||||
else // assume 32-bit
|
||||
{
|
||||
// Set the DMA src to the value for the second scanline because the
|
||||
// first DMA transfer occurs in HBlank *after* the first scanline is drawn
|
||||
gScanlineEffect.dmaSrcBuffers[0] = (u32 *)gScanlineEffectRegBuffers[0] + 1;
|
||||
gScanlineEffect.dmaSrcBuffers[1] = (u32 *)gScanlineEffectRegBuffers[1] + 1;
|
||||
gScanlineEffect.setFirstScanlineReg = CopyValue32Bit;
|
||||
}
|
||||
|
||||
gScanlineEffect.dmaControl = params.dmaControl;
|
||||
gScanlineEffect.dmaDest = params.dmaDest;
|
||||
gScanlineEffect.state = params.initState;
|
||||
gScanlineEffect.unused16 = params.unused9;
|
||||
gScanlineEffect.unused17 = params.unused9;
|
||||
}
|
||||
|
||||
void ScanlineEffect_InitHBlankDmaTransfer(void)
|
||||
{
|
||||
if (gScanlineEffect.state == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (gScanlineEffect.state == 3)
|
||||
{
|
||||
gScanlineEffect.state = 0;
|
||||
DmaStop(0);
|
||||
sShouldStopWaveTask = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
DmaStop(0);
|
||||
// Set DMA to copy to dest register on each HBlank for the next frame.
|
||||
// The HBlank DMA transfers do not occurr during VBlank, so the transfer
|
||||
// will begin on the HBlank after the first scanline
|
||||
DmaSet(0, gScanlineEffect.dmaSrcBuffers[gScanlineEffect.srcBuffer], gScanlineEffect.dmaDest, gScanlineEffect.dmaControl);
|
||||
// Manually set the reg for the first scanline
|
||||
gScanlineEffect.setFirstScanlineReg();
|
||||
// Swap current buffer
|
||||
gScanlineEffect.srcBuffer ^= 1;
|
||||
}
|
||||
}
|
||||
|
||||
// These two functions are used to copy the register for the first scanline,
|
||||
// depending whether it is a 16-bit register or a 32-bit register.
|
||||
|
||||
static void CopyValue16Bit(void)
|
||||
{
|
||||
u16 *dest = (u16 *)gScanlineEffect.dmaDest;
|
||||
u16 *src = (u16 *)&gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer];
|
||||
|
||||
*dest = *src;
|
||||
}
|
||||
|
||||
static void CopyValue32Bit(void)
|
||||
{
|
||||
u32 *dest = (u32 *)gScanlineEffect.dmaDest;
|
||||
u32 *src = (u32 *)&gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer];
|
||||
|
||||
*dest = *src;
|
||||
}
|
||||
|
||||
#define tStartLine data[0]
|
||||
#define tEndLine data[1]
|
||||
#define tWaveLength data[2]
|
||||
#define tSrcBufferOffset data[3]
|
||||
#define tFramesUntilMove data[4]
|
||||
#define tDelayInterval data[5]
|
||||
#define tRegOffset data[6]
|
||||
#define tApplyBattleBgOffsets data[7]
|
||||
|
||||
static void TaskFunc_UpdateWavePerFrame(u8 taskId)
|
||||
{
|
||||
int value = 0;
|
||||
int i;
|
||||
int offset;
|
||||
|
||||
if (sShouldStopWaveTask)
|
||||
{
|
||||
DestroyTask(taskId);
|
||||
gScanlineEffect.waveTaskId = 0xFF;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gTasks[taskId].tApplyBattleBgOffsets)
|
||||
{
|
||||
switch (gTasks[taskId].tRegOffset)
|
||||
{
|
||||
case SCANLINE_EFFECT_REG_BG0HOFS:
|
||||
value = gBattle_BG0_X;
|
||||
break;
|
||||
case SCANLINE_EFFECT_REG_BG0VOFS:
|
||||
value = gBattle_BG0_Y;
|
||||
break;
|
||||
case SCANLINE_EFFECT_REG_BG1HOFS:
|
||||
value = gBattle_BG1_X;
|
||||
break;
|
||||
case SCANLINE_EFFECT_REG_BG1VOFS:
|
||||
value = gBattle_BG1_Y;
|
||||
break;
|
||||
case SCANLINE_EFFECT_REG_BG2HOFS:
|
||||
value = gBattle_BG2_X;
|
||||
break;
|
||||
case SCANLINE_EFFECT_REG_BG2VOFS:
|
||||
value = gBattle_BG2_Y;
|
||||
break;
|
||||
case SCANLINE_EFFECT_REG_BG3HOFS:
|
||||
value = gBattle_BG3_X;
|
||||
break;
|
||||
case SCANLINE_EFFECT_REG_BG3VOFS:
|
||||
value = gBattle_BG3_Y;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (gTasks[taskId].tFramesUntilMove != 0)
|
||||
{
|
||||
gTasks[taskId].tFramesUntilMove--;
|
||||
offset = gTasks[taskId].tSrcBufferOffset + 320;
|
||||
for (i = gTasks[taskId].tStartLine; i < gTasks[taskId].tEndLine; i++)
|
||||
{
|
||||
gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = gScanlineEffectRegBuffers[0][offset] + value;
|
||||
offset++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gTasks[taskId].tFramesUntilMove = gTasks[taskId].tDelayInterval;
|
||||
offset = gTasks[taskId].tSrcBufferOffset + 320;
|
||||
for (i = gTasks[taskId].tStartLine; i < gTasks[taskId].tEndLine; i++)
|
||||
{
|
||||
gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = gScanlineEffectRegBuffers[0][offset] + value;
|
||||
offset++;
|
||||
}
|
||||
|
||||
// increment src buffer offset
|
||||
gTasks[taskId].tSrcBufferOffset++;
|
||||
if (gTasks[taskId].tSrcBufferOffset == gTasks[taskId].tWaveLength)
|
||||
gTasks[taskId].tSrcBufferOffset = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void GenerateWave(u16 *buffer, u8 frequency, u8 amplitude, u8 unused)
|
||||
{
|
||||
u16 i = 0;
|
||||
u8 theta = 0;
|
||||
|
||||
while (i < 256)
|
||||
{
|
||||
buffer[i] = (gSineTable[theta] * amplitude) / 256;
|
||||
theta += frequency;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
// Initializes a background "wave" effect that affects scanlines startLine (inclusive) to endLine (exclusive).
|
||||
// 'frequency' and 'amplitude' control the frequency and amplitude of the wave.
|
||||
// 'delayInterval' controls how fast the wave travels up the screen. The wave will shift upwards one scanline every 'delayInterval'+1 frames.
|
||||
// 'regOffset' is the offset of the video register to modify.
|
||||
u8 ScanlineEffect_InitWave(u8 startLine, u8 endLine, u8 frequency, u8 amplitude, u8 delayInterval, u8 regOffset, bool8 applyBattleBgOffsets)
|
||||
{
|
||||
int i;
|
||||
int offset;
|
||||
struct ScanlineEffectParams params;
|
||||
u8 taskId;
|
||||
|
||||
ScanlineEffect_Clear();
|
||||
|
||||
params.dmaDest = (void *)(REG_ADDR_BG0HOFS + regOffset);
|
||||
params.dmaControl = SCANLINE_EFFECT_DMACNT_16BIT;
|
||||
params.initState = 1;
|
||||
params.unused9 = 0;
|
||||
ScanlineEffect_SetParams(params);
|
||||
|
||||
taskId = CreateTask(TaskFunc_UpdateWavePerFrame, 0);
|
||||
|
||||
gTasks[taskId].tStartLine = startLine;
|
||||
gTasks[taskId].tEndLine = endLine;
|
||||
gTasks[taskId].tWaveLength = 256 / frequency;
|
||||
gTasks[taskId].tSrcBufferOffset = 0;
|
||||
gTasks[taskId].tFramesUntilMove = delayInterval;
|
||||
gTasks[taskId].tDelayInterval = delayInterval;
|
||||
gTasks[taskId].tRegOffset = regOffset;
|
||||
gTasks[taskId].tApplyBattleBgOffsets = applyBattleBgOffsets;
|
||||
|
||||
gScanlineEffect.waveTaskId = taskId;
|
||||
sShouldStopWaveTask = FALSE;
|
||||
|
||||
GenerateWave(&gScanlineEffectRegBuffers[0][320], frequency, amplitude, endLine - startLine);
|
||||
|
||||
offset = 320;
|
||||
for (i = startLine; i < endLine; i++)
|
||||
{
|
||||
gScanlineEffectRegBuffers[0][i] = gScanlineEffectRegBuffers[0][offset];
|
||||
gScanlineEffectRegBuffers[1][i] = gScanlineEffectRegBuffers[0][offset];
|
||||
offset++;
|
||||
}
|
||||
|
||||
return taskId;
|
||||
}
|
||||
10
src/scrcmd.c
10
src/scrcmd.c
@@ -638,7 +638,7 @@ static bool8 IsPaletteNotActive(void)
|
||||
|
||||
bool8 ScrCmd_fadescreen(struct ScriptContext *ctx)
|
||||
{
|
||||
fade_screen(ScriptReadByte(ctx), 0);
|
||||
FadeScreen(ScriptReadByte(ctx), 0);
|
||||
SetupNativeScript(ctx, IsPaletteNotActive);
|
||||
return TRUE;
|
||||
}
|
||||
@@ -648,7 +648,7 @@ bool8 ScrCmd_fadescreenspeed(struct ScriptContext *ctx)
|
||||
u8 mode = ScriptReadByte(ctx);
|
||||
u8 speed = ScriptReadByte(ctx);
|
||||
|
||||
fade_screen(mode, speed);
|
||||
FadeScreen(mode, speed);
|
||||
SetupNativeScript(ctx, IsPaletteNotActive);
|
||||
return TRUE;
|
||||
}
|
||||
@@ -662,12 +662,12 @@ bool8 ScrCmd_fadescreenswapbuffers(struct ScriptContext *ctx)
|
||||
case 1:
|
||||
default:
|
||||
CpuCopy32(gPlttBufferUnfaded, gPaletteDecompressionBuffer, PLTT_DECOMP_BUFFER_SIZE);
|
||||
fade_screen(mode, 0);
|
||||
FadeScreen(mode, 0);
|
||||
break;
|
||||
case 0:
|
||||
case 2:
|
||||
CpuCopy32(gPaletteDecompressionBuffer, gPlttBufferUnfaded, PLTT_DECOMP_BUFFER_SIZE);
|
||||
fade_screen(mode, 0);
|
||||
FadeScreen(mode, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -726,7 +726,7 @@ bool8 ScrCmd_setweather(struct ScriptContext *ctx)
|
||||
|
||||
bool8 ScrCmd_resetweather(struct ScriptContext *ctx)
|
||||
{
|
||||
sub_80AEDBC();
|
||||
SetSav1WeatherFromCurrMapHeader();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
@@ -394,7 +394,7 @@ void sub_80E8FD0(u8 taskId)
|
||||
void sub_80E9068(void)
|
||||
{
|
||||
CreateTask(sub_80E8FD0, 0);
|
||||
fade_screen(1, 0);
|
||||
FadeScreen(1, 0);
|
||||
saved_warp2_set(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1);
|
||||
}
|
||||
|
||||
@@ -451,7 +451,7 @@ void sub_80E916C(u8 taskId)
|
||||
void sub_80E91F8(void)
|
||||
{
|
||||
CreateTask(sub_80E916C, 0);
|
||||
fade_screen(1, 0);
|
||||
FadeScreen(1, 0);
|
||||
}
|
||||
|
||||
bool8 CurrentMapIsSecretBase(void)
|
||||
@@ -651,7 +651,7 @@ void sub_80E96A4(u8 taskId)
|
||||
void sub_80E9728(void)
|
||||
{
|
||||
CreateTask(sub_80E96A4, 0);
|
||||
fade_screen(1, 0);
|
||||
FadeScreen(1, 0);
|
||||
}
|
||||
|
||||
void sub_80E9744(void)
|
||||
|
||||
4111
src/text.c
4111
src/text.c
File diff suppressed because it is too large
Load Diff
118
src/time_events.c
Normal file
118
src/time_events.c
Normal file
@@ -0,0 +1,118 @@
|
||||
#include "global.h"
|
||||
#include "time_events.h"
|
||||
#include "event_data.h"
|
||||
#include "field_weather.h"
|
||||
#include "pokemon.h"
|
||||
#include "random.h"
|
||||
#include "overworld.h"
|
||||
#include "rtc.h"
|
||||
#include "script.h"
|
||||
#include "task.h"
|
||||
|
||||
static u32 GetMirageRnd(void)
|
||||
{
|
||||
u32 hi = VarGet(VAR_MIRAGE_RND_H);
|
||||
u32 lo = VarGet(VAR_MIRAGE_RND_L);
|
||||
return (hi << 16) | lo;
|
||||
}
|
||||
|
||||
static void SetMirageRnd(u32 rnd)
|
||||
{
|
||||
VarSet(VAR_MIRAGE_RND_H, rnd >> 16);
|
||||
VarSet(VAR_MIRAGE_RND_L, rnd);
|
||||
}
|
||||
|
||||
// unused
|
||||
void InitMirageRnd(void)
|
||||
{
|
||||
SetMirageRnd((Random() << 16) | Random());
|
||||
}
|
||||
|
||||
void UpdateMirageRnd(u16 days)
|
||||
{
|
||||
s32 rnd = GetMirageRnd();
|
||||
while (days)
|
||||
{
|
||||
rnd = 1103515245 * rnd + 12345;
|
||||
days--;
|
||||
}
|
||||
SetMirageRnd(rnd);
|
||||
}
|
||||
|
||||
bool8 IsMirageIslandPresent(void)
|
||||
{
|
||||
u16 rnd = GetMirageRnd() >> 16;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < PARTY_SIZE; i++)
|
||||
if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) && (GetMonData(&gPlayerParty[i], MON_DATA_PERSONALITY) & 0xFFFF) == rnd)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void UpdateShoalTideFlag(void)
|
||||
{
|
||||
static const u8 tide[] =
|
||||
{
|
||||
1, // 00
|
||||
1, // 01
|
||||
1, // 02
|
||||
0, // 03
|
||||
0, // 04
|
||||
0, // 05
|
||||
0, // 06
|
||||
0, // 07
|
||||
0, // 08
|
||||
1, // 09
|
||||
1, // 10
|
||||
1, // 11
|
||||
1, // 12
|
||||
1, // 13
|
||||
1, // 14
|
||||
0, // 15
|
||||
0, // 16
|
||||
0, // 17
|
||||
0, // 18
|
||||
0, // 19
|
||||
0, // 20
|
||||
1, // 21
|
||||
1, // 22
|
||||
1, // 23
|
||||
};
|
||||
|
||||
if (is_light_level_1_2_3_5_or_6(get_map_light_from_warp0()))
|
||||
{
|
||||
RtcCalcLocalTime();
|
||||
if (tide[gLocalTime.hours])
|
||||
FlagSet(FLAG_SYS_SHOAL_TIDE);
|
||||
else
|
||||
FlagClear(FLAG_SYS_SHOAL_TIDE);
|
||||
}
|
||||
}
|
||||
|
||||
static void Task_WaitWeather(u8 taskId)
|
||||
{
|
||||
if (IsWeatherChangeComplete())
|
||||
{
|
||||
EnableBothScriptContexts();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
}
|
||||
|
||||
void WaitWeather(void)
|
||||
{
|
||||
CreateTask(Task_WaitWeather, 80);
|
||||
}
|
||||
|
||||
void InitBirchState(void)
|
||||
{
|
||||
*GetVarPointer(VAR_BIRCH_STATE) = 0;
|
||||
}
|
||||
|
||||
void UpdateBirchState(u16 days)
|
||||
{
|
||||
u16 *state = GetVarPointer(VAR_BIRCH_STATE);
|
||||
*state += days;
|
||||
*state %= 7;
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "field_effect.h"
|
||||
#include "field_map_obj.h"
|
||||
#include "field_player_avatar.h"
|
||||
#include "map_obj_8097404.h"
|
||||
#include "field_map_obj_helpers.h"
|
||||
#include "pokenav.h"
|
||||
#include "task.h"
|
||||
#include "util.h"
|
||||
@@ -639,7 +639,7 @@ void sub_80B45D0(void)
|
||||
gApproachingTrainerId++;
|
||||
gSpecialVar_Result = 1;
|
||||
UnfreezeMapObjects();
|
||||
sub_80974D0(gApproachingTrainers[1].mapObjectId);
|
||||
FreezeMapObjectsExceptOne(gApproachingTrainers[1].mapObjectId);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "malloc.h"
|
||||
#include "palette.h"
|
||||
#include "pokenav.h"
|
||||
#include "unknown_task.h"
|
||||
#include "scanline_effect.h"
|
||||
#include "text.h"
|
||||
#include "bg.h"
|
||||
#include "window.h"
|
||||
@@ -131,7 +131,7 @@ void sub_8166340(void)
|
||||
ProcessSpriteCopyRequests();
|
||||
TransferPlttBuffer();
|
||||
sub_81D2108(gUnknown_0203BCAC->field_7C58);
|
||||
sub_80BA0A8();
|
||||
ScanlineEffect_InitHBlankDmaTransfer();
|
||||
}
|
||||
|
||||
void sub_816636C(void (*func)(void))
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "window.h"
|
||||
#include "text_window.h"
|
||||
#include "menu.h"
|
||||
#include "unknown_task.h"
|
||||
#include "scanline_effect.h"
|
||||
#include "task.h"
|
||||
#include "strings.h"
|
||||
#include "sound.h"
|
||||
|
||||
Reference in New Issue
Block a user