Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
21cbf14
refactor: Update actor and model structures for improved memory manag…
PhlexPlexico May 31, 2025
e020758
refactor: Simplify model matrix handling and enhance scaling logic
PhlexPlexico May 31, 2025
11fa24a
Update TexAnim_Spawn
HylianFreddy Jun 3, 2025
a6891e8
Use phony build recipe in Makefile
HylianFreddy Jun 3, 2025
789e887
Merge branch 'makefile-update' into model-cleanup
HylianFreddy Jun 3, 2025
9f3247f
Update Model_SetMatrix and override Remains models
HylianFreddy Jun 5, 2025
8f38c24
fix: Update item table to ensure models are being correctly drawn.
PhlexPlexico Jun 5, 2025
f737e44
fix: Adjust scaling for deku nut.
PhlexPlexico Jun 5, 2025
b9c5c07
Include drawing items for Obj_Moon_Stone
PhlexPlexico Jun 9, 2025
292ed43
Update scaling for MoonStone.,
PhlexPlexico Jun 9, 2025
c5e625f
Start off fish heart piece model drawing.
PhlexPlexico Jun 9, 2025
1fffbe3
Adjust scaling for fish heart piece.
PhlexPlexico Jun 9, 2025
b7fe48a
Update some work on en_mag to see if we can edit the cmb through code…
PhlexPlexico Jun 12, 2025
6cdc553
Include dm_char03 drawing for overhead item.
PhlexPlexico Jun 14, 2025
6012e23
Fix applying scale to second model
HylianFreddy Jun 14, 2025
c3bfe88
Override dm_char05 overhead models
HylianFreddy Jun 14, 2025
cbcc855
Move scale adjustment for dm_char03 (#101)
PhlexPlexico Jun 14, 2025
d1b0245
Update to grab object ID from the function call in ASM instead.
PhlexPlexico Jun 19, 2025
f39f327
Comment out pointer to addr 0x1F15B4 for now.
PhlexPlexico Jun 19, 2025
02b0861
Comment out print in hopes that race condition and crashing is fixed.
PhlexPlexico Jun 21, 2025
39c071a
Formatting.
PhlexPlexico Jun 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions 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 source/rnd/actors
SOURCES := source source/asm source/asm/actors source/lib source/common source/game source/rnd source/game/ui/screens source/rnd/actors
DATA := data
INCLUDES := include
GRAPHICS := gfx
Expand Down Expand Up @@ -61,13 +61,13 @@ endif
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft -mfpu=vfpv2

CFLAGS := -g -Wall -O2 -mword-relocations -D DEBUG \
-ffunction-sections \
-ffunction-sections -fomit-frame-pointer \
$(ARCH)

CFLAGS += $(INCLUDE) -D__3DS__ $(VERFLAGS)

CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++17 -Wno-invalid-offsetof \
-Wno-array-bounds
-Wno-array-bounds

ASFLAGS := -g $(ARCH)
LDFLAGS = -g $(ARCH) -Wl,-Map,$(notdir $*.map) -T $(TOPDIR)/$(LINK_SCRIPT)
Expand Down Expand Up @@ -193,11 +193,10 @@ ifneq ($(ROMFS),)
export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
endif

.PHONY: all clean
.PHONY: all clean $(BUILD)

#---------------------------------------------------------------------------------
all: $(BUILD)
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile

$(BUILD):
@[ -d $@ ] || mkdir -p $@
Expand Down Expand Up @@ -240,7 +239,7 @@ else
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT).elf : $(OFILES)
$(OUTPUT).elf : $(OFILES) $(TOPDIR)/$(LINK_SCRIPT)
#$(OUTPUT).3dsx : $(OUTPUT).elf $(_3DSXDEPS)

