make lots of define files

This commit is contained in:
DizzyEggg 2017-09-07 19:45:32 +02:00
parent 8bfdc42d0e
commit 4a1b2967ca
18 changed files with 379 additions and 100 deletions

View File

@ -7,99 +7,6 @@
thumb_func_start NewGameInitData
@ void NewGameInitData()
NewGameInitData: @ 80844A0
push {r4,r5,lr}
ldr r0, =gSaveFileStatus
ldrh r0, [r0]
cmp r0, 0
beq _080844AE
cmp r0, 0x2
bne _080844B2
_080844AE:
bl RtcReset
_080844B2:
ldr r1, =gDifferentSaveFile
movs r0, 0x1
strb r0, [r1]
ldr r4, =gSaveBlock2Ptr
ldr r0, [r4]
adds r0, 0xAC
movs r5, 0
str r5, [r0]
bl ZeroPlayerPartyMons
bl ZeroEnemyPartyMons
bl ResetPokedex
bl sub_8084400
bl ClearSav1
bl ClearMailData
ldr r0, [r4]
strb r5, [r0, 0x9]
ldr r0, [r4]
adds r0, 0xA8
str r5, [r0]
bl InitPlayerTrainerId
bl PlayTimeCounter_Reset
bl ClearPokedexFlags
bl InitEventData
bl ClearTVShowData
bl ResetGabbyAndTy
bl ResetSecretBases
bl ClearBerryTrees
ldr r4, =gSaveBlock1Ptr
ldr r0, [r4]
movs r1, 0x92
lsls r1, 3
adds r0, r1
ldr r1, =0x00000bb8
bl SetMoney
movs r0, 0
bl SetCoins
bl ResetLinkContestBoolean
bl ResetGameStats
bl ClearAllContestWinnerPics
bl InitLinkBattleRecords
bl InitSeedotSizeRecord
bl InitLotadSizeRecord
ldr r0, =gPlayerPartyCount
strb r5, [r0]
bl ZeroPlayerPartyMons
bl ResetPokemonStorageSystem
bl ClearRoamerData
bl ClearRoamerLocationData
ldr r0, [r4]
ldr r1, =0x00000496
adds r0, r1
strh r5, [r0]
bl ClearBag
bl NewGameInitPCItems
bl ClearPokeblocks
bl ClearDecorationInventories
bl InitEasyChatPhrases
bl SetMauvilleOldMan
bl InitDewfordTrend
bl ResetFanClub
bl ResetLotteryCorner
bl WarpToTruck
ldr r0, =gUnknown_082715DE
bl ScriptContext2_RunNewScript
bl ResetMiniGamesResults
bl copy_strings_to_sav1
bl SetLilycoveLady
bl sub_819FAA0
bl sub_81A4B14
bl sub_8195E10
bl sub_801AFD8
bl sub_800E5AC
bl sub_81D54BC
bl ResetContestLinkResults
pop {r4,r5}
pop {r0}
bx r0
.pool
thumb_func_end NewGameInitData
thumb_func_start ResetMiniGamesResults
ResetMiniGamesResults: @ 80845CC
push {r4-r6,lr}

23
include/battle_message.h Normal file
View File

@ -0,0 +1,23 @@
#ifndef GUARD_BATTLE_MESSAGE_H
#define GUARD_BATTLE_MESSAGE_H
struct StringInfoBattle
{
u16 currentMove;
u16 lastMove;
u16 lastItem;
u8 lastAbility;
u8 scrActive;
u8 unk1605E;
u8 hpScale;
u8 StringBank;
u8 moveType;
u8 abilities[4];
u8 textBuffs[3][0x10];
};
void BufferStringBattle(u16 stringID);
u32 StrCpyDecodeToDisplayedStringBattle(const u8* src);
u32 StrCpyDecodeBattle(const u8* src, u8* dst);
#endif // GUARD_BATTLE_MESSAGE_H

48
include/berry.h Normal file
View File

