From 67d0f32c8f049499f5bdb977cf9f4cbc1f60e296 Mon Sep 17 00:00:00 2001 From: Alex Bates <16batesa@gmail.com> Date: Sun, 27 Dec 2020 12:11:14 +0000 Subject: [PATCH] match battle/area_kmr_part_1/battles.c --- include/map.h | 6 +- include/types.h | 4 +- src/battle/actor/goomba.h | 7 +++ src/battle/actor/paragoomba.h | 7 +++ src/battle/actor/spiked_goomba.h | 7 +++ src/battle/area_kmr_part_1/battles.c | 94 ++++++++++++++++++++++++++++ src/battle/battle.c | 90 +++++++++++++------------- src/battle/battle.h | 48 ++++++++++++++ src/world/area_kmr/kmr_12/events.c | 4 +- tools/splat.yaml | 11 +++- 10 files changed, 225 insertions(+), 53 deletions(-) create mode 100644 src/battle/actor/goomba.h create mode 100644 src/battle/actor/paragoomba.h create mode 100644 src/battle/actor/spiked_goomba.h create mode 100644 src/battle/area_kmr_part_1/battles.c create mode 100644 src/battle/battle.h diff --git a/include/map.h b/include/map.h index 3c1708e0ad..5dcf4b579f 100644 --- a/include/map.h +++ b/include/map.h @@ -237,14 +237,14 @@ typedef struct Enemy { /* 0xDC */ char unk_DC[20]; } Enemy; // size = 0xF0 +/// Zero-terminated. typedef struct { /* 0x00 */ s32 npcCount; /* 0x04 */ StaticNpc* npcs; - /* 0x08 */ FormationID formationID; + /* 0x08 */ BattleID battle; } NpcGroupList[]; // size = 0x0C -#define NPC_GROUP(npcs, formationID) { sizeof(npcs) / sizeof(StaticNpc), &npcs, formationID } -#define NPC_GROUP_LIST_END() { 0, 0, 0 } +#define NPC_GROUP(npcs, battle) { sizeof(npcs) / sizeof(StaticNpc), &npcs, battle } Enemy* get_enemy(NpcId npcId); MapConfig* get_current_map_header(void); diff --git a/include/types.h b/include/types.h index 9721241a66..883df844b3 100644 --- a/include/types.h +++ b/include/types.h @@ -10,8 +10,8 @@ #define UNK_FUN_PTR(name) void(*name)(void) #define UNK_ARGS -typedef s32 FormationID; -#define FORMATION_ID(section, stage, index) ((section << 16) + (stage << 8) + index) +typedef s32 BattleID; +#define BATTLE_ID(area, stage, index) ((area << 16) + (stage << 8) + index) typedef s32 NpcAnimID; #define NPC_ANIM(sprite, palette, anim) ((_NPC_SPRITE_##sprite << 16) + (_NPC_PALETTE_##sprite##_##palette << 8) + _NPC_ANIM_##sprite##_##anim) diff --git a/src/battle/actor/goomba.h b/src/battle/actor/goomba.h new file mode 100644 index 0000000000..04e018590b --- /dev/null +++ b/src/battle/actor/goomba.h @@ -0,0 +1,7 @@ +#ifndef _BATTLE_ACTOR_GOOMBA_ +#define _BATTLE_ACTOR_GOOMBA_ + +// TODO: disasm +#define goomba 0x802196EC + +#endif diff --git a/src/battle/actor/paragoomba.h b/src/battle/actor/paragoomba.h new file mode 100644 index 0000000000..0f90efadec --- /dev/null +++ b/src/battle/actor/paragoomba.h @@ -0,0 +1,7 @@ +#ifndef _BATTLE_ACTOR_PARAGOOMBA_ +#define _BATTLE_ACTOR_PARAGOOMBA_ + +// TODO: disasm +#define paragoomba 0x8021CD00 + +#endif diff --git a/src/battle/actor/spiked_goomba.h b/src/battle/actor/spiked_goomba.h new file mode 100644 index 0000000000..0c1b89f363 --- /dev/null +++ b/src/battle/actor/spiked_goomba.h @@ -0,0 +1,7 @@ +#ifndef _BATTLE_ACTOR_SPIKED_GOOMBA_ +#define _BATTLE_ACTOR_SPIKED_GOOMBA_ + +// TODO: disasm +#define spikedGoomba 0x8021B0AC + +#endif diff --git a/src/battle/area_kmr_part_1/battles.c b/src/battle/area_kmr_part_1/battles.c new file mode 100644 index 0000000000..46c4e894de --- /dev/null +++ b/src/battle/area_kmr_part_1/battles.c @@ -0,0 +1,94 @@ +#include "common.h" +#include "battle/battle.h" + +#include "battle/actor/goomba.h" +#include "battle/actor/paragoomba.h" +#include "battle/actor/spiked_goomba.h" + +Formation formation0 = { + { goomba, .position = 1, .priority = 10 }, +}; + +Formation formation1 = { + { goomba, .position = 1, .priority = 10 }, + { goomba, .position = 2, .priority = 9 }, +}; + +Formation formation2 = { + { goomba, .position = 0, .priority = 10 }, + { goomba, .position = 1, .priority = 9 }, + { goomba, .position = 2, .priority = 8 }, +}; + +Formation formation3 = { + { goomba, .position = 1, .priority = 10 }, + { paragoomba, .position = 6, .priority = 9 }, +}; + +Formation formation4 = { + { goomba, .position = 0, .priority = 10 }, + { goomba, .position = 1, .priority = 9 }, + { goomba, .position = 2, .priority = 8 }, + { goomba, .position = 3, .priority = 7 }, +}; + +Formation formation5 = { + { goomba, .position = 1, .priority = 10 }, + { spikedGoomba, .position = 2, .priority = 9 }, +}; + +Formation formation6 = { + { goomba, .position = 0, .priority = 10 }, + { paragoomba, .position = 5, .priority = 9 }, + { goomba, .position = 2, .priority = 8 }, + { paragoomba, .position = 7, .priority = 7 }, +}; + +Formation formation7 = { + { paragoomba, .position = 5, .priority = 10 }, +}; + +Formation formation8 = { + { paragoomba, .position = 5, .priority = 10 }, + { paragoomba, .position = 6, .priority = 9 }, +}; + +Formation formation9 = { + { paragoomba, .position = 4, .priority = 10 }, + { paragoomba, .position = 5, .priority = 9 }, + { paragoomba, .position = 6, .priority = 8 }, +}; + +Formation formation10 = { + { spikedGoomba, .position = 1, .priority = 10 }, +}; + +Formation formation11 = { + { spikedGoomba, .position = 1, .priority = 10 }, + { goomba, .position = 2, .priority = 9 }, +}; + +BattleList area_kmr_part_1_battles = { + BATTLE("クリボー", formation0, 0x8022066C), + BATTLE("クリボーx2", formation1, 0x8022066C), + BATTLE("クリボーx3", formation2, 0x8022066C), + BATTLE("クリボー、パタクリボー", formation3, 0x8022066C), + BATTLE("クリボーx4", formation4, 0x8022066C), + BATTLE("クリボー,トゲクリボー", formation5, 0x8022066C), + BATTLE("クリボー,パタクリボー,クリボー,パタクリボー", formation6, 0x8022066C), + BATTLE("パタクリボー", formation7, 0x8022066C), + BATTLE("パタクリボーx2", formation8, 0x8022066C), + BATTLE("パタクリボーx3", formation9, 0x8022066C), + BATTLE("トゲクリボー", formation10, 0x8022066C), + BATTLE("トゲクリボー、クリボー", formation11, 0x8022066C), + {}, +}; + +StageList area_kmr_part_1_stages = { + { "kmr_02", 0x8021FDD0 }, + { "kmr_03", 0x8022021C }, + { "kmr_04", 0x8022066C }, + { "kmr_05", 0x80220A78 }, + { "kmr_06", 0x80220ECC }, + {}, +}; diff --git a/src/battle/battle.c b/src/battle/battle.c index fb5c475719..071c621443 100644 --- a/src/battle/battle.c +++ b/src/battle/battle.c @@ -1,13 +1,14 @@ #include "common.h" #include "ld_addrs.h" +#include "battle.h" typedef struct BattleArea { /* 0x00 */ char* name; ///< JP debug name. /* 0x04 */ s32 dmaStart; /* 0x08 */ s32 dmaEnd; /* 0x0C */ void* dmaDest; - /* 0x10 */ void* formations; - /* 0x14 */ void* stages; + /* 0x10 */ BattleList* battles; + /* 0x14 */ StageList* stages; /* 0x18 */ s32 unused_18; /* 0x1C */ void* dmaTable; } BattleArea; // size = 0x20 @@ -84,246 +85,249 @@ const s32 rodata_75240[] = { /* 0x75630 */ 0x08080808, 0x08080808, 0x08080808, 0x08080808, }; +BattleList area_kmr_part_1_battles; +StageList area_kmr_part_1_stages; + BattleArea gBattleAreas[0x30] = { { AREA(area_kmr_part_1), .name = "エリア KMR その1", - .formations = 0x802194D4, - .stages = 0x802195D8, + .battles = area_kmr_part_1_battles, + .stages = area_kmr_part_1_stages, }, { AREA(area_kmr_part_2), .name = "エリア KMR その2", - .formations = 0x80219840, + .battles = 0x80219840, .stages = 0x8021987C, }, { AREA(area_kmr_part_3), .name = "エリア KMR その3", - .formations = 0x8021A2AC, + .battles = 0x8021A2AC, .stages = 0x8021A360, }, { AREA(area_mac), .name = "エリア MAC", - .formations = 0x80232A5C, + .battles = 0x80232A5C, .stages = 0x80232AD4, }, { AREA(area_hos), .name = "エリア HOS", - .formations = 0x80225F24, + .battles = 0x80225F24, .stages = 0x80225F88, }, { AREA(area_nok), .name = "エリア NOK", - .formations = 0x80219520, + .battles = 0x80219520, .stages = 0x80219728, }, { AREA(area_trd_part_1), .name = "エリア TRD その1", - .formations = 0x80218CB0, + .battles = 0x80218CB0, .stages = 0x80218EE0, }, { AREA(area_trd_part_2), .name = "エリア TRD その2", - .formations = 0x8021A5DC, + .battles = 0x8021A5DC, .stages = 0x8021A604, }, { AREA(area_trd_part_3), .name = "エリア TRD その3", - .formations = 0x8021823C, + .battles = 0x8021823C, .stages = 0x80218264, }, { AREA(area_iwa), .name = "エリア IWA", - .formations = 0x802185B8, + .battles = 0x802185B8, .stages = 0x802186E4, }, { AREA(area_sbk), .name = "エリア SBK", - .formations = 0x8021FE80, + .battles = 0x8021FE80, .stages = 0x8021FFE8, }, { AREA(area_isk_part_1), .name = "エリア ISK その1", - .formations = 0x80224700, + .battles = 0x80224700, .stages = 0x802248A4, }, { AREA(area_isk_part_2), .name = "エリア ISK その2", - .formations = 0x80220448, + .battles = 0x80220448, .stages = 0x80220470, }, { AREA(area_mim), .name = "エリア MIM", - .formations = 0x8021EA70, + .battles = 0x8021EA70, .stages = 0x8021EBEC, }, { AREA(area_arn), .name = "エリア ARN", - .formations = 0x80228110, + .battles = 0x80228110, .stages = 0x80228278, }, { AREA(area_dgb), .name = "エリア DGB", - .formations = 0x8021B38C, + .battles = 0x8021B38C, .stages = 0x8021B418, }, { AREA(area_omo), .name = "エリア OMO", - .formations = 0x80230730, + .battles = 0x80230730, .stages = 0x80230AC8, }, { AREA(area_omo2), .name = "エリア OMO2", - .formations = 0x8022FBF4, + .battles = 0x8022FBF4, .stages = 0x8022FC1C, }, { AREA(area_omo3), .name = "エリア OMO3", - .formations = 0x8022EA2C, + .battles = 0x8022EA2C, .stages = 0x8022EB1C, }, { AREA(area_kgr), .name = "エリア KGR", - .formations = 0x8021D5FC, + .battles = 0x8021D5FC, .stages = 0x8021D624, }, { AREA(area_jan), .name = "エリア JAN", - .formations = 0x80228AF8, + .battles = 0x80228AF8, .stages = 0x80228C60, }, { AREA(area_jan2), .name = "エリア JAN2", - .formations = 0x8021F6C8, + .battles = 0x8021F6C8, .stages = 0x8021F72C, }, { AREA(area_kzn), .name = "エリア KZN", - .formations = 0x80229E74, + .battles = 0x80229E74, .stages = 0x8022A02C, }, { AREA(area_kzn2), .name = "エリア KZN2", - .formations = 0x8022AA08, + .battles = 0x8022AA08, .stages = 0x8022AA44, .dmaTable = 0x8022AA84, }, { AREA(area_flo), .name = "エリア FLO", - .formations = 0x80234574, + .battles = 0x80234574, .stages = 0x8023486C, }, { AREA(area_flo2), .name = "エリア FLO2", - .formations = 0x802356FC, + .battles = 0x802356FC, .stages = 0x80235788, }, { AREA(area_tik), .name = "エリア TIK", - .formations = 0x802340B4, + .battles = 0x802340B4, .stages = 0x802342BC, }, { AREA(area_tik2), .name = "エリア TIK2", - .formations = 0x80227A90, + .battles = 0x80227A90, .stages = 0x80227AE0, }, { AREA(area_tik3), .name = "エリア TIK3", - .formations = 0x802232E8, + .battles = 0x802232E8, .stages = 0x8022334C, }, { AREA(area_sam), .name = "エリア SAM", - .formations = 0x80231164, + .battles = 0x80231164, .stages = 0x80231290, }, { AREA(area_sam2), .name = "エリア SAM2", - .formations = 0x802234F0, + .battles = 0x802234F0, .stages = 0x8022352C, }, { AREA(area_pra), .name = "エリア PRA", - .formations = 0x8022F4D4, + .battles = 0x8022F4D4, .stages = 0x8022F614, }, { AREA(area_pra2), .name = "エリア PRA2", - .formations = 0x802215A0, + .battles = 0x802215A0, .stages = 0x802215C8, }, { AREA(area_pra3), .name = "エリア PRA3", - .formations = 0x80232888, + .battles = 0x80232888, .stages = 0x8023298C, }, { AREA(area_kpa), .name = "エリア KPA", - .formations = 0x80231A64, + .battles = 0x80231A64, .stages = 0x80231ED8, }, { AREA(area_kpa2), .name = "エリア KPA2", - .formations = 0x802346A8, + .battles = 0x802346A8, .stages = 0x80234720, }, { AREA(area_kpa3), .name = "エリア KPA3", - .formations = 0x8022839C, + .battles = 0x8022839C, .stages = 0x802283EC, }, { AREA(area_kpa4), .name = "エリア KPA4", - .formations = 0x80227910, + .battles = 0x80227910, .stages = 0x80227988, }, { AREA(area_kkj), .name = "エリア KKJ", - .formations = 0x802185BC, + .battles = 0x802185BC, .stages = 0x802185E4, }, { AREA(area_dig), .name = "エリア DIG", - .formations = 0x8022A7C4, + .battles = 0x8022A7C4, .stages = 0x8022A83C, }, {}, diff --git a/src/battle/battle.h b/src/battle/battle.h new file mode 100644 index 0000000000..2d97adfa11 --- /dev/null +++ b/src/battle/battle.h @@ -0,0 +1,48 @@ +#ifndef _BATTLE_BATTLE_H_ +#define _BATTLE_BATTLE_H_ + +#include "common.h" + +typedef struct Stage { + /* 0x00 */ const char* texture; + /* 0x04 */ const char* shape; + /* 0x08 */ const char* hit; + /* 0x0C */ Bytecode* preBattle; + /* 0x10 */ Bytecode* postBattle; + /* 0x14 */ const char* bg; + /* 0x18 */ s32 unk_18; + /* 0x1C */ s32 unk_1C; + /* 0x20 */ s32 unk_20; + /* 0x24 */ s32 unk_24; +} Stage; // size = 0x28 + +/// Zero-terminated. +typedef struct StageListRow { + /* 0x00 */ const char* id; ///< Map ID. + /* 0x04 */ Stage* stage; +} StageList[]; // size = 0x08 * n + +typedef struct FormationRow { + /* 0x00 */ StaticActorData* actor; + /* 0x04 */ s32 position; ///< Home position. May also be a `Vector3*`. + /* 0x08 */ s32 priority; ///< Actors with higher priority values take their turn first. + /* 0x0C */ s32 var0; + /* 0x10 */ s32 var1; + /* 0x14 */ s32 var2; + /* 0x18 */ s32 var3; +} Formation[]; // size = 0x1C * n + +/// Zero-terminated. +typedef struct Battle { + /* 0x00 */ const char* name; ///< Debug SJIS name. + /* 0x04 */ s32 formationSize; + /* 0x08 */ Formation* formation; + /* 0x0C */ Stage* stage; + /* 0x10 */ s32 unk_10; +} BattleList[]; // size = 0x14 * n + +#define BATTLE(name, formation, stage) { name, ARRAY_COUNT(formation), formation, stage } + +// TODO: enum for home position (0..3 are floor, 4..7 are air, etc.) + +#endif diff --git a/src/world/area_kmr/kmr_12/events.c b/src/world/area_kmr/kmr_12/events.c index 44e6095e23..405ec0af16 100644 --- a/src/world/area_kmr/kmr_12/events.c +++ b/src/world/area_kmr/kmr_12/events.c @@ -187,8 +187,8 @@ StaticNpc M(goombaNpc) = { }; NpcGroupList M(npcGroupList) = { - NPC_GROUP(M(goombaNpc), FORMATION_ID(1, 0, 3)), - NPC_GROUP_LIST_END(), + NPC_GROUP(M(goombaNpc), BATTLE_ID(1, 0, 3)), + {}, }; Script M(ReadEastSign) = SCRIPT({ diff --git a/tools/splat.yaml b/tools/splat.yaml index 0739d1ba20..ecb212edb6 100644 --- a/tools/splat.yaml +++ b/tools/splat.yaml @@ -907,8 +907,10 @@ segments: overlay: True files: - [0x4309A0, c] - - [0x431B80, bin] - - [0x4398A0, bin] + - [0x431B80, .data, battle/area_kmr_part_1/battles] + - [0x431FB0, bin, battle/area_kmr_part_1/goomba] + - [0x4398A0, .rodata, battle/area_kmr_part_1/battles] + - [0x439984, bin] - name: battle/area_kmr_part_2/ type: code start: 0x439A90 @@ -978,7 +980,10 @@ segments: vram: 0x80218000 overlay: True files: - - [0x4DA5E0, bin] + - [0x4DA5E0, bin] # 1 func + - [0x4DA6B0, bin] # 2 funcs + - [0x4DA860, bin] # data + - [0x4E25E0, bin] # rodata - name: battle/area_isk_part_1/ type: code start: 0x4E2740