Skip to content

Commit

Permalink
Merge pull request #288 from lhearachel/start-game
Browse files Browse the repository at this point in the history
Document game_start overlay and relevant save blocks
  • Loading branch information
lhearachel authored Nov 4, 2024
2 parents 93fad47 + 26fb0c6 commit 8489e3e
Show file tree
Hide file tree
Showing 207 changed files with 2,228 additions and 2,569 deletions.
102 changes: 33 additions & 69 deletions include/berry_data.h
Original file line number Diff line number Diff line change
@@ -1,87 +1,51 @@
#ifndef POKEPLATINUM_BERRY_DATA_H
#define POKEPLATINUM_BERRY_DATA_H

#include "struct_decls/struct_berry_data_decl.h"

#include "narc.h"
#include "strbuf.h"

// These must be #defines for csv2bin
#define FIRMNESS_VERY_SOFT 1
#define FIRMNESS_SOFT 2
#define FIRMNESS_HARD 3
#define FIRMNESS_VERY_HARD 4
#define FIRMNESS_SUPER_HARD 5

/*
* Constructs a new NARC which contains an open FSFile to the berry data archive.
*
* @param heapID: ID of the heap to alloc from
*
* @returns: Pointer to the newly-allocated NARC
*/
NARC *BerryData_NARC_ctor(u32 heapID);

BerryData *sub_020973A8(NARC *param0, u32 param1, u32 param2);
enum BerryAttribute {
BERRYATTR_SIZE = 0,
BERRYATTR_FIRMNESS,
BERRYATTR_YIELD_CATEGORY,
BERRYATTR_STAGE_DURATION,
BERRYATTR_MOISTURE_DRAIN_RATE,
BERRYATTR_SPICINESS,
BERRYATTR_DRYNESS,
BERRYATTR_SWEETNESS,
BERRYATTR_BITTERNESS,
BERRYATTR_SOURNESS,
BERRYATTR_SMOOTHNESS,
};

typedef struct BerryData {
u16 size;
u8 firmness;
u8 yieldCategory;
u8 stageDuration;
u8 moistureDrainRate;
u8 spiciness;
u8 dryness;
u8 sweetness;
u8 bitterness;
u8 sourness;
u8 smoothness;
} BerryData;

/*
* Closes the wrapped FSFile and returns the NARC allocation to the heap from whence it came.
*
* @param narc: Pointer to the NARC
*/
NARC *BerryData_NARC_ctor(u32 heapID);
BerryData *BerryData_LoadFromOpenNARC(NARC *narc, u32 memberIdx, u32 heapID);
void BerryData_NARC_dtor(NARC *narc);

/*
* Creates a new buffer large enough to hold the data of the specified
* NARC member in 'nuts_data.narc', then reads the data.
*
* @param index: Index of the NARC member within 'nuts_data.narc' which contains the berry's data
* @param heapID: ID of the heap to alloc from
*
* @returns: Pointer to the allocated buffer which contains the data that was read.
*/
BerryData *BerryData_LoadDataByNarcMemberIndex(u32 index, u32 heapID);

/*
* Creates a new buffer large enough to hold the data of the
* specified berry, then reads the data from nuts_data.narc
*
* @param itemID: Item ID of the berry for which to read the data
* @param heapID: ID of the heap to alloc from
*
* @returns: Pointer to the allocated buffer which contains the data that was read.
*/
BerryData *BerryData_Load(u32 memberIdx, u32 heapID);
BerryData *BerryData_LoadDataByItemID(u32 itemID, u32 heapID);

/*
* Retrieves the value of the specified attribute from a BerryData buffer
*
* @param berryData: Pointer to the buffer holding the berry data
* @param attributeID: ID of the attribute to retrieve the value for
*
* @returns: The value of the specified attribute
*/
u32 BerryData_GetAttribute(BerryData *berryData, u32 attributeID);

