papermario/include/map.h

315 lines
10 KiB
C
Raw Normal View History

#ifndef _MAP_H_
#define _MAP_H_
#include "common_structs.h"
#include "enums.h"
#include "script_api/map.h"
// TODO: consider moving Npc here
#define ENTRY_COUNT(entryList) (sizeof(entryList) / sizeof(Vec4f))
typedef s32 MessageID;
2021-04-03 19:21:49 +02:00
typedef Vec4f EntryList[];
/// Fields other than main, entryList, entryCount, background, and tattle are initialised when the map loads.
typedef struct MapConfig {
/* 0x00 */ ModelNode* modelTreeRoot;
/* 0x04 */ UNK_PTR collision;
/* 0x08 */ char unk_08[8];
2020-10-20 08:33:40 +02:00
/* 0x10 */ Script* main;
/* 0x14 */ EntryList* entryList;
/* 0x18 */ s32 entryCount;
/* 0x1C */ char unk_1C[12];
/* 0x28 */ char** modelNameList;
/* 0x2C */ char** colliderNameList;
/* 0x30 */ char** zoneNameList;
/* 0x34 */ char unk_34[4];
2020-10-20 08:33:40 +02:00
/* 0x38 */ BackgroundHeader* background;
/* 0x3C */ union {
MessageID msgID;
UNK_FUN_PTR(get);
} tattle;
} MapConfig; // size = 0x40
2021-01-15 23:26:03 +01:00
typedef s32(*MapInit)(void);
2020-10-30 18:43:12 +01:00
#define MAP_ID_MAX_LEN 7 ///< "xxx_yyy" excluding null terminator.
typedef struct Map {
/* 0x00 */ char* id; ///< @see MAP_ID_MAX_LEN
/* 0x04 */ MapConfig* config;
/* 0x08 */ void* dmaStart;
/* 0x0C */ void* dmaEnd;
/* 0x10 */ void* dmaDest;
/* 0x14 */ char* bgName;
2021-01-12 20:45:50 +01:00
/* 0x18 */ MapInit init; ///< Return TRUE to skip normal asset (shape/hit/bg/tex) loading.
f270, world, and more (#246) * 415D90 decomp * code_415D90 rodata migration * data migration, decomp * . * . * . * 4 funcs * non-matching * audio part 1 * audio work * end of snd * update_symbol_addrs * . * :chicken: * . * sfx func names * bgm * more audio * . * a few audio funcs * update section length * git subrepo pull --force tools/splat subrepo: subdir: "tools/splat" merged: "82ff308caf" upstream: origin: "https://github.com/ethteck/splat.git" branch: "master" commit: "82ff308caf" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo" commit: "2f68596" * git subrepo pull --force tools/splat subrepo: subdir: "tools/splat" merged: "4e9d3cdf85" upstream: origin: "https://github.com/ethteck/splat.git" branch: "master" commit: "4e9d3cdf85" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo" commit: "2f68596" * misc-decomp power * sound * 4 mo * more changes * . * some f270 * git subrepo pull --force tools/splat subrepo: subdir: "tools/splat" merged: "1c8ff4ec3f" upstream: origin: "https://github.com/ethteck/splat.git" branch: "master" commit: "1c8ff4ec3f" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo" commit: "2f68596" * git subrepo pull --force tools/splat subrepo: subdir: "tools/splat" merged: "f0633ecdbc" upstream: origin: "https://github.com/ethteck/splat.git" branch: "master" commit: "f0633ecdbc" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo" commit: "2f68596" * fix is_logo image size * . * git subrepo pull tools/splat subrepo: subdir: "tools/splat" merged: "4be92a4786" upstream: origin: "https://github.com/ethteck/splat.git" branch: "master" commit: "4be92a4786" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo" commit: "2f68596" * state_step_pause * almost * fixing symbol_addrs and disasm * update symbol_addrs * . * fix Matrix4f usages * . * . * update_symbol_addrs * fixes * I hate bitfields * load_map_by_IDs * cleanup * state_step_logos * more cleanup * . * splat * PR comments
2021-04-01 20:00:29 +02:00
/* 0x1C */ union {
u32 u32;
struct {
char unk_1C[0x2];
s8 songVariation; ///< 0 or 1. @see bgm_get_map_default_variation
s8 flags;
} bytes;
} unk_1C;
} Map; // size = 0x20
typedef struct Area {
/* 0x00 */ s32 mapCount;
/* 0x04 */ Map* maps;
/* 0x08 */ char* id; ///< "area_xxx"
/* 0x0C */ char* name; ///< JP debug name.
} Area; // size = 0x10
2020-11-20 05:08:05 +01:00
2021-02-09 14:07:46 +01:00
typedef struct NpcBlueprint {
/* 0x00 */ s32 flags;
/* 0x04 */ NpcAnimID initialAnim;
/* 0x08 */ void (*onUpdate)(struct Npc*);
/* 0x0C */ void (*onRender)(struct Npc*);
2021-02-09 14:07:46 +01:00
} NpcBlueprint; // size = 0x10
typedef struct NpcAISettings {
/* 0x00 */ f32 moveSpeed;
/* 0x04 */ s32 moveTime;
/* 0x08 */ s32 waitTime;
/* 0x0C */ f32 alertRadius;
/* 0x10 */ X32 unk_10;
/* 0x14 */ s32 unk_14;
/* 0x18 */ f32 chaseSpeed;
/* 0x1C */ X32 unk_1C; // chase turn step?
/* 0x20 */ s32 unk_20;
/* 0x24 */ f32 chaseRadius;
/* 0x28 */ X32 unk_28;
/* 0x2C */ s32 unk_2C; // bool
} NpcAISettings; // size = 0x30
2020-10-20 08:33:40 +02:00
typedef struct NpcSettings {
/* 0x00 */ char unk_00[4];
/* 0x04 */ s16 height;
/* 0x06 */ s16 radius;
/* 0x08 */ UNK_PTR otherAI;
2020-10-20 08:33:40 +02:00
/* 0x0C */ Script* onInteract;
/* 0x10 */ Script* ai;
/* 0x14 */ Script* onHit;
/* 0x18 */ Script* aux;
/* 0x1C */ Script* onDefeat;
/* 0x20 */ s32 flags;
/* 0x24 */ char unk_24[4];
/* 0x28 */ s16 level;
/* 0x2A */ s16 unk_2A;
2020-10-20 08:33:40 +02:00
} NpcSettings; // size = 0x2C
typedef struct ItemDrop {
2021-03-29 09:34:39 +02:00
/* 0x00 */ ItemID item;
/* 0x02 */ s16 weight;
/* 0x04 */ s16 unk_08;
} ItemDrop; // size = 0x06
2020-10-22 07:01:11 +02:00
/// @brief Describes heart/flower drop chances after defeating an Npc in the overworld.
///
/// The algorithm for calculating the number of hearts/flowers from a StatDrop is:
/// - If current HP/FP > cutoff, drop 0.
/// - Roll generalChance. If it fails, drop 0.
/// - Roll chancePerAttempt attempts times. For each success, drop a heart/flower.
///
/// StaticNpc holds a table of StatDrops for each stat (hearts, flowers). All are checked together
/// and the number of hearts/flowers to drop is the total number of successful attempts for each stat.
///
/// Each heart/flower is worth 1 HP and 1 FP respectively, if picked up.
///
/// cutoff, generalChance, and chancePerAttempt are short fixed-point percentage values.
/// That is, `F16(0)` is a 0% chance and `F16(100)` is a 100% chance.
typedef struct StatDrop {
2020-10-22 07:01:11 +02:00
/* 0x00 */ s16 cutoff; ///< % of max HP/FP. If current HP/FP > cutoff, no hearts/flowers can be dropped.
/* 0x02 */ s16 generalChance; ///< % chance for any hearts/flowers to be dropped at all from this StatDrop.
/* 0x04 */ s16 attempts; ///< Maximum number of hearts/flowers that can be dropped from this StatDrop.
/* 0x06 */ s16 chancePerAttempt; ///< % chance for a single heart/flower to be dropped from each attempt.
} StatDrop; // size = 0x08
2021-04-03 19:21:49 +02:00
#define NO_DROPS { { F16(100), F16(0), 0, F16(0) }, }
#define STANDARD_HEART_DROPS(attempts) { \
{ F16(20), F16(70), attempts, F16(50) }, \
{ F16(30), F16(60), attempts, F16(50) }, \
{ F16(50), F16(50), attempts, F16(40) }, \
{ F16(80), F16(40), attempts, F16(40) }, \
{ F16(100), F16(30), attempts, F16(30) }, \
}
#define GENEROUS_HEART_DROPS(attempts) { \
{ F16(20), F16(80), attempts, F16(50) } \
{ F16(30), F16(70), attempts, F16(50) } \
{ F16(50), F16(60), attempts, F16(40) } \
{ F16(80), F16(50), attempts, F16(40) } \
{ F16(100), F16(40), attempts, F16(30) }, \
}
#define GENEROUS_WHEN_LOW_HEART_DROPS(attempts) { \
{ F16(20), F16(80), attempts, F16(60) }, \
{ F16(30), F16(70), attempts, F16(50) }, \
{ F16(50), F16(60), attempts, F16(50) }, \
{ F16(80), F16(50), attempts, F16(40) }, \
{ F16(100), F16(30), attempts, F16(30) }, \
}
#define STANDARD_FLOWER_DROPS(attempts) { \
{ F16(20), F16(50), attempts, F16(40) }, \
{ F16(30), F16(40), attempts, F16(40) }, \
{ F16(50), F16(40), attempts, F16(40) }, \
{ F16(80), F16(40), attempts, F16(40) }, \
{ F16(100), F16(30), attempts, F16(40) }, \
}
#define GENEROUS_WHEN_LOW_FLOWER_DROPS(attempts) { \
{ F16(20), F16(70), attempts, F16(50) }, \
{ F16(30), F16(60), attempts, F16(50) }, \
{ F16(50), F16(50), attempts, F16(40) }, \
{ F16(80), F16(40), attempts, F16(40) }, \
{ F16(100), F16(30), attempts, F16(40) }, \
}
#define REDUCED_FLOWER_DROPS(attempts) { \
{ F16(20), F16(40), attempts, F16(40) }, \
{ F16(30), F16(40), attempts, F16(40) }, \
{ F16(50), F16(40), attempts, F16(40) }, \
{ F16(80), F16(40), attempts, F16(40) }, \
{ F16(100), F16(30), attempts, F16(40) }, \
}
2020-10-20 09:14:07 +02:00
#define OVERRIDE_MOVEMENT_SPEED(speed) (speed * 32767)
#define NO_OVERRIDE_MOVEMENT_SPEED OVERRIDE_MOVEMENT_SPEED(-1)
typedef struct StaticNpc {
2021-03-29 09:34:39 +02:00
/* 0x000 */ NpcID id;
2020-10-20 08:33:40 +02:00
/* 0x004 */ NpcSettings* settings;
/* 0x008 */ Vec3f pos;
/* 0x014 */ s32 flags;
/* 0x018 */ Bytecode* init;
/* 0x01C */ char unk_1C[8];
/* 0x024 */ s32 yaw;
/* 0x028 */ s8 dropFlags;
/* 0x029 */ s8 itemDropChance; // %
/* 0x02A */ ItemDrop itemDrops[8];
/* 0x05A */ StatDrop heartDrops[8];
/* 0x09A */ StatDrop flowerDrops[8];
/* 0x0DA */ s16 minCoinBonus;
/* 0x0DC */ s16 maxCoinBonus;
2020-10-20 09:14:07 +02:00
/* 0x0E0 */ s32 movement[48]; // TODO: type
2020-11-11 17:33:55 +01:00
/* 0x1A0 */ NpcAnimID animations[16];
/* 0x1E0 */ char unk_1E0[8];
2020-11-11 17:33:55 +01:00
/* 0x1E8 */ NpcAnimID* extraAnimations;
2020-10-20 08:33:40 +02:00
/* 0x1EC */ MessageID tattle;
} StaticNpc; // size = 0x1F0
2021-04-03 19:21:49 +02:00
enum TerritoryShape { SHAPE_CYLINDER, SHAPE_RECT };
typedef struct {
/* 0x00 */ s32 unk_00;
2021-04-03 19:21:49 +02:00
/* 0x04 */ enum TerritoryShape shape;
/* 0x08 */ s32 pointX;
/* 0x0C */ s32 pointZ;
/* 0x10 */ s32 sizeX;
/* 0x14 */ s32 sizeZ;
/* 0x18 */ f32 unk_34;
/* 0x1C */ s16 unk_1C;
} EnemyTerritoryThing; // size = 0x20
2021-04-03 19:21:49 +02:00
typedef struct {
/* 0x00 */ Vec3i point;
/* 0x0C */ s32 wanderSizeX;
/* 0x10 */ s32 wanderSizeZ;
/* 0x14 */ s32 moveSpeedOverride;
/* 0x18 */ enum TerritoryShape wanderShape;
/* 0x1C */ Vec3i detect;
/* 0x28 */ s32 detectSizeX;
/* 0x2C */ s32 detectSizeZ;
/* 0x30 */ enum TerritoryShape detectShape;
/* 0x34 */ s32 isFlying;
} EnemyTerritoryWander; // size = 0x38
typedef struct {
/* 0x00 */ s32 numPoints;
/* 0x04 */ Vec3i points[10];
/* 0x7C */ s32 moveSpeedOverride;
/* 0x80 */ Vec3i detect;
/* 0x8C */ s32 detectSizeX;
/* 0x90 */ s32 detectSizeZ;
/* 0x94 */ enum TerritoryShape detectShape;
/* 0x98 */ s32 isFlying;
} EnemyTerritoryPatrol; // size = 0x9C
typedef union {
EnemyTerritoryWander wander;
EnemyTerritoryPatrol patrol;
char PADDING[0xC0];
} EnemyTerritory; // size = 0xC0
Various meta work and some decomp (#184) * some * DeadUnkTexturePanFunc * DeadUnkTexturePanFunc2 * move guOrthoF to os * up * git subrepo pull tools/splat subrepo: subdir: "tools/splat" merged: "ae2cce951d" upstream: origin: "https://github.com/ethteck/splat.git" branch: "master" commit: "ae2cce951d" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo" commit: "2f68596" * Updating bin dir * git subrepo pull tools/splat subrepo: subdir: "tools/splat" merged: "5517f520e4" upstream: origin: "https://github.com/ethteck/splat.git" branch: "master" commit: "5517f520e4" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo" commit: "2f68596" * git subrepo pull tools/splat subrepo: subdir: "tools/splat" merged: "fe48dc3b3a" upstream: origin: "https://github.com/ethteck/splat.git" branch: "master" commit: "fe48dc3b3a" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo" commit: "2f68596" * revert garbage * :OK: * git subrepo pull tools/splat subrepo: subdir: "tools/splat" merged: "8c86e4b95b" upstream: origin: "https://github.com/ethteck/splat.git" branch: "master" commit: "8c86e4b95b" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo" commit: "2f68596" * data migration * 3 * .rodata migration and a buncha funcs * 2 mo * some decomp, a file boundary fix * cleanup * UnkNpaAIFunc13s * Update symbol_addrs * remove sublist * deleted asm * data fix * fix data * wtf?! * git subrepo pull tools/splat subrepo: subdir: "tools/splat" merged: "88ce6b44a6" upstream: origin: "https://github.com/ethteck/splat.git" branch: "master" commit: "88ce6b44a6" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo" commit: "2f68596" * symbol_addrs update * blah * PR comments
2021-02-16 11:32:34 +01:00
typedef struct Enemy {
/* 0x00 */ s32 flags;
2020-11-02 08:07:02 +01:00
/* 0x04 */ s8 encounterIndex;
/* 0x05 */ s8 encountered;
/* 0x06 */ u8 scriptGroup; /* scripts launched for this npc controller will be assigned this group */
/* 0x07 */ s8 unk_07;
/* 0x08 */ s16 npcID;
/* 0x0A */ s16 spawnPos[3];
/* 0x10 */ Vec3s unk_10;
/* 0x16 */ char unk_16[2];
2020-10-20 08:33:40 +02:00
/* 0x18 */ struct NpcSettings* npcSettings;
/* 0x1C */ Bytecode* initBytecode;
/* 0x20 */ Bytecode* interactBytecode;
/* 0x24 */ Bytecode* aiBytecode;
/* 0x28 */ Bytecode* hitBytecode;
/* 0x2C */ Bytecode* auxBytecode;
/* 0x30 */ Bytecode* defeatBytecode;
/* 0x34 */ struct ScriptInstance* initScript;
/* 0x38 */ struct ScriptInstance* interactScript;
/* 0x3C */ struct ScriptInstance* aiScript;
/* 0x40 */ struct ScriptInstance* hitScript;
/* 0x44 */ struct ScriptInstance* auxScript;
/* 0x48 */ struct ScriptInstance* defeatScript;
2020-10-20 08:33:40 +02:00
/* 0x4C */ ScriptID initScriptID;
/* 0x50 */ ScriptID interactScriptID;
/* 0x54 */ ScriptID aiScriptID;
/* 0x58 */ ScriptID hitScriptID;
/* 0x5C */ ScriptID auxScriptID;
/* 0x60 */ ScriptID defeatScriptID;
/* 0x64 */ char unk_64[8];
/* 0x6C */ s32 varTable[16];
2020-11-20 15:55:56 +01:00
/* 0xAC */ char unk_AC[4];
/* 0xB0 */ s32 unk_B0;
Various meta work and some decomp (#184) * some * DeadUnkTexturePanFunc * DeadUnkTexturePanFunc2 * move guOrthoF to os * up * git subrepo pull tools/splat subrepo: subdir: "tools/splat" merged: "ae2cce951d" upstream: origin: "https://github.com/ethteck/splat.git" branch: "master" commit: "ae2cce951d" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo" commit: "2f68596" * Updating bin dir * git subrepo pull tools/splat subrepo: subdir: "tools/splat" merged: "5517f520e4" upstream: origin: "https://github.com/ethteck/splat.git" branch: "master" commit: "5517f520e4" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo" commit: "2f68596" * git subrepo pull tools/splat subrepo: subdir: "tools/splat" merged: "fe48dc3b3a" upstream: origin: "https://github.com/ethteck/splat.git" branch: "master" commit: "fe48dc3b3a" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo" commit: "2f68596" * revert garbage * :OK: * git subrepo pull tools/splat subrepo: subdir: "tools/splat" merged: "8c86e4b95b" upstream: origin: "https://github.com/ethteck/splat.git" branch: "master" commit: "8c86e4b95b" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo" commit: "2f68596" * data migration * 3 * .rodata migration and a buncha funcs * 2 mo * some decomp, a file boundary fix * cleanup * UnkNpaAIFunc13s * Update symbol_addrs * remove sublist * deleted asm * data fix * fix data * wtf?! * git subrepo pull tools/splat subrepo: subdir: "tools/splat" merged: "88ce6b44a6" upstream: origin: "https://github.com/ethteck/splat.git" branch: "master" commit: "88ce6b44a6" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo" commit: "2f68596" * symbol_addrs update * blah * PR comments
2021-02-16 11:32:34 +01:00
/* 0xB4 */ s8 unk_B4;
/* 0xB5 */ s8 unk_B5;
/* 0xB6 */ char unk_B6[2];
/* 0xB8 */ s32 unkSettings24;
/* 0xBC */ char unk_BC[8];
/* 0xC4 */ s32 unk_C4;
/* 0xC8 */ s32 unk_C8;
/* 0xCC */ s32* animList;
Various meta work and some decomp (#184) * some * DeadUnkTexturePanFunc * DeadUnkTexturePanFunc2 * move guOrthoF to os * up * git subrepo pull tools/splat subrepo: subdir: "tools/splat" merged: "ae2cce951d" upstream: origin: "https://github.com/ethteck/splat.git" branch: "master" commit: "ae2cce951d" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo" commit: "2f68596" * Updating bin dir * git subrepo pull tools/splat subrepo: subdir: "tools/splat" merged: "5517f520e4" upstream: origin: "https://github.com/ethteck/splat.git" branch: "master" commit: "5517f520e4" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo" commit: "2f68596" * git subrepo pull tools/splat subrepo: subdir: "tools/splat" merged: "fe48dc3b3a" upstream: origin: "https://github.com/ethteck/splat.git" branch: "master" commit: "fe48dc3b3a" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo" commit: "2f68596" * revert garbage * :OK: * git subrepo pull tools/splat subrepo: subdir: "tools/splat" merged: "8c86e4b95b" upstream: origin: "https://github.com/ethteck/splat.git" branch: "master" commit: "8c86e4b95b" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo" commit: "2f68596" * data migration * 3 * .rodata migration and a buncha funcs * 2 mo * some decomp, a file boundary fix * cleanup * UnkNpaAIFunc13s * Update symbol_addrs * remove sublist * deleted asm * data fix * fix data * wtf?! * git subrepo pull tools/splat subrepo: subdir: "tools/splat" merged: "88ce6b44a6" upstream: origin: "https://github.com/ethteck/splat.git" branch: "master" commit: "88ce6b44a6" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo" commit: "2f68596" * symbol_addrs update * blah * PR comments
2021-02-16 11:32:34 +01:00
/* 0xD0 */ EnemyTerritory* territory;
/* 0xD4 */ s16* dropTables;
/* 0xD8 */ u32 tattleString;
/* 0xDC */ char unk_DC[20];
} Enemy; // size = 0xF0
2020-12-27 13:11:14 +01:00
/// Zero-terminated.
typedef struct {
/* 0x00 */ s32 npcCount;
/* 0x04 */ StaticNpc* npcs;
2020-12-27 13:11:14 +01:00
/* 0x08 */ BattleID battle;
} NpcGroupList[]; // size = 0x0C
2020-12-27 13:11:14 +01:00
#define NPC_GROUP(npcs, battle) { sizeof(npcs) / sizeof(StaticNpc), &npcs, battle }
2020-10-20 05:29:42 +02:00
2021-03-29 09:34:39 +02:00
Enemy* get_enemy(NpcID npcId);
2020-11-22 02:31:57 +01:00
MapConfig* get_current_map_header(void);
s32 func_800490B4(EnemyTerritoryThing* arg0, Enemy* arg1, f32 arg2, f32 arg3, s32 arg4);
2020-11-22 21:47:15 +01:00
/// Zero-terminated.
2020-10-30 18:43:12 +01:00
Area gAreas[29];
2020-10-30 18:43:12 +01:00
/// Lists the songs that are forced to use the variation determined by `map.songVariation & 1`.
/// @see bgm_get_map_default_variation
extern SongID gSongsUsingVariationFlag[6];
2020-11-27 07:14:28 +01:00
extern s16 D_8014F738;
#endif