#$(OFILES_SOURCES) : $(HFILES)
Expand Down
24 changes: 22 additions & 2 deletions code/include/game/actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ namespace game::act {
BossGyorg = 0x00CD,
// Great Fairy
NpcGreatFairy = 0x00D2,
// Boss Remains
DmHina = 0x00DC,
// [4] Kafei
NpcKafei = 0x00F4,
// Koume (Boat Lady)
Expand All @@ -72,6 +74,10 @@ namespace game::act {
EnGinkoMan = 0x010F,
// Deku Butler
EnDno = 0x0117,
// Happy Mask Salesman (Cutscenes)
DmChar03 = 0x12B,
// Masks (Cutscenes)
DmChar05 = 0x012D,
// Ice platform created using ice arrows.
BgIcePlatform = 0x013E,
// Npc For Curiosity Shop Owner
Expand All @@ -80,6 +86,8 @@ namespace game::act {
EnShn = 0x0158,
// NPC Postman
NpcEnPm = 0x0166,
// Fish Heart Piece
FishHeart = 0x016A,
// Goht
BossGoht = 0x016E,
// Postbox
Expand Down Expand Up @@ -116,6 +124,8 @@ namespace game::act {
NpcEnBjt = 0x020C,
// [4] Bombers
NpcBombers = 0x020F,
// Moon Stone
ObjMoonStone = 0x0212,
// Keaton
EnKitan = 0x021B,
// [6] Sheikah Hint Stone (MM3D)
Expand Down Expand Up @@ -349,15 +359,25 @@ namespace game::act {
};
static_assert(sizeof(DayTimerActor) == 0x20C);

typedef struct SA_TextureAnimation {
/* 0x00 */ char gap_00[0x14];
/* 0x10 */ f32 animSpeed;
/* 0x18 */ s8 animMode;
// ... size unknown
} SA_TextureAnimation;
static_assert(offsetof(SA_TextureAnimation, animMode) == 0x18);

struct sa_unk_d4 {
void* field_00;
void* field_04;
float field_08;
int field_0c;
float field_10;
float field_14;
z3d_nn_math_MTX34* mtx;
u8 gap_1C[184];
z3d_nn_math_MTX34 mtx;
u8 gap_48[0x50];
SA_TextureAnimation* texAnim;
u8 gap_9C[0x38];
};
static_assert(sizeof(sa_unk_d4) == 0xD4);

Expand Down
3 changes: 2 additions & 1 deletion code/include/game/as.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include "common/types.h"
#include "common/utils.h"
#include "game/actor.h"

namespace game::as {

Expand Down Expand Up @@ -52,7 +53,7 @@ namespace game::as {
int field_28;
int field_2C;
int field_30;
void* field_34;
game::act::sa_unk_d4* field_34;
int field_38;
State state;
u8 gap_64[24];
Expand Down
4 changes: 1 addition & 3 deletions code/include/game/camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,7 @@ namespace game {
u16 field_148;
u16 field_14A;
u16 field_14C;
__attribute__((packed)) __attribute__((aligned(1))) int field_14E;
u16 field_152;
u16 field_154;
z3dVec3s cam_dir;
CameraState state;
CameraMode mode;
u16 field_15A;
Expand Down
3 changes: 1 addition & 2 deletions code/include/rnd/actors/dm_char03.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ namespace rnd {
void* skelAnimeModel;
};
static_assert(sizeof(Dm_Char03) == 0x29C);
extern "C" float rDmChar03Scale;
void Dm_Char03_Init(game::act::Actor* actor, game::GlobalContext* gctx);
void Dm_Char03_Draw(game::act::Actor* actor, game::GlobalContext* gctx);
extern "C" s32 Dm_Char03_OverrideModelDraw(game::act::sa_unk_d4*, game::act::Actor*);
void Dm_Char03_Destroy(game::act::Actor* actor, game::GlobalContext* gctx);

} // namespace rnd
Expand Down
14 changes: 10 additions & 4 deletions code/include/rnd/actors/dm_char05.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,16 @@ namespace rnd {
};
static_assert(sizeof(Dm_Char05) == 0x2B8);

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

void DMChar05_Draw(game::act::Actor* actor, game::GlobalContext* gctx);
enum DmChar05Param {
DMCHAR05_GORON_MASK = 0x0,
DMCHAR05_ZORA_MASK = 0x1,
DMCHAR05_GIBDO_MASK = 0x2,
DMCHAR05_MAJORA_MASK = 0x3,
DMCHAR05_COUPLE_MASK = 0x4,
DMCHAR05_BOMBERS_NOTEBOOK = 0xD,
};

void DMChar05_Destroy(game::act::Actor* self, game::GlobalContext* gctx);
void Dm_Char05_Init(game::act::Actor* actor, game::GlobalContext* gctx);
void Dm_Char05_Destroy(game::act::Actor* self, game::GlobalContext* gctx);
} // namespace rnd
#endif
15 changes: 11 additions & 4 deletions code/include/rnd/actors/dm_hina.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef _RND_ACTORS_EN_DOOR_1_H_
#define _RND_ACTORS_EN_DOOR_1_H_
#ifndef _RND_ACTORS_DM_HINA_H_
#define _RND_ACTORS_DM_HINA_H_

#include "game/actor.h"
#include "rnd/models.h"
Expand All @@ -10,9 +10,16 @@ extern "C" {
}
#endif
namespace rnd {
struct Dm_Hina : public game::act::Actor {
void* next_fn;
u8 gap_1fc[60];
void* skel_anime_model;
void* multi_effect;
int gap_240;
};
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*);
extern "C" 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
37 changes: 37 additions & 0 deletions code/include/rnd/actors/en_mag.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#ifndef _RND_ACTOR_EN_MAG_H_
#define _RND_ACTOR_EN_MAG_H_

#include "game/actor.h"
#include "game/context.h"
#include "rnd/custom_models.h"
#include "rnd/models.h"
#include "rnd/objects.h"
#include "z3d/z3DVec.h"
namespace rnd {
struct En_Mag : public game::act::Actor {
u8 gap_1f8[36];
game::act::sa_unk_d4* skelAnime;
game::act::sa_unk_d4* field_220;
game::act::sa_unk_d4* field_224;
game::act::sa_unk_d4* field_228;
game::act::sa_unk_d4* field_22c;
u8 gap_230[54];
u8 field_266;
u8 gap_267[13];
u32 field_274;
u32 field_278;
u32 field_27c;
u8 gap_280[4];
u16 field_284;
u16 field_286;
u16 field_288;
u16 field_28a;
u32 field_28c;
u32 field_290;
};
static_assert(sizeof(En_Mag) == 0x294);

void En_Mag_rInit(game::act::Actor*, game::GlobalContext*);
} // namespace rnd

#endif //_TITLE_SCREEN_H_
28 changes: 28 additions & 0 deletions code/include/rnd/actors/fish_heart.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#ifndef _RND_ACTORS_FISH_HEART_H_
#define _RND_ACTORS_FISH_HEART_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 {
struct Fish_Heart : public game::act::Actor {
void* next_fn;
u8 gap_1fc[8];
float scale;
u8 gap_208[88];
game::act::sa_unk_d4* skelAnimeModel;
u8 field_264;
u8 gap_265[3];
};
static_assert(sizeof(Fish_Heart) == 0x268);
void Fish_Heart_Init(game::act::Actor* actor, game::GlobalContext* gctx);
extern "C" s32 Fish_Heart_OverrideModelDraw(game::act::sa_unk_d4*, game::act::Actor*);
void Fish_Heart_Destroy(game::act::Actor* actor, game::GlobalContext* gctx);

} // namespace rnd
#endif
27 changes: 27 additions & 0 deletions code/include/rnd/actors/obj_moon_stone.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#ifndef _RND_ACTORS_OBJ_MOONSTONE_H_
#define _RND_ACTORS_OBJ_MOONSTONE_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 {
struct Obj_Moon_Stone : public game::act::Actor {
u8 gap_1f8[88];
void* next_fn;
u32 field_254;
game::act::sa_unk_d4* skelAnimeModelOne;
game::act::sa_unk_d4* skelAnimeModelTwo;
game::act::sa_unk_d4* skelAnimeModelThree;
};
static_assert(sizeof(Obj_Moon_Stone) == 0x264);
void Obj_Moon_Stone_Init(game::act::Actor* actor, game::GlobalContext* gctx);
extern "C" s32 Obj_Moon_Stone_OverrideModelDraw(game::act::sa_unk_d4*, game::act::Actor*);
void Obj_Moon_Stone_Destroy(game::act::Actor* actor, game::GlobalContext* gctx);

} // namespace rnd
#endif
1 change: 0 additions & 1 deletion code/include/rnd/gfx.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "rnd/savefile.h"
#include "rnd/settings.h"
#include "rnd/spoiler_data.h"
#include "rnd/title_screen.h"
extern "C" {
#include <3ds/svc.h>
}
Expand Down
16 changes: 9 additions & 7 deletions code/include/rnd/models.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,26 @@ namespace rnd {
s32 objectBankIdx;
s32 objectBankIdx2;
u8 loaded;
void* saModel;
void* saModel2;
game::act::sa_unk_d4* saModel;
game::act::sa_unk_d4* saModel2;
z3d_nn_math_MTX34* hardcodedMtx; // used for actors that draw their models in unusual ways
f32 scale;
z3dVec3f posOffset;
} Model;

void* SkeletonAnimationModel_Spawn(game::act::Actor*, game::GlobalContext*, s16, s32);
void SkeletonAnimationModel_CopyMtx(void*, void*);
game::act::sa_unk_d4* SkeletonAnimationModel_Spawn(game::act::Actor*, game::GlobalContext*, s16, s32);
void SkeletonAnimationModel_CopyMtx(z3d_nn_math_MTX34* dst, z3d_nn_math_MTX34* src);
void TexAnim_Spawn(game::act::SA_TextureAnimation*, void*);
void SkeletonAnimationModel_SetMeshByDrawItemID(void* model, s32 drawItemId);
void SkeletonAnimationModel_Draw(void*, int);

void Model_SetScale(game::act::Actor*, float);
void Model_SetMtxAndModel(void*, void*);
void Model_InvertMatrix(void* mtx);
void Model_InvertMatrixByScale(void* mtx, float scale);
void Model_UpdateMatrixPosition(void* mtx, void* mtxTwo, void* scaleMtx);

void Model_GetObjectBankIndex(Model* model, game::act::Actor* actor, game::GlobalContext* globalCtx);
void Model_SetAnim(void* model, s16 objectId, u32 objectAnimIndex);
void Model_SetAnim(game::act::sa_unk_d4* model, s16 objectId, u32 objectAnimIndex);

void Model_Init(Model* model, game::GlobalContext* globalCtx);
void Model_Destroy(Model* model);
Expand All @@ -45,7 +47,7 @@ namespace rnd {
void Model_SpawnByActor(game::act::Actor* actor, game::GlobalContext* globalCtx, u16 baseItemId);
void Model_DestroyByActor(game::act::Actor* actor);
void Model_DestroyAll(void);
s32 Model_DrawByActor(game::act::Actor* actor);
s32 Model_DrawByActor(game::act::Actor* actor, z3d_nn_math_MTX34* hardcodedMtx = NULL);
Model* Model_GetOverrideSaModel(game::act::Actor* actor);
void Actor_Init();
} // namespace rnd
Expand Down
6 changes: 2 additions & 4 deletions code/include/rnd/objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,17 @@ namespace rnd {
// Extended Object to deal with spawning multiple actors without running out of standard game space.
typedef game::ActorResource::ObjectContext ExtendedObjectContext;
extern "C" ExtendedObjectContext rExtendedObjectCtx;
extern "C" s32 storedObjId;
extern "C" s32 rStoredObjId;
extern "C" s32 yPos;
extern "C" s32 xPos;
extern "C" s32 zPos;

void TexAnim_Spawn(void*, void*);

s32 Object_SpawnPersistent(void* objectCtx, s16 objectId);
s32 Object_GetSlot(void* objectCtx, s16 objectId);
void Object_Clear(void* objectCtx);
bool Object_IsLoaded(game::ActorResource::ObjectContext* objectCtx, s16 bankIdx);
void Object_UpdateBank(game::ActorResource::ObjectContext* objectCtx);
void* GAR_GetCMBByIndex(game::ObjectBank::ObjectBankArchive* objBankArchive, u32 objectAnimIdx);
void* GAR_GetCMABByIndex(game::ObjectBank::ObjectBankArchive* objBankArchive, u32 objectAnimIdx);

s32 ExtendedObject_Spawn(game::ActorResource::ObjectContext* objectCtx, s16 objectId);
extern "C" void ExtendedObject_Clear(game::ActorResource::ObjectContext* objectCtx);
Expand Down
23 changes: 0 additions & 23 deletions code/include/rnd/title_screen.h

This file was deleted.

Loading