Merge branch 'master' of https://github.com/pret/pokeemerald into battle_refactor
This commit is contained in:
@@ -1324,6 +1324,8 @@ const u8 gText_BattleRecordedOnPass[] = _("{B_PLAYER_NAME}’s battle result was
|
||||
const u8 gText_LinkTrainerWantsToBattlePause[] = _("{B_20}\nwants to battle!{PAUSE 49}");
|
||||
const u8 gText_TwoLinkTrainersWantToBattlePause[] = _("{B_20} and {B_21}\nwant to battle!{PAUSE 49}");
|
||||
|
||||
// This is four lists of moves which use a different attack string in Japanese
|
||||
// to the default. See the documentation for sub_814F950 for more detail.
|
||||
static const u16 sUnknownMoveTable[] =
|
||||
{
|
||||
MOVE_SWORDS_DANCE, MOVE_STRENGTH, MOVE_GROWTH,
|
||||
@@ -1338,16 +1340,16 @@ static const u16 sUnknownMoveTable[] =
|
||||
MOVE_TRICK, MOVE_ASSIST, MOVE_INGRAIN, MOVE_KNOCK_OFF,
|
||||
MOVE_CAMOUFLAGE, MOVE_ASTONISH, MOVE_ODOR_SLEUTH,
|
||||
MOVE_GRASS_WHISTLE, MOVE_SHEER_COLD, MOVE_MUDDY_WATER,
|
||||
MOVE_IRON_DEFENSE, MOVE_BOUNCE, MOVE_NONE,
|
||||
MOVE_IRON_DEFENSE, MOVE_BOUNCE, 0,
|
||||
|
||||
MOVE_TELEPORT, MOVE_RECOVER, MOVE_BIDE, MOVE_AMNESIA,
|
||||
MOVE_FLAIL, MOVE_TAUNT, MOVE_BULK_UP, MOVE_NONE,
|
||||
MOVE_FLAIL, MOVE_TAUNT, MOVE_BULK_UP, 0,
|
||||
|
||||
MOVE_MEDITATE, MOVE_AGILITY, MOVE_MIMIC, MOVE_DOUBLE_TEAM,
|
||||
MOVE_BARRAGE, MOVE_TRANSFORM, MOVE_STRUGGLE, MOVE_SCARY_FACE,
|
||||
MOVE_CHARGE, MOVE_WISH, MOVE_BRICK_BREAK, MOVE_YAWN,
|
||||
MOVE_FEATHER_DANCE, MOVE_TEETER_DANCE, MOVE_MUD_SPORT,
|
||||
MOVE_FAKE_TEARS, MOVE_WATER_SPORT, MOVE_CALM_MIND, MOVE_NONE,
|
||||
MOVE_FAKE_TEARS, MOVE_WATER_SPORT, MOVE_CALM_MIND, 0,
|
||||
|
||||
MOVE_POUND, MOVE_SCRATCH, MOVE_VICE_GRIP,
|
||||
MOVE_WING_ATTACK, MOVE_FLY, MOVE_BIND, MOVE_SLAM,
|
||||
@@ -1361,7 +1363,7 @@ static const u16 sUnknownMoveTable[] =
|
||||
MOVE_FORESIGHT, MOVE_CHARM, MOVE_ATTRACT, MOVE_ROCK_SMASH,
|
||||
MOVE_UPROAR, MOVE_SPIT_UP, MOVE_SWALLOW, MOVE_TORMENT,
|
||||
MOVE_FLATTER, MOVE_ROLE_PLAY, MOVE_ENDEAVOR, MOVE_TICKLE,
|
||||
MOVE_COVET, MOVE_NONE
|
||||
MOVE_COVET, 0
|
||||
};
|
||||
|
||||
static const u8 sDummyWeirdStatusString[] = {EOS, EOS, EOS, EOS, EOS, EOS, EOS, EOS, 0, 0};
|
||||
@@ -2330,6 +2332,10 @@ static void ExpandBattleTextBuffPlaceholders(const u8 *src, u8 *dst)
|
||||
}
|
||||
}
|
||||
|
||||
// Loads one of two text strings into the provided buffer. This is functionally
|
||||
// unused, since the value loaded into the buffer is not read; it loaded one of
|
||||
// two particles (either "は" or "の") which works in tandem with sub_814F950
|
||||
// below to effect changes in the meaning of the line.
|
||||
static void sub_814F8F8(u8* textBuff)
|
||||
{
|
||||
s32 counter = 0;
|
||||
@@ -2337,7 +2343,7 @@ static void sub_814F8F8(u8* textBuff)
|
||||
|
||||
while (counter != 4)
|
||||
{
|
||||
if (sUnknownMoveTable[i] == MOVE_NONE)
|
||||
if (sUnknownMoveTable[i] == 0)
|
||||
counter++;
|
||||
if (sUnknownMoveTable[i++] == gStringInfo->currentMove)
|
||||
break;
|
||||
@@ -2352,6 +2358,24 @@ static void sub_814F8F8(u8* textBuff)
|
||||
}
|
||||
}
|
||||
|
||||
// Appends "!" to the text buffer `dst`. In the original Japanese this looked
|
||||
// into the table of moves at sUnknownMoveTable and varied the line accordingly.
|
||||
//
|
||||
// gText_ExclamationMark was a plain "!", used for any attack not on the list.
|
||||
// It resulted in the translation "<NAME>'s <ATTACK>!".
|
||||
//
|
||||
// gText_ExclamationMark2 was "を つかった!". This resulted in the translation
|
||||
// "<NAME> used <ATTACK>!", which was used for all attacks in English.
|
||||
//
|
||||
// gText_ExclamationMark3 was "した!". This was used for those moves whose
|
||||
// names were verbs, such as Recover, and resulted in translations like "<NAME>
|
||||
// recovered itself!".
|
||||
//
|
||||
// gText_ExclamationMark4 was "を した!" This resulted in a translation of
|
||||
// "<NAME> did an <ATTACK>!".
|
||||
//
|
||||
// gText_ExclamationMark5 was " こうげき!" This resulted in a translation of
|
||||
// "<NAME>'s <ATTACK> attack!".
|
||||
static void sub_814F950(u8* dst)
|
||||
{
|
||||
s32 counter = 0;
|
||||
|
||||
4350
src/battle_transition.c
Normal file
4350
src/battle_transition.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -141,7 +141,7 @@ void InitBerryFixProgram(void)
|
||||
SetVBlankCallback(NULL);
|
||||
ResetSpriteData();
|
||||
ResetTasks();
|
||||
remove_some_task();
|
||||
ScanlineEffect_Stop();
|
||||
SetGpuReg(REG_OFFSET_DISPCNT, 0x0000);
|
||||
berry_fix_mb_manager = AllocZeroed(0x50);
|
||||
berry_fix_mb_manager->state = 0;
|
||||
|
||||
4
src/bg.c
4
src/bg.c
@@ -1007,7 +1007,7 @@ void CopyToBgTilemapBufferRect_ChangePalette(u8 bg, void *src, u8 destX, u8 dest
|
||||
}
|
||||
// Skipping for now, it probably uses structs passed by value
|
||||
/*
|
||||
void CopyRectToBgTilemapBufferRect(u8 bg, void* src, u8 srcX, u8 srcY, u8 srcWidth, u8 srcHeight, u8 destX, u8 destY, u8 rectWidth, u8 rectHeight, u8 palette1, u16 tileOffset, u16 palette2)
|
||||
void CopyRectToBgTilemapBufferRect(u8 bg, const void* src, u8 srcX, u8 srcY, u8 srcWidth, u8 srcHeight, u8 destX, u8 destY, u8 rectWidth, u8 rectHeight, u8 palette1, u16 tileOffset, u16 palette2)
|
||||
{
|
||||
u16 attribute;
|
||||
u16 mode;
|
||||
@@ -1049,7 +1049,7 @@ void CopyRectToBgTilemapBufferRect(u8 bg, void* src, u8 srcX, u8 srcY, u8 srcWid
|
||||
}
|
||||
}*/
|
||||
__attribute__((naked))
|
||||
void CopyRectToBgTilemapBufferRect(u8 bg, void* src, u8 srcX, u8 srcY, u8 srcWidth, u8 srcHeight, u8 destX, u8 destY, u8 rectWidth, u8 rectHeight, u8 palette1, u16 tileOffset, u16 palette2)
|
||||
void CopyRectToBgTilemapBufferRect(u8 bg, const void* src, u8 srcX, u8 srcY, u8 srcWidth, u8 srcHeight, u8 destX, u8 destY, u8 rectWidth, u8 rectHeight, u8 palette1, u16 tileOffset, u16 palette2)
|
||||
{
|
||||
asm("push {r4-r7,lr}\n\
|
||||
mov r7, r10\n\
|
||||
|
||||
0
src/braille_puzzles.c
Executable file → Normal file
0
src/braille_puzzles.c
Executable file → Normal file
0
src/clear_save_data_screen.c
Executable file → Normal file
0
src/clear_save_data_screen.c
Executable file → Normal file
2
src/diploma.c
Executable file → Normal file
2
src/diploma.c
Executable file → Normal file
@@ -72,7 +72,7 @@ void CB2_ShowDiploma(void)
|
||||
DmaFill16(3, 0, VRAM, VRAM_SIZE);
|
||||
DmaFill32(3, 0, OAM, OAM_SIZE);
|
||||
DmaFill16(3, 0, PLTT, PLTT_SIZE);
|
||||
remove_some_task();
|
||||
ScanlineEffect_Stop();
|
||||
ResetTasks();
|
||||
ResetSpriteData();
|
||||
ResetPaletteFade();
|
||||
|
||||
@@ -66,7 +66,7 @@ extern void overworld_free_bg_tilemaps(void);
|
||||
extern void sub_80AF168(void);
|
||||
extern void AllocateMonSpritesGfx(void);
|
||||
extern void FreeMonSpritesGfx(void);
|
||||
extern void remove_some_task(void);
|
||||
extern void ScanlineEffect_Stop(void);
|
||||
extern void reset_temp_tile_data_buffers(void);
|
||||
extern void c2_exit_to_overworld_2_switch(void);
|
||||
extern void play_some_sound(void);
|
||||
@@ -512,7 +512,7 @@ static void CB2_EggHatch_0(void)
|
||||
FreeAllSpritePalettes();
|
||||
ResetSpriteData();
|
||||
ResetTasks();
|
||||
remove_some_task();
|
||||
ScanlineEffect_Stop();
|
||||
m4aSoundVSyncOn();
|
||||
gMain.state++;
|
||||
break;
|
||||
|
||||
@@ -269,7 +269,7 @@ void EvolutionScene(struct Pokemon* mon, u16 speciesToEvolve, bool8 canStopEvo,
|
||||
sub_80356D0();
|
||||
LoadBattleTextboxAndBackground();
|
||||
ResetSpriteData();
|
||||
remove_some_task();
|
||||
ScanlineEffect_Stop();
|
||||
ResetTasks();
|
||||
FreeAllSpritePalettes();
|
||||
|
||||
|
||||
0
src/field_map_obj.c
Executable file → Normal file
0
src/field_map_obj.c
Executable file → Normal file
0
src/field_special_scene.c
Executable file → Normal file
0
src/field_special_scene.c
Executable file → Normal file
@@ -1302,7 +1302,7 @@ static void ClearVramOamPltt_LoadHofPal(void)
|
||||
|
||||
static void sub_8174F70(void)
|
||||
{
|
||||
remove_some_task();
|
||||
ScanlineEffect_Stop();
|
||||
ResetTasks();
|
||||
ResetSpriteData();
|
||||
reset_temp_tile_data_buffers();
|
||||
|
||||
46
src/hof_pc.c
Normal file
46
src/hof_pc.c
Normal file
@@ -0,0 +1,46 @@
|
||||
#include "global.h"
|
||||
#include "hall_of_fame.h"
|
||||
#include "main.h"
|
||||
#include "palette.h"
|
||||
#include "overworld.h"
|
||||
#include "script.h"
|
||||
#include "script_menu.h"
|
||||
#include "task.h"
|
||||
|
||||
extern void (*gFieldCallback)(void);
|
||||
extern void (*gUnknown_0300485C)(void);
|
||||
|
||||
extern void Overworld_PlaySpecialMapMusic(void);
|
||||
extern bool16 ScrSpecial_CreatePCMenu(void);
|
||||
extern void ScriptMenu_DisplayPCStartupPrompt(void);
|
||||
|
||||
static void ReshowPCMenuAfterHallOfFamePC(void);
|
||||
static void Task_WaitForPaletteFade(u8);
|
||||
|
||||
void AccessHallOfFamePC(void)
|
||||
{
|
||||
SetMainCallback2(CB2_DoHallOfFamePC);
|
||||
ScriptContext2_Enable();
|
||||
}
|
||||
|
||||
void ReturnFromHallOfFamePC(void)
|
||||
{
|
||||
SetMainCallback2(c2_exit_to_overworld_2_switch);
|
||||
gFieldCallback = ReshowPCMenuAfterHallOfFamePC;
|
||||
}
|
||||
|
||||
static void ReshowPCMenuAfterHallOfFamePC(void)
|
||||
{
|
||||
ScriptContext2_Enable();
|
||||
Overworld_PlaySpecialMapMusic();
|
||||
ScrSpecial_CreatePCMenu();
|
||||
ScriptMenu_DisplayPCStartupPrompt();
|
||||
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, 0);
|
||||
CreateTask(Task_WaitForPaletteFade, 10);
|
||||
}
|
||||
|
||||
static void Task_WaitForPaletteFade(u8 taskId)
|
||||
{
|
||||
if (!gPaletteFade.active)
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "global.h"
|
||||
#include "item.h"
|
||||
#include "berry.h"
|
||||
#include "constants/items.h"
|
||||
#include "string_util.h"
|
||||
#include "text.h"
|
||||
@@ -11,7 +12,6 @@ extern bool8 InBattlePyramid(void);
|
||||
extern const u8 gText_PokeBalls[];
|
||||
extern const u8 gText_Berries[];
|
||||
extern const u8 gText_Berry[];
|
||||
extern const u8 gUnknown_085897E4[][28]; // not sure what this one is
|
||||
|
||||
bool8 CheckPyramidBagHasItem(u16 itemId, u16 count);
|
||||
bool8 CheckPyramidBagHasSpace(u16 itemId, u16 count);
|
||||
@@ -96,8 +96,8 @@ void CopyItemNameHandlePlural(u16 itemId, u8 *string, u32 quantity)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (itemId >= 0x85 && itemId <= 0xAF)
|
||||
GetBerryCountString(string, gUnknown_085897E4[itemId], quantity);
|
||||
if (itemId >= ITEM_CHERI_BERRY && itemId <= ITEM_ENIGMA_BERRY)
|
||||
GetBerryCountString(string, gBerries[itemId - ITEM_CHERI_BERRY].name, quantity);
|
||||
else
|
||||
StringCopy(string, ItemId_GetItem(itemId)->name);
|
||||
}
|
||||
|
||||
0
src/libisagbprn.c
Executable file → Normal file
0
src/libisagbprn.c
Executable file → Normal file
26
src/mail.c
26
src/mail.c
@@ -240,30 +240,6 @@ static const struct MailLayout sUnknown_0859F458[] = {
|
||||
{ 0x05, 0x09, 0x60, 0x05, 0x1e, Unknown_0859F444 }
|
||||
};
|
||||
|
||||
// What the heck are these meant to be? Call them u16 for now.
|
||||
|
||||
static const u16 Unknown_0859F4E8[] = {
|
||||
0x00, 0x4000, 0x00, 0x00
|
||||
};
|
||||
|
||||
static const u16 Unknown_0859F4F0[] = {
|
||||
0x00, 0x00, -1, 0x00
|
||||
};
|
||||
|
||||
static const u16 Unknown_0859F4F8[] = {
|
||||
0x04, 0x00, -1, 0x00
|
||||
};
|
||||
|
||||
static const u16 Unknown_0859F500[] = {
|
||||
0x00, 0x40, -1, 0x00
|
||||
};
|
||||
|
||||
static const u16 *const sUnknown_0859F508[] = {
|
||||
Unknown_0859F4F0,
|
||||
Unknown_0859F4F8,
|
||||
Unknown_0859F500
|
||||
};
|
||||
|
||||
// .text
|
||||
|
||||
void ReadMail(struct MailStruct *mail, void (*callback)(void), bool8 flag)
|
||||
@@ -329,7 +305,7 @@ static bool8 MailReadBuildGraphics(void)
|
||||
{
|
||||
case 0:
|
||||
SetVBlankCallback(NULL);
|
||||
remove_some_task();
|
||||
ScanlineEffect_Stop();
|
||||
SetGpuReg(REG_OFFSET_DISPCNT, 0x0000);
|
||||
break;
|
||||
case 1:
|
||||
|
||||
@@ -29,7 +29,7 @@ extern void MapMusicMain(void);
|
||||
extern void EnableInterrupts(u16);
|
||||
extern void sub_8033648(void);
|
||||
extern u16 SetFlashTimerIntr(u8 timerNum, void (**intrFunc)(void));
|
||||
extern void remove_some_task(void);
|
||||
extern void ScanlineEffect_Stop(void);
|
||||
|
||||
extern struct SoundInfo gSoundInfo;
|
||||
extern u32 gFlashMemoryPresent;
|
||||
@@ -425,7 +425,7 @@ void DoSoftReset(void)
|
||||
{
|
||||
REG_IME = 0;
|
||||
m4aSoundVSyncOff();
|
||||
remove_some_task();
|
||||
ScanlineEffect_Stop();
|
||||
DmaStop(1);
|
||||
DmaStop(2);
|
||||
DmaStop(3);
|
||||
|
||||
13
src/mystery_event_msg.c
Normal file
13
src/mystery_event_msg.c
Normal file
@@ -0,0 +1,13 @@
|
||||
#include "global.h"
|
||||
|
||||
const u8 gText_MysteryGiftBerry[] = _("Obtained a {STR_VAR_2} BERRY!\nDad has it at PETALBURG GYM.");
|
||||
const u8 gText_MysteryGiftBerryTransform[] = _("The {STR_VAR_1} BERRY transformed into\none {STR_VAR_2} BERRY.");
|
||||
const u8 gText_MysteryGiftBerryObtained[] = _("The {STR_VAR_1} BERRY has already been\nobtained.");
|
||||
const u8 gText_MysteryGiftSpecialRibbon[] = _("A special RIBBON was awarded to\nyour party POKéMON.");
|
||||
const u8 gText_MysteryGiftNationalDex[] = _("The POKéDEX has been upgraded\nwith the NATIONAL MODE.");
|
||||
const u8 gText_MysteryGiftRareWord[] = _("A rare word has been added.");
|
||||
const u8 gText_MysteryGiftSentOver[] = _("{STR_VAR_1} was sent over!");
|
||||
const u8 gText_MysteryGiftFullParty[] = _("Your party is full.\n{STR_VAR_1} could not be sent over.");
|
||||
const u8 gText_MysteryGiftNewTrainer[] = _("A new TRAINER has arrived in\nHOENN.");
|
||||
const u8 gText_MysteryGiftNewAdversaryInBattleTower[] = _("A new adversary has arrived in the\nBATTLE TOWER.");
|
||||
const u8 gText_MysteryGiftCantBeUsed[] = _("This data can’t be used in\nthis version.");
|
||||
396
src/mystery_event_script.c
Normal file
396
src/mystery_event_script.c
Normal file
@@ -0,0 +1,396 @@
|
||||
#include "global.h"
|
||||
#include "berry.h"
|
||||
#include "battle_tower.h"
|
||||
#include "easy_chat.h"
|
||||
#include "event_data.h"
|
||||
#include "mail.h"
|
||||
#include "mystery_event_script.h"
|
||||
#include "pokedex.h"
|
||||
#include "pokemon.h"
|
||||
#include "pokemon_size_record.h"
|
||||
#include "script.h"
|
||||
#include "constants/species.h"
|
||||
#include "strings.h"
|
||||
#include "string_util.h"
|
||||
#include "text.h"
|
||||
#include "util.h"
|
||||
#include "mystery_event_msg.h"
|
||||
#include "pokemon_storage_system.h"
|
||||
|
||||
extern void sub_811EFC0(u8);
|
||||
extern void ValidateEReaderTrainer(void);
|
||||
|
||||
extern ScrCmdFunc gMysteryEventScriptCmdTable[];
|
||||
extern ScrCmdFunc gMysteryEventScriptCmdTableEnd[];
|
||||
|
||||
#define LANGUAGE_MASK 0x1
|
||||
#define VERSION_MASK 0x200
|
||||
|
||||
EWRAM_DATA static struct ScriptContext sMysteryEventScriptContext = {0};
|
||||
|
||||
static bool32 CheckCompatibility(u16 a1, u32 a2, u16 a3, u32 a4)
|
||||
{
|
||||
if (!(a1 & LANGUAGE_MASK))
|
||||
return FALSE;
|
||||
|
||||
if (!(a2 & LANGUAGE_MASK))
|
||||
return FALSE;
|
||||
|
||||
if (!(a3 & 0x4))
|
||||
return FALSE;
|
||||
|
||||
if (!(a4 & VERSION_MASK))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void SetIncompatible(void)
|
||||
{
|
||||
StringExpandPlaceholders(gStringVar4, gText_MysteryGiftCantBeUsed);
|
||||
SetMysteryEventScriptStatus(3);
|
||||
}
|
||||
|
||||
static void InitMysteryEventScript(struct ScriptContext *ctx, u8 *script)
|
||||
{
|
||||
InitScriptContext(ctx, gMysteryEventScriptCmdTable, gMysteryEventScriptCmdTableEnd);
|
||||
SetupBytecodeScript(ctx, script);
|
||||
ctx->data[0] = (u32)script;
|
||||
ctx->data[1] = 0;
|
||||
ctx->data[2] = 0;
|
||||
ctx->data[3] = 0;
|
||||
}
|
||||
|
||||
static bool32 RunMysteryEventScriptCommand(struct ScriptContext *ctx)
|
||||
{
|
||||
if (RunScriptCommand(ctx) && ctx->data[3])
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void sub_8153870(u8 *script)
|
||||
{
|
||||
InitMysteryEventScript(&sMysteryEventScriptContext, script);
|
||||
}
|
||||
|
||||
bool32 sub_8153884(u32 *a0)
|
||||
{
|
||||
bool32 ret = RunMysteryEventScriptCommand(&sMysteryEventScriptContext);
|
||||
*a0 = sMysteryEventScriptContext.data[2];
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
u32 RunMysteryEventScript(u8 *script)
|
||||
{
|
||||
struct ScriptContext *ctx = &sMysteryEventScriptContext;
|
||||
InitMysteryEventScript(ctx, script);
|
||||
while (RunMysteryEventScriptCommand(ctx));
|
||||
|
||||
return ctx->data[2];
|
||||
}
|
||||
|
||||
void SetMysteryEventScriptStatus(u32 val)
|
||||
{
|
||||
sMysteryEventScriptContext.data[2] = val;
|
||||
}
|
||||
|
||||
static int CalcRecordMixingGiftChecksum(void)
|
||||
{
|
||||
unsigned int i;
|
||||
int sum = 0;
|
||||
u8 *data = (u8*)(&gSaveBlock1Ptr->recordMixingGift.data);
|
||||
|
||||
for (i = 0; i < sizeof(gSaveBlock1Ptr->recordMixingGift.data); i++)
|
||||
sum += data[i];
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
||||
static bool32 IsRecordMixingGiftValid(void)
|
||||
{
|
||||
struct RecordMixingGiftData *data = &gSaveBlock1Ptr->recordMixingGift.data;
|
||||
int checksum = CalcRecordMixingGiftChecksum();
|
||||
|
||||
if (data->unk0 == 0
|
||||
|| data->quantity == 0
|
||||
|| data->itemId == 0
|
||||
|| checksum == 0
|
||||
|| checksum != gSaveBlock1Ptr->recordMixingGift.checksum)
|
||||
return FALSE;
|
||||
else
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void ClearRecordMixingGift(void)
|
||||
{
|
||||
CpuFill16(0, &gSaveBlock1Ptr->recordMixingGift, sizeof(gSaveBlock1Ptr->recordMixingGift));
|
||||
}
|
||||
|
||||
static void SetRecordMixingGift(u8 unk, u8 quantity, u16 itemId)
|
||||
{
|
||||
if (!unk || !quantity || !itemId)
|
||||
{
|
||||
ClearRecordMixingGift();
|
||||
}
|
||||
else
|
||||
{
|
||||
gSaveBlock1Ptr->recordMixingGift.data.unk0 = unk;
|
||||
gSaveBlock1Ptr->recordMixingGift.data.quantity = quantity;
|
||||
gSaveBlock1Ptr->recordMixingGift.data.itemId = itemId;
|
||||
gSaveBlock1Ptr->recordMixingGift.checksum = CalcRecordMixingGiftChecksum();
|
||||
}
|
||||
}
|
||||
|
||||
u16 GetRecordMixingGift(void)
|
||||
{
|
||||
struct RecordMixingGiftData *data = &gSaveBlock1Ptr->recordMixingGift.data;
|
||||
|
||||
if (!IsRecordMixingGiftValid())
|
||||
{
|
||||
ClearRecordMixingGift();
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
u16 itemId = data->itemId;
|
||||
data->quantity--;
|
||||
if (data->quantity == 0)
|
||||
ClearRecordMixingGift();
|
||||
else
|
||||
gSaveBlock1Ptr->recordMixingGift.checksum = CalcRecordMixingGiftChecksum();
|
||||
|
||||
return itemId;
|
||||
}
|
||||
}
|
||||
|
||||
bool8 MEScrCmd_end(struct ScriptContext *ctx)
|
||||
{
|
||||
StopScript(ctx);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool8 MEScrCmd_checkcompat(struct ScriptContext *ctx)
|
||||
{
|
||||
u16 v1;
|
||||
u32 v2;
|
||||
u16 v3;
|
||||
u32 v4;
|
||||
|
||||
ctx->data[1] = ScriptReadWord(ctx);
|
||||
v1 = ScriptReadHalfword(ctx);
|
||||
v2 = ScriptReadWord(ctx);
|
||||
v3 = ScriptReadHalfword(ctx);
|
||||
v4 = ScriptReadWord(ctx);
|
||||
|
||||
if (CheckCompatibility(v1, v2, v3, v4) == TRUE)
|
||||
ctx->data[3] = 1;
|
||||
else
|
||||
SetIncompatible();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool8 MEScrCmd_nop(struct ScriptContext *ctx)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 MEScrCmd_setstatus(struct ScriptContext *ctx)
|
||||
{
|
||||
u8 value = ScriptReadByte(ctx);
|
||||
ctx->data[2] = value;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 MEScrCmd_setmsg(struct ScriptContext *ctx)
|
||||
{
|
||||
u8 value = ScriptReadByte(ctx);
|
||||
u8 *str = (u8 *)(ScriptReadWord(ctx) - ctx->data[1] + ctx->data[0]);
|
||||
if (value == 0xFF || value == ctx->data[2])
|
||||
StringExpandPlaceholders(gStringVar4, str);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 MEScrCmd_runscript(struct ScriptContext *ctx)
|
||||
{
|
||||
u8 *script = (u8 *)(ScriptReadWord(ctx) - ctx->data[1] + ctx->data[0]);
|
||||
ScriptContext2_RunNewScript(script);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 MEScrCmd_setenigmaberry(struct ScriptContext *ctx)
|
||||
{
|
||||
u8 *str;
|
||||
const u8 *message;
|
||||
bool32 haveBerry = IsEnigmaBerryValid();
|
||||
u8 *berry = (u8 *)(ScriptReadWord(ctx) - ctx->data[1] + ctx->data[0]);
|
||||
StringCopyN(gStringVar1, gSaveBlock1Ptr->enigmaBerry.berry.name, BERRY_NAME_COUNT);
|
||||
SetEnigmaBerry(berry);
|
||||
StringCopyN(gStringVar2, gSaveBlock1Ptr->enigmaBerry.berry.name, BERRY_NAME_COUNT);
|
||||
|
||||
if (!haveBerry)
|
||||
{
|
||||
str = gStringVar4;
|
||||
message = gText_MysteryGiftBerry;
|
||||
}
|
||||
else if (StringCompare(gStringVar1, gStringVar2))
|
||||
{
|
||||
str = gStringVar4;
|
||||
message = gText_MysteryGiftBerryTransform;
|
||||
}
|
||||
else
|
||||
{
|
||||
str = gStringVar4;
|
||||
message = gText_MysteryGiftBerryObtained;
|
||||
}
|
||||
|
||||
StringExpandPlaceholders(str, message);
|
||||
|
||||
ctx->data[2] = 2;
|
||||
|
||||
if (IsEnigmaBerryValid() == TRUE)
|
||||
VarSet(VAR_ENIGMA_BERRY_AVAILABLE, 1);
|
||||
else
|
||||
ctx->data[2] = 1;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 MEScrCmd_giveribbon(struct ScriptContext *ctx)
|
||||
{
|
||||
u8 index = ScriptReadByte(ctx);
|
||||
u8 ribbonId = ScriptReadByte(ctx);
|
||||
GiveGiftRibbonToParty(index, ribbonId);
|
||||
StringExpandPlaceholders(gStringVar4, gText_MysteryGiftSpecialRibbon);
|
||||
ctx->data[2] = 2;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 MEScrCmd_initramscript(struct ScriptContext *ctx)
|
||||
{
|
||||
u8 mapGroup = ScriptReadByte(ctx);
|
||||
u8 mapNum = ScriptReadByte(ctx);
|
||||
u8 objectId = ScriptReadByte(ctx);
|
||||
u8 *script = (u8 *)(ScriptReadWord(ctx) - ctx->data[1] + ctx->data[0]);
|
||||
u8 *scriptEnd = (u8 *)(ScriptReadWord(ctx) - ctx->data[1] + ctx->data[0]);
|
||||
InitRamScript(script, scriptEnd - script, mapGroup, mapNum, objectId);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 MEScrCmd_givenationaldex(struct ScriptContext *ctx)
|
||||
{
|
||||
EnableNationalPokedex();
|
||||
StringExpandPlaceholders(gStringVar4, gText_MysteryGiftNationalDex);
|
||||
ctx->data[2] = 2;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 MEScrCmd_addrareword(struct ScriptContext *ctx)
|
||||
{
|
||||
sub_811EFC0(ScriptReadByte(ctx));
|
||||
StringExpandPlaceholders(gStringVar4, gText_MysteryGiftRareWord);
|
||||
ctx->data[2] = 2;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 MEScrCmd_setrecordmixinggift(struct ScriptContext *ctx)
|
||||
{
|
||||
u8 unk = ScriptReadByte(ctx);
|
||||
u8 quantity = ScriptReadByte(ctx);
|
||||
u16 itemId = ScriptReadHalfword(ctx);
|
||||
SetRecordMixingGift(unk, quantity, itemId);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 MEScrCmd_givepokemon(struct ScriptContext *ctx)
|
||||
{
|
||||
struct MailStruct mail;
|
||||
struct Pokemon pokemon;
|
||||
u16 species;
|
||||
u16 heldItem;
|
||||
u32 data = ScriptReadWord(ctx) - ctx->data[1] + ctx->data[0];
|
||||
void *pokemonPtr = (void *)data;
|
||||
void *mailPtr = (void *)(data + sizeof(struct Pokemon));
|
||||
|
||||
pokemon = *(struct Pokemon *)pokemonPtr;
|
||||
species = GetMonData(&pokemon, MON_DATA_SPECIES2);
|
||||
|
||||
if (species == SPECIES_EGG)
|
||||
StringCopyN(gStringVar1, gText_EggNickname, POKEMON_NAME_LENGTH + 1);
|
||||
else
|
||||
StringCopyN(gStringVar1, gText_Pokemon, POKEMON_NAME_LENGTH + 1);
|
||||
|
||||
if (gPlayerPartyCount == PARTY_SIZE)
|
||||
{
|
||||
StringExpandPlaceholders(gStringVar4, gText_MysteryGiftFullParty);
|
||||
ctx->data[2] = 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(&gPlayerParty[5], pokemonPtr, sizeof(struct Pokemon));
|
||||
memcpy(&mail, mailPtr, sizeof(struct MailStruct));
|
||||
|
||||
if (species != SPECIES_EGG)
|
||||
{
|
||||
u16 pokedexNum = SpeciesToNationalPokedexNum(species);
|
||||
GetSetPokedexFlag(pokedexNum, FLAG_SET_SEEN);
|
||||
GetSetPokedexFlag(pokedexNum, FLAG_SET_CAUGHT);
|
||||
}
|
||||
|
||||
heldItem = GetMonData(&gPlayerParty[5], MON_DATA_HELD_ITEM);
|
||||
if (ItemIsMail(heldItem))
|
||||
GiveMailToMon2(&gPlayerParty[5], &mail);
|
||||
CompactPartySlots();
|
||||
CalculatePlayerPartyCount();
|
||||
StringExpandPlaceholders(gStringVar4, gText_MysteryGiftSentOver);
|
||||
ctx->data[2] = 2;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 MEScrCmd_addtrainer(struct ScriptContext *ctx)
|
||||
{
|
||||
u32 data = ScriptReadWord(ctx) - ctx->data[1] + ctx->data[0];
|
||||
memcpy((void*)(gSaveBlock2Ptr) + 0xBEC, (void *)data, 0xBC);
|
||||
ValidateEReaderTrainer();
|
||||
StringExpandPlaceholders(gStringVar4, gText_MysteryGiftNewTrainer);
|
||||
ctx->data[2] = 2;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 MEScrCmd_enableresetrtc(struct ScriptContext *ctx)
|
||||
{
|
||||
EnableResetRTC();
|
||||
StringExpandPlaceholders(gStringVar4, gText_InGameClockUsable);
|
||||
ctx->data[2] = 2;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 MEScrCmd_checksum(struct ScriptContext *ctx)
|
||||
{
|
||||
int checksum = ScriptReadWord(ctx);
|
||||
u8 *data = (u8 *)(ScriptReadWord(ctx) - ctx->data[1] + ctx->data[0]);
|
||||
u8 *dataEnd = (u8 *)(ScriptReadWord(ctx) - ctx->data[1] + ctx->data[0]);
|
||||
if (checksum != CalcByteArraySum(data, dataEnd - data))
|
||||
{
|
||||
ctx->data[3] = 0;
|
||||
ctx->data[2] = 1;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool8 MEScrCmd_crc(struct ScriptContext *ctx)
|
||||
{
|
||||
int crc = ScriptReadWord(ctx);
|
||||
u8 *data = (u8 *)(ScriptReadWord(ctx) - ctx->data[1] + ctx->data[0]);
|
||||
u8 *dataEnd = (u8 *)(ScriptReadWord(ctx) - ctx->data[1] + ctx->data[0]);
|
||||
if (crc != CalcCRC16(data, dataEnd - data))
|
||||
{
|
||||
ctx->data[3] = 0;
|
||||
ctx->data[2] = 1;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
662
src/option_menu.c
Normal file
662
src/option_menu.c
Normal file
@@ -0,0 +1,662 @@
|
||||
#include "global.h"
|
||||
#include "option_menu.h"
|
||||
#include "main.h"
|
||||
#include "menu.h"
|
||||
#include "unknown_task.h"
|
||||
#include "palette.h"
|
||||
#include "sprite.h"
|
||||
#include "task.h"
|
||||
#include "bg.h"
|
||||
#include "gpu_regs.h"
|
||||
#include "window.h"
|
||||
#include "text.h"
|
||||
#include "text_window.h"
|
||||
#include "international_string_util.h"
|
||||
#include "strings.h"
|
||||
|
||||
extern void SetPokemonCryStereo(u32 val);
|
||||
|
||||
// Task data
|
||||
enum
|
||||
{
|
||||
TD_MENUSELECTION,
|
||||
TD_TEXTSPEED,
|
||||
TD_BATTLESCENE,
|
||||
TD_BATTLESTYLE,
|
||||
TD_SOUND,
|
||||
TD_BUTTONMODE,
|
||||
TD_FRAMETYPE,
|
||||
};
|
||||
|
||||
// Menu items
|
||||
enum
|
||||
{
|
||||
MENUITEM_TEXTSPEED,
|
||||
MENUITEM_BATTLESCENE,
|
||||
MENUITEM_BATTLESTYLE,
|
||||
MENUITEM_SOUND,
|
||||
MENUITEM_BUTTONMODE,
|
||||
MENUITEM_FRAMETYPE,
|
||||
MENUITEM_CANCEL,
|
||||
MENUITEM_COUNT,
|
||||
};
|
||||
|
||||
// Window Ids
|
||||
enum
|
||||
{
|
||||
WIN_TEXT_OPTION,
|
||||
WIN_OPTIONS
|
||||
};
|
||||
|
||||
// this file's functions
|
||||
static void Task_OptionMenuFadeIn(u8 taskId);
|
||||
static void Task_OptionMenuProcessInput(u8 taskId);
|
||||
static void Task_OptionMenuSave(u8 taskId);
|
||||
static void Task_OptionMenuFadeOut(u8 taskId);
|
||||
static void HighlightOptionMenuItem(u8 selection);
|
||||
static u8 TextSpeed_ProcessInput(u8 selection);
|
||||
static void TextSpeed_DrawChoices(u8 selection);
|
||||
static u8 BattleScene_ProcessInput(u8 selection);
|
||||
static void BattleScene_DrawChoices(u8 selection);
|
||||
static u8 BattleStyle_ProcessInput(u8 selection);
|
||||
static void BattleStyle_DrawChoices(u8 selection);
|
||||
static u8 Sound_ProcessInput(u8 selection);
|
||||
static void Sound_DrawChoices(u8 selection);
|
||||
static u8 FrameType_ProcessInput(u8 selection);
|
||||
static void FrameType_DrawChoices(u8 selection);
|
||||
static u8 ButtonMode_ProcessInput(u8 selection);
|
||||
static void ButtonMode_DrawChoices(u8 selection);
|
||||
static void DrawTextOption(void);
|
||||
static void DrawOptionMenuTexts(void);
|
||||
static void sub_80BB154(void);
|
||||
|
||||
// EWRAM vars
|
||||
EWRAM_DATA static bool8 sArrowPressed = FALSE;
|
||||
|
||||
// const rom data
|
||||
static const u16 sUnknown_0855C604[] = INCBIN_U16("graphics/misc/option_menu_text.gbapal");
|
||||
// note: this is only used in the Japanese release
|
||||
static const u8 sEqualSignGfx[] = INCBIN_U8("graphics/misc/option_menu_equals_sign.4bpp");
|
||||
|
||||
static const u8 *const sOptionMenuItemsNames[MENUITEM_COUNT] =
|
||||
{
|
||||
gText_TextSpeed,
|
||||
gText_BattleScene,
|
||||
gText_BattleStyle,
|
||||
gText_Sound,
|
||||
gText_ButtonMode,
|
||||
gText_Frame,
|
||||
gText_OptionMenuCancel,
|
||||
};
|
||||
|
||||
static const struct WindowTemplate sOptionMenuWinTemplates[] =
|
||||
{
|
||||
{1, 2, 1, 0x1A, 2, 1, 2},
|
||||
{0, 2, 5, 0x1A, 0xE, 1, 0x36},
|
||||
DUMMY_WIN_TEMPLATE
|
||||
};
|
||||
|
||||
static const struct BgTemplate sOptionMenuBgTemplates[] =
|
||||
{
|
||||
{
|
||||
.bg = 1,
|
||||
.charBaseIndex = 1,
|
||||
.mapBaseIndex = 30,
|
||||
.screenSize = 0,
|
||||
.paletteMode = 0,
|
||||
.priority = 0,
|
||||
.baseTile = 0
|
||||
},
|
||||
{
|
||||
.bg = 0,
|
||||
.charBaseIndex = 1,
|
||||
.mapBaseIndex = 31,
|
||||
.screenSize = 0,
|
||||
.paletteMode = 0,
|
||||
.priority = 1,
|
||||
.baseTile = 0
|
||||
}
|
||||
};
|
||||
|
||||
static const u16 sUnknown_0855C6A0[] = {0x7E51};
|
||||
|
||||
// code
|
||||
static void MainCB2(void)
|
||||
{
|
||||
RunTasks();
|
||||
AnimateSprites();
|
||||
BuildOamBuffer();
|
||||
UpdatePaletteFade();
|
||||
}
|
||||
|
||||
static void VBlankCB(void)
|
||||
{
|
||||
LoadOam();
|
||||
ProcessSpriteCopyRequests();
|
||||
TransferPlttBuffer();
|
||||
}
|
||||
|
||||
void CB2_InitOptionMenu(void)
|
||||
{
|
||||
switch (gMain.state)
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
SetVBlankCallback(NULL);
|
||||
gMain.state++;
|
||||
break;
|
||||
case 1:
|
||||
{
|
||||
u8 *addr;
|
||||
u32 size;
|
||||
|
||||
addr = (u8 *)VRAM;
|
||||
size = 0x18000;
|
||||
while (1)
|
||||
{
|
||||
DmaFill16(3, 0, addr, 0x1000);
|
||||
addr += 0x1000;
|
||||
size -= 0x1000;
|
||||
if (size <= 0x1000)
|
||||
{
|
||||
DmaFill16(3, 0, addr, size);
|
||||
break;
|
||||
}
|
||||
}
|
||||
DmaClear32(3, OAM, OAM_SIZE);
|
||||
DmaClear16(3, PLTT, PLTT_SIZE);
|
||||
SetGpuReg(REG_OFFSET_DISPCNT, 0);
|
||||
ResetBgsAndClearDma3BusyFlags(0);
|
||||
InitBgsFromTemplates(0, sOptionMenuBgTemplates, ARRAY_COUNT(sOptionMenuBgTemplates));
|
||||
ChangeBgX(0, 0, 0);
|
||||
ChangeBgY(0, 0, 0);
|
||||
ChangeBgX(1, 0, 0);
|
||||
ChangeBgY(1, 0, 0);
|
||||
ChangeBgX(2, 0, 0);
|
||||
ChangeBgY(2, 0, 0);
|
||||
ChangeBgX(3, 0, 0);
|
||||
ChangeBgY(3, 0, 0);
|
||||
InitWindows(sOptionMenuWinTemplates);
|
||||
DeactivateAllTextPrinters();
|
||||
SetGpuReg(REG_OFFSET_WIN0H, 0);
|
||||
SetGpuReg(REG_OFFSET_WIN0V, 0);
|
||||
SetGpuReg(REG_OFFSET_WININ, 1);
|
||||
SetGpuReg(REG_OFFSET_WINOUT, 35);
|
||||
SetGpuReg(REG_OFFSET_BLDCNT, 193);
|
||||
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
|
||||
SetGpuReg(REG_OFFSET_BLDY, 4);
|
||||
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON | DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP);
|
||||
ShowBg(0);
|
||||
ShowBg(1);
|
||||
gMain.state++;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
ResetPaletteFade();
|
||||
ScanlineEffect_Stop();
|
||||
ResetTasks();
|
||||
ResetSpriteData();
|
||||
gMain.state++;
|
||||
break;
|
||||
case 3:
|
||||
LoadBgTiles(1, GetWindowFrameTilesPal(gSaveBlock2Ptr->optionsWindowFrameType)->tiles, 0x120, 0x1A2);
|
||||
gMain.state++;
|
||||
break;
|
||||
case 4:
|
||||
LoadPalette(sUnknown_0855C6A0, 0, sizeof(sUnknown_0855C6A0));
|
||||
LoadPalette(GetWindowFrameTilesPal(gSaveBlock2Ptr->optionsWindowFrameType)->pal, 0x70, 0x20);
|
||||
gMain.state++;
|
||||
break;
|
||||
case 5:
|
||||
LoadPalette(sUnknown_0855C604, 0x10, sizeof(sUnknown_0855C604));
|
||||
gMain.state++;
|
||||
break;
|
||||
case 6:
|
||||
PutWindowTilemap(0);
|
||||
DrawTextOption();
|
||||
gMain.state++;
|
||||
break;
|
||||
case 7:
|
||||
gMain.state++;
|
||||
break;
|
||||
case 8:
|
||||
PutWindowTilemap(1);
|
||||
DrawOptionMenuTexts();
|
||||
gMain.state++;
|
||||
case 9:
|
||||
sub_80BB154();
|
||||
gMain.state++;
|
||||
break;
|
||||
case 10:
|
||||
{
|
||||
u8 taskId = CreateTask(Task_OptionMenuFadeIn, 0);
|
||||
|
||||
gTasks[taskId].data[TD_MENUSELECTION] = 0;
|
||||
gTasks[taskId].data[TD_TEXTSPEED] = gSaveBlock2Ptr->optionsTextSpeed;
|
||||
gTasks[taskId].data[TD_BATTLESCENE] = gSaveBlock2Ptr->optionsBattleSceneOff;
|
||||
gTasks[taskId].data[TD_BATTLESTYLE] = gSaveBlock2Ptr->optionsBattleStyle;
|
||||
gTasks[taskId].data[TD_SOUND] = gSaveBlock2Ptr->optionsSound;
|
||||
gTasks[taskId].data[TD_BUTTONMODE] = gSaveBlock2Ptr->optionsButtonMode;
|
||||
gTasks[taskId].data[TD_FRAMETYPE] = gSaveBlock2Ptr->optionsWindowFrameType;
|
||||
|
||||
TextSpeed_DrawChoices(gTasks[taskId].data[TD_TEXTSPEED]);
|
||||
BattleScene_DrawChoices(gTasks[taskId].data[TD_BATTLESCENE]);
|
||||
BattleStyle_DrawChoices(gTasks[taskId].data[TD_BATTLESTYLE]);
|
||||
Sound_DrawChoices(gTasks[taskId].data[TD_SOUND]);
|
||||
ButtonMode_DrawChoices(gTasks[taskId].data[TD_BUTTONMODE]);
|
||||
FrameType_DrawChoices(gTasks[taskId].data[TD_FRAMETYPE]);
|
||||
HighlightOptionMenuItem(gTasks[taskId].data[TD_MENUSELECTION]);
|
||||
|
||||
CopyWindowToVram(WIN_OPTIONS, 3);
|
||||
gMain.state++;
|
||||
break;
|
||||
}
|
||||
case 11:
|
||||
BeginNormalPaletteFade(-1, 0, 0x10, 0, 0);
|
||||
SetVBlankCallback(VBlankCB);
|
||||
SetMainCallback2(MainCB2);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static void Task_OptionMenuFadeIn(u8 taskId)
|
||||
{
|
||||
if (!gPaletteFade.active)
|
||||
gTasks[taskId].func = Task_OptionMenuProcessInput;
|
||||
}
|
||||
|
||||
static void Task_OptionMenuProcessInput(u8 taskId)
|
||||
{
|
||||
if (gMain.newKeys & A_BUTTON)
|
||||
{
|
||||
if (gTasks[taskId].data[TD_MENUSELECTION] == MENUITEM_CANCEL)
|
||||
gTasks[taskId].func = Task_OptionMenuSave;
|
||||
}
|
||||
else if (gMain.newKeys & B_BUTTON)
|
||||
{
|
||||
gTasks[taskId].func = Task_OptionMenuSave;
|
||||
}
|
||||
else if (gMain.newKeys & DPAD_UP)
|
||||
{
|
||||
if (gTasks[taskId].data[TD_MENUSELECTION] > 0)
|
||||
gTasks[taskId].data[TD_MENUSELECTION]--;
|
||||
else
|
||||
gTasks[taskId].data[TD_MENUSELECTION] = 6;
|
||||
HighlightOptionMenuItem(gTasks[taskId].data[TD_MENUSELECTION]);
|
||||
}
|
||||
else if (gMain.newKeys & DPAD_DOWN)
|
||||
{
|
||||
if (gTasks[taskId].data[TD_MENUSELECTION] <= 5)
|
||||
gTasks[taskId].data[TD_MENUSELECTION]++;
|
||||
else
|
||||
gTasks[taskId].data[TD_MENUSELECTION] = 0;
|
||||
HighlightOptionMenuItem(gTasks[taskId].data[TD_MENUSELECTION]);
|
||||
}
|
||||
else
|
||||
{
|
||||
u8 previousOption;
|
||||
|
||||
switch (gTasks[taskId].data[TD_MENUSELECTION])
|
||||
{
|
||||
case MENUITEM_TEXTSPEED:
|
||||
previousOption = gTasks[taskId].data[TD_TEXTSPEED];
|
||||
gTasks[taskId].data[TD_TEXTSPEED] = TextSpeed_ProcessInput(gTasks[taskId].data[TD_TEXTSPEED]);
|
||||
|
||||
if (previousOption != gTasks[taskId].data[TD_TEXTSPEED])
|
||||
TextSpeed_DrawChoices(gTasks[taskId].data[TD_TEXTSPEED]);
|
||||
break;
|
||||
case MENUITEM_BATTLESCENE:
|
||||
previousOption = gTasks[taskId].data[TD_BATTLESCENE];
|
||||
gTasks[taskId].data[TD_BATTLESCENE] = BattleScene_ProcessInput(gTasks[taskId].data[TD_BATTLESCENE]);
|
||||
|
||||
if (previousOption != gTasks[taskId].data[TD_BATTLESCENE])
|
||||
BattleScene_DrawChoices(gTasks[taskId].data[TD_BATTLESCENE]);
|
||||
break;
|
||||
case MENUITEM_BATTLESTYLE:
|
||||
previousOption = gTasks[taskId].data[TD_BATTLESTYLE];
|
||||
gTasks[taskId].data[TD_BATTLESTYLE] = BattleStyle_ProcessInput(gTasks[taskId].data[TD_BATTLESTYLE]);
|
||||
|
||||
if (previousOption != gTasks[taskId].data[TD_BATTLESTYLE])
|
||||
BattleStyle_DrawChoices(gTasks[taskId].data[TD_BATTLESTYLE]);
|
||||
break;
|
||||
case MENUITEM_SOUND:
|
||||
previousOption = gTasks[taskId].data[TD_SOUND];
|
||||
gTasks[taskId].data[TD_SOUND] = Sound_ProcessInput(gTasks[taskId].data[TD_SOUND]);
|
||||
|
||||
if (previousOption != gTasks[taskId].data[TD_SOUND])
|
||||
Sound_DrawChoices(gTasks[taskId].data[TD_SOUND]);
|
||||
break;
|
||||
case MENUITEM_BUTTONMODE:
|
||||
previousOption = gTasks[taskId].data[TD_BUTTONMODE];
|
||||
gTasks[taskId].data[TD_BUTTONMODE] = ButtonMode_ProcessInput(gTasks[taskId].data[TD_BUTTONMODE]);
|
||||
|
||||
if (previousOption != gTasks[taskId].data[TD_BUTTONMODE])
|
||||
ButtonMode_DrawChoices(gTasks[taskId].data[TD_BUTTONMODE]);
|
||||
break;
|
||||
case MENUITEM_FRAMETYPE:
|
||||
previousOption = gTasks[taskId].data[TD_FRAMETYPE];
|
||||
gTasks[taskId].data[TD_FRAMETYPE] = FrameType_ProcessInput(gTasks[taskId].data[TD_FRAMETYPE]);
|
||||
|
||||
if (previousOption != gTasks[taskId].data[TD_FRAMETYPE])
|
||||
FrameType_DrawChoices(gTasks[taskId].data[TD_FRAMETYPE]);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
if (sArrowPressed)
|
||||
{
|
||||
sArrowPressed = FALSE;
|
||||
CopyWindowToVram(WIN_OPTIONS, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void Task_OptionMenuSave(u8 taskId)
|
||||
{
|
||||
gSaveBlock2Ptr->optionsTextSpeed = gTasks[taskId].data[TD_TEXTSPEED];
|
||||
gSaveBlock2Ptr->optionsBattleSceneOff = gTasks[taskId].data[TD_BATTLESCENE];
|
||||
gSaveBlock2Ptr->optionsBattleStyle = gTasks[taskId].data[TD_BATTLESTYLE];
|
||||
gSaveBlock2Ptr->optionsSound = gTasks[taskId].data[TD_SOUND];
|
||||
gSaveBlock2Ptr->optionsButtonMode = gTasks[taskId].data[TD_BUTTONMODE];
|
||||
gSaveBlock2Ptr->optionsWindowFrameType = gTasks[taskId].data[TD_FRAMETYPE];
|
||||
|
||||
BeginNormalPaletteFade(-1, 0, 0, 0x10, 0);
|
||||
gTasks[taskId].func = Task_OptionMenuFadeOut;
|
||||
}
|
||||
|
||||
static void Task_OptionMenuFadeOut(u8 taskId)
|
||||
{
|
||||
if (!gPaletteFade.active)
|
||||
{
|
||||
DestroyTask(taskId);
|
||||
FreeAllWindowBuffers();
|
||||
SetMainCallback2(gMain.savedCallback);
|
||||
}
|
||||
}
|
||||
|
||||
static void HighlightOptionMenuItem(u8 index)
|
||||
{
|
||||
SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE(16, 224));
|
||||
SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(index * 16 + 40, index * 16 + 56));
|
||||
}
|
||||
|
||||
static void DrawOptionMenuChoice(const u8 *text, u8 x, u8 y, u8 style)
|
||||
{
|
||||
u8 dst[16];
|
||||
u16 i;
|
||||
|
||||
for (i = 0; *text != EOS && i <= 14; i++)
|
||||
dst[i] = *(text++);
|
||||
|
||||
if (style != 0)
|
||||
{
|
||||
dst[2] = 4;
|
||||
dst[5] = 5;
|
||||
}
|
||||
|
||||
dst[i] = EOS;
|
||||
PrintTextOnWindow(WIN_OPTIONS, 1, dst, x, y + 1, TEXT_SPEED_FF, NULL);
|
||||
}
|
||||
|
||||
static u8 TextSpeed_ProcessInput(u8 selection)
|
||||
{
|
||||
if (gMain.newKeys & DPAD_RIGHT)
|
||||
{
|
||||
if (selection <= 1)
|
||||
selection++;
|
||||
else
|
||||
selection = 0;
|
||||
|
||||
sArrowPressed = TRUE;
|
||||
}
|
||||
if (gMain.newKeys & DPAD_LEFT)
|
||||
{
|
||||
if (selection != 0)
|
||||
selection--;
|
||||
else
|
||||
selection = 2;
|
||||
|
||||
sArrowPressed = TRUE;
|
||||
}
|
||||
return selection;
|
||||
}
|
||||
|
||||
static void TextSpeed_DrawChoices(u8 selection)
|
||||
{
|
||||
u8 styles[3];
|
||||
s32 widthSlow, widthMid, widthFast, xMid;
|
||||
|
||||
styles[0] = 0;
|
||||
styles[1] = 0;
|
||||
styles[2] = 0;
|
||||
styles[selection] = 1;
|
||||
|
||||
DrawOptionMenuChoice(gText_TextSpeedSlow, 104, 0, styles[0]);
|
||||
|
||||
widthSlow = GetStringWidth(1, gText_TextSpeedSlow, 0);
|
||||
widthMid = GetStringWidth(1, gText_TextSpeedMid, 0);
|
||||
widthFast = GetStringWidth(1, gText_TextSpeedFast, 0);
|
||||
|
||||
widthMid -= 94;
|
||||
xMid = (widthSlow - widthMid - widthFast) / 2 + 104;
|
||||
DrawOptionMenuChoice(gText_TextSpeedMid, xMid, 0, styles[1]);
|
||||
|
||||
DrawOptionMenuChoice(gText_TextSpeedFast, GetStringRightAlignXOffset(1, gText_TextSpeedFast, 198), 0, styles[2]);
|
||||
}
|
||||
|
||||
static u8 BattleScene_ProcessInput(u8 selection)
|
||||
{
|
||||
if (gMain.newKeys & (DPAD_LEFT | DPAD_RIGHT))
|
||||
{
|
||||
selection ^= 1;
|
||||
sArrowPressed = TRUE;
|
||||
}
|
||||
|
||||
return selection;
|
||||
}
|
||||
|
||||
static void BattleScene_DrawChoices(u8 selection)
|
||||
{
|
||||
u8 styles[2];
|
||||
|
||||
styles[0] = 0;
|
||||
styles[1] = 0;
|
||||
styles[selection] = 1;
|
||||
|
||||
DrawOptionMenuChoice(gText_BattleSceneOn, 104, 16, styles[0]);
|
||||
DrawOptionMenuChoice(gText_BattleSceneOff, GetStringRightAlignXOffset(1, gText_BattleSceneOff, 198), 16, styles[1]);
|
||||
}
|
||||
|
||||
static u8 BattleStyle_ProcessInput(u8 selection)
|
||||
{
|
||||
if (gMain.newKeys & (DPAD_LEFT | DPAD_RIGHT))
|
||||
{
|
||||
selection ^= 1;
|
||||
sArrowPressed = TRUE;
|
||||
}
|
||||
|
||||
return selection;
|
||||
}
|
||||
|
||||
static void BattleStyle_DrawChoices(u8 selection)
|
||||
{
|
||||
u8 styles[2];
|
||||
|
||||
styles[0] = 0;
|
||||
styles[1] = 0;
|
||||
styles[selection] = 1;
|
||||
|
||||
DrawOptionMenuChoice(gText_BattleStyleShift, 104, 32, styles[0]);
|
||||
DrawOptionMenuChoice(gText_BattleStyleSet, GetStringRightAlignXOffset(1, gText_BattleStyleSet, 198), 32, styles[1]);
|
||||
}
|
||||
|
||||
static u8 Sound_ProcessInput(u8 selection)
|
||||
{
|
||||
if (gMain.newKeys & (DPAD_LEFT | DPAD_RIGHT))
|
||||
{
|
||||
selection ^= 1;
|
||||
SetPokemonCryStereo(selection);
|
||||
sArrowPressed = TRUE;
|
||||
}
|
||||
|
||||
return selection;
|
||||
}
|
||||
|
||||
static void Sound_DrawChoices(u8 selection)
|
||||
{
|
||||
u8 styles[2];
|
||||
|
||||
styles[0] = 0;
|
||||
styles[1] = 0;
|
||||
styles[selection] = 1;
|
||||
|
||||
DrawOptionMenuChoice(gText_SoundMono, 104, 48, styles[0]);
|
||||
DrawOptionMenuChoice(gText_SoundStereo, GetStringRightAlignXOffset(1, gText_SoundStereo, 198), 48, styles[1]);
|
||||
}
|
||||
|
||||
static u8 FrameType_ProcessInput(u8 selection)
|
||||
{
|
||||
if (gMain.newKeys & DPAD_RIGHT)
|
||||
{
|
||||
if (selection < WINDOW_FRAMES_COUNT - 1)
|
||||
selection++;
|
||||
else
|
||||
selection = 0;
|
||||
|
||||
LoadBgTiles(1, GetWindowFrameTilesPal(selection)->tiles, 0x120, 0x1A2);
|
||||
LoadPalette(GetWindowFrameTilesPal(selection)->pal, 0x70, 0x20);
|
||||
sArrowPressed = TRUE;
|
||||
}
|
||||
if (gMain.newKeys & DPAD_LEFT)
|
||||
{
|
||||
if (selection != 0)
|
||||
selection--;
|
||||
else
|
||||
selection = WINDOW_FRAMES_COUNT - 1;
|
||||
|
||||
LoadBgTiles(1, GetWindowFrameTilesPal(selection)->tiles, 0x120, 0x1A2);
|
||||
LoadPalette(GetWindowFrameTilesPal(selection)->pal, 0x70, 0x20);
|
||||
sArrowPressed = TRUE;
|
||||
}
|
||||
return selection;
|
||||
}
|
||||
|
||||
static void FrameType_DrawChoices(u8 selection)
|
||||
{
|
||||
u8 text[16];
|
||||
u8 n = selection + 1;
|
||||
u16 i;
|
||||
|
||||
for (i = 0; gText_FrameTypeNumber[i] != EOS && i <= 5; i++)
|
||||
text[i] = gText_FrameTypeNumber[i];
|
||||
|
||||
// Convert a number to decimal string
|
||||
if (n / 10 != 0)
|
||||
{
|
||||
text[i] = n / 10 + CHAR_0;
|
||||
i++;
|
||||
text[i] = n % 10 + CHAR_0;
|
||||
i++;
|
||||
}
|
||||
else
|
||||
{
|
||||
text[i] = n % 10 + CHAR_0;
|
||||
i++;
|
||||
text[i] = 0x77;
|
||||
i++;
|
||||
}
|
||||
|
||||
text[i] = EOS;
|
||||
|
||||
DrawOptionMenuChoice(gText_FrameType, 104, 80, 0);
|
||||
DrawOptionMenuChoice(text, 128, 80, 1);
|
||||
}
|
||||
|
||||
static u8 ButtonMode_ProcessInput(u8 selection)
|
||||
{
|
||||
if (gMain.newKeys & DPAD_RIGHT)
|
||||
{
|
||||
if (selection <= 1)
|
||||
selection++;
|
||||
else
|
||||
selection = 0;
|
||||
|
||||
sArrowPressed = TRUE;
|
||||
}
|
||||
if (gMain.newKeys & DPAD_LEFT)
|
||||
{
|
||||
if (selection != 0)
|
||||
selection--;
|
||||
else
|
||||
selection = 2;
|
||||
|
||||
sArrowPressed = TRUE;
|
||||
}
|
||||
return selection;
|
||||
}
|
||||
|
||||
static void ButtonMode_DrawChoices(u8 selection)
|
||||
{
|
||||
s32 widthNormal, widthLR, widthLA, xLR;
|
||||
u8 styles[3];
|
||||
|
||||
styles[0] = 0;
|
||||
styles[1] = 0;
|
||||
styles[2] = 0;
|
||||
styles[selection] = 1;
|
||||
|
||||
DrawOptionMenuChoice(gText_ButtonTypeNormal, 104, 64, styles[0]);
|
||||
|
||||
widthNormal = GetStringWidth(1, gText_ButtonTypeNormal, 0);
|
||||
widthLR = GetStringWidth(1, gText_ButtonTypeLR, 0);
|
||||
widthLA = GetStringWidth(1, gText_ButtonTypeLEqualsA, 0);
|
||||
|
||||
widthLR -= 94;
|
||||
xLR = (widthNormal - widthLR - widthLA) / 2 + 104;
|
||||
DrawOptionMenuChoice(gText_ButtonTypeLR, xLR, 64, styles[1]);
|
||||
|
||||
DrawOptionMenuChoice(gText_ButtonTypeLEqualsA, GetStringRightAlignXOffset(1, gText_ButtonTypeLEqualsA, 198), 64, styles[2]);
|
||||
}
|
||||
|
||||
static void DrawTextOption(void)
|
||||
{
|
||||
FillWindowPixelBuffer(WIN_TEXT_OPTION, 0x11);
|
||||
PrintTextOnWindow(WIN_TEXT_OPTION, 1, gText_Option, 8, 1, TEXT_SPEED_FF, NULL);
|
||||
CopyWindowToVram(WIN_TEXT_OPTION, 3);
|
||||
}
|
||||
|
||||
static void DrawOptionMenuTexts(void)
|
||||
{
|
||||
u8 i;
|
||||
|
||||
FillWindowPixelBuffer(WIN_OPTIONS, 0x11);
|
||||
for (i = 0; i < MENUITEM_COUNT; i++)
|
||||
{
|
||||
PrintTextOnWindow(WIN_OPTIONS, 1, sOptionMenuItemsNames[i], 8, (i * 16) + 1, TEXT_SPEED_FF, NULL);
|
||||
}
|
||||
CopyWindowToVram(WIN_OPTIONS, 3);
|
||||
}
|
||||
|
||||
static void sub_80BB154(void)
|
||||
{
|
||||
// bg, tileNum, x, y, width, height, pal
|
||||
FillBgTilemapBufferRect(1, 0x1A2, 1, 0, 1, 1, 7);
|
||||
FillBgTilemapBufferRect(1, 0x1A3, 2, 0, 0x1B, 1, 7);
|
||||
FillBgTilemapBufferRect(1, 0x1A4, 28, 0, 1, 1, 7);
|
||||
FillBgTilemapBufferRect(1, 0x1A5, 1, 1, 1, 2, 7);
|
||||
FillBgTilemapBufferRect(1, 0x1A7, 28, 1, 1, 2, 7);
|
||||
FillBgTilemapBufferRect(1, 0x1A8, 1, 3, 1, 1, 7);
|
||||
FillBgTilemapBufferRect(1, 0x1A9, 2, 3, 0x1B, 1, 7);
|
||||
FillBgTilemapBufferRect(1, 0x1AA, 28, 3, 1, 1, 7);
|
||||
FillBgTilemapBufferRect(1, 0x1A2, 1, 4, 1, 1, 7);
|
||||
FillBgTilemapBufferRect(1, 0x1A3, 2, 4, 0x1A, 1, 7);
|
||||
FillBgTilemapBufferRect(1, 0x1A4, 28, 4, 1, 1, 7);
|
||||
FillBgTilemapBufferRect(1, 0x1A5, 1, 5, 1, 0x12, 7);
|
||||
FillBgTilemapBufferRect(1, 0x1A7, 28, 5, 1, 0x12, 7);
|
||||
FillBgTilemapBufferRect(1, 0x1A8, 1, 19, 1, 1, 7);
|
||||
FillBgTilemapBufferRect(1, 0x1A9, 2, 19, 0x1A, 1, 7);
|
||||
FillBgTilemapBufferRect(1, 0x1AA, 28, 19, 1, 1, 7);
|
||||
|
||||
CopyBgTilemapBufferToVram(1);
|
||||
}
|
||||
@@ -419,7 +419,7 @@ static bool8 InitPokeblockMenu(void)
|
||||
gMain.state++;
|
||||
break;
|
||||
case 1:
|
||||
remove_some_task();
|
||||
ScanlineEffect_Stop();
|
||||
gMain.state++;
|
||||
break;
|
||||
case 2:
|
||||
|
||||
4
src/pokemon_summary_screen.c
Executable file → Normal file
4
src/pokemon_summary_screen.c
Executable file → Normal file
@@ -75,7 +75,7 @@ extern u8 sub_81221AC();
|
||||
extern void SetVBlankHBlankCallbacksToNull();
|
||||
extern void ResetVramOamAndBgCntRegs();
|
||||
extern void clear_scheduled_bg_copies_to_vram();
|
||||
extern void remove_some_task();
|
||||
extern void ScanlineEffect_Stop();
|
||||
extern void ResetBgsAndClearDma3BusyFlags(u32 leftoverFireRedLeafGreenVariable);
|
||||
extern void ShowBg(u8 a);
|
||||
extern void SetGpuReg(u8 regOffset, u16 value);
|
||||
@@ -455,7 +455,7 @@ bool8 sub_81BFB10(void)
|
||||
gMain.state++;
|
||||
break;
|
||||
case 1:
|
||||
remove_some_task();
|
||||
ScanlineEffect_Stop();
|
||||
gMain.state++;
|
||||
break;
|
||||
case 2:
|
||||
|
||||
7
src/save_failed_screen.c
Executable file → Normal file
7
src/save_failed_screen.c
Executable file → Normal file
@@ -9,6 +9,7 @@
|
||||
#include "menu.h"
|
||||
#include "save.h"
|
||||
#include "gba/flash_internal.h"
|
||||
#include "text_window.h"
|
||||
|
||||
#define MSG_WIN_TOP 12
|
||||
#define CLOCK_WIN_TOP (MSG_WIN_TOP - 4)
|
||||
@@ -21,9 +22,7 @@ extern const u8 gBirchHelpGfx[];
|
||||
extern const u8 gBirchBagTilemap[];
|
||||
extern const u8 gBirchGrassTilemap[];
|
||||
extern const u16 gBirchBagGrassPal[];
|
||||
extern const u16 gUnknown_0850FEFC[];
|
||||
extern const u16 gUnknown_0860F074[];
|
||||
extern const u32 gUnknown_0850E87C[];
|
||||
extern struct SaveSection gSaveDataBuffer;
|
||||
|
||||
extern u8 gText_SaveFailedCheckingBackup[];
|
||||
@@ -226,7 +225,7 @@ static void CB2_SaveFailedScreen(void)
|
||||
InitBgsFromTemplates(0, gUnknown_085EFD88, 3);
|
||||
SetBgTilemapBuffer(0, (void *)&gDecompressionBuffer[0x2000]);
|
||||
CpuFill32(0, &gDecompressionBuffer[0x2000], 0x800);
|
||||
LoadBgTiles(0, gUnknown_0850E87C, 0x120, 0x214);
|
||||
LoadBgTiles(0, gTextWindowFrame1_Gfx, 0x120, 0x214);
|
||||
InitWindows(gUnknown_085EFD94);
|
||||
// AddWindowWithoutTileMap returns a u16/integer, but the info is clobbered into a u8 here resulting in lost info. Bug?
|
||||
gSaveFailedWindowIds[TEXT_WIN_ID] = AddWindowWithoutTileMap(gUnknown_085EFD9C);
|
||||
@@ -239,7 +238,7 @@ static void CB2_SaveFailedScreen(void)
|
||||
ResetPaletteFade();
|
||||
LoadPalette(gBirchBagGrassPal, 0, 0x40);
|
||||
LoadPalette(sSaveFailedClockPal, 0x100, 0x20);
|
||||
LoadPalette(gUnknown_0850FEFC, 0xE0, 0x20);
|
||||
LoadPalette(gTextWindowFrame1_Pal, 0xE0, 0x20);
|
||||
LoadPalette(gUnknown_0860F074, 0xF0, 0x20);
|
||||
SetWindowBorderStyle(gSaveFailedWindowIds[TEXT_WIN_ID], FALSE, 0x214, 0xE);
|
||||
SetWindowBorderStyle(gSaveFailedWindowIds[CLOCK_WIN_ID], FALSE, 0x214, 0xE);
|
||||
|
||||
0
src/save_location.c
Executable file → Normal file
0
src/save_location.c
Executable file → Normal file
@@ -53,7 +53,7 @@ extern const u8 gUnknown_085B1E0C[];
|
||||
extern const u8 gUnknown_085B1E28[][2];
|
||||
|
||||
extern void sub_809882C(u8, u16, u8);
|
||||
extern void remove_some_task(void);
|
||||
extern void ScanlineEffect_Stop(void);
|
||||
extern void clear_scheduled_bg_copies_to_vram(void);
|
||||
extern void dp13_810BB8C(void);
|
||||
extern void do_scheduled_bg_tilemap_copies_to_vram(void);
|
||||
@@ -74,7 +74,7 @@ static void Task_MoveStarterChooseCursor(u8 taskId);
|
||||
static void sub_8134668(u8 taskId);
|
||||
static void CreateStarterPokemonLabel(u8 selection);
|
||||
static u8 CreatePokemonFrontSprite(u16 species, u8 x, u8 y);
|
||||
static void StarterPokemonSpriteCallback(struct Sprite *sprite);
|
||||
void StarterPokemonSpriteCallback(struct Sprite *sprite);
|
||||
|
||||
static IWRAM_DATA u16 sStarterChooseWindowId;
|
||||
|
||||
@@ -134,7 +134,7 @@ void CB2_ChooseStarter(void)
|
||||
DeactivateAllTextPrinters();
|
||||
sub_809882C(0, 0x2A8, 0xD0);
|
||||
clear_scheduled_bg_copies_to_vram();
|
||||
remove_some_task();
|
||||
ScanlineEffect_Stop();
|
||||
ResetTasks();
|
||||
ResetSpriteData();
|
||||
ResetPaletteFade();
|
||||
@@ -361,7 +361,7 @@ static u8 CreatePokemonFrontSprite(u16 species, u8 x, u8 y)
|
||||
return spriteId;
|
||||
}
|
||||
|
||||
static void sub_81346DC(struct Sprite *sprite)
|
||||
void sub_81346DC(struct Sprite *sprite)
|
||||
{
|
||||
sprite->pos1.x = gUnknown_085B1E28[gTasks[sprite->data[0]].tStarterSelection][0];
|
||||
sprite->pos1.y = gUnknown_085B1E28[gTasks[sprite->data[0]].tStarterSelection][1];
|
||||
@@ -369,7 +369,7 @@ static void sub_81346DC(struct Sprite *sprite)
|
||||
sprite->data[1] = (u8)(sprite->data[1]) + 4;
|
||||
}
|
||||
|
||||
static void sub_813473C(struct Sprite *sprite)
|
||||
void sub_813473C(struct Sprite *sprite)
|
||||
{
|
||||
if (gTasks[sprite->data[0]].tStarterSelection == sprite->data[1])
|
||||
StartSpriteAnimIfDifferent(sprite, 1);
|
||||
@@ -377,7 +377,7 @@ static void sub_813473C(struct Sprite *sprite)
|
||||
StartSpriteAnimIfDifferent(sprite, 0);
|
||||
}
|
||||
|
||||
static void StarterPokemonSpriteCallback(struct Sprite *sprite)
|
||||
void StarterPokemonSpriteCallback(struct Sprite *sprite)
|
||||
{
|
||||
//Move sprite to upper center of screen
|
||||
if (sprite->pos1.x > STARTER_PKMN_POS_X)
|
||||
|
||||
@@ -3,26 +3,97 @@
|
||||
#include "text_window.h"
|
||||
#include "window.h"
|
||||
#include "palette.h"
|
||||
#include "bg.h"
|
||||
#include "graphics.h"
|
||||
|
||||
extern u8 LoadBgTiles(u8 bg, const void *src, u16 size, u16 destOffset);
|
||||
extern void FillBgTilemapBufferRect(u8 bg, u16 tileNum, u8 x, u8 y, u8 width, u8 height, u8 palette);
|
||||
// const rom data
|
||||
const u32 gTextWindowFrame1_Gfx[] = INCBIN_U32("graphics/text_window/1.4bpp");
|
||||
static const u32 sTextWindowFrame2_Gfx[] = INCBIN_U32("graphics/text_window/2.4bpp");
|
||||
static const u32 sTextWindowFrame3_Gfx[] = INCBIN_U32("graphics/text_window/3.4bpp");
|
||||
static const u32 sTextWindowFrame4_Gfx[] = INCBIN_U32("graphics/text_window/4.4bpp");
|
||||
static const u32 sTextWindowFrame5_Gfx[] = INCBIN_U32("graphics/text_window/5.4bpp");
|
||||
static const u32 sTextWindowFrame6_Gfx[] = INCBIN_U32("graphics/text_window/6.4bpp");
|
||||
static const u32 sTextWindowFrame7_Gfx[] = INCBIN_U32("graphics/text_window/7.4bpp");
|
||||
static const u32 sTextWindowFrame8_Gfx[] = INCBIN_U32("graphics/text_window/8.4bpp");
|
||||
static const u32 sTextWindowFrame9_Gfx[] = INCBIN_U32("graphics/text_window/9.4bpp");
|
||||
static const u32 sTextWindowFrame10_Gfx[] = INCBIN_U32("graphics/text_window/10.4bpp");
|
||||
static const u32 sTextWindowFrame11_Gfx[] = INCBIN_U32("graphics/text_window/11.4bpp");
|
||||
static const u32 sTextWindowFrame12_Gfx[] = INCBIN_U32("graphics/text_window/12.4bpp");
|
||||
static const u32 sTextWindowFrame13_Gfx[] = INCBIN_U32("graphics/text_window/13.4bpp");
|
||||
static const u32 sTextWindowFrame14_Gfx[] = INCBIN_U32("graphics/text_window/14.4bpp");
|
||||
static const u32 sTextWindowFrame15_Gfx[] = INCBIN_U32("graphics/text_window/15.4bpp");
|
||||
static const u32 sTextWindowFrame16_Gfx[] = INCBIN_U32("graphics/text_window/16.4bpp");
|
||||
static const u32 sTextWindowFrame17_Gfx[] = INCBIN_U32("graphics/text_window/17.4bpp");
|
||||
static const u32 sTextWindowFrame18_Gfx[] = INCBIN_U32("graphics/text_window/18.4bpp");
|
||||
static const u32 sTextWindowFrame19_Gfx[] = INCBIN_U32("graphics/text_window/19.4bpp");
|
||||
static const u32 sTextWindowFrame20_Gfx[] = INCBIN_U32("graphics/text_window/20.4bpp");
|
||||
|
||||
extern const struct TilesPal gUnknown_0851021C[];
|
||||
extern const u32 gUnknown_08DDD748[];
|
||||
extern const u16 gUnknown_0851017C[];
|
||||
extern const u16 gUnknown_08DDD728[];
|
||||
const u16 gTextWindowFrame1_Pal[] = INCBIN_U16("graphics/text_window/1.gbapal");
|
||||
static const u16 sTextWindowFrame2_Pal[] = INCBIN_U16("graphics/text_window/2.gbapal");
|
||||
static const u16 sTextWindowFrame3_Pal[] = INCBIN_U16("graphics/text_window/3.gbapal");
|
||||
static const u16 sTextWindowFrame4_Pal[] = INCBIN_U16("graphics/text_window/4.gbapal");
|
||||
static const u16 sTextWindowFrame5_Pal[] = INCBIN_U16("graphics/text_window/5.gbapal");
|
||||
static const u16 sTextWindowFrame6_Pal[] = INCBIN_U16("graphics/text_window/6.gbapal");
|
||||
static const u16 sTextWindowFrame7_Pal[] = INCBIN_U16("graphics/text_window/7.gbapal");
|
||||
static const u16 sTextWindowFrame8_Pal[] = INCBIN_U16("graphics/text_window/8.gbapal");
|
||||
static const u16 sTextWindowFrame9_Pal[] = INCBIN_U16("graphics/text_window/9.gbapal");
|
||||
static const u16 sTextWindowFrame10_Pal[] = INCBIN_U16("graphics/text_window/10.gbapal");
|
||||
static const u16 sTextWindowFrame11_Pal[] = INCBIN_U16("graphics/text_window/11.gbapal");
|
||||
static const u16 sTextWindowFrame12_Pal[] = INCBIN_U16("graphics/text_window/12.gbapal");
|
||||
static const u16 sTextWindowFrame13_Pal[] = INCBIN_U16("graphics/text_window/13.gbapal");
|
||||
static const u16 sTextWindowFrame14_Pal[] = INCBIN_U16("graphics/text_window/14.gbapal");
|
||||
static const u16 sTextWindowFrame15_Pal[] = INCBIN_U16("graphics/text_window/15.gbapal");
|
||||
static const u16 sTextWindowFrame16_Pal[] = INCBIN_U16("graphics/text_window/16.gbapal");
|
||||
static const u16 sTextWindowFrame17_Pal[] = INCBIN_U16("graphics/text_window/17.gbapal");
|
||||
static const u16 sTextWindowFrame18_Pal[] = INCBIN_U16("graphics/text_window/18.gbapal");
|
||||
static const u16 sTextWindowFrame19_Pal[] = INCBIN_U16("graphics/text_window/19.gbapal");
|
||||
static const u16 sTextWindowFrame20_Pal[] = INCBIN_U16("graphics/text_window/20.gbapal");
|
||||
|
||||
const struct TilesPal* sub_8098758(u8 id)
|
||||
static const u16 sUnknown_0851017C[][16] =
|
||||
{
|
||||
if (id > 19)
|
||||
return &gUnknown_0851021C[0];
|
||||
INCBIN_U16("graphics/text_window/message_box.gbapal"),
|
||||
INCBIN_U16("graphics/text_window/text_pal1.gbapal"),
|
||||
INCBIN_U16("graphics/text_window/text_pal2.gbapal"),
|
||||
INCBIN_U16("graphics/text_window/text_pal3.gbapal"),
|
||||
INCBIN_U16("graphics/text_window/text_pal4.gbapal")
|
||||
};
|
||||
|
||||
static const struct TilesPal sWindowFrames[WINDOW_FRAMES_COUNT] =
|
||||
{
|
||||
{gTextWindowFrame1_Gfx, gTextWindowFrame1_Pal},
|
||||
{sTextWindowFrame2_Gfx, sTextWindowFrame2_Pal},
|
||||
{sTextWindowFrame3_Gfx, sTextWindowFrame3_Pal},
|
||||
{sTextWindowFrame4_Gfx, sTextWindowFrame4_Pal},
|
||||
{sTextWindowFrame5_Gfx, sTextWindowFrame5_Pal},
|
||||
{sTextWindowFrame6_Gfx, sTextWindowFrame6_Pal},
|
||||
{sTextWindowFrame7_Gfx, sTextWindowFrame7_Pal},
|
||||
{sTextWindowFrame8_Gfx, sTextWindowFrame8_Pal},
|
||||
{sTextWindowFrame9_Gfx, sTextWindowFrame9_Pal},
|
||||
{sTextWindowFrame10_Gfx, sTextWindowFrame10_Pal},
|
||||
{sTextWindowFrame11_Gfx, sTextWindowFrame11_Pal},
|
||||
{sTextWindowFrame12_Gfx, sTextWindowFrame12_Pal},
|
||||
{sTextWindowFrame13_Gfx, sTextWindowFrame13_Pal},
|
||||
{sTextWindowFrame14_Gfx, sTextWindowFrame14_Pal},
|
||||
{sTextWindowFrame15_Gfx, sTextWindowFrame15_Pal},
|
||||
{sTextWindowFrame16_Gfx, sTextWindowFrame16_Pal},
|
||||
{sTextWindowFrame17_Gfx, sTextWindowFrame17_Pal},
|
||||
{sTextWindowFrame18_Gfx, sTextWindowFrame18_Pal},
|
||||
{sTextWindowFrame19_Gfx, sTextWindowFrame19_Pal},
|
||||
{sTextWindowFrame20_Gfx, sTextWindowFrame20_Pal}
|
||||
};
|
||||
|
||||
// code
|
||||
const struct TilesPal *GetWindowFrameTilesPal(u8 id)
|
||||
{
|
||||
if (id >= WINDOW_FRAMES_COUNT)
|
||||
return &sWindowFrames[0];
|
||||
else
|
||||
return &gUnknown_0851021C[id];
|
||||
return &sWindowFrames[id];
|
||||
}
|
||||
|
||||
void copy_textbox_border_tile_patterns_to_vram(u8 windowId, u16 destOffset, u8 palOffset)
|
||||
{
|
||||
LoadBgTiles(GetWindowAttribute(windowId, WINDOW_PRIORITY), gUnknown_08DDD748, 0x1C0, destOffset);
|
||||
LoadBgTiles(GetWindowAttribute(windowId, WINDOW_PRIORITY), gMessageBox_Gfx, 0x1C0, destOffset);
|
||||
LoadPalette(GetOverworldTextboxPalettePtr(), palOffset, 0x20);
|
||||
}
|
||||
|
||||
@@ -33,8 +104,8 @@ void box_border_load_tiles_and_pal(u8 windowId, u16 destOffset, u8 palOffset)
|
||||
|
||||
void sub_80987D4(u8 windowId, u8 frameId, u16 destOffset, u8 palOffset)
|
||||
{
|
||||
LoadBgTiles(GetWindowAttribute(windowId, WINDOW_PRIORITY), gUnknown_0851021C[frameId].tiles, 0x120, destOffset);
|
||||
LoadPalette(gUnknown_0851021C[frameId].pal, palOffset, 0x20);
|
||||
LoadBgTiles(GetWindowAttribute(windowId, WINDOW_PRIORITY), sWindowFrames[frameId].tiles, 0x120, destOffset);
|
||||
LoadPalette(sWindowFrames[frameId].pal, palOffset, 0x20);
|
||||
}
|
||||
|
||||
void sub_809882C(u8 windowId, u16 destOffset, u8 palOffset)
|
||||
@@ -89,7 +160,7 @@ void rbox_fill_rectangle(u8 windowId)
|
||||
FillBgTilemapBufferRect(bgLayer, 0, tilemapLeft - 1, tilemapTop - 1, width + 2, height + 2, 0x11);
|
||||
}
|
||||
|
||||
const u16* stdpal_get(u8 id)
|
||||
const u16 *stdpal_get(u8 id)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
@@ -110,16 +181,17 @@ const u16* stdpal_get(u8 id)
|
||||
id = 0x40;
|
||||
break;
|
||||
}
|
||||
return &gUnknown_0851017C[id];
|
||||
|
||||
return (const u16 *)(sUnknown_0851017C) + id;
|
||||
}
|
||||
|
||||
const u16* GetOverworldTextboxPalettePtr(void)
|
||||
const u16 *GetOverworldTextboxPalettePtr(void)
|
||||
{
|
||||
return gUnknown_08DDD728;
|
||||
return gMessageBox_Pal;
|
||||
}
|
||||
|
||||
void sub_8098C6C(u8 bg, u16 destOffset, u8 palOffset)
|
||||
{
|
||||
LoadBgTiles(bg, gUnknown_0851021C[gSaveBlock2Ptr->optionsWindowFrameType].tiles, 0x120, destOffset);
|
||||
LoadPalette(sub_8098758(gSaveBlock2Ptr->optionsWindowFrameType)->pal, palOffset, 0x20);
|
||||
LoadBgTiles(bg, sWindowFrames[gSaveBlock2Ptr->optionsWindowFrameType].tiles, 0x120, destOffset);
|
||||
LoadPalette(GetWindowFrameTilesPal(gSaveBlock2Ptr->optionsWindowFrameType)->pal, palOffset, 0x20);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "blend_palette.h"
|
||||
#include "battle_transition.h"
|
||||
#include "task.h"
|
||||
#include "battle_transition.h"
|
||||
|
||||
// Static type declarations
|
||||
|
||||
@@ -1392,7 +1393,7 @@ static void sub_80A1818(u16 a1)
|
||||
{
|
||||
CpuCopy16(gTilesetAnims_BattleDomePals0[a1 & 0x3], gPlttBufferUnfaded + 0x80, 32);
|
||||
BlendPalette(0x80, 0x10, gPaletteFade.y, gPaletteFade.blendColor & 0x7FFF);
|
||||
if ((u8)FindTaskIdByFunc(sub_8149DFC) != 0xFF )
|
||||
if ((u8)FindTaskIdByFunc(TransitionPhase1_Task_RunFuncs) != 0xFF )
|
||||
{
|
||||
sSecondaryTilesetCB = sub_80A1670;
|
||||
sSecondaryTilesetCBBufferSize = 0x20;
|
||||
@@ -1402,7 +1403,7 @@ static void sub_80A1818(u16 a1)
|
||||
static void sub_80A1884(u16 a1)
|
||||
{
|
||||
CpuCopy16(gTilesetAnims_BattleDomePals0[a1 & 0x3], gPlttBufferUnfaded + 0x80, 32);
|
||||
if ((u8)FindTaskIdByFunc(sub_8149DFC) == 0xFF )
|
||||
if ((u8)FindTaskIdByFunc(TransitionPhase1_Task_RunFuncs) == 0xFF )
|
||||
{
|
||||
BlendPalette(0x80, 0x10, gPaletteFade.y, gPaletteFade.blendColor & 0x7FFF);
|
||||
if (!--sSecondaryTilesetCBBufferSize)
|
||||
|
||||
633
src/unk_transition.c
Normal file
633
src/unk_transition.c
Normal file
@@ -0,0 +1,633 @@
|
||||
#include "global.h"
|
||||
#include "sprite.h"
|
||||
#include "decompress.h"
|
||||
#include "unk_transition.h"
|
||||
#include "battle_transition.h"
|
||||
#include "task.h"
|
||||
#include "palette.h"
|
||||
#include "trig.h"
|
||||
#include "bg.h"
|
||||
#include "gpu_regs.h"
|
||||
|
||||
typedef bool8 (*TransitionStateFunc)(struct Task *task);
|
||||
|
||||
// this file's functions
|
||||
static void sub_81DA848(struct Sprite *sprite);
|
||||
static void sub_81DA9BC(struct Sprite *sprite);
|
||||
static bool8 sub_81DAACC(struct Task *task);
|
||||
static bool8 sub_81DAC14(struct Task *task);
|
||||
static bool8 sub_81DABBC(struct Task *task);
|
||||
static bool8 sub_81DAB4C(struct Task *task);
|
||||
static bool8 sub_81DAC80(struct Task *task);
|
||||
static bool8 sub_81DACEC(struct Task *task);
|
||||
static bool8 sub_81DAD58(struct Task *task);
|
||||
static bool8 sub_81DADC4(struct Task *task);
|
||||
static bool8 sub_81DAE44(struct Task *task);
|
||||
static bool8 sub_81DAEB0(struct Task *task);
|
||||
static bool8 sub_81DAF34(struct Task *task);
|
||||
static bool8 sub_81DAFA0(struct Task *task);
|
||||
static bool8 sub_81DB02C(struct Task *task);
|
||||
static bool8 sub_81DB098(struct Task *task);
|
||||
static bool8 sub_81DB124(struct Task *task);
|
||||
static bool8 sub_81DB190(struct Task *task);
|
||||
static bool8 sub_81DB224(struct Task *task);
|
||||
static bool8 sub_81DB290(struct Task *task);
|
||||
static bool8 sub_81DB328(struct Task *task);
|
||||
|
||||
// const rom data
|
||||
// TODO: move those from .s file to .c
|
||||
extern const u8 gUnknown_0862AD54[];
|
||||
extern const u8 gUnknown_0862AF30[];
|
||||
extern const u8 gUnknown_0862B0DC[];
|
||||
extern const u16 gUnknown_0862B53C[];
|
||||
|
||||
static const struct OamData sOamData_862B71C =
|
||||
{
|
||||
.y = 0,
|
||||
.affineMode = 0,
|
||||
.objMode = 0,
|
||||
.mosaic = 0,
|
||||
.bpp = 0,
|
||||
.shape = 0,
|
||||
.x = 0,
|
||||
.matrixNum = 0,
|
||||
.size = 3,
|
||||
.tileNum = 0,
|
||||
.priority = 1,
|
||||
.paletteNum = 0,
|
||||
.affineParam = 0
|
||||
};
|
||||
|
||||
static const struct CompressedSpriteSheet sUnknown_0862B724 =
|
||||
{
|
||||
gUnknown_0862B0DC, 0x1800, 11920
|
||||
};
|
||||
|
||||
static const struct SpritePalette sUnknown_0862B72C =
|
||||
{
|
||||
gUnknown_0862B53C, 11920
|
||||
};
|
||||
|
||||
static const union AnimCmd sSpriteAnim_862B734[] =
|
||||
{
|
||||
ANIMCMD_FRAME(0, 1),
|
||||
ANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AnimCmd sSpriteAnim_862B73C[] =
|
||||
{
|
||||
ANIMCMD_FRAME(64, 1),
|
||||
ANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AnimCmd sSpriteAnim_862B744[] =
|
||||
{
|
||||
ANIMCMD_FRAME(128, 1),
|
||||
ANIMCMD_END
|
||||
};
|
||||
|
||||
static const union AnimCmd *const sSpriteAnimTable_862B74C[] =
|
||||
{
|
||||
sSpriteAnim_862B734,
|
||||
sSpriteAnim_862B73C,
|
||||
sSpriteAnim_862B744
|
||||
};
|
||||
|
||||
static const struct SpriteTemplate sUnknown_0862B758 =
|
||||
{
|
||||
.tileTag = 11920,
|
||||
.paletteTag = 11920,
|
||||
.oam = &sOamData_862B71C,
|
||||
.anims = sSpriteAnimTable_862B74C,
|
||||
.images = NULL,
|
||||
.affineAnims = gDummySpriteAffineAnimTable,
|
||||
.callback = SpriteCallbackDummy,
|
||||
};
|
||||
|
||||
static const TransitionStateFunc sPhase2_34_Funcs[] =
|
||||
{
|
||||
sub_81DAACC,
|
||||
sub_81DAC14,
|
||||
sub_81DABBC,
|
||||
sub_81DAB4C,
|
||||
sub_81DAC80
|
||||
};
|
||||
|
||||
static const TransitionStateFunc sPhase2_35_Funcs[] =
|
||||
{
|
||||
sub_81DAACC,
|
||||
sub_81DACEC,
|
||||
sub_81DABBC,
|
||||
sub_81DAB4C,
|
||||
sub_81DAD58
|
||||
};
|
||||
|
||||
static const TransitionStateFunc sPhase2_36_Funcs[] =
|
||||
{
|
||||
sub_81DAACC,
|
||||
sub_81DADC4,
|
||||
sub_81DABBC,
|
||||
sub_81DAB4C,
|
||||
sub_81DAE44
|
||||
};
|
||||
|
||||
static const TransitionStateFunc sPhase2_37_Funcs[] =
|
||||
{
|
||||
sub_81DAACC,
|
||||
sub_81DAEB0,
|
||||
sub_81DABBC,
|
||||
sub_81DAB4C,
|
||||
sub_81DAF34
|
||||
};
|
||||
|
||||
static const TransitionStateFunc sPhase2_38_Funcs[] =
|
||||
{
|
||||
sub_81DAACC,
|
||||
sub_81DAFA0,
|
||||
sub_81DABBC,
|
||||
sub_81DAB4C,
|
||||
sub_81DB02C
|
||||
};
|
||||
|
||||
static const TransitionStateFunc sPhase2_39_Funcs[] =
|
||||
{
|
||||
sub_81DAACC,
|
||||
sub_81DB098,
|
||||
sub_81DABBC,
|
||||
sub_81DAB4C,
|
||||
sub_81DB124
|
||||
};
|
||||
|
||||
static const TransitionStateFunc sPhase2_40_Funcs[] =
|
||||
{
|
||||
sub_81DAACC,
|
||||
sub_81DB190,
|
||||
sub_81DABBC,
|
||||
sub_81DAB4C,
|
||||
sub_81DB224
|
||||
};
|
||||
|
||||
static const TransitionStateFunc sPhase2_41_Funcs[] =
|
||||
{
|
||||
sub_81DAACC,
|
||||
sub_81DB290,
|
||||
sub_81DABBC,
|
||||
sub_81DAB4C,
|
||||
sub_81DB328
|
||||
};
|
||||
|
||||
// code
|
||||
static void sub_81DA700(void)
|
||||
{
|
||||
u16 *dst1, *dst2;
|
||||
|
||||
sub_8149F58(&dst1, &dst2);
|
||||
LZ77UnCompVram(gUnknown_0862AD54, dst2);
|
||||
LZ77UnCompVram(gUnknown_0862AF30, dst1);
|
||||
LoadPalette(gUnknown_0862B53C, 0xF0, 0x20);
|
||||
LoadCompressedObjectPic(&sUnknown_0862B724);
|
||||
LoadSpritePalette(&sUnknown_0862B72C);
|
||||
}
|
||||
|
||||
static u8 sub_81DA74C(s16 x, s16 y, u8 arg2, u8 arg3, s8 arg4, s8 arg5, u8 spriteAnimNum)
|
||||
{
|
||||
u8 spriteId = CreateSprite(&sUnknown_0862B758, x, y, 0);
|
||||
|
||||
switch (spriteAnimNum)
|
||||
{
|
||||
case 0:
|
||||
gSprites[spriteId].data[0] = 120;
|
||||
gSprites[spriteId].data[1] = 45;
|
||||
break;
|
||||
case 1:
|
||||
gSprites[spriteId].data[0] = 89;
|
||||
gSprites[spriteId].data[1] = 97;
|
||||
break;
|
||||
case 2:
|
||||
gSprites[spriteId].data[0] = 151;
|
||||
gSprites[spriteId].data[1] = 97;
|
||||
break;
|
||||
}
|
||||
|
||||
gSprites[spriteId].data[2] = arg4;
|
||||
gSprites[spriteId].data[3] = arg5;
|
||||
gSprites[spriteId].data[6] = arg2;
|
||||
gSprites[spriteId].data[7] = arg3;
|
||||
gSprites[spriteId].data[4] = 0;
|
||||
gSprites[spriteId].data[5] = 0;
|
||||
|
||||
StartSpriteAnim(&gSprites[spriteId], spriteAnimNum);
|
||||
gSprites[spriteId].callback = sub_81DA848;
|
||||
|
||||
return spriteId;
|
||||
}
|
||||
|
||||
static void sub_81DA848(struct Sprite *sprite)
|
||||
{
|
||||
s16 *data = sprite->data;
|
||||
|
||||
if (sprite->pos1.x == data[0] && sprite->pos1.y == data[1])
|
||||
{
|
||||
sprite->callback = SpriteCallbackDummy;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (data[4] == data[6])
|
||||
{
|
||||
sprite->pos1.x += data[2];
|
||||
data[4] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
data[4]++;
|
||||
}
|
||||
|
||||
if (data[5] == data[7])
|
||||
{
|
||||
sprite->pos1.y += data[3];
|
||||
data[5] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
data[5]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static u8 sub_81DA8BC(s16 x, s16 y, s16 arg2, s16 arg3, s16 arg4, s16 arg5, s16 arg6, u8 spriteAnimNum)
|
||||
{
|
||||
u8 spriteId = CreateSprite(&sUnknown_0862B758, x, y, 0);
|
||||
|
||||
switch (spriteAnimNum)
|
||||
{
|
||||
case 0:
|
||||
gSprites[spriteId].data[0] = 120;
|
||||
gSprites[spriteId].data[1] = 45;
|
||||
break;
|
||||
case 1:
|
||||
gSprites[spriteId].data[0] = 89;
|
||||
gSprites[spriteId].data[1] = 97;
|
||||
break;
|
||||
case 2:
|
||||
gSprites[spriteId].data[0] = 151;
|
||||
gSprites[spriteId].data[1] = 97;
|
||||
break;
|
||||
}
|
||||
|
||||
gSprites[spriteId].data[2] = arg2;
|
||||
gSprites[spriteId].data[3] = arg3;
|
||||
gSprites[spriteId].data[4] = arg4;
|
||||
gSprites[spriteId].data[5] = arg5;
|
||||
gSprites[spriteId].data[6] = arg6;
|
||||
|
||||
StartSpriteAnim(&gSprites[spriteId], spriteAnimNum);
|
||||
gSprites[spriteId].callback = sub_81DA9BC;
|
||||
|
||||
return spriteId;
|
||||
}
|
||||
|
||||
static void sub_81DA9BC(struct Sprite *sprite)
|
||||
{
|
||||
sprite->pos2.x = (Sin2(sprite->data[2]) * sprite->data[4]) >> 12; // div by 4096
|
||||
sprite->pos2.y = (Cos2(sprite->data[2]) * sprite->data[4]) >> 12; // div by 4096
|
||||
|
||||
sprite->data[2] = (sprite->data[2] + sprite->data[3]) % 360;
|
||||
|
||||
if (sprite->data[4] != sprite->data[5])
|
||||
sprite->data[4] += sprite->data[6];
|
||||
else
|
||||
sprite->callback = SpriteCallbackDummy;
|
||||
}
|
||||
|
||||
#define tState data[0]
|
||||
|
||||
static void sub_81DAA20(struct Task *task)
|
||||
{
|
||||
FreeSpriteTilesByTag(11920);
|
||||
FreeSpritePaletteByTag(11920);
|
||||
|
||||
DestroySprite(&gSprites[task->data[4]]);
|
||||
DestroySprite(&gSprites[task->data[5]]);
|
||||
DestroySprite(&gSprites[task->data[6]]);
|
||||
}
|
||||
|
||||
static bool8 sub_81DAA74(struct Task *task)
|
||||
{
|
||||
if (gSprites[task->data[4]].callback == SpriteCallbackDummy
|
||||
&& gSprites[task->data[5]].callback == SpriteCallbackDummy
|
||||
&& gSprites[task->data[6]].callback == SpriteCallbackDummy)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static bool8 sub_81DAACC(struct Task *task)
|
||||
{
|
||||
if (task->data[1] == 0)
|
||||
{
|
||||
ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON);
|
||||
ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN1_ON);
|
||||
ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_BG0_ON);
|
||||
|
||||
task->data[1]++;
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
sub_81DA700();
|
||||
SetGpuReg(REG_OFFSET_BLDCNT, 0x3F41);
|
||||
SetGpuReg(REG_OFFSET_BLDALPHA, 0x1000);
|
||||
ChangeBgX(0, 0, 0);
|
||||
ChangeBgY(0, 0, 0);
|
||||
ChangeBgY(0, 0x500, 2);
|
||||
|
||||
task->data[1] = 0;
|
||||
task->tState++;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
static bool8 sub_81DAB4C(struct Task *task)
|
||||
{
|
||||
if (task->data[2] == 0)
|
||||
SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_BG0_ON);
|
||||
|
||||
if (task->data[2] == 16)
|
||||
{
|
||||
if (task->data[3] == 31)
|
||||
{
|
||||
BeginNormalPaletteFade(-1, -1, 0, 0x10, 0);
|
||||
task->tState++;
|
||||
}
|
||||
else
|
||||
{
|
||||
task->data[3]++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
u16 var;
|
||||
|
||||
task->data[2]++;
|
||||
var = task->data[2];
|
||||
SetGpuReg(REG_OFFSET_BLDALPHA, (var) | ((16 - var) << 8));
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static bool8 sub_81DABBC(struct Task *task)
|
||||
{
|
||||
if (sub_81DAA74(task) == TRUE)
|
||||
task->tState++;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void Phase2Task_34(u8 taskId)
|
||||
{
|
||||
while (sPhase2_34_Funcs[gTasks[taskId].tState](&gTasks[taskId]));
|
||||
}
|
||||
|
||||
static bool8 sub_81DAC14(struct Task *task)
|
||||
{
|
||||
task->data[4] = sub_81DA74C(120, -51, 0, 0, 0, 2, 0);
|
||||
task->data[5] = sub_81DA74C(-7, 193, 0, 0, 2, -2, 1);
|
||||
task->data[6] = sub_81DA74C(247, 193, 0, 0, -2, -2, 2);
|
||||
|
||||
task->tState++;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static bool8 sub_81DAC80(struct Task *task)
|
||||
{
|
||||
if (!gPaletteFade.active)
|
||||
{
|
||||
sub_81DAA20(task);
|
||||
DestroyTask(FindTaskIdByFunc(Phase2Task_34));
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void Phase2Task_35(u8 taskId)
|
||||
{
|
||||
while (sPhase2_35_Funcs[gTasks[taskId].tState](&gTasks[taskId]));
|
||||
}
|
||||
|
||||
static bool8 sub_81DACEC(struct Task *task)
|
||||
{
|
||||
task->data[4] = sub_81DA74C(120, 197, 0, 0, 0, -4, 0);
|
||||
task->data[5] = sub_81DA74C(241, 59, 0, 1, -4, 2, 1);
|
||||
task->data[6] = sub_81DA74C(-1, 59, 0, 1, 4, 2, 2);
|
||||
|
||||
task->tState++;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static bool8 sub_81DAD58(struct Task *task)
|
||||
{
|
||||
if (!gPaletteFade.active)
|
||||
{
|
||||
sub_81DAA20(task);
|
||||
DestroyTask(FindTaskIdByFunc(Phase2Task_35));
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void Phase2Task_36(u8 taskId)
|
||||
{
|
||||
while (sPhase2_36_Funcs[gTasks[taskId].tState](&gTasks[taskId]));
|
||||
}
|
||||
|
||||
static bool8 sub_81DADC4(struct Task *task)
|
||||
{
|
||||
task->data[4] = sub_81DA8BC(120, 45, 12, 4, 128, 0, -4, 0);
|
||||
task->data[5] = sub_81DA8BC(89, 97, 252, 4, 128, 0, -4, 1);
|
||||
task->data[6] = sub_81DA8BC(151, 97, 132, 4, 128, 0, -4, 2);
|
||||
|
||||
task->tState++;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static bool8 sub_81DAE44(struct Task *task)
|
||||
{
|
||||
if (!gPaletteFade.active)
|
||||
{
|
||||
sub_81DAA20(task);
|
||||
DestroyTask(FindTaskIdByFunc(Phase2Task_36));
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void Phase2Task_37(u8 taskId)
|
||||
{
|
||||
while (sPhase2_37_Funcs[gTasks[taskId].tState](&gTasks[taskId]));
|
||||
}
|
||||
|
||||
static bool8 sub_81DAEB0(struct Task *task)
|
||||
{
|
||||
task->data[4] = sub_81DA8BC(120, 80, 284, 8, 131, 35, -3, 0);
|
||||
task->data[5] = sub_81DA8BC(120, 80, 44, 8, 131, 35, -3, 1);
|
||||
task->data[6] = sub_81DA8BC(121, 80, 164, 8, 131, 35, -3, 2);
|
||||
|
||||
task->tState++;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static bool8 sub_81DAF34(struct Task *task)
|
||||
{
|
||||
if (!gPaletteFade.active)
|
||||
{
|
||||
sub_81DAA20(task);
|
||||
DestroyTask(FindTaskIdByFunc(Phase2Task_37));
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void Phase2Task_38(u8 taskId)
|
||||
{
|
||||
while (sPhase2_38_Funcs[gTasks[taskId].tState](&gTasks[taskId]));
|
||||
}
|
||||
|
||||
static bool8 sub_81DAFA0(struct Task *task)
|
||||
{
|
||||
if (task->data[1] == 0)
|
||||
{
|
||||
task->data[4] = sub_81DA74C(120, -51, 0, 0, 0, 4, 0);
|
||||
}
|
||||
else if (task->data[1] == 16)
|
||||
{
|
||||
task->data[5] = sub_81DA74C(-7, 193, 0, 0, 4, -4, 1);
|
||||
}
|
||||
else if (task->data[1] == 32)
|
||||
{
|
||||
task->data[6] = sub_81DA74C(247, 193, 0, 0, -4, -4, 2);
|
||||
task->tState++;
|
||||
}
|
||||
|
||||
task->data[1]++;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static bool8 sub_81DB02C(struct Task *task)
|
||||
{
|
||||
if (!gPaletteFade.active)
|
||||
{
|
||||
sub_81DAA20(task);
|
||||
DestroyTask(FindTaskIdByFunc(Phase2Task_38));
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void Phase2Task_39(u8 taskId)
|
||||
{
|
||||
while (sPhase2_39_Funcs[gTasks[taskId].tState](&gTasks[taskId]));
|
||||
}
|
||||
|
||||
static bool8 sub_81DB098(struct Task *task)
|
||||
{
|
||||
if (task->data[1] == 0)
|
||||
{
|
||||
task->data[4] = sub_81DA74C(120, 197, 0, 0, 0, -8, 0);
|
||||
}
|
||||
else if (task->data[1] == 16)
|
||||
{
|
||||
task->data[5] = sub_81DA74C(241, 78, 0, 0, -8, 1, 1);
|
||||
}
|
||||
else if (task->data[1] == 32)
|
||||
{
|
||||
task->data[6] = sub_81DA74C(-1, 78, 0, 0, 8, 1, 2);
|
||||
task->tState++;
|
||||
}
|
||||
|
||||
task->data[1]++;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static bool8 sub_81DB124(struct Task *task)
|
||||
{
|
||||
if (!gPaletteFade.active)
|
||||
{
|
||||
sub_81DAA20(task);
|
||||
DestroyTask(FindTaskIdByFunc(Phase2Task_39));
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void Phase2Task_40(u8 taskId)
|
||||
{
|
||||
while (sPhase2_40_Funcs[gTasks[taskId].tState](&gTasks[taskId]));
|
||||
}
|
||||
|
||||
static bool8 sub_81DB190(struct Task *task)
|
||||
{
|
||||
if (task->data[1] == 0)
|
||||
{
|
||||
task->data[4] = sub_81DA8BC(120, 45, 12, 4, 128, 0, -4, 0);
|
||||
}
|
||||
else if (task->data[1] == 16)
|
||||
{
|
||||
task->data[5] = sub_81DA8BC(89, 97, 252, 4, 128, 0, -4, 1);
|
||||
}
|
||||
else if (task->data[1] == 32)
|
||||
{
|
||||
task->data[6] = sub_81DA8BC(151, 97, 132, 4, 128, 0, -4, 2);
|
||||
task->tState++;
|
||||
}
|
||||
|
||||
task->data[1]++;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static bool8 sub_81DB224(struct Task *task)
|
||||
{
|
||||
if (!gPaletteFade.active)
|
||||
{
|
||||
sub_81DAA20(task);
|
||||
DestroyTask(FindTaskIdByFunc(Phase2Task_40));
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void Phase2Task_41(u8 taskId)
|
||||
{
|
||||
while (sPhase2_41_Funcs[gTasks[taskId].tState](&gTasks[taskId]));
|
||||
}
|
||||
|
||||
static bool8 sub_81DB290(struct Task *task)
|
||||
{
|
||||
if (task->data[1] == 0)
|
||||
{
|
||||
task->data[4] = sub_81DA8BC(120, 80, 284, 8, 131, 35, -3, 0);
|
||||
}
|
||||
else if (task->data[1] == 16)
|
||||
{
|
||||
task->data[5] = sub_81DA8BC(120, 80, 44, 8, 131, 35, -3, 1);
|
||||
}
|
||||
else if (task->data[1] == 32)
|
||||
{
|
||||
task->data[6] = sub_81DA8BC(121, 80, 164, 8, 131, 35, -3, 2);
|
||||
task->tState++;
|
||||
}
|
||||
|
||||
task->data[1]++;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static bool8 sub_81DB328(struct Task *task)
|
||||
{
|
||||
if (!gPaletteFade.active)
|
||||
{
|
||||
sub_81DAA20(task);
|
||||
DestroyTask(FindTaskIdByFunc(Phase2Task_41));
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
@@ -578,7 +578,7 @@ static void LoadWallClockGraphics(void)
|
||||
DeactivateAllTextPrinters();
|
||||
sub_809882C(0, 0x250, 0xd0);
|
||||
clear_scheduled_bg_copies_to_vram();
|
||||
remove_some_task();
|
||||
ScanlineEffect_Stop();
|
||||
ResetTasks();
|
||||
ResetSpriteData();
|
||||
ResetPaletteFade();
|
||||
|
||||
Reference in New Issue
Block a user