/*
* Creates a new string buffer large enough to hold the
* name of the specified berry, then reads the string.
*
* @param index: Index of the NARC member within 'nuts_data.narc' which contains the berry's data
* @param heapID: ID of the heap to alloc from
*
* @returns: Pointer to the allocated buffer which contains the string that was read.
*/
Strbuf *BerryData_AllocAndGetName(u16 index, u32 heapID);

/*
* Creates a new string buffer large enough to hold the
* description of the specified berry, then reads the string.
*
* @param index: Index of the NARC member within 'nuts_data.narc' which contains the berry's data
* @param heapID: ID of the heap to alloc from
*
* @returns: Pointer to the allocated buffer which contains the string that was read.
*/
Strbuf *BerryData_AllocAndGetDescription(u16 index, u16 heapID);
Strbuf *BerryData_AllocAndGetName(u16 memberIdx, u32 heapID);
Strbuf *BerryData_AllocAndGetDescription(u16 memberIdx, u16 heapID);

#endif // POKEPLATINUM_BERRY_DATA_H
67 changes: 67 additions & 0 deletions include/berry_patches.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#ifndef POKEPLATINUM_BERRY_PATCHES_H
#define POKEPLATINUM_BERRY_PATCHES_H

#include "constants/heap.h"

#define MAX_BERRY_PATCHES 128

enum BerryGrowthStage {
BERRY_GROWTH_STAGE_NONE = 0,
BERRY_GROWTH_STAGE_PLANTED,
BERRY_GROWTH_STAGE_SPROUTED,
BERRY_GROWTH_STAGE_GROWING,
BERRY_GROWTH_STAGE_BLOOMING,
BERRY_GROWTH_STAGE_FRUIT,
};

enum MulchType {
MULCH_TYPE_NONE = 0,
MULCH_TYPE_GROWTH,
MULCH_TYPE_DAMP,
MULCH_TYPE_STABLE,
MULCH_TYPE_GOOEY,
};

enum SoilMoisture {
SOIL_VERY_DRY = 0,
SOIL_DRY,
SOIL_MOIST,
};

typedef struct BerryPatch {
u8 berryID;
u8 growthStage;
u16 stageMinutesRemaining;
u16 moistureMinutesRemaining;
u8 replantCount;
u16 yield;
u8 moistureRating;
u8 yieldRating;
u8 mulchType;
u8 isGrowing;
} BerryPatch;

typedef struct BerryGrowthData {
u8 stageDuration;
u8 moistureDrainRate;
u8 yieldCategory;
} BerryGrowthData;

void BerryPatches_Clear(BerryPatch *patches);
void BerryPatches_Init(BerryPatch *patches, enum HeapId heapID, const u16 *initPatches, int initSize);
BerryGrowthData *BerryGrowthData_Init(enum HeapId heapID);
enum BerryGrowthStage BerryPatches_GetPatchGrowthStage(const BerryPatch *patches, int patchID);
int BerryPatches_GetPatchBerryID(const BerryPatch *patches, int patchID);
enum SoilMoisture BerryPatches_GetPatchMoisture(const BerryPatch *patches, int patchID);
int BerryPatches_GetPatchYieldRating(const BerryPatch *patches, int patchID);
void BerryPatches_PlantInPatch(BerryPatch *patches, int patchID, const BerryGrowthData *growthData, int berryID);
void BerryPatches_ResetPatchMoisture(BerryPatch *patches, int patchID);
BOOL BerryPatches_IsPatchGrowing(const BerryPatch *patches, int patchID);
void BerryPatches_SetIsPatchGrowing(BerryPatch *patches, int patchID, BOOL isGrowing);
enum MulchType BerryPatches_GetPatchMulchType(const BerryPatch *patches, int patchID);
void BerryPatches_SetPatchMulchType(BerryPatch *patches, int patchID, enum MulchType mulchType);
int BerryPatches_GetPatchYield(const BerryPatch *patches, int patchID);
int BerryPatches_HarvestPatch(BerryPatch *patches, int patchID);
void BerryPatches_ElapseMinutes(BerryPatch *patches, const BerryGrowthData *growthData, int minutesPassed);