@ -0,0 +1,48 @@
#ifndef GUARD_BERRY_H
#define GUARD_BERRY_H
enum
{
BERRY_FIRMNESS_UNKNOWN,
BERRY_FIRMNESS_VERY_SOFT,
BERRY_FIRMNESS_SOFT,
BERRY_FIRMNESS_HARD,
BERRY_FIRMNESS_VERY_HARD,
BERRY_FIRMNESS_SUPER_HARD,
};
void ClearEnigmaBerries(void);
void SetEnigmaBerry(u8 *src);
u32 GetEnigmaBerryChecksum(struct EnigmaBerry *enigmaBerry);
bool32 IsEnigmaBerryValid(void);
const struct Berry *GetBerryInfo(u8 berry);
struct BerryTree *GetBerryTreeInfo(u8 id);
bool32 FieldObjectInteractionWaterBerryTree(void);
bool8 IsPlayerFacingPlantedBerryTree(void);
bool8 TryToWaterBerryTree(void);
void ClearBerryTrees(void);
bool32 BerryTreeGrow(struct BerryTree *tree);
void BerryTreeTimeUpdate(s32 minutes);
void PlantBerryTree(u8 id, u8 berry, u8 stage, bool8 sparkle);
void RemoveBerryTree(u8 id);
u8 GetBerryTypeByBerryTreeId(u8 id);
u8 GetStageByBerryTreeId(u8);
u8 ItemIdToBerryType(u16 item);
u16 BerryTypeToItemId(u16 berry);
void GetBerryNameByBerryType(u8 berry, u8 *string);
void ResetBerryTreeSparkleFlag(u8 id);
u8 BerryTreeGetNumStagesWatered(struct BerryTree *tree);
u8 GetNumStagesWateredByBerryTreeId(u8 id);
u8 CalcBerryYieldInternal(u16 max, u16 min, u8 water);
u8 CalcBerryYield(struct BerryTree *tree);
u8 GetBerryCountByBerryTreeId(u8 id);
u16 GetStageDurationByBerryType(u8);
void FieldObjectInteractionGetBerryTreeData(void);
void sub_80B4EE4(void);
void FieldObjectInteractionPlantBerryTree(void);
void FieldObjectInteractionPickBerryTree(void);
void FieldObjectInteractionRemoveBerryTree(void);
u8 PlayerHasBerries(void);
void ResetBerryTreeSparkleFlags(void);
#endif // GUARD_BERRY_H

6
include/coins.h Normal file
View File

@ -0,0 +1,6 @@
#ifndef GUARD_COINS_H
#define GUARD_COINS_H
void SetCoins(u16 newValue);
#endif // GUARD_COINS_H

7
include/dewford_trend.h Normal file
View File

@ -0,0 +1,7 @@
#ifndef GUARD_DEWFORDTREND_H
#define GUARD_DEWFORDTREND_H
void InitDewfordTrend(void);
void UpdateDewfordTrendPerDay(u16);
#endif // GUARD_DEWFORDTREND_H

33
include/easy_chat.h Normal file
View File

@ -0,0 +1,33 @@
#ifndef GUARD_EASYCHAT_H
#define GUARD_EASYCHAT_H
// Taken from Pokeruby, check if it's correct
enum
{
EC_GROUP_POKEMON,
EC_GROUP_TRAINER,
EC_GROUP_STATUS,
EC_GROUP_BATTLE,
EC_GROUP_GREETINGS,
EC_GROUP_PEOPLE,
EC_GROUP_VOICES,
EC_GROUP_SPEECH,
EC_GROUP_ENDINGS,
EC_GROUP_FEELINGS,
EC_GROUP_CONDITIONS,
EC_GROUP_ACTIONS,
EC_GROUP_LIFESTYLE,
EC_GROUP_HOBBIES,
EC_GROUP_TIME,
EC_GROUP_MISC,
EC_GROUP_ADJECTIVES,
EC_GROUP_EVENTS,
EC_GROUP_MOVE_1,
EC_GROUP_MOVE_2,
EC_GROUP_TRENDY_SAYING,
EC_GROUP_POKEMON_2,
};
void InitEasyChatPhrases(void);
#endif // GUARD_EASYCHAT_H

