diff --git a/asm/Kyoto/CFactoryStore.s b/asm/Kyoto/CFactoryStore.s index 1b7bd3e5..d82fccfa 100644 --- a/asm/Kyoto/CFactoryStore.s +++ b/asm/Kyoto/CFactoryStore.s @@ -3,8 +3,8 @@ .section .data .balign 8 -.global lbl_803EE3D8 -lbl_803EE3D8: +.global "__vt__31TObjOwnerParam" +"__vt__31TObjOwnerParam": # ROM: 0x3EB3D8 .4byte 0 .4byte 0 @@ -36,12 +36,12 @@ lbl_803EE3E4: /* 8033FA54 0033C9B4 93 E1 00 0C */ stw r31, 0xc(r1) /* 8033FA58 0033C9B8 7C 7F 1B 79 */ or. r31, r3, r3 /* 8033FA5C 0033C9BC 41 82 00 40 */ beq lbl_8033FA9C -/* 8033FA60 0033C9C0 3C 60 80 3F */ lis r3, lbl_803EE3D8@ha -/* 8033FA64 0033C9C4 38 03 E3 D8 */ addi r0, r3, lbl_803EE3D8@l +/* 8033FA60 0033C9C0 3C 60 80 3F */ lis r3, "__vt__31TObjOwnerParam"@ha +/* 8033FA64 0033C9C4 38 03 E3 D8 */ addi r0, r3, "__vt__31TObjOwnerParam"@l /* 8033FA68 0033C9C8 90 1F 00 00 */ stw r0, 0(r31) /* 8033FA6C 0033C9CC 41 82 00 20 */ beq lbl_8033FA8C -/* 8033FA70 0033C9D0 3C 60 80 3E */ lis r3, lbl_803D9C44@ha -/* 8033FA74 0033C9D4 38 03 9C 44 */ addi r0, r3, lbl_803D9C44@l +/* 8033FA70 0033C9D0 3C 60 80 3E */ lis r3, __vt__10IVParamObj@ha +/* 8033FA74 0033C9D4 38 03 9C 44 */ addi r0, r3, __vt__10IVParamObj@l /* 8033FA78 0033C9D8 90 1F 00 00 */ stw r0, 0(r31) /* 8033FA7C 0033C9DC 41 82 00 10 */ beq lbl_8033FA8C /* 8033FA80 0033C9E0 3C 60 80 3E */ lis r3, __vt__4IObj@ha diff --git a/asm/Kyoto/CSimplePool.s b/asm/Kyoto/CSimplePool.s index 8b4bfd57..21d59df3 100644 --- a/asm/Kyoto/CSimplePool.s +++ b/asm/Kyoto/CSimplePool.s @@ -718,12 +718,12 @@ __ct__11CSimplePoolFR8IFactory: /* 8034086C 0033D7CC 7C 7E 1B 79 */ or. r30, r3, r3 /* 80340870 0033D7D0 41 82 00 2C */ beq lbl_8034089C /* 80340874 0033D7D4 3C 60 80 3E */ lis r3, __vt__4IObj@ha -/* 80340878 0033D7D8 3C 80 80 3E */ lis r4, lbl_803D9C44@ha +/* 80340878 0033D7D8 3C 80 80 3E */ lis r4, __vt__10IVParamObj@ha /* 8034087C 0033D7DC 38 03 8D 6C */ addi r0, r3, __vt__4IObj@l -/* 80340880 0033D7E0 3C 60 80 3F */ lis r3, lbl_803EE3D8@ha +/* 80340880 0033D7E0 3C 60 80 3F */ lis r3, "__vt__31TObjOwnerParam"@ha /* 80340884 0033D7E4 90 1E 00 00 */ stw r0, 0(r30) -/* 80340888 0033D7E8 38 84 9C 44 */ addi r4, r4, lbl_803D9C44@l -/* 8034088C 0033D7EC 38 03 E3 D8 */ addi r0, r3, lbl_803EE3D8@l +/* 80340888 0033D7E8 38 84 9C 44 */ addi r4, r4, __vt__10IVParamObj@l +/* 8034088C 0033D7EC 38 03 E3 D8 */ addi r0, r3, "__vt__31TObjOwnerParam"@l /* 80340890 0033D7F0 90 9E 00 00 */ stw r4, 0(r30) /* 80340894 0033D7F4 90 1E 00 00 */ stw r0, 0(r30) /* 80340898 0033D7F8 93 FE 00 04 */ stw r31, 4(r30) diff --git a/asm/MetroidPrime/Factories/CCharacterFactory.s b/asm/MetroidPrime/Factories/CCharacterFactory.s index b4251803..0d3461f6 100644 --- a/asm/MetroidPrime/Factories/CCharacterFactory.s +++ b/asm/MetroidPrime/Factories/CCharacterFactory.s @@ -82,8 +82,8 @@ lbl_803D9C38: .4byte 0 .4byte sub_80034228 -.global lbl_803D9C44 -lbl_803D9C44: +.global __vt__10IVParamObj +__vt__10IVParamObj: # ROM: 0x3D6C44 .4byte 0 .4byte 0 @@ -829,11 +829,11 @@ sub_80032344: /* 800323AC 0002F30C 7C 7F 1B 79 */ or. r31, r3, r3 /* 800323B0 0002F310 41 82 00 2C */ beq lbl_800323DC /* 800323B4 0002F314 3C 60 80 3E */ lis r3, __vt__4IObj@ha -/* 800323B8 0002F318 3C 80 80 3E */ lis r4, lbl_803D9C44@ha +/* 800323B8 0002F318 3C 80 80 3E */ lis r4, __vt__10IVParamObj@ha /* 800323BC 0002F31C 38 03 8D 6C */ addi r0, r3, __vt__4IObj@l /* 800323C0 0002F320 3C 60 80 3E */ lis r3, lbl_803D9C38@ha /* 800323C4 0002F324 90 1F 00 00 */ stw r0, 0(r31) -/* 800323C8 0002F328 38 84 9C 44 */ addi r4, r4, lbl_803D9C44@l +/* 800323C8 0002F328 38 84 9C 44 */ addi r4, r4, __vt__10IVParamObj@l /* 800323CC 0002F32C 38 03 9C 38 */ addi r0, r3, lbl_803D9C38@l /* 800323D0 0002F330 90 9F 00 00 */ stw r4, 0(r31) /* 800323D4 0002F334 90 1F 00 00 */ stw r0, 0(r31) @@ -886,11 +886,11 @@ lbl_80032404: /* 80032488 0002F3E8 7C 7F 1B 79 */ or. r31, r3, r3 /* 8003248C 0002F3EC 41 82 00 2C */ beq lbl_800324B8 /* 80032490 0002F3F0 3C 60 80 3E */ lis r3, __vt__4IObj@ha -/* 80032494 0002F3F4 3C 80 80 3E */ lis r4, lbl_803D9C44@ha +/* 80032494 0002F3F4 3C 80 80 3E */ lis r4, __vt__10IVParamObj@ha /* 80032498 0002F3F8 38 03 8D 6C */ addi r0, r3, __vt__4IObj@l /* 8003249C 0002F3FC 3C 60 80 3E */ lis r3, lbl_803D9C38@ha /* 800324A0 0002F400 90 1F 00 00 */ stw r0, 0(r31) -/* 800324A4 0002F404 38 84 9C 44 */ addi r4, r4, lbl_803D9C44@l +/* 800324A4 0002F404 38 84 9C 44 */ addi r4, r4, __vt__10IVParamObj@l /* 800324A8 0002F408 38 03 9C 38 */ addi r0, r3, lbl_803D9C38@l /* 800324AC 0002F40C 90 9F 00 00 */ stw r4, 0(r31) /* 800324B0 0002F410 90 1F 00 00 */ stw r0, 0(r31) @@ -1035,8 +1035,8 @@ sub_800326a0: /* 800326AC 0002F60C 93 E1 00 0C */ stw r31, 0xc(r1) /* 800326B0 0002F610 7C 7F 1B 79 */ or. r31, r3, r3 /* 800326B4 0002F614 41 82 00 30 */ beq lbl_800326E4 -/* 800326B8 0002F618 3C 60 80 3E */ lis r3, lbl_803D9C44@ha -/* 800326BC 0002F61C 38 03 9C 44 */ addi r0, r3, lbl_803D9C44@l +/* 800326B8 0002F618 3C 60 80 3E */ lis r3, __vt__10IVParamObj@ha +/* 800326BC 0002F61C 38 03 9C 44 */ addi r0, r3, __vt__10IVParamObj@l /* 800326C0 0002F620 90 1F 00 00 */ stw r0, 0(r31) /* 800326C4 0002F624 41 82 00 10 */ beq lbl_800326D4 /* 800326C8 0002F628 3C 60 80 3E */ lis r3, __vt__4IObj@ha @@ -3011,8 +3011,8 @@ sub_80034228: /* 80034244 000311A4 38 03 9C 38 */ addi r0, r3, lbl_803D9C38@l /* 80034248 000311A8 90 1F 00 00 */ stw r0, 0(r31) /* 8003424C 000311AC 41 82 00 20 */ beq lbl_8003426C -/* 80034250 000311B0 3C 60 80 3E */ lis r3, lbl_803D9C44@ha -/* 80034254 000311B4 38 03 9C 44 */ addi r0, r3, lbl_803D9C44@l +/* 80034250 000311B0 3C 60 80 3E */ lis r3, __vt__10IVParamObj@ha +/* 80034254 000311B4 38 03 9C 44 */ addi r0, r3, __vt__10IVParamObj@l /* 80034258 000311B8 90 1F 00 00 */ stw r0, 0(r31) /* 8003425C 000311BC 41 82 00 10 */ beq lbl_8003426C /* 80034260 000311C0 3C 60 80 3E */ lis r3, __vt__4IObj@ha diff --git a/configure.py b/configure.py index 302fcc9f..64241c60 100755 --- a/configure.py +++ b/configure.py @@ -610,7 +610,7 @@ LIBS = [ ["Kyoto/Streams/CZipInputStream", True], ["Kyoto/Streams/CZipOutputStream", True], ["Kyoto/Streams/CZipSupport", True], - "Kyoto/CFactoryStore", + ["Kyoto/CFactoryStore", False], ["Kyoto/CObjectReference", True], "Kyoto/CSimplePool", ["Kyoto/CToken", True], diff --git a/include/Kyoto/CDvdFile.hpp b/include/Kyoto/CDvdFile.hpp index 439cf512..2fc991f5 100644 --- a/include/Kyoto/CDvdFile.hpp +++ b/include/Kyoto/CDvdFile.hpp @@ -17,7 +17,9 @@ public: static bool FileExists(const char*); static void DVDARAMXferCallback(long, DVDFileInfo*); + static void ARAMARAMXferCallback(u32 addr); void HandleDVDInterrupt(); + void HandleARAMInterrupt(); private: uchar pad[0x14]; diff --git a/include/Kyoto/CObjectReference.hpp b/include/Kyoto/CObjectReference.hpp index d86f03f7..8f7e6b2c 100644 --- a/include/Kyoto/CObjectReference.hpp +++ b/include/Kyoto/CObjectReference.hpp @@ -10,12 +10,6 @@ class IObjectStore; class CObjectReference { public: CObjectReference(const rstl::auto_ptr< IObj >& obj); - // : x0_refCount(0) - // , x2_locked(false) - // , x2_lockCount(0) - // , xc_objectStore(nullptr) - // , x10_object(obj.release()) - // , x14_params(CVParamTransfer::Null()) {} ~CObjectReference(); CObjectReference(IObjectStore& store, const rstl::auto_ptr< IObj >& obj, const SObjectTag& tag, CVParamTransfer xfer); diff --git a/include/Kyoto/CVParamTransfer.hpp b/include/Kyoto/CVParamTransfer.hpp index f5b341cd..bd302708 100644 --- a/include/Kyoto/CVParamTransfer.hpp +++ b/include/Kyoto/CVParamTransfer.hpp @@ -1,16 +1,30 @@ #ifndef _CVPARAMTRANSFER #define _CVPARAMTRANSFER +#include "Kyoto/IObj.hpp" #include -class IObj; +class IVParamObj : public IObj {}; + +template < typename T > +class TObjOwnerParam : public IVParamObj { +public: + T* GetData() const { return static_cast(x4_data); } + +private: + T* x4_data; +}; class CVParamTransfer { public: + template < typename T > + CVParamTransfer(TObjOwnerParam< T >* obj) : x0_obj(obj) {} static CVParamTransfer Null(); + const IVParamObj& operator*() const { return *x0_obj; } + private: - rstl::rc_ptr< unkptr > x0_; + rstl::rc_ptr< IVParamObj > x0_obj; }; #endif // _CVPARAMTRANSFER diff --git a/include/dolphin/arq.h b/include/dolphin/arq.h index 6fb79e6e..de43a3fc 100644 --- a/include/dolphin/arq.h +++ b/include/dolphin/arq.h @@ -9,6 +9,20 @@ extern "C" { #endif +typedef struct ARQRequest ARQRequest; +typedef void (*ARQCallback)(u32 pointerToARQRequest); + +struct ARQRequest { + ARQRequest* next; + u32 owner; + u32 type; + u32 priority; + u32 source; + u32 dest; + u32 length; + ARQCallback callback; +}; + void ARQInit(void); #ifdef __cplusplus diff --git a/src/Kyoto/CFactoryStore.cpp b/src/Kyoto/CFactoryStore.cpp new file mode 100644 index 00000000..6899f5d4 --- /dev/null +++ b/src/Kyoto/CFactoryStore.cpp @@ -0,0 +1,5 @@ +#include "Kyoto/IObjectStore.hpp" +#include "Kyoto/Alloc/CMemory.hpp" +#include "Kyoto/CObjectReference.hpp" + +TObjOwnerParam tmp; diff --git a/src/Kyoto/DolphinCDvdFile.cpp b/src/Kyoto/DolphinCDvdFile.cpp index 102605cf..59ba2c0f 100644 --- a/src/Kyoto/DolphinCDvdFile.cpp +++ b/src/Kyoto/DolphinCDvdFile.cpp @@ -1,8 +1,21 @@ #include "Kyoto/CDvdFile.hpp" #include "dolphin/dvd.h" +#include "dolphin/arq.h" +#include "dolphin/os.h" #include "string.h" +const char* tmp = "??(??)"; + +struct SDvdFileInfo : DVDFileInfo { + CDvdFile* x3c_file; +}; + +struct SAramCallback { + char data[0x5c]; + CDvdFile* x5c_file; +}; + const char* DecodeARAMFile(const char* filename) { if (!strncmp(filename, "aram:", 5)) { return filename + 5; @@ -13,5 +26,21 @@ const char* DecodeARAMFile(const char* filename) { void CDvdFile::DVDARAMXferCallback(s32 result, DVDFileInfo* info) { DVDClose(info); - reinterpret_cast(info->cb.userData)->HandleDVDInterrupt(); + reinterpret_cast< SDvdFileInfo* >(info)->x3c_file->HandleDVDInterrupt(); +} + +void CDvdFile::ARAMARAMXferCallback(u32 addr) { + reinterpret_cast< SAramCallback* >(addr)->x5c_file->HandleARAMInterrupt(); +} + +void CDvdFile::HandleARAMInterrupt() { + BOOL enabled = OSDisableInterrupts(); + + OSRestoreInterrupts(enabled); +} + +void CDvdFile::HandleDVDInterrupt() { + BOOL enabled = OSDisableInterrupts(); + + OSRestoreInterrupts(enabled); }