#endif // POKEPLATINUM_BERRY_PATCHES_H
2 changes: 1 addition & 1 deletion include/constants/field/map_load.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef POKEPLATINUM_CONSTANTS_FIELD_MAP_LOAD_H
#define POKEPLATINUM_CONSTANTS_FIELD_MAP_LOAD_H

enum {
enum MapLoadType {
MAP_LOAD_TYPE_OVERWORLD = 0,
MAP_LOAD_TYPE_UNDERGROUND,
MAP_LOAD_TYPE_UNION,
Expand Down
7 changes: 7 additions & 0 deletions include/constants/heap.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ enum HeapId {
HEAP_ID_POKETCH_MAIN = 7,
HEAP_ID_POKETCH_APP,

HEAP_ID_FIELDMAP = 11,

HEAP_ID_COMMUNICATION = 15,

HEAP_ID_DISTORTION_WORLD_WARP = 30,
Expand All @@ -20,16 +22,21 @@ enum HeapId {

HEAP_ID_CHOOSE_STARTER_APP = 47,

HEAP_ID_GAME_START = 77,

HEAP_ID_LIBRARY_TV = 120,
};

enum HeapSize {
HEAP_SIZE_POKETCH_MAIN = 0xc000,
HEAP_SIZE_POKETCH_APP = 0xc000,

HEAP_SIZE_FIELDMAP = 0x1C000,

HEAP_SIZE_CHOOSE_STARTER_APP = 0x40000,
HEAP_SIZE_LIBRARY_TV = 0x40000,
HEAP_SIZE_DISTORTION_WORLD_WARP = 0x50000,
HEAP_SIZE_GAME_START = 0x20000,
};

#endif // POKEPLATINUM_CONSTANTS_HEAP_H
2 changes: 1 addition & 1 deletion include/constants/savedata/save_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ enum SaveTableEntryID {
SAVE_TABLE_ENTRY_IMAGE_CLIPS,
SAVE_TABLE_ENTRY_MAIL,
SAVE_TABLE_ENTRY_POFFINS,
SAVE_TABLE_ENTRY_RANDOM_GROUP,
SAVE_TABLE_ENTRY_RECORD_MIXED_RNG,
SAVE_TABLE_ENTRY_JOURNAL,
SAVE_TABLE_ENTRY_TRAINER_CARD,
SAVE_TABLE_ENTRY_GAME_RECORDS,
Expand Down
9 changes: 5 additions & 4 deletions include/constants/string.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#ifndef POKEPLATINUM_CONSTANTS_STRING_H
#define POKEPLATINUM_CONSTANTS_STRING_H

#define MON_NAME_LEN 10
#define TRAINER_NAME_LEN 7
#define TABLET_NAME_LEN 10
#define MOVE_NAME_LEN 16
#define MON_NAME_LEN 10
#define TRAINER_NAME_LEN 7
#define TABLET_NAME_LEN 10
#define MOVE_NAME_LEN 16
#define UNION_GROUP_NAME_LEN 7

#endif
4 changes: 2 additions & 2 deletions include/core_sys.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ typedef struct CoreSys {
SysTaskManager *mainTaskMgr;
SysTaskManager *vBlankTaskMgr;
SysTaskManager *postVBlankTaskMgr;
SysTaskManager *unk_24;
SysTaskManager *printTaskMgr;
u32 *unk_28;
u32 vblankCounter;
u32 frameCounter;
u32 unk_30;
enum ButtonMode buttonMode;
u32 heldKeysRaw;
u32 pressedKeysRaw;
Expand Down
Loading

0 comments on commit 8489e3e

Please sign in to comment.