View File

@ -155,7 +155,7 @@ struct SaveBlock2
/*0x90*/ u8 filler_90[0x8];
/*0x98*/ struct Time localTimeOffset;
/*0xA0*/ struct Time lastBerryTreeUpdate;
/*0xA8*/ u8 filler_A8[0x4];
/*0xA8*/ u32 field_A8;
/*0xAC*/ u32 encryptionKey;
// TODO: fix and verify labels

6
include/lilycove_lady.h Normal file
View File

@ -0,0 +1,6 @@
#ifndef GUARD_LILYCOVE_LADY_H
#define GUARD_LILYCOVE_LADY_H
void SetLilycoveLady(void);
#endif //GUARD_LILYCOVE_LADY_H

View File

@ -3,6 +3,8 @@
extern bool32 gFlashMemoryPresent;
void ClearSav2(void);
void ClearSav1(void);
void CheckForFlashMemory(void);
void MoveSaveBlocks_ResetHeap(void);
bool32 GetSecretBase2Field_9(void);

12
include/lottery_corner.h Normal file
View File

@ -0,0 +1,12 @@
#ifndef GUARD_LOTTERY_CORNER_H
#define GUARD_LOTTERY_CORNER_H
void ResetLotteryCorner(void);
void SetRandomLotteryNumber(u16 i);
void RetrieveLotteryNumber(void);
void PickLotteryCornerTicket(void);
void SetLotteryNumber(u32 lotteryNum);
u32 GetLotteryNumber(void);
void SetLotteryNumber16_Unused(u16 lotteryNum);
#endif // GUARD_LOTTERY_CORNER_H

View File

@ -0,0 +1,6 @@
#ifndef GUARD_MAUVILLE_OLD_MAN_H
#define GUARD_MAUVILLE_OLD_MAN_H
void SetMauvilleOldMan(void);
#endif // GUARD_MAUVILLE_OLD_MAN_H

6
include/money.h Normal file
View File

@ -0,0 +1,6 @@
#ifndef GUARD_MONEY_H
#define GUARD_MONEY_H
void SetMoney(u32* moneyPtr, u32 newValue);
#endif // GUARD_MONEY_H

View File

@ -8,5 +8,6 @@ void SetDefaultOptions(void);
void ClearPokedexFlags(void);
void WarpToTruck(void);
void NewGameInitData(void);
void ResetMiniGamesResults(void);
#endif // GUARD_NEW_GAME_H

45
include/pokeblock.h Normal file
View File

@ -0,0 +1,45 @@
#ifndef GUARD_POKEBLOCK_H
#define GUARD_POKEBLOCK_H
enum
{
PBLOCK_CLR_BLACK,
PBLOCK_CLR_RED,
PBLOCK_CLR_BLUE,
PBLOCK_CLR_PINK,
PBLOCK_CLR_GREEN,
PBLOCK_CLR_YELLOW
};
enum
{
PBLOCK_COLOR,
PBLOCK_SPICY,
PBLOCK_DRY,
PBLOCK_SWEET,
PBLOCK_BITTER,
PBLOCK_SOUR,
PBLOCK_FEEL,
};
void ClearPokeblocks(void);
/*
void sub_810B96C(void);
u8 sub_810BA50(s16, s16, u8);
u8 sub_810C9B0(struct Pokeblock *);
s16 GetPokeblockData(const struct Pokeblock *, u8);
u8 sub_810C9E8(struct Pokeblock *);
void sub_810BA7C(u8);
bool8 PokeblockClearIfExists(u8);
s16 PokeblockGetGain(u8, const struct Pokeblock *);
u8 sub_810CB68(u8, u8*);
void PokeblockCopyName(struct Pokeblock *pokeblock, u8 *dest);
void CB2_PreparePokeblockFeedScene(void);
#include "main.h"
void sub_8136130(struct Pokeblock *, MainCallback);
*/
#endif // GUARD_POKEBLOCK_H

View File

