mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2025-01-26 13:31:03 +01:00
Merge pull request #1309 from GriffinRichards/misc-macro
Use constants for item data, misc other constants/fixes
This commit is contained in:
commit
6999b237eb
@ -462,18 +462,18 @@ AI_CBM_Attract: @ 82DC5F5
|
||||
get_ability AI_TARGET
|
||||
if_equal ABILITY_OBLIVIOUS, Score_Minus10
|
||||
get_gender AI_USER
|
||||
if_equal 0, AI_CBM_Attract_CheckIfTargetIsFemale
|
||||
if_equal 254, AI_CBM_Attract_CheckIfTargetIsMale
|
||||
if_equal MON_MALE, AI_CBM_Attract_CheckIfTargetIsFemale
|
||||
if_equal MON_FEMALE, AI_CBM_Attract_CheckIfTargetIsMale
|
||||
goto Score_Minus10
|
||||
|
||||
AI_CBM_Attract_CheckIfTargetIsFemale: @ 82DC61A
|
||||
get_gender AI_TARGET
|
||||
if_equal 254, AI_CBM_Attract_End
|
||||
if_equal MON_FEMALE, AI_CBM_Attract_End
|
||||
goto Score_Minus10
|
||||
|
||||
AI_CBM_Attract_CheckIfTargetIsMale: @ 82DC627
|
||||
get_gender AI_TARGET
|
||||
if_equal 0, AI_CBM_Attract_End
|
||||
if_equal MON_MALE, AI_CBM_Attract_End
|
||||
goto Score_Minus10
|
||||
|
||||
AI_CBM_Attract_End: @ 82DC634
|
||||
@ -2057,12 +2057,22 @@ AI_CV_Protect_ScoreDown2:
|
||||
AI_CV_Protect_End:
|
||||
end
|
||||
|
||||
@ BUG: Foresight is only encouraged if the user is Ghost type or
|
||||
@ has high evasion, but should check target instead
|
||||
AI_CV_Foresight:
|
||||
.ifdef BUGFIX
|
||||
get_target_type1
|
||||
if_equal TYPE_GHOST, AI_CV_Foresight2
|
||||
get_target_type2
|
||||
if_equal TYPE_GHOST, AI_CV_Foresight2
|
||||
if_stat_level_more_than AI_TARGET, STAT_EVASION, 8, AI_CV_Foresight3
|
||||
.else
|
||||
get_user_type1
|
||||
if_equal TYPE_GHOST, AI_CV_Foresight2
|
||||
get_user_type2
|
||||
if_equal TYPE_GHOST, AI_CV_Foresight2
|
||||
if_stat_level_more_than AI_USER, STAT_EVASION, 8, AI_CV_Foresight3
|
||||
.endif
|
||||
score -2
|
||||
goto AI_CV_Foresight_End
|
||||
|
||||
@ -2329,13 +2339,13 @@ AI_CV_SemiInvulnerable2:
|
||||
if_status2 AI_TARGET, STATUS2_CURSED, AI_CV_SemiInvulnerable_TryEncourage
|
||||
if_status3 AI_TARGET, STATUS3_LEECHSEED, AI_CV_SemiInvulnerable_TryEncourage
|
||||
get_weather
|
||||
.ifdef BUGFIX
|
||||
.ifdef BUGFIX
|
||||
if_equal AI_WEATHER_HAIL, AI_CV_SemiInvulnerable_CheckIceType
|
||||
if_equal AI_WEATHER_SANDSTORM, AI_CV_SemiInvulnerable_CheckSandstormTypes
|
||||
.else
|
||||
.else
|
||||
if_equal AI_WEATHER_HAIL, AI_CV_SemiInvulnerable_CheckSandstormTypes
|
||||
if_equal AI_WEATHER_SANDSTORM, AI_CV_SemiInvulnerable_CheckIceType
|
||||
.endif
|
||||
.endif
|
||||
goto AI_CV_SemiInvulnerable5
|
||||
|
||||
AI_CV_SemiInvulnerable_CheckSandstormTypes:
|
||||
@ -2404,11 +2414,11 @@ AI_CV_Hail_End:
|
||||
|
||||
@ BUG: Facade score is increased if the target is statused, but should be if the user is
|
||||
AI_CV_Facade:
|
||||
.ifdef BUGFIX
|
||||
.ifdef BUGFIX
|
||||
if_not_status AI_USER, STATUS1_POISON | STATUS1_BURN | STATUS1_PARALYSIS | STATUS1_TOXIC_POISON, AI_CV_Facade_End
|
||||
.else
|
||||
.else
|
||||
if_not_status AI_TARGET, STATUS1_POISON | STATUS1_BURN | STATUS1_PARALYSIS | STATUS1_TOXIC_POISON, AI_CV_Facade_End
|
||||
.endif
|
||||
.endif
|
||||
score +1
|
||||
AI_CV_Facade_End:
|
||||
end
|
||||
|
@ -3,5 +3,5 @@ CaveOfOrigin_1F_MapScripts:: @ 8235768
|
||||
.byte 0
|
||||
|
||||
CaveOfOrigin_1F_OnTransition: @ 823576E
|
||||
call_if_set FLAG_UNUSED_RS_LEGENDARY_BATTLE_DONE, CaveOfOrigin_EventScript_SetTempVars
|
||||
call_if_set FLAG_UNUSED_RS_LEGENDARY_BATTLE_DONE, CaveOfOrigin_EventScript_DisableTriggers
|
||||
end
|
||||
|
@ -3,5 +3,5 @@ CaveOfOrigin_UnusedRubySapphireMap1_MapScripts:: @ 8235778
|
||||
.byte 0
|
||||
|
||||
CaveOfOrigin_UnusedRubySapphireMap1_OnTransition: @ 823577E
|
||||
call_if_set FLAG_UNUSED_RS_LEGENDARY_BATTLE_DONE, CaveOfOrigin_EventScript_SetTempVars
|
||||
call_if_set FLAG_UNUSED_RS_LEGENDARY_BATTLE_DONE, CaveOfOrigin_EventScript_DisableTriggers
|
||||
end
|
||||
|
@ -3,6 +3,6 @@ CaveOfOrigin_UnusedRubySapphireMap2_MapScripts:: @ 8235788
|
||||
.byte 0
|
||||
|
||||
CaveOfOrigin_UnusedRubySapphireMap2_OnTransition: @ 823578E
|
||||
call_if_set FLAG_UNUSED_RS_LEGENDARY_BATTLE_DONE, CaveOfOrigin_EventScript_SetTempVars
|
||||
call_if_set FLAG_UNUSED_RS_LEGENDARY_BATTLE_DONE, CaveOfOrigin_EventScript_DisableTriggers
|
||||
end
|
||||
|
||||
|
@ -3,6 +3,6 @@ CaveOfOrigin_UnusedRubySapphireMap3_MapScripts:: @ 8235798
|
||||
.byte 0
|
||||
|
||||
CaveOfOrigin_UnusedRubySapphireMap3_OnTransition: @ 823579E
|
||||
call_if_set FLAG_UNUSED_RS_LEGENDARY_BATTLE_DONE, CaveOfOrigin_EventScript_SetTempVars
|
||||
call_if_set FLAG_UNUSED_RS_LEGENDARY_BATTLE_DONE, CaveOfOrigin_EventScript_DisableTriggers
|
||||
end
|
||||
|
||||
|
@ -36,7 +36,7 @@ CaveOfOrigin_EventScript_Shake:: @ 82722A7
|
||||
releaseall
|
||||
end
|
||||
|
||||
CaveOfOrigin_EventScript_SetTempVars:: @ 82722C1
|
||||
CaveOfOrigin_EventScript_DisableTriggers:: @ 82722C1
|
||||
setvar VAR_TEMP_1, 1
|
||||
setvar VAR_TEMP_2, 1
|
||||
setvar VAR_TEMP_3, 1
|
||||
|
@ -65,7 +65,7 @@ EventScript_PkmnCenterNurse_ReturnPkmn:: @ 82719E2
|
||||
goto_if_eq EventScript_PkmnCenterNurse_ReturnPkmn2
|
||||
message gText_RestoredPkmnToFullHealth
|
||||
waitmessage
|
||||
applymovement VAR_0x800B, EventScript_PkmnCenterNurse_Bow
|
||||
applymovement VAR_0x800B, Movement_PkmnCenterNurse_Bow
|
||||
waitmovement 0
|
||||
message gText_WeHopeToSeeYouAgain
|
||||
return
|
||||
@ -73,7 +73,7 @@ EventScript_PkmnCenterNurse_ReturnPkmn:: @ 82719E2
|
||||
EventScript_PkmnCenterNurse_ReturnPkmn2:: @ 8271A03
|
||||
message gText_ThankYouForWaiting
|
||||
waitmessage
|
||||
applymovement VAR_0x800B, EventScript_PkmnCenterNurse_Bow
|
||||
applymovement VAR_0x800B, Movement_PkmnCenterNurse_Bow
|
||||
waitmovement 0
|
||||
message gText_WeHopeToSeeYouAgain2
|
||||
return
|
||||
@ -84,7 +84,7 @@ EventScript_PkmnCenterNurse_PlayerWaitingInUnionRoom:: @ 8271A19
|
||||
setflag FLAG_NURSE_UNION_ROOM_REMINDER
|
||||
message CableClub_Text_PlayerIsWaiting
|
||||
waitmessage
|
||||
applymovement VAR_0x800B, EventScript_PkmnCenterNurse_Bow
|
||||
applymovement VAR_0x800B, Movement_PkmnCenterNurse_Bow
|
||||
waitmovement 0
|
||||
message gText_WeHopeToSeeYouAgain
|
||||
return
|
||||
@ -129,7 +129,7 @@ EventScript_PkmnCenterNurse_GoldCardHealPkmn:: @ 8271AC5
|
||||
goto EventScript_PkmnCenterNurse_HealPkmn
|
||||
end
|
||||
|
||||
EventScript_PkmnCenterNurse_Bow: @ 8271AD0
|
||||
Movement_PkmnCenterNurse_Bow: @ 8271AD0
|
||||
nurse_joy_bow
|
||||
delay_4
|
||||
step_end
|
||||
|
@ -6,16 +6,15 @@ EventScript_MixRecordsPrompt:: @ 8271D5E
|
||||
compare VAR_RESULT, YES
|
||||
goto_if_eq EventScript_MixRecords
|
||||
compare VAR_RESULT, NO
|
||||
goto_if_eq EventScript_DeclineMixRecords
|
||||
goto EventScript_DeclineMixRecords
|
||||
goto_if_eq EventScript_EndMixRecords
|
||||
goto EventScript_EndMixRecords
|
||||
|
||||
EventScript_MixRecords:: @ 8271D83
|
||||
special RecordMixingPlayerSpotTriggered
|
||||
waitstate
|
||||
lock
|
||||
faceplayer
|
||||
|
||||
EventScript_DeclineMixRecords:: @ 8271D89
|
||||
EventScript_EndMixRecords:: @ 8271D89
|
||||
message Text_WeHopeToSeeYouAgain
|
||||
waitmessage
|
||||
waitbuttonpress
|
||||
|
@ -17,7 +17,11 @@
|
||||
#define ITEM_LUXURY_BALL 11
|
||||
#define ITEM_PREMIER_BALL 12
|
||||
|
||||
#define LAST_BALL ITEM_PREMIER_BALL
|
||||
// Note: If moving ball IDs around, updating FIRST_BALL/LAST_BALL is not sufficient
|
||||
// Several places expect the ball IDs to be first and contiguous (e.g. gBattlescriptsForBallThrow and MON_DATA_POKEBALL)
|
||||
// If adding new balls, it's easiest to insert them after the last ball and increment the below IDs (and removing ITEM_034 for example)
|
||||
#define FIRST_BALL ITEM_MASTER_BALL
|
||||
#define LAST_BALL ITEM_PREMIER_BALL
|
||||
|
||||
// Pokemon Items
|
||||
#define ITEM_POTION 13
|
||||
@ -145,6 +149,8 @@
|
||||
#define ITEM_FAB_MAIL 131
|
||||
#define ITEM_RETRO_MAIL 132
|
||||
|
||||
#define FIRST_MAIL_INDEX ITEM_ORANGE_MAIL
|
||||
|
||||
// Berries
|
||||
#define ITEM_CHERI_BERRY 133
|
||||
#define ITEM_CHESTO_BERRY 134
|
||||
@ -189,6 +195,10 @@
|
||||
#define ITEM_LANSAT_BERRY 173
|
||||
#define ITEM_STARF_BERRY 174
|
||||
#define ITEM_ENIGMA_BERRY 175
|
||||
|
||||
#define FIRST_BERRY_INDEX ITEM_CHERI_BERRY
|
||||
#define LAST_BERRY_INDEX ITEM_ENIGMA_BERRY
|
||||
|
||||
#define ITEM_0B0 176
|
||||
#define ITEM_0B1 177
|
||||
#define ITEM_0B2 178
|
||||
@ -467,9 +477,6 @@
|
||||
#define ITEMS_COUNT 377
|
||||
#define ITEM_FIELD_ARROW ITEMS_COUNT
|
||||
|
||||
#define FIRST_BERRY_INDEX ITEM_CHERI_BERRY
|
||||
#define LAST_BERRY_INDEX ITEM_ENIGMA_BERRY
|
||||
|
||||
// Range of berries given out by various NPCS
|
||||
#define FIRST_BERRY_MASTER_BERRY ITEM_POMEG_BERRY
|
||||
#define LAST_BERRY_MASTER_BERRY ITEM_NOMEL_BERRY
|
||||
@ -506,6 +513,21 @@
|
||||
#define GOOD_ROD 1
|
||||
#define SUPER_ROD 2
|
||||
|
||||
// Secondary IDs for bikes
|
||||
#define MACH_BIKE 0
|
||||
#define ACRO_BIKE 1
|
||||
|
||||
// Item type IDs (used to determine the exit callback)
|
||||
#define ITEM_USE_MAIL 0
|
||||
#define ITEM_USE_PARTY_MENU 1
|
||||
#define ITEM_USE_FIELD 2
|
||||
#define ITEM_USE_PBLOCK_CASE 3
|
||||
#define ITEM_USE_BAG_MENU 4 // No exit callback, stays in bag menu
|
||||
|
||||
// Item battle usage IDs (only checked to see if nonzero)
|
||||
#define ITEM_B_USE_MEDICINE 1
|
||||
#define ITEM_B_USE_OTHER 2
|
||||
|
||||
// Check if the item is one that can be used on a Pokemon.
|
||||
#define ITEM_HAS_EFFECT(item) ((item) >= ITEM_POTION && (item) <= ITEM_0B2)
|
||||
|
||||
|
@ -238,6 +238,15 @@ struct Evolution
|
||||
u16 targetSpecies;
|
||||
};
|
||||
|
||||
#define NUM_UNOWN_FORMS 28
|
||||
|
||||
#define GET_UNOWN_LETTER(personality) (( \
|
||||
(((personality) & 0x03000000) >> 18) \
|
||||
| (((personality) & 0x00030000) >> 12) \
|
||||
| (((personality) & 0x00000300) >> 6) \
|
||||
| (((personality) & 0x00000003) >> 0) \
|
||||
) % NUM_UNOWN_FORMS)
|
||||
|
||||
extern u8 gPlayerPartyCount;
|
||||
extern struct Pokemon gPlayerParty[PARTY_SIZE];
|
||||
extern u8 gEnemyPartyCount;
|
||||
|
@ -16,13 +16,6 @@
|
||||
#include "util.h"
|
||||
#include "constants/battle_anim.h"
|
||||
|
||||
#define GET_UNOWN_LETTER(personality) (( \
|
||||
(((personality & 0x03000000) >> 24) << 6) \
|
||||
| (((personality & 0x00030000) >> 16) << 4) \
|
||||
| (((personality & 0x00000300) >> 8) << 2) \
|
||||
| (((personality & 0x00000003) >> 0) << 0) \
|
||||
) % 28)
|
||||
|
||||
#define IS_DOUBLE_BATTLE() ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE))
|
||||
|
||||
extern const struct OamData gOamData_AffineNormal_ObjNormal_64x64;
|
||||
|
@ -2722,7 +2722,7 @@ void SpriteCB_FaintOpponentMon(struct Sprite *sprite)
|
||||
if (species == SPECIES_UNOWN)
|
||||
{
|
||||
u32 personalityValue = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battler]], MON_DATA_PERSONALITY);
|
||||
u16 unownForm = ((((personalityValue & 0x3000000) >> 18) | ((personalityValue & 0x30000) >> 12) | ((personalityValue & 0x300) >> 6) | (personalityValue & 3)) % 0x1C);
|
||||
u16 unownForm = GET_UNOWN_LETTER(personalityValue);
|
||||
u16 unownSpecies;
|
||||
|
||||
if (unownForm == 0)
|
||||
|
@ -877,7 +877,7 @@ void StartBerryCrush(MainCallback callback)
|
||||
static void GetBerryFromBag(void)
|
||||
{
|
||||
if (gSpecialVar_ItemId < FIRST_BERRY_INDEX || gSpecialVar_ItemId > LAST_BERRY_INDEX + 1)
|
||||
gSpecialVar_ItemId = ITEM_CHERI_BERRY;
|
||||
gSpecialVar_ItemId = FIRST_BERRY_INDEX;
|
||||
else
|
||||
RemoveBagItem(gSpecialVar_ItemId, 1);
|
||||
|
||||
|
@ -1158,7 +1158,7 @@ static void CB2_RunCreditsSequence(void)
|
||||
static void sub_8175548(void)
|
||||
{
|
||||
ResetBgsAndClearDma3BusyFlags(0);
|
||||
InitBgsFromTemplates(0, sBackgroundTemplates, 1);
|
||||
InitBgsFromTemplates(0, sBackgroundTemplates, ARRAY_COUNT(sBackgroundTemplates));
|
||||
SetBgTilemapBuffer(0, AllocZeroed(BG_SCREEN_SIZE));
|
||||
LoadPalette(gUnknown_085E56F0, 0x80, 0x40);
|
||||
InitWindows(sWindowTemplates);
|
||||
|
1277
src/data/items.h
1277
src/data/items.h
File diff suppressed because it is too large
Load Diff
@ -86,7 +86,7 @@ void LoadSpecialPokePic(const struct CompressedSpriteSheet *src, void *dest, s32
|
||||
{
|
||||
if (species == SPECIES_UNOWN)
|
||||
{
|
||||
u16 i = (((personality & 0x3000000) >> 18) | ((personality & 0x30000) >> 12) | ((personality & 0x300) >> 6) | (personality & 3)) % 0x1C;
|
||||
u16 i = GET_UNOWN_LETTER(personality);
|
||||
|
||||
// The other Unowns are separate from Unown A.
|
||||
if (i == 0)
|
||||
@ -308,7 +308,7 @@ void LoadSpecialPokePic_2(const struct CompressedSpriteSheet *src, void *dest, s
|
||||
{
|
||||
if (species == SPECIES_UNOWN)
|
||||
{
|
||||
u16 i = (((personality & 0x3000000) >> 18) | ((personality & 0x30000) >> 12) | ((personality & 0x300) >> 6) | (personality & 3)) % 0x1C;
|
||||
u16 i = GET_UNOWN_LETTER(personality);
|
||||
|
||||
// The other Unowns are separate from Unown A.
|
||||
if (i == 0)
|
||||
@ -366,7 +366,7 @@ void LoadSpecialPokePic_DontHandleDeoxys(const struct CompressedSpriteSheet *src
|
||||
{
|
||||
if (species == SPECIES_UNOWN)
|
||||
{
|
||||
u16 i = (((personality & 0x3000000) >> 18) | ((personality & 0x30000) >> 12) | ((personality & 0x300) >> 6) | (personality & 3)) % 0x1C;
|
||||
u16 i = GET_UNOWN_LETTER(personality);
|
||||
|
||||
// The other Unowns are separate from Unown A.
|
||||
if (i == 0)
|
||||
|
@ -168,7 +168,7 @@ static const struct BgTemplate sDiplomaBgTemplates[2] =
|
||||
static void InitDiplomaBg(void)
|
||||
{
|
||||
ResetBgsAndClearDma3BusyFlags(0);
|
||||
InitBgsFromTemplates(0, sDiplomaBgTemplates, 2);
|
||||
InitBgsFromTemplates(0, sDiplomaBgTemplates, ARRAY_COUNT(sDiplomaBgTemplates));
|
||||
SetBgTilemapBuffer(1, sDiplomaTilemapPtr);
|
||||
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP);
|
||||
ShowBg(0);
|
||||
|
@ -1513,9 +1513,9 @@ static void ShowLinkContestResultsWindow(void)
|
||||
AddTextPrinterParameterized(gRecordsWindowId, 1, gText_Smart, x, 89, TEXT_SPEED_FF, NULL);
|
||||
AddTextPrinterParameterized(gRecordsWindowId, 1, gText_Tough, x, 105, TEXT_SPEED_FF, NULL);
|
||||
|
||||
for (i = 0; i < 5; i++)
|
||||
for (i = 0; i < CONTEST_CATEGORIES_COUNT; i++)
|
||||
{
|
||||
for (j = 0; j < 4; j++)
|
||||
for (j = 0; j < CONTESTANT_COUNT; j++)
|
||||
{
|
||||
ConvertIntToDecimalStringN(gStringVar4, gSaveBlock2Ptr->contestLinkResults[i][j], STR_CONV_MODE_RIGHT_ALIGN, 4);
|
||||
AddTextPrinterParameterized(gRecordsWindowId, 1, gStringVar4, (j * 38) + 64, (i * 16) + 41, TEXT_SPEED_FF, NULL);
|
||||
|
@ -102,8 +102,8 @@ void CopyItemNameHandlePlural(u16 itemId, u8 *dst, u32 quantity)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (itemId >= ITEM_CHERI_BERRY && itemId <= ITEM_ENIGMA_BERRY)
|
||||
GetBerryCountString(dst, gBerries[itemId - ITEM_CHERI_BERRY].name, quantity);
|
||||
if (itemId >= FIRST_BERRY_INDEX && itemId <= LAST_BERRY_INDEX)
|
||||
GetBerryCountString(dst, gBerries[itemId - FIRST_BERRY_INDEX].name, quantity);
|
||||
else
|
||||
StringCopy(dst, ItemId_GetName(itemId));
|
||||
}
|
||||
|
@ -742,7 +742,7 @@ void BagMenu_InitBGs(void)
|
||||
ResetVramOamAndBgCntRegs();
|
||||
memset(gBagMenu->tilemapBuffer, 0, 0x800);
|
||||
ResetBgsAndClearDma3BusyFlags(0);
|
||||
InitBgsFromTemplates(0, sBgTemplates_ItemMenu, 3);
|
||||
InitBgsFromTemplates(0, sBgTemplates_ItemMenu, ARRAY_COUNT(sBgTemplates_ItemMenu));
|
||||
SetBgTilemapBuffer(2, gBagMenu->tilemapBuffer);
|
||||
ResetAllBgsCoordinates();
|
||||
ScheduleBgCopyTilemapToVram(2);
|
||||
@ -865,7 +865,7 @@ void GetItemName(s8 *dest, u16 itemId)
|
||||
}
|
||||
break;
|
||||
case BERRIES_POCKET:
|
||||
ConvertIntToDecimalStringN(gStringVar1, itemId - ITEM_CHERI_BERRY + 1, STR_CONV_MODE_LEADING_ZEROS, 2);
|
||||
ConvertIntToDecimalStringN(gStringVar1, itemId - FIRST_BERRY_INDEX + 1, STR_CONV_MODE_LEADING_ZEROS, 2);
|
||||
CopyItemName(itemId, gStringVar2);
|
||||
StringExpandPlaceholders(dest, gText_NumberVar1Clear7Var2);
|
||||
break;
|
||||
@ -1721,7 +1721,7 @@ void ItemMenu_UseOutOfBattle(u8 taskId)
|
||||
if (ItemId_GetFieldFunc(gSpecialVar_ItemId))
|
||||
{
|
||||
BagMenu_RemoveSomeWindow();
|
||||
if (CalculatePlayerPartyCount() == 0 && ItemId_GetType(gSpecialVar_ItemId) == 1)
|
||||
if (CalculatePlayerPartyCount() == 0 && ItemId_GetType(gSpecialVar_ItemId) == ITEM_USE_PARTY_MENU)
|
||||
BagMenu_PrintThereIsNoPokemon(taskId);
|
||||
else
|
||||
{
|
||||
|
@ -77,13 +77,13 @@ EWRAM_DATA static void(*sItemUseOnFieldCB)(u8 taskId) = NULL;
|
||||
// Below is set TRUE by UseRegisteredKeyItemOnField
|
||||
#define tUsingRegisteredKeyItem data[3]
|
||||
|
||||
// .rodata
|
||||
|
||||
// UB here if an item with type ITEM_USE_MAIL or ITEM_USE_BAG_MENU uses SetUpItemUseCallback
|
||||
// Never occurs in vanilla, but can occur with improperly created items
|
||||
static const MainCallback sItemUseCallbacks[] =
|
||||
{
|
||||
CB2_ShowPartyMenuForItemUse,
|
||||
CB2_ReturnToField,
|
||||
NULL,
|
||||
[ITEM_USE_PARTY_MENU - 1] = CB2_ShowPartyMenuForItemUse,
|
||||
[ITEM_USE_FIELD - 1] = CB2_ReturnToField,
|
||||
[ITEM_USE_PBLOCK_CASE - 1] = NULL,
|
||||
};
|
||||
|
||||
static const u8 sClockwiseDirections[] = {DIR_NORTH, DIR_EAST, DIR_SOUTH, DIR_WEST};
|
||||
@ -94,13 +94,12 @@ static const struct YesNoFuncTable sUseTMHMYesNoFuncTable =
|
||||
.noFunc = BagMenu_InitListsMenu,
|
||||
};
|
||||
|
||||
// .text
|
||||
|
||||
#define tEnigmaBerryType data[4]
|
||||
static void SetUpItemUseCallback(u8 taskId)
|
||||
{
|
||||
u8 type;
|
||||
if (gSpecialVar_ItemId == ITEM_ENIGMA_BERRY)
|
||||
type = gTasks[taskId].data[4] - 1;
|
||||
type = gTasks[taskId].tEnigmaBerryType - 1;
|
||||
else
|
||||
type = ItemId_GetType(gSpecialVar_ItemId) - 1;
|
||||
if (!InBattlePyramid())
|
||||
@ -218,9 +217,9 @@ void ItemUseOutOfBattle_Bike(u8 taskId)
|
||||
|
||||
static void ItemUseOnFieldCB_Bike(u8 taskId)
|
||||
{
|
||||
if (!ItemId_GetSecondaryId(gSpecialVar_ItemId))
|
||||
if (ItemId_GetSecondaryId(gSpecialVar_ItemId) == MACH_BIKE)
|
||||
GetOnOffBike(PLAYER_AVATAR_FLAG_MACH_BIKE);
|
||||
else
|
||||
else // ACRO_BIKE
|
||||
GetOnOffBike(PLAYER_AVATAR_FLAG_ACRO_BIKE);
|
||||
ScriptUnfreezeObjectEvents();
|
||||
ScriptContext2_Disable();
|
||||
@ -1065,28 +1064,28 @@ void ItemUseOutOfBattle_EnigmaBerry(u8 taskId)
|
||||
case ITEM_EFFECT_SPDEF_EV:
|
||||
case ITEM_EFFECT_SPEED_EV:
|
||||
case ITEM_EFFECT_DEF_EV:
|
||||
gTasks[taskId].data[4] = 1;
|
||||
gTasks[taskId].tEnigmaBerryType = ITEM_USE_PARTY_MENU;
|
||||
ItemUseOutOfBattle_Medicine(taskId);
|
||||
break;
|
||||
case ITEM_EFFECT_SACRED_ASH:
|
||||
gTasks[taskId].data[4] = 1;
|
||||
gTasks[taskId].tEnigmaBerryType = ITEM_USE_PARTY_MENU;
|
||||
ItemUseOutOfBattle_SacredAsh(taskId);
|
||||
break;
|
||||
case ITEM_EFFECT_RAISE_LEVEL:
|
||||
gTasks[taskId].data[4] = 1;
|
||||
gTasks[taskId].tEnigmaBerryType = ITEM_USE_PARTY_MENU;
|
||||
ItemUseOutOfBattle_RareCandy(taskId);
|
||||
break;
|
||||
case ITEM_EFFECT_PP_UP:
|
||||
case ITEM_EFFECT_PP_MAX:
|
||||
gTasks[taskId].data[4] = 1;
|
||||
gTasks[taskId].tEnigmaBerryType = ITEM_USE_PARTY_MENU;
|
||||
ItemUseOutOfBattle_PPUp(taskId);
|
||||
break;
|
||||
case ITEM_EFFECT_HEAL_PP:
|
||||
gTasks[taskId].data[4] = 1;
|
||||
gTasks[taskId].tEnigmaBerryType = ITEM_USE_PARTY_MENU;
|
||||
ItemUseOutOfBattle_PPRecovery(taskId);
|
||||
break;
|
||||
default:
|
||||
gTasks[taskId].data[4] = 4;
|
||||
gTasks[taskId].tEnigmaBerryType = ITEM_USE_BAG_MENU;
|
||||
ItemUseOutOfBattle_CannotUse(taskId);
|
||||
break;
|
||||
}
|
||||
|
10
src/mail.c
10
src/mail.c
@ -125,7 +125,7 @@ static void CB2_ExitMailReadFreeVars(void);
|
||||
|
||||
// .rodata
|
||||
|
||||
static const struct BgTemplate sUnknown_0859F290[] = {
|
||||
static const struct BgTemplate sBgTemplates[] = {
|
||||
{
|
||||
.bg = 0,
|
||||
.charBaseIndex = 2,
|
||||
@ -254,7 +254,7 @@ void ReadMail(struct MailStruct *mail, void (*callback)(void), bool8 flag)
|
||||
sMailRead->parserMultiple = ConvertEasyChatWordsToString;
|
||||
if (IS_ITEM_MAIL(mail->itemId))
|
||||
{
|
||||
sMailRead->mailType = mail->itemId - ITEM_ORANGE_MAIL;
|
||||
sMailRead->mailType = mail->itemId - FIRST_MAIL_INDEX;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -279,10 +279,10 @@ void ReadMail(struct MailStruct *mail, void (*callback)(void), bool8 flag)
|
||||
default:
|
||||
sMailRead->animsActive = 0;
|
||||
break;
|
||||
case ITEM_BEAD_MAIL - ITEM_ORANGE_MAIL:
|
||||
case ITEM_BEAD_MAIL - FIRST_MAIL_INDEX:
|
||||
sMailRead->animsActive = 1;
|
||||
break;
|
||||
case ITEM_DREAM_MAIL - ITEM_ORANGE_MAIL:
|
||||
case ITEM_DREAM_MAIL - FIRST_MAIL_INDEX:
|
||||
sMailRead->animsActive = 2;
|
||||
break;
|
||||
}
|
||||
@ -336,7 +336,7 @@ static bool8 MailReadBuildGraphics(void)
|
||||
break;
|
||||
case 6:
|
||||
ResetBgsAndClearDma3BusyFlags(0);
|
||||
InitBgsFromTemplates(0, sUnknown_0859F290, 3);
|
||||
InitBgsFromTemplates(0, sBgTemplates, ARRAY_COUNT(sBgTemplates));
|
||||
SetBgTilemapBuffer(1, sMailRead->bg1TilemapBuffer);
|
||||
SetBgTilemapBuffer(2, sMailRead->bg2TilemapBuffer);
|
||||
break;
|
||||
|
@ -1799,7 +1799,7 @@ static void CB2_NewGameBirchSpeech_ReturnFromNamingScreen(void)
|
||||
ResetBgsAndClearDma3BusyFlags(0);
|
||||
SetGpuReg(REG_OFFSET_DISPCNT, 0);
|
||||
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP);
|
||||
InitBgsFromTemplates(0, sMainMenuBgTemplates, 2);
|
||||
InitBgsFromTemplates(0, sMainMenuBgTemplates, ARRAY_COUNT(sMainMenuBgTemplates));
|
||||
InitBgFromTemplate(&sBirchBgTemplate);
|
||||
SetVBlankCallback(NULL);
|
||||
SetGpuReg(REG_OFFSET_BG2CNT, 0);
|
||||
@ -2097,7 +2097,7 @@ static void NewGameBirchSpeech_ShowGenderMenu(void)
|
||||
{
|
||||
DrawMainMenuWindowBorder(&gNewGameBirchSpeechTextWindows[1], 0xF3);
|
||||
FillWindowPixelBuffer(1, PIXEL_FILL(1));
|
||||
PrintMenuTable(1, 2, sMenuActions_Gender);
|
||||
PrintMenuTable(1, ARRAY_COUNT(sMenuActions_Gender), sMenuActions_Gender);
|
||||
InitMenuInUpperLeftCornerPlaySoundWhenAPressed(1, 2, 0);
|
||||
PutWindowTilemap(1);
|
||||
CopyWindowToVram(1, 3);
|
||||
|
@ -288,8 +288,8 @@ static u32 (*const func_tbl[])(struct mevent_srv_common *) = {
|
||||
static u32 mevent_srv_exec_common(struct mevent_srv_common * svr)
|
||||
{
|
||||
u32 response;
|
||||
AGB_ASSERT(svr->mainseqno < NELEMS(func_tbl));
|
||||
AGB_ASSERT(svr->mainseqno < ARRAY_COUNT(func_tbl));
|
||||
response = func_tbl[svr->mainseqno](svr);
|
||||
AGB_ASSERT(svr->mainseqno < NELEMS(func_tbl));
|
||||
AGB_ASSERT(svr->mainseqno < ARRAY_COUNT(func_tbl));
|
||||
return response;
|
||||
}
|
||||
|
@ -443,7 +443,7 @@ static void InitItemStorageMenu(u8 taskId, u8 var)
|
||||
windowTemplate.width = GetMaxWidthInMenuTable(gPCText_ItemPCOptionsText, 4);
|
||||
data[4] = AddWindow(&windowTemplate);
|
||||
SetStandardWindowBorderStyle(data[4], 0);
|
||||
PrintMenuTable(data[4], 4, gPCText_ItemPCOptionsText);
|
||||
PrintMenuTable(data[4], ARRAY_COUNT(gPCText_ItemPCOptionsText), gPCText_ItemPCOptionsText);
|
||||
InitMenuInUpperLeftCornerPlaySoundWhenAPressed(data[4], 4, var);
|
||||
ScheduleBgCopyTilemapToVram(0);
|
||||
ItemStorageMenuPrint(gPCText_OptionDescList[var]);
|
||||
@ -686,7 +686,7 @@ static void Mailbox_ReturnToPlayerPC(u8 taskId)
|
||||
static void Mailbox_PrintMailOptions(u8 taskId)
|
||||
{
|
||||
u8 r4 = sub_81D1C84(2);
|
||||
PrintMenuTable(r4, 4, gMailboxMailOptions);
|
||||
PrintMenuTable(r4, ARRAY_COUNT(gMailboxMailOptions), gMailboxMailOptions);
|
||||
InitMenuInUpperLeftCornerPlaySoundWhenAPressed(r4, 4, 0);
|
||||
ScheduleBgCopyTilemapToVram(0);
|
||||
gTasks[taskId].func = Mailbox_MailOptionsProcessInput;
|
||||
|
@ -1373,7 +1373,7 @@ static const struct SearchOptionText sDexSearchColorOptions[] =
|
||||
{},
|
||||
};
|
||||
|
||||
static const struct SearchOptionText sDexSearchTypeOptions[] =
|
||||
static const struct SearchOptionText sDexSearchTypeOptions[NUMBER_OF_MON_TYPES + 1] = // + 2 for "None" and terminator, - 1 for Mystery
|
||||
{
|
||||
{gText_DexEmptyString, gText_DexSearchTypeNone},
|
||||
{gText_DexEmptyString, gTypeNames[TYPE_NORMAL]},
|
||||
@ -1407,7 +1407,7 @@ static const u8 sOrderOptions[] =
|
||||
ORDER_SMALLEST,
|
||||
};
|
||||
|
||||
static const u8 sDexSearchTypeIds[] =
|
||||
static const u8 sDexSearchTypeIds[NUMBER_OF_MON_TYPES] =
|
||||
{
|
||||
TYPE_NONE,
|
||||
TYPE_NORMAL,
|
||||
|
@ -2304,14 +2304,14 @@ void CreateMonWithGenderNatureLetter(struct Pokemon *mon, u16 species, u8 level,
|
||||
{
|
||||
u32 personality;
|
||||
|
||||
if ((u8)(unownLetter - 1) < 28)
|
||||
if ((u8)(unownLetter - 1) < NUM_UNOWN_FORMS)
|
||||
{
|
||||
u16 actualLetter;
|
||||
|
||||
do
|
||||
{
|
||||
personality = Random32();
|
||||
actualLetter = ((((personality & 0x3000000) >> 18) | ((personality & 0x30000) >> 12) | ((personality & 0x300) >> 6) | (personality & 0x3)) % 28);
|
||||
actualLetter = GET_UNOWN_LETTER(personality);
|
||||
}
|
||||
while (nature != GetNatureFromPersonality(personality)
|
||||
|| gender != GetGenderFromSpeciesAndPersonality(species, personality)
|
||||
|
@ -1099,7 +1099,7 @@ u16 GetUnownLetterByPersonality(u32 personality)
|
||||
if (!personality)
|
||||
return 0;
|
||||
else
|
||||
return (((personality & 0x3000000) >> 18) | ((personality & 0x30000) >> 12) | ((personality & 0x300) >> 6) | (personality & 0x3)) % 0x1C;
|
||||
return GET_UNOWN_LETTER(personality);
|
||||
}
|
||||
|
||||
u16 sub_80D2E84(u16 species)
|
||||
|
@ -419,7 +419,7 @@ static u32 LoopedTask_OpenConditionSearchResults(s32 state)
|
||||
switch (state)
|
||||
{
|
||||
case 0:
|
||||
InitBgTemplates(sConditionSearchResultBgTemplates, NELEMS(sConditionSearchResultBgTemplates));
|
||||
InitBgTemplates(sConditionSearchResultBgTemplates, ARRAY_COUNT(sConditionSearchResultBgTemplates));
|
||||
DecompressAndCopyTileDataToVram(1, sConditionSearchResultTiles, 0, 0, 0);
|
||||
SetBgTilemapBuffer(1, searchList->buff);
|
||||
CopyToBgTilemapBuffer(1, sConditionSearchResultTilemap, 0, 0);
|
||||
|
@ -750,7 +750,7 @@ static void LoadPokenavOptionPalettes(void)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
for (i = 0; i < NELEMS(sPokenavOptionsSpriteSheets); i++)
|
||||
for (i = 0; i < ARRAY_COUNT(sPokenavOptionsSpriteSheets); i++)
|
||||
LoadCompressedSpriteSheet(&sPokenavOptionsSpriteSheets[i]);
|
||||
Pokenav_AllocAndLoadPalettes(sPokenavOptionsSpritePalettes);
|
||||
}
|
||||
|
@ -427,7 +427,7 @@ static u32 LoopedTask_OpenRibbonsMonList(s32 state)
|
||||
switch (state)
|
||||
{
|
||||
case 0:
|
||||
InitBgTemplates(sMonRibbonListBgTemplates, NELEMS(sMonRibbonListBgTemplates));
|
||||
InitBgTemplates(sMonRibbonListBgTemplates, ARRAY_COUNT(sMonRibbonListBgTemplates));
|
||||
DecompressAndCopyTileDataToVram(1, sMonRibbonListFrameTiles, 0, 0, 0);
|
||||
SetBgTilemapBuffer(1, monMenu->buff);
|
||||
CopyToBgTilemapBuffer(1, sMonRibbonListFrameTilemap, 0, 0);
|
||||
|
@ -1677,7 +1677,7 @@ void CB2_OpenFlyMap(void)
|
||||
break;
|
||||
case 1:
|
||||
ResetBgsAndClearDma3BusyFlags(0);
|
||||
InitBgsFromTemplates(1, sFlyMapBgTemplates, 3);
|
||||
InitBgsFromTemplates(1, sFlyMapBgTemplates, ARRAY_COUNT(sFlyMapBgTemplates));
|
||||
gMain.state++;
|
||||
break;
|
||||
case 2:
|
||||
|
@ -62,7 +62,7 @@ static const struct OamData sClockOamData =
|
||||
.affineParam = 0
|
||||
};
|
||||
|
||||
static const struct BgTemplate gUnknown_085EFD88[3] =
|
||||
static const struct BgTemplate sBgTemplates[3] =
|
||||
{
|
||||
{
|
||||
.bg = 0,
|
||||
@ -212,7 +212,7 @@ static void CB2_SaveFailedScreen(void)
|
||||
LZ77UnCompVram(gBirchGrassTilemap, (void *)(BG_SCREEN_ADDR(15)));
|
||||
LZ77UnCompVram(sSaveFailedClockGfx, (void *)(VRAM + 0x10020));
|
||||
ResetBgsAndClearDma3BusyFlags(0);
|
||||
InitBgsFromTemplates(0, gUnknown_085EFD88, 3);
|
||||
InitBgsFromTemplates(0, sBgTemplates, ARRAY_COUNT(sBgTemplates));
|
||||
SetBgTilemapBuffer(0, (void *)&gDecompressionBuffer[0x2000]);
|
||||
CpuFill32(0, &gDecompressionBuffer[0x2000], 0x800);
|
||||
LoadBgTiles(0, gTextWindowFrame1_Gfx, 0x120, 0x214);
|
||||
|
@ -996,7 +996,7 @@ static void ShowRegistryMenuActions(u8 taskId)
|
||||
template.width = GetMaxWidthInMenuTable(sRegistryMenuActions, 2);
|
||||
data[7] = AddWindow(&template);
|
||||
SetStandardWindowBorderStyle(data[7], 0);
|
||||
PrintMenuTable(data[7], 2, sRegistryMenuActions);
|
||||
PrintMenuTable(data[7], ARRAY_COUNT(sRegistryMenuActions), sRegistryMenuActions);
|
||||
InitMenuInUpperLeftCornerPlaySoundWhenAPressed(data[7], 2, 0);
|
||||
ScheduleBgCopyTilemapToVram(0);
|
||||
gTasks[taskId].func = HandleRegistryMenuActionsInput;
|
||||
|
Loading…
x
Reference in New Issue
Block a user