Merge pull request #364 from Diegoisawesome/master

Port/decompile field_control_avatar
This commit is contained in:
Diegoisawesome
2018-10-16 21:54:14 -05:00
committed by GitHub
56 changed files with 1277 additions and 2676 deletions

View File

@@ -2710,7 +2710,7 @@ static void PlayerHandleExpUpdate(void)
{
u8 monId = gBattleBufferA[gActiveBattler][1];
if (GetMonData(&gPlayerParty[monId], MON_DATA_LEVEL) >= MAX_MON_LEVEL)
if (GetMonData(&gPlayerParty[monId], MON_DATA_LEVEL) >= MAX_LEVEL)
{
PlayerBufferExecCompleted();
}

View File

@@ -1597,7 +1597,7 @@ static void PlayerPartnerHandleExpUpdate(void)
{
u8 monId = gBattleBufferA[gActiveBattler][1];
if (GetMonData(&gPlayerParty[monId], MON_DATA_LEVEL) >= MAX_MON_LEVEL)
if (GetMonData(&gPlayerParty[monId], MON_DATA_LEVEL) >= MAX_LEVEL)
{
PlayerPartnerBufferExecCompleted();
}

View File

@@ -2341,7 +2341,7 @@ static void MoveBattleBarGraphically(u8 battlerId, u8 whichBar)
&gBattleSpritesDataPtr->battleBars[battlerId].currValue,
array, B_EXPBAR_PIXELS / 8);
level = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_LEVEL);
if (level == MAX_MON_LEVEL)
if (level == MAX_LEVEL)
{
for (i = 0; i < 8; i++)
array[i] = 0;

View File

@@ -3347,7 +3347,7 @@ static void atk23_getexp(void)
gBattleScripting.atk23_state = 5;
gBattleMoveDamage = 0; // used for exp
}
else if (GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_LEVEL) == MAX_MON_LEVEL)
else if (GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_LEVEL) == MAX_LEVEL)
{
*(&gBattleStruct->sentInPokes) >>= 1;
gBattleScripting.atk23_state = 5;
@@ -3430,7 +3430,7 @@ static void atk23_getexp(void)
if (gBattleControllerExecFlags == 0)
{
gBattleBufferB[gBattleStruct->expGetterBattlerId][0] = 0;
if (GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_HP) && GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_LEVEL) != MAX_MON_LEVEL)
if (GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_HP) && GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_LEVEL) != MAX_LEVEL)
{
gBattleResources->statsBeforeLvlUp->hp = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_MAX_HP);
gBattleResources->statsBeforeLvlUp->atk = GetMonData(&gPlayerParty[gBattleStruct->expGetterMonId], MON_DATA_ATK);

View File

@@ -56,8 +56,8 @@ extern bool8 InBattlePyramid(void);
extern bool8 InBattlePike(void);
extern bool32 InTrainerHill(void);
extern bool32 FieldPoisonEffectIsRunning(void);
extern void prev_quest_postbuffer_cursor_backup_reset(void);
extern void ResetPoisonStepCounter(void);
extern void RestartWildEncounterImmunitySteps(void);
extern void ClearPoisonStepCounter(void);
extern void sub_81BE72C(void);
extern void sub_808BCF4(void);
extern void sub_80EECC8(void);
@@ -354,8 +354,8 @@ static void Task_BattleStart(u8 taskId)
{
overworld_free_bg_tilemaps();
SetMainCallback2(CB2_InitBattle);
prev_quest_postbuffer_cursor_backup_reset();
ResetPoisonStepCounter();
RestartWildEncounterImmunitySteps();
ClearPoisonStepCounter();
DestroyTask(taskId);
}
break;
@@ -921,8 +921,8 @@ static void CB2_StartFirstBattle(void)
gMain.savedCallback = CB2_EndFirstBattle;
FreeAllWindowBuffers();
SetMainCallback2(CB2_InitBattle);
prev_quest_postbuffer_cursor_backup_reset();
ResetPoisonStepCounter();
RestartWildEncounterImmunitySteps();
ClearPoisonStepCounter();
IncrementGameStat(GAME_STAT_TOTAL_BATTLES);
IncrementGameStat(GAME_STAT_WILD_BATTLES);
sub_80EECC8();

View File

