Skip to content

Commit

Permalink
Freestanding Items (#72)
Browse files Browse the repository at this point in the history
* Bring in beginning of modified work of model drawing.

Still tons to do, but at least this is a starting point.

* Port OoT3DR functions for model management

* Add in some matrices commands so we can properly flip drawn objects.

Add in CMB files for zelda2keep.

* Include model scale, and bool to flip object if necessary in item table.

* Set correct mesh for rupees

* Adjust player struct and include En_Item00

* Add functions to spawn objects

* Adjust context to properly align with object_context.

Update models with debug.

Adjust item table for adult/giant wallets.

* Update item table. Now compiles. Need to double check item values but should work.

TODO: Implement Extended Object Context

TODO: Fix loaded models not scaling/positioning properly.

* Add in some TODOs for what is still needed for extended object info.

* Include Object function calls.

Create IsLoaded as we do not have a built-in function from game. This may be due to in-lining.

* Move object spawn and extended objects to own files.

* Include rough layout for spawning into rExtendedContext.

Still needs some work as we're still crashing.

* Extended Object now properly spawning in items.

* Properly zero out extended object context.

* Models are now placing properly, but rotation is still failing.

Fix crash for intro scene with PoH on clock tower.

* Zora mask is now drawing properly.

* Overhaul of custom extended context. Things now properly destroy.

* Mass update item scalings

Still need to find remains IDs and a few other things/test all items.

* Rough in dmchar05 overrides.

Update models in item table.

Update todo models in item table.

* More model update, stubbing in saModel2 calls.

* Fix progressive models for bomb bag item get.

More work on models.

* Skeleton animation not spawning twice.

* Revert 17C spawn.

Fix dual model spawning by adjusting the storedObjectId to not revert. Thanks Freddy!!

* Comment out animiation texspawn for now since we don't know how it works.

* Finish testing models.

Rough in DMChar_05, animations and few other things still needed.

Add Item_B_heart calls - free standing containers now draw proper items.

Add small debug text to avoid race condition on gold dust spawning?

TODO: Refactor float sizes as they are incorrect.

* Finish rescaling items.

* Begin work on Dm_Hina models.

Start attempting to override the remains that sit in the portal.

Everything else seems to be working as intended.

* Linter.

* Update to begin work on Dm_Hina overrides.

* Bring in debug tooling to move the actors xyz coords.

Comment out En_Dina for now as we can continue to work on it later.

* Linter

---------

Co-authored-by: HylianFreddy <[email protected]>
  • Loading branch information
PhlexPlexico and HylianFreddy authored Jun 23, 2024
1 parent d01e2bb commit 3e4fa84
Show file tree
Hide file tree
Showing 28 changed files with 1,759 additions and 1,023 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 source/game/ui/screens
SOURCES := source source/asm source/lib source/common source/game source/rnd source/game/ui/screens source/rnd/actors
DATA := data
INCLUDES := include
GRAPHICS := gfx
Expand Down
60 changes: 46 additions & 14 deletions code/include/game/actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@

namespace game {
struct GlobalContext;
}
namespace ActorResource {
struct ActorResource;
}
} // namespace game