@ -0,0 +1,12 @@
#ifndef GUARD_POKEMON_SIZE_RECORD_H
#define GUARD_POKEMON_SIZE_RECORD_H
void InitSeedotSizeRecord(void);
void GetSeedotSizeRecordInfo(void);
void CompareSeedotSize(void);
void InitLotadSizeRecord(void);
void GetLotadSizeRecordInfo(void);
void CompareLotadSize(void);
#endif // GUARD_POKEMON_SIZE_RECORD_H

11
include/roamer.h Normal file
View File

@ -0,0 +1,11 @@
#ifndef GUARD_ROAMER_H
#define GUARD_ROAMER_H
void ClearRoamerData(void);
void ClearRoamerLocationData(void);
void UpdateLocationHistoryForRoamer(void);
void RoamerMoveToOtherLocationSet(void);
void RoamerMove();
u8 TryStartRoamerEncounter(void);
#endif // GUARD_ROAMER_H

59
include/script.h Normal file
View File

@ -0,0 +1,59 @@
#ifndef GUARD_SCRIPT_H
#define GUARD_SCRIPT_H
struct ScriptContext;
typedef bool8 (*ScrCmdFunc)(struct ScriptContext *);
typedef u8 Script[];
struct ScriptContext
{
u8 stackDepth;
u8 mode;
u8 comparisonResult;
u8 (*nativePtr)(void);
const u8 *scriptPtr;
const u8 *stack[20];
ScrCmdFunc *cmdTable;
ScrCmdFunc *cmdTableEnd;
u32 data[4];
};
#define ScriptReadByte(ctx) (*(ctx->scriptPtr++))
void InitScriptContext(struct ScriptContext *ctx, void *cmdTable, void *cmdTableEnd);
u8 SetupBytecodeScript(struct ScriptContext *ctx, const u8 *ptr);
void SetupNativeScript(struct ScriptContext *ctx, void *ptr);
void StopScript(struct ScriptContext *ctx);
u8 RunScriptCommand(struct ScriptContext *ctx);
u8 ScriptPush(struct ScriptContext *ctx, const u8 *ptr);
const u8 *ScriptPop(struct ScriptContext *ctx);
void ScriptJump(struct ScriptContext *ctx, u8 *ptr);
void ScriptCall(struct ScriptContext *ctx, u8 *ptr);
void ScriptReturn(struct ScriptContext *ctx);
u16 ScriptReadHalfword(struct ScriptContext *ctx);
u32 ScriptReadWord(struct ScriptContext *ctx);
void ScriptContext2_Enable(void);
void ScriptContext2_Disable(void);
bool8 ScriptContext2_IsEnabled(void);
void ScriptContext1_Init(void);
bool8 ScriptContext2_RunScript(void);
void ScriptContext1_SetupScript(const u8 *ptr);
void ScriptContext1_Stop(void);
void EnableBothScriptContexts(void);
void ScriptContext2_RunNewScript(const u8 *ptr);
u8 *mapheader_get_tagged_pointer(u8 tag);
void mapheader_run_script_by_tag(u8 tag);
u8 *mapheader_get_first_match_from_tagged_ptr_list(u8 tag);
void mapheader_run_script_with_tag_x1(void);
void mapheader_run_script_with_tag_x3(void);
void mapheader_run_script_with_tag_x5(void);
void mapheader_run_script_with_tag_x6(void);
bool8 mapheader_run_first_tag2_script_list_match(void);
void mapheader_run_first_tag4_script_list_match(void);
u32 CalculateRamScriptChecksum(void);
void ClearRamScript(void);
bool8 InitRamScript(u8 *script, u16 scriptSize, u8 mapGroup, u8 mapNum, u8 objectId);
u8 *GetRamScript(u8 objectId, u8 *script);
#endif // GUARD_SCRIPT_H

View File