@@ -11,7 +11,7 @@
extern u8 EventObjectGetBerryTreeId(u8 eventObjectId);
extern void sub_8092EF0(u8 mapId, u8 mapNumber, u8 mapGroup);
extern void CB2_ChooseBerry(void);
extern const u8* GetEventObjectScriptPointerForComparison(void);
extern const u8* GetEventObjectScriptPointerPlayerFacing(void);
extern bool8 IsBerryTreeSparkling(u8, u8, u8);
extern u16 gSpecialVar_ItemId;
@@ -930,7 +930,7 @@ bool32 EventObjectInteractionWaterBerryTree(void)
bool8 IsPlayerFacingPlantedBerryTree(void)
{
if (GetEventObjectScriptPointerForComparison() == BerryTreeScript
if (GetEventObjectScriptPointerPlayerFacing() == BerryTreeScript
&& GetStageByBerryTreeId(EventObjectGetBerryTreeId(gSelectedEventObject)) == 0)
return TRUE;
else
@@ -939,7 +939,7 @@ bool8 IsPlayerFacingPlantedBerryTree(void)
bool8 TryToWaterBerryTree(void)
{
if (GetEventObjectScriptPointerForComparison() != BerryTreeScript)
if (GetEventObjectScriptPointerPlayerFacing() != BerryTreeScript)
return FALSE;
else
return EventObjectInteractionWaterBerryTree();

View File

@@ -18,7 +18,7 @@
:(n <= 36) ? ((n + 14) * CUBE(n) / 50) \
: (((n / 2) + 32) * CUBE(n) / 50)
const u32 gExperienceTables[][MAX_MON_LEVEL + 1] =
const u32 gExperienceTables[][MAX_LEVEL + 1] =
{
{ // Medium Fast
0, // 0

View File

@@ -241,7 +241,7 @@ static void ApplyDaycareExperience(struct Pokemon *mon)
bool8 firstMove;
u16 learnedMove;
for (i = 0; i < MAX_MON_LEVEL; i++)
for (i = 0; i < MAX_LEVEL; i++)
{
// Add the mon's gained daycare experience level by level until it can't level up anymore.
if (TryIncrementMonLevel(mon))
@@ -278,7 +278,7 @@ static u16 TakeSelectedPokemonFromDaycare(struct DaycareMon *daycareMon)
species = GetBoxMonData(&daycareMon->mon, MON_DATA_SPECIES);
BoxMonToMon(&daycareMon->mon, &pokemon);
if (GetMonData(&pokemon, MON_DATA_LEVEL) != MAX_MON_LEVEL)
if (GetMonData(&pokemon, MON_DATA_LEVEL) != MAX_LEVEL)
{
experience = GetMonData(&pokemon, MON_DATA_EXP) + daycareMon->steps;
SetMonData(&pokemon, MON_DATA_EXP, &experience);
@@ -949,7 +949,7 @@ static bool8 _DoEggActions_CheckHatch(struct DayCare *daycare)
return FALSE; // no hatching
}
bool8 DoEggActions_CheckHatch(void)
bool8 ShouldEggHatch(void)
{
return _DoEggActions_CheckHatch(&gSaveBlock1Ptr->daycare);
}

View File

@@ -17,7 +17,6 @@
#include "pokenav.h"
#include "random.h"
#include "rom_818CFC8.h"
#include "rom_81BE66C.h"
#include "sprite.h"
#include "trainer_see.h"
#include "util.h"
@@ -2638,10 +2637,10 @@ void sub_808F28C(u8 localId, u8 mapNum, u8 mapGroup, u8 decorCat)
switch (decorCat)
{
case DECORCAT_DOLL:
OverrideMovementTypeForEventObject(&gEventObjects[eventObjectId], EventScript_2766A2);
OverrideMovementTypeForEventObject(&gEventObjects[eventObjectId], EventScript_SecretPower1);
break;
case DECORCAT_CUSHION:
OverrideMovementTypeForEventObject(&gEventObjects[eventObjectId], EventScript_2766A6);
OverrideMovementTypeForEventObject(&gEventObjects[eventObjectId], EventScript_SecretPower2);
break;
}
}

1058
src/field_control_avatar.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -111,7 +111,7 @@ void sub_80F972C(void)
ScriptContext1_Stop();
}
unsigned int overworld_poison(void)
int DoPoisonFieldEffect(void)
{
int i;
unsigned int hp;

View File

@@ -3668,7 +3668,7 @@ bool32 sub_813B374(void)
}
}
bool32 sub_813B3B0(void)
bool8 sub_813B3B0(void)
{
static const u8 gUnknown_085B3410[] = { 0x1d, 0x1d, 0x1e, 0x1e, 0x1f, 0x1f, 0x21, 0x21, 0x14, 0x14, 0x28, 0x28, 0x2a, 0x2a, 0x2c, 0x2c };

View File

@@ -679,7 +679,7 @@ bool8 MetatileBehavior_IsSecretBasePC(u8 metatileBehavior)
return FALSE;
}
bool8 MetatileBehavior_IsSecretBaseRegisterPC(u8 metatileBehavior)
bool8 MetatileBehavior_IsRecordMixingSecretBasePC(u8 metatileBehavior)
{
if (metatileBehavior == MB_SECRET_BASE_REGISTER_PC)
return TRUE;
@@ -815,7 +815,7 @@ bool8 MetatileBehavior_IsSecretBaseSandOrnament(u8 metatileBehavior)
return FALSE;
}
bool8 MetatileBehavior_IsSecretBaseTvOrShield(u8 metatileBehavior)
bool8 MetatileBehavior_IsSecretBaseShieldOrToyTV(u8 metatileBehavior)
{
if (metatileBehavior == MB_SECRET_BASE_TV_SHIELD)
return TRUE;
@@ -1164,7 +1164,7 @@ bool8 MetatileBehavior_IsRegionMap(u8 metatileBehavior)
return FALSE;
}
bool8 MetatileBehavior_IsClosedSootopolisGymDoor(u8 metatileBehavior)
bool8 MetatileBehavior_IsClosedSootopolisDoor(u8 metatileBehavior)
{
if (metatileBehavior == MB_CLOSED_SOOTOPOLIS_DOOR)
return TRUE;
@@ -1365,7 +1365,7 @@ bool8 MetatileBehavior_IsCuttableGrass(u8 metatileBehavior)
return FALSE;
}
bool8 MetatileBehavior_IsRunningShoesInstruction(u8 metatileBehavior)
bool8 MetatileBehavior_IsRunningShoesManual(u8 metatileBehavior)
{
if (metatileBehavior == MB_RUNNING_SHOES_INSTRUCTION)
return TRUE;

View File

@@ -107,7 +107,7 @@ extern void sub_80A0A2C(void);
extern void not_trainer_hill_battle_pyramid(void);
extern void apply_map_tileset2_palette(const struct MapLayout *);
extern void copy_map_tileset2_to_vram_2(const struct MapLayout *);
extern void prev_quest_postbuffer_cursor_backup_reset(void);
extern void RestartWildEncounterImmunitySteps(void);
extern void ShowMapNamePopup(void);
extern bool32 InTrainerHill(void);
extern bool32 sub_808651C(void);
@@ -164,8 +164,8 @@ extern bool32 sub_8009F3C(void);
extern void sub_8010198(void);
extern u32 sub_800B4DC(void);
extern bool32 sub_80B39D4(u8);
extern const u8* sub_809C2C8(struct MapPosition *a1, u8, u8);
extern u8 *sub_809D0F4(void*);
extern const u8* GetInteractedLinkPlayerScript(struct MapPosition *a1, u8, u8);
extern u8 *GetCoordEventScriptAtMapPosition(void*);
extern u8 sub_808BD6C(u8);
extern u8 sub_808BD7C(u8);
extern void UpdateEventObjectSpriteVisibility(struct Sprite*, u8);
@@ -827,7 +827,7 @@ void mliX_load_map(u8 mapGroup, u8 mapNum)
TrySetMapSaveWarpStatus();
ClearTempFieldEventData();
ResetCyclingRoadChallengeData();
prev_quest_postbuffer_cursor_backup_reset();
RestartWildEncounterImmunitySteps();
TryUpdateRandomTrainerRematches(mapGroup, mapNum);
DoTimeBasedEvents();
SetSav1WeatherFromCurrMapHeader();
@@ -876,7 +876,7 @@ static void mli0_load_map(u32 a1)
TrySetMapSaveWarpStatus();
ClearTempFieldEventData();
ResetCyclingRoadChallengeData();
prev_quest_postbuffer_cursor_backup_reset();
RestartWildEncounterImmunitySteps();
TryUpdateRandomTrainerRematches(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum);
if (a1 != 1)
DoTimeBasedEvents();
@@ -2706,7 +2706,7 @@ static u8 *sub_8087370(struct UnkStruct_8054FF8 *a1)
{
if (a1->c != 2)
return 0;
return sub_809D0F4(&a1->sub);
return GetCoordEventScriptAtMapPosition(&a1->sub);
}
static bool32 sub_8087388(struct UnkStruct_8054FF8 *a1)
@@ -2747,7 +2747,7 @@ static const u8 *sub_80873B4(struct UnkStruct_8054FF8 *a1)
return EventScript_TradeRoom_ReadTrainerCard2;
}
return sub_809C2C8(&unkStruct, a1->field_C, a1->d);
return GetInteractedLinkPlayerScript(&unkStruct, a1->field_C, a1->d);
}
static u16 sub_8087480(const u8 *script)

View File

@@ -3251,7 +3251,7 @@ u8 GetLevelFromMonExp(struct Pokemon *mon)
u32 exp = GetMonData(mon, MON_DATA_EXP, NULL);
s32 level = 1;
while (level <= MAX_MON_LEVEL && gExperienceTables[gBaseStats[species].growthRate][level] <= exp)
while (level <= MAX_LEVEL && gExperienceTables[gBaseStats[species].growthRate][level] <= exp)
level++;
return level - 1;
@@ -3263,7 +3263,7 @@ u8 GetLevelFromBoxMonExp(struct BoxPokemon *boxMon)
u32 exp = GetBoxMonData(boxMon, MON_DATA_EXP, NULL);
s32 level = 1;
while (level <= MAX_MON_LEVEL && gExperienceTables[gBaseStats[species].growthRate][level] <= exp)
while (level <= MAX_LEVEL && gExperienceTables[gBaseStats[species].growthRate][level] <= exp)
level++;
return level - 1;
@@ -5145,7 +5145,7 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov
retVal = FALSE;
}
if ((itemEffect[cmdIndex] & 0x40) // raise level
&& GetMonData(mon, MON_DATA_LEVEL, NULL) != MAX_MON_LEVEL)
&& GetMonData(mon, MON_DATA_LEVEL, NULL) != MAX_LEVEL)
{
dataUnsigned = gExperienceTables[gBaseStats[GetMonData(mon, MON_DATA_SPECIES, NULL)].growthRate][GetMonData(mon, MON_DATA_LEVEL, NULL) + 1];
SetMonData(mon, MON_DATA_EXP, &dataUnsigned);
@@ -6430,12 +6430,12 @@ bool8 TryIncrementMonLevel(struct Pokemon *mon)
u16 species = GetMonData(mon, MON_DATA_SPECIES, 0);
u8 nextLevel = GetMonData(mon, MON_DATA_LEVEL, 0) + 1;
u32 expPoints = GetMonData(mon, MON_DATA_EXP, 0);
if (expPoints > gExperienceTables[gBaseStats[species].growthRate][MAX_MON_LEVEL])
if (expPoints > gExperienceTables[gBaseStats[species].growthRate][MAX_LEVEL])
{
expPoints = gExperienceTables[gBaseStats[species].growthRate][MAX_MON_LEVEL];
expPoints = gExperienceTables[gBaseStats[species].growthRate][MAX_LEVEL];
SetMonData(mon, MON_DATA_EXP, &expPoints);
}
if (nextLevel > MAX_MON_LEVEL || expPoints < gExperienceTables[gBaseStats[species].growthRate][nextLevel])
if (nextLevel > MAX_LEVEL || expPoints < gExperienceTables[gBaseStats[species].growthRate][nextLevel])
{
return FALSE;
}

View File

@@ -2533,7 +2533,7 @@ static void DrawExperienceProgressBar(struct Pokemon *unused)
u16 *r9;
u8 i;
if (summary->level < MAX_MON_LEVEL)
if (summary->level < MAX_LEVEL)
{
u32 expBetweenLevels = gExperienceTables[gBaseStats[summary->species].growthRate][summary->level + 1] - gExperienceTables[gBaseStats[summary->species].growthRate][summary->level];
u32 expSinceLastLevel = summary->exp - gExperienceTables[gBaseStats[summary->species].growthRate][summary->level];
@@ -3349,7 +3349,7 @@ static void PrintExpPointsNextLevel(void)
offset = GetStringRightAlignXOffset(1, gStringVar1, 42) + 2;
SummaryScreen_PrintTextOnWindow(windowId, gStringVar1, offset, 1, 0, 0);
if (sum->level < MAX_MON_LEVEL)
if (sum->level < MAX_LEVEL)
expToNextLevel = gExperienceTables[gBaseStats[sum->species].growthRate][sum->level + 1] - sum->exp;
else
expToNextLevel = 0;

View File

@@ -1646,7 +1646,7 @@ void sub_8014304(s8 mapGroup, s8 mapNum, s32 x, s32 y, u16 arg4)
VarSet(VAR_0x4087, arg4);
gFieldLinkPlayerCount = GetLinkPlayerCount();
gUnknown_03005DB4 = GetMultiplayerId();
sub_809D2BC();
SetCableClubWarp();
Overworld_SetWarpDestination(mapGroup, mapNum, -1, x, y);
WarpIntoMap();
}

View File

@@ -52,7 +52,7 @@
typedef u16 (*SpecialFunc)(void);
typedef void (*NativeFunc)(void);
extern u32 gUnknown_020375C0;
extern const u8 *gUnknown_020375C0;
static EWRAM_DATA u32 gUnknown_020375C4 = 0;
static EWRAM_DATA u16 sPauseCounter = 0;
@@ -284,7 +284,7 @@ bool8 ScrCmd_callstd_if(struct ScriptContext *ctx)
bool8 ScrCmd_gotoram(struct ScriptContext *ctx)
{
ScriptJump(ctx, (const u8 *)gUnknown_020375C0);
ScriptJump(ctx, gUnknown_020375C0);
return FALSE;
}
@@ -2223,7 +2223,7 @@ bool8 ScrCmd_cmdCF(struct ScriptContext *ctx)
if (v1)
{
((u8*)gUnknown_020375C0) = ctx->scriptPtr;
gUnknown_020375C0 = ctx->scriptPtr;
ScriptJump(ctx, v1);
}
return FALSE;

View File

@@ -5,7 +5,7 @@
#define RAM_SCRIPT_MAGIC 51
extern u8* gUnknown_020375C0;
extern const u8* gUnknown_020375C0;
extern bool32 sub_801B27C(void);
@@ -344,7 +344,7 @@ void ClearRamScript(void)
CpuFill32(0, &gSaveBlock1Ptr->ramScript, sizeof(struct RamScript));
}
bool8 InitRamScript(u8 *script, u16 scriptSize, u8 mapGroup, u8 mapNum, u8 objectId)
bool8 InitRamScript(const u8 *script, u16 scriptSize, u8 mapGroup, u8 mapNum, u8 objectId)
{
struct RamScriptData *scriptData = &gSaveBlock1Ptr->ramScript.data;
@@ -362,7 +362,7 @@ bool8 InitRamScript(u8 *script, u16 scriptSize, u8 mapGroup, u8 mapNum, u8 objec
return TRUE;
}
u8 *GetRamScript(u8 objectId, u8 *script)
const u8 *GetRamScript(u8 objectId, const u8 *script)
{
struct RamScriptData *scriptData = &gSaveBlock1Ptr->ramScript.data;
gUnknown_020375C0 = NULL;

View File

@@ -596,13 +596,13 @@ void sub_80E95D4(void)
VarSet(VAR_OBJ_GFX_ID_F, gUnknown_0858D060[sub_80EA20C(VarGet(VAR_0x4054))]);
}
void sub_80E9608(struct Coords16 *coords, struct MapEvents *events)
void sub_80E9608(const struct MapPosition *position, const struct MapEvents *events)
{
s16 bgEventIdx;
for (bgEventIdx = 0; bgEventIdx < events->bgEventCount; bgEventIdx ++)
{
if (events->bgEvents[bgEventIdx].kind == BG_EVENT_SECRET_BASE && coords->x == events->bgEvents[bgEventIdx].x + 7 && coords->y == events->bgEvents[bgEventIdx].y + 7)
if (events->bgEvents[bgEventIdx].kind == BG_EVENT_SECRET_BASE && position->x == events->bgEvents[bgEventIdx].x + 7 && position->y == events->bgEvents[bgEventIdx].y + 7)
{
sCurSecretBaseId = events->bgEvents[bgEventIdx].bgUnion.secretBaseId;
break;
@@ -610,9 +610,9 @@ void sub_80E9608(struct Coords16 *coords, struct MapEvents *events)
}
}
void sub_80E9668(struct Coords16 *coords, struct MapEvents *events)
void sub_80E9668(const struct MapPosition *position, const struct MapEvents *events)
{
sub_80E9608(coords, events);
sub_80E9608(position, events);
sub_80E8B6C();
ScriptContext1_SetupScript(EventScript_275BB7);
}