namespace game::act {

Expand Down Expand Up @@ -300,19 +303,8 @@ namespace game::act {
MainFunc* calc_fn;
MainFunc* draw_fn;
ActorOverlayInfo* overlay_info;
float field_14C;
float field_150;
float field_154;
int field_158;
float field_15C;
float field_160;
float field_164;
int field_168;
float field_16C;
float field_170;
float field_174;
int field_178;
void* field_17C;
float mtx[3][4];
game::ActorResource::ActorResource* field_17C;
char field_180[80];
int field_1D0;
u8 field_1D4;
Expand Down Expand Up @@ -355,6 +347,46 @@ namespace game::act {
};
static_assert(sizeof(DayTimerActor) == 0x20C);

typedef void (*SkeletonAnimationModelFunc)(struct SkeletonAnimationModel*);
struct SkeletonAnimationModel_VTable {
// u8 gap_00[4];
SkeletonAnimationModelFunc destroy_function;
u8 gap_4[4];
};

struct SkeletonAnimationModel_unk_10 {
void* unk_00;
void* unk_04;
s32 unk_08;
s32 unk_0C;
s32 unk_10;
};
static_assert(sizeof(SkeletonAnimationModel_unk_10) == 0x14);

struct SkeletonAnimationModel_unk_0C {
SkeletonAnimationModel_unk_10* unk_00;
void* cmabManager;
f32 curFrame;
f32 animSpeed;
s8 animMode;
u8 unk_11[0x87];
};
static_assert(sizeof(SkeletonAnimationModel_unk_0C) == 0x98);

struct SkeletonAnimationModel {
SkeletonAnimationModel_VTable* vtbl;
u8 unk_04[8];
SkeletonAnimationModel_unk_0C* unk_0C;
SkeletonAnimationModel_unk_10* unk_10;
void* unk_draw_struct_14;
u8 gap_18[100];
float mtx[3][4];
s8 field_AC;
u8 gap_AD[3];
};
static_assert(offsetof(SkeletonAnimationModel, field_AC) == 0xAC);
static_assert(sizeof(SkeletonAnimationModel) == 0xB0);

ActorOverlayInfo* GetActorOverlayInfoTable();

} // namespace game::act
Expand Down
4 changes: 2 additions & 2 deletions code/include/game/actorresource.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ namespace game::ActorResource {

struct ObjectContext {
u8 num;
char gap_01[7];
char gap_01[3];
ActorResource status[OBJECT_EXCHANGE_BANK_MAX];
};
static_assert(sizeof(ObjectContext) == 0x1838);
static_assert(sizeof(ObjectContext) == 0x1834);

u32 find(ActorResources*, int);
u32 loadActorResource(ActorResources*, u32);
Expand Down
11 changes: 8 additions & 3 deletions code/include/game/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,9 @@ namespace game {
float field_2A4;
u8 gap_2A8[228];
u8 field_38C;
u8 gap_38D[123];
u8 gap_38D[71];
z3d_nn_math_MTX34 some_global_mtx;
u8 gap_404[4];
Camera main_camera;
Camera other_cameras[3];
Camera* cameras[4];
Expand Down Expand Up @@ -312,10 +314,10 @@ namespace game {
u8 field_883A;
__attribute__((aligned(2))) u8 gap_883C[2];
u8 field_883E;
__attribute__((aligned(2))) u8 gap_8840[3064];
__attribute__((aligned(2))) u8 gap_8840[3060];
game::ActorResource::ActorResources* actors_spawn_stuff;
game::ActorResource::ObjectContext object_context;
u8 gap_AC74[5004];
u8 gap_AC6C[5012];
u32 field_C000;
u8 gap_C004[604];
u8 room_number;
Expand Down Expand Up @@ -464,8 +466,11 @@ namespace game {
static_assert(offsetof(GlobalContext, field_836E) == 0x836E);
static_assert(offsetof(GlobalContext, gap_8390) == 0x8390);
static_assert(offsetof(GlobalContext, field_C4C8) == 0xC4C8);
static_assert(offsetof(GlobalContext, gap_AC6C) == 0xAC6C);
static_assert(offsetof(GlobalContext, field_83CE) == 0x83CE);
static_assert(offsetof(GlobalContext, gap_8384) == 0x8384);
static_assert(offsetof(GlobalContext, gap_404) == 0x0404);
static_assert(offsetof(GlobalContext, object_context) == 0x9438);
static_assert(sizeof(GlobalContext) == 0x11030);

struct PersistentSceneCycleFlags {
Expand Down
39 changes: 31 additions & 8 deletions code/include/game/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -474,14 +474,37 @@ namespace game::act {
u8 gap_120C8[160];
u32 field_1168;
u8 gap_116C[492];
u32 field_1358;
u8 gap_135C[160];
u32 field_13FC;
u8 gap_1400[160];
u32 field_14A0;
u8 gap_14A4[860];
int field_12800;
u8 gap_1804[436];
u8 playerGfxFns1[0xa4];
u8 playerGfxFns2[0xa4];
u8 playerGfxFns3[0xa4];
u8 gap_12544[116];
u16 field_125B8;
u16 field_125BA;
u16 field_125BC;
u16 field_125BE;
u8 gap_125C0[32];
u32 field_125E0;
u8 gap_125E4[32];
u32 field_12604;
u8 gap_12608[32];
u32 field_12628;
u8 gap_1262C[68];
u32 field_12670;
void* object_fn_common0;
void* object_fns;
u32 field_1267C;
void* object_fn_goron;
void* object_fn_goron2;
z3d_nn_math_MTX34 mtx;
u8 gap_126B8[768];
// u32 field_1358;
// u8 gap_135C[160];
// u32 field_13FC;
// u8 gap_1400[160];
// u32 field_14A0;
// u8 gap_14A4[860];
// int field_12800;
// u8 gap_1804[436];
u32 field_19B8;
u32 field_129BC;
u8 gap_129C0[12];
Expand Down
18 changes: 18 additions & 0 deletions code/include/rnd/actors/dm_hina.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef _RND_ACTORS_EN_DOOR_1_H_
#define _RND_ACTORS_EN_DOOR_1_H_

#include "game/actor.h"
#include "rnd/models.h"
#if defined ENABLE_DEBUG || defined DEBUG_PRINT
#include "common/debug.h"
extern "C" {
#include <3ds/svc.h>
}
#endif
namespace rnd {
void Dm_Hina_Init(game::act::Actor*, game::GlobalContext*);
void Dm_Hina_Draw(game::act::Actor*, game::GlobalContext*);
void Dm_Hina_Draw(game::act::Actor*, game::GlobalContext*);
void Dm_Hina_Destroy(game::act::Actor*, game::GlobalContext*);
} // namespace rnd
#endif
26 changes: 26 additions & 0 deletions code/include/rnd/actors/dmchar05.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#ifndef _RND_ACTORS_DMCHAR05_H_
#define _RND_ACTORS_DMCHAR05_H_

#include "game/actor.h"
#include "rnd/models.h"
#if defined ENABLE_DEBUG || defined DEBUG_PRINT
#include "common/debug.h"
extern "C" {
#include <3ds/svc.h>
}
#endif
namespace rnd {
extern "C" {
void SpawnDmChar05Model(game::act::Actor*);
u8 DrawDmChar05Model(game::act::Actor*);
void DmChar05_rDestroy(game::act::Actor*, game::GlobalContext*);
void DMChar05_Init(game::act::Actor* actor, game::GlobalContext* gctx);

void DMChar05_Init(game::act::Actor* actor, game::GlobalContext* gctx);

void DMChar05_Draw(game::act::Actor* actor, game::GlobalContext* gctx);

void DMChar05_Destroy(game::act::Actor* self, game::GlobalContext* gctx);
}
} // namespace rnd
#endif
Loading

0 comments on commit 3e4fa84

Please sign in to comment.