Skip to content

Commit

Permalink
Trade item swaps (#35)
Browse files Browse the repository at this point in the history
* Import GearScreen and identify value of the index update. Need to work on using L to go back in items.

* Full L and R rotation of items in the deed slot now working.

* Finalize trade item swap logic.

TODO: Include ext item collection in itemeffect calls.

* Complete work for keeping trade items over cycle and cycling through trade items.

Update some fields in common data to match mm decomp.

Hopefully fix bottle issues once and for all.

* Formatting change.

Debug changes as well.

* Update bottle logic.

Update mask base items to be a mask so they get mask fanfare.

Update drawing items for refill items.

* Minor decomp work.

Find blast mask timer.

* WIP: Attempt a new way of giving items from chests.

* Update more bottle conditions.

Update chest conditions to give items back if the user lacks them.

* Bring in rough chest content matching for future purposes.

* Attempt at breaking up inventory space and moving it to its own hooks.

WIP: removing items if the user gives them away.

* Fix item swapping and deletion of items on giving items.

* Change chest function to be more reflective of what it does.

* Finish adjusting Kafei letter in mail. Last to do it pendant.

* Formatting fixes.

* Revert mask changes as we cannot override animations on pickup just yet.
  • Loading branch information
PhlexPlexico authored Feb 17, 2024
1 parent d5283f5 commit 892d905
Show file tree
Hide file tree
Showing 26 changed files with 888 additions and 115 deletions.
2 changes: 1 addition & 1 deletion code/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ include $(DEVKITARM)/3ds_rules
#---------------------------------------------------------------------------------
TARGET := $(notdir $(CURDIR))
BUILD := build
SOURCES := source source/asm source/lib source/common source/game source/rnd
SOURCES := source source/asm source/lib source/common source/game source/rnd source/game/ui/screens
DATA := data
INCLUDES := include
GRAPHICS := gfx
Expand Down
12 changes: 6 additions & 6 deletions code/include/game/actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,14 +325,14 @@ namespace game::act {

// Name courtesy of the OoT decomp project.
struct DynaPolyActor : Actor {
u32 dyna_poly_id;
float field_1FC;
u32 bg_id;
float push_force;
float field_200;
u16 field_204;
u8 field_206;
u32 dyna_poly_flags;
s16 y_rotation;
u32 transform_flags;
u8 interact_flags;
};
static_assert(sizeof(DynaPolyActor) == 0x20C);
static_assert(sizeof(DynaPolyActor) == 0x210);

struct DayTimerActor {
Actor common_actor;
Expand Down
55 changes: 55 additions & 0 deletions code/include/game/actors/chest.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#ifndef _GAME_ACTORS_CHEST_H
#define _GAME_ACTORS_CHEST_H

#include "game/actor.h"
#include "game/as.h"
#include "game/collision.h"
#include "game/skelanime.h"
#include "rnd/item_override.h"

namespace game::actors {
enum class EnBoxType : u8 {
ENBOX_TYPE_BIG = 0, // E.g. Hookshot Chest
ENBOX_TYPE_BIG_ROOM_CLEAR = 1,
ENBOX_TYPE_BIG_ORNATE = 2, // E.g. Boss Key Chests
ENBOX_TYPE_BIG_SWITCH_FLAG_FALL = 3,
ENBOX_TYPE_BIG_INVISIBLE = 4,
ENBOX_TYPE_SMALL = 5,
ENBOX_TYPE_SMALL_INVISIBLE = 6,
ENBOX_TYPE_SMALL_ROOM_CLEAR = 7,
ENBOX_TYPE_SMALL_SWITCH_FLAG_FALL = 8,
ENBOX_TYPE_BIG_SONG_ZELDAS_LULLABY = 9,
ENBOX_TYPE_BIG_SONG_SUNS = 10,
ENBOX_TYPE_BIG_SWITCH_FLAG = 11,
ENBOX_TYPE_SMALL_SWITCH_FLAG = 12
};

struct En_Box {
game::act::DynaPolyActor dyna;
SkelAnime* skel_anime;
u8 gap_210[52];
CollisionInfoCylinder* collision_cylinder;
u8 gap_248[84];
int field_29C;
u8 gap_2A0[8];
void* some_fn;
u8 gap_2AC[312];
u16 some_item_check;
u8 movement_flags;
u8 alpha;
u8 switch_flag;
EnBoxType chest_type;
u8 iceSmokeTImer;
s8 field_3EB;
u8 gap_3EC[16];
void* field_3fc;
u8 gap_400[16];
game::act::Actor* field_410;
int csId2;
rnd::GetItemID GetItemID;
s32 collectableFlag;
u8 gap_420[8];
};
} // namespace game::actors

#endif
8 changes: 4 additions & 4 deletions code/include/game/common_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace game {
struct PlayerData {
char field_11C[4];
u8 gap_124[2];
u16 song_of_time_counter; // Plays song of time cutscene when == 0
u16 three_day_reset_count; // Plays song of time cutscene when == 0
char16_t playerName[8];
u16 anonymous_h;

Expand Down Expand Up @@ -226,13 +226,13 @@ namespace game {
/// In-game time.
/// 0x0000 is midnight, 0x4000 is 6am, 0x8000 is noon, 0xc000 is 6pm.
u16 time;
u16 anonymous_3;
u16 jinxTimer;
u16 rupee_accumulator;
act::Player::Form player_form;
char anonymous_5;
bool has_tatl;
char anonymous_7;
char anonymous_8;
char bButtonUsability;
char anonymous_9;
char anonymous_10;
char anonymous_11;
Expand Down Expand Up @@ -316,7 +316,7 @@ namespace game {
int previous_defeated_boss; // or last viewed giant cutscene, values 4 and greater makes
// woodfall giant repeat for all temples.
// u8 gap1221[3];
int anonymous_63;
int stolenItems;
u8 gap1220[8];
u16 bank_rupee_count;
u16 anonymous_64;
Expand Down
3 changes: 2 additions & 1 deletion code/include/game/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,8 @@ namespace game::act {
u8 gap_11EC0[6];
char field_11EC6;
char field_11EC7;
u16 disable_b_if_255;
// u8 field_11EC8;
u16 blastMaskTimer;
u16 zora_barrier_timer;
u16 field_11ECC;
char field_11ECE[1];
Expand Down
39 changes: 39 additions & 0 deletions code/include/game/skelanime.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#ifndef _GAME_SKELANIME_H
#define _GAME_SKELANIME_H

#include "common/types.h"
#include "game/context.h"
#include "z3d/z3DVec.h"

namespace game {

struct SkelAnime {
u8 limb_count;
u8 mode;
u8 d_list_count;
s8 taper;
void** skeleton; /* An array of pointers to limbs. Can be StandardLimb, LodLimb, or SkinLimb. */
void* animation; /* Can be an AnimationHeader or PlayerAnimationHeader. */
float start_frame;
float end_frame;
float animation_length;
float cur_frame;
float play_speed;
z3dVec3s* joint_table;
z3dVec3s* morph_table;
float morph_weight;
float morph_rate;
union {
s32 (*normal)(struct SkelAnime*); // Can be Loop, Partial loop, Play once, Morph, or Tapered morph
s32 (*player)(struct game::GlobalContext*, struct SkelAnime*); // Loop, Play once, and Morph
} update;
s8 init_flags;
u8 move_flags;
s16 prev_yaw;
z3dVec3s prev_transl;
z3dVec3s base_transl;
};

} // namespace game

#endif
27 changes: 27 additions & 0 deletions code/include/game/ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,33 @@ namespace game::ui {
};
static_assert(sizeof(Layout) == 0x170);

struct ItemIcon {
Layout thisx;
u8 initialized;
u8 gap_171[3];
int icon_id;
int item_count;
int icon_number;
int rank_ten;
AnimPlayer* item_icon_player;
AnimPlayer* rank_ten_player;
AnimPlayer* rank_a_player;
AnimPlayer* color_player;
AnimPlayer* main_player;
Anim* idle_anim;
Anim* pressed_anim;
Anim* activated_anim;
Anim* disabled_anim;
Anim* unusable_anim;
Anim* selected_anim;
AnimPlayer* return_player;
Anim* return_to_start_anim;
Anim* return_vanish_idle_anim;
Anim* return_remain_idle_anim;
Anim* return_empty_idle_anim;
Anim* equip_anim;
void* item_icon_pane;
};
struct CommonLayouts {
Layout* touch_panel;
Layout* background;
Expand Down
69 changes: 69 additions & 0 deletions code/include/game/ui/screens/gearscreen.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#include "common/utils.h"
#include "game/message.h"
#include "game/ui.h"

#ifndef _GAME_UI_GEARSCREEN_H
#define _GAME_UI_GEARSCREEN_H

namespace game::ui::screens {
struct GearScreen {
Screen* screen;
int press_handler;
u16 field_8;
u16 field_A;
void* subMenuTitle;
void* subMenuUpCollect;
void* menuCollect;
void* commonBottomBg;
void* btn_return_top_l;
void* btn_return;
void* btn_option_l;
void* main_player;
void* in_menu_collect_anim;
void* out_menu_collect_anim;
u8 gap_34[240];
int field_124;
int field_128;
int field_12C;
ItemIcon* cursorItemCollect;
ItemIcon* icon_event00_l;
ItemIcon* icon_event01_l;
ItemIcon* icon_event02_l;
ItemIcon* icon_event03_l;
ItemIcon* icon_shadowgraph_box_l;
ItemIcon* icon_purse_l;
ItemIcon* icon_bomb_bag_l;
ItemIcon* icon_arrow_l;
ItemIcon* icon_sword_l;
ItemIcon* icon_shield_l;
ItemIcon* icon_boss00_l;
ItemIcon* icon_boss02_l;
ItemIcon* icon_boss01_l;
ItemIcon* icon_boss03_l;
ItemIcon* icon_schedule_l;
ItemIcon* icon_okarina_l;
ItemIcon* icon_trumpet_l;
ItemIcon* icon_drum_l;
ItemIcon* icon_guitar_l;
ItemIcon* icon_f_tickets_l;
ItemIcon* heart_pieces_l;
void* frame_deformation_player;
void* blink_picture_g;
void* small_picture_g;
u8 field_194;
u8 cursorIndex; // Possible Index For Selected Item on Gear Screen
u8 field_196;
u8 field_197;
int pressed_btn_option;
int field_19C;
int field_1A0;
u8 has_opened_option_menu;
u8 gap_1a5[3];
};
static_assert(sizeof(GearScreen) == 0x1A8);
static_assert(offsetof(GearScreen, press_handler) == 0x00004);

GearScreen* GetGearScreen();
} // namespace game::ui::screens

#endif
21 changes: 15 additions & 6 deletions code/include/rnd/chest.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@
#define _RND_CHEST_H_

#include "common/advanced_context.h"
#include "game/actors/chest.h"
#include "game/context.h"

#include "rnd/item_override.h"
#include "rnd/settings.h"
#if defined ENABLE_DEBUG || defined DEBUG_PRINT
#include "common/debug.h"
extern "C" {
#include <3ds/svc.h>
}
#endif
namespace rnd {
enum class ChestSize : u8 {
VANILLA_SIZE,
Expand All @@ -22,10 +30,11 @@ namespace rnd {
DECORATED_SMALL,
};

void EnBox_rInit(game::act::Actor* thisx, game::GlobalContext* globalCtx);
void EnBox_rUpdate(game::act::Actor* thisx, game::GlobalContext* globalCtx);
u8 Chest_OverrideAnimation();
u8 Chest_OverrideDecoration();
u8 Chest_OverrideIceSmoke(game::act::Actor* thisx);
extern "C" game::actors::EnBoxType Chest_OverrideSize(game::actors::En_Box*, game::GlobalContext*, s16);
// void EnBox_rInit(game::act::Actor* thisx, game::GlobalContext* globalCtx);
// void EnBox_rUpdate(game::act::Actor* thisx, game::GlobalContext* globalCtx);
// u8 Chest_OverrideAnimation();
// u8 Chest_OverrideDecoration();
// u8 Chest_OverrideIceSmoke(game::act::Actor* thisx);
} // namespace rnd
#endif //_CHEST_H_
26 changes: 26 additions & 0 deletions code/include/rnd/custom_screen.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#ifndef _RND_CUSTOM_SCREEN_H_
#define _RND_CUSTOM_SCREEN_H_

#include "common/advanced_context.h"
#include "common/types.h"
#include "game/ui/screens/gearscreen.h"
#include "rnd/savefile.h"
#if defined ENABLE_DEBUG || defined DEBUG_PRINT
#include "common/debug.h"
extern "C" {
#include <3ds/svc.h>
}
#endif

namespace rnd {
namespace gearscreen {
extern "C" void GearScreen_GetStoredTradeItem(game::ui::screens::GearScreen*);
void GearScreen_DrawAndShowItem(game::ItemId, game::ui::Anim*, u16, int);
bool GearScreen_LoopTradeItemsForward(game::ui::Anim*, int, game::ItemId, game::ItemId, int);
bool GearScreen_LoopTradeItemsBackward(game::ui::Anim*, int, game::ItemId, game::ItemId, int);
int GearScreen_GetTextIdFromItemId(game::ItemId);
int GearScreen_GetModelIdFromItemId(game::ItemId);
} // namespace gearscreen
} // namespace rnd

#endif
1 change: 1 addition & 0 deletions code/include/rnd/item_effect.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ namespace rnd {
void ItemEffect_FillWalletUpgrade(game::CommonData* comData, s16 arg1, s16 arg2);
void ItemEffect_GiveRemains(game::CommonData* comData, s16 mask, s16 arg2);
void ItemEffect_GiveMask(game::CommonData* comData, s16 mask, s16 arg2);
void ItemEffect_GiveTradeItem(game::CommonData* comData, s16 mask, s16 arg2);
} // namespace rnd

#endif //_ITEM_EFFECT_H_
Loading

0 comments on commit 892d905

Please sign in to comment.