Merge branch 'master' of https://github.com/pret/pokeemerald into fix_perms

This commit is contained in:
Devin
2018-01-21 15:22:05 -05:00
293 changed files with 8429 additions and 2787 deletions

View File

@@ -2730,6 +2730,10 @@ static bool8 Phase2_ShredSplit_Func2(struct Task *task)
return FALSE;
}
// 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
// done and the second part was left out.
static bool8 Phase2_ShredSplit_Func3(struct Task *task)
{
u16 i;

View File

@@ -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;

View 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();

View File

@@ -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;

View File

@@ -269,7 +269,7 @@ void EvolutionScene(struct Pokemon* mon, u16 speciesToEvolve, bool8 canStopEvo,
sub_80356D0();
LoadBattleTextboxAndBackground();
ResetSpriteData();
remove_some_task();
ScanlineEffect_Stop();
ResetTasks();
FreeAllSpritePalettes();

View 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();

View File

@@ -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:

View File

@@ -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);

662
src/option_menu.c Normal file
View 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);
}

View File

@@ -419,7 +419,7 @@ static bool8 InitPokeblockMenu(void)
gMain.state++;
break;
case 1:
remove_some_task();
ScanlineEffect_Stop();
gMain.state++;
break;
case 2:

View 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:

View 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);

View 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)

View File

@@ -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);
}

View File

@@ -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();