@ -1,22 +1,62 @@
#include "global.h"
#include "new_game.h"
#include "rng.h"
#include "pokemon.h"
#include "roamer.h"
#include "pokemon_size_record.h"
#include "script.h"
#include "lottery_corner.h"
#include "play_time.h"
#include "mauville_old_man.h"
#include "lilycove_lady.h"
#include "load_save.h"
#include "pokeblock.h"
#include "dewford_trend.h"
#include "berry.h"
#include "rtc.h"
#include "easy_chat.h"
#include "event_data.h"
#include "money.h"
#include "coins.h"
extern u8 gPlayerPartyCount;
extern u8 gDifferentSaveFile;
extern u16 gSaveFileStatus;
extern u8 gUnknown_030060B0;
// TODO: replace those declarations with file headers
extern u16 GetGeneratedTrainerIdLower(void);
extern void ClearContestWinnerPicsInContestHall(void);
extern void warp1_set(s8 mapBank, s8 mapNo, s8 warpNo, s8 xPos, s8 yPos);
extern void warp_in(void);
extern void sub_80BB358(void);
extern void ZeroPlayerPartyMons(void);
extern void ZeroEnemyPartyMons(void);
extern void ResetBagScrollPositions(void);
extern void sub_813624C(void); // clears something pokeblock related
extern void ClearSav2(void); // clears something pokeblock related
extern void ResetPokedex(void);
extern void sub_8084400(void);
extern void ClearMailData(void);
extern void ClearTVShowData(void);
extern void ResetGabbyAndTy(void);
extern void ResetSecretBases(void);
extern void ResetLinkContestBoolean(void);
extern void ResetGameStats(void);
extern void sub_8052DA8(void);
extern void InitLinkBattleRecords(void);
extern void ResetPokemonStorageSystem(void);
extern void ClearBag(void);
extern void NewGameInitPCItems(void);
extern void ClearDecorationInventories(void);
extern void ResetFanClub(void);
extern void copy_strings_to_sav1(void);
extern void sub_819FAA0(void);
extern void sub_81A4B14(void);
extern void sub_8195E10(void);
extern void sub_801AFD8(void);
extern void sub_800E5AC(void);
extern void sub_81D54BC(void);
extern void ResetContestLinkResults(void);
extern u8 gUnknown_082715DE[];
void WriteUnalignedWord(u32 var, u8 *dataPtr)
{
@ -104,8 +144,63 @@ void sub_808447C(void)
ResetBagScrollPositions();
sub_813624C();
}
/*
void NewGameInitData(void)
{
Finish when more header files are available
}*/
if (gSaveFileStatus == 0 || gSaveFileStatus == 2)
RtcReset();
gDifferentSaveFile = 1;
gSaveBlock2Ptr->encryptionKey = 0;
ZeroPlayerPartyMons();
ZeroEnemyPartyMons();
ResetPokedex();
sub_8084400();
ClearSav1();
ClearMailData();
gSaveBlock2Ptr->specialSaveWarp = 0;
gSaveBlock2Ptr->field_A8 = 0;
InitPlayerTrainerId();
PlayTimeCounter_Reset();
ClearPokedexFlags();
InitEventData();
ClearTVShowData();
ResetGabbyAndTy();
ResetSecretBases();
ClearBerryTrees();
SetMoney(&gSaveBlock1Ptr->money, 3000);
SetCoins(0);
ResetLinkContestBoolean();
ResetGameStats();
ClearAllContestWinnerPics();
InitLinkBattleRecords();
InitSeedotSizeRecord();
InitLotadSizeRecord();
gPlayerPartyCount = 0;
ZeroPlayerPartyMons();
ResetPokemonStorageSystem();
ClearRoamerData();
ClearRoamerLocationData();
gSaveBlock1Ptr->registeredItem = 0;
ClearBag();
NewGameInitPCItems();
ClearPokeblocks();
ClearDecorationInventories();
InitEasyChatPhrases();
SetMauvilleOldMan();
InitDewfordTrend();
ResetFanClub();
ResetLotteryCorner();
WarpToTruck();
ScriptContext2_RunNewScript(gUnknown_082715DE);
ResetMiniGamesResults();
copy_strings_to_sav1();
SetLilycoveLady();
sub_819FAA0();
sub_81A4B14();
sub_8195E10();
sub_801AFD8();
sub_800E5AC();
sub_81D54BC();
ResetContestLinkResults();
}