Skip to content

Commit

Permalink
Finish testing models.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
PhlexPlexico committed Jun 21, 2024
1 parent e2322d2 commit d1efa9d
Show file tree
Hide file tree
Showing 13 changed files with 128 additions and 83 deletions.
9 changes: 8 additions & 1 deletion code/include/rnd/actors/dmchar05.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ namespace rnd {
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
19 changes: 19 additions & 0 deletions code/include/rnd/actors/item_b_heart.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef _RND_ACTORS_ITEM_B_HEART_H_
#define _RND_ACTORS_ITEM_B_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 {
extern "C" {
void ItemBHeart_Init(game::act::Actor*, game::GlobalContext*);
void ItemBHeart_Draw(game::act::Actor*, game::GlobalContext*);
void ItemBHeart_Destroy(game::act::Actor*, game::GlobalContext*);
}
} // namespace rnd
#endif
2 changes: 2 additions & 0 deletions code/include/rnd/models.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ namespace rnd {
typedef struct {
game::act::Actor* actor;
ItemRow* itemRow;
u16 baseItemId;
s16 objectId;
s32 objectBankIdx;
s32 objectBankIdx2;
u8 loaded;
void* saModel;
void* saModel2;
Expand Down
2 changes: 2 additions & 0 deletions code/include/rnd/objects.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#ifndef _RND_OBJECTS_H_
#define _RND_OBJECTS_H_
#define noop (void)0
#include "common/advanced_context.h"
#include "game/actor.h"
#include "game/actorresource.h"
#include "game/common_data.h"
#include "z3d/z3DVec.h"

namespace rnd {
// Extended Object to deal with spawning multiple actors without running out of standard game space.
typedef game::ActorResource::ObjectContext ExtendedObjectContext;
Expand Down
7 changes: 0 additions & 7 deletions code/mm.ld
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,6 @@ SECTIONS{
*(.patch_CheckMoTRequirement)
}

/* .patch_OverrideDmChar05Init 0x3C6CDC : {
*(.patch_OverrideDmChar05Init)
} */

.patch_OverrideItem00Init 0x3D018C : {
*(.patch_OverrideItem00Init)
Expand Down Expand Up @@ -472,10 +469,6 @@ SECTIONS{
*(.patch_OverrideGreatFairySpawn)
}

/* .patch_OverrideDmChar05Draw 0x404BA0 : {
*(.patch_OverrideDmChar05Draw)
} */

.patch_HMSGiveItem 0x41D018 : {
*(.patch_HMSGiveItem)
}
Expand Down
18 changes: 0 additions & 18 deletions code/source/asm/model_hooks.s
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@ hook_ModelSpawnGetObjectStatus:
pop {r1-r12, lr}
bx lr

.global hook_OverrideDmChar05Init
hook_OverrideDmChar05Init:
mov r5,#0x28C
push {r0-r12,lr}
bl SpawnDmChar05Model
pop {r0-r12, lr}
bx lr

.global hook_OverrideItem00Init
hook_OverrideItem00Init:
cpy r4,r0
Expand All @@ -24,16 +16,6 @@ hook_OverrideItem00Init:
pop {r0-r12, lr}
bx lr

.global hook_OverrideDmChar05Draw
hook_OverrideDmChar05Draw:
cpy r4,r0
push {r0-r12,lr}
bl DrawDmChar05Model
cmp r0,#0x0
pop {r0-r12, lr}
bxeq lr
pop {r4,r5,pc}

.global hook_OverrideItem00Draw
hook_OverrideItem00Draw:
cpy r4,r0
Expand Down
10 changes: 0 additions & 10 deletions code/source/asm/model_patches.s
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,11 @@ patch_ExtendedObjectClear:
patch_ModelSpawnGetObjectStatus:
bl hook_ModelSpawnGetObjectStatus

.section .patch_OverrideDmChar05Init
.global patch_OverrideDmChar05Init
patch_OverrideDmChar05Init:
bl hook_OverrideDmChar05Init

.section .patch_OverrideItem00Init
.global patch_OverrideItem00Init
patch_OverrideItem00Init:
bl hook_OverrideItem00Init

.section .patch_OverrideDmChar05Draw
.global patch_OverrideDmChar05Draw
patch_OverrideDmChar05Draw:
bl hook_OverrideDmChar05Draw

.section .patch_OverrideItem00Draw
.global patch_OverrideItem00Draw
patch_OverrideItem00Draw:
Expand Down
25 changes: 17 additions & 8 deletions code/source/rnd/actors/dmchar05.cpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
#include "rnd/actors/dmchar05.h"

namespace rnd {
// TODO: Crashes on game start, need to adjust calls in patch side maybe.
extern "C" {
void SpawnDmChar05Model(game::act::Actor* actor) {
Model_SpawnByActor(actor, rnd::GetContext().gctx, 0);
void DMChar05_Init(game::act::Actor* actor, game::GlobalContext* gctx) {
util::GetPointer<void(game::act::Actor*, game::GlobalContext*)>(0x3C6CD8)(actor, gctx);
// TODO: DETERMINE WHICH MASK AND WHATNOT FROM PARAMS.
if (actor->params != 0x03)
Model_SpawnByActor(actor, GetContext().gctx, 0x79);
}

u8 DrawDmChar05Model(game::act::Actor* actor) {
return Model_DrawByActor(actor);
void DMChar05_Draw(game::act::Actor* actor, game::GlobalContext* gctx) {
if (actor->params != 0x03) {
if (!Model_DrawByActor(actor)) {
util::GetPointer<void(game::act::Actor*, game::GlobalContext*)>(0x41D1C8)(actor, gctx);
}
} else {
util::GetPointer<void(game::act::Actor*, game::GlobalContext*)>(0x41D1C8)(actor, gctx);
}
}
void DmChar05_rDestroy(game::act::Actor* self, game::GlobalContext*) {
Model_DestroyByActor(self);
util::GetPointer<void(game::act::Actor*)>(0x3A9C50)(self);

void DMChar05_Destroy(game::act::Actor* self, game::GlobalContext* gctx) {
if(self->params != 0x03) Model_DestroyByActor(self);
util::GetPointer<void(game::act::Actor*)>(0x3C6F90)(self);
}
}

Expand Down
22 changes: 22 additions & 0 deletions code/source/rnd/actors/item_b_heart.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include "rnd/actors/item_b_heart.h"

namespace rnd {
extern "C" {
void ItemBHeart_Init(game::act::Actor* actor, game::GlobalContext* gctx) {
util::GetPointer<void(game::act::Actor*, game::GlobalContext*)>(0x464648)(actor, gctx);
Model_SpawnByActor(actor, rnd::GetContext().gctx, 0x0D);
}

void ItemBHeart_Draw(game::act::Actor* actor, game::GlobalContext*) {
if (!Model_DrawByActor(actor)) {
util::GetPointer<void(game::act::Actor*)>(0x4A779C)(actor);
}
}

void ItemBHeart_Destroy(game::act::Actor* self, game::GlobalContext* gctx) {
Model_DestroyByActor(self);
util::GetPointer<void(game::act::Actor*)>(0x4646F0)(self);
}
}

} // namespace rnd
4 changes: 2 additions & 2 deletions code/source/rnd/item_override.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ namespace rnd {
rItemOverrides[0].value.looksLikeItemId = 0x26;
rItemOverrides[1].key.scene = 0x6F;
rItemOverrides[1].key.type = ItemOverride_Type::OVR_COLLECTABLE;
rItemOverrides[1].value.getItemId = 0x59;
rItemOverrides[1].value.looksLikeItemId = 0x59;
rItemOverrides[1].value.getItemId = 0x80;
rItemOverrides[1].value.looksLikeItemId = 0x16;
rItemOverrides[2].key.scene = 0x12;
rItemOverrides[2].key.type = ItemOverride_Type::OVR_COLLECTABLE;
rItemOverrides[2].value.getItemId = 0x37;
Expand Down
Loading

0 comments on commit d1efa9d

Please sign in to comment.