From 74ec59cace57d0036512688aaf39bac2647fc8a4 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Tue, 21 Mar 2023 18:11:49 -0400 Subject: [PATCH 01/51] add sAnimHideHpBoxes to fix healthbox reappearing from e.g. B_ANIM_SWITCH_OUT_OPPONENT_MON --- src/battle_anim.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/battle_anim.c b/src/battle_anim.c index fd81152e1..de9a97ce2 100644 --- a/src/battle_anim.c +++ b/src/battle_anim.c @@ -119,6 +119,7 @@ EWRAM_DATA u8 gBattleAnimAttacker = 0; EWRAM_DATA u8 gBattleAnimTarget = 0; EWRAM_DATA u16 gAnimBattlerSpecies[MAX_BATTLERS_COUNT] = {0}; EWRAM_DATA u8 gAnimCustomPanning = 0; +EWRAM_DATA static bool8 sAnimHideHpBoxes = FALSE; #include "data/battle_anim.h" @@ -232,7 +233,6 @@ void LaunchBattleAnimation(u32 animType, u32 animId) { s32 i; const u8 *const *animsTable; - bool32 hideHpBoxes; if (gTestRunnerEnabled) { @@ -261,7 +261,7 @@ void LaunchBattleAnimation(u32 animType, u32 animId) break; } - hideHpBoxes = !(animType == ANIM_TYPE_MOVE && animId == MOVE_TRANSFORM); + sAnimHideHpBoxes = !(animType == ANIM_TYPE_MOVE && animId == MOVE_TRANSFORM); if (animType != ANIM_TYPE_MOVE) { switch (animId) @@ -276,10 +276,10 @@ void LaunchBattleAnimation(u32 animType, u32 animId) case B_ANIM_MEGA_EVOLUTION: case B_ANIM_PRIMAL_REVERSION: case B_ANIM_GULP_MISSILE: - hideHpBoxes = TRUE; + sAnimHideHpBoxes = TRUE; break; default: - hideHpBoxes = FALSE; + sAnimHideHpBoxes = FALSE; break; } } @@ -287,7 +287,7 @@ void LaunchBattleAnimation(u32 animType, u32 animId) if (!IsContest()) { InitPrioritiesForVisibleBattlers(); - UpdateOamPriorityInAllHealthboxes(0, hideHpBoxes); + UpdateOamPriorityInAllHealthboxes(0, sAnimHideHpBoxes); for (i = 0; i < MAX_BATTLERS_COUNT; i++) { if (GetBattlerSide(i) != B_SIDE_PLAYER) @@ -762,7 +762,8 @@ static void Cmd_end(void) if (!IsContest()) { InitPrioritiesForVisibleBattlers(); - UpdateOamPriorityInAllHealthboxes(1, TRUE); + UpdateOamPriorityInAllHealthboxes(1, sAnimHideHpBoxes); + sAnimHideHpBoxes = FALSE; } gAnimScriptActive = FALSE; } From afc4b4cdee2d5596a6262084bd795281f887d7b9 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Tue, 28 Mar 2023 15:07:37 -0400 Subject: [PATCH 02/51] add mirror herb --- data/battle_scripts_1.s | 29 ++++++++++++++++++++++----- include/battle.h | 1 + include/battle_scripts.h | 2 ++ include/constants/battle_string_ids.h | 3 ++- src/battle_message.c | 2 ++ src/battle_script_commands.c | 14 +++++++++++++ src/battle_util.c | 26 ++++++++++++++++++++++++ 7 files changed, 71 insertions(+), 6 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 200a04461..c8bd53735 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -9980,23 +9980,42 @@ BattleScript_PrintPlayerForfeitedLinkBattle:: end2 BattleScript_TotemFlaredToLife:: - playanimation BS_ATTACKER, B_ANIM_TOTEM_FLARE + playanimation BS_ATTACKER, B_ANIM_TOTEM_FLARE, NULL printstring STRINGID_AURAFLAREDTOLIFE waitmessage B_WAIT_TIME_LONG - goto BattleScript_ApplyTotemVarBoost + call BattleScript_ApplyTotemVarBoost + end2 + +@ remove the mirror herb, do totem loop +BattleScript_MirrorHerbCopyStatChangeEnd2:: + call BattleScript_MirrorHerbCopyStatChange + end2 + +BattleScript_MirrorHerbCopyStatChange:: + playanimation BS_SCRIPTING, B_ANIM_HELD_ITEM_EFFECT, NULL + printstring STRINGID_MIRRORHERBCOPIED + waitmessage B_WAIT_TIME_LONG + removeitem BS_SCRIPTING + call BattleScript_TotemVar_Ret + copybyte gBattlerAttacker, sSAVED_BATTLER @ restore the original attacker just to be safe + return BattleScript_TotemVar:: + call BattleScript_TotemVar_Ret + end2 + +BattleScript_TotemVar_Ret:: gettotemboost BattleScript_ApplyTotemVarBoost BattleScript_TotemVarEnd: - end2 + return BattleScript_ApplyTotemVarBoost: statbuffchange STAT_CHANGE_ALLOW_PTR, BattleScript_TotemVarEnd setgraphicalstatchangevalues playanimation BS_SCRIPTING, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1 -BattleScript_TotemVarPrintStatMsg: printfromtable gStatUpStringIds waitmessage B_WAIT_TIME_LONG - goto BattleScript_TotemVar @loop until stats bitfield is empty + goto BattleScript_TotemVar_Ret @loop until stats bitfield is empty + BattleScript_AnnounceAirLockCloudNine:: call BattleScript_AbilityPopUp diff --git a/include/battle.h b/include/battle.h index 491273b80..f1818d583 100644 --- a/include/battle.h +++ b/include/battle.h @@ -145,6 +145,7 @@ struct ProtectStruct u16 quash:1; u16 shellTrap:1; u16 silkTrapped:1; + u16 eatMirrorHerb:1; u32 physicalDmg; u32 specialDmg; u8 physicalBattlerId; diff --git a/include/battle_scripts.h b/include/battle_scripts.h index c78fcafe4..248f28119 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -1,6 +1,8 @@ #ifndef GUARD_BATTLE_SCRIPTS_H #define GUARD_BATTLE_SCRIPTS_H +extern const u8 BattleScript_MirrorHerbCopyStatChange[]; +extern const u8 BattleScript_MirrorHerbCopyStatChangeEnd2[]; extern const u8 BattleScript_NotAffected[]; extern const u8 BattleScript_HitFromCritCalc[]; extern const u8 BattleScript_MoveEnd[]; diff --git a/include/constants/battle_string_ids.h b/include/constants/battle_string_ids.h index b94176334..4051a3a6d 100644 --- a/include/constants/battle_string_ids.h +++ b/include/constants/battle_string_ids.h @@ -647,8 +647,9 @@ #define STRINGID_STEALTHROCKDISAPPEAREDFROMTEAM 645 #define STRINGID_COULDNTFULLYPROTECT 646 #define STRINGID_STOCKPILEDEFFECTWOREOFF 647 +#define STRINGID_MIRRORHERBCOPIED 648 -#define BATTLESTRINGS_COUNT 648 +#define BATTLESTRINGS_COUNT 649 // This is the string id that gBattleStringsTable starts with. // String ids before this (e.g. STRINGID_INTROMSG) are not in the table, diff --git a/src/battle_message.c b/src/battle_message.c index 2ecfac0c7..9ab40cd4e 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -782,9 +782,11 @@ static const u8 sText_PrepareShellTrap[] = _("{B_ATK_NAME_WITH_PREFIX} set a she static const u8 sText_ShellTrapDidntWork[] = _("{B_ATK_NAME_WITH_PREFIX}'s shell trap didn't work!"); static const u8 sText_CouldntFullyProtect[] = _("{B_DEF_NAME_WITH_PREFIX} couldn't fully protect\nitself and got hurt!"); static const u8 sText_StockpiledEffectWoreOff[] = _("{B_ATK_NAME_WITH_PREFIX}'s stockpiled\neffect wore off!"); +static const u8 sText_MirrorHerbCopied[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX}'s used its {B_LAST_ITEM}\nto mirror its opponent's stat changes!"); const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = { + [STRINGID_MIRRORHERBCOPIED - BATTLESTRINGS_TABLE_START] = sText_MirrorHerbCopied, [STRINGID_STOCKPILEDEFFECTWOREOFF - BATTLESTRINGS_TABLE_START] = sText_StockpiledEffectWoreOff, [STRINGID_COULDNTFULLYPROTECT - BATTLESTRINGS_TABLE_START] = sText_CouldntFullyProtect, [STRINGID_ATTACKERGAINEDSTRENGTHFROMTHEFALLEN - BATTLESTRINGS_TABLE_START] = sText_AttackerGainedStrengthFromTheFallen, diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 28bf60c39..72a332af9 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -12080,6 +12080,20 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr { gBattleCommunication[MULTISTRING_CHOOSER] = (gBattlerTarget == gActiveBattler); gProtectStructs[gActiveBattler].statRaised = TRUE; + + // check mirror herb + for (index = 0; index < gBattlersCount; index++) + { + if (GetBattlerSide(index) == GetBattlerSide(gActiveBattler)) + continue; // Only triggers on opposing side + if (GetBattlerHoldEffect(index, TRUE) == HOLD_EFFECT_MIRROR_HERB + && gBattleMons[index].statStages[statId] < MAX_STAT_STAGE) + { + gProtectStructs[index].eatMirrorHerb = 1; + gTotemBoosts[index].stats |= (1 << (statId - 1)); // -1 to start at atk + gTotemBoosts[index].statChanges[statId - 1] = statValue; + } + } } } diff --git a/src/battle_util.c b/src/battle_util.c index dea28b5d8..e92ccfdbd 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -6877,6 +6877,26 @@ static bool32 GetMentalHerbEffect(u8 battlerId) return ret; } +static u8 TryConsumeMirrorHerb(u8 battlerId, bool32 execute) +{ + u8 effect = 0; + + if (gProtectStructs[battlerId].eatMirrorHerb) { + gLastUsedItem = gBattleMons[battlerId].item; + gBattleScripting.savedBattler = gBattlerAttacker; + gBattleScripting.battler = gBattlerAttacker = battlerId; + gProtectStructs[battlerId].eatMirrorHerb = 0; + if (execute) { + BattleScriptExecute(BattleScript_MirrorHerbCopyStatChangeEnd2); + } else { + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_MirrorHerbCopyStatChange; + } + effect = ITEM_STATS_CHANGE; + } + return effect; +} + static u8 ItemEffectMoveEnd(u32 battlerId, u16 holdEffect) { u8 effect = 0; @@ -7058,6 +7078,9 @@ static u8 ItemEffectMoveEnd(u32 battlerId, u16 holdEffect) effect = ITEM_EFFECT_OTHER; } break; + case HOLD_EFFECT_MIRROR_HERB: + effect = TryConsumeMirrorHerb(battlerId, FALSE); + break; } return effect; @@ -7580,6 +7603,9 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) if (!moveTurn) effect = TrySetMicleBerry(battlerId, gLastUsedItem, TRUE); break; + case HOLD_EFFECT_MIRROR_HERB: + effect = TryConsumeMirrorHerb(battlerId, TRUE); + break; } if (effect != 0) From f8bbcdfe73bafea1fa8db869e4fcdfe4c492c948 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Tue, 28 Mar 2023 15:12:54 -0400 Subject: [PATCH 03/51] minor fix to mirror herb message --- src/battle_message.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_message.c b/src/battle_message.c index 9ab40cd4e..140b8b3c4 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -782,7 +782,7 @@ static const u8 sText_PrepareShellTrap[] = _("{B_ATK_NAME_WITH_PREFIX} set a she static const u8 sText_ShellTrapDidntWork[] = _("{B_ATK_NAME_WITH_PREFIX}'s shell trap didn't work!"); static const u8 sText_CouldntFullyProtect[] = _("{B_DEF_NAME_WITH_PREFIX} couldn't fully protect\nitself and got hurt!"); static const u8 sText_StockpiledEffectWoreOff[] = _("{B_ATK_NAME_WITH_PREFIX}'s stockpiled\neffect wore off!"); -static const u8 sText_MirrorHerbCopied[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX}'s used its {B_LAST_ITEM}\nto mirror its opponent's stat changes!"); +static const u8 sText_MirrorHerbCopied[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} used its {B_LAST_ITEM}\nto mirror its opponent's stat changes!"); const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = { From 76f02774ea645eb285731b49f9c829bc17341b8b Mon Sep 17 00:00:00 2001 From: Martin Griffin Date: Thu, 20 Apr 2023 20:35:22 +0100 Subject: [PATCH 04/51] Detect memory leaks in tests Can use KNOWN_LEAKING; to specify that a test is known to leak memory. The location information is available in regular game builds. Thus it is available for use in debugging leaks in-game too. In the future we should consider replacing it with NULL if NDEBUG is defined. This is not currently possible because the tests do not force NDEBUG to be undefined. --- gflib/malloc.c | 69 +++++++++++++++++++-------------------- gflib/malloc.h | 41 +++++++++++++++++++++-- include/gba/defines.h | 3 ++ include/global.h | 3 ++ test/test.h | 5 +++ test/test_battle.h | 1 + test/test_runner.c | 26 +++++++++++++++ test/test_runner_battle.c | 10 ++++++ 8 files changed, 120 insertions(+), 38 deletions(-) diff --git a/gflib/malloc.c b/gflib/malloc.c index d0b949763..dcfac6ee8 100644 --- a/gflib/malloc.c +++ b/gflib/malloc.c @@ -1,37 +1,18 @@ #include "global.h" +#include "malloc.h" static void *sHeapStart; static u32 sHeapSize; -#define MALLOC_SYSTEM_ID 0xA3A3 - -struct MemBlock { - // Whether this block is currently allocated. - bool16 flag; - - // Magic number used for error checking. Should equal MALLOC_SYSTEM_ID. - u16 magic; - - // Size of the block (not including this header struct). - u32 size; - - // Previous block pointer. Equals sHeapStart if this is the first block. - struct MemBlock *prev; - - // Next block pointer. Equals sHeapStart if this is the last block. - struct MemBlock *next; - - // Data in the memory block. (Arrays of length 0 are a GNU extension.) - u8 data[0]; -}; - void PutMemBlockHeader(void *block, struct MemBlock *prev, struct MemBlock *next, u32 size) { struct MemBlock *header = (struct MemBlock *)block; - header->flag = FALSE; + header->allocated = FALSE; + header->locationHi = 0; header->magic = MALLOC_SYSTEM_ID; header->size = size; + header->locationLo = 0; header->prev = prev; header->next = next; } @@ -41,7 +22,7 @@ void PutFirstMemBlockHeader(void *block, u32 size) PutMemBlockHeader(block, (struct MemBlock *)block, (struct MemBlock *)block, size - sizeof(struct MemBlock)); } -void *AllocInternal(void *heapStart, u32 size) +void *AllocInternal(void *heapStart, u32 size, const char *location) { struct MemBlock *pos = (struct MemBlock *)heapStart; struct MemBlock *head = pos; @@ -55,14 +36,14 @@ void *AllocInternal(void *heapStart, u32 size) for (;;) { // Loop through the blocks looking for unused block that's big enough. - if (!pos->flag) { + if (!pos->allocated) { foundBlockSize = pos->size; if (foundBlockSize >= size) { if (foundBlockSize - size < 2 * sizeof(struct MemBlock)) { // The block isn't much bigger than the requested size, // so just use it. - pos->flag = TRUE; + pos->allocated = TRUE; } else { // The block is significantly bigger than the requested // size, so split the rest into a separate block. @@ -71,7 +52,7 @@ void *AllocInternal(void *heapStart, u32 size) splitBlock = (struct MemBlock *)(pos->data + size); - pos->flag = TRUE; + pos->allocated = TRUE; pos->size = size; PutMemBlockHeader(splitBlock, pos, pos->next, foundBlockSize); @@ -82,6 +63,9 @@ void *AllocInternal(void *heapStart, u32 size) splitBlock->next->prev = splitBlock; } + pos->locationHi = ((uintptr_t)location) >> 14; + pos->locationLo = (uintptr_t)location; + return pos->data; } } @@ -98,12 +82,12 @@ void FreeInternal(void *heapStart, void *pointer) if (pointer) { struct MemBlock *head = (struct MemBlock *)heapStart; struct MemBlock *block = (struct MemBlock *)((u8 *)pointer - sizeof(struct MemBlock)); - block->flag = FALSE; + block->allocated = FALSE; // If the freed block isn't the last one, merge with the next block // if it's not in use. if (block->next != head) { - if (!block->next->flag) { + if (!block->next->allocated) { block->size += sizeof(struct MemBlock) + block->next->size; block->next->magic = 0; block->next = block->next->next; @@ -115,7 +99,7 @@ void FreeInternal(void *heapStart, void *pointer) // If the freed block isn't the first one, merge with the previous block // if it's not in use. if (block != head) { - if (!block->prev->flag) { + if (!block->prev->allocated) { block->prev->next = block->next; if (block->next != head) @@ -128,9 +112,9 @@ void FreeInternal(void *heapStart, void *pointer) } } -void *AllocZeroedInternal(void *heapStart, u32 size) +void *AllocZeroedInternal(void *heapStart, u32 size, const char *location) { - void *mem = AllocInternal(heapStart, size); + void *mem = AllocInternal(heapStart, size, location); if (mem != NULL) { if (size & 3) @@ -175,14 +159,14 @@ void InitHeap(void *heapStart, u32 heapSize) PutFirstMemBlockHeader(heapStart, heapSize); } -void *Alloc(u32 size) +void *Alloc_(u32 size, const char *location) { - return AllocInternal(sHeapStart, size); + return AllocInternal(sHeapStart, size, location); } -void *AllocZeroed(u32 size) +void *AllocZeroed_(u32 size, const char *location) { - return AllocZeroedInternal(sHeapStart, size); + return AllocZeroedInternal(sHeapStart, size, location); } void Free(void *pointer) @@ -207,3 +191,16 @@ bool32 CheckHeap() return TRUE; } + +const struct MemBlock *HeapHead(void) +{ + return (const struct MemBlock *)sHeapStart; +} + +const char *MemBlockLocation(const struct MemBlock *block) +{ + if (!block->allocated) + return NULL; + + return (const char *)(ROM_START | (block->locationHi << 14) | block->locationLo); +} diff --git a/gflib/malloc.h b/gflib/malloc.h index 851db83a6..f484b1580 100644 --- a/gflib/malloc.h +++ b/gflib/malloc.h @@ -11,11 +11,48 @@ #define TRY_FREE_AND_SET_NULL(ptr) if (ptr != NULL) FREE_AND_SET_NULL(ptr) +#define MALLOC_SYSTEM_ID 0xA3A3 + +struct MemBlock +{ + // Whether this block is currently allocated. + u16 allocated:1; + + u16 unused_00:4; + + // High 11 bits of location pointer. + u16 locationHi:11; + + // Magic number used for error checking. Should equal MALLOC_SYSTEM_ID. + u16 magic; + + // Size of the block (not including this header struct). + u32 size:18; + + // Low 14 bits of location pointer. + u32 locationLo:14; + + // Previous block pointer. Equals sHeapStart if this is the first block. + struct MemBlock *prev; + + // Next block pointer. Equals sHeapStart if this is the last block. + struct MemBlock *next; + + // Data in the memory block. (Arrays of length 0 are a GNU extension.) + u8 data[0]; +}; + extern u8 gHeap[]; -void *Alloc(u32 size); -void *AllocZeroed(u32 size); +#define Alloc(size) Alloc_(size, __FILE__ ":" STR(__LINE__)) +#define AllocZeroed(size) AllocZeroed_(size, __FILE__ ":" STR(__LINE__)) + +void *Alloc_(u32 size, const char *location); +void *AllocZeroed_(u32 size, const char *location); void Free(void *pointer); void InitHeap(void *pointer, u32 size); +const struct MemBlock *HeapHead(void); +const char *MemBlockLocation(const struct MemBlock *block); + #endif // GUARD_ALLOC_H diff --git a/include/gba/defines.h b/include/gba/defines.h index 82caf56e6..9959a17ef 100644 --- a/include/gba/defines.h +++ b/include/gba/defines.h @@ -22,6 +22,9 @@ #define INTR_CHECK (*(u16 *)0x3007FF8) #define INTR_VECTOR (*(void **)0x3007FFC) +#define ROM_START 0x8000000 +#define ROM_END 0xA000000 + #define EWRAM_START 0x02000000 #define EWRAM_END (EWRAM_START + 0x40000) #define IWRAM_START 0x03000000 diff --git a/include/global.h b/include/global.h index c20f2ed42..eca45bdb6 100644 --- a/include/global.h +++ b/include/global.h @@ -147,6 +147,9 @@ #define CAT(a, b) CAT_(a, b) #define CAT_(a, b) a ## b +#define STR(a) STR_(a) +#define STR_(a) #a + // Converts a string to a compound literal, essentially making it a pointer to const u8 #define COMPOUND_STRING(str) (const u8[]) _(str) diff --git a/test/test.h b/test/test.h index dfa1f12b1..bf3e0b004 100644 --- a/test/test.h +++ b/test/test.h @@ -46,6 +46,7 @@ struct TestRunnerState u8 result; u8 expectedResult; + bool8 expectLeaks:1; u32 timeoutSeconds; }; @@ -69,6 +70,7 @@ extern struct TestRunnerState gTestRunnerState; void CB2_TestRunner(void); void Test_ExpectedResult(enum TestResult); +void Test_ExpectLeaks(bool32); void Test_ExitWithResult(enum TestResult, const char *fmt, ...); s32 MgbaPrintf_(const char *fmt, ...); @@ -160,6 +162,9 @@ s32 MgbaPrintf_(const char *fmt, ...); #define KNOWN_FAILING \ Test_ExpectedResult(TEST_RESULT_FAIL) +#define KNOWN_LEAKING \ + Test_ExpectLeaks(TRUE) + #define PARAMETRIZE if (gFunctionTestRunnerState->parameters++ == gFunctionTestRunnerState->runParameter) #define TO_DO \ diff --git a/test/test_battle.h b/test/test_battle.h index 967bb661d..3597e9d16 100644 --- a/test/test_battle.h +++ b/test/test_battle.h @@ -615,6 +615,7 @@ struct BattleTestRunnerState bool8 runThen:1; bool8 runFinally:1; bool8 runningFinally:1; + bool8 tearDownBattle:1; struct BattleTestData data; u8 *results; u8 checkProgressParameter; diff --git a/test/test_runner.c b/test/test_runner.c index ef9f2da73..64cb20e26 100644 --- a/test/test_runner.c +++ b/test/test_runner.c @@ -111,6 +111,7 @@ void CB2_TestRunner(void) gTestRunnerState.state = STATE_REPORT_RESULT; gTestRunnerState.result = TEST_RESULT_PASS; gTestRunnerState.expectedResult = TEST_RESULT_PASS; + gTestRunnerState.expectLeaks = FALSE; if (gTestRunnerHeadless) gTestRunnerState.timeoutSeconds = TIMEOUT_SECONDS; else @@ -141,6 +142,26 @@ void CB2_TestRunner(void) if (gTestRunnerState.test->runner->tearDown) gTestRunnerState.test->runner->tearDown(gTestRunnerState.test->data); + if (!gTestRunnerState.expectLeaks) + { + const struct MemBlock *head = HeapHead(); + const struct MemBlock *block = head; + do + { + if (block->allocated) + { + const char *location = MemBlockLocation(block); + if (location) + MgbaPrintf_("%s: %d bytes not freed", location, block->size); + else + MgbaPrintf_(": %d bytes not freed", block->size); + gTestRunnerState.result = TEST_RESULT_FAIL; + } + block = block->next; + } + while (block != head); + } + if (gTestRunnerState.test->runner == &gAssumptionsRunner) { if (gTestRunnerState.result != TEST_RESULT_PASS) @@ -238,6 +259,11 @@ void Test_ExpectedResult(enum TestResult result) gTestRunnerState.expectedResult = result; } +void Test_ExpectLeaks(bool32 expectLeaks) +{ + gTestRunnerState.expectLeaks = expectLeaks; +} + static void FunctionTest_SetUp(void *data) { (void)data; diff --git a/test/test_runner_battle.c b/test/test_runner_battle.c index 365120f13..8654f78cd 100644 --- a/test/test_runner_battle.c +++ b/test/test_runner_battle.c @@ -893,6 +893,15 @@ static void BattleTest_TearDown(void *data) { if (STATE) { + // Free resources that aren't cleaned up when the battle was + // aborted unexpectedly. + if (STATE->tearDownBattle) + { + FreeMonSpritesGfx(); + FreeBattleSpritesData(); + FreeBattleResources(); + FreeAllWindowBuffers(); + } FREE_AND_SET_NULL(STATE->results); FREE_AND_SET_NULL(STATE); } @@ -923,6 +932,7 @@ static bool32 BattleTest_HandleExitWithResult(void *data, enum TestResult result } else { + STATE->tearDownBattle = TRUE; return FALSE; } } From c81a985b5b76779c9419289dddb57ef047bfae70 Mon Sep 17 00:00:00 2001 From: Martin Griffin Date: Thu, 20 Apr 2023 21:45:16 +0100 Subject: [PATCH 05/51] Fix USE_ITEM explicit targets --- include/recorded_battle.h | 1 + src/battle_controller_recorded_opponent.c | 1 + src/battle_controller_recorded_player.c | 1 + test/test_runner_battle.c | 8 +++++--- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/include/recorded_battle.h b/include/recorded_battle.h index d04e89c36..ea66096d7 100644 --- a/include/recorded_battle.h +++ b/include/recorded_battle.h @@ -45,6 +45,7 @@ enum RECORDED_PARTY_INDEX, RECORDED_BATTLE_PALACE_ACTION, RECORDED_ITEM_ID, + RECORDED_ITEM_TARGET, }; extern u32 gRecordedBattleRngSeed; diff --git a/src/battle_controller_recorded_opponent.c b/src/battle_controller_recorded_opponent.c index e7fc6fd84..bb41b42d6 100644 --- a/src/battle_controller_recorded_opponent.c +++ b/src/battle_controller_recorded_opponent.c @@ -1441,6 +1441,7 @@ static void RecordedOpponentHandleChooseItem(void) u8 byte1 = RecordedBattle_GetBattlerAction(RECORDED_ITEM_ID, gActiveBattler); u8 byte2 = RecordedBattle_GetBattlerAction(RECORDED_ITEM_ID, gActiveBattler); gBattleStruct->chosenItem[gActiveBattler] = (byte1 << 8) | byte2; + gBattleStruct->itemPartyIndex[gActiveBattler] = RecordedBattle_GetBattlerAction(RECORDED_ITEM_TARGET, gActiveBattler); BtlController_EmitOneReturnValue(BUFFER_B, gBattleStruct->chosenItem[gActiveBattler]); RecordedOpponentBufferExecCompleted(); } diff --git a/src/battle_controller_recorded_player.c b/src/battle_controller_recorded_player.c index 87f575839..efbd60f18 100644 --- a/src/battle_controller_recorded_player.c +++ b/src/battle_controller_recorded_player.c @@ -1465,6 +1465,7 @@ static void RecordedPlayerHandleChooseItem(void) u8 byte1 = RecordedBattle_GetBattlerAction(RECORDED_ITEM_ID, gActiveBattler); u8 byte2 = RecordedBattle_GetBattlerAction(RECORDED_ITEM_ID, gActiveBattler); gBattleStruct->chosenItem[gActiveBattler] = (byte1 << 8) | byte2; + gBattleStruct->itemPartyIndex[gActiveBattler] = RecordedBattle_GetBattlerAction(RECORDED_ITEM_TARGET, gActiveBattler); BtlController_EmitOneReturnValue(BUFFER_B, gBattleStruct->chosenItem[gActiveBattler]); RecordedPlayerBufferExecCompleted(); } diff --git a/test/test_runner_battle.c b/test/test_runner_battle.c index 365120f13..2a44cc018 100644 --- a/test/test_runner_battle.c +++ b/test/test_runner_battle.c @@ -1540,9 +1540,11 @@ void UseItem(u32 sourceLine, struct BattlePokemon *battler, struct ItemContext c PushBattlerAction(sourceLine, battlerId, RECORDED_ITEM_ID, (ctx.itemId >> 8) & 0xFF); PushBattlerAction(sourceLine, battlerId, RECORDED_ITEM_ID, ctx.itemId & 0xFF); if (ctx.explicitPartyIndex) - gBattleStruct->itemPartyIndex[battlerId] = ctx.partyIndex; - if (ctx.explicitMove) - gBattleStruct->itemPartyIndex[battlerId] = i; + PushBattlerAction(sourceLine, battlerId, RECORDED_ITEM_TARGET, ctx.partyIndex); + else if (ctx.explicitMove) + PushBattlerAction(sourceLine, battlerId, RECORDED_ITEM_TARGET, i); + else + PushBattlerAction(sourceLine, battlerId, RECORDED_ITEM_TARGET, 0); DATA.actionBattlers |= 1 << battlerId; } From e1e8277fbaa9897c981e7619473df49c6cbe04a2 Mon Sep 17 00:00:00 2001 From: CallmeEchoo Date: Fri, 21 Apr 2023 00:29:58 +0200 Subject: [PATCH 06/51] batch 1 --- test/item_effect_cure_status.c | 101 +++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 test/item_effect_cure_status.c diff --git a/test/item_effect_cure_status.c b/test/item_effect_cure_status.c new file mode 100644 index 000000000..db8e56a45 --- /dev/null +++ b/test/item_effect_cure_status.c @@ -0,0 +1,101 @@ +#include "global.h" +#include "test_battle.h" + +SINGLE_BATTLE_TEST("Paralyze Heal heals a Pokemon from being paralyzed") +{ + GIVEN { + ASSUME(gItems[ITEM_PARALYZE_HEAL].battleUsage == EFFECT_ITEM_CURE_STATUS); + PLAYER(SPECIES_WOBBUFFET) { Status1(STATUS1_PARALYSIS); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { USE_ITEM(player, ITEM_PARALYZE_HEAL, partyIndex: 0); } + } SCENE { + MESSAGE("Paralyze Heal cured Wobbuffet's status!"); + } +} + +SINGLE_BATTLE_TEST("Antidote heals a Pokemon from being poisoned") +{ + GIVEN { + ASSUME(gItems[ITEM_ANTIDOTE].battleUsage == EFFECT_ITEM_CURE_STATUS); + PLAYER(SPECIES_WOBBUFFET) { Status1(STATUS1_PSN_ANY); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { USE_ITEM(player, ITEM_ANTIDOTE, partyIndex: 0); } + } SCENE { + MESSAGE("Antidote cured Wobbuffet's status!"); + } +} + +SINGLE_BATTLE_TEST("Awakening heals a Pokemon from being asleep") +{ + GIVEN { + ASSUME(gItems[ITEM_AWAKENING].battleUsage == EFFECT_ITEM_CURE_STATUS); + PLAYER(SPECIES_WOBBUFFET) { Status1(STATUS1_SLEEP); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { USE_ITEM(player, ITEM_AWAKENING, partyIndex: 0); } + } SCENE { + MESSAGE("Awakening cured Wobbuffet's status!"); + } +} + +SINGLE_BATTLE_TEST("Burn Heal heals a Pokemon from being burned") +{ + GIVEN { + ASSUME(gItems[ITEM_BURN_HEAL].battleUsage == EFFECT_ITEM_CURE_STATUS); + PLAYER(SPECIES_WOBBUFFET) { Status1(STATUS1_BURN); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { USE_ITEM(player, ITEM_BURN_HEAL, partyIndex: 0); } + } SCENE { + MESSAGE("Burn Heal cured Wobbuffet's status!"); + } +} + +SINGLE_BATTLE_TEST("Ice Heal heals a Pokemon from being paralyzed") +{ + GIVEN { + ASSUME(gItems[ITEM_ICE_HEAL].battleUsage == EFFECT_ITEM_CURE_STATUS); + PLAYER(SPECIES_WOBBUFFET) { Status1(STATUS1_FREEZE); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { USE_ITEM(player, ITEM_ICE_HEAL, partyIndex: 0); } + } SCENE { + MESSAGE("Ice Heal cured Wobbuffet's status!"); + } +} + +SINGLE_BATTLE_TEST("Full Heal heals a Pokemon from any primary status") +{ + u16 status; + PARAMETRIZE{ status = STATUS1_BURN; } + PARAMETRIZE{ status = STATUS1_FREEZE; } + PARAMETRIZE{ status = STATUS1_PARALYSIS; } + PARAMETRIZE{ status = STATUS1_POISON; } + PARAMETRIZE{ status = STATUS1_TOXIC_POISON; } + PARAMETRIZE{ status = STATUS1_SLEEP; } + GIVEN { + ASSUME(gItems[ITEM_FULL_HEAL].battleUsage == EFFECT_ITEM_CURE_STATUS); + PLAYER(SPECIES_WOBBUFFET) { Status1(status); } + OPPONENT(SPECIES_WYNAUT); + } WHEN { + TURN { USE_ITEM(player, ITEM_FULL_HEAL, partyIndex: 0); } + } SCENE { + MESSAGE("Full Heal cured Wobbuffet's status!"); + } +} + +SINGLE_BATTLE_TEST("Full Heal heals a Pokemon from being confused") +{ + GIVEN { + ASSUME(gItems[ITEM_FULL_HEAL].battleUsage == EFFECT_ITEM_CURE_STATUS); + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_GENGAR); + } WHEN { + TURN { MOVE(opponent, MOVE_CONFUSE_RAY); } + TURN { USE_ITEM(player, ITEM_FULL_HEAL, partyIndex: 0); } + } SCENE { + MESSAGE("Full Heal cured Wobbuffet's status!"); + } +} From 94cb569c4790b0b4fe5a0bd6d814e15cfeb75312 Mon Sep 17 00:00:00 2001 From: CallmeEchoo <65783283+CallmeEchoo@users.noreply.github.com> Date: Fri, 21 Apr 2023 10:25:58 +0200 Subject: [PATCH 07/51] local specialties tests --- test/item_effect_cure_status.c | 222 ++++++++++++++++++++++++++++++++- 1 file changed, 217 insertions(+), 5 deletions(-) diff --git a/test/item_effect_cure_status.c b/test/item_effect_cure_status.c index db8e56a45..9a850a131 100644 --- a/test/item_effect_cure_status.c +++ b/test/item_effect_cure_status.c @@ -18,7 +18,20 @@ SINGLE_BATTLE_TEST("Antidote heals a Pokemon from being poisoned") { GIVEN { ASSUME(gItems[ITEM_ANTIDOTE].battleUsage == EFFECT_ITEM_CURE_STATUS); - PLAYER(SPECIES_WOBBUFFET) { Status1(STATUS1_PSN_ANY); } + PLAYER(SPECIES_WOBBUFFET) { Status1(STATUS1_POISON); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { USE_ITEM(player, ITEM_ANTIDOTE, partyIndex: 0); } + } SCENE { + MESSAGE("Antidote cured Wobbuffet's status!"); + } +} + +SINGLE_BATTLE_TEST("Antidote heals a Pokemon from being badly poisoned") +{ + GIVEN { + ASSUME(gItems[ITEM_ANTIDOTE].battleUsage == EFFECT_ITEM_CURE_STATUS); + PLAYER(SPECIES_WOBBUFFET) { Status1(STATUS1_TOXIC_POISON); } OPPONENT(SPECIES_WOBBUFFET); } WHEN { TURN { USE_ITEM(player, ITEM_ANTIDOTE, partyIndex: 0); } @@ -86,16 +99,215 @@ SINGLE_BATTLE_TEST("Full Heal heals a Pokemon from any primary status") } } -SINGLE_BATTLE_TEST("Full Heal heals a Pokemon from being confused") +SINGLE_BATTLE_TEST("Pewter Crunchies heals a Pokemon from any primary status") { + u16 status; + PARAMETRIZE{ status = STATUS1_BURN; } + PARAMETRIZE{ status = STATUS1_FREEZE; } + PARAMETRIZE{ status = STATUS1_PARALYSIS; } + PARAMETRIZE{ status = STATUS1_POISON; } + PARAMETRIZE{ status = STATUS1_TOXIC_POISON; } + PARAMETRIZE{ status = STATUS1_SLEEP; } GIVEN { - ASSUME(gItems[ITEM_FULL_HEAL].battleUsage == EFFECT_ITEM_CURE_STATUS); + ASSUME(gItems[ITEM_PEWTER_CRUNCHIES].battleUsage == EFFECT_ITEM_CURE_STATUS); + PLAYER(SPECIES_WOBBUFFET) { Status1(status); } + OPPONENT(SPECIES_WYNAUT); + } WHEN { + TURN { USE_ITEM(player, ITEM_PEWTER_CRUNCHIES, partyIndex: 0); } + } SCENE { + MESSAGE("PewtrCrnches cured Wobbuffet's status!"); + } +} + +SINGLE_BATTLE_TEST("Lava Cookies heals a Pokemon from any primary status") +{ + u16 status; + PARAMETRIZE{ status = STATUS1_BURN; } + PARAMETRIZE{ status = STATUS1_FREEZE; } + PARAMETRIZE{ status = STATUS1_PARALYSIS; } + PARAMETRIZE{ status = STATUS1_POISON; } + PARAMETRIZE{ status = STATUS1_TOXIC_POISON; } + PARAMETRIZE{ status = STATUS1_SLEEP; } + GIVEN { + ASSUME(gItems[ITEM_LAVA_COOKIE].battleUsage == EFFECT_ITEM_CURE_STATUS); + PLAYER(SPECIES_WOBBUFFET) { Status1(status); } + OPPONENT(SPECIES_WYNAUT); + } WHEN { + TURN { USE_ITEM(player, ITEM_LAVA_COOKIE, partyIndex: 0); } + } SCENE { + MESSAGE("Lava Cookie cured Wobbuffet's status!"); + } +} + +SINGLE_BATTLE_TEST("Rage Candy Bar heals a Pokemon from any primary status") +{ + u16 status; + PARAMETRIZE{ status = STATUS1_BURN; } + PARAMETRIZE{ status = STATUS1_FREEZE; } + PARAMETRIZE{ status = STATUS1_PARALYSIS; } + PARAMETRIZE{ status = STATUS1_POISON; } + PARAMETRIZE{ status = STATUS1_TOXIC_POISON; } + PARAMETRIZE{ status = STATUS1_SLEEP; } + GIVEN { + ASSUME(gItems[ITEM_RAGE_CANDY_BAR].battleUsage == EFFECT_ITEM_CURE_STATUS); + PLAYER(SPECIES_WOBBUFFET) { Status1(status); } + OPPONENT(SPECIES_WYNAUT); + } WHEN { + TURN { USE_ITEM(player, ITEM_RAGE_CANDY_BAR, partyIndex: 0); } + } SCENE { + MESSAGE("RageCandyBar cured Wobbuffet's status!"); + } +} + +SINGLE_BATTLE_TEST("Old Gateu heals a Pokemon from any primary status") +{ + u16 status; + PARAMETRIZE{ status = STATUS1_BURN; } + PARAMETRIZE{ status = STATUS1_FREEZE; } + PARAMETRIZE{ status = STATUS1_PARALYSIS; } + PARAMETRIZE{ status = STATUS1_POISON; } + PARAMETRIZE{ status = STATUS1_TOXIC_POISON; } + PARAMETRIZE{ status = STATUS1_SLEEP; } + GIVEN { + ASSUME(gItems[ITEM_OLD_GATEAU].battleUsage == EFFECT_ITEM_CURE_STATUS); + PLAYER(SPECIES_WOBBUFFET) { Status1(status); } + OPPONENT(SPECIES_WYNAUT); + } WHEN { + TURN { USE_ITEM(player, ITEM_OLD_GATEAU, partyIndex: 0); } + } SCENE { + MESSAGE("Old Gateau cured Wobbuffet's status!"); + } +} + +SINGLE_BATTLE_TEST("Casteliacone heals a Pokemon from any primary status") +{ + u16 status; + PARAMETRIZE{ status = STATUS1_BURN; } + PARAMETRIZE{ status = STATUS1_FREEZE; } + PARAMETRIZE{ status = STATUS1_PARALYSIS; } + PARAMETRIZE{ status = STATUS1_POISON; } + PARAMETRIZE{ status = STATUS1_TOXIC_POISON; } + PARAMETRIZE{ status = STATUS1_SLEEP; } + GIVEN { + ASSUME(gItems[ITEM_CASTELIACONE].battleUsage == EFFECT_ITEM_CURE_STATUS); + PLAYER(SPECIES_WOBBUFFET) { Status1(status); } + OPPONENT(SPECIES_WYNAUT); + } WHEN { + TURN { USE_ITEM(player, ITEM_CASTELIACONE, partyIndex: 0); } + } SCENE { + MESSAGE("Casteliacone cured Wobbuffet's status!"); + } +} + +SINGLE_BATTLE_TEST("Lumiose Galette heals a Pokemon from any primary status") +{ + u16 status; + PARAMETRIZE{ status = STATUS1_BURN; } + PARAMETRIZE{ status = STATUS1_FREEZE; } + PARAMETRIZE{ status = STATUS1_PARALYSIS; } + PARAMETRIZE{ status = STATUS1_POISON; } + PARAMETRIZE{ status = STATUS1_TOXIC_POISON; } + PARAMETRIZE{ status = STATUS1_SLEEP; } + GIVEN { + ASSUME(gItems[ITEM_LUMIOSE_GALETTE].battleUsage == EFFECT_ITEM_CURE_STATUS); + PLAYER(SPECIES_WOBBUFFET) { Status1(status); } + OPPONENT(SPECIES_WYNAUT); + } WHEN { + TURN { USE_ITEM(player, ITEM_LUMIOSE_GALETTE, partyIndex: 0); } + } SCENE { + MESSAGE("LumioseGlete cured Wobbuffet's status!"); + } +} + +SINGLE_BATTLE_TEST("Shalour Sable heals a Pokemon from any primary status") +{ + u16 status; + PARAMETRIZE{ status = STATUS1_BURN; } + PARAMETRIZE{ status = STATUS1_FREEZE; } + PARAMETRIZE{ status = STATUS1_PARALYSIS; } + PARAMETRIZE{ status = STATUS1_POISON; } + PARAMETRIZE{ status = STATUS1_TOXIC_POISON; } + PARAMETRIZE{ status = STATUS1_SLEEP; } + GIVEN { + ASSUME(gItems[ITEM_SHALOUR_SABLE].battleUsage == EFFECT_ITEM_CURE_STATUS); + PLAYER(SPECIES_WOBBUFFET) { Status1(status); } + OPPONENT(SPECIES_WYNAUT); + } WHEN { + TURN { USE_ITEM(player, ITEM_SHALOUR_SABLE, partyIndex: 0); } + } SCENE { + MESSAGE("ShalourSable cured Wobbuffet's status!"); + } +} + +SINGLE_BATTLE_TEST("Big Malasada heals a Pokemon from any primary status") +{ + u16 status; + PARAMETRIZE{ status = STATUS1_BURN; } + PARAMETRIZE{ status = STATUS1_FREEZE; } + PARAMETRIZE{ status = STATUS1_PARALYSIS; } + PARAMETRIZE{ status = STATUS1_POISON; } + PARAMETRIZE{ status = STATUS1_TOXIC_POISON; } + PARAMETRIZE{ status = STATUS1_SLEEP; } + GIVEN { + ASSUME(gItems[ITEM_BIG_MALASADA].battleUsage == EFFECT_ITEM_CURE_STATUS); + PLAYER(SPECIES_WOBBUFFET) { Status1(status); } + OPPONENT(SPECIES_WYNAUT); + } WHEN { + TURN { USE_ITEM(player, ITEM_BIG_MALASADA, partyIndex: 0); } + } SCENE { + MESSAGE("Big Malasada cured Wobbuffet's status!"); + } +} + +SINGLE_BATTLE_TEST("Full Heal and local specialties heal a Pokemon from being confused") +{ + u16 item; + PARAMETRIZE { item = ITEM_FULL_HEAL; } + PARAMETRIZE { item = ITEM_PEWTER_CRUNCHIES; } + PARAMETRIZE { item = ITEM_LAVA_COOKIE; } + PARAMETRIZE { item = ITEM_RAGE_CANDY_BAR; } + PARAMETRIZE { item = ITEM_OLD_GATEAU; } + PARAMETRIZE { item = ITEM_CASTELIACONE; } + PARAMETRIZE { item = ITEM_LUMIOSE_GALETTE; } + PARAMETRIZE { item = ITEM_SHALOUR_SABLE; } + PARAMETRIZE { item = ITEM_BIG_MALASADA; } + GIVEN { + ASSUME(gItems[item].battleUsage == EFFECT_ITEM_CURE_STATUS); PLAYER(SPECIES_WOBBUFFET); OPPONENT(SPECIES_GENGAR); } WHEN { TURN { MOVE(opponent, MOVE_CONFUSE_RAY); } - TURN { USE_ITEM(player, ITEM_FULL_HEAL, partyIndex: 0); } + TURN { USE_ITEM(player, item, partyIndex: 0); } } SCENE { - MESSAGE("Full Heal cured Wobbuffet's status!"); + switch (item) + { + case ITEM_FULL_HEAL: + MESSAGE("Full Heal cured Wobbuffet's status!"); + break; + case ITEM_PEWTER_CRUNCHIES: + MESSAGE("PewtrCrnches cured Wobbuffet's status!"); + break; + case ITEM_LAVA_COOKIE: + MESSAGE("Lava Cookie cured Wobbuffet's status!"); + break; + case ITEM_RAGE_CANDY_BAR: + MESSAGE("RageCandyBar cured Wobbuffet's status!"); + break; + case ITEM_OLD_GATEAU: + MESSAGE("Old Gateau cured Wobbuffet's status!"); + break; + case ITEM_CASTELIACONE: + MESSAGE("Casteliacone cured Wobbuffet's status!"); + break; + case ITEM_LUMIOSE_GALETTE: + MESSAGE("LumioseGlete cured Wobbuffet's status!"); + break; + case ITEM_SHALOUR_SABLE: + MESSAGE("ShalourSable cured Wobbuffet's status!"); + break; + case ITEM_BIG_MALASADA: + MESSAGE("Big Malasada cured Wobbuffet's status!"); + break; + } } } From 301a12fe98c9d892ace9de3f6d085ed8df5b35cc Mon Sep 17 00:00:00 2001 From: CallmeEchoo <65783283+CallmeEchoo@users.noreply.github.com> Date: Fri, 21 Apr 2023 10:51:43 +0200 Subject: [PATCH 08/51] fix battleUsage for heal powder --- src/data/items.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data/items.h b/src/data/items.h index 84436be55..2df5c3638 100644 --- a/src/data/items.h +++ b/src/data/items.h @@ -526,7 +526,7 @@ const struct Item gItems[] = .pocket = POCKET_ITEMS, .type = ITEM_USE_PARTY_MENU, .fieldUseFunc = ItemUseOutOfBattle_Medicine, - .battleUsage = EFFECT_ITEM_RESTORE_HP, + .battleUsage = EFFECT_ITEM_CURE_STATUS, .flingPower = 30, }, From 1cc28c89ef6b23bb37555e40d02839684dc80a91 Mon Sep 17 00:00:00 2001 From: CallmeEchoo Date: Fri, 21 Apr 2023 20:36:41 +0200 Subject: [PATCH 09/51] X item tests --- test/item_effect_increase_stat.c | 125 ++++++++++++++++++++++++++++++- 1 file changed, 124 insertions(+), 1 deletion(-) diff --git a/test/item_effect_increase_stat.c b/test/item_effect_increase_stat.c index b459e3ac8..7fcbe7279 100644 --- a/test/item_effect_increase_stat.c +++ b/test/item_effect_increase_stat.c @@ -1,7 +1,7 @@ #include "global.h" #include "test_battle.h" -SINGLE_BATTLE_TEST("X-Attack sharply raises battler's Attack stat", s16 damage) +SINGLE_BATTLE_TEST("X Attack sharply raises battler's Attack stat", s16 damage) { u16 useItem; PARAMETRIZE { useItem = FALSE; } @@ -23,3 +23,126 @@ SINGLE_BATTLE_TEST("X-Attack sharply raises battler's Attack stat", s16 damage) EXPECT_MUL_EQ(results[0].damage, Q_4_12(1.5), results[1].damage); } } + +SINGLE_BATTLE_TEST("X Defense sharply raises battler's Defense stat", s16 damage) +{ + u16 useItem; + PARAMETRIZE { useItem = FALSE; } + PARAMETRIZE { useItem = TRUE; } + GIVEN { + ASSUME(gItems[ITEM_X_DEFENSE].battleUsage == EFFECT_ITEM_INCREASE_STAT); + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + if (useItem) TURN { USE_ITEM(player, ITEM_X_DEFENSE); } + TURN { MOVE(opponent, MOVE_TACKLE); } + } SCENE { + MESSAGE("Foe Wobbuffet used Tackle!"); + HP_BAR(player, captureDamage: &results[i].damage); + } FINALLY { + if (B_X_ITEMS_BUFF >= GEN_7) + EXPECT_MUL_EQ(results[0].damage, Q_4_12(0.5), results[1].damage); + else + EXPECT_MUL_EQ(results[0].damage, Q_4_12(0.66), results[1].damage); + } +} + +SINGLE_BATTLE_TEST("X Sp. Atk sharply raises battler's Sp. Attack stat", s16 damage) +{ + u16 useItem; + PARAMETRIZE { useItem = FALSE; } + PARAMETRIZE { useItem = TRUE; } + GIVEN { + ASSUME(gItems[ITEM_X_SP_ATK].battleUsage == EFFECT_ITEM_INCREASE_STAT); + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + if (useItem) TURN { USE_ITEM(player, ITEM_X_SP_ATK); } + TURN { MOVE(player, MOVE_DISARMING_VOICE); } + } SCENE { + MESSAGE("Wobbuffet used DisrmngVoice!"); + HP_BAR(opponent, captureDamage: &results[i].damage); + } FINALLY { + if (B_X_ITEMS_BUFF >= GEN_7) + EXPECT_MUL_EQ(results[0].damage, Q_4_12(2.0), results[1].damage); + else + EXPECT_MUL_EQ(results[0].damage, Q_4_12(1.5), results[1].damage); + } +} + +SINGLE_BATTLE_TEST("X Sp. Def sharply raises battler's Sp. Defense stat", s16 damage) +{ + u16 useItem; + PARAMETRIZE { useItem = FALSE; } + PARAMETRIZE { useItem = TRUE; } + GIVEN { + ASSUME(gItems[ITEM_X_SP_DEF].battleUsage == EFFECT_ITEM_INCREASE_STAT); + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + if (useItem) TURN { USE_ITEM(player, ITEM_X_SP_DEF); } + TURN { MOVE(opponent, MOVE_DISARMING_VOICE); } + } SCENE { + MESSAGE("Foe Wobbuffet used DisrmngVoice!"); + HP_BAR(player, captureDamage: &results[i].damage); + } FINALLY { + if (B_X_ITEMS_BUFF >= GEN_7) + EXPECT_MUL_EQ(results[0].damage, Q_4_12(0.5), results[1].damage); + else + EXPECT_MUL_EQ(results[0].damage, Q_4_12(0.66), results[1].damage); + } +} + +SINGLE_BATTLE_TEST("X Speed sharply raises battler's Speed stat", s16 damage) +{ + u16 useItem; + PARAMETRIZE { useItem = FALSE; } + PARAMETRIZE { useItem = TRUE; } + GIVEN { + ASSUME(gItems[ITEM_X_SPEED].battleUsage == EFFECT_ITEM_INCREASE_STAT); + if (B_X_ITEMS_BUFF >= GEN_7) + { + PLAYER(SPECIES_WOBBUFFET) { Speed(3); }; + OPPONENT(SPECIES_WOBBUFFET) { Speed(4); }; + } + else + { + PLAYER(SPECIES_WOBBUFFET) { Speed(4); }; + OPPONENT(SPECIES_WOBBUFFET) { Speed(5); }; + } + } WHEN { + if (useItem) TURN { USE_ITEM(player, ITEM_X_SPEED); } + TURN { MOVE(player, MOVE_TACKLE); MOVE(opponent, MOVE_TACKLE); } + } SCENE { + if (useItem) + { + MESSAGE("Wobbuffet used Tackle!"); + MESSAGE("Foe Wobbuffet used Tackle!"); + } else + { + MESSAGE("Foe Wobbuffet used Tackle!"); + MESSAGE("Wobbuffet used Tackle!"); + } + } +} + +SINGLE_BATTLE_TEST("X Accuracy sharply raises battler's Accuracy stat", s16 damage) +{ + + ASSUME(gBattleMoves[MOVE_SING].accuracy == 55); + if (B_X_ITEMS_BUFF >= GEN_7) + PASSES_RANDOMLY(gBattleMoves[MOVE_SING].accuracy * 5 / 3, 100, RNG_ACCURACY); + else + PASSES_RANDOMLY(gBattleMoves[MOVE_SING].accuracy * 4 / 3, 100, RNG_ACCURACY); + GIVEN { + ASSUME(gItems[ITEM_X_ACCURACY].battleUsage == EFFECT_ITEM_INCREASE_STAT); + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { USE_ITEM(player, ITEM_X_ACCURACY); } + TURN { MOVE(player, MOVE_SING); } + } SCENE { + MESSAGE("Wobbuffet used Sing!"); + MESSAGE("Foe Wobbuffet fell asleep!"); + } +} From b4aee00432275f757d519640b497b9ee7d78e136 Mon Sep 17 00:00:00 2001 From: CallmeEchoo Date: Fri, 21 Apr 2023 20:57:19 +0200 Subject: [PATCH 10/51] replace pokemon with battler in string --- test/item_effect_cure_status.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/test/item_effect_cure_status.c b/test/item_effect_cure_status.c index 9a850a131..9747d18be 100644 --- a/test/item_effect_cure_status.c +++ b/test/item_effect_cure_status.c @@ -1,7 +1,7 @@ #include "global.h" #include "test_battle.h" -SINGLE_BATTLE_TEST("Paralyze Heal heals a Pokemon from being paralyzed") +SINGLE_BATTLE_TEST("Paralyze Heal heals a battler from being paralyzed") { GIVEN { ASSUME(gItems[ITEM_PARALYZE_HEAL].battleUsage == EFFECT_ITEM_CURE_STATUS); @@ -14,7 +14,7 @@ SINGLE_BATTLE_TEST("Paralyze Heal heals a Pokemon from being paralyzed") } } -SINGLE_BATTLE_TEST("Antidote heals a Pokemon from being poisoned") +SINGLE_BATTLE_TEST("Antidote heals a battler from being poisoned") { GIVEN { ASSUME(gItems[ITEM_ANTIDOTE].battleUsage == EFFECT_ITEM_CURE_STATUS); @@ -27,7 +27,7 @@ SINGLE_BATTLE_TEST("Antidote heals a Pokemon from being poisoned") } } -SINGLE_BATTLE_TEST("Antidote heals a Pokemon from being badly poisoned") +SINGLE_BATTLE_TEST("Antidote heals a battler from being badly poisoned") { GIVEN { ASSUME(gItems[ITEM_ANTIDOTE].battleUsage == EFFECT_ITEM_CURE_STATUS); @@ -40,7 +40,7 @@ SINGLE_BATTLE_TEST("Antidote heals a Pokemon from being badly poisoned") } } -SINGLE_BATTLE_TEST("Awakening heals a Pokemon from being asleep") +SINGLE_BATTLE_TEST("Awakening heals a battler from being asleep") { GIVEN { ASSUME(gItems[ITEM_AWAKENING].battleUsage == EFFECT_ITEM_CURE_STATUS); @@ -53,7 +53,7 @@ SINGLE_BATTLE_TEST("Awakening heals a Pokemon from being asleep") } } -SINGLE_BATTLE_TEST("Burn Heal heals a Pokemon from being burned") +SINGLE_BATTLE_TEST("Burn Heal heals a battler from being burned") { GIVEN { ASSUME(gItems[ITEM_BURN_HEAL].battleUsage == EFFECT_ITEM_CURE_STATUS); @@ -66,7 +66,7 @@ SINGLE_BATTLE_TEST("Burn Heal heals a Pokemon from being burned") } } -SINGLE_BATTLE_TEST("Ice Heal heals a Pokemon from being paralyzed") +SINGLE_BATTLE_TEST("Ice Heal heals a battler from being paralyzed") { GIVEN { ASSUME(gItems[ITEM_ICE_HEAL].battleUsage == EFFECT_ITEM_CURE_STATUS); @@ -79,7 +79,7 @@ SINGLE_BATTLE_TEST("Ice Heal heals a Pokemon from being paralyzed") } } -SINGLE_BATTLE_TEST("Full Heal heals a Pokemon from any primary status") +SINGLE_BATTLE_TEST("Full Heal heals a battler from any primary status") { u16 status; PARAMETRIZE{ status = STATUS1_BURN; } @@ -99,7 +99,7 @@ SINGLE_BATTLE_TEST("Full Heal heals a Pokemon from any primary status") } } -SINGLE_BATTLE_TEST("Pewter Crunchies heals a Pokemon from any primary status") +SINGLE_BATTLE_TEST("Pewter Crunchies heals a battler from any primary status") { u16 status; PARAMETRIZE{ status = STATUS1_BURN; } @@ -119,7 +119,7 @@ SINGLE_BATTLE_TEST("Pewter Crunchies heals a Pokemon from any primary status") } } -SINGLE_BATTLE_TEST("Lava Cookies heals a Pokemon from any primary status") +SINGLE_BATTLE_TEST("Lava Cookies heals a battler from any primary status") { u16 status; PARAMETRIZE{ status = STATUS1_BURN; } @@ -139,7 +139,7 @@ SINGLE_BATTLE_TEST("Lava Cookies heals a Pokemon from any primary status") } } -SINGLE_BATTLE_TEST("Rage Candy Bar heals a Pokemon from any primary status") +SINGLE_BATTLE_TEST("Rage Candy Bar heals a battler from any primary status") { u16 status; PARAMETRIZE{ status = STATUS1_BURN; } @@ -159,7 +159,7 @@ SINGLE_BATTLE_TEST("Rage Candy Bar heals a Pokemon from any primary status") } } -SINGLE_BATTLE_TEST("Old Gateu heals a Pokemon from any primary status") +SINGLE_BATTLE_TEST("Old Gateu heals a battler from any primary status") { u16 status; PARAMETRIZE{ status = STATUS1_BURN; } @@ -179,7 +179,7 @@ SINGLE_BATTLE_TEST("Old Gateu heals a Pokemon from any primary status") } } -SINGLE_BATTLE_TEST("Casteliacone heals a Pokemon from any primary status") +SINGLE_BATTLE_TEST("Casteliacone heals a battler from any primary status") { u16 status; PARAMETRIZE{ status = STATUS1_BURN; } @@ -199,7 +199,7 @@ SINGLE_BATTLE_TEST("Casteliacone heals a Pokemon from any primary status") } } -SINGLE_BATTLE_TEST("Lumiose Galette heals a Pokemon from any primary status") +SINGLE_BATTLE_TEST("Lumiose Galette heals a battler from any primary status") { u16 status; PARAMETRIZE{ status = STATUS1_BURN; } @@ -219,7 +219,7 @@ SINGLE_BATTLE_TEST("Lumiose Galette heals a Pokemon from any primary status") } } -SINGLE_BATTLE_TEST("Shalour Sable heals a Pokemon from any primary status") +SINGLE_BATTLE_TEST("Shalour Sable heals a battler from any primary status") { u16 status; PARAMETRIZE{ status = STATUS1_BURN; } @@ -239,7 +239,7 @@ SINGLE_BATTLE_TEST("Shalour Sable heals a Pokemon from any primary status") } } -SINGLE_BATTLE_TEST("Big Malasada heals a Pokemon from any primary status") +SINGLE_BATTLE_TEST("Big Malasada heals a battler from any primary status") { u16 status; PARAMETRIZE{ status = STATUS1_BURN; } @@ -259,7 +259,7 @@ SINGLE_BATTLE_TEST("Big Malasada heals a Pokemon from any primary status") } } -SINGLE_BATTLE_TEST("Full Heal and local specialties heal a Pokemon from being confused") +SINGLE_BATTLE_TEST("Full Heal and local specialties heal a battler from being confused") { u16 item; PARAMETRIZE { item = ITEM_FULL_HEAL; } From cbac6d0e87bc1c99a5cb70c0c78971306bc1eadd Mon Sep 17 00:00:00 2001 From: CallmeEchoo Date: Fri, 21 Apr 2023 20:57:30 +0200 Subject: [PATCH 11/51] Full Restore test --- test/item_effect_heal_and_cure_status.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 test/item_effect_heal_and_cure_status.c diff --git a/test/item_effect_heal_and_cure_status.c b/test/item_effect_heal_and_cure_status.c new file mode 100644 index 000000000..742f432f5 --- /dev/null +++ b/test/item_effect_heal_and_cure_status.c @@ -0,0 +1,25 @@ +#include "global.h" +#include "test_battle.h" + +SINGLE_BATTLE_TEST("Full Restore restores a battler's HP and cures any primary status") +{ + u16 status; + PARAMETRIZE{ status = STATUS1_BURN; } + PARAMETRIZE{ status = STATUS1_FREEZE; } + PARAMETRIZE{ status = STATUS1_PARALYSIS; } + PARAMETRIZE{ status = STATUS1_POISON; } + PARAMETRIZE{ status = STATUS1_TOXIC_POISON; } + PARAMETRIZE{ status = STATUS1_SLEEP; } + GIVEN { + ASSUME(gItems[ITEM_FULL_RESTORE].battleUsage == EFFECT_ITEM_HEAL_AND_CURE_STATUS); + PLAYER(SPECIES_WOBBUFFET) { HP(1); MaxHP(300); Status1(status); }; + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN{ USE_ITEM(player, ITEM_FULL_RESTORE, partyIndex: 0); } + } SCENE { + MESSAGE("Full Restore restored Wobbuffet's health!"); + } FINALLY { + EXPECT_EQ(player->hp, player->maxHP); + EXPECT_EQ(player->status1, STATUS1_NONE); + } +} \ No newline at end of file From 38476bd22c2ef28ab3f5401244178cc7d5e1056c Mon Sep 17 00:00:00 2001 From: CallmeEchoo Date: Fri, 21 Apr 2023 21:37:02 +0200 Subject: [PATCH 12/51] fix Full Restore not healing confusion --- data/battle_scripts_2.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/battle_scripts_2.s b/data/battle_scripts_2.s index dee482d1d..ea1a67a68 100644 --- a/data/battle_scripts_2.s +++ b/data/battle_scripts_2.s @@ -76,7 +76,7 @@ BattleScript_ItemCureStatus:: BattleScript_ItemHealAndCureStatus:: call BattleScript_UseItemMessage itemrestorehp - curestatus BS_ATTACKER + itemcurestatus printstring STRINGID_ITEMRESTOREDSPECIESHEALTH waitmessage B_WAIT_TIME_LONG bichalfword gMoveResultFlags, MOVE_RESULT_NO_EFFECT From 4bad450ecfe113e51c7ce1400ca577b906435ada Mon Sep 17 00:00:00 2001 From: CallmeEchoo Date: Fri, 21 Apr 2023 21:57:00 +0200 Subject: [PATCH 13/51] Full Restore confusion test PLS READ COMMENT THIS IS KNOWN_FAILING --- test/item_effect_heal_and_cure_status.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/test/item_effect_heal_and_cure_status.c b/test/item_effect_heal_and_cure_status.c index 742f432f5..d9bf0cf7c 100644 --- a/test/item_effect_heal_and_cure_status.c +++ b/test/item_effect_heal_and_cure_status.c @@ -22,4 +22,25 @@ SINGLE_BATTLE_TEST("Full Restore restores a battler's HP and cures any primary s EXPECT_EQ(player->hp, player->maxHP); EXPECT_EQ(player->status1, STATUS1_NONE); } -} \ No newline at end of file +} + +SINGLE_BATTLE_TEST("Full Restore restores a battler's HP and cures confusion") +{ + // known failing bc even though it passes there is an underlying bug still that is only obvious in the replay. see #2938 + // this also means that this test is likely not very good so I advice this to be redone + KNOWN_FAILING; + GIVEN { + ASSUME(gItems[ITEM_FULL_RESTORE].battleUsage == EFFECT_ITEM_HEAL_AND_CURE_STATUS); + PLAYER(SPECIES_WOBBUFFET) { HP(1); MaxHP(300);}; + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN{ MOVE(opponent, MOVE_CONFUSE_RAY); } + TURN{ USE_ITEM(player, ITEM_FULL_RESTORE, partyIndex: 0); } + TURN{ MOVE(player, MOVE_TACKLE); } + } SCENE { + MESSAGE("Full Restore restored Wobbuffet's health!"); + NONE_OF { MESSAGE("Wobbuffet is confused!"); } + } FINALLY { + EXPECT_EQ(player->hp, player->maxHP); + } +} From ff609f2761d69e1d2d0fa042a54fbe9dba95af0b Mon Sep 17 00:00:00 2001 From: CallmeEchoo <65783283+CallmeEchoo@users.noreply.github.com> Date: Fri, 21 Apr 2023 22:51:33 +0200 Subject: [PATCH 14/51] healing items tests --- test/item_effect_restore_hp.c | 182 ++++++++++++++++++++++++++++++++++ 1 file changed, 182 insertions(+) diff --git a/test/item_effect_restore_hp.c b/test/item_effect_restore_hp.c index 971ec2400..d5d652f65 100644 --- a/test/item_effect_restore_hp.c +++ b/test/item_effect_restore_hp.c @@ -17,6 +17,188 @@ SINGLE_BATTLE_TEST("Potion restores a battler's HP by 20") } } +SINGLE_BATTLE_TEST("Super Potion restores a battler's HP by 50") +{ + s16 damage; + GIVEN { + ASSUME(gItems[ITEM_SUPER_POTION].battleUsage == EFFECT_ITEM_RESTORE_HP); + PLAYER(SPECIES_WOBBUFFET) { HP(50); MaxHP(100); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { USE_ITEM(player, ITEM_SUPER_POTION, partyIndex: 0); } + } SCENE { + HP_BAR(player, captureDamage: &damage); + } FINALLY { + EXPECT_EQ(damage, -50); + } +} + +SINGLE_BATTLE_TEST("Hyper Potion restores a battler's HP by 200") +{ + s16 damage; + GIVEN { + ASSUME(gItems[ITEM_HYPER_POTION].battleUsage == EFFECT_ITEM_RESTORE_HP); + PLAYER(SPECIES_WOBBUFFET) { HP(100); MaxHP(400); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { USE_ITEM(player, ITEM_HYPER_POTION, partyIndex: 0); } + } SCENE { + HP_BAR(player, captureDamage: &damage); + } FINALLY { + EXPECT_EQ(damage, -200); + } +} + +SINGLE_BATTLE_TEST("Max Potion restores a battler's HP fully") +{ + s16 damage; + GIVEN { + ASSUME(gItems[ITEM_MAX_POTION].battleUsage == EFFECT_ITEM_RESTORE_HP); + PLAYER(SPECIES_WOBBUFFET) { HP(1); MaxHP(400); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { USE_ITEM(player, ITEM_MAX_POTION, partyIndex: 0); } + } FINALLY { + EXPECT_EQ(player->hp, player->maxHP); + } +} + +SINGLE_BATTLE_TEST("Fresh Water restores a battler's HP by 30") +{ + s16 damage; + GIVEN { + ASSUME(gItems[ITEM_FRESH_WATER].battleUsage == EFFECT_ITEM_RESTORE_HP); + PLAYER(SPECIES_WOBBUFFET) { HP(50); MaxHP(100); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { USE_ITEM(player, ITEM_FRESH_WATER, partyIndex: 0); } + } SCENE { + HP_BAR(player, captureDamage: &damage); + } FINALLY { + EXPECT_EQ(damage, -30); + } +} + +SINGLE_BATTLE_TEST("Soda Pop restores a battler's HP by 50") +{ + s16 damage; + GIVEN { + ASSUME(gItems[ITEM_SODA_POP].battleUsage == EFFECT_ITEM_RESTORE_HP); + PLAYER(SPECIES_WOBBUFFET) { HP(50); MaxHP(100); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { USE_ITEM(player, ITEM_SODA_POP, partyIndex: 0); } + } SCENE { + HP_BAR(player, captureDamage: &damage); + } FINALLY { + EXPECT_EQ(damage, -50); + } +} + +SINGLE_BATTLE_TEST("Lemonade restores a battler's HP by 70") +{ + s16 damage; + GIVEN { + ASSUME(gItems[ITEM_LEMONADE].battleUsage == EFFECT_ITEM_RESTORE_HP); + PLAYER(SPECIES_WOBBUFFET) { HP(50); MaxHP(200); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { USE_ITEM(player, ITEM_LEMONADE, partyIndex: 0); } + } SCENE { + HP_BAR(player, captureDamage: &damage); + } FINALLY { + EXPECT_EQ(damage, -70); + } +} + +SINGLE_BATTLE_TEST("Moomoo Milk restores a battler's HP by 100") +{ + s16 damage; + GIVEN { + ASSUME(gItems[ITEM_MOOMOO_MILK].battleUsage == EFFECT_ITEM_RESTORE_HP); + PLAYER(SPECIES_WOBBUFFET) { HP(50); MaxHP(200); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { USE_ITEM(player, ITEM_MOOMOO_MILK, partyIndex: 0); } + } SCENE { + HP_BAR(player, captureDamage: &damage); + } FINALLY { + EXPECT_EQ(damage, -100); + } +} + +SINGLE_BATTLE_TEST("Energy Powder restores a battler's HP by 50(60)") +{ + s16 damage; + GIVEN { + ASSUME(gItems[ITEM_ENERGY_POWDER].battleUsage == EFFECT_ITEM_RESTORE_HP); + PLAYER(SPECIES_WOBBUFFET) { HP(50); MaxHP(200); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { USE_ITEM(player, ITEM_ENERGY_POWDER, partyIndex: 0); } + } SCENE { + HP_BAR(player, captureDamage: &damage); + } FINALLY { + #if I_HEALTH_RECOVERY >= GEN_7 + EXPECT_EQ(damage, -60); + #else + EXPECT_EQ(damage, -50); + #endif + } +} + +SINGLE_BATTLE_TEST("Energy Root restores a battler's HP by 120(200)") +{ + s16 damage; + GIVEN { + ASSUME(gItems[ITEM_ENERGY_ROOT].battleUsage == EFFECT_ITEM_RESTORE_HP); + PLAYER(SPECIES_WOBBUFFET) { HP(50); MaxHP(300); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { USE_ITEM(player, ITEM_ENERGY_ROOT, partyIndex: 0); } + } SCENE { + HP_BAR(player, captureDamage: &damage); + } FINALLY { + #if I_HEALTH_RECOVERY >= GEN_7 + EXPECT_EQ(damage, -120); + #else + EXPECT_EQ(damage, -200); + #endif + } +} + +SINGLE_BATTLE_TEST("Sweet Heart restores a battler's HP by 20") +{ + s16 damage; + GIVEN { + ASSUME(gItems[ITEM_SWEET_HEART].battleUsage == EFFECT_ITEM_RESTORE_HP); + PLAYER(SPECIES_WOBBUFFET) { HP(50); MaxHP(100); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { USE_ITEM(player, ITEM_SWEET_HEART, partyIndex: 0); } + } SCENE { + HP_BAR(player, captureDamage: &damage); + } FINALLY { + EXPECT_EQ(damage, -20); + } +} + +SINGLE_BATTLE_TEST("Oran Berry restores a battler's HP by 10") +{ + s16 damage; + GIVEN { + ASSUME(gItems[ITEM_ORAN_BERRY].battleUsage == EFFECT_ITEM_RESTORE_HP); + PLAYER(SPECIES_WOBBUFFET) { HP(50); MaxHP(100); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { USE_ITEM(player, ITEM_ORAN_BERRY, partyIndex: 0); } + } SCENE { + HP_BAR(player, captureDamage: &damage); + } FINALLY { + EXPECT_EQ(damage, -10); + } +} + SINGLE_BATTLE_TEST("Sitrus Berry restores a battler's HP") { s16 damage; From 929e4749dabafb2e90a97a2b9fa8bd93c33dd2f7 Mon Sep 17 00:00:00 2001 From: CallmeEchoo Date: Sat, 22 Apr 2023 02:34:50 +0200 Subject: [PATCH 15/51] temporarily rename test string for easier test runs --- test/item_effect_cure_status.c | 32 ++++++++++++++++---------------- test/item_effect_restore_hp.c | 26 +++++++++++++------------- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/test/item_effect_cure_status.c b/test/item_effect_cure_status.c index 9747d18be..f014a29b7 100644 --- a/test/item_effect_cure_status.c +++ b/test/item_effect_cure_status.c @@ -1,7 +1,7 @@ #include "global.h" #include "test_battle.h" -SINGLE_BATTLE_TEST("Paralyze Heal heals a battler from being paralyzed") +SINGLE_BATTLE_TEST("Cure Status: Paralyze Heal heals a battler from being paralyzed") { GIVEN { ASSUME(gItems[ITEM_PARALYZE_HEAL].battleUsage == EFFECT_ITEM_CURE_STATUS); @@ -14,7 +14,7 @@ SINGLE_BATTLE_TEST("Paralyze Heal heals a battler from being paralyzed") } } -SINGLE_BATTLE_TEST("Antidote heals a battler from being poisoned") +SINGLE_BATTLE_TEST("Cure Status: Antidote heals a battler from being poisoned") { GIVEN { ASSUME(gItems[ITEM_ANTIDOTE].battleUsage == EFFECT_ITEM_CURE_STATUS); @@ -27,7 +27,7 @@ SINGLE_BATTLE_TEST("Antidote heals a battler from being poisoned") } } -SINGLE_BATTLE_TEST("Antidote heals a battler from being badly poisoned") +SINGLE_BATTLE_TEST("Cure Status: Antidote heals a battler from being badly poisoned") { GIVEN { ASSUME(gItems[ITEM_ANTIDOTE].battleUsage == EFFECT_ITEM_CURE_STATUS); @@ -40,7 +40,7 @@ SINGLE_BATTLE_TEST("Antidote heals a battler from being badly poisoned") } } -SINGLE_BATTLE_TEST("Awakening heals a battler from being asleep") +SINGLE_BATTLE_TEST("Cure Status: Awakening heals a battler from being asleep") { GIVEN { ASSUME(gItems[ITEM_AWAKENING].battleUsage == EFFECT_ITEM_CURE_STATUS); @@ -53,7 +53,7 @@ SINGLE_BATTLE_TEST("Awakening heals a battler from being asleep") } } -SINGLE_BATTLE_TEST("Burn Heal heals a battler from being burned") +SINGLE_BATTLE_TEST("Cure Status: Burn Heal heals a battler from being burned") { GIVEN { ASSUME(gItems[ITEM_BURN_HEAL].battleUsage == EFFECT_ITEM_CURE_STATUS); @@ -66,7 +66,7 @@ SINGLE_BATTLE_TEST("Burn Heal heals a battler from being burned") } } -SINGLE_BATTLE_TEST("Ice Heal heals a battler from being paralyzed") +SINGLE_BATTLE_TEST("Cure Status: Ice Heal heals a battler from being paralyzed") { GIVEN { ASSUME(gItems[ITEM_ICE_HEAL].battleUsage == EFFECT_ITEM_CURE_STATUS); @@ -79,7 +79,7 @@ SINGLE_BATTLE_TEST("Ice Heal heals a battler from being paralyzed") } } -SINGLE_BATTLE_TEST("Full Heal heals a battler from any primary status") +SINGLE_BATTLE_TEST("Cure Status: Full Heal heals a battler from any primary status") { u16 status; PARAMETRIZE{ status = STATUS1_BURN; } @@ -99,7 +99,7 @@ SINGLE_BATTLE_TEST("Full Heal heals a battler from any primary status") } } -SINGLE_BATTLE_TEST("Pewter Crunchies heals a battler from any primary status") +SINGLE_BATTLE_TEST("Cure Status: Pewter Crunchies heals a battler from any primary status") { u16 status; PARAMETRIZE{ status = STATUS1_BURN; } @@ -119,7 +119,7 @@ SINGLE_BATTLE_TEST("Pewter Crunchies heals a battler from any primary status") } } -SINGLE_BATTLE_TEST("Lava Cookies heals a battler from any primary status") +SINGLE_BATTLE_TEST("Cure Status: Lava Cookies heals a battler from any primary status") { u16 status; PARAMETRIZE{ status = STATUS1_BURN; } @@ -139,7 +139,7 @@ SINGLE_BATTLE_TEST("Lava Cookies heals a battler from any primary status") } } -SINGLE_BATTLE_TEST("Rage Candy Bar heals a battler from any primary status") +SINGLE_BATTLE_TEST("Cure Status: Rage Candy Bar heals a battler from any primary status") { u16 status; PARAMETRIZE{ status = STATUS1_BURN; } @@ -159,7 +159,7 @@ SINGLE_BATTLE_TEST("Rage Candy Bar heals a battler from any primary status") } } -SINGLE_BATTLE_TEST("Old Gateu heals a battler from any primary status") +SINGLE_BATTLE_TEST("Cure Status: Old Gateu heals a battler from any primary status") { u16 status; PARAMETRIZE{ status = STATUS1_BURN; } @@ -179,7 +179,7 @@ SINGLE_BATTLE_TEST("Old Gateu heals a battler from any primary status") } } -SINGLE_BATTLE_TEST("Casteliacone heals a battler from any primary status") +SINGLE_BATTLE_TEST("Cure Status: Casteliacone heals a battler from any primary status") { u16 status; PARAMETRIZE{ status = STATUS1_BURN; } @@ -199,7 +199,7 @@ SINGLE_BATTLE_TEST("Casteliacone heals a battler from any primary status") } } -SINGLE_BATTLE_TEST("Lumiose Galette heals a battler from any primary status") +SINGLE_BATTLE_TEST("Cure Status: Lumiose Galette heals a battler from any primary status") { u16 status; PARAMETRIZE{ status = STATUS1_BURN; } @@ -219,7 +219,7 @@ SINGLE_BATTLE_TEST("Lumiose Galette heals a battler from any primary status") } } -SINGLE_BATTLE_TEST("Shalour Sable heals a battler from any primary status") +SINGLE_BATTLE_TEST("Cure Status: Shalour Sable heals a battler from any primary status") { u16 status; PARAMETRIZE{ status = STATUS1_BURN; } @@ -239,7 +239,7 @@ SINGLE_BATTLE_TEST("Shalour Sable heals a battler from any primary status") } } -SINGLE_BATTLE_TEST("Big Malasada heals a battler from any primary status") +SINGLE_BATTLE_TEST("Cure Status: Big Malasada heals a battler from any primary status") { u16 status; PARAMETRIZE{ status = STATUS1_BURN; } @@ -259,7 +259,7 @@ SINGLE_BATTLE_TEST("Big Malasada heals a battler from any primary status") } } -SINGLE_BATTLE_TEST("Full Heal and local specialties heal a battler from being confused") +SINGLE_BATTLE_TEST("Cure Status: Full Heal and local specialties heal a battler from being confused") { u16 item; PARAMETRIZE { item = ITEM_FULL_HEAL; } diff --git a/test/item_effect_restore_hp.c b/test/item_effect_restore_hp.c index d5d652f65..8898c772b 100644 --- a/test/item_effect_restore_hp.c +++ b/test/item_effect_restore_hp.c @@ -1,7 +1,7 @@ #include "global.h" #include "test_battle.h" -SINGLE_BATTLE_TEST("Potion restores a battler's HP by 20") +SINGLE_BATTLE_TEST("Restore HP: Potion restores a battler's HP by 20") { s16 damage; GIVEN { @@ -17,7 +17,7 @@ SINGLE_BATTLE_TEST("Potion restores a battler's HP by 20") } } -SINGLE_BATTLE_TEST("Super Potion restores a battler's HP by 50") +SINGLE_BATTLE_TEST("Restore HP: Super Potion restores a battler's HP by 50") { s16 damage; GIVEN { @@ -33,7 +33,7 @@ SINGLE_BATTLE_TEST("Super Potion restores a battler's HP by 50") } } -SINGLE_BATTLE_TEST("Hyper Potion restores a battler's HP by 200") +SINGLE_BATTLE_TEST("Restore HP: Hyper Potion restores a battler's HP by 200") { s16 damage; GIVEN { @@ -49,7 +49,7 @@ SINGLE_BATTLE_TEST("Hyper Potion restores a battler's HP by 200") } } -SINGLE_BATTLE_TEST("Max Potion restores a battler's HP fully") +SINGLE_BATTLE_TEST("Restore HP: Max Potion restores a battler's HP fully") { s16 damage; GIVEN { @@ -63,7 +63,7 @@ SINGLE_BATTLE_TEST("Max Potion restores a battler's HP fully") } } -SINGLE_BATTLE_TEST("Fresh Water restores a battler's HP by 30") +SINGLE_BATTLE_TEST("Restore HP: Fresh Water restores a battler's HP by 30") { s16 damage; GIVEN { @@ -79,7 +79,7 @@ SINGLE_BATTLE_TEST("Fresh Water restores a battler's HP by 30") } } -SINGLE_BATTLE_TEST("Soda Pop restores a battler's HP by 50") +SINGLE_BATTLE_TEST("Restore HP: Soda Pop restores a battler's HP by 50") { s16 damage; GIVEN { @@ -95,7 +95,7 @@ SINGLE_BATTLE_TEST("Soda Pop restores a battler's HP by 50") } } -SINGLE_BATTLE_TEST("Lemonade restores a battler's HP by 70") +SINGLE_BATTLE_TEST("Restore HP: Lemonade restores a battler's HP by 70") { s16 damage; GIVEN { @@ -111,7 +111,7 @@ SINGLE_BATTLE_TEST("Lemonade restores a battler's HP by 70") } } -SINGLE_BATTLE_TEST("Moomoo Milk restores a battler's HP by 100") +SINGLE_BATTLE_TEST("Restore HP: Moomoo Milk restores a battler's HP by 100") { s16 damage; GIVEN { @@ -127,7 +127,7 @@ SINGLE_BATTLE_TEST("Moomoo Milk restores a battler's HP by 100") } } -SINGLE_BATTLE_TEST("Energy Powder restores a battler's HP by 50(60)") +SINGLE_BATTLE_TEST("Restore HP: Energy Powder restores a battler's HP by 60(50)") { s16 damage; GIVEN { @@ -147,7 +147,7 @@ SINGLE_BATTLE_TEST("Energy Powder restores a battler's HP by 50(60)") } } -SINGLE_BATTLE_TEST("Energy Root restores a battler's HP by 120(200)") +SINGLE_BATTLE_TEST("Restore HP: Energy Root restores a battler's HP by 120(200)") { s16 damage; GIVEN { @@ -167,7 +167,7 @@ SINGLE_BATTLE_TEST("Energy Root restores a battler's HP by 120(200)") } } -SINGLE_BATTLE_TEST("Sweet Heart restores a battler's HP by 20") +SINGLE_BATTLE_TEST("Restore HP: Sweet Heart restores a battler's HP by 20") { s16 damage; GIVEN { @@ -183,7 +183,7 @@ SINGLE_BATTLE_TEST("Sweet Heart restores a battler's HP by 20") } } -SINGLE_BATTLE_TEST("Oran Berry restores a battler's HP by 10") +SINGLE_BATTLE_TEST("Restore HP: Oran Berry restores a battler's HP by 10") { s16 damage; GIVEN { @@ -199,7 +199,7 @@ SINGLE_BATTLE_TEST("Oran Berry restores a battler's HP by 10") } } -SINGLE_BATTLE_TEST("Sitrus Berry restores a battler's HP") +SINGLE_BATTLE_TEST("Restore HP: Sitrus Berry restores a battler's HP") { s16 damage; GIVEN { From 42215c94e7953375a3a4c0acde8ebac57d67963f Mon Sep 17 00:00:00 2001 From: CallmeEchoo Date: Sat, 22 Apr 2023 02:39:46 +0200 Subject: [PATCH 16/51] actually working restore hp tests --- test/item_effect_restore_hp.c | 106 ++++++++++++++-------------------- 1 file changed, 43 insertions(+), 63 deletions(-) diff --git a/test/item_effect_restore_hp.c b/test/item_effect_restore_hp.c index 8898c772b..67c5eb202 100644 --- a/test/item_effect_restore_hp.c +++ b/test/item_effect_restore_hp.c @@ -1,51 +1,48 @@ #include "global.h" #include "test_battle.h" +#define TEST_HP 1 +#define MAX_HP 400 + SINGLE_BATTLE_TEST("Restore HP: Potion restores a battler's HP by 20") { s16 damage; GIVEN { ASSUME(gItems[ITEM_POTION].battleUsage == EFFECT_ITEM_RESTORE_HP); - PLAYER(SPECIES_WOBBUFFET) { HP(50); MaxHP(100); } + PLAYER(SPECIES_WOBBUFFET) { HP(TEST_HP); MaxHP(MAX_HP); } OPPONENT(SPECIES_WOBBUFFET); } WHEN { TURN { USE_ITEM(player, ITEM_POTION, partyIndex: 0); } } SCENE { - HP_BAR(player, captureDamage: &damage); - } FINALLY { - EXPECT_EQ(damage, -20); + HP_BAR(player, hp: TEST_HP + 20); } } -SINGLE_BATTLE_TEST("Restore HP: Super Potion restores a battler's HP by 50") +SINGLE_BATTLE_TEST("Restore HP: Super Potion restores a battler's HP by 60") { s16 damage; GIVEN { ASSUME(gItems[ITEM_SUPER_POTION].battleUsage == EFFECT_ITEM_RESTORE_HP); - PLAYER(SPECIES_WOBBUFFET) { HP(50); MaxHP(100); } + PLAYER(SPECIES_WOBBUFFET) { HP(TEST_HP); MaxHP(MAX_HP); } OPPONENT(SPECIES_WOBBUFFET); } WHEN { TURN { USE_ITEM(player, ITEM_SUPER_POTION, partyIndex: 0); } } SCENE { - HP_BAR(player, captureDamage: &damage); - } FINALLY { - EXPECT_EQ(damage, -50); + HP_BAR(player, hp: TEST_HP + 60); } } -SINGLE_BATTLE_TEST("Restore HP: Hyper Potion restores a battler's HP by 200") +SINGLE_BATTLE_TEST("Restore HP: Hyper Potion restores a battler's HP by 120") { s16 damage; GIVEN { ASSUME(gItems[ITEM_HYPER_POTION].battleUsage == EFFECT_ITEM_RESTORE_HP); - PLAYER(SPECIES_WOBBUFFET) { HP(100); MaxHP(400); } + PLAYER(SPECIES_WOBBUFFET) { HP(TEST_HP); MaxHP(MAX_HP); } OPPONENT(SPECIES_WOBBUFFET); } WHEN { TURN { USE_ITEM(player, ITEM_HYPER_POTION, partyIndex: 0); } } SCENE { - HP_BAR(player, captureDamage: &damage); - } FINALLY { - EXPECT_EQ(damage, -200); + HP_BAR(player, hp: TEST_HP + 120); } } @@ -54,12 +51,12 @@ SINGLE_BATTLE_TEST("Restore HP: Max Potion restores a battler's HP fully") s16 damage; GIVEN { ASSUME(gItems[ITEM_MAX_POTION].battleUsage == EFFECT_ITEM_RESTORE_HP); - PLAYER(SPECIES_WOBBUFFET) { HP(1); MaxHP(400); } + PLAYER(SPECIES_WOBBUFFET) { HP(TEST_HP); MaxHP(MAX_HP); } OPPONENT(SPECIES_WOBBUFFET); } WHEN { TURN { USE_ITEM(player, ITEM_MAX_POTION, partyIndex: 0); } - } FINALLY { - EXPECT_EQ(player->hp, player->maxHP); + } SCENE { + HP_BAR(player, hp: MAX_HP); } } @@ -68,14 +65,12 @@ SINGLE_BATTLE_TEST("Restore HP: Fresh Water restores a battler's HP by 30") s16 damage; GIVEN { ASSUME(gItems[ITEM_FRESH_WATER].battleUsage == EFFECT_ITEM_RESTORE_HP); - PLAYER(SPECIES_WOBBUFFET) { HP(50); MaxHP(100); } + PLAYER(SPECIES_WOBBUFFET) { HP(TEST_HP); MaxHP(MAX_HP); } OPPONENT(SPECIES_WOBBUFFET); } WHEN { TURN { USE_ITEM(player, ITEM_FRESH_WATER, partyIndex: 0); } } SCENE { - HP_BAR(player, captureDamage: &damage); - } FINALLY { - EXPECT_EQ(damage, -30); + HP_BAR(player, hp: TEST_HP + 30); } } @@ -84,14 +79,12 @@ SINGLE_BATTLE_TEST("Restore HP: Soda Pop restores a battler's HP by 50") s16 damage; GIVEN { ASSUME(gItems[ITEM_SODA_POP].battleUsage == EFFECT_ITEM_RESTORE_HP); - PLAYER(SPECIES_WOBBUFFET) { HP(50); MaxHP(100); } + PLAYER(SPECIES_WOBBUFFET) { HP(TEST_HP); MaxHP(MAX_HP); } OPPONENT(SPECIES_WOBBUFFET); } WHEN { TURN { USE_ITEM(player, ITEM_SODA_POP, partyIndex: 0); } } SCENE { - HP_BAR(player, captureDamage: &damage); - } FINALLY { - EXPECT_EQ(damage, -50); + HP_BAR(player, hp: TEST_HP + 50); } } @@ -100,14 +93,12 @@ SINGLE_BATTLE_TEST("Restore HP: Lemonade restores a battler's HP by 70") s16 damage; GIVEN { ASSUME(gItems[ITEM_LEMONADE].battleUsage == EFFECT_ITEM_RESTORE_HP); - PLAYER(SPECIES_WOBBUFFET) { HP(50); MaxHP(200); } + PLAYER(SPECIES_WOBBUFFET) { HP(TEST_HP); MaxHP(MAX_HP); } OPPONENT(SPECIES_WOBBUFFET); } WHEN { TURN { USE_ITEM(player, ITEM_LEMONADE, partyIndex: 0); } } SCENE { - HP_BAR(player, captureDamage: &damage); - } FINALLY { - EXPECT_EQ(damage, -70); + HP_BAR(player, hp: TEST_HP + 70); } } @@ -116,14 +107,12 @@ SINGLE_BATTLE_TEST("Restore HP: Moomoo Milk restores a battler's HP by 100") s16 damage; GIVEN { ASSUME(gItems[ITEM_MOOMOO_MILK].battleUsage == EFFECT_ITEM_RESTORE_HP); - PLAYER(SPECIES_WOBBUFFET) { HP(50); MaxHP(200); } + PLAYER(SPECIES_WOBBUFFET) { HP(TEST_HP); MaxHP(MAX_HP); } OPPONENT(SPECIES_WOBBUFFET); } WHEN { TURN { USE_ITEM(player, ITEM_MOOMOO_MILK, partyIndex: 0); } } SCENE { - HP_BAR(player, captureDamage: &damage); - } FINALLY { - EXPECT_EQ(damage, -100); + HP_BAR(player, hp: TEST_HP + 100); } } @@ -132,18 +121,15 @@ SINGLE_BATTLE_TEST("Restore HP: Energy Powder restores a battler's HP by 60(50)" s16 damage; GIVEN { ASSUME(gItems[ITEM_ENERGY_POWDER].battleUsage == EFFECT_ITEM_RESTORE_HP); - PLAYER(SPECIES_WOBBUFFET) { HP(50); MaxHP(200); } + PLAYER(SPECIES_WOBBUFFET) { HP(TEST_HP); MaxHP(MAX_HP); } OPPONENT(SPECIES_WOBBUFFET); } WHEN { TURN { USE_ITEM(player, ITEM_ENERGY_POWDER, partyIndex: 0); } } SCENE { - HP_BAR(player, captureDamage: &damage); - } FINALLY { - #if I_HEALTH_RECOVERY >= GEN_7 - EXPECT_EQ(damage, -60); - #else - EXPECT_EQ(damage, -50); - #endif + if (I_HEALTH_RECOVERY >= GEN_7) + HP_BAR(player, hp: TEST_HP + 60); + else + HP_BAR(player, hp: TEST_HP + 50); } } @@ -152,18 +138,15 @@ SINGLE_BATTLE_TEST("Restore HP: Energy Root restores a battler's HP by 120(200)" s16 damage; GIVEN { ASSUME(gItems[ITEM_ENERGY_ROOT].battleUsage == EFFECT_ITEM_RESTORE_HP); - PLAYER(SPECIES_WOBBUFFET) { HP(50); MaxHP(300); } + PLAYER(SPECIES_WOBBUFFET) { HP(TEST_HP); MaxHP(MAX_HP); } OPPONENT(SPECIES_WOBBUFFET); } WHEN { TURN { USE_ITEM(player, ITEM_ENERGY_ROOT, partyIndex: 0); } } SCENE { - HP_BAR(player, captureDamage: &damage); - } FINALLY { - #if I_HEALTH_RECOVERY >= GEN_7 - EXPECT_EQ(damage, -120); - #else - EXPECT_EQ(damage, -200); - #endif + if (I_HEALTH_RECOVERY >= GEN_7) + HP_BAR(player, hp: TEST_HP + 120); + else + HP_BAR(player, hp: TEST_HP + 200); } } @@ -172,14 +155,12 @@ SINGLE_BATTLE_TEST("Restore HP: Sweet Heart restores a battler's HP by 20") s16 damage; GIVEN { ASSUME(gItems[ITEM_SWEET_HEART].battleUsage == EFFECT_ITEM_RESTORE_HP); - PLAYER(SPECIES_WOBBUFFET) { HP(50); MaxHP(100); } + PLAYER(SPECIES_WOBBUFFET) { HP(TEST_HP); MaxHP(MAX_HP); } OPPONENT(SPECIES_WOBBUFFET); } WHEN { TURN { USE_ITEM(player, ITEM_SWEET_HEART, partyIndex: 0); } } SCENE { - HP_BAR(player, captureDamage: &damage); - } FINALLY { - EXPECT_EQ(damage, -20); + HP_BAR(player, hp: TEST_HP + 20); } } @@ -188,32 +169,31 @@ SINGLE_BATTLE_TEST("Restore HP: Oran Berry restores a battler's HP by 10") s16 damage; GIVEN { ASSUME(gItems[ITEM_ORAN_BERRY].battleUsage == EFFECT_ITEM_RESTORE_HP); - PLAYER(SPECIES_WOBBUFFET) { HP(50); MaxHP(100); } + PLAYER(SPECIES_WOBBUFFET) { HP(TEST_HP); MaxHP(MAX_HP); } OPPONENT(SPECIES_WOBBUFFET); } WHEN { TURN { USE_ITEM(player, ITEM_ORAN_BERRY, partyIndex: 0); } } SCENE { - HP_BAR(player, captureDamage: &damage); - } FINALLY { - EXPECT_EQ(damage, -10); + HP_BAR(player, hp: TEST_HP + 10); } } -SINGLE_BATTLE_TEST("Restore HP: Sitrus Berry restores a battler's HP") +SINGLE_BATTLE_TEST("Restore HP: Sitrus Berry restores a battler's HP by 25% of its max HP(30HP flat)") { s16 damage; GIVEN { ASSUME(gItems[ITEM_SITRUS_BERRY].battleUsage == EFFECT_ITEM_RESTORE_HP); - PLAYER(SPECIES_WOBBUFFET) { HP(50); MaxHP(100); } + PLAYER(SPECIES_WOBBUFFET) { HP(TEST_HP); MaxHP(MAX_HP); } OPPONENT(SPECIES_WOBBUFFET); } WHEN { TURN { USE_ITEM(player, ITEM_SITRUS_BERRY, partyIndex: 0); } } SCENE { - HP_BAR(player, captureDamage: &damage); - } FINALLY { if (I_SITRUS_BERRY_HEAL >= GEN_4) - EXPECT_EQ(damage, -25); + HP_BAR(player, hp: TEST_HP + MAX_HP * 0.25); else - EXPECT_EQ(damage, -30); + HP_BAR(player, hp: TEST_HP + 30); } } + +#undef TEST_HP +#undef MAX_HP \ No newline at end of file From 727f1ac37cb4de69e8d4bbf390a5628e7c719501 Mon Sep 17 00:00:00 2001 From: CallmeEchoo Date: Sat, 22 Apr 2023 15:04:40 +0200 Subject: [PATCH 17/51] guard spec test --- test/item_effect_set_mist.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 test/item_effect_set_mist.c diff --git a/test/item_effect_set_mist.c b/test/item_effect_set_mist.c new file mode 100644 index 000000000..e01775ec4 --- /dev/null +++ b/test/item_effect_set_mist.c @@ -0,0 +1,19 @@ +#include "global.h" +#include "test_battle.h" + +SINGLE_BATTLE_TEST("Guard Spec. sets Mist effect on the battlers side") +{ + GIVEN { + ASSUME(gItems[ITEM_GUARD_SPEC].battleUsage == EFFECT_ITEM_SET_MIST); + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { USE_ITEM(player, ITEM_GUARD_SPEC, partyIndex: 0); } + TURN { MOVE(opponent, MOVE_GROWL); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_MIST, player); + MESSAGE("Ally became shrouded in MIST!"); + MESSAGE("Foe Wobbuffet used Growl!"); + MESSAGE("Wobbuffet is protected by MIST!"); + } +} From 18ac81174d626bf858882dad8861283cd751290c Mon Sep 17 00:00:00 2001 From: CallmeEchoo Date: Sat, 22 Apr 2023 17:41:19 +0200 Subject: [PATCH 18/51] Dire Hit test currently known failing, bc of weird bug. see comment. --- test/item_effect_set_focus_energy.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 test/item_effect_set_focus_energy.c diff --git a/test/item_effect_set_focus_energy.c b/test/item_effect_set_focus_energy.c new file mode 100644 index 000000000..ff7d82f49 --- /dev/null +++ b/test/item_effect_set_focus_energy.c @@ -0,0 +1,22 @@ +#include "global.h" +#include "test_battle.h" + +SINGLE_BATTLE_TEST("Dire Hit increases a battler's critical hit chance by 2 stages") +{ + KNOWN_FAILING; // Displays Message "Foe Wobbuffet used Dire Hit.." when facing off against Wobbuffet. Doesnt happen against other species? + ASSUME(B_CRIT_CHANCE >= GEN_7); + PASSES_RANDOMLY(1, 2, RNG_CRITICAL_HIT); + GIVEN { + ASSUME(gItems[ITEM_DIRE_HIT].battleUsage == EFFECT_ITEM_SET_FOCUS_ENERGY); + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_ABOMASNOW); + } WHEN { + TURN { USE_ITEM(player, ITEM_DIRE_HIT, partyIndex: 0); } + TURN { MOVE(player, MOVE_SCRATCH); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_FOCUS_ENERGY, player); + MESSAGE("Wobbuffet used Dire Hit to get pumped!"); + MESSAGE("Wobbuffet used Scratch!"); + MESSAGE("A critical hit!"); + } +} From 1b6bb3e9ebd9380e1f5c3026a986caa6e8b6d963 Mon Sep 17 00:00:00 2001 From: CallmeEchoo Date: Sat, 22 Apr 2023 17:53:37 +0200 Subject: [PATCH 19/51] make the test fail intentionally --- test/item_effect_set_focus_energy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/item_effect_set_focus_energy.c b/test/item_effect_set_focus_energy.c index ff7d82f49..72e90d610 100644 --- a/test/item_effect_set_focus_energy.c +++ b/test/item_effect_set_focus_energy.c @@ -9,7 +9,7 @@ SINGLE_BATTLE_TEST("Dire Hit increases a battler's critical hit chance by 2 stag GIVEN { ASSUME(gItems[ITEM_DIRE_HIT].battleUsage == EFFECT_ITEM_SET_FOCUS_ENERGY); PLAYER(SPECIES_WOBBUFFET); - OPPONENT(SPECIES_ABOMASNOW); + OPPONENT(SPECIES_WOBBUFFET); } WHEN { TURN { USE_ITEM(player, ITEM_DIRE_HIT, partyIndex: 0); } TURN { MOVE(player, MOVE_SCRATCH); } From 0b66cf01ecb71fe83c98a2b70edc4eeb443a5864 Mon Sep 17 00:00:00 2001 From: CallmeEchoo Date: Mon, 24 Apr 2023 14:15:43 +0200 Subject: [PATCH 20/51] remove no longer needed variable --- test/item_effect_restore_hp.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/test/item_effect_restore_hp.c b/test/item_effect_restore_hp.c index 67c5eb202..4572a0d8b 100644 --- a/test/item_effect_restore_hp.c +++ b/test/item_effect_restore_hp.c @@ -6,7 +6,6 @@ SINGLE_BATTLE_TEST("Restore HP: Potion restores a battler's HP by 20") { - s16 damage; GIVEN { ASSUME(gItems[ITEM_POTION].battleUsage == EFFECT_ITEM_RESTORE_HP); PLAYER(SPECIES_WOBBUFFET) { HP(TEST_HP); MaxHP(MAX_HP); } @@ -20,7 +19,6 @@ SINGLE_BATTLE_TEST("Restore HP: Potion restores a battler's HP by 20") SINGLE_BATTLE_TEST("Restore HP: Super Potion restores a battler's HP by 60") { - s16 damage; GIVEN { ASSUME(gItems[ITEM_SUPER_POTION].battleUsage == EFFECT_ITEM_RESTORE_HP); PLAYER(SPECIES_WOBBUFFET) { HP(TEST_HP); MaxHP(MAX_HP); } @@ -34,7 +32,6 @@ SINGLE_BATTLE_TEST("Restore HP: Super Potion restores a battler's HP by 60") SINGLE_BATTLE_TEST("Restore HP: Hyper Potion restores a battler's HP by 120") { - s16 damage; GIVEN { ASSUME(gItems[ITEM_HYPER_POTION].battleUsage == EFFECT_ITEM_RESTORE_HP); PLAYER(SPECIES_WOBBUFFET) { HP(TEST_HP); MaxHP(MAX_HP); } @@ -48,7 +45,6 @@ SINGLE_BATTLE_TEST("Restore HP: Hyper Potion restores a battler's HP by 120") SINGLE_BATTLE_TEST("Restore HP: Max Potion restores a battler's HP fully") { - s16 damage; GIVEN { ASSUME(gItems[ITEM_MAX_POTION].battleUsage == EFFECT_ITEM_RESTORE_HP); PLAYER(SPECIES_WOBBUFFET) { HP(TEST_HP); MaxHP(MAX_HP); } @@ -62,7 +58,6 @@ SINGLE_BATTLE_TEST("Restore HP: Max Potion restores a battler's HP fully") SINGLE_BATTLE_TEST("Restore HP: Fresh Water restores a battler's HP by 30") { - s16 damage; GIVEN { ASSUME(gItems[ITEM_FRESH_WATER].battleUsage == EFFECT_ITEM_RESTORE_HP); PLAYER(SPECIES_WOBBUFFET) { HP(TEST_HP); MaxHP(MAX_HP); } @@ -76,7 +71,6 @@ SINGLE_BATTLE_TEST("Restore HP: Fresh Water restores a battler's HP by 30") SINGLE_BATTLE_TEST("Restore HP: Soda Pop restores a battler's HP by 50") { - s16 damage; GIVEN { ASSUME(gItems[ITEM_SODA_POP].battleUsage == EFFECT_ITEM_RESTORE_HP); PLAYER(SPECIES_WOBBUFFET) { HP(TEST_HP); MaxHP(MAX_HP); } @@ -90,7 +84,6 @@ SINGLE_BATTLE_TEST("Restore HP: Soda Pop restores a battler's HP by 50") SINGLE_BATTLE_TEST("Restore HP: Lemonade restores a battler's HP by 70") { - s16 damage; GIVEN { ASSUME(gItems[ITEM_LEMONADE].battleUsage == EFFECT_ITEM_RESTORE_HP); PLAYER(SPECIES_WOBBUFFET) { HP(TEST_HP); MaxHP(MAX_HP); } @@ -104,7 +97,6 @@ SINGLE_BATTLE_TEST("Restore HP: Lemonade restores a battler's HP by 70") SINGLE_BATTLE_TEST("Restore HP: Moomoo Milk restores a battler's HP by 100") { - s16 damage; GIVEN { ASSUME(gItems[ITEM_MOOMOO_MILK].battleUsage == EFFECT_ITEM_RESTORE_HP); PLAYER(SPECIES_WOBBUFFET) { HP(TEST_HP); MaxHP(MAX_HP); } @@ -118,7 +110,6 @@ SINGLE_BATTLE_TEST("Restore HP: Moomoo Milk restores a battler's HP by 100") SINGLE_BATTLE_TEST("Restore HP: Energy Powder restores a battler's HP by 60(50)") { - s16 damage; GIVEN { ASSUME(gItems[ITEM_ENERGY_POWDER].battleUsage == EFFECT_ITEM_RESTORE_HP); PLAYER(SPECIES_WOBBUFFET) { HP(TEST_HP); MaxHP(MAX_HP); } @@ -135,7 +126,6 @@ SINGLE_BATTLE_TEST("Restore HP: Energy Powder restores a battler's HP by 60(50)" SINGLE_BATTLE_TEST("Restore HP: Energy Root restores a battler's HP by 120(200)") { - s16 damage; GIVEN { ASSUME(gItems[ITEM_ENERGY_ROOT].battleUsage == EFFECT_ITEM_RESTORE_HP); PLAYER(SPECIES_WOBBUFFET) { HP(TEST_HP); MaxHP(MAX_HP); } @@ -152,7 +142,6 @@ SINGLE_BATTLE_TEST("Restore HP: Energy Root restores a battler's HP by 120(200)" SINGLE_BATTLE_TEST("Restore HP: Sweet Heart restores a battler's HP by 20") { - s16 damage; GIVEN { ASSUME(gItems[ITEM_SWEET_HEART].battleUsage == EFFECT_ITEM_RESTORE_HP); PLAYER(SPECIES_WOBBUFFET) { HP(TEST_HP); MaxHP(MAX_HP); } @@ -166,7 +155,6 @@ SINGLE_BATTLE_TEST("Restore HP: Sweet Heart restores a battler's HP by 20") SINGLE_BATTLE_TEST("Restore HP: Oran Berry restores a battler's HP by 10") { - s16 damage; GIVEN { ASSUME(gItems[ITEM_ORAN_BERRY].battleUsage == EFFECT_ITEM_RESTORE_HP); PLAYER(SPECIES_WOBBUFFET) { HP(TEST_HP); MaxHP(MAX_HP); } @@ -180,7 +168,6 @@ SINGLE_BATTLE_TEST("Restore HP: Oran Berry restores a battler's HP by 10") SINGLE_BATTLE_TEST("Restore HP: Sitrus Berry restores a battler's HP by 25% of its max HP(30HP flat)") { - s16 damage; GIVEN { ASSUME(gItems[ITEM_SITRUS_BERRY].battleUsage == EFFECT_ITEM_RESTORE_HP); PLAYER(SPECIES_WOBBUFFET) { HP(TEST_HP); MaxHP(MAX_HP); } From c4497bc0a8ca077eccf305f9d16982e4cc8a80f2 Mon Sep 17 00:00:00 2001 From: CallmeEchoo Date: Mon, 24 Apr 2023 14:16:17 +0200 Subject: [PATCH 21/51] revive tests --- test/item_effect_revive.c | 96 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 test/item_effect_revive.c diff --git a/test/item_effect_revive.c b/test/item_effect_revive.c new file mode 100644 index 000000000..9ced527f4 --- /dev/null +++ b/test/item_effect_revive.c @@ -0,0 +1,96 @@ +#include "global.h" +#include "test_battle.h" + +#define MAX_HP 200 + +SINGLE_BATTLE_TEST("Revive: Super Potion restores a fainted battler's HP to half") +{ + GIVEN { + ASSUME(gItems[ITEM_SUPER_POTION].battleUsage == EFFECT_ITEM_RESTORE_HP); + PLAYER(SPECIES_WYNAUT) { HP(1); MaxHP(MAX_HP); } + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(opponent, MOVE_TACKLE); SEND_OUT(player, 1); } + TURN { USE_ITEM(player, ITEM_SUPER_POTION, partyIndex: 0); } + TURN { SWITCH(player, 0); } + } SCENE { + MESSAGE("Super Potion restored Wynaut's health!"); + } FINALLY { + EXPECT_EQ(player->hp, 60); + } +} + +SINGLE_BATTLE_TEST("Revive: Revive restores a fainted battler's HP to half") +{ + GIVEN { + ASSUME(gItems[ITEM_REVIVE].battleUsage == EFFECT_ITEM_REVIVE); + PLAYER(SPECIES_WYNAUT) { HP(1); MaxHP(MAX_HP); } + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(opponent, MOVE_TACKLE); SEND_OUT(player, 1); } + TURN { USE_ITEM(player, ITEM_REVIVE, partyIndex: 0); } + TURN { SWITCH(player, 0); } + } SCENE { + MESSAGE("Revive restored Wynaut's health!"); + } FINALLY { + EXPECT_EQ(player->hp, MAX_HP/2); + } +} + +SINGLE_BATTLE_TEST("Revive: Max Revive restores a fainted battler's HP fully") +{ + GIVEN { + ASSUME(gItems[ITEM_MAX_REVIVE].battleUsage == EFFECT_ITEM_REVIVE); + PLAYER(SPECIES_WYNAUT) { HP(1); MaxHP(MAX_HP); } + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(opponent, MOVE_TACKLE); SEND_OUT(player, 1); } + TURN { USE_ITEM(player, ITEM_MAX_REVIVE, partyIndex: 0); } + TURN { SWITCH(player, 0); } + } SCENE { + MESSAGE("Max Revive restored Wynaut's health!"); + } FINALLY { + EXPECT_EQ(player->hp, MAX_HP); + } +} + +SINGLE_BATTLE_TEST("Revive: Revival Herb restores a fainted battler's HP fully") +{ + GIVEN { + ASSUME(gItems[ITEM_REVIVAL_HERB].battleUsage == EFFECT_ITEM_REVIVE); + PLAYER(SPECIES_WYNAUT) { HP(1); MaxHP(MAX_HP); } + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(opponent, MOVE_TACKLE); SEND_OUT(player, 1); } + TURN { USE_ITEM(player, ITEM_REVIVAL_HERB, partyIndex: 0); } + TURN { SWITCH(player, 0); } + } SCENE { + MESSAGE("Revival Herb restored Wynaut's health!"); + } FINALLY { + EXPECT_EQ(player->hp, MAX_HP); + } +} + +SINGLE_BATTLE_TEST("Revive: Max Honey restores a fainted battler's HP fully") +{ + GIVEN { + ASSUME(gItems[ITEM_MAX_HONEY].battleUsage == EFFECT_ITEM_REVIVE); + PLAYER(SPECIES_WYNAUT) { HP(1); MaxHP(MAX_HP); } + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(opponent, MOVE_TACKLE); SEND_OUT(player, 1); } + TURN { USE_ITEM(player, ITEM_MAX_HONEY, partyIndex: 0); } + TURN { SWITCH(player, 0); } + } SCENE { + MESSAGE("Max Honey restored Wynaut's health!"); + } FINALLY { + EXPECT_EQ(player->hp, MAX_HP); + } +} + +#undef MAX_HP From f74a1b07660ad5fd8c2e205074f1e265df98657d Mon Sep 17 00:00:00 2001 From: CallmeEchoo Date: Mon, 24 Apr 2023 22:26:56 +0200 Subject: [PATCH 22/51] fix strings after update --- test/item_effect_cure_status.c | 61 +++++++------------------ test/item_effect_heal_and_cure_status.c | 5 +- test/item_effect_revive.c | 10 ++-- 3 files changed, 23 insertions(+), 53 deletions(-) diff --git a/test/item_effect_cure_status.c b/test/item_effect_cure_status.c index f014a29b7..c593aa016 100644 --- a/test/item_effect_cure_status.c +++ b/test/item_effect_cure_status.c @@ -10,7 +10,7 @@ SINGLE_BATTLE_TEST("Cure Status: Paralyze Heal heals a battler from being paraly } WHEN { TURN { USE_ITEM(player, ITEM_PARALYZE_HEAL, partyIndex: 0); } } SCENE { - MESSAGE("Paralyze Heal cured Wobbuffet's status!"); + MESSAGE("Wobbuffet had its status healed!"); } } @@ -23,7 +23,7 @@ SINGLE_BATTLE_TEST("Cure Status: Antidote heals a battler from being poisoned") } WHEN { TURN { USE_ITEM(player, ITEM_ANTIDOTE, partyIndex: 0); } } SCENE { - MESSAGE("Antidote cured Wobbuffet's status!"); + MESSAGE("Wobbuffet had its status healed!"); } } @@ -36,7 +36,7 @@ SINGLE_BATTLE_TEST("Cure Status: Antidote heals a battler from being badly poiso } WHEN { TURN { USE_ITEM(player, ITEM_ANTIDOTE, partyIndex: 0); } } SCENE { - MESSAGE("Antidote cured Wobbuffet's status!"); + MESSAGE("Wobbuffet had its status healed!"); } } @@ -49,7 +49,7 @@ SINGLE_BATTLE_TEST("Cure Status: Awakening heals a battler from being asleep") } WHEN { TURN { USE_ITEM(player, ITEM_AWAKENING, partyIndex: 0); } } SCENE { - MESSAGE("Awakening cured Wobbuffet's status!"); + MESSAGE("Wobbuffet had its status healed!"); } } @@ -62,7 +62,7 @@ SINGLE_BATTLE_TEST("Cure Status: Burn Heal heals a battler from being burned") } WHEN { TURN { USE_ITEM(player, ITEM_BURN_HEAL, partyIndex: 0); } } SCENE { - MESSAGE("Burn Heal cured Wobbuffet's status!"); + MESSAGE("Wobbuffet had its status healed!"); } } @@ -75,7 +75,7 @@ SINGLE_BATTLE_TEST("Cure Status: Ice Heal heals a battler from being paralyzed") } WHEN { TURN { USE_ITEM(player, ITEM_ICE_HEAL, partyIndex: 0); } } SCENE { - MESSAGE("Ice Heal cured Wobbuffet's status!"); + MESSAGE("Wobbuffet had its status healed!"); } } @@ -95,7 +95,7 @@ SINGLE_BATTLE_TEST("Cure Status: Full Heal heals a battler from any primary stat } WHEN { TURN { USE_ITEM(player, ITEM_FULL_HEAL, partyIndex: 0); } } SCENE { - MESSAGE("Full Heal cured Wobbuffet's status!"); + MESSAGE("Wobbuffet had its status healed!"); } } @@ -115,7 +115,7 @@ SINGLE_BATTLE_TEST("Cure Status: Pewter Crunchies heals a battler from any prima } WHEN { TURN { USE_ITEM(player, ITEM_PEWTER_CRUNCHIES, partyIndex: 0); } } SCENE { - MESSAGE("PewtrCrnches cured Wobbuffet's status!"); + MESSAGE("Wobbuffet had its status healed!"); } } @@ -135,7 +135,7 @@ SINGLE_BATTLE_TEST("Cure Status: Lava Cookies heals a battler from any primary s } WHEN { TURN { USE_ITEM(player, ITEM_LAVA_COOKIE, partyIndex: 0); } } SCENE { - MESSAGE("Lava Cookie cured Wobbuffet's status!"); + MESSAGE("Wobbuffet had its status healed!"); } } @@ -155,7 +155,7 @@ SINGLE_BATTLE_TEST("Cure Status: Rage Candy Bar heals a battler from any primary } WHEN { TURN { USE_ITEM(player, ITEM_RAGE_CANDY_BAR, partyIndex: 0); } } SCENE { - MESSAGE("RageCandyBar cured Wobbuffet's status!"); + MESSAGE("Wobbuffet had its status healed!"); } } @@ -175,7 +175,7 @@ SINGLE_BATTLE_TEST("Cure Status: Old Gateu heals a battler from any primary stat } WHEN { TURN { USE_ITEM(player, ITEM_OLD_GATEAU, partyIndex: 0); } } SCENE { - MESSAGE("Old Gateau cured Wobbuffet's status!"); + MESSAGE("Wobbuffet had its status healed!"); } } @@ -195,7 +195,7 @@ SINGLE_BATTLE_TEST("Cure Status: Casteliacone heals a battler from any primary s } WHEN { TURN { USE_ITEM(player, ITEM_CASTELIACONE, partyIndex: 0); } } SCENE { - MESSAGE("Casteliacone cured Wobbuffet's status!"); + MESSAGE("Wobbuffet had its status healed!"); } } @@ -215,7 +215,7 @@ SINGLE_BATTLE_TEST("Cure Status: Lumiose Galette heals a battler from any primar } WHEN { TURN { USE_ITEM(player, ITEM_LUMIOSE_GALETTE, partyIndex: 0); } } SCENE { - MESSAGE("LumioseGlete cured Wobbuffet's status!"); + MESSAGE("Wobbuffet had its status healed!");; } } @@ -235,7 +235,7 @@ SINGLE_BATTLE_TEST("Cure Status: Shalour Sable heals a battler from any primary } WHEN { TURN { USE_ITEM(player, ITEM_SHALOUR_SABLE, partyIndex: 0); } } SCENE { - MESSAGE("ShalourSable cured Wobbuffet's status!"); + MESSAGE("Wobbuffet had its status healed!"); } } @@ -255,7 +255,7 @@ SINGLE_BATTLE_TEST("Cure Status: Big Malasada heals a battler from any primary s } WHEN { TURN { USE_ITEM(player, ITEM_BIG_MALASADA, partyIndex: 0); } } SCENE { - MESSAGE("Big Malasada cured Wobbuffet's status!"); + MESSAGE("Wobbuffet had its status healed!"); } } @@ -279,35 +279,6 @@ SINGLE_BATTLE_TEST("Cure Status: Full Heal and local specialties heal a battler TURN { MOVE(opponent, MOVE_CONFUSE_RAY); } TURN { USE_ITEM(player, item, partyIndex: 0); } } SCENE { - switch (item) - { - case ITEM_FULL_HEAL: - MESSAGE("Full Heal cured Wobbuffet's status!"); - break; - case ITEM_PEWTER_CRUNCHIES: - MESSAGE("PewtrCrnches cured Wobbuffet's status!"); - break; - case ITEM_LAVA_COOKIE: - MESSAGE("Lava Cookie cured Wobbuffet's status!"); - break; - case ITEM_RAGE_CANDY_BAR: - MESSAGE("RageCandyBar cured Wobbuffet's status!"); - break; - case ITEM_OLD_GATEAU: - MESSAGE("Old Gateau cured Wobbuffet's status!"); - break; - case ITEM_CASTELIACONE: - MESSAGE("Casteliacone cured Wobbuffet's status!"); - break; - case ITEM_LUMIOSE_GALETTE: - MESSAGE("LumioseGlete cured Wobbuffet's status!"); - break; - case ITEM_SHALOUR_SABLE: - MESSAGE("ShalourSable cured Wobbuffet's status!"); - break; - case ITEM_BIG_MALASADA: - MESSAGE("Big Malasada cured Wobbuffet's status!"); - break; - } + MESSAGE("Wobbuffet had its status healed!"); } } diff --git a/test/item_effect_heal_and_cure_status.c b/test/item_effect_heal_and_cure_status.c index d9bf0cf7c..95f97fbaa 100644 --- a/test/item_effect_heal_and_cure_status.c +++ b/test/item_effect_heal_and_cure_status.c @@ -17,7 +17,7 @@ SINGLE_BATTLE_TEST("Full Restore restores a battler's HP and cures any primary s } WHEN { TURN{ USE_ITEM(player, ITEM_FULL_RESTORE, partyIndex: 0); } } SCENE { - MESSAGE("Full Restore restored Wobbuffet's health!"); + MESSAGE("Wobbuffet had its HP restored!"); } FINALLY { EXPECT_EQ(player->hp, player->maxHP); EXPECT_EQ(player->status1, STATUS1_NONE); @@ -28,7 +28,6 @@ SINGLE_BATTLE_TEST("Full Restore restores a battler's HP and cures confusion") { // known failing bc even though it passes there is an underlying bug still that is only obvious in the replay. see #2938 // this also means that this test is likely not very good so I advice this to be redone - KNOWN_FAILING; GIVEN { ASSUME(gItems[ITEM_FULL_RESTORE].battleUsage == EFFECT_ITEM_HEAL_AND_CURE_STATUS); PLAYER(SPECIES_WOBBUFFET) { HP(1); MaxHP(300);}; @@ -38,7 +37,7 @@ SINGLE_BATTLE_TEST("Full Restore restores a battler's HP and cures confusion") TURN{ USE_ITEM(player, ITEM_FULL_RESTORE, partyIndex: 0); } TURN{ MOVE(player, MOVE_TACKLE); } } SCENE { - MESSAGE("Full Restore restored Wobbuffet's health!"); + MESSAGE("Wobbuffet had its HP restored!"); NONE_OF { MESSAGE("Wobbuffet is confused!"); } } FINALLY { EXPECT_EQ(player->hp, player->maxHP); diff --git a/test/item_effect_revive.c b/test/item_effect_revive.c index 9ced527f4..695361892 100644 --- a/test/item_effect_revive.c +++ b/test/item_effect_revive.c @@ -15,7 +15,7 @@ SINGLE_BATTLE_TEST("Revive: Super Potion restores a fainted battler's HP to half TURN { USE_ITEM(player, ITEM_SUPER_POTION, partyIndex: 0); } TURN { SWITCH(player, 0); } } SCENE { - MESSAGE("Super Potion restored Wynaut's health!"); + MESSAGE("Wynaut had its HP restored!"); } FINALLY { EXPECT_EQ(player->hp, 60); } @@ -33,7 +33,7 @@ SINGLE_BATTLE_TEST("Revive: Revive restores a fainted battler's HP to half") TURN { USE_ITEM(player, ITEM_REVIVE, partyIndex: 0); } TURN { SWITCH(player, 0); } } SCENE { - MESSAGE("Revive restored Wynaut's health!"); + MESSAGE("Wynaut had its HP restored!"); } FINALLY { EXPECT_EQ(player->hp, MAX_HP/2); } @@ -51,7 +51,7 @@ SINGLE_BATTLE_TEST("Revive: Max Revive restores a fainted battler's HP fully") TURN { USE_ITEM(player, ITEM_MAX_REVIVE, partyIndex: 0); } TURN { SWITCH(player, 0); } } SCENE { - MESSAGE("Max Revive restored Wynaut's health!"); + MESSAGE("Wynaut had its HP restored!"); } FINALLY { EXPECT_EQ(player->hp, MAX_HP); } @@ -69,7 +69,7 @@ SINGLE_BATTLE_TEST("Revive: Revival Herb restores a fainted battler's HP fully") TURN { USE_ITEM(player, ITEM_REVIVAL_HERB, partyIndex: 0); } TURN { SWITCH(player, 0); } } SCENE { - MESSAGE("Revival Herb restored Wynaut's health!"); + MESSAGE("Wynaut had its HP restored!"); } FINALLY { EXPECT_EQ(player->hp, MAX_HP); } @@ -87,7 +87,7 @@ SINGLE_BATTLE_TEST("Revive: Max Honey restores a fainted battler's HP fully") TURN { USE_ITEM(player, ITEM_MAX_HONEY, partyIndex: 0); } TURN { SWITCH(player, 0); } } SCENE { - MESSAGE("Max Honey restored Wynaut's health!"); + MESSAGE("Wynaut had its HP restored!"); } FINALLY { EXPECT_EQ(player->hp, MAX_HP); } From 59666a1eb42d0699f27c102614234f4a8abd03eb Mon Sep 17 00:00:00 2001 From: CallmeEchoo Date: Mon, 24 Apr 2023 22:36:58 +0200 Subject: [PATCH 23/51] heal powder test --- test/item_effect_cure_status.c | 21 +++++++++++++++++++++ test/item_effect_heal_and_cure_status.c | 2 -- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/test/item_effect_cure_status.c b/test/item_effect_cure_status.c index c593aa016..229f4e2b7 100644 --- a/test/item_effect_cure_status.c +++ b/test/item_effect_cure_status.c @@ -99,6 +99,26 @@ SINGLE_BATTLE_TEST("Cure Status: Full Heal heals a battler from any primary stat } } +SINGLE_BATTLE_TEST("Cure Status: Heal Powder heals a battler from any primary status") +{ + u16 status; + PARAMETRIZE{ status = STATUS1_BURN; } + PARAMETRIZE{ status = STATUS1_FREEZE; } + PARAMETRIZE{ status = STATUS1_PARALYSIS; } + PARAMETRIZE{ status = STATUS1_POISON; } + PARAMETRIZE{ status = STATUS1_TOXIC_POISON; } + PARAMETRIZE{ status = STATUS1_SLEEP; } + GIVEN { + ASSUME(gItems[ITEM_HEAL_POWDER].battleUsage == EFFECT_ITEM_CURE_STATUS); + PLAYER(SPECIES_WOBBUFFET) { Status1(status); } + OPPONENT(SPECIES_WYNAUT); + } WHEN { + TURN { USE_ITEM(player, ITEM_HEAL_POWDER, partyIndex: 0); } + } SCENE { + MESSAGE("Wobbuffet had its status healed!"); + } +} + SINGLE_BATTLE_TEST("Cure Status: Pewter Crunchies heals a battler from any primary status") { u16 status; @@ -263,6 +283,7 @@ SINGLE_BATTLE_TEST("Cure Status: Full Heal and local specialties heal a battler { u16 item; PARAMETRIZE { item = ITEM_FULL_HEAL; } + PARAMETRIZE { item = ITEM_HEAL_POWDER; } PARAMETRIZE { item = ITEM_PEWTER_CRUNCHIES; } PARAMETRIZE { item = ITEM_LAVA_COOKIE; } PARAMETRIZE { item = ITEM_RAGE_CANDY_BAR; } diff --git a/test/item_effect_heal_and_cure_status.c b/test/item_effect_heal_and_cure_status.c index 95f97fbaa..6e264d25a 100644 --- a/test/item_effect_heal_and_cure_status.c +++ b/test/item_effect_heal_and_cure_status.c @@ -26,8 +26,6 @@ SINGLE_BATTLE_TEST("Full Restore restores a battler's HP and cures any primary s SINGLE_BATTLE_TEST("Full Restore restores a battler's HP and cures confusion") { - // known failing bc even though it passes there is an underlying bug still that is only obvious in the replay. see #2938 - // this also means that this test is likely not very good so I advice this to be redone GIVEN { ASSUME(gItems[ITEM_FULL_RESTORE].battleUsage == EFFECT_ITEM_HEAL_AND_CURE_STATUS); PLAYER(SPECIES_WOBBUFFET) { HP(1); MaxHP(300);}; From 60e048b83e967db723f2b6893555e14a44a8b0cb Mon Sep 17 00:00:00 2001 From: CallmeEchoo Date: Tue, 25 Apr 2023 13:44:16 +0200 Subject: [PATCH 24/51] more robust status cure tests --- test/item_effect_cure_status.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/test/item_effect_cure_status.c b/test/item_effect_cure_status.c index 229f4e2b7..4d4cbda2e 100644 --- a/test/item_effect_cure_status.c +++ b/test/item_effect_cure_status.c @@ -11,6 +11,8 @@ SINGLE_BATTLE_TEST("Cure Status: Paralyze Heal heals a battler from being paraly TURN { USE_ITEM(player, ITEM_PARALYZE_HEAL, partyIndex: 0); } } SCENE { MESSAGE("Wobbuffet had its status healed!"); + } FINALLY { + EXPECT_EQ(player->status1, STATUS1_NONE); } } @@ -24,6 +26,8 @@ SINGLE_BATTLE_TEST("Cure Status: Antidote heals a battler from being poisoned") TURN { USE_ITEM(player, ITEM_ANTIDOTE, partyIndex: 0); } } SCENE { MESSAGE("Wobbuffet had its status healed!"); + } FINALLY { + EXPECT_EQ(player->status1, STATUS1_NONE); } } @@ -37,6 +41,8 @@ SINGLE_BATTLE_TEST("Cure Status: Antidote heals a battler from being badly poiso TURN { USE_ITEM(player, ITEM_ANTIDOTE, partyIndex: 0); } } SCENE { MESSAGE("Wobbuffet had its status healed!"); + } FINALLY { + EXPECT_EQ(player->status1, STATUS1_NONE); } } @@ -50,6 +56,8 @@ SINGLE_BATTLE_TEST("Cure Status: Awakening heals a battler from being asleep") TURN { USE_ITEM(player, ITEM_AWAKENING, partyIndex: 0); } } SCENE { MESSAGE("Wobbuffet had its status healed!"); + } FINALLY { + EXPECT_EQ(player->status1, STATUS1_NONE); } } @@ -63,6 +71,8 @@ SINGLE_BATTLE_TEST("Cure Status: Burn Heal heals a battler from being burned") TURN { USE_ITEM(player, ITEM_BURN_HEAL, partyIndex: 0); } } SCENE { MESSAGE("Wobbuffet had its status healed!"); + } FINALLY { + EXPECT_EQ(player->status1, STATUS1_NONE); } } @@ -76,6 +86,8 @@ SINGLE_BATTLE_TEST("Cure Status: Ice Heal heals a battler from being paralyzed") TURN { USE_ITEM(player, ITEM_ICE_HEAL, partyIndex: 0); } } SCENE { MESSAGE("Wobbuffet had its status healed!"); + } FINALLY { + EXPECT_EQ(player->status1, STATUS1_NONE); } } @@ -96,6 +108,8 @@ SINGLE_BATTLE_TEST("Cure Status: Full Heal heals a battler from any primary stat TURN { USE_ITEM(player, ITEM_FULL_HEAL, partyIndex: 0); } } SCENE { MESSAGE("Wobbuffet had its status healed!"); + } FINALLY { + EXPECT_EQ(player->status1, STATUS1_NONE); } } @@ -116,6 +130,8 @@ SINGLE_BATTLE_TEST("Cure Status: Heal Powder heals a battler from any primary st TURN { USE_ITEM(player, ITEM_HEAL_POWDER, partyIndex: 0); } } SCENE { MESSAGE("Wobbuffet had its status healed!"); + } FINALLY { + EXPECT_EQ(player->status1, STATUS1_NONE); } } @@ -136,6 +152,8 @@ SINGLE_BATTLE_TEST("Cure Status: Pewter Crunchies heals a battler from any prima TURN { USE_ITEM(player, ITEM_PEWTER_CRUNCHIES, partyIndex: 0); } } SCENE { MESSAGE("Wobbuffet had its status healed!"); + } FINALLY { + EXPECT_EQ(player->status1, STATUS1_NONE); } } @@ -156,6 +174,8 @@ SINGLE_BATTLE_TEST("Cure Status: Lava Cookies heals a battler from any primary s TURN { USE_ITEM(player, ITEM_LAVA_COOKIE, partyIndex: 0); } } SCENE { MESSAGE("Wobbuffet had its status healed!"); + } FINALLY { + EXPECT_EQ(player->status1, STATUS1_NONE); } } @@ -176,6 +196,8 @@ SINGLE_BATTLE_TEST("Cure Status: Rage Candy Bar heals a battler from any primary TURN { USE_ITEM(player, ITEM_RAGE_CANDY_BAR, partyIndex: 0); } } SCENE { MESSAGE("Wobbuffet had its status healed!"); + } FINALLY { + EXPECT_EQ(player->status1, STATUS1_NONE); } } @@ -196,6 +218,8 @@ SINGLE_BATTLE_TEST("Cure Status: Old Gateu heals a battler from any primary stat TURN { USE_ITEM(player, ITEM_OLD_GATEAU, partyIndex: 0); } } SCENE { MESSAGE("Wobbuffet had its status healed!"); + } FINALLY { + EXPECT_EQ(player->status1, STATUS1_NONE); } } @@ -216,6 +240,8 @@ SINGLE_BATTLE_TEST("Cure Status: Casteliacone heals a battler from any primary s TURN { USE_ITEM(player, ITEM_CASTELIACONE, partyIndex: 0); } } SCENE { MESSAGE("Wobbuffet had its status healed!"); + } FINALLY { + EXPECT_EQ(player->status1, STATUS1_NONE); } } @@ -236,6 +262,8 @@ SINGLE_BATTLE_TEST("Cure Status: Lumiose Galette heals a battler from any primar TURN { USE_ITEM(player, ITEM_LUMIOSE_GALETTE, partyIndex: 0); } } SCENE { MESSAGE("Wobbuffet had its status healed!");; + } FINALLY { + EXPECT_EQ(player->status1, STATUS1_NONE); } } @@ -256,6 +284,8 @@ SINGLE_BATTLE_TEST("Cure Status: Shalour Sable heals a battler from any primary TURN { USE_ITEM(player, ITEM_SHALOUR_SABLE, partyIndex: 0); } } SCENE { MESSAGE("Wobbuffet had its status healed!"); + } FINALLY { + EXPECT_EQ(player->status1, STATUS1_NONE); } } @@ -276,6 +306,8 @@ SINGLE_BATTLE_TEST("Cure Status: Big Malasada heals a battler from any primary s TURN { USE_ITEM(player, ITEM_BIG_MALASADA, partyIndex: 0); } } SCENE { MESSAGE("Wobbuffet had its status healed!"); + } FINALLY { + EXPECT_EQ(player->status1, STATUS1_NONE); } } @@ -301,5 +333,7 @@ SINGLE_BATTLE_TEST("Cure Status: Full Heal and local specialties heal a battler TURN { USE_ITEM(player, item, partyIndex: 0); } } SCENE { MESSAGE("Wobbuffet had its status healed!"); + } FINALLY { + EXPECT_EQ(player->status2, STATUS1_NONE); // because we dont have STATUS2_NONE } } From 7fad0a2dbce29dfa50e40e6c2194c3462df7626d Mon Sep 17 00:00:00 2001 From: CallmeEchoo Date: Tue, 25 Apr 2023 19:45:35 +0200 Subject: [PATCH 25/51] add MovesWithPP macro to allow for setting pps in tests --- test/test_battle.h | 5 +++++ test/test_runner_battle.c | 15 +++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/test/test_battle.h b/test/test_battle.h index 967bb661d..0f413a2e4 100644 --- a/test/test_battle.h +++ b/test/test_battle.h @@ -713,6 +713,9 @@ void Randomly(u32 sourceLine, u32 passes, u32 trials, struct RandomlyContext); /* Given */ +#define MOVE_ARGS(...) {__VA_ARGS__} +#define PP_ARGS(...) {__VA_ARGS__} + #define GIVEN for (; gBattleTestRunnerState->runGiven; gBattleTestRunnerState->runGiven = FALSE) #define RNGSeed(seed) RNGSeed_(__LINE__, seed) @@ -733,6 +736,7 @@ void Randomly(u32 sourceLine, u32 passes, u32 trials, struct RandomlyContext); #define Speed(speed) Speed_(__LINE__, speed) #define Item(item) Item_(__LINE__, item) #define Moves(move1, ...) Moves_(__LINE__, (const u16 [MAX_MON_MOVES]) { move1, __VA_ARGS__ }) +#define MovesWithPP(moves, pp) MovesWithPP_(__LINE__, (const u16 [MAX_MON_MOVES]) MOVE_ARGS moves, (const u8 [MAX_MON_MOVES]) PP_ARGS pp) #define Friendship(friendship) Friendship_(__LINE__, friendship) #define Status1(status1) Status1_(__LINE__, status1) @@ -753,6 +757,7 @@ void SpDefense_(u32 sourceLine, u32 spDefense); void Speed_(u32 sourceLine, u32 speed); void Item_(u32 sourceLine, u32 item); void Moves_(u32 sourceLine, const u16 moves[MAX_MON_MOVES]); +void MovesWithPP_(u32 sourceLine, const u16 moves[MAX_MON_MOVES], const u8 pp[MAX_MON_MOVES]); void Friendship_(u32 sourceLine, u32 friendship); void Status1_(u32 sourceLine, u32 status1); diff --git a/test/test_runner_battle.c b/test/test_runner_battle.c index 2a44cc018..33fcd5a0f 100644 --- a/test/test_runner_battle.c +++ b/test/test_runner_battle.c @@ -1161,6 +1161,21 @@ void Moves_(u32 sourceLine, const u16 moves[MAX_MON_MOVES]) DATA.explicitMoves[DATA.currentSide] |= 1 << DATA.currentPartyIndex; } +void MovesWithPP_(u32 sourceLine, const u16 moves[MAX_MON_MOVES], const u8 pp[MAX_MON_MOVES]) +{ + s32 i; + INVALID_IF(!DATA.currentMon, "Moves outside of PLAYER/OPPONENT"); + for (i = 0; i < MAX_MON_MOVES; i++) + { + if (moves[i] == MOVE_NONE) + break; + INVALID_IF(moves[i] >= MOVES_COUNT, "Illegal move: %d", moves[i]); + SetMonData(DATA.currentMon, MON_DATA_MOVE1 + i, &moves[i]); + SetMonData(DATA.currentMon, MON_DATA_PP1 + i, &pp[i]); + } + DATA.explicitMoves[DATA.currentSide] |= 1 << DATA.currentPartyIndex; +} + void Friendship_(u32 sourceLine, u32 friendship) { INVALID_IF(!DATA.currentMon, "Friendship outside of PLAYER/OPPONENT"); From 08ec873ef27da02404c35c9ae911779043edaf9a Mon Sep 17 00:00:00 2001 From: CallmeEchoo Date: Tue, 25 Apr 2023 20:35:36 +0200 Subject: [PATCH 26/51] update MoveWithPP macro to use struct --- test/test_battle.h | 10 ++++++---- test/test_runner_battle.c | 10 +++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/test/test_battle.h b/test/test_battle.h index 0f413a2e4..f2d8bab78 100644 --- a/test/test_battle.h +++ b/test/test_battle.h @@ -713,8 +713,10 @@ void Randomly(u32 sourceLine, u32 passes, u32 trials, struct RandomlyContext); /* Given */ -#define MOVE_ARGS(...) {__VA_ARGS__} -#define PP_ARGS(...) {__VA_ARGS__} +struct moveWithPP { + u16 moveId; + u8 pp; +}; #define GIVEN for (; gBattleTestRunnerState->runGiven; gBattleTestRunnerState->runGiven = FALSE) @@ -736,7 +738,7 @@ void Randomly(u32 sourceLine, u32 passes, u32 trials, struct RandomlyContext); #define Speed(speed) Speed_(__LINE__, speed) #define Item(item) Item_(__LINE__, item) #define Moves(move1, ...) Moves_(__LINE__, (const u16 [MAX_MON_MOVES]) { move1, __VA_ARGS__ }) -#define MovesWithPP(moves, pp) MovesWithPP_(__LINE__, (const u16 [MAX_MON_MOVES]) MOVE_ARGS moves, (const u8 [MAX_MON_MOVES]) PP_ARGS pp) +#define MovesWithPP(movewithpp1, ...) MovesWithPP_(__LINE__, (struct moveWithPP[MAX_MON_MOVES]) {movewithpp1, __VA_ARGS__}) #define Friendship(friendship) Friendship_(__LINE__, friendship) #define Status1(status1) Status1_(__LINE__, status1) @@ -757,7 +759,7 @@ void SpDefense_(u32 sourceLine, u32 spDefense); void Speed_(u32 sourceLine, u32 speed); void Item_(u32 sourceLine, u32 item); void Moves_(u32 sourceLine, const u16 moves[MAX_MON_MOVES]); -void MovesWithPP_(u32 sourceLine, const u16 moves[MAX_MON_MOVES], const u8 pp[MAX_MON_MOVES]); +void MovesWithPP_(u32 sourceLine, struct moveWithPP moveWithPP[MAX_MON_MOVES]); void Friendship_(u32 sourceLine, u32 friendship); void Status1_(u32 sourceLine, u32 status1); diff --git a/test/test_runner_battle.c b/test/test_runner_battle.c index 33fcd5a0f..75e459e49 100644 --- a/test/test_runner_battle.c +++ b/test/test_runner_battle.c @@ -1161,17 +1161,17 @@ void Moves_(u32 sourceLine, const u16 moves[MAX_MON_MOVES]) DATA.explicitMoves[DATA.currentSide] |= 1 << DATA.currentPartyIndex; } -void MovesWithPP_(u32 sourceLine, const u16 moves[MAX_MON_MOVES], const u8 pp[MAX_MON_MOVES]) +void MovesWithPP_(u32 sourceLine, struct moveWithPP moveWithPP[MAX_MON_MOVES]) { s32 i; INVALID_IF(!DATA.currentMon, "Moves outside of PLAYER/OPPONENT"); for (i = 0; i < MAX_MON_MOVES; i++) { - if (moves[i] == MOVE_NONE) + if (moveWithPP[i].moveId == MOVE_NONE) break; - INVALID_IF(moves[i] >= MOVES_COUNT, "Illegal move: %d", moves[i]); - SetMonData(DATA.currentMon, MON_DATA_MOVE1 + i, &moves[i]); - SetMonData(DATA.currentMon, MON_DATA_PP1 + i, &pp[i]); + INVALID_IF(moveWithPP[i].moveId >= MOVES_COUNT, "Illegal move: %d", &moveWithPP[i].moveId); + SetMonData(DATA.currentMon, MON_DATA_MOVE1 + i, &moveWithPP[i].moveId); + SetMonData(DATA.currentMon, MON_DATA_PP1 + i, &moveWithPP[i].pp); } DATA.explicitMoves[DATA.currentSide] |= 1 << DATA.currentPartyIndex; } From d3e9a689fdf1a42519f0cf77777bde189758232f Mon Sep 17 00:00:00 2001 From: CallmeEchoo Date: Tue, 25 Apr 2023 21:26:19 +0200 Subject: [PATCH 27/51] restore pp item tests --- test/item_effect_restore_pp.c | 61 +++++++++++++++++++++++++++++++---- 1 file changed, 54 insertions(+), 7 deletions(-) diff --git a/test/item_effect_restore_pp.c b/test/item_effect_restore_pp.c index 234d4ae4e..f21593566 100644 --- a/test/item_effect_restore_pp.c +++ b/test/item_effect_restore_pp.c @@ -1,19 +1,66 @@ #include "global.h" #include "test_battle.h" -SINGLE_BATTLE_TEST("Ether restores the PP of one of a battler's moves") +SINGLE_BATTLE_TEST("Restore PP: Ether restores the PP of one of a battler's moves by 10 ") { GIVEN { ASSUME(gItems[ITEM_ETHER].battleUsage == EFFECT_ITEM_RESTORE_PP); ASSUME(gItems[ITEM_ETHER].type == ITEM_USE_PARTY_MENU_MOVES); - PLAYER(SPECIES_WOBBUFFET) { Moves(MOVE_TACKLE, MOVE_CONFUSION); } + PLAYER(SPECIES_WOBBUFFET) { MovesWithPP({MOVE_TACKLE, 0}, {MOVE_CONFUSION, 20}); } OPPONENT(SPECIES_WOBBUFFET); } WHEN { - TURN { MOVE(player, MOVE_TACKLE); } - TURN { MOVE(player, MOVE_CONFUSION); } TURN { USE_ITEM(player, ITEM_ETHER, partyIndex: 0, move: MOVE_TACKLE); } - } FINALLY { - EXPECT_EQ(player->pp[0], 35); - EXPECT_EQ(player->pp[1], 24); + } THEN { + EXPECT_EQ(player->pp[0], 10); + EXPECT_EQ(player->pp[1], 20); + } +} + +SINGLE_BATTLE_TEST("Restore PP: Max Ether restores the PP of one of a battler's moves fully") +{ + GIVEN { + ASSUME(gItems[ITEM_MAX_ETHER].battleUsage == EFFECT_ITEM_RESTORE_PP); + ASSUME(gItems[ITEM_MAX_ETHER].type == ITEM_USE_PARTY_MENU_MOVES); + PLAYER(SPECIES_WOBBUFFET) { MovesWithPP({MOVE_TACKLE, 0}, {MOVE_CONFUSION, 20}); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { USE_ITEM(player, ITEM_MAX_ETHER, partyIndex: 0, move: MOVE_TACKLE); } + } THEN { + EXPECT_EQ(player->pp[0], 35); + EXPECT_EQ(player->pp[1], 20); + } +} + +SINGLE_BATTLE_TEST("Restore PP: Elixir restores the PP of all of a battler's moves by 10") +{ + GIVEN { + ASSUME(gItems[ITEM_ELIXIR].battleUsage == EFFECT_ITEM_RESTORE_PP); + ASSUME(gItems[ITEM_ELIXIR].type == ITEM_USE_PARTY_MENU); + PLAYER(SPECIES_WOBBUFFET) { MovesWithPP({MOVE_TACKLE, 0}, {MOVE_CONFUSION, 0}, {MOVE_SCRATCH, 0}, {MOVE_GROWL, 0}); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { USE_ITEM(player, ITEM_ELIXIR, partyIndex: 0); } + } THEN { + EXPECT_EQ(player->pp[0], 10); + EXPECT_EQ(player->pp[1], 10); + EXPECT_EQ(player->pp[2], 10); + EXPECT_EQ(player->pp[3], 10); + } +} + +SINGLE_BATTLE_TEST("Restore PP: Max Elixir restores the PP of all of a battler's moves fully") +{ + GIVEN { + ASSUME(gItems[ITEM_MAX_ELIXIR].battleUsage == EFFECT_ITEM_RESTORE_PP); + ASSUME(gItems[ITEM_MAX_ELIXIR].type == ITEM_USE_PARTY_MENU); + PLAYER(SPECIES_WOBBUFFET) { MovesWithPP({MOVE_TACKLE, 0}, {MOVE_CONFUSION, 0}, {MOVE_SCRATCH, 0}, {MOVE_GROWL, 0}); } + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { USE_ITEM(player, ITEM_MAX_ELIXIR, partyIndex: 0); } + } THEN { + EXPECT_EQ(player->pp[0], 35); + EXPECT_EQ(player->pp[1], 25); + EXPECT_EQ(player->pp[2], 35); + EXPECT_EQ(player->pp[3], 40); } } From 9f2589e1595cd8bf9f40a734bfc13b195b03f967 Mon Sep 17 00:00:00 2001 From: CallmeEchoo Date: Tue, 25 Apr 2023 23:06:07 +0200 Subject: [PATCH 28/51] better usage of THEN over FINALLY --- test/item_effect_cure_status.c | 36 ++++++++++++------------- test/item_effect_heal_and_cure_status.c | 4 +-- test/item_effect_revive.c | 26 +++--------------- 3 files changed, 24 insertions(+), 42 deletions(-) diff --git a/test/item_effect_cure_status.c b/test/item_effect_cure_status.c index 4d4cbda2e..949f60f0e 100644 --- a/test/item_effect_cure_status.c +++ b/test/item_effect_cure_status.c @@ -11,7 +11,7 @@ SINGLE_BATTLE_TEST("Cure Status: Paralyze Heal heals a battler from being paraly TURN { USE_ITEM(player, ITEM_PARALYZE_HEAL, partyIndex: 0); } } SCENE { MESSAGE("Wobbuffet had its status healed!"); - } FINALLY { + } THEN { EXPECT_EQ(player->status1, STATUS1_NONE); } } @@ -26,7 +26,7 @@ SINGLE_BATTLE_TEST("Cure Status: Antidote heals a battler from being poisoned") TURN { USE_ITEM(player, ITEM_ANTIDOTE, partyIndex: 0); } } SCENE { MESSAGE("Wobbuffet had its status healed!"); - } FINALLY { + } THEN { EXPECT_EQ(player->status1, STATUS1_NONE); } } @@ -41,7 +41,7 @@ SINGLE_BATTLE_TEST("Cure Status: Antidote heals a battler from being badly poiso TURN { USE_ITEM(player, ITEM_ANTIDOTE, partyIndex: 0); } } SCENE { MESSAGE("Wobbuffet had its status healed!"); - } FINALLY { + } THEN { EXPECT_EQ(player->status1, STATUS1_NONE); } } @@ -56,7 +56,7 @@ SINGLE_BATTLE_TEST("Cure Status: Awakening heals a battler from being asleep") TURN { USE_ITEM(player, ITEM_AWAKENING, partyIndex: 0); } } SCENE { MESSAGE("Wobbuffet had its status healed!"); - } FINALLY { + } THEN { EXPECT_EQ(player->status1, STATUS1_NONE); } } @@ -71,7 +71,7 @@ SINGLE_BATTLE_TEST("Cure Status: Burn Heal heals a battler from being burned") TURN { USE_ITEM(player, ITEM_BURN_HEAL, partyIndex: 0); } } SCENE { MESSAGE("Wobbuffet had its status healed!"); - } FINALLY { + } THEN { EXPECT_EQ(player->status1, STATUS1_NONE); } } @@ -86,7 +86,7 @@ SINGLE_BATTLE_TEST("Cure Status: Ice Heal heals a battler from being paralyzed") TURN { USE_ITEM(player, ITEM_ICE_HEAL, partyIndex: 0); } } SCENE { MESSAGE("Wobbuffet had its status healed!"); - } FINALLY { + } THEN { EXPECT_EQ(player->status1, STATUS1_NONE); } } @@ -108,7 +108,7 @@ SINGLE_BATTLE_TEST("Cure Status: Full Heal heals a battler from any primary stat TURN { USE_ITEM(player, ITEM_FULL_HEAL, partyIndex: 0); } } SCENE { MESSAGE("Wobbuffet had its status healed!"); - } FINALLY { + } THEN { EXPECT_EQ(player->status1, STATUS1_NONE); } } @@ -130,7 +130,7 @@ SINGLE_BATTLE_TEST("Cure Status: Heal Powder heals a battler from any primary st TURN { USE_ITEM(player, ITEM_HEAL_POWDER, partyIndex: 0); } } SCENE { MESSAGE("Wobbuffet had its status healed!"); - } FINALLY { + } THEN { EXPECT_EQ(player->status1, STATUS1_NONE); } } @@ -152,7 +152,7 @@ SINGLE_BATTLE_TEST("Cure Status: Pewter Crunchies heals a battler from any prima TURN { USE_ITEM(player, ITEM_PEWTER_CRUNCHIES, partyIndex: 0); } } SCENE { MESSAGE("Wobbuffet had its status healed!"); - } FINALLY { + } THEN { EXPECT_EQ(player->status1, STATUS1_NONE); } } @@ -174,7 +174,7 @@ SINGLE_BATTLE_TEST("Cure Status: Lava Cookies heals a battler from any primary s TURN { USE_ITEM(player, ITEM_LAVA_COOKIE, partyIndex: 0); } } SCENE { MESSAGE("Wobbuffet had its status healed!"); - } FINALLY { + } THEN { EXPECT_EQ(player->status1, STATUS1_NONE); } } @@ -196,7 +196,7 @@ SINGLE_BATTLE_TEST("Cure Status: Rage Candy Bar heals a battler from any primary TURN { USE_ITEM(player, ITEM_RAGE_CANDY_BAR, partyIndex: 0); } } SCENE { MESSAGE("Wobbuffet had its status healed!"); - } FINALLY { + } THEN { EXPECT_EQ(player->status1, STATUS1_NONE); } } @@ -218,7 +218,7 @@ SINGLE_BATTLE_TEST("Cure Status: Old Gateu heals a battler from any primary stat TURN { USE_ITEM(player, ITEM_OLD_GATEAU, partyIndex: 0); } } SCENE { MESSAGE("Wobbuffet had its status healed!"); - } FINALLY { + } THEN { EXPECT_EQ(player->status1, STATUS1_NONE); } } @@ -240,7 +240,7 @@ SINGLE_BATTLE_TEST("Cure Status: Casteliacone heals a battler from any primary s TURN { USE_ITEM(player, ITEM_CASTELIACONE, partyIndex: 0); } } SCENE { MESSAGE("Wobbuffet had its status healed!"); - } FINALLY { + } THEN { EXPECT_EQ(player->status1, STATUS1_NONE); } } @@ -262,7 +262,7 @@ SINGLE_BATTLE_TEST("Cure Status: Lumiose Galette heals a battler from any primar TURN { USE_ITEM(player, ITEM_LUMIOSE_GALETTE, partyIndex: 0); } } SCENE { MESSAGE("Wobbuffet had its status healed!");; - } FINALLY { + } THEN { EXPECT_EQ(player->status1, STATUS1_NONE); } } @@ -284,7 +284,7 @@ SINGLE_BATTLE_TEST("Cure Status: Shalour Sable heals a battler from any primary TURN { USE_ITEM(player, ITEM_SHALOUR_SABLE, partyIndex: 0); } } SCENE { MESSAGE("Wobbuffet had its status healed!"); - } FINALLY { + } THEN { EXPECT_EQ(player->status1, STATUS1_NONE); } } @@ -306,12 +306,12 @@ SINGLE_BATTLE_TEST("Cure Status: Big Malasada heals a battler from any primary s TURN { USE_ITEM(player, ITEM_BIG_MALASADA, partyIndex: 0); } } SCENE { MESSAGE("Wobbuffet had its status healed!"); - } FINALLY { + } THEN { EXPECT_EQ(player->status1, STATUS1_NONE); } } -SINGLE_BATTLE_TEST("Cure Status: Full Heal and local specialties heal a battler from being confused") +SINGLE_BATTLE_TEST("Cure Status: Full Heal, Heal Powder and Local Specialties heal a battler from being confused") { u16 item; PARAMETRIZE { item = ITEM_FULL_HEAL; } @@ -333,7 +333,7 @@ SINGLE_BATTLE_TEST("Cure Status: Full Heal and local specialties heal a battler TURN { USE_ITEM(player, item, partyIndex: 0); } } SCENE { MESSAGE("Wobbuffet had its status healed!"); - } FINALLY { + } THEN { EXPECT_EQ(player->status2, STATUS1_NONE); // because we dont have STATUS2_NONE } } diff --git a/test/item_effect_heal_and_cure_status.c b/test/item_effect_heal_and_cure_status.c index 6e264d25a..17ac5be96 100644 --- a/test/item_effect_heal_and_cure_status.c +++ b/test/item_effect_heal_and_cure_status.c @@ -18,7 +18,7 @@ SINGLE_BATTLE_TEST("Full Restore restores a battler's HP and cures any primary s TURN{ USE_ITEM(player, ITEM_FULL_RESTORE, partyIndex: 0); } } SCENE { MESSAGE("Wobbuffet had its HP restored!"); - } FINALLY { + } THEN { EXPECT_EQ(player->hp, player->maxHP); EXPECT_EQ(player->status1, STATUS1_NONE); } @@ -37,7 +37,7 @@ SINGLE_BATTLE_TEST("Full Restore restores a battler's HP and cures confusion") } SCENE { MESSAGE("Wobbuffet had its HP restored!"); NONE_OF { MESSAGE("Wobbuffet is confused!"); } - } FINALLY { + } THEN { EXPECT_EQ(player->hp, player->maxHP); } } diff --git a/test/item_effect_revive.c b/test/item_effect_revive.c index 695361892..3c6995176 100644 --- a/test/item_effect_revive.c +++ b/test/item_effect_revive.c @@ -3,24 +3,6 @@ #define MAX_HP 200 -SINGLE_BATTLE_TEST("Revive: Super Potion restores a fainted battler's HP to half") -{ - GIVEN { - ASSUME(gItems[ITEM_SUPER_POTION].battleUsage == EFFECT_ITEM_RESTORE_HP); - PLAYER(SPECIES_WYNAUT) { HP(1); MaxHP(MAX_HP); } - PLAYER(SPECIES_WOBBUFFET); - OPPONENT(SPECIES_WOBBUFFET); - } WHEN { - TURN { MOVE(opponent, MOVE_TACKLE); SEND_OUT(player, 1); } - TURN { USE_ITEM(player, ITEM_SUPER_POTION, partyIndex: 0); } - TURN { SWITCH(player, 0); } - } SCENE { - MESSAGE("Wynaut had its HP restored!"); - } FINALLY { - EXPECT_EQ(player->hp, 60); - } -} - SINGLE_BATTLE_TEST("Revive: Revive restores a fainted battler's HP to half") { GIVEN { @@ -34,7 +16,7 @@ SINGLE_BATTLE_TEST("Revive: Revive restores a fainted battler's HP to half") TURN { SWITCH(player, 0); } } SCENE { MESSAGE("Wynaut had its HP restored!"); - } FINALLY { + } THEN { EXPECT_EQ(player->hp, MAX_HP/2); } } @@ -52,7 +34,7 @@ SINGLE_BATTLE_TEST("Revive: Max Revive restores a fainted battler's HP fully") TURN { SWITCH(player, 0); } } SCENE { MESSAGE("Wynaut had its HP restored!"); - } FINALLY { + } THEN { EXPECT_EQ(player->hp, MAX_HP); } } @@ -70,7 +52,7 @@ SINGLE_BATTLE_TEST("Revive: Revival Herb restores a fainted battler's HP fully") TURN { SWITCH(player, 0); } } SCENE { MESSAGE("Wynaut had its HP restored!"); - } FINALLY { + } THEN { EXPECT_EQ(player->hp, MAX_HP); } } @@ -88,7 +70,7 @@ SINGLE_BATTLE_TEST("Revive: Max Honey restores a fainted battler's HP fully") TURN { SWITCH(player, 0); } } SCENE { MESSAGE("Wynaut had its HP restored!"); - } FINALLY { + } THEN { EXPECT_EQ(player->hp, MAX_HP); } } From a2809acfd1d6818acb6d39c5d8f1520746201c20 Mon Sep 17 00:00:00 2001 From: CallmeEchoo Date: Wed, 26 Apr 2023 01:02:47 +0200 Subject: [PATCH 29/51] fix gChosenMovePos not being assigned correctly for battle items thanks griffin <3 Co-Authored-By: Martin Griffin <838573+mrgriffin@users.noreply.github.com> --- include/recorded_battle.h | 1 + src/battle_controller_recorded_opponent.c | 1 + src/battle_controller_recorded_player.c | 1 + src/battle_script_commands.c | 10 +++++++--- test/test_runner_battle.c | 8 ++------ 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/include/recorded_battle.h b/include/recorded_battle.h index ea66096d7..02bbe8fc3 100644 --- a/include/recorded_battle.h +++ b/include/recorded_battle.h @@ -46,6 +46,7 @@ enum RECORDED_BATTLE_PALACE_ACTION, RECORDED_ITEM_ID, RECORDED_ITEM_TARGET, + RECORDED_ITEM_MOVE, }; extern u32 gRecordedBattleRngSeed; diff --git a/src/battle_controller_recorded_opponent.c b/src/battle_controller_recorded_opponent.c index bb41b42d6..8255abcab 100644 --- a/src/battle_controller_recorded_opponent.c +++ b/src/battle_controller_recorded_opponent.c @@ -1442,6 +1442,7 @@ static void RecordedOpponentHandleChooseItem(void) u8 byte2 = RecordedBattle_GetBattlerAction(RECORDED_ITEM_ID, gActiveBattler); gBattleStruct->chosenItem[gActiveBattler] = (byte1 << 8) | byte2; gBattleStruct->itemPartyIndex[gActiveBattler] = RecordedBattle_GetBattlerAction(RECORDED_ITEM_TARGET, gActiveBattler); + gChosenMovePos = RecordedBattle_GetBattlerAction(RECORDED_ITEM_MOVE, gActiveBattler); BtlController_EmitOneReturnValue(BUFFER_B, gBattleStruct->chosenItem[gActiveBattler]); RecordedOpponentBufferExecCompleted(); } diff --git a/src/battle_controller_recorded_player.c b/src/battle_controller_recorded_player.c index efbd60f18..8350e8594 100644 --- a/src/battle_controller_recorded_player.c +++ b/src/battle_controller_recorded_player.c @@ -1466,6 +1466,7 @@ static void RecordedPlayerHandleChooseItem(void) u8 byte2 = RecordedBattle_GetBattlerAction(RECORDED_ITEM_ID, gActiveBattler); gBattleStruct->chosenItem[gActiveBattler] = (byte1 << 8) | byte2; gBattleStruct->itemPartyIndex[gActiveBattler] = RecordedBattle_GetBattlerAction(RECORDED_ITEM_TARGET, gActiveBattler); + gChosenMovePos = RecordedBattle_GetBattlerAction(RECORDED_ITEM_MOVE, gActiveBattler); BtlController_EmitOneReturnValue(BUFFER_B, gBattleStruct->chosenItem[gActiveBattler]); RecordedPlayerBufferExecCompleted(); } diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 07669635e..31ef4cea7 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -16563,8 +16563,7 @@ void BS_ItemIncreaseStat(void) { void BS_ItemRestorePP(void) { NATIVE_ARGS(); const u8 *effect = GetItemEffect(gLastUsedItem); - u32 i, pp, maxPP, moveId; - u32 loopEnd = MAX_MON_MOVES; + u32 i, pp, maxPP, moveId, loopEnd; u32 battlerId = MAX_BATTLERS_COUNT; struct Pokemon *mon = (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER) ? &gPlayerParty[gBattleStruct->itemPartyIndex[gBattlerAttacker]] : &gEnemyParty[gBattleStruct->itemPartyIndex[gBattlerAttacker]]; @@ -16574,6 +16573,11 @@ void BS_ItemRestorePP(void) { i = gChosenMovePos; loopEnd = gChosenMovePos + 1; } + else + { + i = 0; + loopEnd = MAX_MON_MOVES; + } // Check if the recipient is an active battler. if (gBattleStruct->itemPartyIndex[gBattlerAttacker] == gBattlerPartyIndexes[gBattlerAttacker]) @@ -16583,7 +16587,7 @@ void BS_ItemRestorePP(void) { battlerId = BATTLE_PARTNER(gBattlerAttacker); // Heal PP! - for (i = 0; i < loopEnd; i++) + for (; i < loopEnd; i++) { pp = GetMonData(mon, MON_DATA_PP1 + i, NULL); moveId = GetMonData(mon, MON_DATA_MOVE1 + i, NULL); diff --git a/test/test_runner_battle.c b/test/test_runner_battle.c index 75e459e49..f10291262 100644 --- a/test/test_runner_battle.c +++ b/test/test_runner_battle.c @@ -1554,12 +1554,8 @@ void UseItem(u32 sourceLine, struct BattlePokemon *battler, struct ItemContext c PushBattlerAction(sourceLine, battlerId, RECORDED_ACTION_TYPE, B_ACTION_USE_ITEM); PushBattlerAction(sourceLine, battlerId, RECORDED_ITEM_ID, (ctx.itemId >> 8) & 0xFF); PushBattlerAction(sourceLine, battlerId, RECORDED_ITEM_ID, ctx.itemId & 0xFF); - if (ctx.explicitPartyIndex) - PushBattlerAction(sourceLine, battlerId, RECORDED_ITEM_TARGET, ctx.partyIndex); - else if (ctx.explicitMove) - PushBattlerAction(sourceLine, battlerId, RECORDED_ITEM_TARGET, i); - else - PushBattlerAction(sourceLine, battlerId, RECORDED_ITEM_TARGET, 0); + PushBattlerAction(sourceLine, battlerId, RECORDED_ITEM_TARGET, ctx.partyIndex); + PushBattlerAction(sourceLine, battlerId, RECORDED_ITEM_MOVE, i); DATA.actionBattlers |= 1 << battlerId; } From a5d39155c641da90df709db174961618ebd1b812 Mon Sep 17 00:00:00 2001 From: CallmeEchoo <65783283+CallmeEchoo@users.noreply.github.com> Date: Wed, 26 Apr 2023 14:15:35 +0200 Subject: [PATCH 30/51] add Max Mushroom test --- test/item_effect_increase_stat.c | 121 +++++++++++++++++++++++++++++-- 1 file changed, 113 insertions(+), 8 deletions(-) diff --git a/test/item_effect_increase_stat.c b/test/item_effect_increase_stat.c index 7fcbe7279..bb5989207 100644 --- a/test/item_effect_increase_stat.c +++ b/test/item_effect_increase_stat.c @@ -1,7 +1,7 @@ #include "global.h" #include "test_battle.h" -SINGLE_BATTLE_TEST("X Attack sharply raises battler's Attack stat", s16 damage) +SINGLE_BATTLE_TEST("Increase Stat: X Attack sharply raises battler's Attack stat", s16 damage) { u16 useItem; PARAMETRIZE { useItem = FALSE; } @@ -24,7 +24,7 @@ SINGLE_BATTLE_TEST("X Attack sharply raises battler's Attack stat", s16 damage) } } -SINGLE_BATTLE_TEST("X Defense sharply raises battler's Defense stat", s16 damage) +SINGLE_BATTLE_TEST("Increase Stat: X Defense sharply raises battler's Defense stat", s16 damage) { u16 useItem; PARAMETRIZE { useItem = FALSE; } @@ -47,7 +47,7 @@ SINGLE_BATTLE_TEST("X Defense sharply raises battler's Defense stat", s16 damage } } -SINGLE_BATTLE_TEST("X Sp. Atk sharply raises battler's Sp. Attack stat", s16 damage) +SINGLE_BATTLE_TEST("Increase Stat: X Sp. Atk sharply raises battler's Sp. Attack stat", s16 damage) { u16 useItem; PARAMETRIZE { useItem = FALSE; } @@ -70,7 +70,7 @@ SINGLE_BATTLE_TEST("X Sp. Atk sharply raises battler's Sp. Attack stat", s16 dam } } -SINGLE_BATTLE_TEST("X Sp. Def sharply raises battler's Sp. Defense stat", s16 damage) +SINGLE_BATTLE_TEST("Increase Stat: X Sp. Def sharply raises battler's Sp. Defense stat", s16 damage) { u16 useItem; PARAMETRIZE { useItem = FALSE; } @@ -93,7 +93,7 @@ SINGLE_BATTLE_TEST("X Sp. Def sharply raises battler's Sp. Defense stat", s16 da } } -SINGLE_BATTLE_TEST("X Speed sharply raises battler's Speed stat", s16 damage) +SINGLE_BATTLE_TEST("Increase Stat: X Speed sharply raises battler's Speed stat", s16 damage) { u16 useItem; PARAMETRIZE { useItem = FALSE; } @@ -106,7 +106,7 @@ SINGLE_BATTLE_TEST("X Speed sharply raises battler's Speed stat", s16 damage) OPPONENT(SPECIES_WOBBUFFET) { Speed(4); }; } else - { + { PLAYER(SPECIES_WOBBUFFET) { Speed(4); }; OPPONENT(SPECIES_WOBBUFFET) { Speed(5); }; } @@ -118,7 +118,7 @@ SINGLE_BATTLE_TEST("X Speed sharply raises battler's Speed stat", s16 damage) { MESSAGE("Wobbuffet used Tackle!"); MESSAGE("Foe Wobbuffet used Tackle!"); - } else + } else { MESSAGE("Foe Wobbuffet used Tackle!"); MESSAGE("Wobbuffet used Tackle!"); @@ -126,7 +126,7 @@ SINGLE_BATTLE_TEST("X Speed sharply raises battler's Speed stat", s16 damage) } } -SINGLE_BATTLE_TEST("X Accuracy sharply raises battler's Accuracy stat", s16 damage) +SINGLE_BATTLE_TEST("Increase Stat: X Accuracy sharply raises battler's Accuracy stat", s16 damage) { ASSUME(gBattleMoves[MOVE_SING].accuracy == 55); @@ -146,3 +146,108 @@ SINGLE_BATTLE_TEST("X Accuracy sharply raises battler's Accuracy stat", s16 dama MESSAGE("Foe Wobbuffet fell asleep!"); } } + +SINGLE_BATTLE_TEST("Increase Stat: Max Mushrooms raises battler's Attack stat", s16 damage) +{ + u16 useItem; + PARAMETRIZE { useItem = FALSE; } + PARAMETRIZE { useItem = TRUE; } + GIVEN { + ASSUME(gItems[ITEM_MAX_MUSHROOMS].battleUsage == EFFECT_ITEM_INCREASE_ALL_STATS); + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + if (useItem) TURN { USE_ITEM(player, ITEM_MAX_MUSHROOMS); } + TURN { MOVE(player, MOVE_TACKLE); } + } SCENE { + MESSAGE("Wobbuffet used Tackle!"); + HP_BAR(opponent, captureDamage: &results[i].damage); + } FINALLY { + EXPECT_MUL_EQ(results[0].damage, Q_4_12(1.5), results[1].damage); + } +} + +SINGLE_BATTLE_TEST("Increase Stat: Max Mushrooms raises battler's Defense stat", s16 damage) +{ + u16 useItem; + PARAMETRIZE { useItem = FALSE; } + PARAMETRIZE { useItem = TRUE; } + GIVEN { + ASSUME(gItems[ITEM_MAX_MUSHROOMS].battleUsage == EFFECT_ITEM_INCREASE_ALL_STATS); + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + if (useItem) TURN { USE_ITEM(player, ITEM_MAX_MUSHROOMS); } + TURN { MOVE(opponent, MOVE_TACKLE); } + } SCENE { + MESSAGE("Foe Wobbuffet used Tackle!"); + HP_BAR(player, captureDamage: &results[i].damage); + } FINALLY { + EXPECT_MUL_EQ(results[0].damage, Q_4_12(0.66), results[1].damage); + } +} + +SINGLE_BATTLE_TEST("Increase Stat: Max Mushrooms raises battler's Sp. Attack stat", s16 damage) +{ + u16 useItem; + PARAMETRIZE { useItem = FALSE; } + PARAMETRIZE { useItem = TRUE; } + GIVEN { + ASSUME(gItems[ITEM_MAX_MUSHROOMS].battleUsage == EFFECT_ITEM_INCREASE_ALL_STATS); + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + if (useItem) TURN { USE_ITEM(player, ITEM_MAX_MUSHROOMS); } + TURN { MOVE(player, MOVE_DISARMING_VOICE); } + } SCENE { + MESSAGE("Wobbuffet used DisrmngVoice!"); + HP_BAR(opponent, captureDamage: &results[i].damage); + } FINALLY { + EXPECT_MUL_EQ(results[0].damage, Q_4_12(1.5), results[1].damage); + } +} + +SINGLE_BATTLE_TEST("Increase Stat: Max Mushrooms battler's Sp. Defense stat", s16 damage) +{ + u16 useItem; + PARAMETRIZE { useItem = FALSE; } + PARAMETRIZE { useItem = TRUE; } + GIVEN { + ASSUME(gItems[ITEM_MAX_MUSHROOMS].battleUsage == EFFECT_ITEM_INCREASE_ALL_STATS); + PLAYER(SPECIES_WOBBUFFET); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + if (useItem) TURN { USE_ITEM(player, ITEM_MAX_MUSHROOMS); } + TURN { MOVE(opponent, MOVE_DISARMING_VOICE); } + } SCENE { + MESSAGE("Foe Wobbuffet used DisrmngVoice!"); + HP_BAR(player, captureDamage: &results[i].damage); + } FINALLY { + EXPECT_MUL_EQ(results[0].damage, Q_4_12(0.66), results[1].damage); + } +} + +SINGLE_BATTLE_TEST("Increase Stat: Max Mushrooms raises battler's Speed stat", s16 damage) +{ + u16 useItem; + PARAMETRIZE { useItem = FALSE; } + PARAMETRIZE { useItem = TRUE; } + GIVEN { + ASSUME(gItems[ITEM_MAX_MUSHROOMS].battleUsage == EFFECT_ITEM_INCREASE_ALL_STATS); + PLAYER(SPECIES_WOBBUFFET) { Speed(4); }; + OPPONENT(SPECIES_WOBBUFFET) { Speed(5); }; + } WHEN { + if (useItem) TURN { USE_ITEM(player, ITEM_MAX_MUSHROOMS); } + TURN { MOVE(player, MOVE_TACKLE); MOVE(opponent, MOVE_TACKLE); } + } SCENE { + if (useItem) + { + MESSAGE("Wobbuffet used Tackle!"); + MESSAGE("Foe Wobbuffet used Tackle!"); + } else + { + MESSAGE("Foe Wobbuffet used Tackle!"); + MESSAGE("Wobbuffet used Tackle!"); + } + } +} From b53c913558c5c454922a29c12cd864822b5da3dc Mon Sep 17 00:00:00 2001 From: Bassoonian Date: Sat, 29 Apr 2023 18:16:36 +0200 Subject: [PATCH 31/51] Manually port daycare expansion to modern standards --- include/config/pokemon.h | 13 +++-- src/daycare.c | 108 ++++++++++++++++++++++++++------------- 2 files changed, 82 insertions(+), 39 deletions(-) diff --git a/include/config/pokemon.h b/include/config/pokemon.h index 1cde573c9..624721746 100644 --- a/include/config/pokemon.h +++ b/include/config/pokemon.h @@ -8,10 +8,15 @@ #define P_UPDATED_EGG_GROUPS GEN_LATEST // Since Gen 8, certain Pokémon have gained new egg groups. // Breeding settings -#define P_NIDORAN_M_DITTO_BREED GEN_LATEST // Since Gen 5, when Nidoran♂ breeds with Ditto it can produce Nidoran♀ offspring. Before, it would only yield male offspring. This change also applies to Volbeat. -#define P_INCENSE_BREEDING GEN_LATEST // Since Gen 9, cross-generation Baby Pokémon don't require Incense being held by the parents to be obtained via breeding. -#define P_EGG_HATCH_LEVEL GEN_LATEST // Since Gen 4, Pokémon will hatch from eggs at level 1 instead of 5. -#define P_BALL_INHERITING GEN_LATEST // Since Gen 6, Eggs from the Daycare will inherit the Poké Ball from their mother. From Gen7 onwards, the father can pass it down as well, as long as it's of the same species as the mother. +#define P_NIDORAN_M_DITTO_BREED GEN_LATEST // Since Gen 5, when Nidoran♂ breeds with Ditto it can produce Nidoran♀ offspring. Before, it would only yield male offspring. This change also applies to Volbeat. +#define P_INCENSE_BREEDING GEN_LATEST // Since Gen 9, cross-generation Baby Pokémon don't require Incense being held by the parents to be obtained via breeding. +#define P_EGG_HATCH_LEVEL GEN_LATEST // Since Gen 4, Pokémon will hatch from eggs at level 1 instead of 5. +#define P_BALL_INHERITING GEN_LATEST // Since Gen 6, Eggs from the Daycare will inherit the Poké Ball from their mother. From Gen 7 onwards, the father can pass it down as well, as long as it's of the same species as the mother. +#define P_TM_INHERITANCE GEN_LATEST // Since Gen 6, the father no longer passes down TMs to the baby. +#define P_MOTHER_EGG_MOVE_INHERITANCE GEN_LATEST // Since Gen 6, the mother can also pass down Egg Moves. +#define P_NATURE_INHERITANCE GEN_LATEST // In Gen 3, Everstone grants Ditto and mothers a 50% chance to pass on Nature. Since Gen 4, anyone can pass on nature. Since Gen 5, the chance is 100%. +#define P_ABILITY_INHERITANCE GEN_LATEST // TODO: In B2W2, a female Pokémon has an 80% chance of passing down their ability if bred with a male. Since Gen 6, the chance is 80% for normal ability and 60% for Hidden Ability, and anyone can pass down their abilities if bred with Ditto. NOTE: BW's effect: 60% chance to pass down HA and random for normal ability has been omitted. +#define P_EGG_MOVE_TRANSFER GEN_LATEST // TODO: Starting in Gen 8, if two Pokémon of the same species are together in the Daycare, one knows an Egg Move, and the other has an empty slot, the other Pokémon will receive the Egg Move in the empty slot. // Species-specific settings #define P_SHEDINJA_BALL GEN_LATEST // Since Gen 4, Shedinja requires a Poké Ball for its evolution. In Gen 3, Shedinja inherits Nincada's Ball. diff --git a/src/daycare.c b/src/daycare.c index 803c0cacf..3feabe9ba 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -21,11 +21,14 @@ #include "overworld.h" #include "item.h" #include "constants/items.h" +#include "constants/hold_effects.h" #include "constants/moves.h" #include "constants/region_map_sections.h" extern const struct Evolution gEvolutionTable[][EVOS_PER_MON]; +#define IS_DITTO(species) (gBaseStats[species].eggGroup1 == EGG_GROUP_DITTO || gBaseStats[species].eggGroup2 == EGG_GROUP_DITTO) + static void ClearDaycareMonMail(struct DaycareMail *mail); static void SetInitialEggData(struct Pokemon *mon, u16 species, struct DayCare *daycare); static u8 GetDaycareCompatibilityScore(struct DayCare *daycare); @@ -425,43 +428,29 @@ static u16 GetEggSpecies(u16 species) static s32 GetParentToInheritNature(struct DayCare *daycare) { - u32 species[DAYCARE_MON_COUNT]; - s32 i; - s32 dittoCount; - s32 parent = -1; + u32 i; + u8 numWithEverstone = 0; + s32 slot = -1; - // search for female gender for (i = 0; i < DAYCARE_MON_COUNT; i++) { - if (GetBoxMonGender(&daycare->mons[i].mon) == MON_FEMALE) - parent = i; + if (ItemId_GetHoldEffect(GetBoxMonData(&daycare->mons[i].mon, MON_DATA_HELD_ITEM)) == HOLD_EFFECT_PREVENT_EVOLVE + #if P_NATURE_INHERITANCE == GEN_3 + && (GetBoxMonGender(&daycare->mons[i].mon) == MON_FEMALE || IS_DITTO(GetBoxMonData(&daycare->mons[i].mon, MON_DATA_SPECIES))) + #endif + ) { + slot = i; + numWithEverstone++; + } } - // search for ditto - for (dittoCount = 0, i = 0; i < DAYCARE_MON_COUNT; i++) - { - species[i] = GetBoxMonData(&daycare->mons[i].mon, MON_DATA_SPECIES); - if (species[i] == SPECIES_DITTO) - dittoCount++, parent = i; - } - - // coin flip on ...two Dittos - if (dittoCount == DAYCARE_MON_COUNT) - { - if (Random() >= USHRT_MAX / 2) - parent = 0; - else - parent = 1; - } - - // Don't inherit nature if not holding Everstone - if (GetBoxMonData(&daycare->mons[parent].mon, MON_DATA_HELD_ITEM) != ITEM_EVERSTONE - || Random() >= USHRT_MAX / 2) - { - return -1; - } - - return parent; + if (numWithEverstone >= DAYCARE_MON_COUNT) + return Random() & 1; +#if P_NATURE_INHERITANCE > GEN_4 + return slot; +#else + return Random() & 1 ? slot : -1; +#endif } static void _TriggerPendingDaycareEgg(struct DayCare *daycare) @@ -541,7 +530,7 @@ static void InheritIVs(struct Pokemon *egg, struct DayCare *daycare) { u16 motherItem = GetBoxMonData(&daycare->mons[0].mon, MON_DATA_HELD_ITEM); u16 fatherItem = GetBoxMonData(&daycare->mons[1].mon, MON_DATA_HELD_ITEM); - u8 i; + u8 i, start; u8 selectedIvs[5]; u8 availableIVs[NUM_STATS]; u8 whichParents[5]; @@ -557,8 +546,33 @@ static void InheritIVs(struct Pokemon *egg, struct DayCare *daycare) availableIVs[i] = i; } + start = 0; + if (ItemId_GetHoldEffect(motherItem) == HOLD_EFFECT_POWER_ITEM && + ItemId_GetHoldEffect(fatherItem) == HOLD_EFFECT_POWER_ITEM) + { + whichParents[0] = Random() % DAYCARE_MON_COUNT; + selectedIvs[0] = ItemId_GetSecondaryId( + GetBoxMonData(&daycare->mons[whichParents[0]].mon, MON_DATA_HELD_ITEM)); + RemoveIVIndexFromList(availableIVs, selectedIvs[0]); + start++; + } + else if (ItemId_GetHoldEffect(motherItem) == HOLD_EFFECT_POWER_ITEM) + { + whichParents[0] = 0; + selectedIvs[0] = ItemId_GetSecondaryId(motherItem); + RemoveIVIndexFromList(availableIVs, selectedIvs[0]); + start++; + } + else if (ItemId_GetHoldEffect(fatherItem) == HOLD_EFFECT_POWER_ITEM) + { + whichParents[0] = 1; + selectedIvs[0] = ItemId_GetSecondaryId(fatherItem); + RemoveIVIndexFromList(availableIVs, selectedIvs[0]); + start++; + } + // Select which IVs that will be inherited. - for (i = 0; i < howManyIVs; i++) + for (i = start; i < howManyIVs; i++) { // Randomly pick an IV from the available list and stop from being chosen again. // BUG: Instead of removing the IV that was just picked, this @@ -577,7 +591,7 @@ static void InheritIVs(struct Pokemon *egg, struct DayCare *daycare) } // Determine which parent each of the selected IVs should inherit from. - for (i = 0; i < howManyIVs; i++) + for (i = start; i < howManyIVs; i++) { whichParents[i] = Random() % DAYCARE_MON_COUNT; } @@ -703,6 +717,28 @@ static void BuildEggMoveset(struct Pokemon *egg, struct BoxPokemon *father, stru numEggMoves = GetEggMoves(egg, sHatchedEggEggMoves); +#if P_MOTHER_EGG_MOVE_INHERITANCE >= GEN_6 + for (i = 0; i < MAX_MON_MOVES; i++) + { + if (sHatchedEggMotherMoves[i] != MOVE_NONE) + { + for (j = 0; j < numEggMoves; j++) + { + if (sHatchedEggMotherMoves[i] == sHatchedEggEggMoves[j]) + { + if (GiveMoveToMon(egg, sHatchedEggMotherMoves[i]) == MON_HAS_MAX_MOVES) + DeleteFirstMoveAndGiveMoveToMon(egg, sHatchedEggMotherMoves[i]); + break; + } + } + } + else + { + break; + } + } +#endif + for (i = 0; i < MAX_MON_MOVES; i++) { if (sHatchedEggFatherMoves[i] != MOVE_NONE) @@ -722,6 +758,7 @@ static void BuildEggMoveset(struct Pokemon *egg, struct BoxPokemon *father, stru break; } } +#if P_TM_INHERITANCE < GEN_6 for (i = 0; i < MAX_MON_MOVES; i++) { if (sHatchedEggFatherMoves[i] != MOVE_NONE) @@ -737,6 +774,7 @@ static void BuildEggMoveset(struct Pokemon *egg, struct BoxPokemon *father, stru } } } +#endif for (i = 0; i < MAX_MON_MOVES; i++) { if (sHatchedEggFatherMoves[i] == MOVE_NONE) From acf4529d8b48587a7033e7cf71251ec8eb97ff06 Mon Sep 17 00:00:00 2001 From: Bassoonian Date: Sun, 30 Apr 2023 11:25:48 +0200 Subject: [PATCH 32/51] Allow Egg Move transfer for non-eggs --- include/config/pokemon.h | 2 +- include/pokemon.h | 1 + src/daycare.c | 50 ++++++++++++++++++++++++++++++++++++++++ src/pokemon.c | 3 +-- 4 files changed, 53 insertions(+), 3 deletions(-) diff --git a/include/config/pokemon.h b/include/config/pokemon.h index 624721746..d6e239515 100644 --- a/include/config/pokemon.h +++ b/include/config/pokemon.h @@ -16,7 +16,7 @@ #define P_MOTHER_EGG_MOVE_INHERITANCE GEN_LATEST // Since Gen 6, the mother can also pass down Egg Moves. #define P_NATURE_INHERITANCE GEN_LATEST // In Gen 3, Everstone grants Ditto and mothers a 50% chance to pass on Nature. Since Gen 4, anyone can pass on nature. Since Gen 5, the chance is 100%. #define P_ABILITY_INHERITANCE GEN_LATEST // TODO: In B2W2, a female Pokémon has an 80% chance of passing down their ability if bred with a male. Since Gen 6, the chance is 80% for normal ability and 60% for Hidden Ability, and anyone can pass down their abilities if bred with Ditto. NOTE: BW's effect: 60% chance to pass down HA and random for normal ability has been omitted. -#define P_EGG_MOVE_TRANSFER GEN_LATEST // TODO: Starting in Gen 8, if two Pokémon of the same species are together in the Daycare, one knows an Egg Move, and the other has an empty slot, the other Pokémon will receive the Egg Move in the empty slot. +#define P_EGG_MOVE_TRANSFER GEN_LATEST // Starting in Gen 8, if two Pokémon of the same species are together in the Daycare, one knows an Egg Move, and the other has an empty slot, the other Pokémon will receive the Egg Move in the empty slot. In Gen 9, if a Pokémon holds a Mirror Herb, it will receive Egg Moves from the other regardless of species. // Species-specific settings #define P_SHEDINJA_BALL GEN_LATEST // Since Gen 4, Shedinja requires a Poké Ball for its evolution. In Gen 3, Shedinja inherits Nincada's Ball. diff --git a/include/pokemon.h b/include/pokemon.h index 581677cae..239486106 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -442,6 +442,7 @@ void BoxMonToMon(const struct BoxPokemon *src, struct Pokemon *dest); u8 GetLevelFromMonExp(struct Pokemon *mon); u8 GetLevelFromBoxMonExp(struct BoxPokemon *boxMon); u16 GiveMoveToMon(struct Pokemon *mon, u16 move); +u16 GiveMoveToBoxMon(struct BoxPokemon *boxMon, u16 move); u16 GiveMoveToBattleMon(struct BattlePokemon *mon, u16 move); void SetMonMoveSlot(struct Pokemon *mon, u16 move, u8 slot); void SetBattleMonMoveSlot(struct BattlePokemon *mon, u16 move, u8 slot); diff --git a/src/daycare.c b/src/daycare.c index 3feabe9ba..a058ce905 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -34,6 +34,7 @@ static void SetInitialEggData(struct Pokemon *mon, u16 species, struct DayCare * static u8 GetDaycareCompatibilityScore(struct DayCare *daycare); static void DaycarePrintMonInfo(u8 windowId, u32 daycareSlotId, u8 y); static u8 ModifyBreedingScoreForOvalCharm(u8 score); +static u8 GetEggMoves(struct Pokemon *pokemon, u16 *eggMoves); // RAM buffers used to assist with BuildEggMoveset() EWRAM_DATA static u16 sHatchedEggLevelUpMoves[EGG_LVL_UP_MOVES_ARRAY_COUNT] = {0}; @@ -164,6 +165,51 @@ static s8 Daycare_FindEmptySpot(struct DayCare *daycare) return -1; } +static void TransferEggMoves(void) +{ + u32 i, j, k, l; + u16 numEggMoves; + struct Pokemon mon; + + for (i = 0; i < DAYCARE_MON_COUNT; i++) + { + if (!GetBoxMonData(&gSaveBlock1Ptr->daycare.mons[i].mon, MON_DATA_SANITY_HAS_SPECIES)) + continue; + + // Get list of egg moves for mon + BoxMonToMon(&gSaveBlock1Ptr->daycare.mons[i].mon, &mon); + for (j = 0; j < EGG_MOVES_ARRAY_COUNT; j++) + sHatchedEggEggMoves[j] = MOVE_NONE; + numEggMoves = GetEggMoves(&mon, sHatchedEggEggMoves); + for (j = 0; j < numEggMoves; j++) + { + // Go through other Daycare mons + for (k = 0; k < DAYCARE_MON_COUNT; k++) + { + if (k == i || !GetBoxMonData(&gSaveBlock1Ptr->daycare.mons[k].mon, MON_DATA_SANITY_HAS_SPECIES)) + continue; + + // Check if you can inherit from them + if (GetBoxMonData(&gSaveBlock1Ptr->daycare.mons[k].mon, MON_DATA_SPECIES) != GetBoxMonData(&gSaveBlock1Ptr->daycare.mons[i].mon, MON_DATA_SPECIES) + #if P_EGG_MOVE_TRANSFER >= GEN_9 + && GetBoxMonData(&gSaveBlock1Ptr->daycare.mons[i].mon, MON_DATA_HELD_ITEM) != ITEM_MIRROR_HERB + #endif + ) + continue; + + for (l = 0; l < MAX_MON_MOVES; l++) + { + if (GetBoxMonData(&gSaveBlock1Ptr->daycare.mons[k].mon, MON_DATA_MOVE1 + l) != sHatchedEggEggMoves[j]) + continue; + + if (GiveMoveToBoxMon(&gSaveBlock1Ptr->daycare.mons[i].mon, sHatchedEggEggMoves[j]) == MON_HAS_MAX_MOVES) + break; + } + } + } + } +} + static void StorePokemonInDaycare(struct Pokemon *mon, struct DaycareMon *daycareMon) { if (MonHasMail(mon)) @@ -186,6 +232,10 @@ static void StorePokemonInDaycare(struct Pokemon *mon, struct DaycareMon *daycar ZeroMonData(mon); CompactPartySlots(); CalculatePlayerPartyCount(); + +#if P_EGG_MOVE_TRANSFER >= GEN_8 + TransferEggMoves(); +#endif } static void StorePokemonInEmptyDaycareSlot(struct Pokemon *mon, struct DayCare *daycare) diff --git a/src/pokemon.c b/src/pokemon.c index e82cb98c3..5b83e9748 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -63,7 +63,6 @@ static union PokemonSubstruct *GetSubstruct(struct BoxPokemon *boxMon, u32 perso static void EncryptBoxMon(struct BoxPokemon *boxMon); static void DecryptBoxMon(struct BoxPokemon *boxMon); static void Task_PlayMapChosenOrBattleBGM(u8 taskId); -static u16 GiveMoveToBoxMon(struct BoxPokemon *boxMon, u16 move); static bool8 ShouldSkipFriendshipChange(void); static void RemoveIVIndexFromList(u8 *ivs, u8 selectedIv); void TrySpecialOverworldEvo(); @@ -4194,7 +4193,7 @@ u16 GiveMoveToMon(struct Pokemon *mon, u16 move) return GiveMoveToBoxMon(&mon->box, move); } -static u16 GiveMoveToBoxMon(struct BoxPokemon *boxMon, u16 move) +u16 GiveMoveToBoxMon(struct BoxPokemon *boxMon, u16 move) { s32 i; for (i = 0; i < MAX_MON_MOVES; i++) From 21fa91b80b76b8e4b67b8ea0df45c94bc7d078de Mon Sep 17 00:00:00 2001 From: Bassoonian Date: Sun, 30 Apr 2023 11:45:24 +0200 Subject: [PATCH 33/51] Add ClearHatchedEggMoves per SBird's suggestion Co-Authored-By: Philipp AUER --- src/daycare.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/daycare.c b/src/daycare.c index a058ce905..2997578d5 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -165,6 +165,14 @@ static s8 Daycare_FindEmptySpot(struct DayCare *daycare) return -1; } +static void ClearHatchedEggMoves(void) +{ + u16 i; + + for (i = 0; i < EGG_MOVES_ARRAY_COUNT; i++) + sHatchedEggEggMoves[i] = MOVE_NONE; +} + static void TransferEggMoves(void) { u32 i, j, k, l; @@ -176,10 +184,8 @@ static void TransferEggMoves(void) if (!GetBoxMonData(&gSaveBlock1Ptr->daycare.mons[i].mon, MON_DATA_SANITY_HAS_SPECIES)) continue; - // Get list of egg moves for mon BoxMonToMon(&gSaveBlock1Ptr->daycare.mons[i].mon, &mon); - for (j = 0; j < EGG_MOVES_ARRAY_COUNT; j++) - sHatchedEggEggMoves[j] = MOVE_NONE; + ClearHatchedEggMoves(); numEggMoves = GetEggMoves(&mon, sHatchedEggEggMoves); for (j = 0; j < numEggMoves; j++) { @@ -753,8 +759,7 @@ static void BuildEggMoveset(struct Pokemon *egg, struct BoxPokemon *father, stru sHatchedEggFatherMoves[i] = MOVE_NONE; sHatchedEggFinalMoves[i] = MOVE_NONE; } - for (i = 0; i < EGG_MOVES_ARRAY_COUNT; i++) - sHatchedEggEggMoves[i] = MOVE_NONE; + ClearHatchedEggMoves(); for (i = 0; i < EGG_LVL_UP_MOVES_ARRAY_COUNT; i++) sHatchedEggLevelUpMoves[i] = MOVE_NONE; From 8f75844ece7546df6b06db53302685f458c1f8b9 Mon Sep 17 00:00:00 2001 From: Bassoonian Date: Sun, 30 Apr 2023 12:58:18 +0200 Subject: [PATCH 34/51] Add Ability inheritance --- include/config/pokemon.h | 2 +- src/daycare.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/include/config/pokemon.h b/include/config/pokemon.h index d6e239515..a65eddb73 100644 --- a/include/config/pokemon.h +++ b/include/config/pokemon.h @@ -15,7 +15,7 @@ #define P_TM_INHERITANCE GEN_LATEST // Since Gen 6, the father no longer passes down TMs to the baby. #define P_MOTHER_EGG_MOVE_INHERITANCE GEN_LATEST // Since Gen 6, the mother can also pass down Egg Moves. #define P_NATURE_INHERITANCE GEN_LATEST // In Gen 3, Everstone grants Ditto and mothers a 50% chance to pass on Nature. Since Gen 4, anyone can pass on nature. Since Gen 5, the chance is 100%. -#define P_ABILITY_INHERITANCE GEN_LATEST // TODO: In B2W2, a female Pokémon has an 80% chance of passing down their ability if bred with a male. Since Gen 6, the chance is 80% for normal ability and 60% for Hidden Ability, and anyone can pass down their abilities if bred with Ditto. NOTE: BW's effect: 60% chance to pass down HA and random for normal ability has been omitted. +#define P_ABILITY_INHERITANCE GEN_LATEST // In B2W2, a female Pokémon has an 80% chance of passing down their ability if bred with a male. Since Gen 6, the chance is 80% for normal ability and 60% for Hidden Ability, and anyone can pass down their abilities if bred with Ditto. NOTE: BW's effect: 60% chance to pass down HA and random for normal ability has been omitted. #define P_EGG_MOVE_TRANSFER GEN_LATEST // Starting in Gen 8, if two Pokémon of the same species are together in the Daycare, one knows an Egg Move, and the other has an empty slot, the other Pokémon will receive the Egg Move in the empty slot. In Gen 9, if a Pokémon holds a Mirror Herb, it will receive Egg Moves from the other regardless of species. // Species-specific settings diff --git a/src/daycare.c b/src/daycare.c index 2997578d5..08b9ec23f 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -712,6 +712,35 @@ static void InheritPokeball(struct Pokemon *egg, struct BoxPokemon *father, stru SetMonData(egg, MON_DATA_POKEBALL, &inheritBall); } +static void InheritAbility(struct Pokemon *egg, struct BoxPokemon *father, struct BoxPokemon *mother) +{ + u8 fatherAbility = GetBoxMonData(father, MON_DATA_ABILITY_NUM); + u8 motherAbility = GetBoxMonData(mother, MON_DATA_ABILITY_NUM); + u8 motherSpecies = GetBoxMonData(mother, MON_DATA_SPECIES); + u8 inheritAbility = motherAbility; + + if (motherSpecies == SPECIES_DITTO) + #if P_ABILITY_INHERITANCE < GEN_6 + return; + #else + inheritAbility = fatherAbility; + #endif + + if (inheritAbility < 2 && (Random() % 10 < 8)) + { + SetMonData(egg, MON_DATA_ABILITY_NUM, &inheritAbility); + } +#if P_ABILITY_INHERITANCE < GEN_6 + else if (Random() % 10 < 8) +#else + else if (Random() % 10 < 6) +#endif + { + // Hidden Abilities have a different chance of being passed down + SetMonData(egg, MON_DATA_ABILITY_NUM, &inheritAbility); + } +} + // Counts the number of egg moves a pokemon learns and stores the moves in // the given array. static u8 GetEggMoves(struct Pokemon *pokemon, u16 *eggMoves) @@ -1000,6 +1029,9 @@ static void _GiveEggFromDaycare(struct DayCare *daycare) InheritIVs(&egg, daycare); InheritPokeball(&egg, &daycare->mons[parentSlots[1]].mon, &daycare->mons[parentSlots[0]].mon); BuildEggMoveset(&egg, &daycare->mons[parentSlots[1]].mon, &daycare->mons[parentSlots[0]].mon); +#if P_ABILITY_INHERITANCE >= GEN_8 + InheritAbility(&egg, &daycare->mons[parentSlots[1]].mon, &daycare->mons[parentSlots[0]].mon); +#endif GiveMoveIfItem(&egg, daycare); From 47cd903fdecc3d2636a30479fa698de720a5650d Mon Sep 17 00:00:00 2001 From: CallmeEchoo Date: Sun, 30 Apr 2023 18:02:41 +0200 Subject: [PATCH 35/51] update dire hit failing comment --- test/item_effect_set_focus_energy.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/item_effect_set_focus_energy.c b/test/item_effect_set_focus_energy.c index 72e90d610..19093e739 100644 --- a/test/item_effect_set_focus_energy.c +++ b/test/item_effect_set_focus_energy.c @@ -3,7 +3,10 @@ SINGLE_BATTLE_TEST("Dire Hit increases a battler's critical hit chance by 2 stages") { - KNOWN_FAILING; // Displays Message "Foe Wobbuffet used Dire Hit.." when facing off against Wobbuffet. Doesnt happen against other species? + /* KNOWN_FAILING due to message mismatch for "Wobbuffet used Dire Hit to get pumped!" + * As of the time of writing, this test passes if the above mentioned message is removed + * For more details refer to description of PR #2940 */ + KNOWN_FAILING; ASSUME(B_CRIT_CHANCE >= GEN_7); PASSES_RANDOMLY(1, 2, RNG_CRITICAL_HIT); GIVEN { From f1d60a4a04b13882c91ef2b5a0496119675e246b Mon Sep 17 00:00:00 2001 From: Bassoonian Date: Sun, 30 Apr 2023 22:52:37 +0200 Subject: [PATCH 36/51] Fixed wrong generation in check --- src/daycare.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/daycare.c b/src/daycare.c index 08b9ec23f..31a7bade0 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -1029,7 +1029,7 @@ static void _GiveEggFromDaycare(struct DayCare *daycare) InheritIVs(&egg, daycare); InheritPokeball(&egg, &daycare->mons[parentSlots[1]].mon, &daycare->mons[parentSlots[0]].mon); BuildEggMoveset(&egg, &daycare->mons[parentSlots[1]].mon, &daycare->mons[parentSlots[0]].mon); -#if P_ABILITY_INHERITANCE >= GEN_8 +#if P_ABILITY_INHERITANCE >= GEN_6 InheritAbility(&egg, &daycare->mons[parentSlots[1]].mon, &daycare->mons[parentSlots[0]].mon); #endif From 772c50408cf93957f545855c8ca9d8a660f64f84 Mon Sep 17 00:00:00 2001 From: CallmeEchoo Date: Sun, 30 Apr 2023 23:22:51 +0200 Subject: [PATCH 37/51] remove identifier strings no longer needed since testing is done. --- test/item_effect_cure_status.c | 34 ++++++++++++++++---------------- test/item_effect_increase_stat.c | 22 ++++++++++----------- test/item_effect_restore_hp.c | 26 ++++++++++++------------ test/item_effect_restore_pp.c | 8 ++++---- test/item_effect_revive.c | 8 ++++---- 5 files changed, 49 insertions(+), 49 deletions(-) diff --git a/test/item_effect_cure_status.c b/test/item_effect_cure_status.c index 949f60f0e..1f7c9d7a2 100644 --- a/test/item_effect_cure_status.c +++ b/test/item_effect_cure_status.c @@ -1,7 +1,7 @@ #include "global.h" #include "test_battle.h" -SINGLE_BATTLE_TEST("Cure Status: Paralyze Heal heals a battler from being paralyzed") +SINGLE_BATTLE_TEST("Paralyze Heal heals a battler from being paralyzed") { GIVEN { ASSUME(gItems[ITEM_PARALYZE_HEAL].battleUsage == EFFECT_ITEM_CURE_STATUS); @@ -16,7 +16,7 @@ SINGLE_BATTLE_TEST("Cure Status: Paralyze Heal heals a battler from being paraly } } -SINGLE_BATTLE_TEST("Cure Status: Antidote heals a battler from being poisoned") +SINGLE_BATTLE_TEST("Antidote heals a battler from being poisoned") { GIVEN { ASSUME(gItems[ITEM_ANTIDOTE].battleUsage == EFFECT_ITEM_CURE_STATUS); @@ -31,7 +31,7 @@ SINGLE_BATTLE_TEST("Cure Status: Antidote heals a battler from being poisoned") } } -SINGLE_BATTLE_TEST("Cure Status: Antidote heals a battler from being badly poisoned") +SINGLE_BATTLE_TEST("Antidote heals a battler from being badly poisoned") { GIVEN { ASSUME(gItems[ITEM_ANTIDOTE].battleUsage == EFFECT_ITEM_CURE_STATUS); @@ -46,7 +46,7 @@ SINGLE_BATTLE_TEST("Cure Status: Antidote heals a battler from being badly poiso } } -SINGLE_BATTLE_TEST("Cure Status: Awakening heals a battler from being asleep") +SINGLE_BATTLE_TEST("Awakening heals a battler from being asleep") { GIVEN { ASSUME(gItems[ITEM_AWAKENING].battleUsage == EFFECT_ITEM_CURE_STATUS); @@ -61,7 +61,7 @@ SINGLE_BATTLE_TEST("Cure Status: Awakening heals a battler from being asleep") } } -SINGLE_BATTLE_TEST("Cure Status: Burn Heal heals a battler from being burned") +SINGLE_BATTLE_TEST("Burn Heal heals a battler from being burned") { GIVEN { ASSUME(gItems[ITEM_BURN_HEAL].battleUsage == EFFECT_ITEM_CURE_STATUS); @@ -76,7 +76,7 @@ SINGLE_BATTLE_TEST("Cure Status: Burn Heal heals a battler from being burned") } } -SINGLE_BATTLE_TEST("Cure Status: Ice Heal heals a battler from being paralyzed") +SINGLE_BATTLE_TEST("Ice Heal heals a battler from being paralyzed") { GIVEN { ASSUME(gItems[ITEM_ICE_HEAL].battleUsage == EFFECT_ITEM_CURE_STATUS); @@ -91,7 +91,7 @@ SINGLE_BATTLE_TEST("Cure Status: Ice Heal heals a battler from being paralyzed") } } -SINGLE_BATTLE_TEST("Cure Status: Full Heal heals a battler from any primary status") +SINGLE_BATTLE_TEST("Full Heal heals a battler from any primary status") { u16 status; PARAMETRIZE{ status = STATUS1_BURN; } @@ -113,7 +113,7 @@ SINGLE_BATTLE_TEST("Cure Status: Full Heal heals a battler from any primary stat } } -SINGLE_BATTLE_TEST("Cure Status: Heal Powder heals a battler from any primary status") +SINGLE_BATTLE_TEST("Heal Powder heals a battler from any primary status") { u16 status; PARAMETRIZE{ status = STATUS1_BURN; } @@ -135,7 +135,7 @@ SINGLE_BATTLE_TEST("Cure Status: Heal Powder heals a battler from any primary st } } -SINGLE_BATTLE_TEST("Cure Status: Pewter Crunchies heals a battler from any primary status") +SINGLE_BATTLE_TEST("Pewter Crunchies heals a battler from any primary status") { u16 status; PARAMETRIZE{ status = STATUS1_BURN; } @@ -157,7 +157,7 @@ SINGLE_BATTLE_TEST("Cure Status: Pewter Crunchies heals a battler from any prima } } -SINGLE_BATTLE_TEST("Cure Status: Lava Cookies heals a battler from any primary status") +SINGLE_BATTLE_TEST("Lava Cookies heals a battler from any primary status") { u16 status; PARAMETRIZE{ status = STATUS1_BURN; } @@ -179,7 +179,7 @@ SINGLE_BATTLE_TEST("Cure Status: Lava Cookies heals a battler from any primary s } } -SINGLE_BATTLE_TEST("Cure Status: Rage Candy Bar heals a battler from any primary status") +SINGLE_BATTLE_TEST("Rage Candy Bar heals a battler from any primary status") { u16 status; PARAMETRIZE{ status = STATUS1_BURN; } @@ -201,7 +201,7 @@ SINGLE_BATTLE_TEST("Cure Status: Rage Candy Bar heals a battler from any primary } } -SINGLE_BATTLE_TEST("Cure Status: Old Gateu heals a battler from any primary status") +SINGLE_BATTLE_TEST("Old Gateu heals a battler from any primary status") { u16 status; PARAMETRIZE{ status = STATUS1_BURN; } @@ -223,7 +223,7 @@ SINGLE_BATTLE_TEST("Cure Status: Old Gateu heals a battler from any primary stat } } -SINGLE_BATTLE_TEST("Cure Status: Casteliacone heals a battler from any primary status") +SINGLE_BATTLE_TEST("Casteliacone heals a battler from any primary status") { u16 status; PARAMETRIZE{ status = STATUS1_BURN; } @@ -245,7 +245,7 @@ SINGLE_BATTLE_TEST("Cure Status: Casteliacone heals a battler from any primary s } } -SINGLE_BATTLE_TEST("Cure Status: Lumiose Galette heals a battler from any primary status") +SINGLE_BATTLE_TEST("Lumiose Galette heals a battler from any primary status") { u16 status; PARAMETRIZE{ status = STATUS1_BURN; } @@ -267,7 +267,7 @@ SINGLE_BATTLE_TEST("Cure Status: Lumiose Galette heals a battler from any primar } } -SINGLE_BATTLE_TEST("Cure Status: Shalour Sable heals a battler from any primary status") +SINGLE_BATTLE_TEST("Shalour Sable heals a battler from any primary status") { u16 status; PARAMETRIZE{ status = STATUS1_BURN; } @@ -289,7 +289,7 @@ SINGLE_BATTLE_TEST("Cure Status: Shalour Sable heals a battler from any primary } } -SINGLE_BATTLE_TEST("Cure Status: Big Malasada heals a battler from any primary status") +SINGLE_BATTLE_TEST("Big Malasada heals a battler from any primary status") { u16 status; PARAMETRIZE{ status = STATUS1_BURN; } @@ -311,7 +311,7 @@ SINGLE_BATTLE_TEST("Cure Status: Big Malasada heals a battler from any primary s } } -SINGLE_BATTLE_TEST("Cure Status: Full Heal, Heal Powder and Local Specialties heal a battler from being confused") +SINGLE_BATTLE_TEST("Full Heal, Heal Powder and Local Specialties heal a battler from being confused") { u16 item; PARAMETRIZE { item = ITEM_FULL_HEAL; } diff --git a/test/item_effect_increase_stat.c b/test/item_effect_increase_stat.c index bb5989207..bbaf20e2f 100644 --- a/test/item_effect_increase_stat.c +++ b/test/item_effect_increase_stat.c @@ -1,7 +1,7 @@ #include "global.h" #include "test_battle.h" -SINGLE_BATTLE_TEST("Increase Stat: X Attack sharply raises battler's Attack stat", s16 damage) +SINGLE_BATTLE_TEST("X Attack sharply raises battler's Attack stat", s16 damage) { u16 useItem; PARAMETRIZE { useItem = FALSE; } @@ -24,7 +24,7 @@ SINGLE_BATTLE_TEST("Increase Stat: X Attack sharply raises battler's Attack stat } } -SINGLE_BATTLE_TEST("Increase Stat: X Defense sharply raises battler's Defense stat", s16 damage) +SINGLE_BATTLE_TEST("X Defense sharply raises battler's Defense stat", s16 damage) { u16 useItem; PARAMETRIZE { useItem = FALSE; } @@ -47,7 +47,7 @@ SINGLE_BATTLE_TEST("Increase Stat: X Defense sharply raises battler's Defense st } } -SINGLE_BATTLE_TEST("Increase Stat: X Sp. Atk sharply raises battler's Sp. Attack stat", s16 damage) +SINGLE_BATTLE_TEST("X Sp. Atk sharply raises battler's Sp. Attack stat", s16 damage) { u16 useItem; PARAMETRIZE { useItem = FALSE; } @@ -70,7 +70,7 @@ SINGLE_BATTLE_TEST("Increase Stat: X Sp. Atk sharply raises battler's Sp. Attack } } -SINGLE_BATTLE_TEST("Increase Stat: X Sp. Def sharply raises battler's Sp. Defense stat", s16 damage) +SINGLE_BATTLE_TEST("X Sp. Def sharply raises battler's Sp. Defense stat", s16 damage) { u16 useItem; PARAMETRIZE { useItem = FALSE; } @@ -93,7 +93,7 @@ SINGLE_BATTLE_TEST("Increase Stat: X Sp. Def sharply raises battler's Sp. Defens } } -SINGLE_BATTLE_TEST("Increase Stat: X Speed sharply raises battler's Speed stat", s16 damage) +SINGLE_BATTLE_TEST("X Speed sharply raises battler's Speed stat", s16 damage) { u16 useItem; PARAMETRIZE { useItem = FALSE; } @@ -126,7 +126,7 @@ SINGLE_BATTLE_TEST("Increase Stat: X Speed sharply raises battler's Speed stat", } } -SINGLE_BATTLE_TEST("Increase Stat: X Accuracy sharply raises battler's Accuracy stat", s16 damage) +SINGLE_BATTLE_TEST("X Accuracy sharply raises battler's Accuracy stat", s16 damage) { ASSUME(gBattleMoves[MOVE_SING].accuracy == 55); @@ -147,7 +147,7 @@ SINGLE_BATTLE_TEST("Increase Stat: X Accuracy sharply raises battler's Accuracy } } -SINGLE_BATTLE_TEST("Increase Stat: Max Mushrooms raises battler's Attack stat", s16 damage) +SINGLE_BATTLE_TEST("Max Mushrooms raises battler's Attack stat", s16 damage) { u16 useItem; PARAMETRIZE { useItem = FALSE; } @@ -167,7 +167,7 @@ SINGLE_BATTLE_TEST("Increase Stat: Max Mushrooms raises battler's Attack stat", } } -SINGLE_BATTLE_TEST("Increase Stat: Max Mushrooms raises battler's Defense stat", s16 damage) +SINGLE_BATTLE_TEST("Max Mushrooms raises battler's Defense stat", s16 damage) { u16 useItem; PARAMETRIZE { useItem = FALSE; } @@ -187,7 +187,7 @@ SINGLE_BATTLE_TEST("Increase Stat: Max Mushrooms raises battler's Defense stat", } } -SINGLE_BATTLE_TEST("Increase Stat: Max Mushrooms raises battler's Sp. Attack stat", s16 damage) +SINGLE_BATTLE_TEST("Max Mushrooms raises battler's Sp. Attack stat", s16 damage) { u16 useItem; PARAMETRIZE { useItem = FALSE; } @@ -207,7 +207,7 @@ SINGLE_BATTLE_TEST("Increase Stat: Max Mushrooms raises battler's Sp. Attack sta } } -SINGLE_BATTLE_TEST("Increase Stat: Max Mushrooms battler's Sp. Defense stat", s16 damage) +SINGLE_BATTLE_TEST("Max Mushrooms battler's Sp. Defense stat", s16 damage) { u16 useItem; PARAMETRIZE { useItem = FALSE; } @@ -227,7 +227,7 @@ SINGLE_BATTLE_TEST("Increase Stat: Max Mushrooms battler's Sp. Defense stat", s1 } } -SINGLE_BATTLE_TEST("Increase Stat: Max Mushrooms raises battler's Speed stat", s16 damage) +SINGLE_BATTLE_TEST("Max Mushrooms raises battler's Speed stat", s16 damage) { u16 useItem; PARAMETRIZE { useItem = FALSE; } diff --git a/test/item_effect_restore_hp.c b/test/item_effect_restore_hp.c index 4572a0d8b..4662e9f25 100644 --- a/test/item_effect_restore_hp.c +++ b/test/item_effect_restore_hp.c @@ -4,7 +4,7 @@ #define TEST_HP 1 #define MAX_HP 400 -SINGLE_BATTLE_TEST("Restore HP: Potion restores a battler's HP by 20") +SINGLE_BATTLE_TEST("Potion restores a battler's HP by 20") { GIVEN { ASSUME(gItems[ITEM_POTION].battleUsage == EFFECT_ITEM_RESTORE_HP); @@ -17,7 +17,7 @@ SINGLE_BATTLE_TEST("Restore HP: Potion restores a battler's HP by 20") } } -SINGLE_BATTLE_TEST("Restore HP: Super Potion restores a battler's HP by 60") +SINGLE_BATTLE_TEST("Super Potion restores a battler's HP by 60") { GIVEN { ASSUME(gItems[ITEM_SUPER_POTION].battleUsage == EFFECT_ITEM_RESTORE_HP); @@ -30,7 +30,7 @@ SINGLE_BATTLE_TEST("Restore HP: Super Potion restores a battler's HP by 60") } } -SINGLE_BATTLE_TEST("Restore HP: Hyper Potion restores a battler's HP by 120") +SINGLE_BATTLE_TEST("Hyper Potion restores a battler's HP by 120") { GIVEN { ASSUME(gItems[ITEM_HYPER_POTION].battleUsage == EFFECT_ITEM_RESTORE_HP); @@ -43,7 +43,7 @@ SINGLE_BATTLE_TEST("Restore HP: Hyper Potion restores a battler's HP by 120") } } -SINGLE_BATTLE_TEST("Restore HP: Max Potion restores a battler's HP fully") +SINGLE_BATTLE_TEST("Max Potion restores a battler's HP fully") { GIVEN { ASSUME(gItems[ITEM_MAX_POTION].battleUsage == EFFECT_ITEM_RESTORE_HP); @@ -56,7 +56,7 @@ SINGLE_BATTLE_TEST("Restore HP: Max Potion restores a battler's HP fully") } } -SINGLE_BATTLE_TEST("Restore HP: Fresh Water restores a battler's HP by 30") +SINGLE_BATTLE_TEST("Fresh Water restores a battler's HP by 30") { GIVEN { ASSUME(gItems[ITEM_FRESH_WATER].battleUsage == EFFECT_ITEM_RESTORE_HP); @@ -69,7 +69,7 @@ SINGLE_BATTLE_TEST("Restore HP: Fresh Water restores a battler's HP by 30") } } -SINGLE_BATTLE_TEST("Restore HP: Soda Pop restores a battler's HP by 50") +SINGLE_BATTLE_TEST("Soda Pop restores a battler's HP by 50") { GIVEN { ASSUME(gItems[ITEM_SODA_POP].battleUsage == EFFECT_ITEM_RESTORE_HP); @@ -82,7 +82,7 @@ SINGLE_BATTLE_TEST("Restore HP: Soda Pop restores a battler's HP by 50") } } -SINGLE_BATTLE_TEST("Restore HP: Lemonade restores a battler's HP by 70") +SINGLE_BATTLE_TEST("Lemonade restores a battler's HP by 70") { GIVEN { ASSUME(gItems[ITEM_LEMONADE].battleUsage == EFFECT_ITEM_RESTORE_HP); @@ -95,7 +95,7 @@ SINGLE_BATTLE_TEST("Restore HP: Lemonade restores a battler's HP by 70") } } -SINGLE_BATTLE_TEST("Restore HP: Moomoo Milk restores a battler's HP by 100") +SINGLE_BATTLE_TEST("Moomoo Milk restores a battler's HP by 100") { GIVEN { ASSUME(gItems[ITEM_MOOMOO_MILK].battleUsage == EFFECT_ITEM_RESTORE_HP); @@ -108,7 +108,7 @@ SINGLE_BATTLE_TEST("Restore HP: Moomoo Milk restores a battler's HP by 100") } } -SINGLE_BATTLE_TEST("Restore HP: Energy Powder restores a battler's HP by 60(50)") +SINGLE_BATTLE_TEST("Energy Powder restores a battler's HP by 60(50)") { GIVEN { ASSUME(gItems[ITEM_ENERGY_POWDER].battleUsage == EFFECT_ITEM_RESTORE_HP); @@ -124,7 +124,7 @@ SINGLE_BATTLE_TEST("Restore HP: Energy Powder restores a battler's HP by 60(50)" } } -SINGLE_BATTLE_TEST("Restore HP: Energy Root restores a battler's HP by 120(200)") +SINGLE_BATTLE_TEST("Energy Root restores a battler's HP by 120(200)") { GIVEN { ASSUME(gItems[ITEM_ENERGY_ROOT].battleUsage == EFFECT_ITEM_RESTORE_HP); @@ -140,7 +140,7 @@ SINGLE_BATTLE_TEST("Restore HP: Energy Root restores a battler's HP by 120(200)" } } -SINGLE_BATTLE_TEST("Restore HP: Sweet Heart restores a battler's HP by 20") +SINGLE_BATTLE_TEST("Sweet Heart restores a battler's HP by 20") { GIVEN { ASSUME(gItems[ITEM_SWEET_HEART].battleUsage == EFFECT_ITEM_RESTORE_HP); @@ -153,7 +153,7 @@ SINGLE_BATTLE_TEST("Restore HP: Sweet Heart restores a battler's HP by 20") } } -SINGLE_BATTLE_TEST("Restore HP: Oran Berry restores a battler's HP by 10") +SINGLE_BATTLE_TEST("Oran Berry restores a battler's HP by 10") { GIVEN { ASSUME(gItems[ITEM_ORAN_BERRY].battleUsage == EFFECT_ITEM_RESTORE_HP); @@ -166,7 +166,7 @@ SINGLE_BATTLE_TEST("Restore HP: Oran Berry restores a battler's HP by 10") } } -SINGLE_BATTLE_TEST("Restore HP: Sitrus Berry restores a battler's HP by 25% of its max HP(30HP flat)") +SINGLE_BATTLE_TEST("Sitrus Berry restores a battler's HP by 25% of its max HP(30HP flat)") { GIVEN { ASSUME(gItems[ITEM_SITRUS_BERRY].battleUsage == EFFECT_ITEM_RESTORE_HP); diff --git a/test/item_effect_restore_pp.c b/test/item_effect_restore_pp.c index f21593566..7194efbbb 100644 --- a/test/item_effect_restore_pp.c +++ b/test/item_effect_restore_pp.c @@ -1,7 +1,7 @@ #include "global.h" #include "test_battle.h" -SINGLE_BATTLE_TEST("Restore PP: Ether restores the PP of one of a battler's moves by 10 ") +SINGLE_BATTLE_TEST("Ether restores the PP of one of a battler's moves by 10 ") { GIVEN { ASSUME(gItems[ITEM_ETHER].battleUsage == EFFECT_ITEM_RESTORE_PP); @@ -16,7 +16,7 @@ SINGLE_BATTLE_TEST("Restore PP: Ether restores the PP of one of a battler's move } } -SINGLE_BATTLE_TEST("Restore PP: Max Ether restores the PP of one of a battler's moves fully") +SINGLE_BATTLE_TEST("Max Ether restores the PP of one of a battler's moves fully") { GIVEN { ASSUME(gItems[ITEM_MAX_ETHER].battleUsage == EFFECT_ITEM_RESTORE_PP); @@ -31,7 +31,7 @@ SINGLE_BATTLE_TEST("Restore PP: Max Ether restores the PP of one of a battler's } } -SINGLE_BATTLE_TEST("Restore PP: Elixir restores the PP of all of a battler's moves by 10") +SINGLE_BATTLE_TEST("Elixir restores the PP of all of a battler's moves by 10") { GIVEN { ASSUME(gItems[ITEM_ELIXIR].battleUsage == EFFECT_ITEM_RESTORE_PP); @@ -48,7 +48,7 @@ SINGLE_BATTLE_TEST("Restore PP: Elixir restores the PP of all of a battler's mov } } -SINGLE_BATTLE_TEST("Restore PP: Max Elixir restores the PP of all of a battler's moves fully") +SINGLE_BATTLE_TEST("Max Elixir restores the PP of all of a battler's moves fully") { GIVEN { ASSUME(gItems[ITEM_MAX_ELIXIR].battleUsage == EFFECT_ITEM_RESTORE_PP); diff --git a/test/item_effect_revive.c b/test/item_effect_revive.c index 3c6995176..77423fff1 100644 --- a/test/item_effect_revive.c +++ b/test/item_effect_revive.c @@ -3,7 +3,7 @@ #define MAX_HP 200 -SINGLE_BATTLE_TEST("Revive: Revive restores a fainted battler's HP to half") +SINGLE_BATTLE_TEST("Revive restores a fainted battler's HP to half") { GIVEN { ASSUME(gItems[ITEM_REVIVE].battleUsage == EFFECT_ITEM_REVIVE); @@ -21,7 +21,7 @@ SINGLE_BATTLE_TEST("Revive: Revive restores a fainted battler's HP to half") } } -SINGLE_BATTLE_TEST("Revive: Max Revive restores a fainted battler's HP fully") +SINGLE_BATTLE_TEST("Max Revive restores a fainted battler's HP fully") { GIVEN { ASSUME(gItems[ITEM_MAX_REVIVE].battleUsage == EFFECT_ITEM_REVIVE); @@ -39,7 +39,7 @@ SINGLE_BATTLE_TEST("Revive: Max Revive restores a fainted battler's HP fully") } } -SINGLE_BATTLE_TEST("Revive: Revival Herb restores a fainted battler's HP fully") +SINGLE_BATTLE_TEST("Revival Herb restores a fainted battler's HP fully") { GIVEN { ASSUME(gItems[ITEM_REVIVAL_HERB].battleUsage == EFFECT_ITEM_REVIVE); @@ -57,7 +57,7 @@ SINGLE_BATTLE_TEST("Revive: Revival Herb restores a fainted battler's HP fully") } } -SINGLE_BATTLE_TEST("Revive: Max Honey restores a fainted battler's HP fully") +SINGLE_BATTLE_TEST("Max Honey restores a fainted battler's HP fully") { GIVEN { ASSUME(gItems[ITEM_MAX_HONEY].battleUsage == EFFECT_ITEM_REVIVE); From 15ce9eb71cde27b9142bb20c067fef19333ca852 Mon Sep 17 00:00:00 2001 From: CallmeEchoo Date: Mon, 1 May 2023 18:53:06 +0200 Subject: [PATCH 38/51] fix dire hit message mismatch --- src/battle_message.c | 2 +- test/item_effect_set_focus_energy.c | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/battle_message.c b/src/battle_message.c index 21f7098f8..cf42176a1 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -260,7 +260,7 @@ static const u8 sText_XFoundOneY[] = _("{B_ATK_NAME_WITH_PREFIX} found\none {B_L static const u8 sText_SoothingAroma[] = _("A soothing aroma wafted\nthrough the area!"); static const u8 sText_ItemsCantBeUsedNow[] = _("Items can't be used now.{PAUSE 64}"); static const u8 sText_ForXCommaYZ[] = _("For {B_SCR_ACTIVE_NAME_WITH_PREFIX},\n{B_LAST_ITEM} {B_BUFF1}"); -static const u8 sText_PkmnUsedXToGetPumped[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} used\n{B_LAST_ITEM} to get pumped!"); +static const u8 sText_PkmnUsedXToGetPumped[] = _("{B_ACTIVE_NAME_WITH_PREFIX} used\n{B_LAST_ITEM} to get pumped!"); static const u8 sText_PkmnLostFocus[] = _("{B_ATK_NAME_WITH_PREFIX} lost its\nfocus and couldn't move!"); static const u8 sText_PkmnWasDraggedOut[] = _("{B_DEF_NAME_WITH_PREFIX} was\ndragged out!\p"); static const u8 sText_TheWallShattered[] = _("The wall shattered!"); diff --git a/test/item_effect_set_focus_energy.c b/test/item_effect_set_focus_energy.c index 19093e739..95648465e 100644 --- a/test/item_effect_set_focus_energy.c +++ b/test/item_effect_set_focus_energy.c @@ -3,10 +3,6 @@ SINGLE_BATTLE_TEST("Dire Hit increases a battler's critical hit chance by 2 stages") { - /* KNOWN_FAILING due to message mismatch for "Wobbuffet used Dire Hit to get pumped!" - * As of the time of writing, this test passes if the above mentioned message is removed - * For more details refer to description of PR #2940 */ - KNOWN_FAILING; ASSUME(B_CRIT_CHANCE >= GEN_7); PASSES_RANDOMLY(1, 2, RNG_CRITICAL_HIT); GIVEN { From bdd0195fe01963e81dfe09c5b8e2368a1d12f0be Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Mon, 1 May 2023 17:00:37 -0400 Subject: [PATCH 39/51] add mirror herb tests --- test/hold_effect_mirror_herb.c | 51 ++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 test/hold_effect_mirror_herb.c diff --git a/test/hold_effect_mirror_herb.c b/test/hold_effect_mirror_herb.c new file mode 100644 index 000000000..68ea5614b --- /dev/null +++ b/test/hold_effect_mirror_herb.c @@ -0,0 +1,51 @@ +#include "global.h" +#include "test_battle.h" + +ASSUMPTIONS +{ + gItems[ITEM_MIRROR_HERB].holdEffect == HOLD_EFFECT_MIRROR_HERB; +}; + +SINGLE_BATTLE_TEST("Mirror Herb copies all of foe's stat changes in a turn", s16 damage) +{ + u32 item; + PARAMETRIZE{ item = ITEM_NONE; } + PARAMETRIZE{ item = ITEM_MIRROR_HERB; } + GIVEN { + ASSUME(gItems[ITEM_MIRROR_HERB].holdEffect == HOLD_EFFECT_MIRROR_HERB); + PLAYER(SPECIES_WOBBUFFET) { Speed(4); } + OPPONENT(SPECIES_WOBBUFFET) { Speed(5); Item(item); } + } WHEN { + TURN { MOVE(player, MOVE_DRAGON_DANCE); } + TURN { MOVE(player, MOVE_TACKLE); MOVE(opponent, MOVE_TACKLE); } + } SCENE { + if (item == ITEM_NONE) { + ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, player); + ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, opponent); + HP_BAR(player, captureDamage: &results[i].damage); + } else { + ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, opponent); + HP_BAR(player, captureDamage: &results[i].damage); + ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, player); + } + } FINALLY { + EXPECT_MUL_EQ(results[0].damage, Q_4_12(1.5), results[1].damage); + EXPECT_EQ(player->statStages[STAT_ATK], opponent->statStages[STAT_ATK]); + EXPECT_EQ(player->statStages[STAT_SPEED], opponent->statStages[STAT_SPEED]); + } +} + +SINGLE_BATTLE_TEST("Mirror Herb copies all of of Stuff Cheeks", s16 damage) +{ + GIVEN { + ASSUME(gItems[ITEM_MIRROR_HERB].holdEffect == HOLD_EFFECT_MIRROR_HERB); + ASSUME(gItems[ITEM_LIECHI_BERRY].holdEffect == HOLD_EFFECT_ATTACK_UP); + PLAYER(SPECIES_SKWOVET) { Item(ITEM_LIECHI_BERRY); } + OPPONENT(SPECIES_WOBBUFFET) { Item(ITEM_MIRROR_HERB); } + } WHEN { + TURN { MOVE(player, MOVE_STUFF_CHEEKS); } + } THEN { + EXPECT_EQ(player->statStages[STAT_ATK], opponent->statStages[STAT_ATK]); + EXPECT_EQ(player->statStages[STAT_DEF], opponent->statStages[STAT_DEF]); + } +} From 3652e8261a3fa8575c0f54a194d562f5c11f434c Mon Sep 17 00:00:00 2001 From: ghoulslash <41651341+ghoulslash@users.noreply.github.com> Date: Mon, 1 May 2023 15:09:20 -0600 Subject: [PATCH 40/51] Apply suggestions from code review Co-authored-by: Salem <65783283+CallmeEchoo@users.noreply.github.com> --- test/hold_effect_mirror_herb.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/hold_effect_mirror_herb.c b/test/hold_effect_mirror_herb.c index 68ea5614b..b1c3c8132 100644 --- a/test/hold_effect_mirror_herb.c +++ b/test/hold_effect_mirror_herb.c @@ -3,7 +3,7 @@ ASSUMPTIONS { - gItems[ITEM_MIRROR_HERB].holdEffect == HOLD_EFFECT_MIRROR_HERB; + ASSUME(gItems[ITEM_MIRROR_HERB].holdEffect == HOLD_EFFECT_MIRROR_HERB); }; SINGLE_BATTLE_TEST("Mirror Herb copies all of foe's stat changes in a turn", s16 damage) @@ -12,7 +12,6 @@ SINGLE_BATTLE_TEST("Mirror Herb copies all of foe's stat changes in a turn", s16 PARAMETRIZE{ item = ITEM_NONE; } PARAMETRIZE{ item = ITEM_MIRROR_HERB; } GIVEN { - ASSUME(gItems[ITEM_MIRROR_HERB].holdEffect == HOLD_EFFECT_MIRROR_HERB); PLAYER(SPECIES_WOBBUFFET) { Speed(4); } OPPONENT(SPECIES_WOBBUFFET) { Speed(5); Item(item); } } WHEN { @@ -38,7 +37,6 @@ SINGLE_BATTLE_TEST("Mirror Herb copies all of foe's stat changes in a turn", s16 SINGLE_BATTLE_TEST("Mirror Herb copies all of of Stuff Cheeks", s16 damage) { GIVEN { - ASSUME(gItems[ITEM_MIRROR_HERB].holdEffect == HOLD_EFFECT_MIRROR_HERB); ASSUME(gItems[ITEM_LIECHI_BERRY].holdEffect == HOLD_EFFECT_ATTACK_UP); PLAYER(SPECIES_SKWOVET) { Item(ITEM_LIECHI_BERRY); } OPPONENT(SPECIES_WOBBUFFET) { Item(ITEM_MIRROR_HERB); } From 63c2e8a7d98b50921bdc1398dfb41bf04326de4e Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Mon, 1 May 2023 18:02:21 -0400 Subject: [PATCH 41/51] small mirror herb test synta fix --- test/hold_effect_mirror_herb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/hold_effect_mirror_herb.c b/test/hold_effect_mirror_herb.c index b1c3c8132..fc0a6de95 100644 --- a/test/hold_effect_mirror_herb.c +++ b/test/hold_effect_mirror_herb.c @@ -4,7 +4,7 @@ ASSUMPTIONS { ASSUME(gItems[ITEM_MIRROR_HERB].holdEffect == HOLD_EFFECT_MIRROR_HERB); -}; +} SINGLE_BATTLE_TEST("Mirror Herb copies all of foe's stat changes in a turn", s16 damage) { From 957ee36c75cac33e83eadf540d440164b2902adf Mon Sep 17 00:00:00 2001 From: Alex <93446519+AlexOn1ine@users.noreply.github.com> Date: Tue, 2 May 2023 23:25:44 +0200 Subject: [PATCH 42/51] Fix for Ceaseless Edge/Axe Kick visual glitch (#2969) --- data/battle_scripts_1.s | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 575c88939..23a7632bd 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -452,7 +452,7 @@ BattleScript_StealthRockActivates:: setstealthrock BattleScript_MoveEnd printfromtable gDmgHazardsStringIds waitmessage B_WAIT_TIME_LONG - goto BattleScript_MoveEnd + return BattleScript_EffectDireClaw:: setmoveeffect MOVE_EFFECT_DIRE_CLAW @@ -466,7 +466,7 @@ BattleScript_SpikesActivates:: trysetspikes BattleScript_MoveEnd printfromtable gDmgHazardsStringIds waitmessage B_WAIT_TIME_LONG - goto BattleScript_MoveEnd + return BattleScript_EffectAttackUpUserAlly: jumpifnoally BS_ATTACKER, BattleScript_EffectAttackUp From 1068ec5d9fcf8a6550b1f37d78f4c719c077245b Mon Sep 17 00:00:00 2001 From: Bassoonian Date: Wed, 3 May 2023 13:03:40 +0200 Subject: [PATCH 43/51] Fix Plus/Minus to only work with special moves --- src/battle_util.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/battle_util.c b/src/battle_util.c index 402af3544..831e65829 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -9255,7 +9255,7 @@ static u32 CalcAttackStat(u16 move, u8 battlerAtk, u8 battlerDef, u8 moveType, b #if B_PLUS_MINUS_INTERACTION >= GEN_5 case ABILITY_PLUS: case ABILITY_MINUS: - if (IsBattlerAlive(BATTLE_PARTNER(battlerAtk))) + if (IS_MOVE_SPECIAL(move) && IsBattlerAlive(BATTLE_PARTNER(battlerAtk))) { u32 partnerAbility = GetBattlerAbility(BATTLE_PARTNER(battlerAtk)); if (partnerAbility == ABILITY_PLUS || partnerAbility == ABILITY_MINUS) @@ -9264,11 +9264,11 @@ static u32 CalcAttackStat(u16 move, u8 battlerAtk, u8 battlerDef, u8 moveType, b break; #else case ABILITY_PLUS: - if (IsBattlerAlive(BATTLE_PARTNER(battlerAtk)) && GetBattlerAbility(BATTLE_PARTNER(battlerAtk)) == ABILITY_MINUS) + if (IS_MOVE_SPECIAL(move) && IsBattlerAlive(BATTLE_PARTNER(battlerAtk)) && GetBattlerAbility(BATTLE_PARTNER(battlerAtk)) == ABILITY_MINUS) MulModifier(&modifier, UQ_4_12(1.5)); break; case ABILITY_MINUS: - if (IsBattlerAlive(BATTLE_PARTNER(battlerAtk)) && GetBattlerAbility(BATTLE_PARTNER(battlerAtk)) == ABILITY_PLUS) + if (IS_MOVE_SPECIAL(move) && IsBattlerAlive(BATTLE_PARTNER(battlerAtk)) && GetBattlerAbility(BATTLE_PARTNER(battlerAtk)) == ABILITY_PLUS) MulModifier(&modifier, UQ_4_12(1.5)); break; #endif From 069627a7fc03b3f699059b93d2cd8bf5d6e00e49 Mon Sep 17 00:00:00 2001 From: Bassoonian Date: Wed, 3 May 2023 15:36:17 +0200 Subject: [PATCH 44/51] Hydra OSX support --- Makefile | 2 +- tools/mgba-rom-test-hydra/main.c | 40 +- tools/patchelf/elf.h | 3147 ++++++++++++++++++++++++++++++ tools/patchelf/patchelf.c | 2 +- 4 files changed, 3186 insertions(+), 5 deletions(-) create mode 100644 tools/patchelf/elf.h diff --git a/Makefile b/Makefile index 87bd771b0..7486e41f0 100644 --- a/Makefile +++ b/Makefile @@ -480,7 +480,7 @@ endif check: $(TESTELF) @cp $< $(HEADLESSELF) $(PATCHELF) $(HEADLESSELF) gTestRunnerHeadless '\x01' gTestRunnerSkipIsFail "$(TEST_SKIP_IS_FAIL)" - $(ROMTESTHYDRA) $(ROMTEST) $(HEADLESSELF) + $(ROMTESTHYDRA) $(ROMTEST) $(OBJCOPY) $(HEADLESSELF) libagbsyscall: @$(MAKE) -C libagbsyscall TOOLCHAIN=$(TOOLCHAIN) MODERN=$(MODERN) diff --git a/tools/mgba-rom-test-hydra/main.c b/tools/mgba-rom-test-hydra/main.c index 8705225b8..2e2fe7ce8 100644 --- a/tools/mgba-rom-test-hydra/main.c +++ b/tools/mgba-rom-test-hydra/main.c @@ -23,7 +23,9 @@ #include #include #include +#ifndef __APPLE__ #include +#endif #include #include #include @@ -176,9 +178,9 @@ static void exit2(int _) int main(int argc, char *argv[]) { - if (argc < 3) + if (argc < 4) { - fprintf(stderr, "usage %s mgba-rom-test rom\n", argv[0]); + fprintf(stderr, "usage %s mgba-rom-test objcopy rom\n", argv[0]); exit(2); } @@ -205,7 +207,7 @@ int main(int argc, char *argv[]) } int elffd; - if ((elffd = open(argv[2], O_RDONLY)) == -1) + if ((elffd = open(argv[3], O_RDONLY)) == -1) { perror("open elffd failed"); exit(2); @@ -264,11 +266,13 @@ int main(int argc, char *argv[]) perror("fork mgba-rom-test failed"); exit(2); } else if (pid == 0) { + #ifndef __APPLE__ if (prctl(PR_SET_PDEATHSIG, SIGTERM) == -1) { perror("prctl failed"); _exit(2); } + #endif if (getppid() != parent_pid) // Parent died. { _exit(2); @@ -332,6 +336,36 @@ int main(int argc, char *argv[]) _exit(2); } } +#ifdef __APPLE__ + pid_t objcopypid = fork(); + if (objcopypid == -1) + { + perror("fork objcopy failed"); + _exit(2); + } + else if (objcopypid == 0) + { + if (execlp(argv[2], argv[2], "-O", "binary", rom_path, rom_path, NULL) == -1) + { + perror("execlp objcopy failed"); + _exit(2); + } + } + else + { + int wstatus; + if (waitpid(objcopypid, &wstatus, 0) == -1) + { + perror("waitpid objcopy failed"); + _exit(2); + } + if (!WIFEXITED(wstatus) || WEXITSTATUS(wstatus) != 0) + { + fprintf(stderr, "objcopy exited with an error\n"); + _exit(2); + } + } +#endif // stdbuf is required because otherwise mgba never flushes // stdout. if (execlp("stdbuf", "stdbuf", "-oL", argv[1], "-l15", "-ClogLevel.gba.dma=16", "-Rr0", rom_path, NULL) == -1) diff --git a/tools/patchelf/elf.h b/tools/patchelf/elf.h new file mode 100644 index 000000000..79d3b974b --- /dev/null +++ b/tools/patchelf/elf.h @@ -0,0 +1,3147 @@ +/* +From musl include/elf.h + +Copyright © 2005-2014 Rich Felker, et al. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef _ELF_H +#define _ELF_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +typedef uint16_t Elf32_Half; +typedef uint16_t Elf64_Half; + +typedef uint32_t Elf32_Word; +typedef int32_t Elf32_Sword; +typedef uint32_t Elf64_Word; +typedef int32_t Elf64_Sword; + +typedef uint64_t Elf32_Xword; +typedef int64_t Elf32_Sxword; +typedef uint64_t Elf64_Xword; +typedef int64_t Elf64_Sxword; + +typedef uint32_t Elf32_Addr; +typedef uint64_t Elf64_Addr; + +typedef uint32_t Elf32_Off; +typedef uint64_t Elf64_Off; + +typedef uint16_t Elf32_Section; +typedef uint16_t Elf64_Section; + +typedef Elf32_Half Elf32_Versym; +typedef Elf64_Half Elf64_Versym; + +#define EI_NIDENT (16) + +typedef struct { + unsigned char e_ident[EI_NIDENT]; + Elf32_Half e_type; + Elf32_Half e_machine; + Elf32_Word e_version; + Elf32_Addr e_entry; + Elf32_Off e_phoff; + Elf32_Off e_shoff; + Elf32_Word e_flags; + Elf32_Half e_ehsize; + Elf32_Half e_phentsize; + Elf32_Half e_phnum; + Elf32_Half e_shentsize; + Elf32_Half e_shnum; + Elf32_Half e_shstrndx; +} Elf32_Ehdr; + +typedef struct { + unsigned char e_ident[EI_NIDENT]; + Elf64_Half e_type; + Elf64_Half e_machine; + Elf64_Word e_version; + Elf64_Addr e_entry; + Elf64_Off e_phoff; + Elf64_Off e_shoff; + Elf64_Word e_flags; + Elf64_Half e_ehsize; + Elf64_Half e_phentsize; + Elf64_Half e_phnum; + Elf64_Half e_shentsize; + Elf64_Half e_shnum; + Elf64_Half e_shstrndx; +} Elf64_Ehdr; + +#define EI_MAG0 0 +#define ELFMAG0 0x7f + +#define EI_MAG1 1 +#define ELFMAG1 'E' + +#define EI_MAG2 2 +#define ELFMAG2 'L' + +#define EI_MAG3 3 +#define ELFMAG3 'F' + + +#define ELFMAG "\177ELF" +#define SELFMAG 4 + +#define EI_CLASS 4 +#define ELFCLASSNONE 0 +#define ELFCLASS32 1 +#define ELFCLASS64 2 +#define ELFCLASSNUM 3 + +#define EI_DATA 5 +#define ELFDATANONE 0 +#define ELFDATA2LSB 1 +#define ELFDATA2MSB 2 +#define ELFDATANUM 3 + +#define EI_VERSION 6 + + +#define EI_OSABI 7 +#define ELFOSABI_NONE 0 +#define ELFOSABI_SYSV 0 +#define ELFOSABI_HPUX 1 +#define ELFOSABI_NETBSD 2 +#define ELFOSABI_LINUX 3 +#define ELFOSABI_GNU 3 +#define ELFOSABI_SOLARIS 6 +#define ELFOSABI_AIX 7 +#define ELFOSABI_IRIX 8 +#define ELFOSABI_FREEBSD 9 +#define ELFOSABI_TRU64 10 +#define ELFOSABI_MODESTO 11 +#define ELFOSABI_OPENBSD 12 +#define ELFOSABI_ARM 97 +#define ELFOSABI_STANDALONE 255 + +#define EI_ABIVERSION 8 + +#define EI_PAD 9 + + + +#define ET_NONE 0 +#define ET_REL 1 +#define ET_EXEC 2 +#define ET_DYN 3 +#define ET_CORE 4 +#define ET_NUM 5 +#define ET_LOOS 0xfe00 +#define ET_HIOS 0xfeff +#define ET_LOPROC 0xff00 +#define ET_HIPROC 0xffff + + + +#define EM_NONE 0 +#define EM_M32 1 +#define EM_SPARC 2 +#define EM_386 3 +#define EM_68K 4 +#define EM_88K 5 +#define EM_860 7 +#define EM_MIPS 8 +#define EM_S370 9 +#define EM_MIPS_RS3_LE 10 + +#define EM_PARISC 15 +#define EM_VPP500 17 +#define EM_SPARC32PLUS 18 +#define EM_960 19 +#define EM_PPC 20 +#define EM_PPC64 21 +#define EM_S390 22 + +#define EM_V800 36 +#define EM_FR20 37 +#define EM_RH32 38 +#define EM_RCE 39 +#define EM_ARM 40 +#define EM_FAKE_ALPHA 41 +#define EM_SH 42 +#define EM_SPARCV9 43 +#define EM_TRICORE 44 +#define EM_ARC 45 +#define EM_H8_300 46 +#define EM_H8_300H 47 +#define EM_H8S 48 +#define EM_H8_500 49 +#define EM_IA_64 50 +#define EM_MIPS_X 51 +#define EM_COLDFIRE 52 +#define EM_68HC12 53 +#define EM_MMA 54 +#define EM_PCP 55 +#define EM_NCPU 56 +#define EM_NDR1 57 +#define EM_STARCORE 58 +#define EM_ME16 59 +#define EM_ST100 60 +#define EM_TINYJ 61 +#define EM_X86_64 62 +#define EM_PDSP 63 + +#define EM_FX66 66 +#define EM_ST9PLUS 67 +#define EM_ST7 68 +#define EM_68HC16 69 +#define EM_68HC11 70 +#define EM_68HC08 71 +#define EM_68HC05 72 +#define EM_SVX 73 +#define EM_ST19 74 +#define EM_VAX 75 +#define EM_CRIS 76 +#define EM_JAVELIN 77 +#define EM_FIREPATH 78 +#define EM_ZSP 79 +#define EM_MMIX 80 +#define EM_HUANY 81 +#define EM_PRISM 82 +#define EM_AVR 83 +#define EM_FR30 84 +#define EM_D10V 85 +#define EM_D30V 86 +#define EM_V850 87 +#define EM_M32R 88 +#define EM_MN10300 89 +#define EM_MN10200 90 +#define EM_PJ 91 +#define EM_OR1K 92 +#define EM_OPENRISC 92 +#define EM_ARC_A5 93 +#define EM_ARC_COMPACT 93 +#define EM_XTENSA 94 +#define EM_VIDEOCORE 95 +#define EM_TMM_GPP 96 +#define EM_NS32K 97 +#define EM_TPC 98 +#define EM_SNP1K 99 +#define EM_ST200 100 +#define EM_IP2K 101 +#define EM_MAX 102 +#define EM_CR 103 +#define EM_F2MC16 104 +#define EM_MSP430 105 +#define EM_BLACKFIN 106 +#define EM_SE_C33 107 +#define EM_SEP 108 +#define EM_ARCA 109 +#define EM_UNICORE 110 +#define EM_EXCESS 111 +#define EM_DXP 112 +#define EM_ALTERA_NIOS2 113 +#define EM_CRX 114 +#define EM_XGATE 115 +#define EM_C166 116 +#define EM_M16C 117 +#define EM_DSPIC30F 118 +#define EM_CE 119 +#define EM_M32C 120 +#define EM_TSK3000 131 +#define EM_RS08 132 +#define EM_SHARC 133 +#define EM_ECOG2 134 +#define EM_SCORE7 135 +#define EM_DSP24 136 +#define EM_VIDEOCORE3 137 +#define EM_LATTICEMICO32 138 +#define EM_SE_C17 139 +#define EM_TI_C6000 140 +#define EM_TI_C2000 141 +#define EM_TI_C5500 142 +#define EM_TI_ARP32 143 +#define EM_TI_PRU 144 +#define EM_MMDSP_PLUS 160 +#define EM_CYPRESS_M8C 161 +#define EM_R32C 162 +#define EM_TRIMEDIA 163 +#define EM_QDSP6 164 +#define EM_8051 165 +#define EM_STXP7X 166 +#define EM_NDS32 167 +#define EM_ECOG1X 168 +#define EM_MAXQ30 169 +#define EM_XIMO16 170 +#define EM_MANIK 171 +#define EM_CRAYNV2 172 +#define EM_RX 173 +#define EM_METAG 174 +#define EM_MCST_ELBRUS 175 +#define EM_ECOG16 176 +#define EM_CR16 177 +#define EM_ETPU 178 +#define EM_SLE9X 179 +#define EM_L10M 180 +#define EM_K10M 181 +#define EM_AARCH64 183 +#define EM_AVR32 185 +#define EM_STM8 186 +#define EM_TILE64 187 +#define EM_TILEPRO 188 +#define EM_MICROBLAZE 189 +#define EM_CUDA 190 +#define EM_TILEGX 191 +#define EM_CLOUDSHIELD 192 +#define EM_COREA_1ST 193 +#define EM_COREA_2ND 194 +#define EM_ARC_COMPACT2 195 +#define EM_OPEN8 196 +#define EM_RL78 197 +#define EM_VIDEOCORE5 198 +#define EM_78KOR 199 +#define EM_56800EX 200 +#define EM_BA1 201 +#define EM_BA2 202 +#define EM_XCORE 203 +#define EM_MCHP_PIC 204 +#define EM_KM32 210 +#define EM_KMX32 211 +#define EM_EMX16 212 +#define EM_EMX8 213 +#define EM_KVARC 214 +#define EM_CDP 215 +#define EM_COGE 216 +#define EM_COOL 217 +#define EM_NORC 218 +#define EM_CSR_KALIMBA 219 +#define EM_Z80 220 +#define EM_VISIUM 221 +#define EM_FT32 222 +#define EM_MOXIE 223 +#define EM_AMDGPU 224 +#define EM_RISCV 243 +#define EM_BPF 247 +#define EM_NUM 248 + +#define EM_ALPHA 0x9026 + +#define EV_NONE 0 +#define EV_CURRENT 1 +#define EV_NUM 2 + +typedef struct { + Elf32_Word sh_name; + Elf32_Word sh_type; + Elf32_Word sh_flags; + Elf32_Addr sh_addr; + Elf32_Off sh_offset; + Elf32_Word sh_size; + Elf32_Word sh_link; + Elf32_Word sh_info; + Elf32_Word sh_addralign; + Elf32_Word sh_entsize; +} Elf32_Shdr; + +typedef struct { + Elf64_Word sh_name; + Elf64_Word sh_type; + Elf64_Xword sh_flags; + Elf64_Addr sh_addr; + Elf64_Off sh_offset; + Elf64_Xword sh_size; + Elf64_Word sh_link; + Elf64_Word sh_info; + Elf64_Xword sh_addralign; + Elf64_Xword sh_entsize; +} Elf64_Shdr; + + + +#define SHN_UNDEF 0 +#define SHN_LORESERVE 0xff00 +#define SHN_LOPROC 0xff00 +#define SHN_BEFORE 0xff00 + +#define SHN_AFTER 0xff01 + +#define SHN_HIPROC 0xff1f +#define SHN_LOOS 0xff20 +#define SHN_HIOS 0xff3f +#define SHN_ABS 0xfff1 +#define SHN_COMMON 0xfff2 +#define SHN_XINDEX 0xffff +#define SHN_HIRESERVE 0xffff + + + +#define SHT_NULL 0 +#define SHT_PROGBITS 1 +#define SHT_SYMTAB 2 +#define SHT_STRTAB 3 +#define SHT_RELA 4 +#define SHT_HASH 5 +#define SHT_DYNAMIC 6 +#define SHT_NOTE 7 +#define SHT_NOBITS 8 +#define SHT_REL 9 +#define SHT_SHLIB 10 +#define SHT_DYNSYM 11 +#define SHT_INIT_ARRAY 14 +#define SHT_FINI_ARRAY 15 +#define SHT_PREINIT_ARRAY 16 +#define SHT_GROUP 17 +#define SHT_SYMTAB_SHNDX 18 +#define SHT_NUM 19 +#define SHT_LOOS 0x60000000 +#define SHT_GNU_ATTRIBUTES 0x6ffffff5 +#define SHT_GNU_HASH 0x6ffffff6 +#define SHT_GNU_LIBLIST 0x6ffffff7 +#define SHT_CHECKSUM 0x6ffffff8 +#define SHT_LOSUNW 0x6ffffffa +#define SHT_SUNW_move 0x6ffffffa +#define SHT_SUNW_COMDAT 0x6ffffffb +#define SHT_SUNW_syminfo 0x6ffffffc +#define SHT_GNU_verdef 0x6ffffffd +#define SHT_GNU_verneed 0x6ffffffe +#define SHT_GNU_versym 0x6fffffff +#define SHT_HISUNW 0x6fffffff +#define SHT_HIOS 0x6fffffff +#define SHT_LOPROC 0x70000000 +#define SHT_HIPROC 0x7fffffff +#define SHT_LOUSER 0x80000000 +#define SHT_HIUSER 0x8fffffff + +#define SHF_WRITE (1 << 0) +#define SHF_ALLOC (1 << 1) +#define SHF_EXECINSTR (1 << 2) +#define SHF_MERGE (1 << 4) +#define SHF_STRINGS (1 << 5) +#define SHF_INFO_LINK (1 << 6) +#define SHF_LINK_ORDER (1 << 7) +#define SHF_OS_NONCONFORMING (1 << 8) + +#define SHF_GROUP (1 << 9) +#define SHF_TLS (1 << 10) +#define SHF_COMPRESSED (1 << 11) +#define SHF_MASKOS 0x0ff00000 +#define SHF_MASKPROC 0xf0000000 +#define SHF_ORDERED (1 << 30) +#define SHF_EXCLUDE (1U << 31) + +typedef struct { + Elf32_Word ch_type; + Elf32_Word ch_size; + Elf32_Word ch_addralign; +} Elf32_Chdr; + +typedef struct { + Elf64_Word ch_type; + Elf64_Word ch_reserved; + Elf64_Xword ch_size; + Elf64_Xword ch_addralign; +} Elf64_Chdr; + +#define ELFCOMPRESS_ZLIB 1 +#define ELFCOMPRESS_LOOS 0x60000000 +#define ELFCOMPRESS_HIOS 0x6fffffff +#define ELFCOMPRESS_LOPROC 0x70000000 +#define ELFCOMPRESS_HIPROC 0x7fffffff + + +#define GRP_COMDAT 0x1 + +typedef struct { + Elf32_Word st_name; + Elf32_Addr st_value; + Elf32_Word st_size; + unsigned char st_info; + unsigned char st_other; + Elf32_Section st_shndx; +} Elf32_Sym; + +typedef struct { + Elf64_Word st_name; + unsigned char st_info; + unsigned char st_other; + Elf64_Section st_shndx; + Elf64_Addr st_value; + Elf64_Xword st_size; +} Elf64_Sym; + +typedef struct { + Elf32_Half si_boundto; + Elf32_Half si_flags; +} Elf32_Syminfo; + +typedef struct { + Elf64_Half si_boundto; + Elf64_Half si_flags; +} Elf64_Syminfo; + +#define SYMINFO_BT_SELF 0xffff +#define SYMINFO_BT_PARENT 0xfffe +#define SYMINFO_BT_LOWRESERVE 0xff00 + +#define SYMINFO_FLG_DIRECT 0x0001 +#define SYMINFO_FLG_PASSTHRU 0x0002 +#define SYMINFO_FLG_COPY 0x0004 +#define SYMINFO_FLG_LAZYLOAD 0x0008 + +#define SYMINFO_NONE 0 +#define SYMINFO_CURRENT 1 +#define SYMINFO_NUM 2 + +#define ELF32_ST_BIND(val) (((unsigned char) (val)) >> 4) +#define ELF32_ST_TYPE(val) ((val) & 0xf) +#define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf)) + +#define ELF64_ST_BIND(val) ELF32_ST_BIND (val) +#define ELF64_ST_TYPE(val) ELF32_ST_TYPE (val) +#define ELF64_ST_INFO(bind, type) ELF32_ST_INFO ((bind), (type)) + +#define STB_LOCAL 0 +#define STB_GLOBAL 1 +#define STB_WEAK 2 +#define STB_NUM 3 +#define STB_LOOS 10 +#define STB_GNU_UNIQUE 10 +#define STB_HIOS 12 +#define STB_LOPROC 13 +#define STB_HIPROC 15 + +#define STT_NOTYPE 0 +#define STT_OBJECT 1 +#define STT_FUNC 2 +#define STT_SECTION 3 +#define STT_FILE 4 +#define STT_COMMON 5 +#define STT_TLS 6 +#define STT_NUM 7 +#define STT_LOOS 10 +#define STT_GNU_IFUNC 10 +#define STT_HIOS 12 +#define STT_LOPROC 13 +#define STT_HIPROC 15 + +#define STN_UNDEF 0 + +#define ELF32_ST_VISIBILITY(o) ((o) & 0x03) +#define ELF64_ST_VISIBILITY(o) ELF32_ST_VISIBILITY (o) + +#define STV_DEFAULT 0 +#define STV_INTERNAL 1 +#define STV_HIDDEN 2 +#define STV_PROTECTED 3 + + + + +typedef struct { + Elf32_Addr r_offset; + Elf32_Word r_info; +} Elf32_Rel; + +typedef struct { + Elf64_Addr r_offset; + Elf64_Xword r_info; +} Elf64_Rel; + + + +typedef struct { + Elf32_Addr r_offset; + Elf32_Word r_info; + Elf32_Sword r_addend; +} Elf32_Rela; + +typedef struct { + Elf64_Addr r_offset; + Elf64_Xword r_info; + Elf64_Sxword r_addend; +} Elf64_Rela; + + + +#define ELF32_R_SYM(val) ((val) >> 8) +#define ELF32_R_TYPE(val) ((val) & 0xff) +#define ELF32_R_INFO(sym, type) (((sym) << 8) + ((type) & 0xff)) + +#define ELF64_R_SYM(i) ((i) >> 32) +#define ELF64_R_TYPE(i) ((i) & 0xffffffff) +#define ELF64_R_INFO(sym,type) ((((Elf64_Xword) (sym)) << 32) + (type)) + + + +typedef struct { + Elf32_Word p_type; + Elf32_Off p_offset; + Elf32_Addr p_vaddr; + Elf32_Addr p_paddr; + Elf32_Word p_filesz; + Elf32_Word p_memsz; + Elf32_Word p_flags; + Elf32_Word p_align; +} Elf32_Phdr; + +typedef struct { + Elf64_Word p_type; + Elf64_Word p_flags; + Elf64_Off p_offset; + Elf64_Addr p_vaddr; + Elf64_Addr p_paddr; + Elf64_Xword p_filesz; + Elf64_Xword p_memsz; + Elf64_Xword p_align; +} Elf64_Phdr; + + + +#define PT_NULL 0 +#define PT_LOAD 1 +#define PT_DYNAMIC 2 +#define PT_INTERP 3 +#define PT_NOTE 4 +#define PT_SHLIB 5 +#define PT_PHDR 6 +#define PT_TLS 7 +#define PT_NUM 8 +#define PT_LOOS 0x60000000 +#define PT_GNU_EH_FRAME 0x6474e550 +#define PT_GNU_STACK 0x6474e551 +#define PT_GNU_RELRO 0x6474e552 +#define PT_LOSUNW 0x6ffffffa +#define PT_SUNWBSS 0x6ffffffa +#define PT_SUNWSTACK 0x6ffffffb +#define PT_HISUNW 0x6fffffff +#define PT_HIOS 0x6fffffff +#define PT_LOPROC 0x70000000 +#define PT_HIPROC 0x7fffffff + + +#define PN_XNUM 0xffff + + +#define PF_X (1 << 0) +#define PF_W (1 << 1) +#define PF_R (1 << 2) +#define PF_MASKOS 0x0ff00000 +#define PF_MASKPROC 0xf0000000 + + + +#define NT_PRSTATUS 1 +#define NT_FPREGSET 2 +#define NT_PRPSINFO 3 +#define NT_PRXREG 4 +#define NT_TASKSTRUCT 4 +#define NT_PLATFORM 5 +#define NT_AUXV 6 +#define NT_GWINDOWS 7 +#define NT_ASRS 8 +#define NT_PSTATUS 10 +#define NT_PSINFO 13 +#define NT_PRCRED 14 +#define NT_UTSNAME 15 +#define NT_LWPSTATUS 16 +#define NT_LWPSINFO 17 +#define NT_PRFPXREG 20 +#define NT_SIGINFO 0x53494749 +#define NT_FILE 0x46494c45 +#define NT_PRXFPREG 0x46e62b7f +#define NT_PPC_VMX 0x100 +#define NT_PPC_SPE 0x101 +#define NT_PPC_VSX 0x102 +#define NT_386_TLS 0x200 +#define NT_386_IOPERM 0x201 +#define NT_X86_XSTATE 0x202 +#define NT_S390_HIGH_GPRS 0x300 +#define NT_S390_TIMER 0x301 +#define NT_S390_TODCMP 0x302 +#define NT_S390_TODPREG 0x303 +#define NT_S390_CTRS 0x304 +#define NT_S390_PREFIX 0x305 +#define NT_S390_LAST_BREAK 0x306 +#define NT_S390_SYSTEM_CALL 0x307 +#define NT_S390_TDB 0x308 +#define NT_ARM_VFP 0x400 +#define NT_ARM_TLS 0x401 +#define NT_ARM_HW_BREAK 0x402 +#define NT_ARM_HW_WATCH 0x403 +#define NT_ARM_SYSTEM_CALL 0x404 +#define NT_ARM_SVE 0x405 +#define NT_METAG_CBUF 0x500 +#define NT_METAG_RPIPE 0x501 +#define NT_METAG_TLS 0x502 +#define NT_VERSION 1 + + + + +typedef struct { + Elf32_Sword d_tag; + union { + Elf32_Word d_val; + Elf32_Addr d_ptr; + } d_un; +} Elf32_Dyn; + +typedef struct { + Elf64_Sxword d_tag; + union { + Elf64_Xword d_val; + Elf64_Addr d_ptr; + } d_un; +} Elf64_Dyn; + + + +#define DT_NULL 0 +#define DT_NEEDED 1 +#define DT_PLTRELSZ 2 +#define DT_PLTGOT 3 +#define DT_HASH 4 +#define DT_STRTAB 5 +#define DT_SYMTAB 6 +#define DT_RELA 7 +#define DT_RELASZ 8 +#define DT_RELAENT 9 +#define DT_STRSZ 10 +#define DT_SYMENT 11 +#define DT_INIT 12 +#define DT_FINI 13 +#define DT_SONAME 14 +#define DT_RPATH 15 +#define DT_SYMBOLIC 16 +#define DT_REL 17 +#define DT_RELSZ 18 +#define DT_RELENT 19 +#define DT_PLTREL 20 +#define DT_DEBUG 21 +#define DT_TEXTREL 22 +#define DT_JMPREL 23 +#define DT_BIND_NOW 24 +#define DT_INIT_ARRAY 25 +#define DT_FINI_ARRAY 26 +#define DT_INIT_ARRAYSZ 27 +#define DT_FINI_ARRAYSZ 28 +#define DT_RUNPATH 29 +#define DT_FLAGS 30 +#define DT_ENCODING 32 +#define DT_PREINIT_ARRAY 32 +#define DT_PREINIT_ARRAYSZ 33 +#define DT_NUM 34 +#define DT_LOOS 0x6000000d +#define DT_HIOS 0x6ffff000 +#define DT_LOPROC 0x70000000 +#define DT_HIPROC 0x7fffffff +#define DT_PROCNUM DT_MIPS_NUM + +#define DT_VALRNGLO 0x6ffffd00 +#define DT_GNU_PRELINKED 0x6ffffdf5 +#define DT_GNU_CONFLICTSZ 0x6ffffdf6 +#define DT_GNU_LIBLISTSZ 0x6ffffdf7 +#define DT_CHECKSUM 0x6ffffdf8 +#define DT_PLTPADSZ 0x6ffffdf9 +#define DT_MOVEENT 0x6ffffdfa +#define DT_MOVESZ 0x6ffffdfb +#define DT_FEATURE_1 0x6ffffdfc +#define DT_POSFLAG_1 0x6ffffdfd + +#define DT_SYMINSZ 0x6ffffdfe +#define DT_SYMINENT 0x6ffffdff +#define DT_VALRNGHI 0x6ffffdff +#define DT_VALTAGIDX(tag) (DT_VALRNGHI - (tag)) +#define DT_VALNUM 12 + +#define DT_ADDRRNGLO 0x6ffffe00 +#define DT_GNU_HASH 0x6ffffef5 +#define DT_TLSDESC_PLT 0x6ffffef6 +#define DT_TLSDESC_GOT 0x6ffffef7 +#define DT_GNU_CONFLICT 0x6ffffef8 +#define DT_GNU_LIBLIST 0x6ffffef9 +#define DT_CONFIG 0x6ffffefa +#define DT_DEPAUDIT 0x6ffffefb +#define DT_AUDIT 0x6ffffefc +#define DT_PLTPAD 0x6ffffefd +#define DT_MOVETAB 0x6ffffefe +#define DT_SYMINFO 0x6ffffeff +#define DT_ADDRRNGHI 0x6ffffeff +#define DT_ADDRTAGIDX(tag) (DT_ADDRRNGHI - (tag)) +#define DT_ADDRNUM 11 + + + +#define DT_VERSYM 0x6ffffff0 + +#define DT_RELACOUNT 0x6ffffff9 +#define DT_RELCOUNT 0x6ffffffa + + +#define DT_FLAGS_1 0x6ffffffb +#define DT_VERDEF 0x6ffffffc + +#define DT_VERDEFNUM 0x6ffffffd +#define DT_VERNEED 0x6ffffffe + +#define DT_VERNEEDNUM 0x6fffffff +#define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag)) +#define DT_VERSIONTAGNUM 16 + + + +#define DT_AUXILIARY 0x7ffffffd +#define DT_FILTER 0x7fffffff +#define DT_EXTRATAGIDX(tag) ((Elf32_Word)-((Elf32_Sword) (tag) <<1>>1)-1) +#define DT_EXTRANUM 3 + + +#define DF_ORIGIN 0x00000001 +#define DF_SYMBOLIC 0x00000002 +#define DF_TEXTREL 0x00000004 +#define DF_BIND_NOW 0x00000008 +#define DF_STATIC_TLS 0x00000010 + + + +#define DF_1_NOW 0x00000001 +#define DF_1_GLOBAL 0x00000002 +#define DF_1_GROUP 0x00000004 +#define DF_1_NODELETE 0x00000008 +#define DF_1_LOADFLTR 0x00000010 +#define DF_1_INITFIRST 0x00000020 +#define DF_1_NOOPEN 0x00000040 +#define DF_1_ORIGIN 0x00000080 +#define DF_1_DIRECT 0x00000100 +#define DF_1_TRANS 0x00000200 +#define DF_1_INTERPOSE 0x00000400 +#define DF_1_NODEFLIB 0x00000800 +#define DF_1_NODUMP 0x00001000 +#define DF_1_CONFALT 0x00002000 +#define DF_1_ENDFILTEE 0x00004000 +#define DF_1_DISPRELDNE 0x00008000 +#define DF_1_DISPRELPND 0x00010000 +#define DF_1_NODIRECT 0x00020000 +#define DF_1_IGNMULDEF 0x00040000 +#define DF_1_NOKSYMS 0x00080000 +#define DF_1_NOHDR 0x00100000 +#define DF_1_EDITED 0x00200000 +#define DF_1_NORELOC 0x00400000 +#define DF_1_SYMINTPOSE 0x00800000 +#define DF_1_GLOBAUDIT 0x01000000 +#define DF_1_SINGLETON 0x02000000 + +#define DTF_1_PARINIT 0x00000001 +#define DTF_1_CONFEXP 0x00000002 + + +#define DF_P1_LAZYLOAD 0x00000001 +#define DF_P1_GROUPPERM 0x00000002 + + + + +typedef struct { + Elf32_Half vd_version; + Elf32_Half vd_flags; + Elf32_Half vd_ndx; + Elf32_Half vd_cnt; + Elf32_Word vd_hash; + Elf32_Word vd_aux; + Elf32_Word vd_next; +} Elf32_Verdef; + +typedef struct { + Elf64_Half vd_version; + Elf64_Half vd_flags; + Elf64_Half vd_ndx; + Elf64_Half vd_cnt; + Elf64_Word vd_hash; + Elf64_Word vd_aux; + Elf64_Word vd_next; +} Elf64_Verdef; + + + +#define VER_DEF_NONE 0 +#define VER_DEF_CURRENT 1 +#define VER_DEF_NUM 2 + + +#define VER_FLG_BASE 0x1 +#define VER_FLG_WEAK 0x2 + + +#define VER_NDX_LOCAL 0 +#define VER_NDX_GLOBAL 1 +#define VER_NDX_LORESERVE 0xff00 +#define VER_NDX_ELIMINATE 0xff01 + + + +typedef struct { + Elf32_Word vda_name; + Elf32_Word vda_next; +} Elf32_Verdaux; + +typedef struct { + Elf64_Word vda_name; + Elf64_Word vda_next; +} Elf64_Verdaux; + + + + +typedef struct { + Elf32_Half vn_version; + Elf32_Half vn_cnt; + Elf32_Word vn_file; + Elf32_Word vn_aux; + Elf32_Word vn_next; +} Elf32_Verneed; + +typedef struct { + Elf64_Half vn_version; + Elf64_Half vn_cnt; + Elf64_Word vn_file; + Elf64_Word vn_aux; + Elf64_Word vn_next; +} Elf64_Verneed; + + + +#define VER_NEED_NONE 0 +#define VER_NEED_CURRENT 1 +#define VER_NEED_NUM 2 + + + +typedef struct { + Elf32_Word vna_hash; + Elf32_Half vna_flags; + Elf32_Half vna_other; + Elf32_Word vna_name; + Elf32_Word vna_next; +} Elf32_Vernaux; + +typedef struct { + Elf64_Word vna_hash; + Elf64_Half vna_flags; + Elf64_Half vna_other; + Elf64_Word vna_name; + Elf64_Word vna_next; +} Elf64_Vernaux; + + + +#define VER_FLG_WEAK 0x2 + + + +typedef struct { + uint32_t a_type; + union { + uint32_t a_val; + } a_un; +} Elf32_auxv_t; + +typedef struct { + uint64_t a_type; + union { + uint64_t a_val; + } a_un; +} Elf64_auxv_t; + + + +#define AT_NULL 0 +#define AT_IGNORE 1 +#define AT_EXECFD 2 +#define AT_PHDR 3 +#define AT_PHENT 4 +#define AT_PHNUM 5 +#define AT_PAGESZ 6 +#define AT_BASE 7 +#define AT_FLAGS 8 +#define AT_ENTRY 9 +#define AT_NOTELF 10 +#define AT_UID 11 +#define AT_EUID 12 +#define AT_GID 13 +#define AT_EGID 14 +#define AT_CLKTCK 17 + + +#define AT_PLATFORM 15 +#define AT_HWCAP 16 + + + + +#define AT_FPUCW 18 + + +#define AT_DCACHEBSIZE 19 +#define AT_ICACHEBSIZE 20 +#define AT_UCACHEBSIZE 21 + + + +#define AT_IGNOREPPC 22 + +#define AT_SECURE 23 + +#define AT_BASE_PLATFORM 24 + +#define AT_RANDOM 25 + +#define AT_HWCAP2 26 + +#define AT_EXECFN 31 + + + +#define AT_SYSINFO 32 +#define AT_SYSINFO_EHDR 33 + + + +#define AT_L1I_CACHESHAPE 34 +#define AT_L1D_CACHESHAPE 35 +#define AT_L2_CACHESHAPE 36 +#define AT_L3_CACHESHAPE 37 + + + + +typedef struct { + Elf32_Word n_namesz; + Elf32_Word n_descsz; + Elf32_Word n_type; +} Elf32_Nhdr; + +typedef struct { + Elf64_Word n_namesz; + Elf64_Word n_descsz; + Elf64_Word n_type; +} Elf64_Nhdr; + + + + +#define ELF_NOTE_SOLARIS "SUNW Solaris" + + +#define ELF_NOTE_GNU "GNU" + + + + + +#define ELF_NOTE_PAGESIZE_HINT 1 + + +#define NT_GNU_ABI_TAG 1 +#define ELF_NOTE_ABI NT_GNU_ABI_TAG + + + +#define ELF_NOTE_OS_LINUX 0 +#define ELF_NOTE_OS_GNU 1 +#define ELF_NOTE_OS_SOLARIS2 2 +#define ELF_NOTE_OS_FREEBSD 3 + +#define NT_GNU_BUILD_ID 3 +#define NT_GNU_GOLD_VERSION 4 + + + +typedef struct { + Elf32_Xword m_value; + Elf32_Word m_info; + Elf32_Word m_poffset; + Elf32_Half m_repeat; + Elf32_Half m_stride; +} Elf32_Move; + +typedef struct { + Elf64_Xword m_value; + Elf64_Xword m_info; + Elf64_Xword m_poffset; + Elf64_Half m_repeat; + Elf64_Half m_stride; +} Elf64_Move; + + +#define ELF32_M_SYM(info) ((info) >> 8) +#define ELF32_M_SIZE(info) ((unsigned char) (info)) +#define ELF32_M_INFO(sym, size) (((sym) << 8) + (unsigned char) (size)) + +#define ELF64_M_SYM(info) ELF32_M_SYM (info) +#define ELF64_M_SIZE(info) ELF32_M_SIZE (info) +#define ELF64_M_INFO(sym, size) ELF32_M_INFO (sym, size) + +#define EF_CPU32 0x00810000 + +#define R_68K_NONE 0 +#define R_68K_32 1 +#define R_68K_16 2 +#define R_68K_8 3 +#define R_68K_PC32 4 +#define R_68K_PC16 5 +#define R_68K_PC8 6 +#define R_68K_GOT32 7 +#define R_68K_GOT16 8 +#define R_68K_GOT8 9 +#define R_68K_GOT32O 10 +#define R_68K_GOT16O 11 +#define R_68K_GOT8O 12 +#define R_68K_PLT32 13 +#define R_68K_PLT16 14 +#define R_68K_PLT8 15 +#define R_68K_PLT32O 16 +#define R_68K_PLT16O 17 +#define R_68K_PLT8O 18 +#define R_68K_COPY 19 +#define R_68K_GLOB_DAT 20 +#define R_68K_JMP_SLOT 21 +#define R_68K_RELATIVE 22 +#define R_68K_NUM 23 + +#define R_386_NONE 0 +#define R_386_32 1 +#define R_386_PC32 2 +#define R_386_GOT32 3 +#define R_386_PLT32 4 +#define R_386_COPY 5 +#define R_386_GLOB_DAT 6 +#define R_386_JMP_SLOT 7 +#define R_386_RELATIVE 8 +#define R_386_GOTOFF 9 +#define R_386_GOTPC 10 +#define R_386_32PLT 11 +#define R_386_TLS_TPOFF 14 +#define R_386_TLS_IE 15 +#define R_386_TLS_GOTIE 16 +#define R_386_TLS_LE 17 +#define R_386_TLS_GD 18 +#define R_386_TLS_LDM 19 +#define R_386_16 20 +#define R_386_PC16 21 +#define R_386_8 22 +#define R_386_PC8 23 +#define R_386_TLS_GD_32 24 +#define R_386_TLS_GD_PUSH 25 +#define R_386_TLS_GD_CALL 26 +#define R_386_TLS_GD_POP 27 +#define R_386_TLS_LDM_32 28 +#define R_386_TLS_LDM_PUSH 29 +#define R_386_TLS_LDM_CALL 30 +#define R_386_TLS_LDM_POP 31 +#define R_386_TLS_LDO_32 32 +#define R_386_TLS_IE_32 33 +#define R_386_TLS_LE_32 34 +#define R_386_TLS_DTPMOD32 35 +#define R_386_TLS_DTPOFF32 36 +#define R_386_TLS_TPOFF32 37 +#define R_386_SIZE32 38 +#define R_386_TLS_GOTDESC 39 +#define R_386_TLS_DESC_CALL 40 +#define R_386_TLS_DESC 41 +#define R_386_IRELATIVE 42 +#define R_386_GOT32X 43 +#define R_386_NUM 44 + + + + + +#define STT_SPARC_REGISTER 13 + + + +#define EF_SPARCV9_MM 3 +#define EF_SPARCV9_TSO 0 +#define EF_SPARCV9_PSO 1 +#define EF_SPARCV9_RMO 2 +#define EF_SPARC_LEDATA 0x800000 +#define EF_SPARC_EXT_MASK 0xFFFF00 +#define EF_SPARC_32PLUS 0x000100 +#define EF_SPARC_SUN_US1 0x000200 +#define EF_SPARC_HAL_R1 0x000400 +#define EF_SPARC_SUN_US3 0x000800 + + + +#define R_SPARC_NONE 0 +#define R_SPARC_8 1 +#define R_SPARC_16 2 +#define R_SPARC_32 3 +#define R_SPARC_DISP8 4 +#define R_SPARC_DISP16 5 +#define R_SPARC_DISP32 6 +#define R_SPARC_WDISP30 7 +#define R_SPARC_WDISP22 8 +#define R_SPARC_HI22 9 +#define R_SPARC_22 10 +#define R_SPARC_13 11 +#define R_SPARC_LO10 12 +#define R_SPARC_GOT10 13 +#define R_SPARC_GOT13 14 +#define R_SPARC_GOT22 15 +#define R_SPARC_PC10 16 +#define R_SPARC_PC22 17 +#define R_SPARC_WPLT30 18 +#define R_SPARC_COPY 19 +#define R_SPARC_GLOB_DAT 20 +#define R_SPARC_JMP_SLOT 21 +#define R_SPARC_RELATIVE 22 +#define R_SPARC_UA32 23 + + + +#define R_SPARC_PLT32 24 +#define R_SPARC_HIPLT22 25 +#define R_SPARC_LOPLT10 26 +#define R_SPARC_PCPLT32 27 +#define R_SPARC_PCPLT22 28 +#define R_SPARC_PCPLT10 29 +#define R_SPARC_10 30 +#define R_SPARC_11 31 +#define R_SPARC_64 32 +#define R_SPARC_OLO10 33 +#define R_SPARC_HH22 34 +#define R_SPARC_HM10 35 +#define R_SPARC_LM22 36 +#define R_SPARC_PC_HH22 37 +#define R_SPARC_PC_HM10 38 +#define R_SPARC_PC_LM22 39 +#define R_SPARC_WDISP16 40 +#define R_SPARC_WDISP19 41 +#define R_SPARC_GLOB_JMP 42 +#define R_SPARC_7 43 +#define R_SPARC_5 44 +#define R_SPARC_6 45 +#define R_SPARC_DISP64 46 +#define R_SPARC_PLT64 47 +#define R_SPARC_HIX22 48 +#define R_SPARC_LOX10 49 +#define R_SPARC_H44 50 +#define R_SPARC_M44 51 +#define R_SPARC_L44 52 +#define R_SPARC_REGISTER 53 +#define R_SPARC_UA64 54 +#define R_SPARC_UA16 55 +#define R_SPARC_TLS_GD_HI22 56 +#define R_SPARC_TLS_GD_LO10 57 +#define R_SPARC_TLS_GD_ADD 58 +#define R_SPARC_TLS_GD_CALL 59 +#define R_SPARC_TLS_LDM_HI22 60 +#define R_SPARC_TLS_LDM_LO10 61 +#define R_SPARC_TLS_LDM_ADD 62 +#define R_SPARC_TLS_LDM_CALL 63 +#define R_SPARC_TLS_LDO_HIX22 64 +#define R_SPARC_TLS_LDO_LOX10 65 +#define R_SPARC_TLS_LDO_ADD 66 +#define R_SPARC_TLS_IE_HI22 67 +#define R_SPARC_TLS_IE_LO10 68 +#define R_SPARC_TLS_IE_LD 69 +#define R_SPARC_TLS_IE_LDX 70 +#define R_SPARC_TLS_IE_ADD 71 +#define R_SPARC_TLS_LE_HIX22 72 +#define R_SPARC_TLS_LE_LOX10 73 +#define R_SPARC_TLS_DTPMOD32 74 +#define R_SPARC_TLS_DTPMOD64 75 +#define R_SPARC_TLS_DTPOFF32 76 +#define R_SPARC_TLS_DTPOFF64 77 +#define R_SPARC_TLS_TPOFF32 78 +#define R_SPARC_TLS_TPOFF64 79 +#define R_SPARC_GOTDATA_HIX22 80 +#define R_SPARC_GOTDATA_LOX10 81 +#define R_SPARC_GOTDATA_OP_HIX22 82 +#define R_SPARC_GOTDATA_OP_LOX10 83 +#define R_SPARC_GOTDATA_OP 84 +#define R_SPARC_H34 85 +#define R_SPARC_SIZE32 86 +#define R_SPARC_SIZE64 87 +#define R_SPARC_GNU_VTINHERIT 250 +#define R_SPARC_GNU_VTENTRY 251 +#define R_SPARC_REV32 252 + +#define R_SPARC_NUM 253 + + + +#define DT_SPARC_REGISTER 0x70000001 +#define DT_SPARC_NUM 2 + + +#define EF_MIPS_NOREORDER 1 +#define EF_MIPS_PIC 2 +#define EF_MIPS_CPIC 4 +#define EF_MIPS_XGOT 8 +#define EF_MIPS_64BIT_WHIRL 16 +#define EF_MIPS_ABI2 32 +#define EF_MIPS_ABI_ON32 64 +#define EF_MIPS_FP64 512 +#define EF_MIPS_NAN2008 1024 +#define EF_MIPS_ARCH 0xf0000000 + + + +#define EF_MIPS_ARCH_1 0x00000000 +#define EF_MIPS_ARCH_2 0x10000000 +#define EF_MIPS_ARCH_3 0x20000000 +#define EF_MIPS_ARCH_4 0x30000000 +#define EF_MIPS_ARCH_5 0x40000000 +#define EF_MIPS_ARCH_32 0x50000000 +#define EF_MIPS_ARCH_64 0x60000000 +#define EF_MIPS_ARCH_32R2 0x70000000 +#define EF_MIPS_ARCH_64R2 0x80000000 + + +#define E_MIPS_ARCH_1 0x00000000 +#define E_MIPS_ARCH_2 0x10000000 +#define E_MIPS_ARCH_3 0x20000000 +#define E_MIPS_ARCH_4 0x30000000 +#define E_MIPS_ARCH_5 0x40000000 +#define E_MIPS_ARCH_32 0x50000000 +#define E_MIPS_ARCH_64 0x60000000 + + + +#define SHN_MIPS_ACOMMON 0xff00 +#define SHN_MIPS_TEXT 0xff01 +#define SHN_MIPS_DATA 0xff02 +#define SHN_MIPS_SCOMMON 0xff03 +#define SHN_MIPS_SUNDEFINED 0xff04 + + + +#define SHT_MIPS_LIBLIST 0x70000000 +#define SHT_MIPS_MSYM 0x70000001 +#define SHT_MIPS_CONFLICT 0x70000002 +#define SHT_MIPS_GPTAB 0x70000003 +#define SHT_MIPS_UCODE 0x70000004 +#define SHT_MIPS_DEBUG 0x70000005 +#define SHT_MIPS_REGINFO 0x70000006 +#define SHT_MIPS_PACKAGE 0x70000007 +#define SHT_MIPS_PACKSYM 0x70000008 +#define SHT_MIPS_RELD 0x70000009 +#define SHT_MIPS_IFACE 0x7000000b +#define SHT_MIPS_CONTENT 0x7000000c +#define SHT_MIPS_OPTIONS 0x7000000d +#define SHT_MIPS_SHDR 0x70000010 +#define SHT_MIPS_FDESC 0x70000011 +#define SHT_MIPS_EXTSYM 0x70000012 +#define SHT_MIPS_DENSE 0x70000013 +#define SHT_MIPS_PDESC 0x70000014 +#define SHT_MIPS_LOCSYM 0x70000015 +#define SHT_MIPS_AUXSYM 0x70000016 +#define SHT_MIPS_OPTSYM 0x70000017 +#define SHT_MIPS_LOCSTR 0x70000018 +#define SHT_MIPS_LINE 0x70000019 +#define SHT_MIPS_RFDESC 0x7000001a +#define SHT_MIPS_DELTASYM 0x7000001b +#define SHT_MIPS_DELTAINST 0x7000001c +#define SHT_MIPS_DELTACLASS 0x7000001d +#define SHT_MIPS_DWARF 0x7000001e +#define SHT_MIPS_DELTADECL 0x7000001f +#define SHT_MIPS_SYMBOL_LIB 0x70000020 +#define SHT_MIPS_EVENTS 0x70000021 +#define SHT_MIPS_TRANSLATE 0x70000022 +#define SHT_MIPS_PIXIE 0x70000023 +#define SHT_MIPS_XLATE 0x70000024 +#define SHT_MIPS_XLATE_DEBUG 0x70000025 +#define SHT_MIPS_WHIRL 0x70000026 +#define SHT_MIPS_EH_REGION 0x70000027 +#define SHT_MIPS_XLATE_OLD 0x70000028 +#define SHT_MIPS_PDR_EXCEPTION 0x70000029 + + + +#define SHF_MIPS_GPREL 0x10000000 +#define SHF_MIPS_MERGE 0x20000000 +#define SHF_MIPS_ADDR 0x40000000 +#define SHF_MIPS_STRINGS 0x80000000 +#define SHF_MIPS_NOSTRIP 0x08000000 +#define SHF_MIPS_LOCAL 0x04000000 +#define SHF_MIPS_NAMES 0x02000000 +#define SHF_MIPS_NODUPE 0x01000000 + + + + + +#define STO_MIPS_DEFAULT 0x0 +#define STO_MIPS_INTERNAL 0x1 +#define STO_MIPS_HIDDEN 0x2 +#define STO_MIPS_PROTECTED 0x3 +#define STO_MIPS_PLT 0x8 +#define STO_MIPS_SC_ALIGN_UNUSED 0xff + + +#define STB_MIPS_SPLIT_COMMON 13 + + + +typedef union { + struct { + Elf32_Word gt_current_g_value; + Elf32_Word gt_unused; + } gt_header; + struct { + Elf32_Word gt_g_value; + Elf32_Word gt_bytes; + } gt_entry; +} Elf32_gptab; + + + +typedef struct { + Elf32_Word ri_gprmask; + Elf32_Word ri_cprmask[4]; + Elf32_Sword ri_gp_value; +} Elf32_RegInfo; + + + +typedef struct { + unsigned char kind; + + unsigned char size; + Elf32_Section section; + + Elf32_Word info; +} Elf_Options; + + + +#define ODK_NULL 0 +#define ODK_REGINFO 1 +#define ODK_EXCEPTIONS 2 +#define ODK_PAD 3 +#define ODK_HWPATCH 4 +#define ODK_FILL 5 +#define ODK_TAGS 6 +#define ODK_HWAND 7 +#define ODK_HWOR 8 + + + +#define OEX_FPU_MIN 0x1f +#define OEX_FPU_MAX 0x1f00 +#define OEX_PAGE0 0x10000 +#define OEX_SMM 0x20000 +#define OEX_FPDBUG 0x40000 +#define OEX_PRECISEFP OEX_FPDBUG +#define OEX_DISMISS 0x80000 + +#define OEX_FPU_INVAL 0x10 +#define OEX_FPU_DIV0 0x08 +#define OEX_FPU_OFLO 0x04 +#define OEX_FPU_UFLO 0x02 +#define OEX_FPU_INEX 0x01 + + + +#define OHW_R4KEOP 0x1 +#define OHW_R8KPFETCH 0x2 +#define OHW_R5KEOP 0x4 +#define OHW_R5KCVTL 0x8 + +#define OPAD_PREFIX 0x1 +#define OPAD_POSTFIX 0x2 +#define OPAD_SYMBOL 0x4 + + + +typedef struct { + Elf32_Word hwp_flags1; + Elf32_Word hwp_flags2; +} Elf_Options_Hw; + + + +#define OHWA0_R4KEOP_CHECKED 0x00000001 +#define OHWA1_R4KEOP_CLEAN 0x00000002 + + + +#define R_MIPS_NONE 0 +#define R_MIPS_16 1 +#define R_MIPS_32 2 +#define R_MIPS_REL32 3 +#define R_MIPS_26 4 +#define R_MIPS_HI16 5 +#define R_MIPS_LO16 6 +#define R_MIPS_GPREL16 7 +#define R_MIPS_LITERAL 8 +#define R_MIPS_GOT16 9 +#define R_MIPS_PC16 10 +#define R_MIPS_CALL16 11 +#define R_MIPS_GPREL32 12 + +#define R_MIPS_SHIFT5 16 +#define R_MIPS_SHIFT6 17 +#define R_MIPS_64 18 +#define R_MIPS_GOT_DISP 19 +#define R_MIPS_GOT_PAGE 20 +#define R_MIPS_GOT_OFST 21 +#define R_MIPS_GOT_HI16 22 +#define R_MIPS_GOT_LO16 23 +#define R_MIPS_SUB 24 +#define R_MIPS_INSERT_A 25 +#define R_MIPS_INSERT_B 26 +#define R_MIPS_DELETE 27 +#define R_MIPS_HIGHER 28 +#define R_MIPS_HIGHEST 29 +#define R_MIPS_CALL_HI16 30 +#define R_MIPS_CALL_LO16 31 +#define R_MIPS_SCN_DISP 32 +#define R_MIPS_REL16 33 +#define R_MIPS_ADD_IMMEDIATE 34 +#define R_MIPS_PJUMP 35 +#define R_MIPS_RELGOT 36 +#define R_MIPS_JALR 37 +#define R_MIPS_TLS_DTPMOD32 38 +#define R_MIPS_TLS_DTPREL32 39 +#define R_MIPS_TLS_DTPMOD64 40 +#define R_MIPS_TLS_DTPREL64 41 +#define R_MIPS_TLS_GD 42 +#define R_MIPS_TLS_LDM 43 +#define R_MIPS_TLS_DTPREL_HI16 44 +#define R_MIPS_TLS_DTPREL_LO16 45 +#define R_MIPS_TLS_GOTTPREL 46 +#define R_MIPS_TLS_TPREL32 47 +#define R_MIPS_TLS_TPREL64 48 +#define R_MIPS_TLS_TPREL_HI16 49 +#define R_MIPS_TLS_TPREL_LO16 50 +#define R_MIPS_GLOB_DAT 51 +#define R_MIPS_COPY 126 +#define R_MIPS_JUMP_SLOT 127 + +#define R_MIPS_NUM 128 + + + +#define PT_MIPS_REGINFO 0x70000000 +#define PT_MIPS_RTPROC 0x70000001 +#define PT_MIPS_OPTIONS 0x70000002 +#define PT_MIPS_ABIFLAGS 0x70000003 + + + +#define PF_MIPS_LOCAL 0x10000000 + + + +#define DT_MIPS_RLD_VERSION 0x70000001 +#define DT_MIPS_TIME_STAMP 0x70000002 +#define DT_MIPS_ICHECKSUM 0x70000003 +#define DT_MIPS_IVERSION 0x70000004 +#define DT_MIPS_FLAGS 0x70000005 +#define DT_MIPS_BASE_ADDRESS 0x70000006 +#define DT_MIPS_MSYM 0x70000007 +#define DT_MIPS_CONFLICT 0x70000008 +#define DT_MIPS_LIBLIST 0x70000009 +#define DT_MIPS_LOCAL_GOTNO 0x7000000a +#define DT_MIPS_CONFLICTNO 0x7000000b +#define DT_MIPS_LIBLISTNO 0x70000010 +#define DT_MIPS_SYMTABNO 0x70000011 +#define DT_MIPS_UNREFEXTNO 0x70000012 +#define DT_MIPS_GOTSYM 0x70000013 +#define DT_MIPS_HIPAGENO 0x70000014 +#define DT_MIPS_RLD_MAP 0x70000016 +#define DT_MIPS_DELTA_CLASS 0x70000017 +#define DT_MIPS_DELTA_CLASS_NO 0x70000018 + +#define DT_MIPS_DELTA_INSTANCE 0x70000019 +#define DT_MIPS_DELTA_INSTANCE_NO 0x7000001a + +#define DT_MIPS_DELTA_RELOC 0x7000001b +#define DT_MIPS_DELTA_RELOC_NO 0x7000001c + +#define DT_MIPS_DELTA_SYM 0x7000001d + +#define DT_MIPS_DELTA_SYM_NO 0x7000001e + +#define DT_MIPS_DELTA_CLASSSYM 0x70000020 + +#define DT_MIPS_DELTA_CLASSSYM_NO 0x70000021 + +#define DT_MIPS_CXX_FLAGS 0x70000022 +#define DT_MIPS_PIXIE_INIT 0x70000023 +#define DT_MIPS_SYMBOL_LIB 0x70000024 +#define DT_MIPS_LOCALPAGE_GOTIDX 0x70000025 +#define DT_MIPS_LOCAL_GOTIDX 0x70000026 +#define DT_MIPS_HIDDEN_GOTIDX 0x70000027 +#define DT_MIPS_PROTECTED_GOTIDX 0x70000028 +#define DT_MIPS_OPTIONS 0x70000029 +#define DT_MIPS_INTERFACE 0x7000002a +#define DT_MIPS_DYNSTR_ALIGN 0x7000002b +#define DT_MIPS_INTERFACE_SIZE 0x7000002c +#define DT_MIPS_RLD_TEXT_RESOLVE_ADDR 0x7000002d + +#define DT_MIPS_PERF_SUFFIX 0x7000002e + +#define DT_MIPS_COMPACT_SIZE 0x7000002f +#define DT_MIPS_GP_VALUE 0x70000030 +#define DT_MIPS_AUX_DYNAMIC 0x70000031 + +#define DT_MIPS_PLTGOT 0x70000032 + +#define DT_MIPS_RWPLT 0x70000034 +#define DT_MIPS_RLD_MAP_REL 0x70000035 +#define DT_MIPS_NUM 0x36 + + + +#define RHF_NONE 0 +#define RHF_QUICKSTART (1 << 0) +#define RHF_NOTPOT (1 << 1) +#define RHF_NO_LIBRARY_REPLACEMENT (1 << 2) +#define RHF_NO_MOVE (1 << 3) +#define RHF_SGI_ONLY (1 << 4) +#define RHF_GUARANTEE_INIT (1 << 5) +#define RHF_DELTA_C_PLUS_PLUS (1 << 6) +#define RHF_GUARANTEE_START_INIT (1 << 7) +#define RHF_PIXIE (1 << 8) +#define RHF_DEFAULT_DELAY_LOAD (1 << 9) +#define RHF_REQUICKSTART (1 << 10) +#define RHF_REQUICKSTARTED (1 << 11) +#define RHF_CORD (1 << 12) +#define RHF_NO_UNRES_UNDEF (1 << 13) +#define RHF_RLD_ORDER_SAFE (1 << 14) + + + +typedef struct { + Elf32_Word l_name; + Elf32_Word l_time_stamp; + Elf32_Word l_checksum; + Elf32_Word l_version; + Elf32_Word l_flags; +} Elf32_Lib; + +typedef struct { + Elf64_Word l_name; + Elf64_Word l_time_stamp; + Elf64_Word l_checksum; + Elf64_Word l_version; + Elf64_Word l_flags; +} Elf64_Lib; + + + + +#define LL_NONE 0 +#define LL_EXACT_MATCH (1 << 0) +#define LL_IGNORE_INT_VER (1 << 1) +#define LL_REQUIRE_MINOR (1 << 2) +#define LL_EXPORTS (1 << 3) +#define LL_DELAY_LOAD (1 << 4) +#define LL_DELTA (1 << 5) + + + +typedef Elf32_Addr Elf32_Conflict; + +typedef struct { + Elf32_Half version; + unsigned char isa_level; + unsigned char isa_rev; + unsigned char gpr_size; + unsigned char cpr1_size; + unsigned char cpr2_size; + unsigned char fp_abi; + Elf32_Word isa_ext; + Elf32_Word ases; + Elf32_Word flags1; + Elf32_Word flags2; +} Elf_MIPS_ABIFlags_v0; + +#define MIPS_AFL_REG_NONE 0x00 +#define MIPS_AFL_REG_32 0x01 +#define MIPS_AFL_REG_64 0x02 +#define MIPS_AFL_REG_128 0x03 + +#define MIPS_AFL_ASE_DSP 0x00000001 +#define MIPS_AFL_ASE_DSPR2 0x00000002 +#define MIPS_AFL_ASE_EVA 0x00000004 +#define MIPS_AFL_ASE_MCU 0x00000008 +#define MIPS_AFL_ASE_MDMX 0x00000010 +#define MIPS_AFL_ASE_MIPS3D 0x00000020 +#define MIPS_AFL_ASE_MT 0x00000040 +#define MIPS_AFL_ASE_SMARTMIPS 0x00000080 +#define MIPS_AFL_ASE_VIRT 0x00000100 +#define MIPS_AFL_ASE_MSA 0x00000200 +#define MIPS_AFL_ASE_MIPS16 0x00000400 +#define MIPS_AFL_ASE_MICROMIPS 0x00000800 +#define MIPS_AFL_ASE_XPA 0x00001000 +#define MIPS_AFL_ASE_MASK 0x00001fff + +#define MIPS_AFL_EXT_XLR 1 +#define MIPS_AFL_EXT_OCTEON2 2 +#define MIPS_AFL_EXT_OCTEONP 3 +#define MIPS_AFL_EXT_LOONGSON_3A 4 +#define MIPS_AFL_EXT_OCTEON 5 +#define MIPS_AFL_EXT_5900 6 +#define MIPS_AFL_EXT_4650 7 +#define MIPS_AFL_EXT_4010 8 +#define MIPS_AFL_EXT_4100 9 +#define MIPS_AFL_EXT_3900 10 +#define MIPS_AFL_EXT_10000 11 +#define MIPS_AFL_EXT_SB1 12 +#define MIPS_AFL_EXT_4111 13 +#define MIPS_AFL_EXT_4120 14 +#define MIPS_AFL_EXT_5400 15 +#define MIPS_AFL_EXT_5500 16 +#define MIPS_AFL_EXT_LOONGSON_2E 17 +#define MIPS_AFL_EXT_LOONGSON_2F 18 + +#define MIPS_AFL_FLAGS1_ODDSPREG 1 + +enum +{ + Val_GNU_MIPS_ABI_FP_ANY = 0, + Val_GNU_MIPS_ABI_FP_DOUBLE = 1, + Val_GNU_MIPS_ABI_FP_SINGLE = 2, + Val_GNU_MIPS_ABI_FP_SOFT = 3, + Val_GNU_MIPS_ABI_FP_OLD_64 = 4, + Val_GNU_MIPS_ABI_FP_XX = 5, + Val_GNU_MIPS_ABI_FP_64 = 6, + Val_GNU_MIPS_ABI_FP_64A = 7, + Val_GNU_MIPS_ABI_FP_MAX = 7 +}; + + + + +#define EF_PARISC_TRAPNIL 0x00010000 +#define EF_PARISC_EXT 0x00020000 +#define EF_PARISC_LSB 0x00040000 +#define EF_PARISC_WIDE 0x00080000 +#define EF_PARISC_NO_KABP 0x00100000 + +#define EF_PARISC_LAZYSWAP 0x00400000 +#define EF_PARISC_ARCH 0x0000ffff + + + +#define EFA_PARISC_1_0 0x020b +#define EFA_PARISC_1_1 0x0210 +#define EFA_PARISC_2_0 0x0214 + + + +#define SHN_PARISC_ANSI_COMMON 0xff00 + +#define SHN_PARISC_HUGE_COMMON 0xff01 + + + +#define SHT_PARISC_EXT 0x70000000 +#define SHT_PARISC_UNWIND 0x70000001 +#define SHT_PARISC_DOC 0x70000002 + + + +#define SHF_PARISC_SHORT 0x20000000 +#define SHF_PARISC_HUGE 0x40000000 +#define SHF_PARISC_SBP 0x80000000 + + + +#define STT_PARISC_MILLICODE 13 + +#define STT_HP_OPAQUE (STT_LOOS + 0x1) +#define STT_HP_STUB (STT_LOOS + 0x2) + + + +#define R_PARISC_NONE 0 +#define R_PARISC_DIR32 1 +#define R_PARISC_DIR21L 2 +#define R_PARISC_DIR17R 3 +#define R_PARISC_DIR17F 4 +#define R_PARISC_DIR14R 6 +#define R_PARISC_PCREL32 9 +#define R_PARISC_PCREL21L 10 +#define R_PARISC_PCREL17R 11 +#define R_PARISC_PCREL17F 12 +#define R_PARISC_PCREL14R 14 +#define R_PARISC_DPREL21L 18 +#define R_PARISC_DPREL14R 22 +#define R_PARISC_GPREL21L 26 +#define R_PARISC_GPREL14R 30 +#define R_PARISC_LTOFF21L 34 +#define R_PARISC_LTOFF14R 38 +#define R_PARISC_SECREL32 41 +#define R_PARISC_SEGBASE 48 +#define R_PARISC_SEGREL32 49 +#define R_PARISC_PLTOFF21L 50 +#define R_PARISC_PLTOFF14R 54 +#define R_PARISC_LTOFF_FPTR32 57 +#define R_PARISC_LTOFF_FPTR21L 58 +#define R_PARISC_LTOFF_FPTR14R 62 +#define R_PARISC_FPTR64 64 +#define R_PARISC_PLABEL32 65 +#define R_PARISC_PLABEL21L 66 +#define R_PARISC_PLABEL14R 70 +#define R_PARISC_PCREL64 72 +#define R_PARISC_PCREL22F 74 +#define R_PARISC_PCREL14WR 75 +#define R_PARISC_PCREL14DR 76 +#define R_PARISC_PCREL16F 77 +#define R_PARISC_PCREL16WF 78 +#define R_PARISC_PCREL16DF 79 +#define R_PARISC_DIR64 80 +#define R_PARISC_DIR14WR 83 +#define R_PARISC_DIR14DR 84 +#define R_PARISC_DIR16F 85 +#define R_PARISC_DIR16WF 86 +#define R_PARISC_DIR16DF 87 +#define R_PARISC_GPREL64 88 +#define R_PARISC_GPREL14WR 91 +#define R_PARISC_GPREL14DR 92 +#define R_PARISC_GPREL16F 93 +#define R_PARISC_GPREL16WF 94 +#define R_PARISC_GPREL16DF 95 +#define R_PARISC_LTOFF64 96 +#define R_PARISC_LTOFF14WR 99 +#define R_PARISC_LTOFF14DR 100 +#define R_PARISC_LTOFF16F 101 +#define R_PARISC_LTOFF16WF 102 +#define R_PARISC_LTOFF16DF 103 +#define R_PARISC_SECREL64 104 +#define R_PARISC_SEGREL64 112 +#define R_PARISC_PLTOFF14WR 115 +#define R_PARISC_PLTOFF14DR 116 +#define R_PARISC_PLTOFF16F 117 +#define R_PARISC_PLTOFF16WF 118 +#define R_PARISC_PLTOFF16DF 119 +#define R_PARISC_LTOFF_FPTR64 120 +#define R_PARISC_LTOFF_FPTR14WR 123 +#define R_PARISC_LTOFF_FPTR14DR 124 +#define R_PARISC_LTOFF_FPTR16F 125 +#define R_PARISC_LTOFF_FPTR16WF 126 +#define R_PARISC_LTOFF_FPTR16DF 127 +#define R_PARISC_LORESERVE 128 +#define R_PARISC_COPY 128 +#define R_PARISC_IPLT 129 +#define R_PARISC_EPLT 130 +#define R_PARISC_TPREL32 153 +#define R_PARISC_TPREL21L 154 +#define R_PARISC_TPREL14R 158 +#define R_PARISC_LTOFF_TP21L 162 +#define R_PARISC_LTOFF_TP14R 166 +#define R_PARISC_LTOFF_TP14F 167 +#define R_PARISC_TPREL64 216 +#define R_PARISC_TPREL14WR 219 +#define R_PARISC_TPREL14DR 220 +#define R_PARISC_TPREL16F 221 +#define R_PARISC_TPREL16WF 222 +#define R_PARISC_TPREL16DF 223 +#define R_PARISC_LTOFF_TP64 224 +#define R_PARISC_LTOFF_TP14WR 227 +#define R_PARISC_LTOFF_TP14DR 228 +#define R_PARISC_LTOFF_TP16F 229 +#define R_PARISC_LTOFF_TP16WF 230 +#define R_PARISC_LTOFF_TP16DF 231 +#define R_PARISC_GNU_VTENTRY 232 +#define R_PARISC_GNU_VTINHERIT 233 +#define R_PARISC_TLS_GD21L 234 +#define R_PARISC_TLS_GD14R 235 +#define R_PARISC_TLS_GDCALL 236 +#define R_PARISC_TLS_LDM21L 237 +#define R_PARISC_TLS_LDM14R 238 +#define R_PARISC_TLS_LDMCALL 239 +#define R_PARISC_TLS_LDO21L 240 +#define R_PARISC_TLS_LDO14R 241 +#define R_PARISC_TLS_DTPMOD32 242 +#define R_PARISC_TLS_DTPMOD64 243 +#define R_PARISC_TLS_DTPOFF32 244 +#define R_PARISC_TLS_DTPOFF64 245 +#define R_PARISC_TLS_LE21L R_PARISC_TPREL21L +#define R_PARISC_TLS_LE14R R_PARISC_TPREL14R +#define R_PARISC_TLS_IE21L R_PARISC_LTOFF_TP21L +#define R_PARISC_TLS_IE14R R_PARISC_LTOFF_TP14R +#define R_PARISC_TLS_TPREL32 R_PARISC_TPREL32 +#define R_PARISC_TLS_TPREL64 R_PARISC_TPREL64 +#define R_PARISC_HIRESERVE 255 + + + +#define PT_HP_TLS (PT_LOOS + 0x0) +#define PT_HP_CORE_NONE (PT_LOOS + 0x1) +#define PT_HP_CORE_VERSION (PT_LOOS + 0x2) +#define PT_HP_CORE_KERNEL (PT_LOOS + 0x3) +#define PT_HP_CORE_COMM (PT_LOOS + 0x4) +#define PT_HP_CORE_PROC (PT_LOOS + 0x5) +#define PT_HP_CORE_LOADABLE (PT_LOOS + 0x6) +#define PT_HP_CORE_STACK (PT_LOOS + 0x7) +#define PT_HP_CORE_SHM (PT_LOOS + 0x8) +#define PT_HP_CORE_MMF (PT_LOOS + 0x9) +#define PT_HP_PARALLEL (PT_LOOS + 0x10) +#define PT_HP_FASTBIND (PT_LOOS + 0x11) +#define PT_HP_OPT_ANNOT (PT_LOOS + 0x12) +#define PT_HP_HSL_ANNOT (PT_LOOS + 0x13) +#define PT_HP_STACK (PT_LOOS + 0x14) + +#define PT_PARISC_ARCHEXT 0x70000000 +#define PT_PARISC_UNWIND 0x70000001 + + + +#define PF_PARISC_SBP 0x08000000 + +#define PF_HP_PAGE_SIZE 0x00100000 +#define PF_HP_FAR_SHARED 0x00200000 +#define PF_HP_NEAR_SHARED 0x00400000 +#define PF_HP_CODE 0x01000000 +#define PF_HP_MODIFY 0x02000000 +#define PF_HP_LAZYSWAP 0x04000000 +#define PF_HP_SBP 0x08000000 + + + + + + +#define EF_ALPHA_32BIT 1 +#define EF_ALPHA_CANRELAX 2 + + + + +#define SHT_ALPHA_DEBUG 0x70000001 +#define SHT_ALPHA_REGINFO 0x70000002 + + + +#define SHF_ALPHA_GPREL 0x10000000 + + +#define STO_ALPHA_NOPV 0x80 +#define STO_ALPHA_STD_GPLOAD 0x88 + + + +#define R_ALPHA_NONE 0 +#define R_ALPHA_REFLONG 1 +#define R_ALPHA_REFQUAD 2 +#define R_ALPHA_GPREL32 3 +#define R_ALPHA_LITERAL 4 +#define R_ALPHA_LITUSE 5 +#define R_ALPHA_GPDISP 6 +#define R_ALPHA_BRADDR 7 +#define R_ALPHA_HINT 8 +#define R_ALPHA_SREL16 9 +#define R_ALPHA_SREL32 10 +#define R_ALPHA_SREL64 11 +#define R_ALPHA_GPRELHIGH 17 +#define R_ALPHA_GPRELLOW 18 +#define R_ALPHA_GPREL16 19 +#define R_ALPHA_COPY 24 +#define R_ALPHA_GLOB_DAT 25 +#define R_ALPHA_JMP_SLOT 26 +#define R_ALPHA_RELATIVE 27 +#define R_ALPHA_TLS_GD_HI 28 +#define R_ALPHA_TLSGD 29 +#define R_ALPHA_TLS_LDM 30 +#define R_ALPHA_DTPMOD64 31 +#define R_ALPHA_GOTDTPREL 32 +#define R_ALPHA_DTPREL64 33 +#define R_ALPHA_DTPRELHI 34 +#define R_ALPHA_DTPRELLO 35 +#define R_ALPHA_DTPREL16 36 +#define R_ALPHA_GOTTPREL 37 +#define R_ALPHA_TPREL64 38 +#define R_ALPHA_TPRELHI 39 +#define R_ALPHA_TPRELLO 40 +#define R_ALPHA_TPREL16 41 + +#define R_ALPHA_NUM 46 + + +#define LITUSE_ALPHA_ADDR 0 +#define LITUSE_ALPHA_BASE 1 +#define LITUSE_ALPHA_BYTOFF 2 +#define LITUSE_ALPHA_JSR 3 +#define LITUSE_ALPHA_TLS_GD 4 +#define LITUSE_ALPHA_TLS_LDM 5 + + +#define DT_ALPHA_PLTRO (DT_LOPROC + 0) +#define DT_ALPHA_NUM 1 + + + + +#define EF_PPC_EMB 0x80000000 + + +#define EF_PPC_RELOCATABLE 0x00010000 +#define EF_PPC_RELOCATABLE_LIB 0x00008000 + + + +#define R_PPC_NONE 0 +#define R_PPC_ADDR32 1 +#define R_PPC_ADDR24 2 +#define R_PPC_ADDR16 3 +#define R_PPC_ADDR16_LO 4 +#define R_PPC_ADDR16_HI 5 +#define R_PPC_ADDR16_HA 6 +#define R_PPC_ADDR14 7 +#define R_PPC_ADDR14_BRTAKEN 8 +#define R_PPC_ADDR14_BRNTAKEN 9 +#define R_PPC_REL24 10 +#define R_PPC_REL14 11 +#define R_PPC_REL14_BRTAKEN 12 +#define R_PPC_REL14_BRNTAKEN 13 +#define R_PPC_GOT16 14 +#define R_PPC_GOT16_LO 15 +#define R_PPC_GOT16_HI 16 +#define R_PPC_GOT16_HA 17 +#define R_PPC_PLTREL24 18 +#define R_PPC_COPY 19 +#define R_PPC_GLOB_DAT 20 +#define R_PPC_JMP_SLOT 21 +#define R_PPC_RELATIVE 22 +#define R_PPC_LOCAL24PC 23 +#define R_PPC_UADDR32 24 +#define R_PPC_UADDR16 25 +#define R_PPC_REL32 26 +#define R_PPC_PLT32 27 +#define R_PPC_PLTREL32 28 +#define R_PPC_PLT16_LO 29 +#define R_PPC_PLT16_HI 30 +#define R_PPC_PLT16_HA 31 +#define R_PPC_SDAREL16 32 +#define R_PPC_SECTOFF 33 +#define R_PPC_SECTOFF_LO 34 +#define R_PPC_SECTOFF_HI 35 +#define R_PPC_SECTOFF_HA 36 + + +#define R_PPC_TLS 67 +#define R_PPC_DTPMOD32 68 +#define R_PPC_TPREL16 69 +#define R_PPC_TPREL16_LO 70 +#define R_PPC_TPREL16_HI 71 +#define R_PPC_TPREL16_HA 72 +#define R_PPC_TPREL32 73 +#define R_PPC_DTPREL16 74 +#define R_PPC_DTPREL16_LO 75 +#define R_PPC_DTPREL16_HI 76 +#define R_PPC_DTPREL16_HA 77 +#define R_PPC_DTPREL32 78 +#define R_PPC_GOT_TLSGD16 79 +#define R_PPC_GOT_TLSGD16_LO 80 +#define R_PPC_GOT_TLSGD16_HI 81 +#define R_PPC_GOT_TLSGD16_HA 82 +#define R_PPC_GOT_TLSLD16 83 +#define R_PPC_GOT_TLSLD16_LO 84 +#define R_PPC_GOT_TLSLD16_HI 85 +#define R_PPC_GOT_TLSLD16_HA 86 +#define R_PPC_GOT_TPREL16 87 +#define R_PPC_GOT_TPREL16_LO 88 +#define R_PPC_GOT_TPREL16_HI 89 +#define R_PPC_GOT_TPREL16_HA 90 +#define R_PPC_GOT_DTPREL16 91 +#define R_PPC_GOT_DTPREL16_LO 92 +#define R_PPC_GOT_DTPREL16_HI 93 +#define R_PPC_GOT_DTPREL16_HA 94 +#define R_PPC_TLSGD 95 +#define R_PPC_TLSLD 96 + + +#define R_PPC_EMB_NADDR32 101 +#define R_PPC_EMB_NADDR16 102 +#define R_PPC_EMB_NADDR16_LO 103 +#define R_PPC_EMB_NADDR16_HI 104 +#define R_PPC_EMB_NADDR16_HA 105 +#define R_PPC_EMB_SDAI16 106 +#define R_PPC_EMB_SDA2I16 107 +#define R_PPC_EMB_SDA2REL 108 +#define R_PPC_EMB_SDA21 109 +#define R_PPC_EMB_MRKREF 110 +#define R_PPC_EMB_RELSEC16 111 +#define R_PPC_EMB_RELST_LO 112 +#define R_PPC_EMB_RELST_HI 113 +#define R_PPC_EMB_RELST_HA 114 +#define R_PPC_EMB_BIT_FLD 115 +#define R_PPC_EMB_RELSDA 116 + + +#define R_PPC_DIAB_SDA21_LO 180 +#define R_PPC_DIAB_SDA21_HI 181 +#define R_PPC_DIAB_SDA21_HA 182 +#define R_PPC_DIAB_RELSDA_LO 183 +#define R_PPC_DIAB_RELSDA_HI 184 +#define R_PPC_DIAB_RELSDA_HA 185 + + +#define R_PPC_IRELATIVE 248 + + +#define R_PPC_REL16 249 +#define R_PPC_REL16_LO 250 +#define R_PPC_REL16_HI 251 +#define R_PPC_REL16_HA 252 + + + +#define R_PPC_TOC16 255 + + +#define DT_PPC_GOT (DT_LOPROC + 0) +#define DT_PPC_OPT (DT_LOPROC + 1) +#define DT_PPC_NUM 2 + +#define PPC_OPT_TLS 1 + + +#define R_PPC64_NONE R_PPC_NONE +#define R_PPC64_ADDR32 R_PPC_ADDR32 +#define R_PPC64_ADDR24 R_PPC_ADDR24 +#define R_PPC64_ADDR16 R_PPC_ADDR16 +#define R_PPC64_ADDR16_LO R_PPC_ADDR16_LO +#define R_PPC64_ADDR16_HI R_PPC_ADDR16_HI +#define R_PPC64_ADDR16_HA R_PPC_ADDR16_HA +#define R_PPC64_ADDR14 R_PPC_ADDR14 +#define R_PPC64_ADDR14_BRTAKEN R_PPC_ADDR14_BRTAKEN +#define R_PPC64_ADDR14_BRNTAKEN R_PPC_ADDR14_BRNTAKEN +#define R_PPC64_REL24 R_PPC_REL24 +#define R_PPC64_REL14 R_PPC_REL14 +#define R_PPC64_REL14_BRTAKEN R_PPC_REL14_BRTAKEN +#define R_PPC64_REL14_BRNTAKEN R_PPC_REL14_BRNTAKEN +#define R_PPC64_GOT16 R_PPC_GOT16 +#define R_PPC64_GOT16_LO R_PPC_GOT16_LO +#define R_PPC64_GOT16_HI R_PPC_GOT16_HI +#define R_PPC64_GOT16_HA R_PPC_GOT16_HA + +#define R_PPC64_COPY R_PPC_COPY +#define R_PPC64_GLOB_DAT R_PPC_GLOB_DAT +#define R_PPC64_JMP_SLOT R_PPC_JMP_SLOT +#define R_PPC64_RELATIVE R_PPC_RELATIVE + +#define R_PPC64_UADDR32 R_PPC_UADDR32 +#define R_PPC64_UADDR16 R_PPC_UADDR16 +#define R_PPC64_REL32 R_PPC_REL32 +#define R_PPC64_PLT32 R_PPC_PLT32 +#define R_PPC64_PLTREL32 R_PPC_PLTREL32 +#define R_PPC64_PLT16_LO R_PPC_PLT16_LO +#define R_PPC64_PLT16_HI R_PPC_PLT16_HI +#define R_PPC64_PLT16_HA R_PPC_PLT16_HA + +#define R_PPC64_SECTOFF R_PPC_SECTOFF +#define R_PPC64_SECTOFF_LO R_PPC_SECTOFF_LO +#define R_PPC64_SECTOFF_HI R_PPC_SECTOFF_HI +#define R_PPC64_SECTOFF_HA R_PPC_SECTOFF_HA +#define R_PPC64_ADDR30 37 +#define R_PPC64_ADDR64 38 +#define R_PPC64_ADDR16_HIGHER 39 +#define R_PPC64_ADDR16_HIGHERA 40 +#define R_PPC64_ADDR16_HIGHEST 41 +#define R_PPC64_ADDR16_HIGHESTA 42 +#define R_PPC64_UADDR64 43 +#define R_PPC64_REL64 44 +#define R_PPC64_PLT64 45 +#define R_PPC64_PLTREL64 46 +#define R_PPC64_TOC16 47 +#define R_PPC64_TOC16_LO 48 +#define R_PPC64_TOC16_HI 49 +#define R_PPC64_TOC16_HA 50 +#define R_PPC64_TOC 51 +#define R_PPC64_PLTGOT16 52 +#define R_PPC64_PLTGOT16_LO 53 +#define R_PPC64_PLTGOT16_HI 54 +#define R_PPC64_PLTGOT16_HA 55 + +#define R_PPC64_ADDR16_DS 56 +#define R_PPC64_ADDR16_LO_DS 57 +#define R_PPC64_GOT16_DS 58 +#define R_PPC64_GOT16_LO_DS 59 +#define R_PPC64_PLT16_LO_DS 60 +#define R_PPC64_SECTOFF_DS 61 +#define R_PPC64_SECTOFF_LO_DS 62 +#define R_PPC64_TOC16_DS 63 +#define R_PPC64_TOC16_LO_DS 64 +#define R_PPC64_PLTGOT16_DS 65 +#define R_PPC64_PLTGOT16_LO_DS 66 + + +#define R_PPC64_TLS 67 +#define R_PPC64_DTPMOD64 68 +#define R_PPC64_TPREL16 69 +#define R_PPC64_TPREL16_LO 70 +#define R_PPC64_TPREL16_HI 71 +#define R_PPC64_TPREL16_HA 72 +#define R_PPC64_TPREL64 73 +#define R_PPC64_DTPREL16 74 +#define R_PPC64_DTPREL16_LO 75 +#define R_PPC64_DTPREL16_HI 76 +#define R_PPC64_DTPREL16_HA 77 +#define R_PPC64_DTPREL64 78 +#define R_PPC64_GOT_TLSGD16 79 +#define R_PPC64_GOT_TLSGD16_LO 80 +#define R_PPC64_GOT_TLSGD16_HI 81 +#define R_PPC64_GOT_TLSGD16_HA 82 +#define R_PPC64_GOT_TLSLD16 83 +#define R_PPC64_GOT_TLSLD16_LO 84 +#define R_PPC64_GOT_TLSLD16_HI 85 +#define R_PPC64_GOT_TLSLD16_HA 86 +#define R_PPC64_GOT_TPREL16_DS 87 +#define R_PPC64_GOT_TPREL16_LO_DS 88 +#define R_PPC64_GOT_TPREL16_HI 89 +#define R_PPC64_GOT_TPREL16_HA 90 +#define R_PPC64_GOT_DTPREL16_DS 91 +#define R_PPC64_GOT_DTPREL16_LO_DS 92 +#define R_PPC64_GOT_DTPREL16_HI 93 +#define R_PPC64_GOT_DTPREL16_HA 94 +#define R_PPC64_TPREL16_DS 95 +#define R_PPC64_TPREL16_LO_DS 96 +#define R_PPC64_TPREL16_HIGHER 97 +#define R_PPC64_TPREL16_HIGHERA 98 +#define R_PPC64_TPREL16_HIGHEST 99 +#define R_PPC64_TPREL16_HIGHESTA 100 +#define R_PPC64_DTPREL16_DS 101 +#define R_PPC64_DTPREL16_LO_DS 102 +#define R_PPC64_DTPREL16_HIGHER 103 +#define R_PPC64_DTPREL16_HIGHERA 104 +#define R_PPC64_DTPREL16_HIGHEST 105 +#define R_PPC64_DTPREL16_HIGHESTA 106 +#define R_PPC64_TLSGD 107 +#define R_PPC64_TLSLD 108 +#define R_PPC64_TOCSAVE 109 +#define R_PPC64_ADDR16_HIGH 110 +#define R_PPC64_ADDR16_HIGHA 111 +#define R_PPC64_TPREL16_HIGH 112 +#define R_PPC64_TPREL16_HIGHA 113 +#define R_PPC64_DTPREL16_HIGH 114 +#define R_PPC64_DTPREL16_HIGHA 115 + + +#define R_PPC64_JMP_IREL 247 +#define R_PPC64_IRELATIVE 248 +#define R_PPC64_REL16 249 +#define R_PPC64_REL16_LO 250 +#define R_PPC64_REL16_HI 251 +#define R_PPC64_REL16_HA 252 + +#define EF_PPC64_ABI 3 + +#define DT_PPC64_GLINK (DT_LOPROC + 0) +#define DT_PPC64_OPD (DT_LOPROC + 1) +#define DT_PPC64_OPDSZ (DT_LOPROC + 2) +#define DT_PPC64_OPT (DT_LOPROC + 3) +#define DT_PPC64_NUM 4 + +#define PPC64_OPT_TLS 1 +#define PPC64_OPT_MULTI_TOC 2 + +#define STO_PPC64_LOCAL_BIT 5 +#define STO_PPC64_LOCAL_MASK 0xe0 +#define PPC64_LOCAL_ENTRY_OFFSET(x) (1 << (((x)&0xe0)>>5) & 0xfc) + + +#define EF_ARM_RELEXEC 0x01 +#define EF_ARM_HASENTRY 0x02 +#define EF_ARM_INTERWORK 0x04 +#define EF_ARM_APCS_26 0x08 +#define EF_ARM_APCS_FLOAT 0x10 +#define EF_ARM_PIC 0x20 +#define EF_ARM_ALIGN8 0x40 +#define EF_ARM_NEW_ABI 0x80 +#define EF_ARM_OLD_ABI 0x100 +#define EF_ARM_SOFT_FLOAT 0x200 +#define EF_ARM_VFP_FLOAT 0x400 +#define EF_ARM_MAVERICK_FLOAT 0x800 + +#define EF_ARM_ABI_FLOAT_SOFT 0x200 +#define EF_ARM_ABI_FLOAT_HARD 0x400 + + +#define EF_ARM_SYMSARESORTED 0x04 +#define EF_ARM_DYNSYMSUSESEGIDX 0x08 +#define EF_ARM_MAPSYMSFIRST 0x10 +#define EF_ARM_EABIMASK 0XFF000000 + + +#define EF_ARM_BE8 0x00800000 +#define EF_ARM_LE8 0x00400000 + +#define EF_ARM_EABI_VERSION(flags) ((flags) & EF_ARM_EABIMASK) +#define EF_ARM_EABI_UNKNOWN 0x00000000 +#define EF_ARM_EABI_VER1 0x01000000 +#define EF_ARM_EABI_VER2 0x02000000 +#define EF_ARM_EABI_VER3 0x03000000 +#define EF_ARM_EABI_VER4 0x04000000 +#define EF_ARM_EABI_VER5 0x05000000 + + +#define STT_ARM_TFUNC STT_LOPROC +#define STT_ARM_16BIT STT_HIPROC + + +#define SHF_ARM_ENTRYSECT 0x10000000 +#define SHF_ARM_COMDEF 0x80000000 + + + +#define PF_ARM_SB 0x10000000 + +#define PF_ARM_PI 0x20000000 +#define PF_ARM_ABS 0x40000000 + + +#define PT_ARM_EXIDX (PT_LOPROC + 1) + + +#define SHT_ARM_EXIDX (SHT_LOPROC + 1) +#define SHT_ARM_PREEMPTMAP (SHT_LOPROC + 2) +#define SHT_ARM_ATTRIBUTES (SHT_LOPROC + 3) + +#define R_AARCH64_NONE 0 +#define R_AARCH64_P32_ABS32 1 +#define R_AARCH64_P32_COPY 180 +#define R_AARCH64_P32_GLOB_DAT 181 +#define R_AARCH64_P32_JUMP_SLOT 182 +#define R_AARCH64_P32_RELATIVE 183 +#define R_AARCH64_P32_TLS_DTPMOD 184 +#define R_AARCH64_P32_TLS_DTPREL 185 +#define R_AARCH64_P32_TLS_TPREL 186 +#define R_AARCH64_P32_TLSDESC 187 +#define R_AARCH64_P32_IRELATIVE 188 +#define R_AARCH64_ABS64 257 +#define R_AARCH64_ABS32 258 +#define R_AARCH64_ABS16 259 +#define R_AARCH64_PREL64 260 +#define R_AARCH64_PREL32 261 +#define R_AARCH64_PREL16 262 +#define R_AARCH64_MOVW_UABS_G0 263 +#define R_AARCH64_MOVW_UABS_G0_NC 264 +#define R_AARCH64_MOVW_UABS_G1 265 +#define R_AARCH64_MOVW_UABS_G1_NC 266 +#define R_AARCH64_MOVW_UABS_G2 267 +#define R_AARCH64_MOVW_UABS_G2_NC 268 +#define R_AARCH64_MOVW_UABS_G3 269 +#define R_AARCH64_MOVW_SABS_G0 270 +#define R_AARCH64_MOVW_SABS_G1 271 +#define R_AARCH64_MOVW_SABS_G2 272 +#define R_AARCH64_LD_PREL_LO19 273 +#define R_AARCH64_ADR_PREL_LO21 274 +#define R_AARCH64_ADR_PREL_PG_HI21 275 +#define R_AARCH64_ADR_PREL_PG_HI21_NC 276 +#define R_AARCH64_ADD_ABS_LO12_NC 277 +#define R_AARCH64_LDST8_ABS_LO12_NC 278 +#define R_AARCH64_TSTBR14 279 +#define R_AARCH64_CONDBR19 280 +#define R_AARCH64_JUMP26 282 +#define R_AARCH64_CALL26 283 +#define R_AARCH64_LDST16_ABS_LO12_NC 284 +#define R_AARCH64_LDST32_ABS_LO12_NC 285 +#define R_AARCH64_LDST64_ABS_LO12_NC 286 +#define R_AARCH64_MOVW_PREL_G0 287 +#define R_AARCH64_MOVW_PREL_G0_NC 288 +#define R_AARCH64_MOVW_PREL_G1 289 +#define R_AARCH64_MOVW_PREL_G1_NC 290 +#define R_AARCH64_MOVW_PREL_G2 291 +#define R_AARCH64_MOVW_PREL_G2_NC 292 +#define R_AARCH64_MOVW_PREL_G3 293 +#define R_AARCH64_LDST128_ABS_LO12_NC 299 +#define R_AARCH64_MOVW_GOTOFF_G0 300 +#define R_AARCH64_MOVW_GOTOFF_G0_NC 301 +#define R_AARCH64_MOVW_GOTOFF_G1 302 +#define R_AARCH64_MOVW_GOTOFF_G1_NC 303 +#define R_AARCH64_MOVW_GOTOFF_G2 304 +#define R_AARCH64_MOVW_GOTOFF_G2_NC 305 +#define R_AARCH64_MOVW_GOTOFF_G3 306 +#define R_AARCH64_GOTREL64 307 +#define R_AARCH64_GOTREL32 308 +#define R_AARCH64_GOT_LD_PREL19 309 +#define R_AARCH64_LD64_GOTOFF_LO15 310 +#define R_AARCH64_ADR_GOT_PAGE 311 +#define R_AARCH64_LD64_GOT_LO12_NC 312 +#define R_AARCH64_LD64_GOTPAGE_LO15 313 +#define R_AARCH64_TLSGD_ADR_PREL21 512 +#define R_AARCH64_TLSGD_ADR_PAGE21 513 +#define R_AARCH64_TLSGD_ADD_LO12_NC 514 +#define R_AARCH64_TLSGD_MOVW_G1 515 +#define R_AARCH64_TLSGD_MOVW_G0_NC 516 +#define R_AARCH64_TLSLD_ADR_PREL21 517 +#define R_AARCH64_TLSLD_ADR_PAGE21 518 +#define R_AARCH64_TLSLD_ADD_LO12_NC 519 +#define R_AARCH64_TLSLD_MOVW_G1 520 +#define R_AARCH64_TLSLD_MOVW_G0_NC 521 +#define R_AARCH64_TLSLD_LD_PREL19 522 +#define R_AARCH64_TLSLD_MOVW_DTPREL_G2 523 +#define R_AARCH64_TLSLD_MOVW_DTPREL_G1 524 +#define R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC 525 +#define R_AARCH64_TLSLD_MOVW_DTPREL_G0 526 +#define R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC 527 +#define R_AARCH64_TLSLD_ADD_DTPREL_HI12 528 +#define R_AARCH64_TLSLD_ADD_DTPREL_LO12 529 +#define R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC 530 +#define R_AARCH64_TLSLD_LDST8_DTPREL_LO12 531 +#define R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC 532 +#define R_AARCH64_TLSLD_LDST16_DTPREL_LO12 533 +#define R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC 534 +#define R_AARCH64_TLSLD_LDST32_DTPREL_LO12 535 +#define R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC 536 +#define R_AARCH64_TLSLD_LDST64_DTPREL_LO12 537 +#define R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC 538 +#define R_AARCH64_TLSIE_MOVW_GOTTPREL_G1 539 +#define R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC 540 +#define R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 541 +#define R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC 542 +#define R_AARCH64_TLSIE_LD_GOTTPREL_PREL19 543 +#define R_AARCH64_TLSLE_MOVW_TPREL_G2 544 +#define R_AARCH64_TLSLE_MOVW_TPREL_G1 545 +#define R_AARCH64_TLSLE_MOVW_TPREL_G1_NC 546 +#define R_AARCH64_TLSLE_MOVW_TPREL_G0 547 +#define R_AARCH64_TLSLE_MOVW_TPREL_G0_NC 548 +#define R_AARCH64_TLSLE_ADD_TPREL_HI12 549 +#define R_AARCH64_TLSLE_ADD_TPREL_LO12 550 +#define R_AARCH64_TLSLE_ADD_TPREL_LO12_NC 551 +#define R_AARCH64_TLSLE_LDST8_TPREL_LO12 552 +#define R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC 553 +#define R_AARCH64_TLSLE_LDST16_TPREL_LO12 554 +#define R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC 555 +#define R_AARCH64_TLSLE_LDST32_TPREL_LO12 556 +#define R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC 557 +#define R_AARCH64_TLSLE_LDST64_TPREL_LO12 558 +#define R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC 559 +#define R_AARCH64_TLSDESC_LD_PREL19 560 +#define R_AARCH64_TLSDESC_ADR_PREL21 561 +#define R_AARCH64_TLSDESC_ADR_PAGE21 562 +#define R_AARCH64_TLSDESC_LD64_LO12 563 +#define R_AARCH64_TLSDESC_ADD_LO12 564 +#define R_AARCH64_TLSDESC_OFF_G1 565 +#define R_AARCH64_TLSDESC_OFF_G0_NC 566 +#define R_AARCH64_TLSDESC_LDR 567 +#define R_AARCH64_TLSDESC_ADD 568 +#define R_AARCH64_TLSDESC_CALL 569 +#define R_AARCH64_TLSLE_LDST128_TPREL_LO12 570 +#define R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC 571 +#define R_AARCH64_TLSLD_LDST128_DTPREL_LO12 572 +#define R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC 573 +#define R_AARCH64_COPY 1024 +#define R_AARCH64_GLOB_DAT 1025 +#define R_AARCH64_JUMP_SLOT 1026 +#define R_AARCH64_RELATIVE 1027 +#define R_AARCH64_TLS_DTPMOD 1028 +#define R_AARCH64_TLS_DTPMOD64 1028 +#define R_AARCH64_TLS_DTPREL 1029 +#define R_AARCH64_TLS_DTPREL64 1029 +#define R_AARCH64_TLS_TPREL 1030 +#define R_AARCH64_TLS_TPREL64 1030 +#define R_AARCH64_TLSDESC 1031 + + +#define R_ARM_NONE 0 +#define R_ARM_PC24 1 +#define R_ARM_ABS32 2 +#define R_ARM_REL32 3 +#define R_ARM_PC13 4 +#define R_ARM_ABS16 5 +#define R_ARM_ABS12 6 +#define R_ARM_THM_ABS5 7 +#define R_ARM_ABS8 8 +#define R_ARM_SBREL32 9 +#define R_ARM_THM_PC22 10 +#define R_ARM_THM_PC8 11 +#define R_ARM_AMP_VCALL9 12 +#define R_ARM_TLS_DESC 13 +#define R_ARM_THM_SWI8 14 +#define R_ARM_XPC25 15 +#define R_ARM_THM_XPC22 16 +#define R_ARM_TLS_DTPMOD32 17 +#define R_ARM_TLS_DTPOFF32 18 +#define R_ARM_TLS_TPOFF32 19 +#define R_ARM_COPY 20 +#define R_ARM_GLOB_DAT 21 +#define R_ARM_JUMP_SLOT 22 +#define R_ARM_RELATIVE 23 +#define R_ARM_GOTOFF 24 +#define R_ARM_GOTPC 25 +#define R_ARM_GOT32 26 +#define R_ARM_PLT32 27 +#define R_ARM_CALL 28 +#define R_ARM_JUMP24 29 +#define R_ARM_THM_JUMP24 30 +#define R_ARM_BASE_ABS 31 +#define R_ARM_ALU_PCREL_7_0 32 +#define R_ARM_ALU_PCREL_15_8 33 +#define R_ARM_ALU_PCREL_23_15 34 +#define R_ARM_LDR_SBREL_11_0 35 +#define R_ARM_ALU_SBREL_19_12 36 +#define R_ARM_ALU_SBREL_27_20 37 +#define R_ARM_TARGET1 38 +#define R_ARM_SBREL31 39 +#define R_ARM_V4BX 40 +#define R_ARM_TARGET2 41 +#define R_ARM_PREL31 42 +#define R_ARM_MOVW_ABS_NC 43 +#define R_ARM_MOVT_ABS 44 +#define R_ARM_MOVW_PREL_NC 45 +#define R_ARM_MOVT_PREL 46 +#define R_ARM_THM_MOVW_ABS_NC 47 +#define R_ARM_THM_MOVT_ABS 48 +#define R_ARM_THM_MOVW_PREL_NC 49 +#define R_ARM_THM_MOVT_PREL 50 +#define R_ARM_THM_JUMP19 51 +#define R_ARM_THM_JUMP6 52 +#define R_ARM_THM_ALU_PREL_11_0 53 +#define R_ARM_THM_PC12 54 +#define R_ARM_ABS32_NOI 55 +#define R_ARM_REL32_NOI 56 +#define R_ARM_ALU_PC_G0_NC 57 +#define R_ARM_ALU_PC_G0 58 +#define R_ARM_ALU_PC_G1_NC 59 +#define R_ARM_ALU_PC_G1 60 +#define R_ARM_ALU_PC_G2 61 +#define R_ARM_LDR_PC_G1 62 +#define R_ARM_LDR_PC_G2 63 +#define R_ARM_LDRS_PC_G0 64 +#define R_ARM_LDRS_PC_G1 65 +#define R_ARM_LDRS_PC_G2 66 +#define R_ARM_LDC_PC_G0 67 +#define R_ARM_LDC_PC_G1 68 +#define R_ARM_LDC_PC_G2 69 +#define R_ARM_ALU_SB_G0_NC 70 +#define R_ARM_ALU_SB_G0 71 +#define R_ARM_ALU_SB_G1_NC 72 +#define R_ARM_ALU_SB_G1 73 +#define R_ARM_ALU_SB_G2 74 +#define R_ARM_LDR_SB_G0 75 +#define R_ARM_LDR_SB_G1 76 +#define R_ARM_LDR_SB_G2 77 +#define R_ARM_LDRS_SB_G0 78 +#define R_ARM_LDRS_SB_G1 79 +#define R_ARM_LDRS_SB_G2 80 +#define R_ARM_LDC_SB_G0 81 +#define R_ARM_LDC_SB_G1 82 +#define R_ARM_LDC_SB_G2 83 +#define R_ARM_MOVW_BREL_NC 84 +#define R_ARM_MOVT_BREL 85 +#define R_ARM_MOVW_BREL 86 +#define R_ARM_THM_MOVW_BREL_NC 87 +#define R_ARM_THM_MOVT_BREL 88 +#define R_ARM_THM_MOVW_BREL 89 +#define R_ARM_TLS_GOTDESC 90 +#define R_ARM_TLS_CALL 91 +#define R_ARM_TLS_DESCSEQ 92 +#define R_ARM_THM_TLS_CALL 93 +#define R_ARM_PLT32_ABS 94 +#define R_ARM_GOT_ABS 95 +#define R_ARM_GOT_PREL 96 +#define R_ARM_GOT_BREL12 97 +#define R_ARM_GOTOFF12 98 +#define R_ARM_GOTRELAX 99 +#define R_ARM_GNU_VTENTRY 100 +#define R_ARM_GNU_VTINHERIT 101 +#define R_ARM_THM_PC11 102 +#define R_ARM_THM_PC9 103 +#define R_ARM_TLS_GD32 104 + +#define R_ARM_TLS_LDM32 105 + +#define R_ARM_TLS_LDO32 106 + +#define R_ARM_TLS_IE32 107 + +#define R_ARM_TLS_LE32 108 +#define R_ARM_TLS_LDO12 109 +#define R_ARM_TLS_LE12 110 +#define R_ARM_TLS_IE12GP 111 +#define R_ARM_ME_TOO 128 +#define R_ARM_THM_TLS_DESCSEQ 129 +#define R_ARM_THM_TLS_DESCSEQ16 129 +#define R_ARM_THM_TLS_DESCSEQ32 130 +#define R_ARM_THM_GOT_BREL12 131 +#define R_ARM_IRELATIVE 160 +#define R_ARM_RXPC25 249 +#define R_ARM_RSBREL32 250 +#define R_ARM_THM_RPC22 251 +#define R_ARM_RREL32 252 +#define R_ARM_RABS22 253 +#define R_ARM_RPC24 254 +#define R_ARM_RBASE 255 + +#define R_ARM_NUM 256 + + + + +#define EF_IA_64_MASKOS 0x0000000f +#define EF_IA_64_ABI64 0x00000010 +#define EF_IA_64_ARCH 0xff000000 + + +#define PT_IA_64_ARCHEXT (PT_LOPROC + 0) +#define PT_IA_64_UNWIND (PT_LOPROC + 1) +#define PT_IA_64_HP_OPT_ANOT (PT_LOOS + 0x12) +#define PT_IA_64_HP_HSL_ANOT (PT_LOOS + 0x13) +#define PT_IA_64_HP_STACK (PT_LOOS + 0x14) + + +#define PF_IA_64_NORECOV 0x80000000 + + +#define SHT_IA_64_EXT (SHT_LOPROC + 0) +#define SHT_IA_64_UNWIND (SHT_LOPROC + 1) + + +#define SHF_IA_64_SHORT 0x10000000 +#define SHF_IA_64_NORECOV 0x20000000 + + +#define DT_IA_64_PLT_RESERVE (DT_LOPROC + 0) +#define DT_IA_64_NUM 1 + + +#define R_IA64_NONE 0x00 +#define R_IA64_IMM14 0x21 +#define R_IA64_IMM22 0x22 +#define R_IA64_IMM64 0x23 +#define R_IA64_DIR32MSB 0x24 +#define R_IA64_DIR32LSB 0x25 +#define R_IA64_DIR64MSB 0x26 +#define R_IA64_DIR64LSB 0x27 +#define R_IA64_GPREL22 0x2a +#define R_IA64_GPREL64I 0x2b +#define R_IA64_GPREL32MSB 0x2c +#define R_IA64_GPREL32LSB 0x2d +#define R_IA64_GPREL64MSB 0x2e +#define R_IA64_GPREL64LSB 0x2f +#define R_IA64_LTOFF22 0x32 +#define R_IA64_LTOFF64I 0x33 +#define R_IA64_PLTOFF22 0x3a +#define R_IA64_PLTOFF64I 0x3b +#define R_IA64_PLTOFF64MSB 0x3e +#define R_IA64_PLTOFF64LSB 0x3f +#define R_IA64_FPTR64I 0x43 +#define R_IA64_FPTR32MSB 0x44 +#define R_IA64_FPTR32LSB 0x45 +#define R_IA64_FPTR64MSB 0x46 +#define R_IA64_FPTR64LSB 0x47 +#define R_IA64_PCREL60B 0x48 +#define R_IA64_PCREL21B 0x49 +#define R_IA64_PCREL21M 0x4a +#define R_IA64_PCREL21F 0x4b +#define R_IA64_PCREL32MSB 0x4c +#define R_IA64_PCREL32LSB 0x4d +#define R_IA64_PCREL64MSB 0x4e +#define R_IA64_PCREL64LSB 0x4f +#define R_IA64_LTOFF_FPTR22 0x52 +#define R_IA64_LTOFF_FPTR64I 0x53 +#define R_IA64_LTOFF_FPTR32MSB 0x54 +#define R_IA64_LTOFF_FPTR32LSB 0x55 +#define R_IA64_LTOFF_FPTR64MSB 0x56 +#define R_IA64_LTOFF_FPTR64LSB 0x57 +#define R_IA64_SEGREL32MSB 0x5c +#define R_IA64_SEGREL32LSB 0x5d +#define R_IA64_SEGREL64MSB 0x5e +#define R_IA64_SEGREL64LSB 0x5f +#define R_IA64_SECREL32MSB 0x64 +#define R_IA64_SECREL32LSB 0x65 +#define R_IA64_SECREL64MSB 0x66 +#define R_IA64_SECREL64LSB 0x67 +#define R_IA64_REL32MSB 0x6c +#define R_IA64_REL32LSB 0x6d +#define R_IA64_REL64MSB 0x6e +#define R_IA64_REL64LSB 0x6f +#define R_IA64_LTV32MSB 0x74 +#define R_IA64_LTV32LSB 0x75 +#define R_IA64_LTV64MSB 0x76 +#define R_IA64_LTV64LSB 0x77 +#define R_IA64_PCREL21BI 0x79 +#define R_IA64_PCREL22 0x7a +#define R_IA64_PCREL64I 0x7b +#define R_IA64_IPLTMSB 0x80 +#define R_IA64_IPLTLSB 0x81 +#define R_IA64_COPY 0x84 +#define R_IA64_SUB 0x85 +#define R_IA64_LTOFF22X 0x86 +#define R_IA64_LDXMOV 0x87 +#define R_IA64_TPREL14 0x91 +#define R_IA64_TPREL22 0x92 +#define R_IA64_TPREL64I 0x93 +#define R_IA64_TPREL64MSB 0x96 +#define R_IA64_TPREL64LSB 0x97 +#define R_IA64_LTOFF_TPREL22 0x9a +#define R_IA64_DTPMOD64MSB 0xa6 +#define R_IA64_DTPMOD64LSB 0xa7 +#define R_IA64_LTOFF_DTPMOD22 0xaa +#define R_IA64_DTPREL14 0xb1 +#define R_IA64_DTPREL22 0xb2 +#define R_IA64_DTPREL64I 0xb3 +#define R_IA64_DTPREL32MSB 0xb4 +#define R_IA64_DTPREL32LSB 0xb5 +#define R_IA64_DTPREL64MSB 0xb6 +#define R_IA64_DTPREL64LSB 0xb7 +#define R_IA64_LTOFF_DTPREL22 0xba + + +#define EF_SH_MACH_MASK 0x1f +#define EF_SH_UNKNOWN 0x0 +#define EF_SH1 0x1 +#define EF_SH2 0x2 +#define EF_SH3 0x3 +#define EF_SH_DSP 0x4 +#define EF_SH3_DSP 0x5 +#define EF_SH4AL_DSP 0x6 +#define EF_SH3E 0x8 +#define EF_SH4 0x9 +#define EF_SH2E 0xb +#define EF_SH4A 0xc +#define EF_SH2A 0xd +#define EF_SH4_NOFPU 0x10 +#define EF_SH4A_NOFPU 0x11 +#define EF_SH4_NOMMU_NOFPU 0x12 +#define EF_SH2A_NOFPU 0x13 +#define EF_SH3_NOMMU 0x14 +#define EF_SH2A_SH4_NOFPU 0x15 +#define EF_SH2A_SH3_NOFPU 0x16 +#define EF_SH2A_SH4 0x17 +#define EF_SH2A_SH3E 0x18 + +#define R_SH_NONE 0 +#define R_SH_DIR32 1 +#define R_SH_REL32 2 +#define R_SH_DIR8WPN 3 +#define R_SH_IND12W 4 +#define R_SH_DIR8WPL 5 +#define R_SH_DIR8WPZ 6 +#define R_SH_DIR8BP 7 +#define R_SH_DIR8W 8 +#define R_SH_DIR8L 9 +#define R_SH_SWITCH16 25 +#define R_SH_SWITCH32 26 +#define R_SH_USES 27 +#define R_SH_COUNT 28 +#define R_SH_ALIGN 29 +#define R_SH_CODE 30 +#define R_SH_DATA 31 +#define R_SH_LABEL 32 +#define R_SH_SWITCH8 33 +#define R_SH_GNU_VTINHERIT 34 +#define R_SH_GNU_VTENTRY 35 +#define R_SH_TLS_GD_32 144 +#define R_SH_TLS_LD_32 145 +#define R_SH_TLS_LDO_32 146 +#define R_SH_TLS_IE_32 147 +#define R_SH_TLS_LE_32 148 +#define R_SH_TLS_DTPMOD32 149 +#define R_SH_TLS_DTPOFF32 150 +#define R_SH_TLS_TPOFF32 151 +#define R_SH_GOT32 160 +#define R_SH_PLT32 161 +#define R_SH_COPY 162 +#define R_SH_GLOB_DAT 163 +#define R_SH_JMP_SLOT 164 +#define R_SH_RELATIVE 165 +#define R_SH_GOTOFF 166 +#define R_SH_GOTPC 167 +#define R_SH_GOT20 201 +#define R_SH_GOTOFF20 202 +#define R_SH_GOTFUNCDESC 203 +#define R_SH_GOTFUNCDEST20 204 +#define R_SH_GOTOFFFUNCDESC 205 +#define R_SH_GOTOFFFUNCDEST20 206 +#define R_SH_FUNCDESC 207 +#define R_SH_FUNCDESC_VALUE 208 + +#define R_SH_NUM 256 + + + +#define R_390_NONE 0 +#define R_390_8 1 +#define R_390_12 2 +#define R_390_16 3 +#define R_390_32 4 +#define R_390_PC32 5 +#define R_390_GOT12 6 +#define R_390_GOT32 7 +#define R_390_PLT32 8 +#define R_390_COPY 9 +#define R_390_GLOB_DAT 10 +#define R_390_JMP_SLOT 11 +#define R_390_RELATIVE 12 +#define R_390_GOTOFF32 13 +#define R_390_GOTPC 14 +#define R_390_GOT16 15 +#define R_390_PC16 16 +#define R_390_PC16DBL 17 +#define R_390_PLT16DBL 18 +#define R_390_PC32DBL 19 +#define R_390_PLT32DBL 20 +#define R_390_GOTPCDBL 21 +#define R_390_64 22 +#define R_390_PC64 23 +#define R_390_GOT64 24 +#define R_390_PLT64 25 +#define R_390_GOTENT 26 +#define R_390_GOTOFF16 27 +#define R_390_GOTOFF64 28 +#define R_390_GOTPLT12 29 +#define R_390_GOTPLT16 30 +#define R_390_GOTPLT32 31 +#define R_390_GOTPLT64 32 +#define R_390_GOTPLTENT 33 +#define R_390_PLTOFF16 34 +#define R_390_PLTOFF32 35 +#define R_390_PLTOFF64 36 +#define R_390_TLS_LOAD 37 +#define R_390_TLS_GDCALL 38 + +#define R_390_TLS_LDCALL 39 + +#define R_390_TLS_GD32 40 + +#define R_390_TLS_GD64 41 + +#define R_390_TLS_GOTIE12 42 + +#define R_390_TLS_GOTIE32 43 + +#define R_390_TLS_GOTIE64 44 + +#define R_390_TLS_LDM32 45 + +#define R_390_TLS_LDM64 46 + +#define R_390_TLS_IE32 47 + +#define R_390_TLS_IE64 48 + +#define R_390_TLS_IEENT 49 + +#define R_390_TLS_LE32 50 + +#define R_390_TLS_LE64 51 + +#define R_390_TLS_LDO32 52 + +#define R_390_TLS_LDO64 53 + +#define R_390_TLS_DTPMOD 54 +#define R_390_TLS_DTPOFF 55 +#define R_390_TLS_TPOFF 56 + +#define R_390_20 57 +#define R_390_GOT20 58 +#define R_390_GOTPLT20 59 +#define R_390_TLS_GOTIE20 60 + + +#define R_390_NUM 61 + + + +#define R_CRIS_NONE 0 +#define R_CRIS_8 1 +#define R_CRIS_16 2 +#define R_CRIS_32 3 +#define R_CRIS_8_PCREL 4 +#define R_CRIS_16_PCREL 5 +#define R_CRIS_32_PCREL 6 +#define R_CRIS_GNU_VTINHERIT 7 +#define R_CRIS_GNU_VTENTRY 8 +#define R_CRIS_COPY 9 +#define R_CRIS_GLOB_DAT 10 +#define R_CRIS_JUMP_SLOT 11 +#define R_CRIS_RELATIVE 12 +#define R_CRIS_16_GOT 13 +#define R_CRIS_32_GOT 14 +#define R_CRIS_16_GOTPLT 15 +#define R_CRIS_32_GOTPLT 16 +#define R_CRIS_32_GOTREL 17 +#define R_CRIS_32_PLT_GOTREL 18 +#define R_CRIS_32_PLT_PCREL 19 + +#define R_CRIS_NUM 20 + + + +#define R_X86_64_NONE 0 +#define R_X86_64_64 1 +#define R_X86_64_PC32 2 +#define R_X86_64_GOT32 3 +#define R_X86_64_PLT32 4 +#define R_X86_64_COPY 5 +#define R_X86_64_GLOB_DAT 6 +#define R_X86_64_JUMP_SLOT 7 +#define R_X86_64_RELATIVE 8 +#define R_X86_64_GOTPCREL 9 + +#define R_X86_64_32 10 +#define R_X86_64_32S 11 +#define R_X86_64_16 12 +#define R_X86_64_PC16 13 +#define R_X86_64_8 14 +#define R_X86_64_PC8 15 +#define R_X86_64_DTPMOD64 16 +#define R_X86_64_DTPOFF64 17 +#define R_X86_64_TPOFF64 18 +#define R_X86_64_TLSGD 19 + +#define R_X86_64_TLSLD 20 + +#define R_X86_64_DTPOFF32 21 +#define R_X86_64_GOTTPOFF 22 + +#define R_X86_64_TPOFF32 23 +#define R_X86_64_PC64 24 +#define R_X86_64_GOTOFF64 25 +#define R_X86_64_GOTPC32 26 +#define R_X86_64_GOT64 27 +#define R_X86_64_GOTPCREL64 28 +#define R_X86_64_GOTPC64 29 +#define R_X86_64_GOTPLT64 30 +#define R_X86_64_PLTOFF64 31 +#define R_X86_64_SIZE32 32 +#define R_X86_64_SIZE64 33 + +#define R_X86_64_GOTPC32_TLSDESC 34 +#define R_X86_64_TLSDESC_CALL 35 + +#define R_X86_64_TLSDESC 36 +#define R_X86_64_IRELATIVE 37 +#define R_X86_64_RELATIVE64 38 +#define R_X86_64_GOTPCRELX 41 +#define R_X86_64_REX_GOTPCRELX 42 +#define R_X86_64_NUM 43 + + + +#define R_MN10300_NONE 0 +#define R_MN10300_32 1 +#define R_MN10300_16 2 +#define R_MN10300_8 3 +#define R_MN10300_PCREL32 4 +#define R_MN10300_PCREL16 5 +#define R_MN10300_PCREL8 6 +#define R_MN10300_GNU_VTINHERIT 7 +#define R_MN10300_GNU_VTENTRY 8 +#define R_MN10300_24 9 +#define R_MN10300_GOTPC32 10 +#define R_MN10300_GOTPC16 11 +#define R_MN10300_GOTOFF32 12 +#define R_MN10300_GOTOFF24 13 +#define R_MN10300_GOTOFF16 14 +#define R_MN10300_PLT32 15 +#define R_MN10300_PLT16 16 +#define R_MN10300_GOT32 17 +#define R_MN10300_GOT24 18 +#define R_MN10300_GOT16 19 +#define R_MN10300_COPY 20 +#define R_MN10300_GLOB_DAT 21 +#define R_MN10300_JMP_SLOT 22 +#define R_MN10300_RELATIVE 23 + +#define R_MN10300_NUM 24 + + + +#define R_M32R_NONE 0 +#define R_M32R_16 1 +#define R_M32R_32 2 +#define R_M32R_24 3 +#define R_M32R_10_PCREL 4 +#define R_M32R_18_PCREL 5 +#define R_M32R_26_PCREL 6 +#define R_M32R_HI16_ULO 7 +#define R_M32R_HI16_SLO 8 +#define R_M32R_LO16 9 +#define R_M32R_SDA16 10 +#define R_M32R_GNU_VTINHERIT 11 +#define R_M32R_GNU_VTENTRY 12 + +#define R_M32R_16_RELA 33 +#define R_M32R_32_RELA 34 +#define R_M32R_24_RELA 35 +#define R_M32R_10_PCREL_RELA 36 +#define R_M32R_18_PCREL_RELA 37 +#define R_M32R_26_PCREL_RELA 38 +#define R_M32R_HI16_ULO_RELA 39 +#define R_M32R_HI16_SLO_RELA 40 +#define R_M32R_LO16_RELA 41 +#define R_M32R_SDA16_RELA 42 +#define R_M32R_RELA_GNU_VTINHERIT 43 +#define R_M32R_RELA_GNU_VTENTRY 44 +#define R_M32R_REL32 45 + +#define R_M32R_GOT24 48 +#define R_M32R_26_PLTREL 49 +#define R_M32R_COPY 50 +#define R_M32R_GLOB_DAT 51 +#define R_M32R_JMP_SLOT 52 +#define R_M32R_RELATIVE 53 +#define R_M32R_GOTOFF 54 +#define R_M32R_GOTPC24 55 +#define R_M32R_GOT16_HI_ULO 56 + +#define R_M32R_GOT16_HI_SLO 57 + +#define R_M32R_GOT16_LO 58 +#define R_M32R_GOTPC_HI_ULO 59 + +#define R_M32R_GOTPC_HI_SLO 60 + +#define R_M32R_GOTPC_LO 61 + +#define R_M32R_GOTOFF_HI_ULO 62 + +#define R_M32R_GOTOFF_HI_SLO 63 + +#define R_M32R_GOTOFF_LO 64 +#define R_M32R_NUM 256 + +#define R_MICROBLAZE_NONE 0 +#define R_MICROBLAZE_32 1 +#define R_MICROBLAZE_32_PCREL 2 +#define R_MICROBLAZE_64_PCREL 3 +#define R_MICROBLAZE_32_PCREL_LO 4 +#define R_MICROBLAZE_64 5 +#define R_MICROBLAZE_32_LO 6 +#define R_MICROBLAZE_SRO32 7 +#define R_MICROBLAZE_SRW32 8 +#define R_MICROBLAZE_64_NONE 9 +#define R_MICROBLAZE_32_SYM_OP_SYM 10 +#define R_MICROBLAZE_GNU_VTINHERIT 11 +#define R_MICROBLAZE_GNU_VTENTRY 12 +#define R_MICROBLAZE_GOTPC_64 13 +#define R_MICROBLAZE_GOT_64 14 +#define R_MICROBLAZE_PLT_64 15 +#define R_MICROBLAZE_REL 16 +#define R_MICROBLAZE_JUMP_SLOT 17 +#define R_MICROBLAZE_GLOB_DAT 18 +#define R_MICROBLAZE_GOTOFF_64 19 +#define R_MICROBLAZE_GOTOFF_32 20 +#define R_MICROBLAZE_COPY 21 +#define R_MICROBLAZE_TLS 22 +#define R_MICROBLAZE_TLSGD 23 +#define R_MICROBLAZE_TLSLD 24 +#define R_MICROBLAZE_TLSDTPMOD32 25 +#define R_MICROBLAZE_TLSDTPREL32 26 +#define R_MICROBLAZE_TLSDTPREL64 27 +#define R_MICROBLAZE_TLSGOTTPREL32 28 +#define R_MICROBLAZE_TLSTPREL32 29 + +#define DT_NIOS2_GP 0x70000002 + +#define R_NIOS2_NONE 0 +#define R_NIOS2_S16 1 +#define R_NIOS2_U16 2 +#define R_NIOS2_PCREL16 3 +#define R_NIOS2_CALL26 4 +#define R_NIOS2_IMM5 5 +#define R_NIOS2_CACHE_OPX 6 +#define R_NIOS2_IMM6 7 +#define R_NIOS2_IMM8 8 +#define R_NIOS2_HI16 9 +#define R_NIOS2_LO16 10 +#define R_NIOS2_HIADJ16 11 +#define R_NIOS2_BFD_RELOC_32 12 +#define R_NIOS2_BFD_RELOC_16 13 +#define R_NIOS2_BFD_RELOC_8 14 +#define R_NIOS2_GPREL 15 +#define R_NIOS2_GNU_VTINHERIT 16 +#define R_NIOS2_GNU_VTENTRY 17 +#define R_NIOS2_UJMP 18 +#define R_NIOS2_CJMP 19 +#define R_NIOS2_CALLR 20 +#define R_NIOS2_ALIGN 21 +#define R_NIOS2_GOT16 22 +#define R_NIOS2_CALL16 23 +#define R_NIOS2_GOTOFF_LO 24 +#define R_NIOS2_GOTOFF_HA 25 +#define R_NIOS2_PCREL_LO 26 +#define R_NIOS2_PCREL_HA 27 +#define R_NIOS2_TLS_GD16 28 +#define R_NIOS2_TLS_LDM16 29 +#define R_NIOS2_TLS_LDO16 30 +#define R_NIOS2_TLS_IE16 31 +#define R_NIOS2_TLS_LE16 32 +#define R_NIOS2_TLS_DTPMOD 33 +#define R_NIOS2_TLS_DTPREL 34 +#define R_NIOS2_TLS_TPREL 35 +#define R_NIOS2_COPY 36 +#define R_NIOS2_GLOB_DAT 37 +#define R_NIOS2_JUMP_SLOT 38 +#define R_NIOS2_RELATIVE 39 +#define R_NIOS2_GOTOFF 40 +#define R_NIOS2_CALL26_NOAT 41 +#define R_NIOS2_GOT_LO 42 +#define R_NIOS2_GOT_HA 43 +#define R_NIOS2_CALL_LO 44 +#define R_NIOS2_CALL_HA 45 + +#define R_OR1K_NONE 0 +#define R_OR1K_32 1 +#define R_OR1K_16 2 +#define R_OR1K_8 3 +#define R_OR1K_LO_16_IN_INSN 4 +#define R_OR1K_HI_16_IN_INSN 5 +#define R_OR1K_INSN_REL_26 6 +#define R_OR1K_GNU_VTENTRY 7 +#define R_OR1K_GNU_VTINHERIT 8 +#define R_OR1K_32_PCREL 9 +#define R_OR1K_16_PCREL 10 +#define R_OR1K_8_PCREL 11 +#define R_OR1K_GOTPC_HI16 12 +#define R_OR1K_GOTPC_LO16 13 +#define R_OR1K_GOT16 14 +#define R_OR1K_PLT26 15 +#define R_OR1K_GOTOFF_HI16 16 +#define R_OR1K_GOTOFF_LO16 17 +#define R_OR1K_COPY 18 +#define R_OR1K_GLOB_DAT 19 +#define R_OR1K_JMP_SLOT 20 +#define R_OR1K_RELATIVE 21 +#define R_OR1K_TLS_GD_HI16 22 +#define R_OR1K_TLS_GD_LO16 23 +#define R_OR1K_TLS_LDM_HI16 24 +#define R_OR1K_TLS_LDM_LO16 25 +#define R_OR1K_TLS_LDO_HI16 26 +#define R_OR1K_TLS_LDO_LO16 27 +#define R_OR1K_TLS_IE_HI16 28 +#define R_OR1K_TLS_IE_LO16 29 +#define R_OR1K_TLS_LE_HI16 30 +#define R_OR1K_TLS_LE_LO16 31 +#define R_OR1K_TLS_TPOFF 32 +#define R_OR1K_TLS_DTPOFF 33 +#define R_OR1K_TLS_DTPMOD 34 + +#define R_BPF_NONE 0 +#define R_BPF_MAP_FD 1 + +#ifdef __cplusplus +} +#endif + + +#endif diff --git a/tools/patchelf/patchelf.c b/tools/patchelf/patchelf.c index 19363c55f..573b5808a 100644 --- a/tools/patchelf/patchelf.c +++ b/tools/patchelf/patchelf.c @@ -1,5 +1,5 @@ #include -#include +#include "elf.h" #include #include #include From 7e7384ee0225ccd470a3724186ad01f2e2437b8d Mon Sep 17 00:00:00 2001 From: CallmeEchoo Date: Sat, 6 May 2023 19:12:49 +0200 Subject: [PATCH 45/51] tiny test doc fix --- test/test_battle.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_battle.h b/test/test_battle.h index 432e33fa8..81cb7e594 100644 --- a/test/test_battle.h +++ b/test/test_battle.h @@ -369,7 +369,7 @@ * s16 damage; * HP_BAR(player, captureDamage: &damage); * If none of the above are used, causes the test to fail if the HP - * changes at all. + * does not change at all. * * MESSAGE(pattern) * Causes the test to fail if the message in pattern is not displayed. From e0bed6776b215e96f45799f685af1aaad9bc5408 Mon Sep 17 00:00:00 2001 From: Martin Griffin Date: Wed, 26 Apr 2023 11:12:41 +0100 Subject: [PATCH 46/51] INVALID if FINALLY without PARAMETRIZE --- test/ability_volt_absorb.c | 3 +-- test/item_effect_restore_hp.c | 2 +- test/move_effect_bide.c | 4 ++-- test/move_effect_triple_kick.c | 8 ++++---- test/move_flag_three_strikes.c | 4 ++-- test/terrain_electric.c | 2 +- test/terrain_grassy.c | 2 +- test/terrain_misty.c | 2 +- test/terrain_psychic.c | 2 +- test/test_battle.h | 4 +++- test/test_runner_battle.c | 9 ++++++++- 11 files changed, 25 insertions(+), 17 deletions(-) diff --git a/test/ability_volt_absorb.c b/test/ability_volt_absorb.c index 18902eaa2..8a3c21ef6 100644 --- a/test/ability_volt_absorb.c +++ b/test/ability_volt_absorb.c @@ -80,8 +80,7 @@ DOUBLE_BATTLE_TEST("Volt Absorb does not stop Electric Typed Explosion from dama MESSAGE("Jolteon restored HP using its Volt Absorb!"); HP_BAR(playerRight, captureDamage: &results->damage1); HP_BAR(opponentRight, captureDamage: &results->damage2); - } - FINALLY { + } THEN { EXPECT_NE(results[0].damage1, 0); EXPECT_NE(results[0].damage2, 0); } diff --git a/test/item_effect_restore_hp.c b/test/item_effect_restore_hp.c index 4662e9f25..6fd58fe82 100644 --- a/test/item_effect_restore_hp.c +++ b/test/item_effect_restore_hp.c @@ -183,4 +183,4 @@ SINGLE_BATTLE_TEST("Sitrus Berry restores a battler's HP by 25% of its max HP(30 } #undef TEST_HP -#undef MAX_HP \ No newline at end of file +#undef MAX_HP diff --git a/test/move_effect_bide.c b/test/move_effect_bide.c index 3a5c38735..0b0e18408 100644 --- a/test/move_effect_bide.c +++ b/test/move_effect_bide.c @@ -28,7 +28,7 @@ SINGLE_BATTLE_TEST("Bide deals twice the taken damage over two turns") MESSAGE("Wobbuffet unleashed energy!"); ANIMATION(ANIM_TYPE_MOVE, MOVE_BIDE, player); HP_BAR(opponent, captureDamage: &bideDamage); - } FINALLY { - EXPECT_EQ(bideDamage, damage1 + damage2); + } THEN { + EXPECT_EQ(bideDamage, 2 * (damage1 + damage2)); } } diff --git a/test/move_effect_triple_kick.c b/test/move_effect_triple_kick.c index d3187aefe..e0a91b011 100644 --- a/test/move_effect_triple_kick.c +++ b/test/move_effect_triple_kick.c @@ -6,7 +6,7 @@ ASSUMPTIONS ASSUME(gBattleMoves[MOVE_TRIPLE_KICK].effect & EFFECT_TRIPLE_KICK); } -SINGLE_BATTLE_TEST("Triple Kick damage is increaased by its base damage for each hit") +SINGLE_BATTLE_TEST("Triple Kick damage is increased by its base damage for each hit") { s16 firstHit; s16 secondHit; @@ -24,8 +24,8 @@ SINGLE_BATTLE_TEST("Triple Kick damage is increaased by its base damage for each HP_BAR(opponent, captureDamage: &secondHit); ANIMATION(ANIM_TYPE_MOVE, MOVE_TRIPLE_KICK, player); HP_BAR(opponent, captureDamage: &thirdHit); - } FINALLY { - EXPECT_EQ(secondHit, firstHit * 2); - EXPECT_EQ(thirdHit, firstHit * 3); + } THEN { + EXPECT_MUL_EQ(firstHit, Q_4_12(2.0), secondHit); + EXPECT_MUL_EQ(firstHit, Q_4_12(3.0), thirdHit); } } diff --git a/test/move_flag_three_strikes.c b/test/move_flag_three_strikes.c index 7ea7844c4..b597b4efe 100644 --- a/test/move_flag_three_strikes.c +++ b/test/move_flag_three_strikes.c @@ -20,7 +20,7 @@ SINGLE_BATTLE_TEST("Three-strike flag turns a move into a 3-hit move") HP_BAR(opponent, captureDamage: &secondHit); ANIMATION(ANIM_TYPE_MOVE, MOVE_TRIPLE_DIVE, player); HP_BAR(opponent, captureDamage: &thirdHit); - } FINALLY { + } THEN { EXPECT_EQ(firstHit, secondHit); EXPECT_EQ(secondHit, thirdHit); EXPECT_EQ(firstHit, thirdHit); @@ -49,7 +49,7 @@ SINGLE_BATTLE_TEST("Surging Strikes hits 3 times with each hit being a critical ANIMATION(ANIM_TYPE_MOVE, MOVE_SURGING_STRIKES, player); HP_BAR(opponent, captureDamage: &thirdHit); MESSAGE("A critical hit!"); - } FINALLY { + } THEN { EXPECT_EQ(firstHit, secondHit); EXPECT_EQ(secondHit, thirdHit); EXPECT_EQ(firstHit, thirdHit); diff --git a/test/terrain_electric.c b/test/terrain_electric.c index e9c34ef92..78f490c42 100644 --- a/test/terrain_electric.c +++ b/test/terrain_electric.c @@ -34,7 +34,7 @@ SINGLE_BATTLE_TEST("Electric Terrain activates Electric Seed and Mimicry") MESSAGE("Using Electric Seed, the Defense of Wobbuffet rose!"); ABILITY_POPUP(opponent); MESSAGE("Foe Stunfisk's type changed to Electr!"); - } FINALLY { + } THEN { EXPECT_EQ(gBattleMons[B_POSITION_OPPONENT_LEFT].type1, TYPE_ELECTRIC); } } diff --git a/test/terrain_grassy.c b/test/terrain_grassy.c index 7668c49bd..21d64f61e 100644 --- a/test/terrain_grassy.c +++ b/test/terrain_grassy.c @@ -30,7 +30,7 @@ SINGLE_BATTLE_TEST("Grassy Terrain activates Grassy Seed and Mimicry") MESSAGE("Using Grassy Seed, the Defense of Wobbuffet rose!"); ABILITY_POPUP(opponent); MESSAGE("Foe Stunfisk's type changed to Grass!"); - } FINALLY { + } THEN { EXPECT_EQ(gBattleMons[B_POSITION_OPPONENT_LEFT].type1, TYPE_GRASS); } } diff --git a/test/terrain_misty.c b/test/terrain_misty.c index 4f8793d9d..f60122075 100644 --- a/test/terrain_misty.c +++ b/test/terrain_misty.c @@ -34,7 +34,7 @@ SINGLE_BATTLE_TEST("Misty Terrain activates Misty Seed and Mimicry") MESSAGE("Using Misty Seed, the Sp. Def of Wobbuffet rose!"); ABILITY_POPUP(opponent); MESSAGE("Foe Stunfisk's type changed to Fairy!"); - } FINALLY { + } THEN { EXPECT_EQ(gBattleMons[B_POSITION_OPPONENT_LEFT].type1, TYPE_FAIRY); } } diff --git a/test/terrain_psychic.c b/test/terrain_psychic.c index 3ecfa99e0..f7e3a2af7 100644 --- a/test/terrain_psychic.c +++ b/test/terrain_psychic.c @@ -33,7 +33,7 @@ SINGLE_BATTLE_TEST("Psychic Terrain activates Psychic Seed and Mimicry") MESSAGE("Using Psychic Seed, the Sp. Def of Wobbuffet rose!"); ABILITY_POPUP(opponent); MESSAGE("Foe Stunfisk's type changed to Psychc!"); - } FINALLY { + } THEN { EXPECT_EQ(gBattleMons[B_POSITION_OPPONENT_LEFT].type1, TYPE_PSYCHIC); } } diff --git a/test/test_battle.h b/test/test_battle.h index 4c563c91d..205c69919 100644 --- a/test/test_battle.h +++ b/test/test_battle.h @@ -897,7 +897,9 @@ void QueueStatus(u32 sourceLine, struct BattlePokemon *battler, struct StatusEve /* Finally */ -#define FINALLY for (; gBattleTestRunnerState->runFinally; gBattleTestRunnerState->runFinally = FALSE) if ((gBattleTestRunnerState->runningFinally = TRUE)) +#define FINALLY for (ValidateFinally(__LINE__); gBattleTestRunnerState->runFinally; gBattleTestRunnerState->runFinally = FALSE) if ((gBattleTestRunnerState->runningFinally = TRUE)) + +void ValidateFinally(u32 sourceLine); /* Expect */ diff --git a/test/test_runner_battle.c b/test/test_runner_battle.c index 7740783b2..2c26e3918 100644 --- a/test/test_runner_battle.c +++ b/test/test_runner_battle.c @@ -1719,7 +1719,6 @@ void QueueMessage(u32 sourceLine, const u8 *pattern) }; } - void QueueStatus(u32 sourceLine, struct BattlePokemon *battler, struct StatusEventContext ctx) { s32 battlerId = battler - gBattleMons; @@ -1759,3 +1758,11 @@ void QueueStatus(u32 sourceLine, struct BattlePokemon *battler, struct StatusEve }}, }; } + +void ValidateFinally(u32 sourceLine) +{ + // Defer this error until after estimating the cost. + if (STATE->results == NULL) + return; + INVALID_IF(STATE->parametersCount == 0, "FINALLY without PARAMETRIZE"); +} From 9cd13cc52024fbdaca2e1515e47d354084371ae4 Mon Sep 17 00:00:00 2001 From: Martin Griffin Date: Thu, 20 Apr 2023 21:45:16 +0100 Subject: [PATCH 47/51] Fix USE_ITEM explicit targets --- include/battle.h | 1 + src/battle_controller_recorded_opponent.c | 2 +- src/battle_controller_recorded_player.c | 2 +- src/battle_script_commands.c | 6 +++--- src/party_menu.c | 2 +- test/test_runner_battle.c | 4 ++++ 6 files changed, 11 insertions(+), 6 deletions(-) diff --git a/include/battle.h b/include/battle.h index 466a9138d..00c7081fb 100644 --- a/include/battle.h +++ b/include/battle.h @@ -658,6 +658,7 @@ struct BattleStruct u8 storedLunarDance:4; // Each battler as a bit. u16 supremeOverlordModifier[MAX_BATTLERS_COUNT]; u8 itemPartyIndex[MAX_BATTLERS_COUNT]; + u8 itemMoveIndex[MAX_BATTLERS_COUNT]; bool8 trainerSlideHalfHpMsgDone; u8 trainerSlideFirstCriticalHitMsgState:2; u8 trainerSlideFirstSuperEffectiveHitMsgState:2; diff --git a/src/battle_controller_recorded_opponent.c b/src/battle_controller_recorded_opponent.c index 751584076..d1c60343a 100644 --- a/src/battle_controller_recorded_opponent.c +++ b/src/battle_controller_recorded_opponent.c @@ -1443,7 +1443,7 @@ static void RecordedOpponentHandleChooseItem(void) u8 byte2 = RecordedBattle_GetBattlerAction(RECORDED_ITEM_ID, gActiveBattler); gBattleStruct->chosenItem[gActiveBattler] = (byte1 << 8) | byte2; gBattleStruct->itemPartyIndex[gActiveBattler] = RecordedBattle_GetBattlerAction(RECORDED_ITEM_TARGET, gActiveBattler); - gChosenMovePos = RecordedBattle_GetBattlerAction(RECORDED_ITEM_MOVE, gActiveBattler); + gBattleStruct->itemMoveIndex[gActiveBattler] = RecordedBattle_GetBattlerAction(RECORDED_ITEM_MOVE, gActiveBattler); BtlController_EmitOneReturnValue(BUFFER_B, gBattleStruct->chosenItem[gActiveBattler]); RecordedOpponentBufferExecCompleted(); } diff --git a/src/battle_controller_recorded_player.c b/src/battle_controller_recorded_player.c index 1a56220d7..46f3de4f1 100644 --- a/src/battle_controller_recorded_player.c +++ b/src/battle_controller_recorded_player.c @@ -1467,7 +1467,7 @@ static void RecordedPlayerHandleChooseItem(void) u8 byte2 = RecordedBattle_GetBattlerAction(RECORDED_ITEM_ID, gActiveBattler); gBattleStruct->chosenItem[gActiveBattler] = (byte1 << 8) | byte2; gBattleStruct->itemPartyIndex[gActiveBattler] = RecordedBattle_GetBattlerAction(RECORDED_ITEM_TARGET, gActiveBattler); - gChosenMovePos = RecordedBattle_GetBattlerAction(RECORDED_ITEM_MOVE, gActiveBattler); + gBattleStruct->itemMoveIndex[gActiveBattler] = RecordedBattle_GetBattlerAction(RECORDED_ITEM_MOVE, gActiveBattler); BtlController_EmitOneReturnValue(BUFFER_B, gBattleStruct->chosenItem[gActiveBattler]); RecordedPlayerBufferExecCompleted(); } diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 1187267b2..084288431 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -16536,10 +16536,10 @@ void BS_ItemRestorePP(void) { // Check whether to apply to all moves. if (effect[4] & ITEM4_HEAL_PP_ONE) { - i = gChosenMovePos; - loopEnd = gChosenMovePos + 1; + i = gBattleStruct->itemMoveIndex[gBattlerAttacker]; + loopEnd = i + 1; } - else + else { i = 0; loopEnd = MAX_MON_MOVES; diff --git a/src/party_menu.c b/src/party_menu.c index 773495a4d..aa37b1c69 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -4944,7 +4944,7 @@ static void TryUseItemOnMove(u8 taskId) else { gBattleStruct->itemPartyIndex[gBattlerInMenuId] = GetPartyIdFromBattleSlot(gPartyMenu.slotId); - gChosenMovePos = ptr->data1; + gBattleStruct->itemMoveIndex[gBattlerInMenuId] = ptr->data1; gPartyMenuUseExitCallback = TRUE; RemoveBagItem(gSpecialVar_ItemId, 1); ScheduleBgCopyTilemapToVram(2); diff --git a/test/test_runner_battle.c b/test/test_runner_battle.c index 2c26e3918..b7360e19c 100644 --- a/test/test_runner_battle.c +++ b/test/test_runner_battle.c @@ -1564,6 +1564,10 @@ void UseItem(u32 sourceLine, struct BattlePokemon *battler, struct ItemContext c } INVALID_IF(i == MAX_MON_MOVES, "USE_ITEM on invalid move: %d", ctx.move); } + else + { + i = 0; + } PushBattlerAction(sourceLine, battlerId, RECORDED_ACTION_TYPE, B_ACTION_USE_ITEM); PushBattlerAction(sourceLine, battlerId, RECORDED_ITEM_ID, (ctx.itemId >> 8) & 0xFF); PushBattlerAction(sourceLine, battlerId, RECORDED_ITEM_ID, ctx.itemId & 0xFF); From 29fa6ba5743f2a1c636af0c7e3491f2f2e3bb81d Mon Sep 17 00:00:00 2001 From: Martin Griffin Date: Wed, 26 Apr 2023 11:31:19 +0100 Subject: [PATCH 48/51] INVALID if PASSES_RANDOMLY and results --- test/hold_effect_berserk_gene.c | 17 +++++------------ test/test_runner_battle.c | 2 ++ 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/test/hold_effect_berserk_gene.c b/test/hold_effect_berserk_gene.c index 361d14861..103a0a1a3 100644 --- a/test/hold_effect_berserk_gene.c +++ b/test/hold_effect_berserk_gene.c @@ -11,14 +11,11 @@ SINGLE_BATTLE_TEST("Berserk Gene sharply raises attack at the start of battle", u16 useItem; PARAMETRIZE { useItem = FALSE; } PARAMETRIZE { useItem = TRUE; } - if (useItem) PASSES_RANDOMLY(66, 100, RNG_CONFUSION); GIVEN { - PLAYER(SPECIES_WOBBUFFET) { if (useItem) Item(ITEM_BERSERK_GENE); }; + PLAYER(SPECIES_WOBBUFFET) { if (useItem) Item(ITEM_BERSERK_GENE); } OPPONENT(SPECIES_WOBBUFFET); } WHEN { - TURN { - MOVE(player, MOVE_TACKLE); - } + TURN { MOVE(player, MOVE_TACKLE, WITH_RNG(RNG_CONFUSION, FALSE)); } } SCENE { if (useItem) { @@ -38,17 +35,13 @@ SINGLE_BATTLE_TEST("Berserk Gene activates on switch in", s16 damage) u16 useItem; PARAMETRIZE { useItem = FALSE; } PARAMETRIZE { useItem = TRUE; } - if (useItem) PASSES_RANDOMLY(66, 100, RNG_CONFUSION); GIVEN { PLAYER(SPECIES_WYNAUT); - PLAYER(SPECIES_WOBBUFFET) { if (useItem) Item(ITEM_BERSERK_GENE); }; + PLAYER(SPECIES_WOBBUFFET) { if (useItem) Item(ITEM_BERSERK_GENE); } OPPONENT(SPECIES_WOBBUFFET); } WHEN { - TURN { - SWITCH(player, 1); - } TURN { - MOVE(player, MOVE_TACKLE); - } + TURN { SWITCH(player, 1); } + TURN { MOVE(player, MOVE_TACKLE, WITH_RNG(RNG_CONFUSION, FALSE)); } } SCENE { if (useItem) { diff --git a/test/test_runner_battle.c b/test/test_runner_battle.c index b7360e19c..c1ea34e8c 100644 --- a/test/test_runner_battle.c +++ b/test/test_runner_battle.c @@ -939,6 +939,8 @@ static bool32 BattleTest_HandleExitWithResult(void *data, enum TestResult result void Randomly(u32 sourceLine, u32 passes, u32 trials, struct RandomlyContext ctx) { + const struct BattleTest *test = gTestRunnerState.test->data; + INVALID_IF(test->resultsSize > 0, "PASSES_RANDOMLY is incompatible with results"); INVALID_IF(passes > trials, "%d passes specified, but only %d trials", passes, trials); STATE->rngTag = ctx.tag; STATE->runTrial = 0; From efab893c470eed58e41727852440f58c528b60bc Mon Sep 17 00:00:00 2001 From: Martin Griffin Date: Wed, 26 Apr 2023 11:38:52 +0100 Subject: [PATCH 49/51] INVALID if results without PARAMETRIZE --- test/ability_dry_skin.c | 5 ++++- test/ability_volt_absorb.c | 11 ++++++----- test/hold_effect_mirror_herb.c | 6 +++--- test/item_effect_increase_stat.c | 2 +- test/terrain_psychic.c | 10 +++++----- test/test_runner_battle.c | 2 ++ 6 files changed, 21 insertions(+), 15 deletions(-) diff --git a/test/ability_dry_skin.c b/test/ability_dry_skin.c index 6c28d0c42..855872d76 100644 --- a/test/ability_dry_skin.c +++ b/test/ability_dry_skin.c @@ -33,10 +33,13 @@ SINGLE_BATTLE_TEST("Dry Skin heals 1/8th Max HP in Rain") SINGLE_BATTLE_TEST("Dry Skin increases damage taken from Fire-type moves by 25%", s16 damage) { + u32 ability; + PARAMETRIZE { ability = ABILITY_EFFECT_SPORE; } + PARAMETRIZE { ability = ABILITY_DRY_SKIN; } GIVEN { ASSUME(gBattleMoves[MOVE_EMBER].type == TYPE_FIRE); PLAYER(SPECIES_WOBBUFFET); - OPPONENT(SPECIES_PARASECT) { Ability(ABILITY_DRY_SKIN); }; + OPPONENT(SPECIES_PARASECT) { Ability(ability); }; } WHEN { TURN {MOVE(player, MOVE_EMBER); } } SCENE { diff --git a/test/ability_volt_absorb.c b/test/ability_volt_absorb.c index 8a3c21ef6..6b9296268 100644 --- a/test/ability_volt_absorb.c +++ b/test/ability_volt_absorb.c @@ -63,8 +63,9 @@ SINGLE_BATTLE_TEST("Volt Absorb is only triggered once on multi strike moves") } } -DOUBLE_BATTLE_TEST("Volt Absorb does not stop Electric Typed Explosion from damaging other pokemon", s16 damage1, s16 damage2) // Fixed issue #1961 +DOUBLE_BATTLE_TEST("Volt Absorb does not stop Electric Typed Explosion from damaging other pokemon") // Fixed issue #1961 { + s16 damage1, damage2; GIVEN { ASSUME(gBattleMoves[MOVE_EXPLOSION].effect == EFFECT_EXPLOSION); ASSUME(gBattleMoves[MOVE_EXPLOSION].type == TYPE_NORMAL); @@ -78,11 +79,11 @@ DOUBLE_BATTLE_TEST("Volt Absorb does not stop Electric Typed Explosion from dama ABILITY_POPUP(playerLeft, ABILITY_VOLT_ABSORB); HP_BAR(playerLeft, hp: TEST_MAX_HP / 4 + 1); MESSAGE("Jolteon restored HP using its Volt Absorb!"); - HP_BAR(playerRight, captureDamage: &results->damage1); - HP_BAR(opponentRight, captureDamage: &results->damage2); + HP_BAR(playerRight, captureDamage: &damage1); + HP_BAR(opponentRight, captureDamage: &damage2); } THEN { - EXPECT_NE(results[0].damage1, 0); - EXPECT_NE(results[0].damage2, 0); + EXPECT_NE(damage1, 0); + EXPECT_NE(damage2, 0); } } diff --git a/test/hold_effect_mirror_herb.c b/test/hold_effect_mirror_herb.c index fc0a6de95..22f564b85 100644 --- a/test/hold_effect_mirror_herb.c +++ b/test/hold_effect_mirror_herb.c @@ -9,8 +9,8 @@ ASSUMPTIONS SINGLE_BATTLE_TEST("Mirror Herb copies all of foe's stat changes in a turn", s16 damage) { u32 item; - PARAMETRIZE{ item = ITEM_NONE; } - PARAMETRIZE{ item = ITEM_MIRROR_HERB; } + PARAMETRIZE { item = ITEM_NONE; } + PARAMETRIZE { item = ITEM_MIRROR_HERB; } GIVEN { PLAYER(SPECIES_WOBBUFFET) { Speed(4); } OPPONENT(SPECIES_WOBBUFFET) { Speed(5); Item(item); } @@ -34,7 +34,7 @@ SINGLE_BATTLE_TEST("Mirror Herb copies all of foe's stat changes in a turn", s16 } } -SINGLE_BATTLE_TEST("Mirror Herb copies all of of Stuff Cheeks", s16 damage) +SINGLE_BATTLE_TEST("Mirror Herb copies all of of Stuff Cheeks") { GIVEN { ASSUME(gItems[ITEM_LIECHI_BERRY].holdEffect == HOLD_EFFECT_ATTACK_UP); diff --git a/test/item_effect_increase_stat.c b/test/item_effect_increase_stat.c index bbaf20e2f..310932040 100644 --- a/test/item_effect_increase_stat.c +++ b/test/item_effect_increase_stat.c @@ -126,7 +126,7 @@ SINGLE_BATTLE_TEST("X Speed sharply raises battler's Speed stat", s16 damage) } } -SINGLE_BATTLE_TEST("X Accuracy sharply raises battler's Accuracy stat", s16 damage) +SINGLE_BATTLE_TEST("X Accuracy sharply raises battler's Accuracy stat") { ASSUME(gBattleMoves[MOVE_SING].accuracy == 55); diff --git a/test/terrain_psychic.c b/test/terrain_psychic.c index f7e3a2af7..f9f95a47d 100644 --- a/test/terrain_psychic.c +++ b/test/terrain_psychic.c @@ -61,7 +61,7 @@ SINGLE_BATTLE_TEST("Psychic Terrain increases power of Psychic-type moves by 30/ } } -SINGLE_BATTLE_TEST("Psychic Terrain doesn't block priority moves that target the user", s16 damage) +SINGLE_BATTLE_TEST("Psychic Terrain doesn't block priority moves that target the user") { GIVEN { PLAYER(SPECIES_SABLEYE) { Ability(ABILITY_PRANKSTER); HP(1); } @@ -76,7 +76,7 @@ SINGLE_BATTLE_TEST("Psychic Terrain doesn't block priority moves that target the } } -SINGLE_BATTLE_TEST("Psychic Terrain doesn't block priority moves that target all battlers", s16 damage) +SINGLE_BATTLE_TEST("Psychic Terrain doesn't block priority moves that target all battlers") { KNOWN_FAILING; GIVEN { @@ -91,7 +91,7 @@ SINGLE_BATTLE_TEST("Psychic Terrain doesn't block priority moves that target all } } -SINGLE_BATTLE_TEST("Psychic Terrain doesn't block priority moves that target all opponents", s16 damage) +SINGLE_BATTLE_TEST("Psychic Terrain doesn't block priority moves that target all opponents") { KNOWN_FAILING; GIVEN { @@ -106,7 +106,7 @@ SINGLE_BATTLE_TEST("Psychic Terrain doesn't block priority moves that target all } } -DOUBLE_BATTLE_TEST("Psychic Terrain doesn't block priority moves that target allies", s16 damage) +DOUBLE_BATTLE_TEST("Psychic Terrain doesn't block priority moves that target allies") { GIVEN { PLAYER(SPECIES_SABLEYE) { Ability(ABILITY_PRANKSTER); } @@ -122,7 +122,7 @@ DOUBLE_BATTLE_TEST("Psychic Terrain doesn't block priority moves that target all } } -SINGLE_BATTLE_TEST("Psychic Terrain doesn't block priority field moves", s16 damage) +SINGLE_BATTLE_TEST("Psychic Terrain doesn't block priority field moves") { KNOWN_FAILING; GIVEN { diff --git a/test/test_runner_battle.c b/test/test_runner_battle.c index c1ea34e8c..cfe5db9d6 100644 --- a/test/test_runner_battle.c +++ b/test/test_runner_battle.c @@ -134,6 +134,8 @@ static void BattleTest_SetUp(void *data) Test_ExitWithResult(TEST_RESULT_ERROR, "OOM: STATE = AllocZerod(%d)", sizeof(*STATE)); InvokeTestFunction(test); STATE->parameters = STATE->parametersCount; + if (STATE->parametersCount == 0 && test->resultsSize > 0) + Test_ExitWithResult(TEST_RESULT_INVALID, "results without PARAMETRIZE"); STATE->results = AllocZeroed(test->resultsSize * STATE->parameters); if (!STATE->results) Test_ExitWithResult(TEST_RESULT_ERROR, "OOM: STATE->results = AllocZerod(%d)", sizeof(test->resultsSize * STATE->parameters)); From a2ca2aa7d90c091aea4d72df81237fa75843e212 Mon Sep 17 00:00:00 2001 From: Martin Griffin Date: Thu, 27 Apr 2023 09:25:04 +0100 Subject: [PATCH 50/51] Report errors in estimateCost --- test/test_runner.c | 88 ++++++++++++++++++++++++++++------------------ 1 file changed, 53 insertions(+), 35 deletions(-) diff --git a/test/test_runner.c b/test/test_runner.c index 64cb20e26..bfd7b47a5 100644 --- a/test/test_runner.c +++ b/test/test_runner.c @@ -42,7 +42,14 @@ static bool32 PrefixMatch(const char *pattern, const char *string) } } -enum { STATE_INIT, STATE_NEXT_TEST, STATE_REPORT_RESULT, STATE_EXIT }; +enum +{ + STATE_INIT, + STATE_NEXT_TEST, + STATE_RUN_TEST, + STATE_REPORT_RESULT, + STATE_EXIT, +}; void CB2_TestRunner(void) { @@ -81,6 +88,26 @@ void CB2_TestRunner(void) return; } + MgbaPrintf_(":N%s", gTestRunnerState.test->name); + gTestRunnerState.result = TEST_RESULT_PASS; + gTestRunnerState.expectedResult = TEST_RESULT_PASS; + gTestRunnerState.expectLeaks = FALSE; + if (gTestRunnerHeadless) + gTestRunnerState.timeoutSeconds = TIMEOUT_SECONDS; + else + gTestRunnerState.timeoutSeconds = UINT_MAX; + InitHeap(gHeap, HEAP_SIZE); + EnableInterrupts(INTR_FLAG_TIMER2); + REG_TM2CNT_L = UINT16_MAX - (274 * 60); // Approx. 1 second. + REG_TM2CNT_H = TIMER_ENABLE | TIMER_INTR_ENABLE | TIMER_1024CLK; + + // NOTE: Assumes that the compiler interns __FILE__. + if (gTestRunnerState.skipFilename == gTestRunnerState.test->filename) + { + gTestRunnerState.result = TEST_RESULT_ASSUMPTION_FAIL; + return; + } + // Greedily assign tests to processes based on estimated cost. // TODO: Make processCosts a min heap. if (gTestRunnerState.test->runner != &gAssumptionsRunner) @@ -98,40 +125,26 @@ void CB2_TestRunner(void) } } + if (minCostProcess == gTestRunnerI) + gTestRunnerState.state = STATE_RUN_TEST; + else + gTestRunnerState.state = STATE_NEXT_TEST; + + // XXX: If estimateCost exits only on some processes then + // processCosts will be inconsistent. if (gTestRunnerState.test->runner->estimateCost) gTestRunnerState.processCosts[minCostProcess] += gTestRunnerState.test->runner->estimateCost(gTestRunnerState.test->data); else gTestRunnerState.processCosts[minCostProcess] += 1; - - if (minCostProcess != gTestRunnerI) - return; } - MgbaPrintf_(":N%s", gTestRunnerState.test->name); + break; + + case STATE_RUN_TEST: gTestRunnerState.state = STATE_REPORT_RESULT; - gTestRunnerState.result = TEST_RESULT_PASS; - gTestRunnerState.expectedResult = TEST_RESULT_PASS; - gTestRunnerState.expectLeaks = FALSE; - if (gTestRunnerHeadless) - gTestRunnerState.timeoutSeconds = TIMEOUT_SECONDS; - else - gTestRunnerState.timeoutSeconds = UINT_MAX; - InitHeap(gHeap, HEAP_SIZE); - EnableInterrupts(INTR_FLAG_TIMER2); - REG_TM2CNT_L = UINT16_MAX - (274 * 60); // Approx. 1 second. - REG_TM2CNT_H = TIMER_ENABLE | TIMER_INTR_ENABLE | TIMER_1024CLK; - - // NOTE: Assumes that the compiler interns __FILE__. - if (gTestRunnerState.skipFilename == gTestRunnerState.test->filename) - { - gTestRunnerState.result = TEST_RESULT_ASSUMPTION_FAIL; - } - else - { - if (gTestRunnerState.test->runner->setUp) - gTestRunnerState.test->runner->setUp(gTestRunnerState.test->data); - gTestRunnerState.test->runner->run(gTestRunnerState.test->data); - } + if (gTestRunnerState.test->runner->setUp) + gTestRunnerState.test->runner->setUp(gTestRunnerState.test->data); + gTestRunnerState.test->runner->run(gTestRunnerState.test->data); break; case STATE_REPORT_RESULT: @@ -345,6 +358,8 @@ static void Intr_Timer2(void) } else { + if (gTestRunnerState.state == STATE_RUN_TEST) + gTestRunnerState.state = STATE_REPORT_RESULT; gTestRunnerState.result = TEST_RESULT_TIMEOUT; ReinitCallbacks(); IRQ_LR = ((uintptr_t)JumpToAgbMainLoop & ~1) + 4; @@ -354,16 +369,19 @@ static void Intr_Timer2(void) void Test_ExitWithResult(enum TestResult result, const char *fmt, ...) { - bool32 handled = FALSE; gTestRunnerState.result = result; ReinitCallbacks(); - if (gTestRunnerState.test->runner->handleExitWithResult) - handled = gTestRunnerState.test->runner->handleExitWithResult(gTestRunnerState.test->data, result); - if (!handled && gTestRunnerState.result != gTestRunnerState.expectedResult) + if (gTestRunnerState.state == STATE_REPORT_RESULT + && gTestRunnerState.test->runner->handleExitWithResult) { - va_list va; - va_start(va, fmt); - MgbaVPrintf_(fmt, va); + if (!gTestRunnerState.test->runner->handleExitWithResult(gTestRunnerState.test->data, result) + && gTestRunnerState.result != gTestRunnerState.expectedResult) + { + va_list va; + va_start(va, fmt); + MgbaVPrintf_(fmt, va); + va_end(va); + } } JumpToAgbMainLoop(); } From e52e8ce7e15f96f753f37af1f44e62ac1c90c52a Mon Sep 17 00:00:00 2001 From: Martin Griffin Date: Sun, 7 May 2023 07:50:29 +0100 Subject: [PATCH 51/51] Cleanup Compound Eyes tests --- test/ability_compound_eyes.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/test/ability_compound_eyes.c b/test/ability_compound_eyes.c index d90604d5c..6bdb15fa7 100644 --- a/test/ability_compound_eyes.c +++ b/test/ability_compound_eyes.c @@ -6,7 +6,7 @@ SINGLE_BATTLE_TEST("Compound Eyes raises accuracy") PASSES_RANDOMLY(91, 100, RNG_ACCURACY); GIVEN { ASSUME(gBattleMoves[MOVE_THUNDER].accuracy == 70); - PLAYER(SPECIES_BUTTERFREE) { Ability(ABILITY_COMPOUND_EYES); }; + PLAYER(SPECIES_BUTTERFREE) { Ability(ABILITY_COMPOUND_EYES); } OPPONENT(SPECIES_WOBBUFFET); } WHEN { TURN { MOVE(player, MOVE_THUNDER); } @@ -16,16 +16,13 @@ SINGLE_BATTLE_TEST("Compound Eyes raises accuracy") } } -// This fails even though the ability works correctly. The failure is due to -// a statistical anomaly in the test system where FISSURE hits 3 times more often -// than we expect. SINGLE_BATTLE_TEST("Compound Eyes does not affect OHKO moves") { PASSES_RANDOMLY(30, 100, RNG_ACCURACY); GIVEN { ASSUME(gBattleMoves[MOVE_FISSURE].accuracy == 30); ASSUME(gBattleMoves[MOVE_FISSURE].effect == EFFECT_OHKO); - PLAYER(SPECIES_BUTTERFREE) { Ability(ABILITY_COMPOUND_EYES); }; + PLAYER(SPECIES_BUTTERFREE) { Ability(ABILITY_COMPOUND_EYES); } OPPONENT(SPECIES_WOBBUFFET); } WHEN { TURN { MOVE(player, MOVE_FISSURE); }