Scaffold (?) JSTObjectSystem.cpp

This commit is contained in:
HeartPiece 2024-05-14 23:56:40 +10:00
parent d318357056
commit fcdee93317
6 changed files with 206 additions and 114 deletions

View File

@ -183,7 +183,7 @@
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/loadResource.cpp">loadResource.cpp</a> | 9618 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/JSTObjectParticleActor.cpp">JSTObjectParticleActor.cpp</a> | 10472 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/sysMaterialAnim.cpp">sysMaterialAnim.cpp</a> | 13329 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/resourceMgr.cpp">resourceMgr.cpp</a> | 14299 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/sysShape.cpp">sysShape.cpp</a> | 15279 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/sysShapeModel.cpp">sysShapeModel.cpp</a> | 16170 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/JSTObjectSystem.cpp">JSTObjectSystem.cpp</a> | 18053 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/titleSection.cpp">titleSection.cpp</a> | 19547 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/titleSection.cpp">titleSection.cpp</a> | 19547 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/JSTObjectSystem.cpp">JSTObjectSystem.cpp</a> | 22482 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/JSTObjectActor.cpp">JSTObjectActor.cpp</a> | 22505 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/matMath.cpp">matMath.cpp</a> | 26236 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/moviePlayer.cpp">moviePlayer.cpp</a> | 26325 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/memoryCard.cpp">memoryCard.cpp</a> | 32750 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/system.cpp">system.cpp</a> | 32972 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/sysGCU/windowMessage.cpp">windowMessage.cpp</a> | 37900 |

View File

@ -33,7 +33,7 @@ struct ObjectSystem : public JStage::TSystem, public ObjectBase {
// _00 = VTABLE (JStage::TSystem)
// _04 = VTABLE2 (ObjectBase)
// _04-_20 = ObjectBase
JGadget::TList_pointer_void mListPointerVoid; // _20
JGadget::TList_pointer<JStage::TObject*> mObjListPointer; // _20
};
} // namespace P2JST

View File

@ -8,7 +8,7 @@ template <typename T>
struct TAllocator {
static TAllocator get() { }
inline TAllocator() { }
// inline TAllocator() { }
u8 _00; // _00
};

View File

