Merge pull request #221 from GriffinRichards/doc-cerulean

Document Cerulean City scripts
This commit is contained in:
PikalaxALT
2020-01-14 20:29:03 -05:00
committed by GitHub
58 changed files with 796 additions and 745 deletions
+4 -4
View File
@@ -9563,17 +9563,17 @@ static void atkF0_givecaughtmon(void)
{
if (GiveMonToPlayer(&gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker ^ BIT_SIDE]]) != MON_GIVEN_TO_PARTY)
{
if (!sub_80CC7B4())
if (!ShouldShowBoxWasFullMessage())
{
gBattleCommunication[MULTISTRING_CHOOSER] = 0;
StringCopy(gStringVar1, GetBoxNamePtr(VarGet(VAR_0x4037)));
StringCopy(gStringVar1, GetBoxNamePtr(VarGet(VAR_PC_BOX_TO_SEND_MON)));
GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker ^ BIT_SIDE]], MON_DATA_NICKNAME, gStringVar2);
}
else
{
StringCopy(gStringVar1, GetBoxNamePtr(VarGet(VAR_0x4037)));
StringCopy(gStringVar1, GetBoxNamePtr(VarGet(VAR_PC_BOX_TO_SEND_MON))); // box the mon was sent to
GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker ^ BIT_SIDE]], MON_DATA_NICKNAME, gStringVar2);
StringCopy(gStringVar3, GetBoxNamePtr(get_unknown_box_id()));
StringCopy(gStringVar3, GetBoxNamePtr(GetPCBoxToSendMon())); //box the mon was going to be sent to
gBattleCommunication[MULTISTRING_CHOOSER] = 2;
}
if (FlagGet(FLAG_SYS_NOT_SOMEONES_PC))
+44 -42
View File
@@ -9,32 +9,34 @@
#include "text.h"
#include "text_window.h"
EWRAM_DATA u8 gUnknown_203F464 = 0;
#define MAX_BERRY_POWDER 99999
u32 DecryptBerryPowder(u32 * a0)
static EWRAM_DATA u8 sBerryPowderVendorWindowId = 0;
u32 DecryptBerryPowder(u32 *powder)
{
return *a0 ^ gSaveBlock2Ptr->encryptionKey;
return *powder ^ gSaveBlock2Ptr->encryptionKey;
}
void SetBerryPowder(u32 * a0, u32 a1)
void SetBerryPowder(u32 *powder, u32 amount)
{
*a0 = gSaveBlock2Ptr->encryptionKey ^ a1;
*powder = amount ^ gSaveBlock2Ptr->encryptionKey;
}
void sub_815EE6C(u32 a0)
void ApplyNewEncryptionKeyToBerryPowder(u32 encryptionKey)
{
ApplyNewEncryptionKeyToWord(&gSaveBlock2Ptr->berryCrush.berryPowderAmount, a0);
ApplyNewEncryptionKeyToWord(&gSaveBlock2Ptr->berryCrush.berryPowderAmount, encryptionKey);
}
bool8 sub_815EE88(u32 a0)
static bool8 HasEnoughBerryPowder(u32 cost)
{
if (DecryptBerryPowder(&gSaveBlock2Ptr->berryCrush.berryPowderAmount) < a0)
if (DecryptBerryPowder(&gSaveBlock2Ptr->berryCrush.berryPowderAmount) < cost)
return FALSE;
else
return TRUE;
}
bool8 sub_815EEB0(void)
bool8 Special_HasEnoughBerryPowder(void)
{
if (DecryptBerryPowder(&gSaveBlock2Ptr->berryCrush.berryPowderAmount) < gSpecialVar_0x8004)
return FALSE;
@@ -42,44 +44,44 @@ bool8 sub_815EEB0(void)
return TRUE;
}
bool8 sub_815EEE0(u32 a0)
bool8 GiveBerryPowder(u32 amountToAdd)
{
u32 * ptr = &gSaveBlock2Ptr->berryCrush.berryPowderAmount;
u32 amount = DecryptBerryPowder(ptr) + a0;
if (amount > 99999)
u32 *powder = &gSaveBlock2Ptr->berryCrush.berryPowderAmount;
u32 amount = DecryptBerryPowder(powder) + amountToAdd;
if (amount > MAX_BERRY_POWDER)
{
SetBerryPowder(ptr, 99999);
SetBerryPowder(powder, MAX_BERRY_POWDER);
return FALSE;
}
else
{
SetBerryPowder(ptr, amount);
SetBerryPowder(powder, amount);
return TRUE;
}
}
bool8 sub_815EF20(u32 a0)
static bool8 TakeBerryPowder(u32 cost)
{
u32 * ptr = &gSaveBlock2Ptr->berryCrush.berryPowderAmount;
if (!sub_815EE88(a0))
u32 *powder = &gSaveBlock2Ptr->berryCrush.berryPowderAmount;
if (!HasEnoughBerryPowder(cost))
return FALSE;
else
{
u32 amount = DecryptBerryPowder(ptr);
SetBerryPowder(ptr, amount - a0);
u32 amount = DecryptBerryPowder(powder);
SetBerryPowder(powder, amount - cost);
return TRUE;
}
}
bool8 sub_815EF5C(void)
bool8 Special_TakeBerryPowder(void)
{
u32 * ptr = &gSaveBlock2Ptr->berryCrush.berryPowderAmount;
if (!sub_815EE88(gSpecialVar_0x8004))
u32 *powder = &gSaveBlock2Ptr->berryCrush.berryPowderAmount;
if (!HasEnoughBerryPowder(gSpecialVar_0x8004))
return FALSE;
else
{
u32 amount = DecryptBerryPowder(ptr);
SetBerryPowder(ptr, amount - gSpecialVar_0x8004);
u32 amount = DecryptBerryPowder(powder);
SetBerryPowder(powder, amount - gSpecialVar_0x8004);
return TRUE;
}
}
@@ -89,42 +91,42 @@ u32 GetBerryPowder(void)
return DecryptBerryPowder(&gSaveBlock2Ptr->berryCrush.berryPowderAmount);
}
void sub_815EFBC(u8 windowId, u32 powder, u8 x, u8 y, u8 speed)
static void PrintBerryPowderAmount(u8 windowId, u32 amount, u8 x, u8 y, u8 speed)
{
ConvertIntToDecimalStringN(gStringVar1, powder, STR_CONV_MODE_RIGHT_ALIGN, 5);
ConvertIntToDecimalStringN(gStringVar1, amount, STR_CONV_MODE_RIGHT_ALIGN, 5);
AddTextPrinterParameterized(windowId, 0, gStringVar1, x, y, speed, NULL);
}
void sub_815F014(u8 windowId, u16 baseBlock, u8 palette, u32 powder)
static void DrawPlayerPowderAmount(u8 windowId, u16 baseBlock, u8 palette, u32 amount)
{
DrawStdFrameWithCustomTileAndPalette(windowId, FALSE, baseBlock, palette);
AddTextPrinterParameterized(windowId, 0, gOtherText_Powder, 0, 0, -1, NULL);
sub_815EFBC(windowId, powder, 39, 12, 0);
PrintBerryPowderAmount(windowId, amount, 39, 12, 0);
}
void sub_815F070(void)
void PrintPlayerBerryPowderAmount(void)
{
sub_815EFBC(gUnknown_203F464, GetBerryPowder(), 39, 12, 0);
PrintBerryPowderAmount(sBerryPowderVendorWindowId, GetBerryPowder(), 39, 12, 0);
}
void sub_815F094(void)
void DisplayBerryPowderVendorMenu(void)
{
struct WindowTemplate template;
if (QuestLog_SchedulePlaybackCB(QLPlaybackCB_DestroyScriptMenuMonPicSprites) != TRUE)
{
template = SetWindowTemplateFields(0, 1, 1, 8, 3, 15, 32);
gUnknown_203F464 = AddWindow(&template);
FillWindowPixelBuffer(gUnknown_203F464, 0);
PutWindowTilemap(gUnknown_203F464);
TextWindow_SetStdFrame0_WithPal(gUnknown_203F464, 0x21D, 0xD0);
sub_815F014(gUnknown_203F464, 0x21D, 0xD, GetBerryPowder());
sBerryPowderVendorWindowId = AddWindow(&template);
FillWindowPixelBuffer(sBerryPowderVendorWindowId, 0);
PutWindowTilemap(sBerryPowderVendorWindowId);
TextWindow_SetStdFrame0_WithPal(sBerryPowderVendorWindowId, 0x21D, 0xD0);
DrawPlayerPowderAmount(sBerryPowderVendorWindowId, 0x21D, 0xD, GetBerryPowder());
}
}
void sub_815F114(void)
void RemoveBerryPowderVendorMenu(void)
{
ClearWindowTilemap(gUnknown_203F464);
ClearStdWindowAndFrameToTransparent(gUnknown_203F464, 1);
RemoveWindow(gUnknown_203F464);
ClearWindowTilemap(sBerryPowderVendorWindowId);
ClearStdWindowAndFrameToTransparent(sBerryPowderVendorWindowId, 1);
RemoveWindow(sBerryPowderVendorWindowId);
}
+23 -7
View File
@@ -1,4 +1,5 @@
static const struct InGameTrade sInGameTrades[] = {
[INGAME_TRADE_MR_MIME] =
{
.nickname = _("MIMIEN"),
.species = SPECIES_MR_MIME,
@@ -13,7 +14,9 @@ static const struct InGameTrade sInGameTrades[] = {
.otGender = MALE,
.sheen = 10,
.requestedSpecies = SPECIES_ABRA
}, {
},
[INGAME_TRADE_JYNX] =
{
.nickname = _("ZYNX"),
.species = SPECIES_JYNX,
.ivs = {18, 17, 18, 22, 25, 21},
@@ -27,7 +30,9 @@ static const struct InGameTrade sInGameTrades[] = {
.otGender = MALE,
.sheen = 10,
.requestedSpecies = SPECIES_POLIWHIRL
}, {
},
[INGAME_TRADE_NIDORAN] =
{
#if defined(FIRERED)
.nickname = _("MS. NIDO"),
.species = SPECIES_NIDORAN_F,
@@ -57,7 +62,9 @@ static const struct InGameTrade sInGameTrades[] = {
.sheen = 10,
.requestedSpecies = SPECIES_NIDORAN_F
#endif
}, {
},
[INGAME_TRADE_FARFETCHD] =
{
.nickname = _("CH'DING"),
.species = SPECIES_FARFETCHD,
.ivs = {20, 25, 21, 24, 15, 20},
@@ -71,7 +78,9 @@ static const struct InGameTrade sInGameTrades[] = {
.otGender = MALE,
.sheen = 10,
.requestedSpecies = SPECIES_SPEAROW
}, {
},
[INGAME_TRADE_NIDORINOA] =
{
#if defined(FIRERED)
.nickname = _("NINA"),
.species = SPECIES_NIDORINA,
@@ -101,7 +110,9 @@ static const struct InGameTrade sInGameTrades[] = {
.sheen = 10,
.requestedSpecies = SPECIES_NIDORINA
#endif
}, {
},
[INGAME_TRADE_LICKITUNG] =
{
.nickname = _("MARC"),
.species = SPECIES_LICKITUNG,
.ivs = {24, 19, 21, 15, 23, 21},
@@ -119,7 +130,9 @@ static const struct InGameTrade sInGameTrades[] = {
#elif defined(LEAFGREEN)
.requestedSpecies = SPECIES_SLOWBRO
#endif
}, {
},
[INGAME_TRADE_ELECTRODE] =
{
.nickname = _("ESPHERE"),
.species = SPECIES_ELECTRODE,
.ivs = {19, 16, 18, 25, 25, 19},
@@ -133,7 +146,9 @@ static const struct InGameTrade sInGameTrades[] = {
.otGender = MALE,
.sheen = 10,
.requestedSpecies = SPECIES_RAICHU
}, {
},
[INGAME_TRADE_TANGELA] =
{
.nickname = _("TANGENY"),
.species = SPECIES_TANGELA,
.ivs = {22, 17, 25, 16, 23, 20},
@@ -148,6 +163,7 @@ static const struct InGameTrade sInGameTrades[] = {
.sheen = 10,
.requestedSpecies = SPECIES_VENONAT
},
[INGAME_TRADE_SEEL] =
{
.nickname = _("SEELOR"),
.species = SPECIES_SEEL,
+40 -26
View File
@@ -45,13 +45,14 @@
#include "constants/maps.h"
#include "constants/region_map.h"
#include "constants/moves.h"
#include "constants/menu.h"
static EWRAM_DATA u8 sElevatorCurrentFloorWindowId = 0;
static EWRAM_DATA u16 sElevatorScroll = 0;
static EWRAM_DATA u16 sElevatorCursorPos = 0;
static EWRAM_DATA struct ListMenuItem * sListMenuItems = NULL;
static EWRAM_DATA u16 sListMenuLastScrollPosition = 0;
static EWRAM_DATA u8 sUnknownBoxId = 0;
static EWRAM_DATA u8 sPCBoxToSendMon = 0;
static EWRAM_DATA u8 sBrailleTextCursorSpriteID = 0;
struct ListMenuTemplate sFieldSpecialsListMenuTemplate;
@@ -1143,7 +1144,7 @@ void Special_ListMenu(void)
task = &gTasks[taskId];
switch (gSpecialVar_0x8004)
{
case 0:
case LISTMENU_BADGES:
task->data[0] = 4;
task->data[1] = 9;
task->data[2] = 1;
@@ -1153,7 +1154,7 @@ void Special_ListMenu(void)
task->data[6] = 1;
task->data[15] = taskId;
break;
case 1:
case LISTMENU_SILPHCO_FLOORS:
task->data[0] = 7;
task->data[1] = 12;
task->data[2] = 1;
@@ -1165,7 +1166,7 @@ void Special_ListMenu(void)
task->data[7] = sElevatorScroll;
task->data[8] = sElevatorCursorPos;
break;
case 2:
case LISTMENU_ROCKET_HIDEOUT_FLOORS: // Multichoice used instead
task->data[0] = 4;
task->data[1] = 4;
task->data[2] = 1;
@@ -1175,7 +1176,7 @@ void Special_ListMenu(void)
task->data[6] = 0;
task->data[15] = taskId;
break;
case 3:
case LISTMENU_DEPT_STORE_FLOORS: // Multichoice used instead
task->data[0] = 4;
task->data[1] = 6;
task->data[2] = 1;
@@ -1185,7 +1186,7 @@ void Special_ListMenu(void)
task->data[6] = 0;
task->data[15] = taskId;
break;
case 4:
case LISTMENU_WIRELESS_LECTURE_HEADERS: // Multichoice used instead
task->data[0] = 4;
task->data[1] = 4;
task->data[2] = 1;
@@ -1195,7 +1196,7 @@ void Special_ListMenu(void)
task->data[6] = 1;
task->data[15] = taskId;
break;
case 5:
case LISTMENU_BERRY_POWDER:
task->data[0] = 7;
task->data[1] = 12;
task->data[2] = 16;
@@ -1205,7 +1206,7 @@ void Special_ListMenu(void)
task->data[6] = 0;
task->data[15] = taskId;
break;
case 6:
case LISTMENU_TRAINER_TOWER_FLOORS: // Mulitchoice used instead
task->data[0] = 3;
task->data[1] = 3;
task->data[2] = 1;
@@ -1226,6 +1227,7 @@ void Special_ListMenu(void)
}
static const u8 *const sListMenuLabels[][12] = {
[LISTMENU_BADGES] =
{
gText_BoulderBadge,
gText_CascadeBadge,
@@ -1236,7 +1238,9 @@ static const u8 *const sListMenuLabels[][12] = {
gText_VolcanoBadge,
gText_EarthBadge,
gOtherText_Exit,
}, {
},
[LISTMENU_SILPHCO_FLOORS] =
{
gText_11F,
gText_10F,
gText_9F,
@@ -1249,24 +1253,32 @@ static const u8 *const sListMenuLabels[][12] = {
gText_2F,
gText_1F,
gOtherText_Exit,
}, {
},
[LISTMENU_ROCKET_HIDEOUT_FLOORS] = // Unncessary, MULTICHOICE_ROCKET_HIDEOUT_ELEVATOR is used instead
{
gText_B1F,
gText_B2F,
gText_B4F,
gOtherText_Exit,
}, {
},
[LISTMENU_DEPT_STORE_FLOORS] = // Unncessary, MULTICHOICE_DEPT_STORE_ELEVATOR is used instead
{
gText_5F,
gText_4F,
gText_3F,
gText_2F,
gText_1F,
gOtherText_Exit,
}, {
},
[LISTMENU_WIRELESS_LECTURE_HEADERS] = // Unnecessary, MULTICHOICE_LINKED_DIRECT_UNION is used instead
{
gText_LinkedGamePlay,
gText_DirectCorner,
gText_UnionRoom,
gOtherText_Quit,
}, {
},
[LISTMENU_BERRY_POWDER] =
{
gText_Energypowder_50,
gText_EnergyRoot_80,
gText_HealPowder_50,
@@ -1279,7 +1291,9 @@ static const u8 *const sListMenuLabels[][12] = {
gText_HpUp_1000,
gText_PpUp_3000,
gOtherText_Exit,
}, {
},
[LISTMENU_TRAINER_TOWER_FLOORS] = // Unnecessary, MULTICHOICE_ROOFTOP_B1F is used instead
{
gText_Rooftop,
gText_B1F,
gOtherText_Exit,
@@ -1295,7 +1309,7 @@ static void Task_CreateScriptListMenu(u8 taskId)
struct Task * task = &gTasks[taskId];
u8 windowId;
ScriptContext2_Enable();
if (gSpecialVar_0x8004 == 1)
if (gSpecialVar_0x8004 == LISTMENU_SILPHCO_FLOORS)
sListMenuLastScrollPosition = sElevatorScroll;
else
sListMenuLastScrollPosition = 0;
@@ -1920,31 +1934,31 @@ u16 Special_BattleCardAction(void)
}
}
void set_unknown_box_id(u8 boxId)
void SetPCBoxToSendMon(u8 boxId)
{
sUnknownBoxId = boxId;
sPCBoxToSendMon = boxId;
}
u16 get_unknown_box_id(void)
u16 GetPCBoxToSendMon(void)
{
return sUnknownBoxId;
return sPCBoxToSendMon;
}
bool8 sub_80CC7B4(void)
bool8 ShouldShowBoxWasFullMessage(void)
{
if (FlagGet(FLAG_SYS_CHANGED_BOX_TO_STORE_MON))
return FALSE;
if (StorageGetCurrentBox() == VarGet(VAR_0x4037))
if (StorageGetCurrentBox() == VarGet(VAR_PC_BOX_TO_SEND_MON))
return FALSE;
FlagSet(FLAG_SYS_CHANGED_BOX_TO_STORE_MON);
return TRUE;
}
bool8 sub_80CC7F8(void)
bool8 IsDestinationBoxFull(void)
{
s32 i;
s32 j;
set_unknown_box_id(VarGet(VAR_0x4037));
SetPCBoxToSendMon(VarGet(VAR_PC_BOX_TO_SEND_MON));
i = StorageGetCurrentBox();
do
{
@@ -1952,10 +1966,10 @@ bool8 sub_80CC7F8(void)
{
if (GetBoxMonData(GetBoxedMonPtr(i, j), MON_DATA_SPECIES, NULL) == SPECIES_NONE)
{
if (get_unknown_box_id() != i)
if (GetPCBoxToSendMon() != i)
FlagClear(FLAG_SYS_CHANGED_BOX_TO_STORE_MON);
VarSet(VAR_0x4037, i);
return sub_80CC7B4();
VarSet(VAR_PC_BOX_TO_SEND_MON, i);
return ShouldShowBoxWasFullMessage();
}
}
i++;
+1 -1
View File
@@ -289,7 +289,7 @@ void ApplyNewEncryptionKeyToAllEncryptedData(u32 encryptionKey)
sub_8054F38(encryptionKey);
ApplyNewEncryptionKeyToBagItems_(encryptionKey);
sub_815EE6C(encryptionKey);
ApplyNewEncryptionKeyToBerryPowder(encryptionKey);
ApplyNewEncryptionKeyToWord(&gSaveBlock1Ptr->money, encryptionKey);
ApplyNewEncryptionKeyToHword(&gSaveBlock1Ptr->coins, encryptionKey);
}
+3 -3
View File
@@ -3632,7 +3632,7 @@ static u8 SendMonToPC(struct Pokemon* mon)
{
s32 boxNo, boxPos;
set_unknown_box_id(VarGet(VAR_0x4037));
SetPCBoxToSendMon(VarGet(VAR_PC_BOX_TO_SEND_MON));
boxNo = StorageGetCurrentBox();
@@ -3647,9 +3647,9 @@ static u8 SendMonToPC(struct Pokemon* mon)
CopyMon(checkingMon, &mon->box, sizeof(mon->box));
gSpecialVar_MonBoxId = boxNo;
gSpecialVar_MonBoxPos = boxPos;
if (get_unknown_box_id() != boxNo)
if (GetPCBoxToSendMon() != boxNo)
FlagClear(FLAG_SYS_CHANGED_BOX_TO_STORE_MON);
VarSet(VAR_0x4037, boxNo);
VarSet(VAR_PC_BOX_TO_SEND_MON, boxNo);
return MON_GIVEN_TO_PC;
}
}