Appetizer sampler (#547)

* 2 fold funcs

* func_8013B1B0

* cleanup & naming

* more formatting

* cleanup

* progress & filemenu stuff

* 2

* func_8013CFA8

* fold_load_gfx (thanks Wiseguy)

* update_encounters_pre_battle

* 3 mdl funcs

* more model funcs

* cd180 funcs

* progrezz

* 3 cam funcs

* more

* 1 more

* eob30 progress

* sfx_play_sound_at_position & sound enum cleanup

* cleanup

* cleanup2

* PR comments
This commit is contained in:
Ethan Roseman 2021-12-13 04:27:28 -05:00 committed by GitHub
parent c719faf847
commit 7230c62545
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
134 changed files with 3760 additions and 8006 deletions

View File

@ -2,6 +2,7 @@
#define _COMMON_H_
#include "ultra64.h"
#include "gbi_custom.h"
#include "types.h"
#include "common_structs.h"
#include "functions.h"

View File

@ -388,8 +388,7 @@ typedef struct Entity {
/* 0x54 */ Vec3f scale;
/* 0x60 */ Vec3f rotation;
/* 0x6C */ f32 shadowPosY;
/* 0x70 */ Matrix4f* inverseTransformMatrix; /* world-to-local */
/* 0x74 */ char unk_74[60];
/* 0x70 */ Matrix4f inverseTransformMatrix; /* world-to-local */
/* 0xB0 */ float effectiveSize;
/* 0xB4 */ char unk_B4[4];
/* 0xB8 */ Mtx transformMatrix;
@ -421,7 +420,7 @@ typedef struct StaticEntityData {
typedef struct MusicSettings {
/* 0x00 */ u16 flags;
/* 0x02 */ u16 unk_02;
/* 0x02 */ s16 unk_02;
/* 0x04 */ s32 fadeOutTime;
/* 0x08 */ s32 fadeInTime;
/* 0x0C */ s16 unk_0C;
@ -558,9 +557,9 @@ typedef struct Camera {
/* 0x03A */ char unk_3A[2];
/* 0x03C */ Vec3f lookAt_eye;
/* 0x048 */ Vec3f lookAt_obj;
/* 0x054 */ f32 unk_54;
/* 0x058 */ f32 unk_58;
/* 0x05C */ f32 unk_5C;
/* 0x054 */ f32 unk_54; // x-related
/* 0x058 */ f32 unk_58; // y-related
/* 0x05C */ f32 unk_5C; // z-related
/* 0x060 */ Vec3f targetPos;
/* 0x06C */ f32 currentYaw;
/* 0x070 */ f32 unk_70;
@ -1502,8 +1501,8 @@ typedef struct ShopOwner {
} ShopOwner;
typedef struct ShopItemLocation {
/* 0x0 */ s16 posModelID;
/* 0x2 */ s16 triggerColliderID;
/* 0x0 */ u16 posModelID;
/* 0x2 */ u16 triggerColliderID;
} ShopItemLocation; // size = 0x4
typedef struct StaticInventoryItem {
@ -1560,7 +1559,7 @@ typedef struct Shop {
typedef struct Encounter {
/* 0x00 */ s32 count;
/* 0x04 */ struct Enemy* enemy[16];
/* 0x44 */ u16 battle;
/* 0x44 */ s16 battle;
/* 0x46 */ s16 stage;
/* 0x48 */ s16 encounterID;
/* 0x4A */ char unk_4C[0x12];
@ -1873,7 +1872,10 @@ typedef struct EncounterStatus {
/* 0x094 */ s32 unk_94;
/* 0x098 */ s32 fadeOutAccel;
/* 0x09C */ s32 battleStartCountdown;
/* 0x0A0 */ char unk_A0[16];
/* 0x0A0 */ s8 unk_A0;
/* 0x0A1 */ char unk_A1[0x1];
/* 0x0A2 */ s16 unk_A2;
/* 0x0A4 */ char unk_A4[0xC];
/* 0x0B0 */ s32 defeatFlags[60][12];
/* 0xFB0 */ s16 recentMaps[2];
/* 0xFB4 */ char unk_FB4[4];
@ -1938,10 +1940,15 @@ typedef struct PauseMapSpace {
} PauseMapSpace; // size = 0x14
typedef struct MenuPanel {
/* 0x00 */ u8 initialized; //?
/* 0x01 */ s8 col;
/* 0x02 */ s8 row;
/* 0x03 */ u8 selected; // usually set to the current value from gridData
/* 0x00 */ union {
/* */ s32 s;
/* */ struct {
/* 0x00 */ u8 initialized;
/* 0x01 */ s8 col;
/* 0x02 */ s8 row;
/* 0x03 */ u8 selected; // usually set to the current value from gridData
/* */ } c;
/* */ } unk_00;
/* 0x04 */ s8 page; // filemenu: 0 = select, 1 = delete, 3 = copy from, 4 = copy to, all else = save
/* 0x05 */ s8 numCols;
/* 0x06 */ s8 numRows;
@ -2269,4 +2276,32 @@ typedef struct struct8015A578 {
/* 0x08 */ f32 unk_08;
} struct8015A578; // size = 0x0C
typedef struct SaveMetadata {
/* 0x00 */ s32 unk_00;
/* 0x04 */ u8 unk_04;
/* 0x05 */ char unk_05[0x1];
/* 0x06 */ s8 unk_06;
/* 0x07 */ s8 unk_07[8];
/* 0x0F */ char unk_0F[0x1];
/* 0x10 */ s32 unk_10;
/* 0x14 */ s32 unk_14;
} SaveMetadata; // size = 0x18
typedef struct SpriteShadingLightSource {
/* 0x00 */ s8 flags;
/* 0x01 */ s8 rgb[3];
/* 0x04 */ Vec3f pos;
/* 0x10 */ f32 falloff;
/* 0x14 */ s8 unk_14;
/* 0x15 */ char unk_15[0x3];
} SpriteShadingLightSource; // size = 0x18
typedef struct SpriteShadingProfile {
/* 0x00 */ s16 flags;
/* 0x02 */ char unk_02[0x2];
/* 0x04 */ SpriteShadingLightSource sources[7];
/* 0xAC */ s8 ambientColor[3];
/* 0xAF */ s8 ambientPower; // ?
} SpriteShadingProfile; // size = 0xB0
#endif

View File

@ -480,18 +480,18 @@ enum Easings {
};
enum SoundIDs {
SOUND_UNKNOWN_0 = 0x00000000,
SOUND_0 = 0x00000000,
SOUND_MENU_BADGE_EQUIP = 0x00000005,
SOUND_MENU_BADGE_UNEQUIP = 0x00000006,
SOUND_UNKNOWN_D = 0x0000000D,
SOUND_UNKNOWN_E = 0x0000000E,
SOUND_UNKNOWN_43 = 0x00000043,
SOUND_D = 0x0000000D,
SOUND_E = 0x0000000E,
SOUND_43 = 0x00000043,
SOUND_JR_TROOPA_SPLASH = 0x00000045,
SOUND_JR_TROOPA_SWIM = 0x00000046,
SOUND_BOO_SPOOK = 0x00000047,
SOUND_UNKNOWN_52 = 0x00000052,
SOUND_UNKNOWN_A2 = 0x000000A2,
SOUND_UNKNOWN_B4 = 0x000000B4,
SOUND_52 = 0x00000052,
SOUND_A2 = 0x000000A2,
SOUND_B4 = 0x000000B4,
SOUND_BOO_VANISH = 0x000000C1,
SOUND_BOO_APPEAR = 0x000000C3,
SOUND_MENU_OPEN = 0x000000C5,
@ -516,12 +516,12 @@ enum SoundIDs {
SOUND_LAND = 0x0000014B,
SOUND_HIT_BLOCK = 0x0000014E,
SOUND_SEARCH_BUSH = 0x00000153,
SOUND_UNKNOWN_162 = 0x00000162,
SOUND_162 = 0x00000162,
SOUND_SMASH_GOOMNUT_TREE = 0x00000165,
SOUND_UNKNOWN_167 = 0x00000167,
SOUND_UNKNOWN_172 = 0x00000172,
SOUND_UNKNOWN_17B = 0x0000017B,
SOUND_UNKNOWN_194 = 0x00000194,
SOUND_167 = 0x00000167,
SOUND_172 = 0x00000172,
SOUND_17B = 0x0000017B,
SOUND_194 = 0x00000194,
SOUND_BASIC_DOOR_OPEN = 0x000001C1,
SOUND_BASIC_DOOR_CLOSE = 0x000001C2,
SOUND_METAL_DOOR_OPEN = 0x000001C3,
@ -532,49 +532,51 @@ enum SoundIDs {
SOUND_CREAKY_DOOR_CLOSE = 0x000001C8,
SOUND_METAL_GATE_OPEN = 0x000001C9,
SOUND_METAL_GATE_CLOSE = 0x000001CA,
SOUND_1CB = 0x000001CB,
SOUND_1CC = 0x000001CC,
SOUND_MENU_BADGE_ERROR = 0x0000021D,
SOUND_UNKNOWN_231 = 0x00000231,
SOUND_UNKNOWN_246 = 0x00000246,
SOUND_UNKNOWN_259 = 0x00000259,
SOUND_UNKNOWN_25A = 0x0000025A,
SOUND_UNKNOWN_25C = 0x0000025C,
SOUND_UNKNOWN_25D = 0x0000025D,
SOUND_UNKNOWN_262 = 0x00000262,
SOUND_UNKNOWN_282 = 0x00000282,
SOUND_231 = 0x00000231,
SOUND_246 = 0x00000246,
SOUND_259 = 0x00000259,
SOUND_25A = 0x0000025A,
SOUND_25C = 0x0000025C,
SOUND_25D = 0x0000025D,
SOUND_262 = 0x00000262,
SOUND_282 = 0x00000282,
SOUND_BOW_SPOOK = 0x00000291,
SOUND_UNKNOWN_295 = 0x00000295,
SOUND_295 = 0x00000295,
SOUND_UNUSED_2C1 = 0x000002C1,
SOUND_SMOKE_BURST = 0x000002CD,
SOUND_DAYZEE_SONG = 0x000002D7,
SOUND_POWER_UP = 0x000002D8,
SOUND_UNKNOWN_2F1 = 0x000002F1,
SOUND_UNKNOWN_2F6 = 0x000002F6,
SOUND_UNKNOWN_2F7 = 0x000002F7,
SOUND_2F1 = 0x000002F1,
SOUND_2F6 = 0x000002F6,
SOUND_2F7 = 0x000002F7,
SOUND_CLOSE_SHELL = 0x000002FF,
SOUND_SHY_GUY_SCREAMS1 = 0x0000030C,
SOUND_SHY_GUY_SCREAMS2 = 0x0000030D,
SOUND_SHY_GUY_SCREAMS3 = 0x0000030E,
SOUND_TOY_TANK_MOVE1 = 0x0000030F,
SOUND_TOY_TANK_MOVE2 = 0x00000310,
SOUND_UNKNOWN_315 = 0x00000315,
SOUND_315 = 0x00000315,
SOUND_MOLE_SURFACE = 0x00000321,
SOUND_MOLE_DIG = 0x00000322,
SOUND_MOLE_POP = 0x00000323,
SOUND_UNKNOWN_32E = 0x0000032E,
SOUND_UNKNOWN_359 = 0x00000359,
SOUND_UNKNOWN_361 = 0x00000361,
SOUND_UNKNOWN_362 = 0x00000362,
SOUND_UNKNOWN_363 = 0x00000363,
SOUND_UNKNOWN_364 = 0x00000364,
SOUND_UNKNOWN_365 = 0x00000365,
SOUND_UNKNOWN_366 = 0x00000366,
SOUND_UNKNOWN_367 = 0x00000367,
SOUND_UNKNOWN_368 = 0x00000368,
SOUND_UNKNOWN_369 = 0x00000369,
SOUND_UNKNOWN_375 = 0x00000375,
SOUND_UNKNOWN_376 = 0x00000376,
SOUND_UNKNOWN_377 = 0x00000377,
SOUND_UNKNOWN_379 = 0x00000379,
SOUND_32E = 0x0000032E,
SOUND_359 = 0x00000359,
SOUND_361 = 0x00000361,
SOUND_362 = 0x00000362,
SOUND_363 = 0x00000363,
SOUND_364 = 0x00000364,
SOUND_365 = 0x00000365,
SOUND_366 = 0x00000366,
SOUND_367 = 0x00000367,
SOUND_368 = 0x00000368,
SOUND_369 = 0x00000369,
SOUND_375 = 0x00000375,
SOUND_376 = 0x00000376,
SOUND_377 = 0x00000377,
SOUND_379 = 0x00000379,
SOUND_37A = 0x0000037A,
SOUND_ELECTRIC = 0x0000037B,
SOUND_GENERAL_WHISTLE = 0x00000395,
@ -584,42 +586,48 @@ enum SoundIDs {
SOUND_DEATH = 0x000003E5,
SOUND_BIG_POWER_UP = 0x000003E6,
SOUND_MOLE_THROW = 0x000003E8,
SOUND_UNKNOWN_3F3 = 0x000003F3,
SOUND_3F3 = 0x000003F3,
SOUND_THROW = 0x000003FA,
SOUND_UNKNOWN_759 = 0x00000759,
SOUND_UNKNOWN_2003 = 0x00002003,
SOUND_UNKNOWN_200D = 0x0000200D,
SOUND_759 = 0x00000759,
SOUND_2003 = 0x00002003,
SOUND_200D = 0x0000200D,
SOUND_BOW_VANISH = 0x0000200E,
SOUND_BOW_APPEAR = 0x0000200F,
SOUND_UNKNOWN_2010 = 0x00002010,
SOUND_2010 = 0x00002010,
SOUND_CANNON1 = 0x00002016,
SOUND_CANNON2 = 0x00002017,
SOUND_CANNON3 = 0x00002018,
SOUND_UNKNOWN_202C = 0x0000202C,
SOUND_UNKNOWN_202D = 0x0000202D,
SOUND_UNKNOWN_202E = 0x0000202E,
SOUND_UNKNOWN_202F = 0x0000202F,
SOUND_UNKNOWN_2030 = 0x00002030,
SOUND_202C = 0x0000202C,
SOUND_202D = 0x0000202D,
SOUND_202E = 0x0000202E,
SOUND_202F = 0x0000202F,
SOUND_2030 = 0x00002030,
SOUND_INFLICT_SLEEP = 0x00002031,
SOUND_INFLICT_STATUS = 0x00002032, //< Stop, poison, paralyze
SOUND_UNKNOWN_2038 = 0x00002038,
SOUND_UNKNOWN_2039 = 0x00002039,
SOUND_2038 = 0x00002038,
SOUND_2039 = 0x00002039,
SOUND_BOMB_BLAST = 0x00002076,
SOUND_JUMP_2081 = 0x00002081,
SOUND_JUMP_8BIT_MARIO = 0x00002082,
SOUND_UNKNOWN_208C = 0x0000208C,
SOUND_UNKNOWN_208D = 0x0000208D,
SOUND_UNKNOWN_208E = 0x0000208E,
SOUND_UNKNOWN_208F = 0x0000208F,
SOUND_UNKNOWN_2095 = 0x00002095,
SOUND_208C = 0x0000208C,
SOUND_208D = 0x0000208D,
SOUND_208E = 0x0000208E,
SOUND_208F = 0x0000208F,
SOUND_2095 = 0x00002095,
SOUND_20A3 = 0x000020A3,
SOUND_20A4 = 0x000020A4,
SOUND_SPELL_CAST1 = 0x000020D4,
SOUND_SPELL_CAST2 = 0x000020D5,
SOUND_SPELL_CAST3 = 0x000020D6,
SOUND_SPELL_CAST4 = 0x000020D7,
SOUND_SPELL_CAST5 = 0x000020D8,
SOUND_UNKNOWN_20F6 = 0x000020F6,
SOUND_UNKNOWN_2106 = 0x00002106,
SOUND_UNKNOWN_2107 = 0x00002107,
SOUND_20F6 = 0x000020F6,
SOUND_2106 = 0x00002106,
SOUND_2107 = 0x00002107,
SOUND_2111 = 0x00002111,
SOUND_2112 = 0x00002112,
SOUND_2113 = 0x00002113,
SOUND_2114 = 0x00002114,
};
enum Cams {
@ -2965,14 +2973,25 @@ enum MsgWindowStates {
};
enum FoldStateFlags {
FOLD_STATE_FLAGS_0 = 0x00000000,
FOLD_STATE_FLAGS_1 = 0x00000001,
FOLD_STATE_FLAGS_80 = 0x00000080,
FOLD_STATE_FLAGS_100 = 0x00000100,
FOLD_STATE_FLAGS_800 = 0x00000800,
FOLD_STATE_FLAGS_1000 = 0x00001000,
FOLD_STATE_FLAGS_4000 = 0x00004000,
FOLD_STATE_FLAGS_20000 = 0x00020000,
FOLD_STATE_FLAG_ENABLED = 0x00000001,
FOLD_STATE_FLAG_G_CULL_BACK = 0x00000002,
FOLD_STATE_FLAG_G_CULL_FRONT = 0x00000004,
FOLD_STATE_FLAG_10 = 0x00000010,
FOLD_STATE_FLAG_20 = 0x00000020,
FOLD_STATE_FLAG_40 = 0x00000040,
FOLD_STATE_FLAG_80 = 0x00000080,
FOLD_STATE_FLAG_100 = 0x00000100,
FOLD_STATE_FLAG_200 = 0x00000200,
FOLD_STATE_FLAG_400 = 0x00000400,
FOLD_STATE_FLAG_800 = 0x00000800,
FOLD_STATE_FLAG_1000 = 0x00001000,
FOLD_STATE_FLAG_2000 = 0x00002000,
FOLD_STATE_FLAG_4000 = 0x00004000,
FOLD_STATE_FLAG_8000 = 0x00008000,
FOLD_STATE_FLAG_10000 = 0x00010000,
FOLD_STATE_FLAG_20000 = 0x00020000,
FOLD_STATE_FLAG_80000 = 0x00080000,
FOLD_STATE_FLAG_100000 = 0x00100000,
};
#endif

View File

@ -47,7 +47,6 @@ void gravity_use_fall_parms(void);
f32 get_clamped_angle_diff(f32, f32);
s32 intro_logos_fade_out(s16 addAlpha);
void _render_transition_stencil(s32, f32, s32);
u32 get_entity_type(s32 arg0);
Entity* get_entity_by_index(s32 index);
s32 create_entity(StaticEntityData*, s32, s32, s32, s32, ...);
@ -77,6 +76,11 @@ void setup_pause_menu_tab(MenuWindowBP* bpArray, s32 arraySize);
s32 draw_ci_image_with_clipping(s32* raster, s32 width, s32 height, s32 fmt, s32 bitDepth, s32* palette, s16 posX,
s16 posY, u16 clipULx, u16 clipULy, u16 clipLRx, u16 clipRLy, u8 opacity);
// file menu stuff
void filemenu_set_cursor_goal_pos(s32 windowIndex, s32 posX, s32 posY);
s8* filemenu_get_menu_message(s32 idx);
void filemenu_draw_message(s8*, s32 posX, s32 posY, s32 alpha, s32 color, s32 flags);
// append gfx funcs
void func_80257B28(s32);
void func_8025595C(Actor*);
@ -95,7 +99,13 @@ s32 can_trigger_loading_zone(void);
void func_802667F0(s32, Actor*, f32, f32, f32);
void* general_heap_malloc(s32 size);
s32 general_heap_free(s32* data);
s32 general_heap_free(void* data);
s32 integer_log(s32 number, u32 base);
void set_battle_formation(s32);
void set_battle_stage(s32);
void load_battle(s32);
void entity_Shadow_init(Shadow* entity);
void entity_SaveBlock_idle(Entity* entity);
@ -292,10 +302,10 @@ void set_animation_rate(s32 actorID, s32 partIndex, f32 rate);
void func_8011B7C0(u16, s32, s32);
ModelAnimator* get_animator_by_index(s32 arg0);
void set_screen_overlay_params_front(u8, f32);
void set_screen_overlay_params_back(s32, f32);
void set_screen_overlay_params_back(u8, f32);
void set_screen_overlay_alpha(s32, f32);
void get_screen_overlay_params(s32, f32*, f32*);
s32 set_screen_overlay_color(s32, u8, u8, u8);
void get_screen_overlay_params(s32, u8*, f32*);
void set_screen_overlay_color(s32, u8, u8, u8);
void set_screen_overlay_center(s32, s32, s32, s32);
s32 rand_int(s32);
void sort_items(void);
@ -407,6 +417,7 @@ void add_xz_vec3f(Vec3f* vector, f32 speed, f32 angleDeg);
void play_movement_dust_effects(s32 var0, f32 xPos, f32 yPos, f32 zPos, f32 angleDeg);
void func_80138D88(s32, s32, s32, s32, f32);
void func_8013A4D0(void);
void btl_cam_set_target_pos(f32, f32, f32);
void deduct_current_move_fp(void);
@ -526,7 +537,7 @@ void* load_asset_by_name(const char* assetName, u32* decompressedSize);
void mdl_draw_hidden_panel_surface(Gfx** arg0, u16 treeIndex);
s32 func_8011CFBC(void);
s32 set_screen_overlay_center_worldpos(void);
void set_screen_overlay_center_worldpos(s32 idx, s32 posIdx, s32 x, s32 y, s32 z);
s32 mdl_get_next_texture_address(s32);
void draw_msg(s32 msgID, s32 posX, s32 posY, s32 opacity, s32 palette, u8 style);
void get_background_color_blend(u8* r, u8* g, u8* b, u8* a);

66
include/gbi_custom.h Normal file
View File

@ -0,0 +1,66 @@
#ifndef _GBI_CUSTOM_H_
#define _GBI_CUSTOM_H_
#include "ultra64.h"
#define gDPScrollMultiTile2_4b(pkt, timg, fmt, width, height, \
uls, ult, lrs, lrt, pal, \
cms, cmt, masks, maskt, shifts, shiftt,\
scrolls, scrollt) \
{ \
gDPSetTextureImage(pkt, fmt, G_IM_SIZ_8b, ((width)>>1), timg); \
gDPSetTile(pkt, fmt, G_IM_SIZ_8b, \
(((((lrs)-(uls)+1)>>1)+7)>>3), 0, \
G_TX_LOADTILE, 0 , cmt, maskt, shiftt, cms, masks, \
shifts); \
gDPLoadSync(pkt); \
gDPLoadTile( pkt, G_TX_LOADTILE, \
(uls)<<(G_TEXTURE_IMAGE_FRAC-1), \
(ult)<<(G_TEXTURE_IMAGE_FRAC), \
(lrs)<<(G_TEXTURE_IMAGE_FRAC-1), \
(lrt)<<(G_TEXTURE_IMAGE_FRAC)); \
gDPPipeSync(pkt); \
gDPSetTile(pkt, fmt, G_IM_SIZ_4b, \
(((((lrs)-(uls)+1)>>1)+7)>>3), 0, \
G_TX_RENDERTILE + 1, 0, cmt, maskt, shiftt, cms, masks, \
shifts); \
gDPSetTileSize(pkt, G_TX_RENDERTILE + 1, \
(uls + scrolls)<<G_TEXTURE_IMAGE_FRAC, \
(ult + scrollt)<<G_TEXTURE_IMAGE_FRAC, \
(lrs + scrolls)<<G_TEXTURE_IMAGE_FRAC, \
(lrt + scrollt)<<G_TEXTURE_IMAGE_FRAC) \
gDPSetTile(pkt, fmt, G_IM_SIZ_4b, \
(((((lrs)-(uls)+1)>>1)+7)>>3), 0, \
G_TX_RENDERTILE + 0, 1, cmt, maskt, shiftt, cms, masks, \
shifts); \
}
#define gDPScrollTextureTile_4b(pkt, timg, fmt, width, height, \
uls, ult, lrs, lrt, pal, \
cms, cmt, masks, maskt, shifts, shiftt, \
scrolls, scrollt) \
\
gDPSetTextureImage(pkt, fmt, G_IM_SIZ_8b, ((width)>>1), timg); \
gDPSetTile(pkt, fmt, G_IM_SIZ_8b, \
(((((lrs)-(uls)+1)>>1)+7)>>3), 0, \
G_TX_LOADTILE, 0 , cmt, maskt, shiftt, cms, masks, \
shifts); \
gDPLoadSync(pkt); \
gDPLoadTile( pkt, G_TX_LOADTILE, \
(uls)<<(G_TEXTURE_IMAGE_FRAC-1), \
(ult)<<(G_TEXTURE_IMAGE_FRAC), \
(lrs)<<(G_TEXTURE_IMAGE_FRAC-1), \
(lrt)<<(G_TEXTURE_IMAGE_FRAC)); \
gDPPipeSync(pkt); \
gDPSetTile(pkt, fmt, G_IM_SIZ_4b, \
(((((lrs)-(uls)+1)>>1)+7)>>3), 0, \
G_TX_RENDERTILE, 0, cmt, maskt, shiftt, cms, masks, \
shifts); \
gDPSetTileSize(pkt, G_TX_RENDERTILE, \
(uls + scrolls)<<G_TEXTURE_IMAGE_FRAC, \
(ult + scrollt)<<G_TEXTURE_IMAGE_FRAC, \
(lrs + scrolls)<<G_TEXTURE_IMAGE_FRAC, \
(lrt + scrollt)<<G_TEXTURE_IMAGE_FRAC) \
#endif

View File

@ -71,7 +71,7 @@ typedef struct ModelLocalVertexCopy {
typedef struct ModelTreeInfo {
/* 0x00 */ u8 modelIndex;
/* 0x01 */ s8 treeDepth;
/* 0x01 */ u8 treeDepth;
/* 0x02 */ s8 textureID;
/* 0x03 */ char unk_03;
} ModelTreeInfo; // size = 0x04

15
include/overlay.h Normal file
View File

@ -0,0 +1,15 @@
#ifndef _OVERLAY_H_
#define _OVERLAY_H_
#include "common.h"
typedef struct ScreenOverlay {
/* 0x00 */ Color_RGB8 color;
/* 0x03 */ char unk_03;
/* 0x04 */ s32 screenPos[2][2];
/* 0x14 */ f32 alpha;
} ScreenOverlay; // size = 0x18
void _render_transition_stencil(u8, f32, ScreenOverlay*);
#endif

View File

@ -2,6 +2,7 @@
#define _SCRIPT_API_MACROS_H_
#include "evt.h"
#include "stdlib/stdarg.h"
/****** EXPRESSIONS ***************************************************************************************************/
@ -125,10 +126,19 @@
/// Bytecode argv[argc];
/// }
/// This macro expands to the given opcode and argv, with argc calculated automatically.
#ifndef PERMUTER
#define EVT_CMD(opcode, argv...) \
opcode, \
(sizeof((Bytecode[]){argv})/sizeof(Bytecode)), \
##argv
#else
// This definition that passes in 0 for the number of args is used for pycparser since it can't handle varargs
#define EVT_CMD(opcode, argv...) \
opcode, \
0, \
##argv
#endif
/// Signals the end of EVT script data. A script missing this will likely crash on load.
#define EVT_END EVT_CMD(EVT_OP_END),

View File

@ -82,7 +82,6 @@ extern EncounterStatus gCurrentEncounter;
extern s8* D_801512F0;
extern s16 D_80151308;
extern s32 D_80151310;
extern s16* D_80151328;
extern s32 D_8010C92C;
extern s16 D_8010CD00;
@ -150,6 +149,8 @@ extern s32 D_800A0964;
extern s8 D_800A0B94;
extern s16 D_800A0BB8;
extern SpriteShadingProfile* D_80151328;
extern Window gWindows[64];

View File

@ -1,15 +1,32 @@
#include "common.h"
typedef struct UnkSpr10 {
/* 0x00 */ s32 unk_00;
/* 0x04 */ char unk_04[0xC];
} UnkSpr10;
extern s32 D_802E0C58;
extern UnkSpr10 D_802E0C70[];
INCLUDE_ASM(s32, "101b90_len_8f0", spr_swizzle_anim_offsets);
INCLUDE_ASM(s32, "101b90_len_8f0", spr_load_sprite);
// spr_init_player_raster_cache
INCLUDE_ASM(void, "101b90_len_8f0", spr_init_player_raster_cache, s32 cacheSize, s32 maxRasterSize);
INCLUDE_ASM(s32, "101b90_len_8f0", spr_get_player_raster);
INCLUDE_ASM(s32, "101b90_len_8f0", spr_update_player_raster_cache);
void spr_update_player_raster_cache(void) {
s32 i;
func_8013A4D0();
for (i = 0; i < D_802E0C58; i++) {
if (D_802E0C70[i].unk_00 != 0) {
D_802E0C70[i].unk_00--;
}
}
}
INCLUDE_ASM(s32, "101b90_len_8f0", spr_load_npc_extra_anims);

View File

@ -70,10 +70,10 @@ BSS s32 filemenu_8024C100[8];
INCLUDE_ASM(s32, "163400", mainmenu_draw_rect);
void filemenu_set_selected(MenuPanel* menu, s32 col, s32 row) {
menu->col = col;
menu->row = row;
menu->selected = menu->gridData[(menu->page * menu->numCols * menu->numRows) +
(menu->numCols * (s8) row) + menu->col];
menu->unk_00.c.col = col;
menu->unk_00.c.row = row;
menu->unk_00.c.selected = menu->gridData[(menu->page * menu->numCols * menu->numRows) +
(menu->numCols * menu->unk_00.c.row) + menu->unk_00.c.col];
}
void filemenu_set_cursor_alpha(s32 arg0) {

View File

@ -2,7 +2,53 @@
#include "filemenu.h"
#include "hud_element.h"
INCLUDE_ASM(s32, "165490", filemenu_draw_contents_title);
extern SaveMetadata D_800779C4[4];
extern u8 D_80077A24[4];
extern s8* D_80249E20[14];
extern MenuWindowBP D_80249EA0[14];
extern s8 D_8024C098;
void filemenu_draw_contents_title(
MenuPanel* menu,
s32 baseX, s32 baseY,
s32 width, s32 height,
s32 opacity, s32 darkening
) {
s32 msgIdx;
s32 xOffset;
s32 yOffset;
switch (menu->page) {
case 0:
msgIdx = 1;
xOffset = 9;
yOffset = 4;
break;
case 1:
msgIdx = 2;
xOffset = 8;
yOffset = 4;
break;
case 3:
msgIdx = 4;
xOffset = 25;
yOffset = 4;
break;
case 4:
msgIdx = 5;
xOffset = 16;
yOffset = 4;
break;
case 2:
default:
msgIdx = 3;
xOffset = 10;
yOffset = 4;
break;
}
filemenu_draw_message(filemenu_get_menu_message(msgIdx), baseX + xOffset, baseY + yOffset, 255, 0, 0);
}
void filemenu_draw_contents_stereo(
MenuPanel* menu,
@ -34,15 +80,92 @@ void filemenu_draw_contents_mono(
}
}
INCLUDE_ASM(s32, "165490", filemenu_draw_contents_option_left);
void filemenu_draw_contents_option_left(
MenuPanel* menu,
s32 baseX, s32 baseY,
s32 width, s32 height,
s32 opacity, s32 darkening
) {
if (menu->page != 2) {
if ((menu->unk_00.s & 0x00FFFF00) == 0x200) {
filemenu_set_cursor_goal_pos(53, baseX, baseY + 8);
}
filemenu_draw_message(filemenu_get_menu_message(9), baseX + 8, baseY + 2, 255, 0, 1);
}
}
INCLUDE_ASM(s32, "165490", filemenu_draw_contents_option_center);
void filemenu_draw_contents_option_center(
MenuPanel* menu,
s32 baseX, s32 baseY,
s32 width, s32 height,
s32 opacity, s32 darkening
) {
s32 msgIdx;
s32 xOffset;
s32 yOffset;
switch (menu->page) {
case 1:
case 2:
case 3:
case 4:
msgIdx = 10;
xOffset = 18;
yOffset = 0;
if ((menu->unk_00.s & 0xFFFF00) == 0x010200) {
filemenu_set_cursor_goal_pos(54, baseX + 8, baseY + 8);
}
break;
default:
msgIdx = 11;
xOffset = 14;
yOffset = 0;
if ((menu->unk_00.s & 0xFFFF00) == 0x010200) {
filemenu_set_cursor_goal_pos(54, baseX + 4, baseY + 8);
}
break;
}
filemenu_draw_message(filemenu_get_menu_message(msgIdx), baseX + xOffset, baseY + yOffset + 2, 255, 0, 1);
}
void filemenu_draw_contents_option_right(
MenuPanel* menu,
s32 baseX, s32 baseY,
s32 width, s32 height,
s32 opacity, s32 darkening
) {
if (menu->page != 2) {
if ((menu->unk_00.s & 0xFFFF00) == 0x020200) {
filemenu_set_cursor_goal_pos(55, baseX + 8, baseY + 8);
}
filemenu_draw_message(filemenu_get_menu_message(10), baseX + 20, baseY + 2, 255, 0, 1);
}
}
INCLUDE_ASM(s32, "165490", filemenu_draw_contents_option_right);
INCLUDE_ASM(s32, "165490", filemenu_draw_contents_file_info);
INCLUDE_ASM(s32, "165490", filemenu_draw_contents_file_title);
void filemenu_draw_contents_file_title(
s32 fileIdx,
MenuPanel* menu,
s32 baseX, s32 baseY,
s32 width, s32 height,
s32 opacity, s32 darkening)
{
if (D_8024C098 == 0 && menu->unk_00.c.selected == fileIdx) {
filemenu_set_cursor_goal_pos(fileIdx + 60, baseX - 3, baseY + 8);
}
filemenu_draw_message(filemenu_get_menu_message(26), baseX + 5, baseY + 1, 255, 0, 1);
if (D_80077A24[fileIdx] == 0) {
draw_number(fileIdx + 1, baseX + 33, baseY + 1, 1, 0, 255, 2);
} else {
draw_number(fileIdx + 1, baseX + 33, baseY + 1, 1, 0, 255, 2);
filemenu_draw_file_name(D_800779C4[fileIdx].unk_07, 8, baseX + 46, baseY + 1, 255, 0, 1, 9);
}
}
void filemenu_draw_contents_file_0_info(
MenuPanel* menu,
@ -116,10 +239,71 @@ void filemenu_draw_contents_file_3_title(
filemenu_draw_contents_file_title(3, menu, baseX, baseY, width, height, opacity, darkening);
}
INCLUDE_ASM(s32, "165490", filemenu_main_init);
void filemenu_main_init(MenuPanel* menu) {
s32 halfWidth;
s32 halfWidth2;
s16* posXPtr;
s32 x;
s32 i;
for (i = 0; i < ARRAY_COUNT(filemenu_hudElemIDs); i++) {
filemenu_hudElemIDs[i] = create_hud_element(D_80249E20[i]);
set_hud_element_flags(filemenu_hudElemIDs[i], 0x80);
}
for (i = 0; i < ARRAY_COUNT(D_80249EA0); i++) {
D_80249EA0[i].tab = menu;
}
setup_pause_menu_tab(D_80249EA0, ARRAY_COUNT(D_80249EA0));
menu->unk_00.c.selected = menu->gridData[(menu->page * menu->numCols * menu->numRows) +
(menu->numCols * menu->unk_00.c.row) +
menu->unk_00.c.col];
if (menu->page == 2) {
gWindows[45].pos.y = 1;
gWindows[45].width = 211;
gWindows[45].height = 25;
} else {
gWindows[45].pos.y = 1;
gWindows[45].width = 162;
gWindows[45].height = 25;
}
halfWidth = gWindows[45].width / 2;
posXPtr = &gWindows[45].pos.x;
if (gWindows[45].parent != -1) {
x = (gWindows[gWindows[45].parent].width / 2) - halfWidth;
} else {
x = 160 - halfWidth;
}
*posXPtr = x;
halfWidth2 = gWindows[54].width / 2;
posXPtr = &gWindows[54].pos.x;
if (gWindows[54].parent != -1) {
x = (gWindows[gWindows[54].parent].width / 2) - halfWidth2;
} else {
x = 160 - halfWidth2;
}
*posXPtr = x;
if (menu->page != 0) {
set_window_update(0x35, 2);
set_window_update(0x37, 2);
set_window_update(0x33, 2);
set_window_update(0x34, 2);
}
menu->unk_00.c.initialized = 1;
}
static const f32 padding[] = { 0.0f }; // TODO remove when the following func is matched
void filemenu_main_handle_input(MenuPanel* menu);
INCLUDE_ASM(s32, "165490", filemenu_main_handle_input);
extern s32 D_8014F150[];
INCLUDE_ASM(s32, "165490", filemenu_main_update);
void filemenu_main_cleanup(void) {

View File

@ -8,11 +8,10 @@ extern s32 filemenu_iterFileIdx;
extern s32 filemenu_pressedButtons;
extern s8 D_8024C090;
extern s32 filemenu_loadedFileIdx;
extern s8 D_8024C098_C09918;
extern s8 D_8024C098;
extern s32 D_8024C100_C09980[3];
extern s32 D_8024C110;
s32 filemenu_get_menu_message(s32 index);
void filemenu_update_show_options_left(s32 windowIndex, s32* flags, s32* posX, s32* posY, s32* posZ, s32* scaleX,
s32* scaleY, s32* rotX, s32* rotY, s32* rotZ, s32* darkening, s32* opacity);
void filemenu_update_show_options_right(s32 windowIndex, s32* flags, s32* posX, s32* posY, s32* posZ, s32* scaleX,
@ -26,7 +25,7 @@ void filemenu_info_draw_message_contents(MenuPanel* menu, s32 baseX, s32 baseY)
switch (page) {
case 0:
filemenu_draw_message(filemenu_get_menu_message(0x1A), baseX + 10, baseY + 4, 255, 0, 0);
draw_number(filemenu_menus[0]->selected + 1, baseX + 48, baseY + 6, 0, 0, 255, 3);
draw_number(filemenu_menus[0]->unk_00.c.selected + 1, baseX + 48, baseY + 6, 0, 0, 255, 3);
filemenu_draw_message(filemenu_get_menu_message(0x1B), baseX + 49, baseY + 4, 255, 0, 0);
break;
case 2:
@ -43,7 +42,7 @@ void filemenu_info_draw_message_contents(MenuPanel* menu, s32 baseX, s32 baseY)
break;
case 3:
filemenu_draw_message(filemenu_get_menu_message(0x1A), baseX + 10, baseY + 4, 255, 0, 0);
draw_number(filemenu_menus[0]->selected + 1, baseX + 48, baseY + 6, 0, 0, 255, page);
draw_number(filemenu_menus[0]->unk_00.c.selected + 1, baseX + 48, baseY + 6, 0, 0, 255, page);
filemenu_draw_message(filemenu_get_menu_message(0x1F), baseX + 49, baseY + 4, 255, 0, 0);
break;
}
@ -66,7 +65,7 @@ void filemenu_info_handle_input(void) {
MenuPanel* menu = filemenu_menus[0];
s32 page;
D_8024C098_C09918 = 0;
D_8024C098 = 0;
page = menu->page;
switch(page) {
@ -130,7 +129,7 @@ void filemenu_draw_contents_file_create_header(MenuPanel* menu, s32 baseX, s32 b
}
tempAmt = 8;
if (D_8024C098_C09918 == 3) {
if (D_8024C098 == 3) {
s32 phi_v0 = 122;
if (D_8024C090 != tempAmt) {

View File

@ -912,7 +912,7 @@ void btl_state_update_partner_move(void) {
break;
}
sfx_play_sound(SOUND_UNKNOWN_2107);
sfx_play_sound(SOUND_2107);
btl_show_battle_message(phi_s0, 0x3C);
for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {

View File

@ -68,112 +68,6 @@ EvtSource BtlBringPartnerOut = {
EVT_END
};
s8 D_80280CE0[] = { 0, 0, 0, 0 };
s32 D_80280CE4 = -1;
EvtSource CamPreset_B = {
EVT_CALL(func_80248DD0)
EVT_RETURN
EVT_END
};
EvtSource CamPreset_F = {
EVT_CALL(func_80248DE4)
EVT_RETURN
EVT_END
};
EvtSource CamPreset_M = {
EVT_CALL(func_80249804)
EVT_RETURN
EVT_END
};
EvtSource CamPreset_G = {
EVT_CALL(func_8024A214)
EVT_RETURN
EVT_END
};
EvtSource CamPreset_I = {
EVT_CALL(func_8024A990)
EVT_RETURN
EVT_END
};
EvtSource CamPreset_H = {
EVT_CALL(func_8024AFE4)
EVT_RETURN
EVT_END
};
EvtSource CamPreset_N = {
EVT_CALL(func_8024B5FC)
EVT_RETURN
EVT_END
};
EvtSource CamPreset_C = {
EVT_CALL(func_8024B9A0)
EVT_RETURN
EVT_END
};
EvtSource CamPreset_D = {
EVT_CALL(func_8024BDA4)
EVT_RETURN
EVT_END
};
EvtSource CamPreset_E = {
EVT_CALL(func_8024C180)
EVT_RETURN
EVT_END
};
EvtSource CamPreset_J = {
EVT_CALL(func_8024C570)
EVT_RETURN
EVT_END
};
EvtSource CamPreset_K = {
EVT_CALL(func_8024C944)
EVT_RETURN
EVT_END
};
EvtSource CamPreset_L = {
EVT_CALL(func_8024CB68)
EVT_RETURN
EVT_END
};
EvtSource CamPreset_A = {
EVT_CALL(func_8024E9B0, 0, 15, 0)
EVT_CALL(func_8024E748, 2, 550)
EVT_CALL(func_8024E748, 3, 100)
EVT_CALL(func_8024E748, 4, 8)
EVT_RETURN
EVT_END
};
EvtSource D_80280EB8 = {
EVT_CALL(SetCamPerspective, 1, 6, 25, 16, 1024)
EVT_CALL(SetCamViewport, 1, 12, 20, 296, 200)
EVT_CALL(SetCamBGColor, 1, 0, 0, 0)
EVT_CALL(SetCamEnabled, 1, 1)
EVT_WAIT_FRAMES(1)
EVT_CALL(InitVirtualEntityList)
EVT_CALL(InitAnimatedModels)
EVT_CALL(func_802CABE8, 1, 0, 240, 100, 8)
EVT_CALL(func_802CAE50, 1, -75, 35, 0)
EVT_CALL(BattleCamTargetActor, 0)
EVT_CALL(func_8024CE9C)
EVT_RETURN
EVT_END
};
void get_dpad_input_radial(f32* angle, f32* magnitude) {
BattleStatus* battleStatus = &gBattleStatus;
u16 currentButtonsDown;

File diff suppressed because it is too large Load Diff

View File

@ -431,7 +431,7 @@ s32 calc_enemy_damage_target(Actor* attacker) {
if (blocked) {
damage--;
damage -= player_team_is_ability_active(target, ABILITY_DAMAGE_DODGE);
sfx_play_sound_at_position(SOUND_UNKNOWN_231, 0, state->goalPos.x, state->goalPos.y, state->goalPos.z);
sfx_play_sound_at_position(SOUND_231, 0, state->goalPos.x, state->goalPos.y, state->goalPos.z);
func_802667F0(0, target, state->goalPos.x, state->goalPos.y, state->goalPos.z);
gBattleStatus.flags1 |= BS_FLAGS1_ATK_BLOCKED;
break;
@ -444,7 +444,7 @@ s32 calc_enemy_damage_target(Actor* attacker) {
if (target->koStatus == STATUS_END && !(battleStatus->currentAttackElement & DAMAGE_TYPE_UNBLOCKABLE)) {
if (check_block_input(BUTTON_A)) {
damage = 0;
sfx_play_sound_at_position(SOUND_UNKNOWN_231, 0, state->goalPos.x, state->goalPos.y, state->goalPos.z);
sfx_play_sound_at_position(SOUND_231, 0, state->goalPos.x, state->goalPos.y, state->goalPos.z);
func_802667F0(0, target, state->goalPos.x, state->goalPos.y, state->goalPos.z);
gBattleStatus.flags1 |= BS_FLAGS1_ATK_BLOCKED;
break;
@ -705,7 +705,7 @@ s32 calc_enemy_damage_target(Actor* attacker) {
func_80267018(target, 1);
if (attacker->actorTypeData1[5] != SOUND_UNKNOWN_0) {
if (attacker->actorTypeData1[5] != SOUND_0) {
sfx_play_sound_at_position(attacker->actorTypeData1[5], 0, state->goalPos.x, state->goalPos.y, state->goalPos.z);
}

View File

@ -1,7 +1,12 @@
#include "common.h"
#include "battle/battle.h"
#include "npc.h"
#include "effects.h"
#include "hud_element.h"
extern s32 D_80077C40;
extern s8 D_8009A654;
extern s16 D_8009A668;
extern s32 D_800A0BA0;
extern f32 D_800A0BA4;
@ -145,8 +150,8 @@ ApiStatus MerleeUpdateFX(Evt* script, s32 isInitialCall) {
if (D_800A0BB8 == 2) {
((EffectInstanceData*)D_800A0BA8->data)->unk_30 = 0.00001f;
((EffectInstanceData*)D_800A0BAC->data)->unk_30 = 0.00001f;
D_800A0BA8->flags |= 0x10;
D_800A0BAC->flags |= 0x10;
D_800A0BA8->flags |= EFFECT_INSTANCE_FLAGS_10;
D_800A0BAC->flags |= EFFECT_INSTANCE_FLAGS_10;
return ApiStatus_DONE1;
}
@ -223,9 +228,9 @@ ApiStatus OnDefeatEnemy(Evt* script, s32 isInitialCall) {
}
if (script->functionTemp[1] & 1) {
npc->flags &= ~2;
npc->flags &= ~NPC_FLAG_2;
} else {
npc->flags |= 2;
npc->flags |= NPC_FLAG_2;
}
if (script->functionTemp[1] == 15) {
@ -244,7 +249,7 @@ ApiStatus OnDefeatEnemy(Evt* script, s32 isInitialCall) {
script->functionTemp[1] -= 1;
if (script->functionTemp[1] == 0) {
npc->flags |= 2;
npc->flags |= NPC_FLAG_2;
return ApiStatus_DONE1;
}
@ -282,7 +287,209 @@ INCLUDE_ASM(s32, "1a1f0_len_5390", update_encounters_neutral);
void draw_encounters_neutral(void) {
}
INCLUDE_ASM(s32, "1a1f0_len_5390", update_encounters_pre_battle);
void update_encounters_pre_battle(void) {
EncounterStatus* currentEncounter = &gCurrentEncounter;
PlayerData* playerData = &gPlayerData;
Encounter* encounter;
Enemy* enemy;
s32 i;
s32 j;
switch (D_8009A5D0) {
case 0:
currentEncounter->fadeOutAmount = 0;
currentEncounter->unk_94 = 1;
currentEncounter->fadeOutAccel = 1;
currentEncounter->unk_08 = -1;
D_8009A654 = 0;
D_80077C40 = 0;
suspend_all_group(0x10);
for (i = 0; i < currentEncounter->numEncounters; i++) {
encounter = currentEncounter->encounterList[i];
if (encounter != NULL) {
for (j = 0; j < encounter->count; j++) {
enemy = encounter->enemy[j];
if (enemy != NULL && !(enemy->flags & NPC_FLAG_NO_AI)) {
if (enemy->aiScript != NULL) {
suspend_all_script(enemy->aiScriptID);
}
if (enemy->auxScript != NULL) {
suspend_all_script(enemy->auxScriptID);
}
}
}
}
}
enemy = currentEncounter->currentEnemy;
if ((enemy->flags & NPC_FLAG_MOTION_BLUR) && currentEncounter->unk_12 == 0) {
currentEncounter->unk_94 = 0;
currentEncounter->battleStartCountdown = 0;
partner_handle_before_battle();
D_8009A5D0 = 3;
return;
}
if (gGameStatusPtr->debugEnemyContact == 2) {
currentEncounter->unk_94 = 0;
currentEncounter->battleStartCountdown = 10;
partner_handle_before_battle();
D_8009A5D0 = 2;
return;
}
enemy = currentEncounter->currentEnemy;
if (currentEncounter->hitType != 1 &&
currentEncounter->hitType != 3 &&
is_ability_active(ABILITY_FIRST_ATTACK) &&
(playerData->level >= enemy->npcSettings->level) &&
!(enemy->flags & ENEMY_FLAGS_40) &&
currentEncounter->unk_12 == 0)
{
currentEncounter->unk_94 = 0;
currentEncounter->battleStartCountdown = 0xA;
D_80077C40 = 1;
D_8009A5D0 = 2;
return;
}
enemy = currentEncounter->currentEnemy;
if ((
(is_ability_active(ABILITY_BUMP_ATTACK)) &&
(playerData->level >= enemy->npcSettings->level) &&
(!(enemy->flags & ENEMY_FLAGS_40) &&
(currentEncounter->unk_12 == 0))
) || (
(enemy = currentEncounter->currentEnemy,
(currentEncounter->hitType == 3)) &&
(is_ability_active(ABILITY_SPIN_ATTACK)) &&
playerData->level >= enemy->npcSettings->level &&
!(enemy->flags & ENEMY_FLAGS_40) &&
currentEncounter->unk_12 == 0
))
{
currentEncounter->battleStartCountdown = 10;
D_80077C40 = 1;
currentEncounter->unk_94 = 0;
D_8009A5D0 = 2;
return;
}
if (currentEncounter->songID < 0) {
switch (currentEncounter->eFirstStrike) {
case 0:
bgm_set_battle_song(SONG_NORMAL_BATTLE, FIRST_STRIKE_NONE);
break;
case 1:
bgm_set_battle_song(SONG_NORMAL_BATTLE, FIRST_STRIKE_PLAYER);
break;
case 2:
bgm_set_battle_song(SONG_NORMAL_BATTLE, FIRST_STRIKE_ENEMY);
break;
}
} else {
bgm_set_battle_song(currentEncounter->songID, FIRST_STRIKE_NONE);
}
bgm_push_battle_song();
D_8009A654 = 1;
currentEncounter->battleStartCountdown = 10;
D_8009A5D0 = 1;
case 1:
if (currentEncounter->fadeOutAmount == 255) {
if (currentEncounter->battleStartCountdown != 0) {
currentEncounter->battleStartCountdown--;
break;
}
encounter = currentEncounter->currentEncounter;
for (i = 0; i < encounter->count; i++) {
enemy = encounter->enemy[i];
if (enemy != NULL &&
((!(enemy->flags & NPC_FLAG_ENABLE_HIT_SCRIPT) || enemy == currentEncounter->currentEnemy)) &&
!(enemy->flags & NPC_FLAG_NO_AI) &&
enemy->hitScript != NULL)
{
kill_script_by_ID(enemy->hitScriptID);
enemy->hitScript = NULL;
}
}
partner_handle_before_battle();
currentEncounter->unk_A0 = 0;
currentEncounter->unk_A2 = 0;
enemy = currentEncounter->currentEnemy;
currentEncounter->unk_10 = enemy->unk_B5;
if (is_ability_active(ABILITY_DIZZY_ATTACK) && currentEncounter->hitType == 3) {
currentEncounter->unk_A0 = 4;
currentEncounter->unk_A2 = 3;
}
sfx_stop_sound(SOUND_2111);
sfx_stop_sound(SOUND_2112);
sfx_stop_sound(SOUND_2113);
sfx_stop_sound(SOUND_2114);
set_battle_formation(0);
set_battle_stage(encounter->stage);
load_battle(encounter->battle);
currentEncounter->unk_07 = 1;
currentEncounter->unk_08 = 0;
currentEncounter->merleeCoinBonus = 0;
currentEncounter->damageTaken = 0;
currentEncounter->coinsEarned = 0;
currentEncounter->fadeOutAccel = 0;
currentEncounter->fadeOutAmount = 255;
set_screen_overlay_params_front(0, 255.0f);
gGameState = 5;
D_8009A678 = 1;
D_8009A5D0 = 0;
}
break;
case 2:
if (currentEncounter->battleStartCountdown != 0) {
currentEncounter->battleStartCountdown--;
break;
}
encounter = currentEncounter->currentEncounter;
for (i = 0; i < encounter->count; i++) {
enemy = encounter->enemy[i];
if (enemy != NULL &&
(!(enemy->flags & NPC_FLAG_ENABLE_HIT_SCRIPT) || enemy == currentEncounter->currentEnemy) &&
!(enemy->flags & NPC_FLAG_NO_AI) &&
(enemy->hitScript != 0))
{
kill_script_by_ID(enemy->hitScriptID);
enemy->hitScript = NULL;
}
}
currentEncounter->unk_08 = 1;
currentEncounter->unk_07 = 1;
currentEncounter->battleOutcome = 0;
currentEncounter->merleeCoinBonus = 0;
currentEncounter->damageTaken = 0;
gGameState = 5;
currentEncounter->coinsEarned = 0;
currentEncounter->fadeOutAccel