@ -9,6 +9,8 @@ namespace JGadget {
template <typename Element, typename Allocator>
struct TList {
struct iterator : std::iterator<std::input_iterator_tag, Element> {
iterator(Element* elem) { mElement = elem; }
Element* mElement;
};
~TList() { } // unused/inlined
@ -50,8 +52,18 @@ struct TList_pointer_void : public TList<void*, TVoidAllocator> {
void* mPrev; // _0C
};
// template <typename Iterator, typename Value>
// void findUpperBound_binary_current(Iterator, Iterator, Iterator, const Value&);
template <typename T>
struct TList_pointer : public TList_pointer_void {
TList_pointer(const TVoidAllocator& allocator)
: TList_pointer_void(allocator)
{
}
~TList_pointer() { }
// _00-_10 = TList_pointer_void
};
template <typename Iterator, typename Value, typename Predicate>
void findUpperBound_binary_current(Iterator, Iterator, Iterator, const Value&, Predicate);

View File

@ -3,24 +3,6 @@
#include "Dolphin/gx.h"
#include "JSystem/JStudio/TObject.h"
#include "types.h"
/*
__vt__Q26JStage7TObject:
.4byte 0
.4byte 0
.4byte 0
.4byte 0
.4byte JSGGetName__Q26JStage7TObjectCFv
.4byte JSGUpdate__Q26JStage7TObjectFv
.4byte JSGGetFlag__Q26JStage7TObjectCFv
.4byte JSGSetFlag__Q26JStage7TObjectFUl
.4byte JSGGetData__Q26JStage7TObjectCFUlPvUl
.4byte JSGSetData__Q26JStage7TObjectFUlPCvUl
.4byte JSGGetParent__Q26JStage7TObjectCFPPQ26JStage7TObjectPUl
.4byte JSGSetParent__Q26JStage7TObjectFPQ26JStage7TObjectUl
.4byte JSGSetRelation__Q26JStage7TObjectFbPQ26JStage7TObjectUl
.4byte JSGFindNodeID__Q26JStage7TObjectCFPCc
.4byte JSGGetNodeTransformation__Q26JStage7TObjectCFUlPA4_f
*/
namespace JStage {
struct TObject {

View File

@ -1,9 +1,15 @@
#include "Game/P2JST/ObjectSystem.h"
#include "nans.h"
#include "Game/P2JST/ObjectActor.h"
#include "Game/P2JST/ObjectCamera.h"
namespace Game {
namespace P2JST {
// NB: this file is probably not (as) terrible if we work out JGadget::TList<>::iterator.
// I assume it's probably similar to TLinkList::iterator, but haven't throughly checked.
// Have attempted things as best I can without that struct properly done + some guesses on what will end up going where.
// Please forgive me for not doing it, godspeed to the next sorry soul in here - HP.
/**
* @note Address: N/A
* @note Size: 0xE4
@ -19,99 +25,15 @@ namespace P2JST {
*/
ObjectSystem::ObjectSystem(char const* name, MoviePlayer* player)
: ObjectBase(name, player)
, mListPointerVoid(JGadget::TVoidAllocator())
, mObjListPointer(JGadget::TVoidAllocator())
{
/*
stwu r1, -0x20(r1)
mflr r0
lis r6, __vt__Q26JStage7TObject@ha
li r8, 0
stw r0, 0x24(r1)
addi r0, r6, __vt__Q26JStage7TObject@l
lis r6, __vt__Q34Game5P2JST10ObjectBase@ha
addi r9, r1, 8
stw r31, 0x1c(r1)
mr r31, r3
mr r7, r31
lis r3, __vt__Q26JStage7TSystem@ha
stw r0, 0(r31)
addi r0, r3, __vt__Q26JStage7TSystem@l
li r7, -1
lis r3, __vt__Q34Game5P2JST12ObjectSystem@ha
stw r0, 0(r31)
addi r0, r6, __vt__Q34Game5P2JST10ObjectBase@l
addi r6, r3, __vt__Q34Game5P2JST12ObjectSystem@l
addi r3, r31, 0x20
stw r0, 4(r31)
addi r0, r6, 0x50
stw r5, 8(r31)
stw r4, 0xc(r31)
mr r4, r9
stw r8, 0x10(r31)
stw r7, 0x14(r31)
stw r8, 0x18(r31)
stw r8, 0x1c(r31)
stw r6, 0(r31)
stw r0, 4(r31)
lbz r0, lbl_805161F8@sda21(r13)
stb r0, 8(r1)
bl "__ct__Q27JGadget18TList_pointer_voidFRCQ27JGadget14TAllocator<Pv>"
lwz r0, 0x24(r1)
mr r3, r31
lwz r31, 0x1c(r1)
mtlr r0
addi r1, r1, 0x20
blr
*/
}
/**
* @note Address: 0x804309F4
* @note Size: 0x84
*/
ObjectSystem::~ObjectSystem()
{
destroyObjectAll();
/*
stwu r1, -0x10(r1)
mflr r0
stw r0, 0x14(r1)
stw r31, 0xc(r1)
mr r31, r4
stw r30, 8(r1)
or. r30, r3, r3
beq lbl_80430A5C
lis r4, __vt__Q34Game5P2JST12ObjectSystem@ha
addi r4, r4, __vt__Q34Game5P2JST12ObjectSystem@l
stw r4, 0(r30)
addi r0, r4, 0x50
stw r0, 4(r30)
bl destroyObjectAll__Q34Game5P2JST12ObjectSystemFv
addic. r0, r30, 0x20
beq lbl_80430A40
addi r3, r30, 0x20
li r4, 0
bl __dt__Q27JGadget18TList_pointer_voidFv
lbl_80430A40:
mr r3, r30
li r4, 0
bl __dt__Q26JStage7TSystemFv
extsh. r0, r31
ble lbl_80430A5C
mr r3, r30
bl __dl__FPv
lbl_80430A5C:
lwz r0, 0x14(r1)
mr r3, r30
lwz r31, 0xc(r1)
lwz r30, 8(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
ObjectSystem::~ObjectSystem() { destroyObjectAll(); }
/**
* @note Address: 0x80430A78
@ -119,6 +41,14 @@ lbl_80430A5C:
*/
void ObjectSystem::destroyObjectAll()
{
// AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
JGadget::TList<void*, JGadget::TVoidAllocator>::iterator iter(&mObjListPointer.mNext);
while (mObjListPointer.mChildCount) {
if (static_cast<JGadget::TList_pointer<JStage::TObject*>*>(*iter.mElement)->mNext) {
static_cast<JStage::TObject*>(static_cast<JGadget::TList_pointer<JStage::TObject*>*>(*iter.mElement)->mNext)->~TObject();
}
mObjListPointer.erase(iter);
}
/*
stwu r1, -0x30(r1)
mflr r0
@ -178,6 +108,28 @@ lbl_80430AF4:
*/
void ObjectSystem::reset()
{
JGadget::TList<void*, JGadget::TVoidAllocator>::iterator iterStart(&mObjListPointer.mNext);
JGadget::TList<void*, JGadget::TVoidAllocator>::iterator iterEnd((void**)mObjListPointer.mNext);
while (iterStart.mElement != iterEnd.mElement) {
JStage::TObject* obj = static_cast<JStage::TObject*>((void*)iterStart.mElement);
switch (obj->JSGFGetType()) {
case JStage::TEO_Camera:
static_cast<ObjectCamera*>(obj)->reset();
break;
case JStage::TEO_Actor:
static_cast<ObjectActor*>(obj)->reset();
break;
default:
obj->JSGFGetType(); // debug probably
break;
case JStage::TEO_AmbientLight:
case JStage::TEO_Light:
case JStage::TEO_Fog:
break;
}
// ++iterStart; // probably something like this
}
/*
stwu r1, -0x30(r1)
mflr r0
@ -263,6 +215,18 @@ lbl_80430BEC:
*/
void ObjectSystem::entry()
{
JGadget::TList<void*, JGadget::TVoidAllocator>::iterator iterStart(&mObjListPointer.mNext);
JGadget::TList<void*, JGadget::TVoidAllocator>::iterator iterEnd((void**)mObjListPointer.mNext);
while (iterStart.mElement != iterEnd.mElement) {
JStage::TObject* obj = static_cast<JStage::TObject*>((void*)iterStart.mElement);
switch (obj->JSGFGetType()) {
case JStage::TEO_Actor:
static_cast<ObjectActor*>(obj)->entry();
break;
}
// ++iterStart; // probably something like this
}
/*
stwu r1, -0x30(r1)
mflr r0
@ -324,6 +288,24 @@ lbl_80430C98:
*/
void ObjectSystem::update()
{
JGadget::TList<void*, JGadget::TVoidAllocator>::iterator iterStart(&mObjListPointer.mNext);
JGadget::TList<void*, JGadget::TVoidAllocator>::iterator iterEnd((void**)mObjListPointer.mNext);
while (iterStart.mElement != iterEnd.mElement) {
JStage::TObject* obj = static_cast<JStage::TObject*>((void*)iterStart.mElement);
switch (obj->JSGFGetType()) {
default:
// probably some DEBUG thing to make this spawn
break;
case JStage::TEO_Actor:
static_cast<ObjectActor*>(obj)->update();
break;
case JStage::TEO_Camera:
static_cast<ObjectCamera*>(obj)->update();
break;
}
// ++iterStart; // probably something like this
}
/*
stwu r1, -0x30(r1)
mflr r0
@ -397,6 +379,24 @@ lbl_80430D6C:
*/
void ObjectSystem::start()
{
JGadget::TList<void*, JGadget::TVoidAllocator>::iterator iterStart(&mObjListPointer.mNext);
JGadget::TList<void*, JGadget::TVoidAllocator>::iterator iterEnd((void**)mObjListPointer.mNext);
while (iterStart.mElement != iterEnd.mElement) {
JStage::TObject* obj = static_cast<JStage::TObject*>((void*)iterStart.mElement);
switch (obj->JSGFGetType()) {
default:
// probably some DEBUG thing to make this spawn
break;
case JStage::TEO_Actor:
static_cast<ObjectActor*>(obj)->start();
break;
case JStage::TEO_Camera:
static_cast<ObjectCamera*>(obj)->start();
break;
}
// ++iterStart; // probably something like this
}
/*
stwu r1, -0x30(r1)
mflr r0
@ -470,6 +470,24 @@ lbl_80430E40:
*/
void ObjectSystem::stop()
{
JGadget::TList<void*, JGadget::TVoidAllocator>::iterator iterStart(&mObjListPointer.mNext);
JGadget::TList<void*, JGadget::TVoidAllocator>::iterator iterEnd((void**)mObjListPointer.mNext);
while (iterStart.mElement != iterEnd.mElement) {
JStage::TObject* obj = static_cast<JStage::TObject*>((void*)iterStart.mElement);
switch (obj->JSGFGetType()) {
default:
// probably some DEBUG thing to make this spawn
break;
case JStage::TEO_Actor:
static_cast<ObjectActor*>(obj)->stop();
break;
case JStage::TEO_Camera:
static_cast<ObjectCamera*>(obj)->stop();
break;
}
// ++iterStart; // probably something like this
}
/*
stwu r1, -0x30(r1)
mflr r0
@ -541,8 +559,33 @@ lbl_80430F14:
* @note Address: 0x80430F3C
* @note Size: 0xFC
*/
JStage::TObject* ObjectSystem::findObject(char const*, JStage::TEObject) const
JStage::TObject* ObjectSystem::findObject(const char* name, JStage::TEObject type) const
{
JGadget::TList<void*, JGadget::TVoidAllocator>::iterator iterStart((void**)&mObjListPointer.mNext);
JGadget::TList<void*, JGadget::TVoidAllocator>::iterator iterEnd((void**)mObjListPointer.mNext);
while (iterStart.mElement != iterEnd.mElement) {
// ++iterStart; // probably
if (iterStart.mElement != iterEnd.mElement) {
JStage::TObject* obj = static_cast<JStage::TObject*>((void*)iterStart.mElement);
bool check;
if (!obj) {
check = false;
} else {
check = (strcmp(obj->JSGGetName(), name) == 0);
}
if (check) {
continue;
}
}
break;
}
if (iterStart.mElement != iterEnd.mElement) {
return static_cast<JStage::TObject*>((void*)iterStart.mElement);
}
return nullptr;
/*
stwu r1, -0x60(r1)
mflr r0
@ -628,9 +671,62 @@ lbl_80431020:
* @note Address: 0x80431038
* @note Size: 0x310
*/
int ObjectSystem::JSGFindObject(JStage::TObject**, char const*, JStage::TEObject) const
int ObjectSystem::JSGFindObject(JStage::TObject** outObject, const char* name, JStage::TEObject type) const
{
JUT_PANICLINE(449, "JSGFindObject---- %d not found\n");
JStage::TObject* obj = findObject(name, type);
const void* newObj = obj;
if (obj) {
*outObject = obj;
return 0;
}
switch (type) {
case JStage::TEO_Actor:
if (name[0] == '@') {
newObj = new ObjectParticleActor(name, mMoviePlayer, nullptr);
} else if (name[0] == '+') {
newObj = new ObjectSpecialActor(name, mMoviePlayer);
} else if (name[0] == '*') {
Creature* actor = findCreature(name);
if (actor) {
newObj = new ObjectGameActor(name, mMoviePlayer, actor);
}
} else if (name[0] == 'p') {
newObj = new ObjectActor(name, mMoviePlayer);
}
break;
case JStage::TEO_Camera:
newObj = new ObjectCamera(name, mMoviePlayer);
break;
default:
JGadget::TList<void*, JGadget::TVoidAllocator>::iterator iterStart((void**)obj);
JGadget::TList<void*, JGadget::TVoidAllocator>::iterator iterEnd((void**)obj);
while (iterStart.mElement != iterEnd.mElement) {
JStage::TObject* obj = static_cast<JStage::TObject*>((void*)iterStart.mElement);
obj->JSGGetName(); // debug probably
// ++iterStart; // probably, eventually
}
JUT_PANICLINE(449, "JSGFindObject---- %d not found\n");
break;
case JStage::TEO_AmbientLight:
case JStage::TEO_Light:
case JStage::TEO_Fog:
break;
}
if (newObj) {
JGadget::TList<void*, JGadget::TVoidAllocator>::iterator iterStart((void**)obj);
void* const& val = &newObj;
// mObjListPointer.insert(iterStart, 0, val);
}
*outObject = *(JStage::TObject**)newObj;
if (!*(JStage::TObject**)newObj) {
return 2;
}
return 0;
/*
.loc_0x0:
stwu r1, -0xB0(r1)
@ -894,7 +990,7 @@ char* ObjectSystem::JSGGetName() const { return const_cast<char*>(mName); }
* @note Address: 0x80431350
* @note Size: 0x8
*/
void ObjectSystem::JSGSetFlag(u32 a1) { mFlags = a1; }
void ObjectSystem::JSGSetFlag(u32 flag) { mFlags = flag; }
/**
* @note Address: 0x80431358
@ -915,3 +1011,5 @@ void ObjectSystem::JSGSetData(u32 d1, void const* d2, u32 d3)
} // namespace P2JST
} // namespace Game
#include "nans.h"