Merge master from pret
This commit is contained in:
510
src/battle_records.c
Normal file
510
src/battle_records.c
Normal file
@@ -0,0 +1,510 @@
|
||||
#include "global.h"
|
||||
#include "battle_records.h"
|
||||
#include "bg.h"
|
||||
#include "window.h"
|
||||
#include "link.h"
|
||||
#include "battle.h"
|
||||
#include "overworld.h"
|
||||
#include "text.h"
|
||||
#include "text_window.h"
|
||||
#include "strings.h"
|
||||
#include "string_util.h"
|
||||
#include "trainer_card.h"
|
||||
#include "menu.h"
|
||||
#include "menu_helpers.h"
|
||||
#include "palette.h"
|
||||
#include "main.h"
|
||||
#include "scanline_effect.h"
|
||||
#include "international_string_util.h"
|
||||
#include "sound.h"
|
||||
#include "constants/songs.h"
|
||||
#include "malloc.h"
|
||||
#include "gpu_regs.h"
|
||||
#include "constants/game_stat.h"
|
||||
|
||||
extern void PrintOnTrainerHillRecordsWindow(void); // pokenav.s
|
||||
|
||||
// this file's functions
|
||||
static void Task_CloseTrainerHillRecordsOnButton(u8 taskId);
|
||||
static void Task_BeginPaletteFade(u8 taskId);
|
||||
static void Task_ExitTrainerHillRecords(u8 taskId);
|
||||
static void RemoveTrainerHillRecordsWindow(u8 windowId);
|
||||
static void CB2_ShowTrainerHillRecords(void);
|
||||
|
||||
// EWRAM variables
|
||||
EWRAM_DATA u8 gRecordsWindowId = 0;
|
||||
EWRAM_DATA static u8 *sTilemapBuffer = NULL;
|
||||
|
||||
// const rom data
|
||||
static const u32 sTrainerHillWindowTileset[] = INCBIN_U32("graphics/unknown/unknown_5B3484.4bpp");
|
||||
static const u16 sTrainerHillWindowPalette[] = INCBIN_U16("graphics/unknown/unknown_5B3484.gbapal");
|
||||
static const u32 sTrainerHillWindowTilemap[] = INCBIN_U32("graphics/unknown/unknown_5B3564.bin");
|
||||
|
||||
static const struct BgTemplate sTrainerHillRecordsBgTemplates[] =
|
||||
{
|
||||
{
|
||||
.bg = 0,
|
||||
.charBaseIndex = 0,
|
||||
.mapBaseIndex = 31,
|
||||
.screenSize = 0,
|
||||
.paletteMode = 0,
|
||||
.priority = 0,
|
||||
.baseTile = 0
|
||||
},
|
||||
{
|
||||
.bg = 3,
|
||||
.charBaseIndex = 1,
|
||||
.mapBaseIndex = 30,
|
||||
.screenSize = 0,
|
||||
.paletteMode = 0,
|
||||
.priority = 3,
|
||||
.baseTile = 0
|
||||
}
|
||||
};
|
||||
|
||||
static const struct WindowTemplate sTrainerHillRecordsWindowTemplates[] =
|
||||
{
|
||||
{0x0, 0x2, 0x1, 0x1A, 0x12, 0xF, 0x14},
|
||||
DUMMY_WIN_TEMPLATE
|
||||
};
|
||||
|
||||
static const struct WindowTemplate sLinkBattleRecordsWindow = {0x0, 0x2, 0x1, 0x1A, 0x11, 0xF, 0x1};
|
||||
|
||||
static const u8 sText_DashesNoPlayer[] = _("-------");
|
||||
static const u8 sText_DashesNoScore[] = _("----");
|
||||
|
||||
// code
|
||||
static void ClearLinkBattleRecord(struct LinkBattleRecord *record)
|
||||
{
|
||||
CpuFill16(0, record, sizeof(struct LinkBattleRecord));
|
||||
record->name[0] = EOS;
|
||||
record->trainerId = 0;
|
||||
record->wins = 0;
|
||||
record->losses = 0;
|
||||
record->draws = 0;
|
||||
}
|
||||
|
||||
static void ClearLinkBattleRecords(struct LinkBattleRecord *records)
|
||||
{
|
||||
s32 i;
|
||||
for (i = 0; i < LINK_B_RECORDS_COUNT; i++)
|
||||
{
|
||||
ClearLinkBattleRecord(records + i);
|
||||
}
|
||||
SetGameStat(GAME_STAT_LINK_BATTLE_WINS, 0);
|
||||
SetGameStat(GAME_STAT_LINK_BATTLE_LOSSES, 0);
|
||||
SetGameStat(GAME_STAT_LINK_BATTLE_DRAWS, 0);
|
||||
}
|
||||
|
||||
static s32 GetLinkBattleRecordTotalBattles(struct LinkBattleRecord *record)
|
||||
{
|
||||
return record->wins + record->losses + record->draws;
|
||||
}
|
||||
|
||||
static s32 FindLinkBattleRecord(struct LinkBattleRecord *records, const u8 *name, u16 trainerId)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
for (i = 0; i < LINK_B_RECORDS_COUNT; i++)
|
||||
{
|
||||
if (!StringCompareN(records[i].name, name, OT_NAME_LENGTH) && records[i].trainerId == trainerId)
|
||||
return i;
|
||||
}
|
||||
|
||||
return LINK_B_RECORDS_COUNT;
|
||||
}
|
||||
|
||||
static void SortLinkBattleRecords(struct LinkBattleRecords *records)
|
||||
{
|
||||
s32 i, j;
|
||||
|
||||
for (i = LINK_B_RECORDS_COUNT - 1; i > 0; i--)
|
||||
{
|
||||
for (j = i - 1; j >= 0; j--)
|
||||
{
|
||||
s32 totalBattlesI = GetLinkBattleRecordTotalBattles(&records->entries[i]);
|
||||
s32 totalBattlesJ = GetLinkBattleRecordTotalBattles(&records->entries[j]);
|
||||
|
||||
if (totalBattlesI > totalBattlesJ)
|
||||
{
|
||||
struct LinkBattleRecord temp1;
|
||||
u8 temp2;
|
||||
|
||||
temp1 = records->entries[i];
|
||||
records->entries[i] = records->entries[j];
|
||||
records->entries[j] = temp1;
|
||||
|
||||
temp2 = records->languages[i];
|
||||
records->languages[i] = records->languages[j];
|
||||
records->languages[j] = temp2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void UpdateLinkBattleRecord(struct LinkBattleRecord *record, s32 battleOutcome)
|
||||
{
|
||||
switch (battleOutcome)
|
||||
{
|
||||
case B_OUTCOME_WON:
|
||||
record->wins++;
|
||||
if (record->wins > 9999)
|
||||
record->wins = 9999;
|
||||
break;
|
||||
case B_OUTCOME_LOST:
|
||||
record->losses++;
|
||||
if (record->losses > 9999)
|
||||
record->losses = 9999;
|
||||
break;
|
||||
case B_OUTCOME_DREW:
|
||||
record->draws++;
|
||||
if (record->draws > 9999)
|
||||
record->draws = 9999;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void UpdateLinkBattleGameStats(s32 battleOutcome)
|
||||
{
|
||||
u8 stat;
|
||||
|
||||
switch (battleOutcome)
|
||||
{
|
||||
case B_OUTCOME_WON:
|
||||
stat = GAME_STAT_LINK_BATTLE_WINS;
|
||||
break;
|
||||
case B_OUTCOME_LOST:
|
||||
stat = GAME_STAT_LINK_BATTLE_LOSSES;
|
||||
break;
|
||||
case B_OUTCOME_DREW:
|
||||
stat = GAME_STAT_LINK_BATTLE_DRAWS;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
if (GetGameStat(stat) < 9999)
|
||||
IncrementGameStat(stat);
|
||||
}
|
||||
|
||||
static void UpdateLinkBattleRecords(struct LinkBattleRecords *records, const u8 *name, u16 trainerId, s32 battleOutcome, u8 battlerId)
|
||||
{
|
||||
s32 index;
|
||||
|
||||
UpdateLinkBattleGameStats(battleOutcome);
|
||||
SortLinkBattleRecords(records);
|
||||
index = FindLinkBattleRecord(records->entries, name, trainerId);
|
||||
if (index == LINK_B_RECORDS_COUNT)
|
||||
{
|
||||
index = LINK_B_RECORDS_COUNT - 1;
|
||||
ClearLinkBattleRecord(&records->entries[index]);
|
||||
StringCopyN(records->entries[index].name, name, OT_NAME_LENGTH);
|
||||
records->entries[index].trainerId = trainerId;
|
||||
records->languages[index] = gLinkPlayers[battlerId].language;
|
||||
}
|
||||
UpdateLinkBattleRecord(&records->entries[index], battleOutcome);
|
||||
SortLinkBattleRecords(records);
|
||||
}
|
||||
|
||||
void ClearPlayerLinkBattleRecords(void)
|
||||
{
|
||||
ClearLinkBattleRecords(gSaveBlock1Ptr->linkBattleRecords.entries);
|
||||
}
|
||||
|
||||
static void IncTrainerCardWins(s32 battlerId)
|
||||
{
|
||||
u16 *wins = &gTrainerCards[battlerId].linkBattleWins;
|
||||
(*wins)++;
|
||||
if (*wins > 9999)
|
||||
*wins = 9999;
|
||||
}
|
||||
|
||||
static void IncTrainerCardLosses(s32 battlerId)
|
||||
{
|
||||
u16 *losses = &gTrainerCards[battlerId].linkBattleLosses;
|
||||
(*losses)++;
|
||||
if (*losses > 9999)
|
||||
*losses = 9999;
|
||||
}
|
||||
|
||||
static void UpdateTrainerCardWinsLosses(s32 battlerId)
|
||||
{
|
||||
switch (gBattleOutcome)
|
||||
{
|
||||
case B_OUTCOME_WON:
|
||||
IncTrainerCardWins(BATTLE_OPPOSITE(battlerId));
|
||||
IncTrainerCardLosses(battlerId);
|
||||
break;
|
||||
case B_OUTCOME_LOST:
|
||||
IncTrainerCardLosses(BATTLE_OPPOSITE(battlerId));
|
||||
IncTrainerCardWins(battlerId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void UpdatePlayerLinkBattleRecords(s32 battlerId)
|
||||
{
|
||||
if (InUnionRoom() != TRUE)
|
||||
{
|
||||
UpdateTrainerCardWinsLosses(battlerId);
|
||||
UpdateLinkBattleRecords(
|
||||
&gSaveBlock1Ptr->linkBattleRecords,
|
||||
gTrainerCards[battlerId].playerName,
|
||||
gTrainerCards[battlerId].trainerId,
|
||||
gBattleOutcome,
|
||||
battlerId);
|
||||
}
|
||||
}
|
||||
|
||||
static void PrintLinkBattleWinsLossesDraws(struct LinkBattleRecord *records)
|
||||
{
|
||||
s32 x;
|
||||
|
||||
ConvertIntToDecimalStringN(gStringVar1, GetGameStat(GAME_STAT_LINK_BATTLE_WINS), STR_CONV_MODE_LEFT_ALIGN, 4);
|
||||
ConvertIntToDecimalStringN(gStringVar2, GetGameStat(GAME_STAT_LINK_BATTLE_LOSSES), STR_CONV_MODE_LEFT_ALIGN, 4);
|
||||
ConvertIntToDecimalStringN(gStringVar3, GetGameStat(GAME_STAT_LINK_BATTLE_DRAWS), STR_CONV_MODE_LEFT_ALIGN, 4);
|
||||
StringExpandPlaceholders(gStringVar4, gText_TotalRecordWLD);
|
||||
|
||||
x = GetStringCenterAlignXOffset(1, gStringVar4, 0xD0);
|
||||
PrintTextOnWindow(gRecordsWindowId, 1, gStringVar4, x, 0x11, 0, NULL);
|
||||
}
|
||||
|
||||
static void PrintLinkBattleRecord(struct LinkBattleRecord *record, u8 y, s32 language)
|
||||
{
|
||||
if (record->wins == 0 && record->losses == 0 && record->draws == 0)
|
||||
{
|
||||
// empty slot
|
||||
PrintTextOnWindow(gRecordsWindowId, 1, sText_DashesNoPlayer, 8, (y * 8) + 1, 0, NULL);
|
||||
PrintTextOnWindow(gRecordsWindowId, 1, sText_DashesNoScore, 80, (y * 8) + 1, 0, NULL);
|
||||
PrintTextOnWindow(gRecordsWindowId, 1, sText_DashesNoScore, 128, (y * 8) + 1, 0, NULL);
|
||||
PrintTextOnWindow(gRecordsWindowId, 1, sText_DashesNoScore, 176, (y * 8) + 1, 0, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
StringFillWithTerminator(gStringVar1, 8);
|
||||
StringCopyN(gStringVar1, record->name, 7);
|
||||
ConvertInternationalString(gStringVar1, language);
|
||||
|
||||
PrintTextOnWindow(gRecordsWindowId, 1, gStringVar1, 8, (y * 8) + 1, 0, NULL);
|
||||
|
||||
ConvertIntToDecimalStringN(gStringVar1, record->wins, STR_CONV_MODE_RIGHT_ALIGN, 4);
|
||||
PrintTextOnWindow(gRecordsWindowId, 1, gStringVar1, 80, (y * 8) + 1, 0, NULL);
|
||||
|
||||
ConvertIntToDecimalStringN(gStringVar1, record->losses, STR_CONV_MODE_RIGHT_ALIGN, 4);
|
||||
PrintTextOnWindow(gRecordsWindowId, 1, gStringVar1, 128, (y * 8) + 1, 0, NULL);
|
||||
|
||||
ConvertIntToDecimalStringN(gStringVar1, record->draws, STR_CONV_MODE_RIGHT_ALIGN, 4);
|
||||
PrintTextOnWindow(gRecordsWindowId, 1, gStringVar1, 176, (y * 8) + 1, 0, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void ShowLinkBattleRecords(void)
|
||||
{
|
||||
s32 i, x;
|
||||
|
||||
gRecordsWindowId = AddWindow(&sLinkBattleRecordsWindow);
|
||||
NewMenuHelpers_DrawStdWindowFrame(gRecordsWindowId, FALSE);
|
||||
FillWindowPixelBuffer(gRecordsWindowId, 0x11);
|
||||
StringExpandPlaceholders(gStringVar4, gText_PlayersBattleResults);
|
||||
|
||||
x = GetStringCenterAlignXOffset(1, gStringVar4, 208);
|
||||
PrintTextOnWindow(gRecordsWindowId, 1, gStringVar4, x, 1, 0, NULL);
|
||||
PrintLinkBattleWinsLossesDraws(gSaveBlock1Ptr->linkBattleRecords.entries);
|
||||
|
||||
StringExpandPlaceholders(gStringVar4, gText_WinLoseDraw);
|
||||
PrintTextOnWindow(gRecordsWindowId, 1, gStringVar4, 0, 41, 0, NULL);
|
||||
|
||||
for (i = 0; i < LINK_B_RECORDS_COUNT; i++)
|
||||
{
|
||||
PrintLinkBattleRecord(&gSaveBlock1Ptr->linkBattleRecords.entries[i], 7 + (i * 2), gSaveBlock1Ptr->linkBattleRecords.languages[i]);
|
||||
}
|
||||
|
||||
PutWindowTilemap(gRecordsWindowId);
|
||||
CopyWindowToVram(gRecordsWindowId, 3);
|
||||
}
|
||||
|
||||
void RemoveRecordsWindow(void)
|
||||
{
|
||||
sub_819746C(gRecordsWindowId, FALSE);
|
||||
RemoveWindow(gRecordsWindowId);
|
||||
}
|
||||
|
||||
static void Task_TrainerHillWaitForPaletteFade(u8 taskId)
|
||||
{
|
||||
if (!gPaletteFade.active)
|
||||
gTasks[taskId].func = Task_CloseTrainerHillRecordsOnButton;
|
||||
}
|
||||
|
||||
static void Task_CloseTrainerHillRecordsOnButton(u8 taskId)
|
||||
{
|
||||
struct Task *task = &gTasks[taskId];
|
||||
|
||||
if (gMain.newKeys & A_BUTTON || gMain.newKeys & B_BUTTON)
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
task->func = Task_BeginPaletteFade;
|
||||
}
|
||||
}
|
||||
|
||||
static void Task_BeginPaletteFade(u8 taskId)
|
||||
{
|
||||
BeginNormalPaletteFade(-1, 0, 0, 0x10, 0);
|
||||
gTasks[taskId].func = Task_ExitTrainerHillRecords;
|
||||
}
|
||||
|
||||
static void Task_ExitTrainerHillRecords(u8 taskId)
|
||||
{
|
||||
if (!gPaletteFade.active)
|
||||
{
|
||||
SetMainCallback2(CB2_ReturnToFieldContinueScript);
|
||||
Free(sTilemapBuffer);
|
||||
RemoveTrainerHillRecordsWindow(0);
|
||||
FreeAllWindowBuffers();
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
}
|
||||
|
||||
static void RemoveTrainerHillRecordsWindow(u8 windowId)
|
||||
{
|
||||
FillWindowPixelBuffer(windowId, 0);
|
||||
ClearWindowTilemap(windowId);
|
||||
CopyWindowToVram(windowId, 2);
|
||||
RemoveWindow(windowId);
|
||||
}
|
||||
|
||||
static void ClearVramOamPlttRegs(void)
|
||||
{
|
||||
DmaClearLarge16(3, (void*)(VRAM), VRAM_SIZE, 0x1000);
|
||||
DmaClear32(3, OAM, OAM_SIZE);
|
||||
DmaClear16(3, PLTT, PLTT_SIZE);
|
||||
|
||||
SetGpuReg(REG_OFFSET_DISPCNT, 0);
|
||||
SetGpuReg(REG_OFFSET_BG0CNT, 0);
|
||||
SetGpuReg(REG_OFFSET_BG0HOFS, 0);
|
||||
SetGpuReg(REG_OFFSET_BG0VOFS, 0);
|
||||
SetGpuReg(REG_OFFSET_BG1CNT, 0);
|
||||
SetGpuReg(REG_OFFSET_BG1HOFS, 0);
|
||||
SetGpuReg(REG_OFFSET_BG1VOFS, 0);
|
||||
SetGpuReg(REG_OFFSET_BG2CNT, 0);
|
||||
SetGpuReg(REG_OFFSET_BG2HOFS, 0);
|
||||
SetGpuReg(REG_OFFSET_BG2VOFS, 0);
|
||||
SetGpuReg(REG_OFFSET_BG3CNT, 0);
|
||||
SetGpuReg(REG_OFFSET_BG3HOFS, 0);
|
||||
SetGpuReg(REG_OFFSET_BG3VOFS, 0);
|
||||
SetGpuReg(REG_OFFSET_WIN0H, 0);
|
||||
SetGpuReg(REG_OFFSET_WIN0V, 0);
|
||||
SetGpuReg(REG_OFFSET_WININ, 0);
|
||||
SetGpuReg(REG_OFFSET_WINOUT, 0);
|
||||
SetGpuReg(REG_OFFSET_BLDCNT, 0);
|
||||
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
|
||||
SetGpuReg(REG_OFFSET_BLDY, 0);
|
||||
}
|
||||
|
||||
static void ClearTasksAndGraphicalStructs(void)
|
||||
{
|
||||
ScanlineEffect_Stop();
|
||||
ResetTasks();
|
||||
ResetSpriteData();
|
||||
ResetPaletteFade();
|
||||
FreeAllSpritePalettes();
|
||||
}
|
||||
|
||||
static void ResetBgCoordinates(void)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
static void SetDispcntReg(void)
|
||||
{
|
||||
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_BG0_ON | DISPCNT_BG3_ON | DISPCNT_OBJ_1D_MAP);
|
||||
}
|
||||
|
||||
static void LoadTrainerHillRecordsWindowGfx(u8 bgId)
|
||||
{
|
||||
LoadBgTiles(bgId, sTrainerHillWindowTileset, sizeof(sTrainerHillWindowTileset), 0);
|
||||
CopyToBgTilemapBufferRect(bgId, sTrainerHillWindowTilemap, 0, 0, 0x20, 0x20);
|
||||
LoadPalette(sTrainerHillWindowPalette, 0, 0x20);
|
||||
}
|
||||
|
||||
static void VblankCB_TrainerHillRecords(void)
|
||||
{
|
||||
LoadOam();
|
||||
ProcessSpriteCopyRequests();
|
||||
TransferPlttBuffer();
|
||||
}
|
||||
|
||||
static void MainCB2_TrainerHillRecords(void)
|
||||
{
|
||||
RunTasks();
|
||||
AnimateSprites();
|
||||
BuildOamBuffer();
|
||||
UpdatePaletteFade();
|
||||
}
|
||||
|
||||
void ShowTrainerHillRecords(void)
|
||||
{
|
||||
SetVBlankCallback(NULL);
|
||||
SetMainCallback2(CB2_ShowTrainerHillRecords);
|
||||
}
|
||||
|
||||
static void CB2_ShowTrainerHillRecords(void)
|
||||
{
|
||||
switch (gMain.state)
|
||||
{
|
||||
case 0:
|
||||
SetVBlankCallback(NULL);
|
||||
ClearVramOamPlttRegs();
|
||||
gMain.state++;
|
||||
break;
|
||||
case 1:
|
||||
ClearTasksAndGraphicalStructs();
|
||||
gMain.state++;
|
||||
break;
|
||||
case 2:
|
||||
sTilemapBuffer = AllocZeroed(0x800);
|
||||
ResetBgsAndClearDma3BusyFlags(0);
|
||||
InitBgsFromTemplates(0, sTrainerHillRecordsBgTemplates, ARRAY_COUNT(sTrainerHillRecordsBgTemplates));
|
||||
SetBgTilemapBuffer(3, sTilemapBuffer);
|
||||
ResetBgCoordinates();
|
||||
gMain.state++;
|
||||
break;
|
||||
case 3:
|
||||
LoadTrainerHillRecordsWindowGfx(3);
|
||||
LoadPalette(stdpal_get(0), 0xF0, 0x20);
|
||||
gMain.state++;
|
||||
break;
|
||||
case 4:
|
||||
if (IsDma3ManagerBusyWithBgCopy() != TRUE)
|
||||
{
|
||||
ShowBg(0);
|
||||
ShowBg(3);
|
||||
CopyBgTilemapBufferToVram(3);
|
||||
gMain.state++;
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
InitWindows(sTrainerHillRecordsWindowTemplates);
|
||||
DeactivateAllTextPrinters();
|
||||
gMain.state++;
|
||||
break;
|
||||
case 6:
|
||||
BeginNormalPaletteFade(-1, 0, 0x10, 0, 0);
|
||||
gMain.state++;
|
||||
break;
|
||||
case 7:
|
||||
SetDispcntReg();
|
||||
SetVBlankCallback(VblankCB_TrainerHillRecords);
|
||||
PrintOnTrainerHillRecordsWindow();
|
||||
CreateTask(Task_TrainerHillWaitForPaletteFade, 8);
|
||||
SetMainCallback2(MainCB2_TrainerHillRecords);
|
||||
gMain.state = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1218,7 +1218,7 @@ void FieldObjectInteractionRemoveBerryTree(void)
|
||||
|
||||
u8 PlayerHasBerries(void)
|
||||
{
|
||||
return IsBagPocketNonEmpty(BAG_BERRIES);
|
||||
return IsBagPocketNonEmpty(POCKET_BERRIES);
|
||||
}
|
||||
|
||||
void ResetBerryTreeSparkleFlags(void)
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "trig.h"
|
||||
#include "tv.h"
|
||||
#include "item_menu.h"
|
||||
#include "battle_records.h"
|
||||
|
||||
#define BLENDER_SCORE_BEST 0
|
||||
#define BLENDER_SCORE_GOOD 1
|
||||
@@ -131,7 +132,6 @@ extern struct MusicPlayerInfo gMPlayInfo_SE2;
|
||||
extern struct MusicPlayerInfo gMPlayInfo_BGM;
|
||||
extern u8 gInGameOpponentsNo;
|
||||
extern u8 gUnknown_020322D5;
|
||||
extern u8 gResultsWindowId;
|
||||
|
||||
// graphics
|
||||
extern const u8 gBerryBlenderArrowTiles[];
|
||||
@@ -2472,7 +2472,7 @@ static void CB2_HandleBlenderEndGame(void)
|
||||
sub_8081F94(&gSendCmd[0]);
|
||||
if (sBerryBlenderData->yesNoAnswer == 0)
|
||||
{
|
||||
if (IsBagPocketNonEmpty(BAG_BERRIES) == FALSE) // no berries
|
||||
if (IsBagPocketNonEmpty(POCKET_BERRIES) == FALSE) // no berries
|
||||
{
|
||||
sBerryBlenderData->playAgainState = CANT_PLAY_NO_BERRIES;
|
||||
gSendCmd[1] = 0x9999;
|
||||
@@ -3485,13 +3485,13 @@ void ShowBerryBlenderRecordWindow(void)
|
||||
u8 text[32];
|
||||
|
||||
winTemplate = sBlenderRecordWindowTemplate;
|
||||
gResultsWindowId = AddWindow(&winTemplate);
|
||||
NewMenuHelpers_DrawStdWindowFrame(gResultsWindowId, 0);
|
||||
FillWindowPixelBuffer(gResultsWindowId, 0x11);
|
||||
gRecordsWindowId = AddWindow(&winTemplate);
|
||||
NewMenuHelpers_DrawStdWindowFrame(gRecordsWindowId, 0);
|
||||
FillWindowPixelBuffer(gRecordsWindowId, 0x11);
|
||||
|
||||
xPos = GetStringCenterAlignXOffset(1, gText_BlenderMaxSpeedRecord, 0x90);
|
||||
PrintTextOnWindow(gResultsWindowId, 1, gText_BlenderMaxSpeedRecord, xPos, 1, 0, NULL);
|
||||
PrintTextOnWindow(gResultsWindowId, 1, gText_234Players, 4, 0x29, 0, NULL);
|
||||
PrintTextOnWindow(gRecordsWindowId, 1, gText_BlenderMaxSpeedRecord, xPos, 1, 0, NULL);
|
||||
PrintTextOnWindow(gRecordsWindowId, 1, gText_234Players, 4, 0x29, 0, NULL);
|
||||
|
||||
for (i = 0, yPos = 0x29; i < BLENDER_SCORES_NO; i++)
|
||||
{
|
||||
@@ -3506,11 +3506,11 @@ void ShowBerryBlenderRecordWindow(void)
|
||||
txtPtr = StringAppend(txtPtr, sText_RPM);
|
||||
|
||||
xPos = GetStringRightAlignXOffset(1, text, 0x8C);
|
||||
PrintTextOnWindow(gResultsWindowId, 1, text, xPos, yPos + (i * 16), 0, NULL);
|
||||
PrintTextOnWindow(gRecordsWindowId, 1, text, xPos, yPos + (i * 16), 0, NULL);
|
||||
}
|
||||
|
||||
PutWindowTilemap(gResultsWindowId);
|
||||
CopyWindowToVram(gResultsWindowId, 3);
|
||||
PutWindowTilemap(gRecordsWindowId);
|
||||
CopyWindowToVram(gRecordsWindowId, 3);
|
||||
}
|
||||
|
||||
static void sub_8083F3C(u8 taskId)
|
||||
|
||||
@@ -517,7 +517,7 @@ static void TryChangeDisplayedBerry(u8 taskId, s8 toMove)
|
||||
s16 *data = gTasks[taskId].data;
|
||||
s16 currPocketPosition = gUnknown_0203CE58.scrollPosition[3] + gUnknown_0203CE58.cursorPosition[3];
|
||||
u32 newPocketPosition = currPocketPosition + toMove;
|
||||
if (newPocketPosition < 46 && BagGetItemIdByPocketPosition(BAG_BERRIES, newPocketPosition) != 0)
|
||||
if (newPocketPosition < 46 && BagGetItemIdByPocketPosition(POCKET_BERRIES, newPocketPosition) != 0)
|
||||
{
|
||||
if (toMove < 0)
|
||||
data[1] = 2;
|
||||
@@ -537,7 +537,7 @@ static void HandleBagCursorPositionChange(s8 toMove)
|
||||
u16 *cursorPos = &gUnknown_0203CE58.cursorPosition[3];
|
||||
if (toMove > 0)
|
||||
{
|
||||
if (*cursorPos < 4 || BagGetItemIdByPocketPosition(BAG_BERRIES, *scrollPos + 8) == 0)
|
||||
if (*cursorPos < 4 || BagGetItemIdByPocketPosition(POCKET_BERRIES, *scrollPos + 8) == 0)
|
||||
*cursorPos += toMove;
|
||||
else
|
||||
*scrollPos += toMove;
|
||||
@@ -550,7 +550,7 @@ static void HandleBagCursorPositionChange(s8 toMove)
|
||||
*scrollPos += toMove;
|
||||
}
|
||||
|
||||
sBerryTag->berryId = ItemIdToBerryType(BagGetItemIdByPocketPosition(BAG_BERRIES, *scrollPos + *cursorPos));
|
||||
sBerryTag->berryId = ItemIdToBerryType(BagGetItemIdByPocketPosition(POCKET_BERRIES, *scrollPos + *cursorPos));
|
||||
}
|
||||
|
||||
static void Task_DisplayAnotherBerry(u8 taskId)
|
||||
|
||||
4
src/bg.c
4
src/bg.c
@@ -965,9 +965,9 @@ void CopyBgTilemapBufferToVram(u8 bg)
|
||||
}
|
||||
}
|
||||
|
||||
void CopyToBgTilemapBufferRect(u8 bg, void* src, u8 destX, u8 destY, u8 width, u8 height)
|
||||
void CopyToBgTilemapBufferRect(u8 bg, const void* src, u8 destX, u8 destY, u8 width, u8 height)
|
||||
{
|
||||
void* srcCopy;
|
||||
const void* srcCopy;
|
||||
u16 destX16;
|
||||
u16 destY16;
|
||||
u16 mode;
|
||||
|
||||
1035
src/item.c
1035
src/item.c
File diff suppressed because it is too large
Load Diff
@@ -4,13 +4,13 @@
|
||||
#include "sprite.h"
|
||||
#include "decompress.h"
|
||||
#include "constants/items.h"
|
||||
#include "data/item_icon_table.h"
|
||||
|
||||
// EWRAM vars
|
||||
EWRAM_DATA void *gItemIconDecompressionBuffer = NULL;
|
||||
EWRAM_DATA void *gItemIcon4x4Buffer = NULL;
|
||||
|
||||
// const rom data
|
||||
extern const void *const gItemIconTable[][2]; // todo: move to C file
|
||||
|
||||
static const struct OamData sOamData_ItemIcon =
|
||||
{
|
||||
|
||||
@@ -72,7 +72,7 @@ void AddBagItemIconSprite(u16, u8);
|
||||
void bag_menu_print_description_box_text(int);
|
||||
void bag_menu_print_cursor(u8, u8);
|
||||
void bag_menu_print(u8, u8, const u8*, u8, u8, u8, u8, u8, u8);
|
||||
bool8 itemid_is_unique(u16);
|
||||
bool8 ItemId_GetImportance(u16);
|
||||
u16 BagGetQuantityByPocketPosition(u8, u16);
|
||||
void sub_81AB89C(void);
|
||||
void task_close_bag_menu_2(u8);
|
||||
@@ -687,7 +687,7 @@ void sub_81AB520(u8 rboxId, int item_index_in_pocket, u8 a)
|
||||
offset = GetStringRightAlignXOffset(7, gStringVar4, 0x77);
|
||||
bag_menu_print(rboxId, 7, gStringVar4, offset, a, 0, 0, -1, 0);
|
||||
}
|
||||
else if (gUnknown_0203CE58.pocket != 4 && (unique = itemid_is_unique(itemId)) == FALSE)
|
||||
else if (gUnknown_0203CE58.pocket != 4 && (unique = ItemId_GetImportance(itemId)) == FALSE)
|
||||
{
|
||||
ConvertIntToDecimalStringN(gStringVar1, itemQuantity, 1, 2);
|
||||
StringExpandPlaceholders(gStringVar4, gText_xVar1);
|
||||
@@ -804,10 +804,10 @@ void sub_81AB9A8(u8 pocketId)
|
||||
{
|
||||
case 2:
|
||||
case 3:
|
||||
sub_80D6FB4(pocket);
|
||||
SortBerriesOrTMHMs(pocket);
|
||||
break;
|
||||
default:
|
||||
sub_80D6F64(pocket);
|
||||
CompactItemsInBagPocket(pocket);
|
||||
break;
|
||||
}
|
||||
gUnknown_0203CE54->unk829[pocketId] = 0;
|
||||
@@ -847,9 +847,9 @@ void sub_81ABAE0(void)
|
||||
sub_8122298(&gUnknown_0203CE58.scrollPosition[i], &gUnknown_0203CE58.cursorPosition[i], gUnknown_0203CE54->unk82E[i], gUnknown_0203CE54->unk829[i], 8);
|
||||
}
|
||||
|
||||
u8 sub_81ABB2C(u8 a)
|
||||
u8 sub_81ABB2C(u8 pocketId)
|
||||
{
|
||||
return gUnknown_0203CE58.scrollPosition[a] + gUnknown_0203CE58.cursorPosition[a];
|
||||
return gUnknown_0203CE58.scrollPosition[pocketId] + gUnknown_0203CE58.cursorPosition[pocketId];
|
||||
}
|
||||
|
||||
void DisplayItemMessage(u8 taskId, u8 fontId, const u8 *str, void ( *callback)(u8 taskId))
|
||||
@@ -1179,7 +1179,7 @@ void sub_81AC498(u8 taskId)
|
||||
sub_81AC590(taskId);
|
||||
else
|
||||
{
|
||||
sub_80D702C(gBagPockets[gUnknown_0203CE58.pocket].itemSlots, data[1], realPos);
|
||||
MoveItemSlotInList(gBagPockets[gUnknown_0203CE58.pocket].itemSlots, data[1], realPos);
|
||||
gUnknown_0203CE54->unk81A = -1;
|
||||
DestroyListMenuTask(data[0], scrollPos, cursorPos);
|
||||
if (data[1] < realPos)
|
||||
@@ -1231,7 +1231,7 @@ void sub_81AC644(u8 unused)
|
||||
gUnknown_0203CE54->unk828 = 4;
|
||||
break;
|
||||
case 8:
|
||||
if (!itemid_is_unique(gSpecialVar_ItemId) && gSpecialVar_ItemId != ITEM_ENIGMA_BERRY)
|
||||
if (!ItemId_GetImportance(gSpecialVar_ItemId) && gSpecialVar_ItemId != ITEM_ENIGMA_BERRY)
|
||||
{
|
||||
gUnknown_0203CE54->unk820 = gUnknown_0861404B;
|
||||
gUnknown_0203CE54->unk828 = 2;
|
||||
@@ -1243,7 +1243,7 @@ void sub_81AC644(u8 unused)
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
if (!itemid_is_unique(gSpecialVar_ItemId) && gSpecialVar_ItemId != ITEM_ENIGMA_BERRY)
|
||||
if (!ItemId_GetImportance(gSpecialVar_ItemId) && gSpecialVar_ItemId != ITEM_ENIGMA_BERRY)
|
||||
{
|
||||
gUnknown_0203CE54->unk820 = gUnknown_0861404D;
|
||||
gUnknown_0203CE54->unk828 = 2;
|
||||
@@ -1255,7 +1255,7 @@ void sub_81AC644(u8 unused)
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
if (!itemid_is_unique(gSpecialVar_ItemId) && gSpecialVar_ItemId != ITEM_ENIGMA_BERRY)
|
||||
if (!ItemId_GetImportance(gSpecialVar_ItemId) && gSpecialVar_ItemId != ITEM_ENIGMA_BERRY)
|
||||
{
|
||||
gUnknown_0203CE54->unk820 = gUnknown_0861404F;
|
||||
gUnknown_0203CE54->unk828 = 2;
|
||||
@@ -1605,7 +1605,7 @@ void ItemMenu_Give(u8 taskId)
|
||||
{
|
||||
DisplayItemMessage(taskId, 1, gText_CantWriteMail, sub_81AD350);
|
||||
}
|
||||
else if (!itemid_is_unique(gSpecialVar_ItemId))
|
||||
else if (!ItemId_GetImportance(gSpecialVar_ItemId))
|
||||
{
|
||||
if (CalculatePlayerPartyCount() == 0)
|
||||
bag_menu_print_there_is_no_pokemon(taskId);
|
||||
@@ -1686,7 +1686,7 @@ void item_menu_type_2(u8 taskId)
|
||||
StringExpandPlaceholders(gStringVar4, gText_Var1CantBeHeldHere);
|
||||
DisplayItemMessage(taskId, 1, gStringVar4, sub_81AD350);
|
||||
}
|
||||
else if (gUnknown_0203CE58.pocket != 4 && !itemid_is_unique(gSpecialVar_ItemId))
|
||||
else if (gUnknown_0203CE58.pocket != 4 && !ItemId_GetImportance(gSpecialVar_ItemId))
|
||||
{
|
||||
unknown_ItemMenu_Confirm(taskId);
|
||||
}
|
||||
@@ -1700,7 +1700,7 @@ void item_menu_type_b(u8 taskId)
|
||||
{
|
||||
if (ItemIsMail(gSpecialVar_ItemId) == TRUE)
|
||||
DisplayItemMessage(taskId, 1, gText_CantWriteMail, sub_81AD350);
|
||||
else if (gUnknown_0203CE58.pocket != 4 && !itemid_is_unique(gSpecialVar_ItemId))
|
||||
else if (gUnknown_0203CE58.pocket != 4 && !ItemId_GetImportance(gSpecialVar_ItemId))
|
||||
gTasks[taskId].func = unknown_ItemMenu_Confirm;
|
||||
else
|
||||
bag_menu_print_cant_be_held_msg(taskId);
|
||||
@@ -1738,7 +1738,7 @@ void display_sell_item_ask_str(u8 taskId)
|
||||
{
|
||||
s16* data = gTasks[taskId].data;
|
||||
|
||||
if (itemid_get_market_price(gSpecialVar_ItemId) == 0)
|
||||
if (ItemId_GetPrice(gSpecialVar_ItemId) == 0)
|
||||
{
|
||||
CopyItemName(gSpecialVar_ItemId, gStringVar2);
|
||||
StringExpandPlaceholders(gStringVar4, gText_CantBuyKeyItem);
|
||||
@@ -1765,7 +1765,7 @@ void sub_81AD680(u8 taskId)
|
||||
{
|
||||
s16* data = gTasks[taskId].data;
|
||||
|
||||
ConvertIntToDecimalStringN(gStringVar1, (itemid_get_market_price(gSpecialVar_ItemId) / 2) * data[8], 0, 6);
|
||||
ConvertIntToDecimalStringN(gStringVar1, (ItemId_GetPrice(gSpecialVar_ItemId) / 2) * data[8], 0, 6);
|
||||
StringExpandPlaceholders(gStringVar4, gText_ICanPayVar1);
|
||||
DisplayItemMessage(taskId, 1, gStringVar4, sub_81AD6E4);
|
||||
}
|
||||
@@ -1790,7 +1790,7 @@ void sub_81AD730(u8 taskId)
|
||||
s16* data = gTasks[taskId].data;
|
||||
u8 windowId = bag_menu_add_window(8);
|
||||
|
||||
sub_81ABCC0(windowId, 1, (itemid_get_market_price(gSpecialVar_ItemId) / 2) * data[8]);
|
||||
sub_81ABCC0(windowId, 1, (ItemId_GetPrice(gSpecialVar_ItemId) / 2) * data[8]);
|
||||
bag_menu_AddMoney_window();
|
||||
gTasks[taskId].func = sub_81AD794;
|
||||
}
|
||||
@@ -1801,7 +1801,7 @@ void sub_81AD794(u8 taskId)
|
||||
|
||||
if (AdjustQuantityAccordingToDPadInput(&data[8], data[2]) == TRUE)
|
||||
{
|
||||
sub_81ABCC0(gUnknown_0203CE54->unk818, data[8], (itemid_get_market_price(gSpecialVar_ItemId) / 2) * data[8]);
|
||||
sub_81ABCC0(gUnknown_0203CE54->unk818, data[8], (ItemId_GetPrice(gSpecialVar_ItemId) / 2) * data[8]);
|
||||
}
|
||||
else if (gMain.newKeys & A_BUTTON)
|
||||
{
|
||||
@@ -1825,7 +1825,7 @@ void sub_81AD84C(u8 taskId)
|
||||
s16* data = gTasks[taskId].data;
|
||||
|
||||
CopyItemName(gSpecialVar_ItemId, gStringVar2);
|
||||
ConvertIntToDecimalStringN(gStringVar1, (itemid_get_market_price(gSpecialVar_ItemId) / 2) * data[8], 0, 6);
|
||||
ConvertIntToDecimalStringN(gStringVar1, (ItemId_GetPrice(gSpecialVar_ItemId) / 2) * data[8], 0, 6);
|
||||
StringExpandPlaceholders(gStringVar4, gText_TurnedOverVar1ForVar2);
|
||||
DisplayItemMessage(taskId, 1, gStringVar4, sub_81AD8C8);
|
||||
}
|
||||
@@ -1838,7 +1838,7 @@ void sub_81AD8C8(u8 taskId)
|
||||
|
||||
PlaySE(SE_REGI);
|
||||
RemoveBagItem(gSpecialVar_ItemId, data[8]);
|
||||
AddMoney(&gSaveBlock1Ptr->money, (itemid_get_market_price(gSpecialVar_ItemId) / 2) * data[8]);
|
||||
AddMoney(&gSaveBlock1Ptr->money, (ItemId_GetPrice(gSpecialVar_ItemId) / 2) * data[8]);
|
||||
DestroyListMenuTask(data[0], scrollPos, cursorPos);
|
||||
sub_81AB9A8(gUnknown_0203CE58.pocket);
|
||||
sub_81ABA88(gUnknown_0203CE58.pocket);
|
||||
@@ -1908,7 +1908,7 @@ void sub_81ADB14(u8 taskId)
|
||||
s16* data = gTasks[taskId].data;
|
||||
|
||||
FillWindowPixelBuffer(1, 0);
|
||||
if (itemid_is_unique(gSpecialVar_ItemId))
|
||||
if (ItemId_GetImportance(gSpecialVar_ItemId))
|
||||
{
|
||||
bag_menu_print(1, 1, gText_CantStoreImportantItems, 3, 1, 0, 0, 0, 0);
|
||||
gTasks[taskId].func = sub_81ADC0C;
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
#include "berry.h"
|
||||
#include "graphics.h"
|
||||
#include "constants/items.h"
|
||||
#include "item.h"
|
||||
#include "item_use.h"
|
||||
#include "constants/hold_effects.h"
|
||||
|
||||
struct CompressedTilesPal
|
||||
{
|
||||
@@ -466,6 +469,9 @@ const struct SpriteTemplate gUnknown_0857FE88 =
|
||||
.callback = sub_80D5B48,
|
||||
};
|
||||
|
||||
#include "data/text/item_descriptions.h"
|
||||
#include "data/items.h"
|
||||
|
||||
// code
|
||||
void RemoveBagSprite(u8 id)
|
||||
{
|
||||
|
||||
@@ -392,7 +392,7 @@ bool8 sub_818DC60(void)
|
||||
|
||||
static void sub_818DCAC(u8 *dest, u16 itemId)
|
||||
{
|
||||
StringCopy(dest, ItemId_GetItem(itemId)->name);
|
||||
StringCopy(dest, ItemId_GetName(itemId));
|
||||
}
|
||||
|
||||
void sub_818DCC8(void)
|
||||
@@ -671,7 +671,7 @@ static u8 sub_818E258(const u8 *str)
|
||||
|
||||
void sub_818E274(void)
|
||||
{
|
||||
StringCopy(gStringVar1, ItemId_GetItem(gUnknown_0203CD68->itemId)->name);
|
||||
StringCopy(gStringVar1, ItemId_GetName(gUnknown_0203CD68->itemId));
|
||||
}
|
||||
|
||||
bool8 sub_818E298(void)
|
||||
|
||||
@@ -4,33 +4,30 @@
|
||||
#include "main.h"
|
||||
#include "pokemon.h"
|
||||
#include "random.h"
|
||||
#include "malloc.h"
|
||||
#include "item.h"
|
||||
|
||||
extern void* gUnknown_0203CF5C;
|
||||
|
||||
extern bool16 IdentifyFlash(void);
|
||||
extern void SetBagItemsPointers(void);
|
||||
extern void SetDecorationInventoriesPointers(void);
|
||||
extern void ApplyNewEncryptionKeyToGameStats(u32 key);
|
||||
extern void ApplyNewEncryptionKeyToBagItems(u32 newKey);
|
||||
extern void ApplyNewEncryptionKeyToBagItems_(u32 key);
|
||||
extern void ApplyNewEncryptionKeyToBerryPowder(u32 key);
|
||||
extern void sub_8084FAC(int unused);
|
||||
|
||||
// this is probably wrong or misleading due to it being used in ResetHeap...
|
||||
extern void InitHeap(void *pointer, u32 size);
|
||||
|
||||
#define SAVEBLOCK_MOVE_RANGE 128
|
||||
|
||||
struct LoadedSaveData
|
||||
{
|
||||
/*0x0000*/ struct ItemSlot items[30];
|
||||
/*0x0078*/ struct ItemSlot keyItems[30];
|
||||
/*0x00F0*/ struct ItemSlot pokeBalls[16];
|
||||
/*0x0130*/ struct ItemSlot TMsHMs[64];
|
||||
/*0x0230*/ struct ItemSlot berries[46];
|
||||
/*0x0000*/ struct ItemSlot items[BAG_ITEMS_COUNT];
|
||||
/*0x0078*/ struct ItemSlot keyItems[BAG_KEYITEMS_COUNT];
|
||||
/*0x00F0*/ struct ItemSlot pokeBalls[BAG_POKEBALLS_COUNT];
|
||||
/*0x0130*/ struct ItemSlot TMsHMs[BAG_TMHM_COUNT];
|
||||
/*0x0230*/ struct ItemSlot berries[BAG_BERRIES_COUNT];
|
||||
/*0x02E8*/ struct MailStruct mail[MAIL_COUNT];
|
||||
};
|
||||
|
||||
// EWRAM DATA
|
||||
EWRAM_DATA struct SaveBlock2 gSaveblock2 = {0};
|
||||
EWRAM_DATA u8 gSaveblock2_DMA[SAVEBLOCK_MOVE_RANGE] = {0};
|
||||
|
||||
@@ -43,8 +40,13 @@ EWRAM_DATA u8 gSaveblock3_DMA[SAVEBLOCK_MOVE_RANGE] = {0};
|
||||
EWRAM_DATA struct LoadedSaveData gLoadedSaveData = {0};
|
||||
EWRAM_DATA u32 gLastEncryptionKey = {0};
|
||||
|
||||
void ApplyNewEncryptionKeyToAllEncryptedData(u32 encryptionKey);
|
||||
// IWRAM common
|
||||
IWRAM_DATA bool32 gFlashMemoryPresent;
|
||||
IWRAM_DATA struct SaveBlock1 *gSaveBlock1Ptr;
|
||||
IWRAM_DATA struct SaveBlock2 *gSaveBlock2Ptr;
|
||||
IWRAM_DATA struct PokemonStorage *gPokemonStoragePtr;
|
||||
|
||||
// code
|
||||
void CheckForFlashMemory(void)
|
||||
{
|
||||
if (!IdentifyFlash())
|
||||
@@ -53,7 +55,9 @@ void CheckForFlashMemory(void)
|
||||
InitFlashTimer();
|
||||
}
|
||||
else
|
||||
{
|
||||
gFlashMemoryPresent = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
void ClearSav2(void)
|
||||
@@ -80,8 +84,6 @@ void SetSaveBlocksPointers(u16 offset)
|
||||
SetDecorationInventoriesPointers();
|
||||
}
|
||||
|
||||
extern u8 gHeap[];
|
||||
|
||||
void MoveSaveBlocks_ResetHeap(void)
|
||||
{
|
||||
void *vblankCB, *hblankCB;
|
||||
@@ -132,7 +134,6 @@ void MoveSaveBlocks_ResetHeap(void)
|
||||
gSaveBlock2Ptr->encryptionKey = encryptionKey;
|
||||
}
|
||||
|
||||
|
||||
u32 GetSecretBase2Field_9(void)
|
||||
{
|
||||
return gSaveBlock2Ptr->specialSaveWarp & 1;
|
||||
@@ -159,112 +160,112 @@ void sav2_gender2_inplace_and_xFE(void)
|
||||
gSaveBlock2Ptr->specialSaveWarp &= ~1;
|
||||
}
|
||||
|
||||
void copy_player_party_to_sav1(void) // SavePlayerParty
|
||||
void SavePlayerParty(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
gSaveBlock1Ptr->playerPartyCount = gPlayerPartyCount;
|
||||
|
||||
for (i = 0; i < 6; i++)
|
||||
for (i = 0; i < PARTY_SIZE; i++)
|
||||
gSaveBlock1Ptr->playerParty[i] = gPlayerParty[i];
|
||||
}
|
||||
|
||||
void copy_player_party_from_sav1(void) // LoadPlayerParty
|
||||
void LoadPlayerParty(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
gPlayerPartyCount = gSaveBlock1Ptr->playerPartyCount;
|
||||
|
||||
for (i = 0; i < 6; i++)
|
||||
for (i = 0; i < PARTY_SIZE; i++)
|
||||
gPlayerParty[i] = gSaveBlock1Ptr->playerParty[i];
|
||||
}
|
||||
|
||||
void save_serialize_npcs(void) // SaveMapObjects
|
||||
void SaveMapObjects(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
for (i = 0; i < MAP_OBJECTS_COUNT; i++)
|
||||
gSaveBlock1Ptr->mapObjects[i] = gMapObjects[i];
|
||||
}
|
||||
|
||||
void save_deserialize_npcs(void) // LoadMapObjects
|
||||
void LoadMapObjects(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
for (i = 0; i < MAP_OBJECTS_COUNT; i++)
|
||||
gMapObjects[i] = gSaveBlock1Ptr->mapObjects[i];
|
||||
}
|
||||
|
||||
void SaveSerializedGame(void)
|
||||
{
|
||||
copy_player_party_to_sav1();
|
||||
save_serialize_npcs();
|
||||
SavePlayerParty();
|
||||
SaveMapObjects();
|
||||
}
|
||||
|
||||
void LoadSerializedGame(void)
|
||||
{
|
||||
copy_player_party_from_sav1();
|
||||
save_deserialize_npcs();
|
||||
LoadPlayerParty();
|
||||
LoadMapObjects();
|
||||
}
|
||||
|
||||
void copy_bags_and_unk_data_from_save_blocks(void)
|
||||
void LoadPlayerBag(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
// load player items.
|
||||
for (i = 0; i < 30; i++)
|
||||
for (i = 0; i < BAG_ITEMS_COUNT; i++)
|
||||
gLoadedSaveData.items[i] = gSaveBlock1Ptr->bagPocket_Items[i];
|
||||
|
||||
// load player key items.
|
||||
for (i = 0; i < 30; i++)
|
||||
for (i = 0; i < BAG_KEYITEMS_COUNT; i++)
|
||||
gLoadedSaveData.keyItems[i] = gSaveBlock1Ptr->bagPocket_KeyItems[i];
|
||||
|
||||
// load player pokeballs.
|
||||
for (i = 0; i < 16; i++)
|
||||
for (i = 0; i < BAG_POKEBALLS_COUNT; i++)
|
||||
gLoadedSaveData.pokeBalls[i] = gSaveBlock1Ptr->bagPocket_PokeBalls[i];
|
||||
|
||||
// load player TMs and HMs.
|
||||
for (i = 0; i < 64; i++)
|
||||
for (i = 0; i < BAG_TMHM_COUNT; i++)
|
||||
gLoadedSaveData.TMsHMs[i] = gSaveBlock1Ptr->bagPocket_TMHM[i];
|
||||
|
||||
// load player berries.
|
||||
for (i = 0; i < 46; i++)
|
||||
for (i = 0; i < BAG_BERRIES_COUNT; i++)
|
||||
gLoadedSaveData.berries[i] = gSaveBlock1Ptr->bagPocket_Berries[i];
|
||||
|
||||
// load mail.
|
||||
for (i = 0; i < 16; i++)
|
||||
for (i = 0; i < MAIL_COUNT; i++)
|
||||
gLoadedSaveData.mail[i] = gSaveBlock1Ptr->mail[i];
|
||||
|
||||
gLastEncryptionKey = gSaveBlock2Ptr->encryptionKey;
|
||||
}
|
||||
|
||||
void copy_bags_and_unk_data_to_save_blocks(void)
|
||||
void SavePlayerBag(void)
|
||||
{
|
||||
int i;
|
||||
u32 encryptionKeyBackup;
|
||||
|
||||
// save player items.
|
||||
for (i = 0; i < 30; i++)
|
||||
for (i = 0; i < BAG_ITEMS_COUNT; i++)
|
||||
gSaveBlock1Ptr->bagPocket_Items[i] = gLoadedSaveData.items[i];
|
||||
|
||||
// save player key items.
|
||||
for (i = 0; i < 30; i++)
|
||||
for (i = 0; i < BAG_KEYITEMS_COUNT; i++)
|
||||
gSaveBlock1Ptr->bagPocket_KeyItems[i] = gLoadedSaveData.keyItems[i];
|
||||
|
||||
// save player pokeballs.
|
||||
for (i = 0; i < 16; i++)
|
||||
for (i = 0; i < BAG_POKEBALLS_COUNT; i++)
|
||||
gSaveBlock1Ptr->bagPocket_PokeBalls[i] = gLoadedSaveData.pokeBalls[i];
|
||||
|
||||
// save player TMs and HMs.
|
||||
for (i = 0; i < 64; i++)
|
||||
for (i = 0; i < BAG_TMHM_COUNT; i++)
|
||||
gSaveBlock1Ptr->bagPocket_TMHM[i] = gLoadedSaveData.TMsHMs[i];
|
||||
|
||||
// save player berries.
|
||||
for (i = 0; i < 46; i++)
|
||||
for (i = 0; i < BAG_BERRIES_COUNT; i++)
|
||||
gSaveBlock1Ptr->bagPocket_Berries[i] = gLoadedSaveData.berries[i];
|
||||
|
||||
// save mail.
|
||||
for (i = 0; i < 16; i++)
|
||||
for (i = 0; i < MAIL_COUNT; i++)
|
||||
gSaveBlock1Ptr->mail[i] = gLoadedSaveData.mail[i];
|
||||
|
||||
encryptionKeyBackup = gSaveBlock2Ptr->encryptionKey;
|
||||
|
||||
@@ -20,8 +20,10 @@
|
||||
#include "tv.h"
|
||||
#include "coins.h"
|
||||
#include "text.h"
|
||||
#include "overworld.h"
|
||||
#include "mail.h"
|
||||
#include "battle_records.h"
|
||||
|
||||
extern u8 gPlayerPartyCount;
|
||||
extern u8 gDifferentSaveFile;
|
||||
extern u16 gSaveFileStatus;
|
||||
extern u8 gUnknown_030060B0;
|
||||
@@ -29,19 +31,15 @@ extern u8 gUnknown_030060B0;
|
||||
// TODO: replace those declarations with file headers
|
||||
extern u16 GetGeneratedTrainerIdLower(void);
|
||||
extern void ClearContestWinnerPicsInContestHall(void);
|
||||
extern void Overworld_SetWarpDestination(s8 mapBank, s8 mapNo, s8 warpNo, s8 xPos, s8 yPos);
|
||||
extern void warp_in(void);
|
||||
extern void sub_80BB358(void);
|
||||
extern void ResetBagScrollPositions(void);
|
||||
extern void ResetPokedex(void);
|
||||
extern void sub_8084400(void);
|
||||
extern void ClearMailData(void);
|
||||
extern void ResetGabbyAndTy(void);
|
||||
extern void ResetSecretBases(void);
|
||||
extern void ResetLinkContestBoolean(void);
|
||||
extern void ResetGameStats(void);
|
||||
extern void sub_8052DA8(void);
|
||||
extern void InitLinkBattleRecords(void);
|
||||
extern void ResetPokemonStorageSystem(void);
|
||||
extern void ClearBag(void);
|
||||
extern void NewGameInitPCItems(void);
|
||||
@@ -58,7 +56,7 @@ extern void ResetContestLinkResults(void);
|
||||
extern void ResetPokeJumpResults(void);
|
||||
extern void SetBerryPowder(u32* powder, u32 newValue);
|
||||
|
||||
extern u8 EventScript_2715DE[];
|
||||
extern const u8 EventScript_2715DE[];
|
||||
|
||||
void WriteUnalignedWord(u32 var, u8 *dataPtr)
|
||||
{
|
||||
@@ -178,7 +176,7 @@ void NewGameInitData(void)
|
||||
ResetLinkContestBoolean();
|
||||
ResetGameStats();
|
||||
ClearAllContestWinnerPics();
|
||||
InitLinkBattleRecords();
|
||||
ClearPlayerLinkBattleRecords();
|
||||
InitSeedotSizeRecord();
|
||||
InitLotadSizeRecord();
|
||||
gPlayerPartyCount = 0;
|
||||
|
||||
@@ -444,7 +444,7 @@ static void ItemStorage_Withdraw(u8 taskId)
|
||||
{
|
||||
s16 *data = gTasks[taskId].data;
|
||||
|
||||
NUM_ITEMS = sub_80D6CE4();
|
||||
NUM_ITEMS = CountUsedPCItemSlots();
|
||||
if (NUM_ITEMS != 0)
|
||||
ItemStorage_WithdrawToss_Helper(taskId, FALSE);
|
||||
else
|
||||
@@ -459,7 +459,7 @@ static void ItemStorage_Toss(u8 taskId)
|
||||
{
|
||||
s16 *data = gTasks[taskId].data;
|
||||
|
||||
NUM_ITEMS = sub_80D6CE4();
|
||||
NUM_ITEMS = CountUsedPCItemSlots();
|
||||
if (NUM_ITEMS != 0)
|
||||
ItemStorage_WithdrawToss_Helper(taskId, TRUE);
|
||||
else
|
||||
@@ -967,7 +967,7 @@ static void sub_816C0C8(void)
|
||||
|
||||
static void sub_816C110(void)
|
||||
{
|
||||
sub_80D6E84();
|
||||
CompactPCItems();
|
||||
sub_812220C(gSaveBlock1Ptr->pcItems, 50, &(playerPCItemPageInfo.pageItems), &(playerPCItemPageInfo.count), 0x8);
|
||||
}
|
||||
|
||||
@@ -1180,7 +1180,7 @@ static void ItemStorage_DoItemSwap(u8 taskId, bool8 a)
|
||||
{
|
||||
if(c != b - 1)
|
||||
{
|
||||
sub_80D702C(gSaveBlock1Ptr->pcItems, c, b);
|
||||
MoveItemSlotInList(gSaveBlock1Ptr->pcItems, c, b);
|
||||
ItemStorage_RefreshListMenu();
|
||||
}
|
||||
}
|
||||
@@ -1301,7 +1301,7 @@ static void ItemStorage_DoItemToss(u8 taskId)
|
||||
|
||||
data = gTasks[taskId].data;
|
||||
b = (playerPCItemPageInfo.cursorPos + playerPCItemPageInfo.itemsAbove);
|
||||
if(!itemid_is_unique(gSaveBlock1Ptr->pcItems[b].itemId))
|
||||
if(!ItemId_GetImportance(gSaveBlock1Ptr->pcItems[b].itemId))
|
||||
{
|
||||
CopyItemName(gSaveBlock1Ptr->pcItems[b].itemId, gStringVar1);
|
||||
ConvertIntToDecimalStringN(gStringVar2, data[2], STR_CONV_MODE_LEFT_ALIGN, 3);
|
||||
@@ -1335,7 +1335,7 @@ static void ItemStorage_HandleRemoveItem(u8 taskId)
|
||||
data = gTasks[taskId].data;
|
||||
if(gMain.newKeys & (A_BUTTON | B_BUTTON))
|
||||
{
|
||||
sub_80D6E48((playerPCItemPageInfo.cursorPos + playerPCItemPageInfo.itemsAbove), data[2]);
|
||||
RemovePCItem((playerPCItemPageInfo.cursorPos + playerPCItemPageInfo.itemsAbove), data[2]);
|
||||
DestroyListMenuTask(data[5], &(playerPCItemPageInfo.itemsAbove), &(playerPCItemPageInfo.cursorPos));
|
||||
sub_816C110();
|
||||
sub_816C140();
|
||||
|
||||
@@ -589,7 +589,7 @@ static void PutPokeblockInfoText(void)
|
||||
{
|
||||
u8 i;
|
||||
|
||||
const u8 *itemName = ItemId_GetItem(ITEM_POKEBLOCK_CASE)->name;
|
||||
const u8 *itemName = ItemId_GetName(ITEM_POKEBLOCK_CASE);
|
||||
PrintOnPokeblockWindow(0, itemName, GetStringCenterAlignXOffset(1, itemName, 0x48));
|
||||
|
||||
PrintOnPokeblockWindow(2, gText_Spicy, 0);
|
||||
|
||||
@@ -3173,11 +3173,11 @@ void sub_81C3554(u8 taskId)
|
||||
|
||||
void sub_81C35E4()
|
||||
{
|
||||
u8 *text;
|
||||
const u8 *text;
|
||||
int offset;
|
||||
if (gUnknown_0203CF1C->summary.item == ITEM_ENIGMA_BERRY && sub_81B1250() == 1 && (gUnknown_0203CF1C->unk40BE == 1 || gUnknown_0203CF1C->unk40BE == 4 || gUnknown_0203CF1C->unk40BE == 5))
|
||||
{
|
||||
text = (u8*)ItemId_GetItem(ITEM_ENIGMA_BERRY);
|
||||
text = ItemId_GetName(ITEM_ENIGMA_BERRY);
|
||||
}
|
||||
else if (gUnknown_0203CF1C->summary.item == ITEM_NONE)
|
||||
text = gText_None;
|
||||
|
||||
@@ -7,6 +7,10 @@
|
||||
EWRAM_DATA static u8 sUnknown = 0;
|
||||
EWRAM_DATA static u32 sRandCount = 0;
|
||||
|
||||
// IWRAM common
|
||||
IWRAM_DATA u32 gRngValue;
|
||||
IWRAM_DATA u32 gRng2Value;
|
||||
|
||||
u16 Random(void)
|
||||
{
|
||||
gRngValue = 1103515245 * gRngValue + 24691;
|
||||
|
||||
31
src/save.c
31
src/save.c
@@ -4,17 +4,15 @@
|
||||
#include "constants/game_stat.h"
|
||||
#include "task.h"
|
||||
#include "decompress.h"
|
||||
#include "load_save.h"
|
||||
#include "overworld.h"
|
||||
|
||||
// for the chunk declarations
|
||||
extern struct SaveBlock2 gSaveblock2;
|
||||
extern struct SaveBlock1 gSaveblock1;
|
||||
extern struct PokemonStorage gPokemonStorage;
|
||||
|
||||
extern struct SaveSectionLocation gRamSaveSectionLocations[0xE];
|
||||
extern u8 gDecompressionBuffer[];
|
||||
extern u32 gFlashMemoryPresent;
|
||||
extern u16 gUnknown_03006294;
|
||||
extern bool8 gSoftResetDisabled;
|
||||
extern u32 gUnknown_0203CF5C;
|
||||
|
||||
// Divide save blocks into individual chunks to be written to flash sectors
|
||||
|
||||
@@ -24,13 +22,13 @@ extern bool8 gSoftResetDisabled;
|
||||
|
||||
/*
|
||||
* Sector Layout:
|
||||
*
|
||||
*
|
||||
* Sectors 0 - 13: Save Slot 1
|
||||
* Sectors 14 - 27: Save Slot 2
|
||||
* Sectors 28 - 29: Hall of Fame
|
||||
* Sector 30: e-Reader/Mystery Gift Stuff (note: e-Reader is deprecated in Emerald US)
|
||||
* Sector 31: Recorded Battle
|
||||
*
|
||||
*
|
||||
* There are two save slots for saving the player's game data. We alternate between
|
||||
* them each time the game is saved, so that if the current save slot is corrupt,
|
||||
* we can load the previous one. We also rotate the sectors in each save slot
|
||||
@@ -41,7 +39,7 @@ extern bool8 gSoftResetDisabled;
|
||||
|
||||
// (u8 *)structure was removed from the first statement of the macro in Emerald.
|
||||
// This is because malloc is used to allocate addresses so storing the raw
|
||||
// addresses should not be done in the offsets information.
|
||||
// addresses should not be done in the offsets information.
|
||||
#define SAVEBLOCK_CHUNK(structure, chunkNum) \
|
||||
{ \
|
||||
chunkNum * SECTOR_DATA_SIZE, \
|
||||
@@ -69,8 +67,10 @@ const struct SaveSectionOffsets gSaveSectionOffsets[] =
|
||||
};
|
||||
|
||||
extern void DoSaveFailedScreen(u8); // save_failed_screen
|
||||
extern void LoadSerializedGame(void); // load_save
|
||||
extern bool32 ProgramFlashSectorAndVerify(u8 sector, u8 *data);
|
||||
extern void save_serialize_map(void);
|
||||
extern void sub_800ADF8(void);
|
||||
extern bool8 sub_800A520(void);
|
||||
|
||||
// iwram common
|
||||
u16 gLastWrittenSector;
|
||||
@@ -656,11 +656,6 @@ void UpdateSaveAddresses(void)
|
||||
}
|
||||
}
|
||||
|
||||
extern u32 GetGameStat(u8 index); // rom4
|
||||
extern void IncrementGameStat(u8 index); // rom4
|
||||
extern void SaveSerializedGame(void); // load_save
|
||||
extern u32 gUnknown_0203CF5C;
|
||||
|
||||
u8 HandleSavingData(u8 saveType)
|
||||
{
|
||||
u8 i;
|
||||
@@ -836,7 +831,7 @@ u16 sub_815355C(void)
|
||||
struct SaveSection* savSection;
|
||||
|
||||
savSection = gFastSaveSection = &gSaveDataBuffer;
|
||||
if (gFlashMemoryPresent != 1)
|
||||
if (gFlashMemoryPresent != TRUE)
|
||||
return 0;
|
||||
UpdateSaveAddresses();
|
||||
GetSaveValidStatus(gRamSaveSectionLocations);
|
||||
@@ -897,12 +892,6 @@ u32 sub_8153634(u8 sector, u8* src)
|
||||
return 1;
|
||||
}
|
||||
|
||||
extern void save_serialize_map(void);
|
||||
extern void sub_8076D5C(void);
|
||||
extern void sav2_gender2_inplace_and_xFE(void);
|
||||
extern void sub_800ADF8(void);
|
||||
extern bool8 sub_800A520(void);
|
||||
|
||||
void sub_8153688(u8 taskId)
|
||||
{
|
||||
s16* taskData = gTasks[taskId].data;
|
||||
|
||||
209
src/trader.c
Normal file
209
src/trader.c
Normal file
@@ -0,0 +1,209 @@
|
||||
#include "global.h"
|
||||
#include "constants/decorations.h"
|
||||
#include "constants/mauville_man.h"
|
||||
#include "decoration.h"
|
||||
#include "decoration_inventory.h"
|
||||
#include "event_data.h"
|
||||
#include "main.h"
|
||||
#include "menu.h"
|
||||
#include "menu_helpers.h"
|
||||
#include "script.h"
|
||||
#include "constants/songs.h"
|
||||
#include "sound.h"
|
||||
#include "string_util.h"
|
||||
#include "strings.h"
|
||||
#include "task.h"
|
||||
#include "script_menu.h"
|
||||
|
||||
static const u8 * const gUnknown_085B09E4[] =
|
||||
{
|
||||
gText_Tristan,
|
||||
gText_Philip,
|
||||
gText_Dennis,
|
||||
gText_Roberto,
|
||||
};
|
||||
|
||||
static const u8 gTraderDecorations[] =
|
||||
{
|
||||
DECOR_DUSKULL_DOLL,
|
||||
DECOR_BALL_CUSHION,
|
||||
DECOR_TIRE,
|
||||
DECOR_PRETTY_FLOWERS,
|
||||
};
|
||||
|
||||
void TraderSetup(void)
|
||||
{
|
||||
u8 i;
|
||||
struct MauvilleOldManTrader *trader = &gSaveBlock1Ptr->oldMan.trader;
|
||||
|
||||
trader->id = MAUVILLE_MAN_TRADER;
|
||||
trader->alreadyTraded = FALSE;
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
StringCopy(trader->unk5[i], gUnknown_085B09E4[i]);
|
||||
trader->unk1[i] = gTraderDecorations[i];
|
||||
trader->language[i] = GAME_LANGUAGE;
|
||||
}
|
||||
}
|
||||
|
||||
void sub_8133A60(void)
|
||||
{
|
||||
struct MauvilleOldManTrader *trader = &gSaveBlock1Ptr->oldMan.trader;
|
||||
trader->alreadyTraded = FALSE;
|
||||
}
|
||||
|
||||
void CreateAvailableDecorationsMenu(u8 taskId)
|
||||
{
|
||||
u8 i;
|
||||
s16 * data = gTasks[taskId].data;
|
||||
struct MauvilleOldManTrader *trader = &gSaveBlock1Ptr->oldMan.trader;
|
||||
struct WindowTemplate windowTemplate = {0, 1, 1, 10, 10, 15, 1};
|
||||
s32 windowWidth = GetStringWidth(1, gText_Exit, 0);
|
||||
s32 fiveMarksWidth = GetStringWidth(1, gText_FiveMarks, 0);
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
s32 curWidth;
|
||||
if (trader->unk1[i] > NUM_DECORATIONS)
|
||||
curWidth = fiveMarksWidth;
|
||||
else
|
||||
curWidth = GetStringWidth(1, gDecorations[trader->unk1[i]].name, 0);
|
||||
if (curWidth > windowWidth)
|
||||
windowWidth = curWidth;
|
||||
}
|
||||
windowTemplate.width = convert_pixel_width_to_tile_width(windowWidth);
|
||||
data[3] = AddWindow(&windowTemplate);
|
||||
SetWindowBorderStyle(data[3], FALSE, 0x214, 14);
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if (trader->unk1[i] > NUM_DECORATIONS)
|
||||
PrintTextOnWindow(data[3], 1, gText_FiveMarks, 8, 16 * i + 1, 255, NULL);
|
||||
else
|
||||
PrintTextOnWindow(data[3], 1, gDecorations[trader->unk1[i]].name, 8, 16 * i + 1, 255, NULL);
|
||||
}
|
||||
PrintTextOnWindow(data[3], 1, gText_Exit, 8, 16 * i + 1, 255, NULL);
|
||||
InitMenuInUpperLeftCornerPlaySoundWhenAPressed(data[3], 5, 0);
|
||||
schedule_bg_copy_tilemap_to_vram(0);
|
||||
}
|
||||
|
||||
void sub_8133BE4(u8 taskId, u8 decorationId)
|
||||
{
|
||||
s16 * data = gTasks[taskId].data;
|
||||
if (decorationId > NUM_DECORATIONS)
|
||||
{
|
||||
gSpecialVar_0x8004 = 0xFFFF;
|
||||
}
|
||||
else
|
||||
{
|
||||
gSpecialVar_0x8004 = decorationId;
|
||||
}
|
||||
|
||||
sub_8198070(data[3], FALSE);
|
||||
ClearWindowTilemap(data[3]);
|
||||
RemoveWindow(data[3]);
|
||||
schedule_bg_copy_tilemap_to_vram(0);
|
||||
DestroyTask(taskId);
|
||||
EnableBothScriptContexts();
|
||||
}
|
||||
|
||||
void Task_HandleGetDecorationMenuInput(u8 taskId)
|
||||
{
|
||||
struct MauvilleOldManTrader *trader = &gSaveBlock1Ptr->oldMan.trader;
|
||||
s8 input = ProcessMenuInput();
|
||||
|
||||
switch (input)
|
||||
{
|
||||
case -2:
|
||||
break;
|
||||
case -1:
|
||||
case 4:
|
||||
PlaySE(SE_SELECT);
|
||||
sub_8133BE4(taskId, 0);
|
||||
break;
|
||||
default:
|
||||
PlaySE(SE_SELECT);
|
||||
gSpecialVar_0x8005 = input;
|
||||
StringCopy(gStringVar1, trader->unk5[input]);
|
||||
ConvertInternationalString(gStringVar1, trader->language[input]);
|
||||
sub_8133BE4(taskId, trader->unk1[input]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ScrSpecial_GetTraderTradedFlag(void)
|
||||
{
|
||||
struct MauvilleOldManTrader *trader = &gSaveBlock1Ptr->oldMan.trader;
|
||||
gSpecialVar_Result = trader->alreadyTraded;
|
||||
}
|
||||
|
||||
void ScrSpecial_DoesPlayerHaveNoDecorations(void)
|
||||
{
|
||||
u8 i;
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
if (CountDecorationCategoryN(i))
|
||||
{
|
||||
gSpecialVar_Result = FALSE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
gSpecialVar_Result = TRUE;
|
||||
}
|
||||
|
||||
void ScrSpecial_IsDecorationFull(void)
|
||||
{
|
||||
gSpecialVar_Result = FALSE;
|
||||
if (gDecorations[gSpecialVar_0x8004].category != gDecorations[gSpecialVar_0x8006].category
|
||||
&& GetFirstEmptyDecorSlot(gDecorations[gSpecialVar_0x8004].category) == -1)
|
||||
{
|
||||
sub_8127250(gStringVar2, gDecorations[gSpecialVar_0x8004].category);
|
||||
gSpecialVar_Result = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
void ScrSpecial_TraderMenuGiveDecoration(void)
|
||||
{
|
||||
CreateTask(sub_8127208, 0);
|
||||
}
|
||||
|
||||
void sub_8133DA0(u8 taskId)
|
||||
{
|
||||
if (IsSelectedDecorInThePC() == TRUE)
|
||||
{
|
||||
gSpecialVar_0x8006 = gCurDecorInventoryItems[gCurDecorationIndex];
|
||||
StringCopy(gStringVar3, gDecorations[gSpecialVar_0x8004].name);
|
||||
StringCopy(gStringVar2, gDecorations[gSpecialVar_0x8006].name);
|
||||
}
|
||||
else
|
||||
{
|
||||
gSpecialVar_0x8006 = 0xFFFF;
|
||||
}
|
||||
DestroyTask(taskId);
|
||||
EnableBothScriptContexts();
|
||||
}
|
||||
|
||||
void sub_8133E1C(u8 taskId)
|
||||
{
|
||||
gSpecialVar_0x8006 = 0;
|
||||
DestroyTask(taskId);
|
||||
EnableBothScriptContexts();
|
||||
}
|
||||
|
||||
void ScrSpecial_TraderDoDecorationTrade(void)
|
||||
{
|
||||
struct MauvilleOldManTrader *trader = &gSaveBlock1Ptr->oldMan.trader;
|
||||
|
||||
DecorationRemove(gSpecialVar_0x8006);
|
||||
DecorationAdd(gSpecialVar_0x8004);
|
||||
StringCopy(trader->unk5[gSpecialVar_0x8005], gSaveBlock2Ptr->playerName);
|
||||
trader->unk1[gSpecialVar_0x8005] = gSpecialVar_0x8006;
|
||||
trader->language[gSpecialVar_0x8005] = GAME_LANGUAGE;
|
||||
trader->alreadyTraded = TRUE;
|
||||
}
|
||||
|
||||
void ScrSpecial_TraderMenuGetDecoration(void)
|
||||
{
|
||||
u8 taskId = CreateTask(Task_HandleGetDecorationMenuInput, 0);
|
||||
CreateAvailableDecorationsMenu(taskId);
|
||||
}
|
||||
30
src/tv.c
30
src/tv.c
@@ -1380,13 +1380,13 @@ void PutFanClubSpecialOnTheAir(void)
|
||||
StringCopy(show->fanClubSpecial.idolName, name);
|
||||
tv_store_id_2x(show);
|
||||
show->fanClubSpecial.language = gGameLanguage;
|
||||
if (show->fanClubSpecial.language == LANGUAGE_JAPANESE || gSaveBlock1Ptr->unk_31A0 == LANGUAGE_JAPANESE)
|
||||
if (show->fanClubSpecial.language == LANGUAGE_JAPANESE || gSaveBlock1Ptr->linkBattleRecords.languages[0] == LANGUAGE_JAPANESE)
|
||||
{
|
||||
show->fanClubSpecial.idolNameLanguage = LANGUAGE_JAPANESE;
|
||||
}
|
||||
else
|
||||
{
|
||||
show->fanClubSpecial.idolNameLanguage = gSaveBlock1Ptr->unk_31A0;
|
||||
show->fanClubSpecial.idolNameLanguage = gSaveBlock1Ptr->linkBattleRecords.languages[0];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2465,7 +2465,7 @@ bool8 sub_80EE7C0(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
if (gSaveBlock1Ptr->linkBattleRecords[0].name[0] == EOS)
|
||||
if (gSaveBlock1Ptr->linkBattleRecords.entries[0].name[0] == EOS)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
@@ -2945,7 +2945,7 @@ static void sub_80EF40C(u8 varIdx, TVShow *show)
|
||||
{
|
||||
if (show->smartshopperShow.itemIds[i] != ITEM_NONE)
|
||||
{
|
||||
price += itemid_get_market_price(show->smartshopperShow.itemIds[i]) * show->smartshopperShow.itemAmounts[i];
|
||||
price += ItemId_GetPrice(show->smartshopperShow.itemIds[i]) * show->smartshopperShow.itemAmounts[i];
|
||||
}
|
||||
}
|
||||
if (show->smartshopperShow.priceReduced == TRUE)
|
||||
@@ -5120,7 +5120,7 @@ static void DoTVShowTodaysSmartShopper(void)
|
||||
break;
|
||||
case 1:
|
||||
TVShowConvertInternationalString(gStringVar1, show->smartshopperShow.playerName, show->smartshopperShow.language);
|
||||
StringCopy(gStringVar2, ItemId_GetItem(show->smartshopperShow.itemIds[0])->name);
|
||||
StringCopy(gStringVar2, ItemId_GetName(show->smartshopperShow.itemIds[0]));
|
||||
TV_PrintIntToStringVar(2, show->smartshopperShow.itemAmounts[0]);
|
||||
sTVShowState += 1 + (Random() % 4);
|
||||
break;
|
||||
@@ -5148,7 +5148,7 @@ static void DoTVShowTodaysSmartShopper(void)
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
StringCopy(gStringVar2, ItemId_GetItem(show->smartshopperShow.itemIds[1])->name);
|
||||
StringCopy(gStringVar2, ItemId_GetName(show->smartshopperShow.itemIds[1]));
|
||||
TV_PrintIntToStringVar(2, show->smartshopperShow.itemAmounts[1]);
|
||||
if (show->smartshopperShow.itemIds[2] != ITEM_NONE)
|
||||
{
|
||||
@@ -5164,7 +5164,7 @@ static void DoTVShowTodaysSmartShopper(void)
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
StringCopy(gStringVar2, ItemId_GetItem(show->smartshopperShow.itemIds[2])->name);
|
||||
StringCopy(gStringVar2, ItemId_GetName(show->smartshopperShow.itemIds[2]));
|
||||
TV_PrintIntToStringVar(2, show->smartshopperShow.itemAmounts[2]);
|
||||
if (show->smartshopperShow.priceReduced == TRUE)
|
||||
{
|
||||
@@ -5201,7 +5201,7 @@ static void DoTVShowTodaysSmartShopper(void)
|
||||
break;
|
||||
case 11:
|
||||
TVShowConvertInternationalString(gStringVar1, show->smartshopperShow.playerName, show->smartshopperShow.language);
|
||||
StringCopy(gStringVar2, ItemId_GetItem(show->smartshopperShow.itemIds[0])->name);
|
||||
StringCopy(gStringVar2, ItemId_GetName(show->smartshopperShow.itemIds[0]));
|
||||
if (show->smartshopperShow.priceReduced == TRUE)
|
||||
{
|
||||
sTVShowState = 8;
|
||||
@@ -5344,7 +5344,7 @@ static void DoTVShowPokemonTodaySuccessfulCapture(void)
|
||||
sTVShowState = 2;
|
||||
break;
|
||||
case 2:
|
||||
StringCopy(gStringVar2, ItemId_GetItem(show->pokemonToday.ball)->name);
|
||||
StringCopy(gStringVar2, ItemId_GetName(show->pokemonToday.ball));
|
||||
TV_PrintIntToStringVar(2, show->pokemonToday.nBallsUsed);
|
||||
if (show->pokemonToday.nBallsUsed < 4)
|
||||
{
|
||||
@@ -6457,7 +6457,7 @@ static void DoTVShowHoennTreasureInvestigators(void)
|
||||
switch (state)
|
||||
{
|
||||
case 0:
|
||||
StringCopy(gStringVar1, ItemId_GetItem(show->treasureInvestigators.item)->name);
|
||||
StringCopy(gStringVar1, ItemId_GetName(show->treasureInvestigators.item));
|
||||
if (show->treasureInvestigators.location == MAPSEC_DYNAMIC)
|
||||
{
|
||||
switch (show->treasureInvestigators.mapDataId)
|
||||
@@ -6476,13 +6476,13 @@ static void DoTVShowHoennTreasureInvestigators(void)
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
StringCopy(gStringVar1, ItemId_GetItem(show->treasureInvestigators.item)->name);
|
||||
StringCopy(gStringVar1, ItemId_GetName(show->treasureInvestigators.item));
|
||||
TVShowConvertInternationalString(gStringVar2, show->treasureInvestigators.playerName, show->treasureInvestigators.language);
|
||||
GetMapName(gStringVar3, show->treasureInvestigators.location, 0);
|
||||
TVShowDone();
|
||||
break;
|
||||
case 2:
|
||||
StringCopy(gStringVar1, ItemId_GetItem(show->treasureInvestigators.item)->name);
|
||||
StringCopy(gStringVar1, ItemId_GetName(show->treasureInvestigators.item));
|
||||
TVShowConvertInternationalString(gStringVar2, show->treasureInvestigators.playerName, show->treasureInvestigators.language);
|
||||
TVShowDone();
|
||||
break;
|
||||
@@ -6598,7 +6598,7 @@ static void DoTVShowBreakingNewsTV(void)
|
||||
break;
|
||||
case 3:
|
||||
TV_PrintIntToStringVar(0, show->breakingNews.balls);
|
||||
StringCopy(gStringVar2, ItemId_GetItem(show->breakingNews.caughtMonBall)->name);
|
||||
StringCopy(gStringVar2, ItemId_GetName(show->breakingNews.caughtMonBall));
|
||||
sTVShowState = 4;
|
||||
break;
|
||||
case 4:
|
||||
@@ -6788,7 +6788,7 @@ static void DoTVShowPokemonLotteryWinnerFlashReport(void)
|
||||
{
|
||||
StringCopy(gStringVar2, gText_Third);
|
||||
}
|
||||
StringCopy(gStringVar3, ItemId_GetItem(show->lottoWinner.item)->name);
|
||||
StringCopy(gStringVar3, ItemId_GetName(show->lottoWinner.item));
|
||||
TVShowDone();
|
||||
ShowFieldMessage(sTVPokemonLotteryWinnerFlashReportTextGroup[state]);
|
||||
}
|
||||
@@ -7530,7 +7530,7 @@ static void DoTVShowSecretBaseSecrets(void)
|
||||
sTVShowState = show->secretBaseSecrets.savedState;
|
||||
break;
|
||||
case 19:
|
||||
StringCopy(gStringVar2, ItemId_GetItem(show->secretBaseSecrets.item)->name);
|
||||
StringCopy(gStringVar2, ItemId_GetName(show->secretBaseSecrets.item));
|
||||
sTVShowState = show->secretBaseSecrets.savedState;
|
||||
break;
|
||||
case 20:
|
||||
|
||||
Reference in New Issue
Block a user