some JSystem work and throw out NW4R

This commit is contained in:
shibbo 2022-08-24 00:23:57 -04:00
parent 08ee7e05cf
commit 521b51f2b0
30 changed files with 709 additions and 43 deletions

View File

@ -16,8 +16,8 @@ other_libs = [
"deps/EABI/PowerPC_EABI_Support/MetroTRK/TRK_Hollywood_Revolution.a",
"deps/EABI/PowerPC_EABI_Support/Msl/MSL_C/PPC_EABI/LIB/MSL_C.PPCEABI.bare.h.a",
"deps/EABI/PowerPC_EABI_Support/Runtime/Lib/Runtime.PPCEABI.H.a",
"build/nw4r/lyt/lyt_init.o",
"deps/NDEV/lib/NdevExi2A.a",
"deps/nw4r_lib/lyt_init.o",
"deps/RVL_SDK/RVL/lib/ai.a",
"deps/RVL_SDK/RVL/lib/base.a",
"deps/RVL_SDK/RVL/lib/bte.a",
@ -106,7 +106,7 @@ def main(compile_non_matching, use_ninja, clean_ninja, link):
default_compiler_path = pathlib.Path("GC/3.0a3/")
compiler_exceptions = {
#"source\JSystem\JKernel\JKRThread.cpp": "GC/2.5/"
#"source\JSystem\JKernel\JKRHeap.cpp": pathlib.Path("GC/1.2.5/")
}
compiler_flags = {
@ -120,7 +120,6 @@ def main(compile_non_matching, use_ninja, clean_ninja, link):
ppc_root = "deps/EABI/PowerPC_EABI_Support"
rvl_sdk_path = pathlib.Path("deps/RVL_SDK/include")
nw4r_path = pathlib.Path("deps/NW4R/Library/include")
trk_path = pathlib.Path(f"{ppc_root}/MetroTRK")
runtime_path = pathlib.Path(f"{ppc_root}/Runtime/Inc")
msl_c_path = pathlib.Path(f"{ppc_root}/MSL/MSL_C/PPC_EABI/Include")
@ -129,7 +128,7 @@ def main(compile_non_matching, use_ninja, clean_ninja, link):
msl_cpp_eabi_path = pathlib.Path(f"{ppc_root}/MSL/MSL_C++/PPC_EABI/Include")
facelib_path = pathlib.Path("deps/RVLFaceLib/include")
includes += f"-i {nw4r_path} -I- -i {facelib_path} -i {rvl_sdk_path} -I- -i {trk_path} -I- -i {runtime_path} -I- -i {msl_c_path} -I- -i {msl_c_common_path} -I- -i {msl_cpp_path} -I- -i {msl_cpp_eabi_path} "
includes += f"-i {facelib_path} -i {rvl_sdk_path} -I- -i {trk_path} -I- -i {runtime_path} -I- -i {msl_c_path} -I- -i {msl_c_common_path} -I- -i {msl_cpp_path} -I- -i {msl_cpp_eabi_path} "
flags += includes
tasks = list()
@ -171,7 +170,7 @@ def main(compile_non_matching, use_ninja, clean_ninja, link):
# Create main compiler rule and exception compilers.
nw.rule("cc", f"{compiler_path} $flags $in -o $out", "Compiling $in...")
exceptionsToRules = { "sample": "value" }
exceptionsToRules = { }
cc_num = 1
for exc in compiler_exceptions.values():
if not exc in exceptionsToRules.keys():
@ -185,6 +184,8 @@ def main(compile_non_matching, use_ninja, clean_ninja, link):
try:
if compiler_exceptions[source_path]:
rule = exceptionsToRules[compiler_exceptions[source_path]]
path = f"deps/Compilers/{compiler_exceptions[source_path]}/mwcceppc.exe "
nw.rule(f"{rule}", f"{path} $flags $in -o $out", "Compiling $in [With different compiler]...")
except:
pass
nw.build(build_path, rule, source_path, variables={ 'flags': flags })

View File

@ -1,25 +1,25 @@
Symbol Name, Object File, Library Archive, Matching
__ct__7JKRHeapFPvUlP7JKRHeapb,JKRHeap.o,JKernel.a,false
__dt__17JSULink<7JKRHeap>Fv,JKRHeap.o,JKernel.a,false
__dt__17JSULink<7JKRHeap>Fv,JKRHeap.o,JKernel.a,true
__dt__17JSUTree<7JKRHeap>Fv,JKRHeap.o,JKernel.a,false
__dt__22JSUList<11JKRDisposer>Fv,JKRHeap.o,JKernel.a,false
__dt__7JKRHeapFv,JKRHeap.o,JKernel.a,false
__dt__7JKRHeapFv,JKRHeap.o,JKernel.a,true
initArena__7JKRHeapFPPcPUli,JKRHeap.o,JKernel.a,false
becomeSystemHeap__7JKRHeapFv,JKRHeap.o,JKernel.a,false
becomeCurrentHeap__7JKRHeapFv,JKRHeap.o,JKernel.a,true
destroy__7JKRHeapFP7JKRHeap,JKRHeap.o,JKernel.a,false
alloc__7JKRHeapFUliP7JKRHeap,JKRHeap.o,JKernel.a,false
alloc__7JKRHeapFUliP7JKRHeap,JKRHeap.o,JKernel.a,true
alloc__7JKRHeapFUli,JKRHeap.o,JKernel.a,false
free__7JKRHeapFPvP7JKRHeap,JKRHeap.o,JKernel.a,false
free__7JKRHeapFPvP7JKRHeap,JKRHeap.o,JKernel.a,true
free__7JKRHeapFPv,JKRHeap.o,JKernel.a,false
callAllDisposer__7JKRHeapFv,JKRHeap.o,JKernel.a,false
callAllDisposer__7JKRHeapFv,JKRHeap.o,JKernel.a,true
freeAll__7JKRHeapFv,JKRHeap.o,JKernel.a,false
freeTail__7JKRHeapFv,JKRHeap.o,JKernel.a,false
resize__7JKRHeapFPvUl,JKRHeap.o,JKernel.a,false
getFreeSize__7JKRHeapFv,JKRHeap.o,JKernel.a,false
getMaxFreeBlock__7JKRHeapFv,JKRHeap.o,JKernel.a,false
getTotalFreeSize__7JKRHeapFv,JKRHeap.o,JKernel.a,false
findFromRoot__7JKRHeapFPv,JKRHeap.o,JKernel.a,false
findFromRoot__7JKRHeapFPv,JKRHeap.o,JKernel.a,true
find__7JKRHeapCFPv,JKRHeap.o,JKernel.a,false
findAllHeap__7JKRHeapCFPv,JKRHeap.o,JKernel.a,false
dispose_subroutine__7JKRHeapFUlUl,JKRHeap.o,JKernel.a,false

1 Symbol Name Object File Library Archive Matching
2 __ct__7JKRHeapFPvUlP7JKRHeapb JKRHeap.o JKernel.a false
3 __dt__17JSULink<7JKRHeap>Fv JKRHeap.o JKernel.a false true
4 __dt__17JSUTree<7JKRHeap>Fv JKRHeap.o JKernel.a false
5 __dt__22JSUList<11JKRDisposer>Fv JKRHeap.o JKernel.a false
6 __dt__7JKRHeapFv JKRHeap.o JKernel.a false true
7 initArena__7JKRHeapFPPcPUli JKRHeap.o JKernel.a false
8 becomeSystemHeap__7JKRHeapFv JKRHeap.o JKernel.a false
9 becomeCurrentHeap__7JKRHeapFv JKRHeap.o JKernel.a true
10 destroy__7JKRHeapFP7JKRHeap JKRHeap.o JKernel.a false
11 alloc__7JKRHeapFUliP7JKRHeap JKRHeap.o JKernel.a false true
12 alloc__7JKRHeapFUli JKRHeap.o JKernel.a false
13 free__7JKRHeapFPvP7JKRHeap JKRHeap.o JKernel.a false true
14 free__7JKRHeapFPv JKRHeap.o JKernel.a false
15 callAllDisposer__7JKRHeapFv JKRHeap.o JKernel.a false true
16 freeAll__7JKRHeapFv JKRHeap.o JKernel.a false
17 freeTail__7JKRHeapFv JKRHeap.o JKernel.a false
18 resize__7JKRHeapFPvUl JKRHeap.o JKernel.a false
19 getFreeSize__7JKRHeapFv JKRHeap.o JKernel.a false
20 getMaxFreeBlock__7JKRHeapFv JKRHeap.o JKernel.a false
21 getTotalFreeSize__7JKRHeapFv JKRHeap.o JKernel.a false
22 findFromRoot__7JKRHeapFPv JKRHeap.o JKernel.a false true
23 find__7JKRHeapCFPv JKRHeap.o JKernel.a false
24 findAllHeap__7JKRHeapCFPv JKRHeap.o JKernel.a false
25 dispose_subroutine__7JKRHeapFUlUl JKRHeap.o JKernel.a false

View File

@ -3345,7 +3345,7 @@ initSceneMessage__2MRFv,SystemUtil.o,Util.a,false
destroySceneMessage__2MRFv,SystemUtil.o,Util.a,false
resetSystemAndGameStatus__2MRFv,SystemUtil.o,Util.a,false
stopAllSound__2MRFUl,SystemUtil.o,Util.a,false
setLayoutDefaultAllocator__2MRFv,SystemUtil.o,Util.a,false
setLayoutDefaultAllocator__2MRFv,SystemUtil.o,Util.a,true
isDisplayEncouragePal60Window__2MRFv,SystemUtil.o,Util.a,false
getPlayerRestartIdInfo__2MRFv,SystemUtil.o,Util.a,false
setPlayerRestartIdInfo__2MRFRC10JMapIdInfo,SystemUtil.o,Util.a,false

1 Symbol Name Object File Library Archive Matching
3345 destroySceneMessage__2MRFv SystemUtil.o Util.a false
3346 resetSystemAndGameStatus__2MRFv SystemUtil.o Util.a false
3347 stopAllSound__2MRFUl SystemUtil.o Util.a false
3348 setLayoutDefaultAllocator__2MRFv SystemUtil.o Util.a false true
3349 isDisplayEncouragePal60Window__2MRFv SystemUtil.o Util.a false
3350 getPlayerRestartIdInfo__2MRFv SystemUtil.o Util.a false
3351 setPlayerRestartIdInfo__2MRFRC10JMapIdInfo SystemUtil.o Util.a false

View File

@ -1,5 +1,5 @@
Symbol Name, Object File, Library Archive, Matching
LytInit__Q24nw4r3lytFv,lyt_init.o,libnw4r_lyt.a,false
LytInit__Q24nw4r3lytFv,lyt_init.o,libnw4r_lyt.a,true
__ct__Q34nw4r3lyt4PaneFPCQ44nw4r3lyt3res4Pane,lyt_pane.o,libnw4r_lyt.a,false
__dt__Q34nw4r3lyt4PaneFv,lyt_pane.o,libnw4r_lyt.a,false
SetName__Q34nw4r3lyt4PaneFPCc,lyt_pane.o,libnw4r_lyt.a,false

1 Symbol Name Object File Library Archive Matching
2 LytInit__Q24nw4r3lytFv lyt_init.o libnw4r_lyt.a false true
3 __ct__Q34nw4r3lyt4PaneFPCQ44nw4r3lyt3res4Pane lyt_pane.o libnw4r_lyt.a false
4 __dt__Q34nw4r3lyt4PaneFv lyt_pane.o libnw4r_lyt.a false
5 SetName__Q34nw4r3lyt4PaneFPCc lyt_pane.o libnw4r_lyt.a false

View File

@ -1,6 +1,6 @@
{
"schemaVersion": 1,
"label": "Game",
"message": "8.258901435926987%",
"message": "8.259284324264303%",
"color": "blue"
}

View File

@ -1,6 +1,6 @@
{
"schemaVersion": 1,
"label": "NW4R",
"message": "0.0%",
"message": "0.14369782400437936%",
"color": "green"
}

View File

@ -1,6 +1,6 @@
{
"schemaVersion": 1,
"label": "Util",
"message": "9.46764%",
"message": "9.47287%",
"color": "ff6666"
}

View File

@ -1,6 +1,6 @@
{
"schemaVersion": 1,
"label": "libnw4r_lyt",
"message": "0.0%",
"message": "0.19905%",
"color": "ffff66"
}

View File

@ -40,7 +40,7 @@
| [JUtility](https://github.com/shibbo/Petari/blob/master/docs/lib/JUtility.md) | 4.0283311199645855% |
| [libnw4Fr_ut](https://github.com/shibbo/Petari/blob/master/docs/lib/libnw4Fr_ut.md) | 0.0% |
| [libnw4r_db](https://github.com/shibbo/Petari/blob/master/docs/lib/libnw4r_db.md) | 0.0% |
| [libnw4r_lyt](https://github.com/shibbo/Petari/blob/master/docs/lib/libnw4r_lyt.md) | 0.0% |
| [libnw4r_lyt](https://github.com/shibbo/Petari/blob/master/docs/lib/libnw4r_lyt.md) | 0.1990521327014218% |
| [libnw4r_math](https://github.com/shibbo/Petari/blob/master/docs/lib/libnw4r_math.md) | 0.0% |
| [libnw4r_ut](https://github.com/shibbo/Petari/blob/master/docs/lib/libnw4r_ut.md) | 0.0% |
| [LiveActor](https://github.com/shibbo/Petari/blob/master/docs/lib/LiveActor.md) | 38.87044721069618% |
@ -72,7 +72,7 @@
| [tpl](https://github.com/shibbo/Petari/blob/master/docs/lib/tpl.md) | 0.0% |
| [TRK_Hollywood_Revolution](https://github.com/shibbo/Petari/blob/master/docs/lib/TRK_Hollywood_Revolution.md) | 0.0% |
| [usb](https://github.com/shibbo/Petari/blob/master/docs/lib/usb.md) | 0.0% |
| [Util](https://github.com/shibbo/Petari/blob/master/docs/lib/Util.md) | 9.467641328085156% |
| [Util](https://github.com/shibbo/Petari/blob/master/docs/lib/Util.md) | 9.472872069150396% |
| [vf](https://github.com/shibbo/Petari/blob/master/docs/lib/vf.md) | 0.0% |
| [vi](https://github.com/shibbo/Petari/blob/master/docs/lib/vi.md) | 0.0% |
| [wenc](https://github.com/shibbo/Petari/blob/master/docs/lib/wenc.md) | 0.0% |

View File

@ -59,7 +59,7 @@
| StarPointerUtil.o | 0.0% | 0 / 108 | 0.0% | :x:
| StringUtil.o | 32.678821879382895% | 10 / 36 | 27.77777777777778% | :eight_pointed_black_star:
| SwitchEventFunctorListener.o | 100.0% | 5 / 5 | 100.0% | :white_check_mark:
| SystemUtil.o | 0.0% | 0 / 34 | 0.0% | :x:
| SystemUtil.o | 1.3937282229965158% | 1 / 34 | 2.941176470588235% | :eight_pointed_black_star:
| TalkUtil.o | 0.0% | 0 / 53 | 0.0% | :x:
| AreaObjUtil.o | 9.481481481481481% | 3 / 22 | 13.636363636363635% | :eight_pointed_black_star:
| BaseMatrixFollowTargetHolder.o | 25.97173144876325% | 9 / 25 | 36.0% | :eight_pointed_black_star:
@ -3689,7 +3689,7 @@
| destroySceneMessage__2MRFv | :x: |
| resetSystemAndGameStatus__2MRFv | :x: |
| stopAllSound__2MRFUl | :x: |
| setLayoutDefaultAllocator__2MRFv | :x: |
| setLayoutDefaultAllocator__2MRFv | :white_check_mark: |
| isDisplayEncouragePal60Window__2MRFv | :x: |
| getPlayerRestartIdInfo__2MRFv | :x: |
| setPlayerRestartIdInfo__2MRFRC10JMapIdInfo | :x: |

View File

@ -8,7 +8,7 @@
| Object | Percentage (of Bytes) | Functions Done / Total Functions | Percentage (Functions) | Status
| ------------- | ------------- | ------------- | ------------- | -------------
| lyt_init.o | 0.0% | 0 / 1 | 0.0% | :x:
| lyt_init.o | 100.0% | 1 / 1 | 100.0% | :white_check_mark:
| lyt_pane.o | 0.0% | 0 / 30 | 0.0% | :x:
| lyt_group.o | 0.0% | 0 / 4 | 0.0% | :x:
| lyt_layout.o | 0.0% | 0 / 17 | 0.0% | :x:
@ -28,7 +28,7 @@
# lyt_init.o
| Symbol | Decompiled? |
| ------------- | ------------- |
| LytInit__Q24nw4r3lytFv | :x: |
| LytInit__Q24nw4r3lytFv | :white_check_mark: |
# lyt_pane.o

View File

@ -1,6 +1,6 @@
#pragma once
#include <nw4r/lyt/drawInfo.h>
#include "nw4r/lyt/lyt_drawInfo.h"
class LayoutManager {
public:

View File

@ -1,6 +1,6 @@
#pragma once
#include <nw4r/ut/TagProcessorBase.h>
#include "nw4r/ut/TagProcessorBase.h"
class MessageTagSkipTagProcessor : public nw4r::ut::TagProcessorBase<wchar_t> {
public:

View File

@ -2,7 +2,7 @@
#include "Game/System/ResourceInfo.h"
#include "JSystem/JKernel/JKRArchive.h"
#include "nw4r/lyt/resourceAccessor.h"
#include "nw4r/lyt/lyt_resourceAccessor.h"
typedef const char* Something;

View File

@ -39,8 +39,19 @@ namespace MR {
public:
static void* alloc(MEMAllocator *, u32);
static void free(MEMAllocator *, void *);
static MEMAllocatorFunc sAllocatorFunc;
static MEMAllocator sAllocator;
};
MEMAllocatorFunc NewDeleteAllocator::sAllocatorFunc = {
NewDeleteAllocator::alloc,
NewDeleteAllocator::free,
};
MEMAllocator NewDeleteAllocator::sAllocator = { &sAllocatorFunc };
template<int T>
class JKRHeapAllocator {
public:

View File

@ -7,6 +7,27 @@ public:
JKRExpHeap(void *, u32, JKRHeap *, bool);
virtual ~JKRExpHeap();
virtual u32 getHeapType();
virtual bool check();
virtual bool dump_sort();
virtual bool dump();
virtual void do_destroy();
virtual void* do_alloc(u32, int);
virtual void do_free(void *);
virtual void do_freeAll();
virtual void do_freeTail();
virtual void do_fillFreeArea();
virtual s32 do_resize(void *, u32);
virtual s32 do_getSize(void *);
virtual s32 do_getFreeSize();
virtual void* do_getMaxFreeBlock();
virtual s32 do_getTotalFreeSize();
virtual s32 do_changeGroupID(u8);
virtual u8 do_getCurrentGroupId();
virtual void state_register(TState *, u32) const;
virtual bool state_compare(const TState &, const TState &) const;
static JKRExpHeap* create(void *, u32, JKRHeap *, bool);
static JKRExpHeap* create(u32, JKRHeap *, bool);

View File

@ -3,22 +3,64 @@
#include<revolution.h>
#include "JSystem/JSupport/JSUList.h"
#include "JSystem/JKernel/JKRDisposer.h"
#include "Inline.h"
// this inherits JKRDisposer
class JKRHeap {
class JKRHeap : public JKRDisposer {
public:
class TState {
public:
u32 _0;
u32 _4;
};
JKRHeap(void *, u32, JKRHeap *, bool);
virtual ~JKRHeap();
virtual void callAllDisposer();
virtual u32 getHeapType() = 0;
virtual bool check() = 0;
virtual bool dump_sort();
virtual bool dump() = 0;
virtual void do_destroy() = 0;
virtual void* do_alloc(u32, int) = 0;
virtual void do_free(void *) = 0;
virtual void do_freeAll() = 0;
virtual void do_freeTail() = 0;
virtual void do_fillFreeArea() = 0;
virtual s32 do_resize(void *, u32) = 0;
virtual s32 do_getSize(void *) = 0;
virtual s32 do_getFreeSize() = 0;
virtual void* do_getMaxFreeBlock() = 0;
virtual s32 do_getTotalFreeSize() = 0;
virtual s32 do_changeGroupID(u8);
virtual u8 do_getCurrentGroupId();
virtual void state_register(TState *, u32) const;
virtual bool state_compare(const TState &, const TState &) const;
virtual void state_dump(const TState &) const;
void* alloc(u32, int);
JKRHeap* becomeSystemHeap();
JKRHeap* becomeCurrentHeap();
void becomeSystemHeap();
void freeAll();
void freeTail();
s32 resize(void *, u32);
s32 getFreeSize();
void* getMaxFreeBlock();
void free(void *);
JKRHeap* find(void *) const;
JKRHeap* findAllHeap(void *) const;
void dispose_subroutine(u32, u32);
static JKRHeap* findFromRoot(void *);
static void* alloc(u32, int, JKRHeap *);
static void free(void *, JKRHeap *);
static void free(void *, JKRHeap *) NO_INLINE;
static void destroy(JKRHeap *);
@ -33,7 +75,25 @@ public:
static JKRHeap *sRootHeap; // _806B70B0
static JKRHeap *sSystemHeap;
u8 _0[0x5C];
static u32 ARALT_AramStartAddr;
inline void* getStartAddr() const {
return (void*)mStart;
}
inline void* getEndAddr() const {
return (void*)mEnd;
}
OSMutex mMutex; // _18
u8* mStart; // _30
u8* mEnd; // _34
u32 mSize; // _38
u8 _3C;
u8 _3D;
u8 _3E;
u8 _3F;
JSUTree<JKRHeap> mChildTree; // _40
JSUList<JKRDisposer> mDisposerList; // _5C
u8 _68;
u8 _69;
@ -41,11 +101,7 @@ public:
u8 _6B;
};
/*void * operator new(void * ptr, size_t) {
return ptr;
}*/
void* operator new(u32, JKRHeap *, int);
void* operator new[](u32, int);
void* operator new[](u32, JKRHeap *, int);
void* operator new[](u32, JKRHeap *, int);

View File

@ -1,6 +1,7 @@
#pragma once
#include <revolution.h>
#include "Inline.h"
class JSUPtrLink;
@ -20,6 +21,14 @@ public:
bool insert(JSUPtrLink *, JSUPtrLink *);
bool remove(JSUPtrLink *);
JSUPtrLink* getFirstLink() const {
return mHead;
}
u32 getNumLinks() const {
return mNodeCount;
}
JSUPtrLink *mHead; // _0
JSUPtrLink *mTail; // _4
u32 mNodeCount; // _8
@ -30,6 +39,18 @@ public:
JSUPtrLink(void *);
~JSUPtrLink();
void* getObjectPtr() const {
return mData;
}
JSUPtrList* getList() const {
return mPtrList;
}
JSUPtrLink* getNext() const {
return mNext;
}
void *mData; // _0
JSUPtrList *mPtrList; // _4
JSUPtrLink *mPrev; // _8
@ -43,7 +64,21 @@ public:
}
~JSULink();
~JSULink() NO_INLINE {
}
T* getObject() const {
return (T*)getObjectPtr();
}
JSULink<T>* getNext() const {
return (JSULink<T>*)this->JSUPtrLink::getNext();
}
JSULink<T>* getPrev() const {
return (JSULink<T>*)this->JSUPtrLink::getPrev();
}
};
template<class T>
@ -56,4 +91,186 @@ public:
JSUList(bool thing) : JSUPtrList(thing) {
}
~JSUList() NO_INLINE {
};
JSULink<T>* getFirst() const {
return (JSULink<T>*)getFirstLink();
}
JSULink<T>* getLast() const {
return (JSULink<T>*)getLastLink();
}
u32 getNumLinks() const {
return this->JSUPtrList::getNumLinks();
}
JSULink<T>* getEnd() const {
return NULL;
}
};
template<typename T>
class JSUListIterator {
public:
JSUListIterator() : mLink(NULL) {
}
JSUListIterator(JSULink<T>* link) : mLink(link) {
}
JSUListIterator(JSUList<T>* list) : mLink(list->getFirst()) {
}
JSUListIterator<T>& operator=(JSULink<T>* link) {
this->mLink = link;
return *this;
}
T* getObject() {
return this->mLink->getObject();
}
bool operator==(JSULink<T> const* other) const { return this->mLink == other; }
bool operator!=(JSULink<T> const* other) const { return this->mLink != other; }
bool operator==(JSUListIterator<T> const& other) const { return this->mLink == other.mLink; }
bool operator!=(JSUListIterator<T> const& other) const { return this->mLink != other.mLink; }
JSUListIterator<T> operator++(int) {
JSUListIterator<T> prev = *this;
this->mLink = this->mLink->getNext();
return prev;
}
JSUListIterator<T>& operator++() {
this->mLink = this->mLink->getNext();
return *this;
}
JSUListIterator<T> operator--(int) {
JSUListIterator<T> prev = *this;
this->mLink = this->mLink->getPrev();
return prev;
}
JSUListIterator<T>& operator--() {
this->mLink = this->mLink->getPrev();
return *this;
}
T& operator*() {
return *this->getObject();
}
T* operator->() {
return this->getObject();
}
JSULink<T>* mLink;
};
/* from https://github.com/zeldaret/tp/blob/master/include/JSystem/JSupport/JSUList.h */
template<typename T>
class JSUTree : public JSUList<T>, public JSULink<T> {
public:
JSUTree(T *pOwner) : JSUList<T>, JSULink<T>(pOwner) {
}
~JSUTree() NO_INLINE {
}
bool appendChild(JSUTree<T>* pChild) {
return this->append(pChild);
}
bool removeChild(JSUTree<T>* child) {
return this->remove(child);
}
JSUTree<T>* getEndChild() const {
return NULL;
}
JSUTree<T>* getFirstChild() const {
return (JSUTree<T>*)this->getFirst();
}
JSUTree<T>* getLastChild() const {
return (JSUTree<T>*)this->getLast();
}
JSUTree<T>* getNextChild() const {
return (JSUTree<T>*)this->getNext();
}
u32 getNumChildren() const {
return this->getNumLinks();
}
T* getObject() const {
return (T*)this->mData;
}
JSUTree<T>* getParent() const {
return (JSUTree<T>*)this->getList();
}
};
template<typename T>
class JSUTreeIterator {
public:
JSUTreeIterator() : mTree(NULL) {
}
JSUTreeIterator(JSUTree<T>* tree) : mTree(tree) {
}
T* getObject() {
return this->mTree->getObject();
}
JSUTreeIterator<T>& operator=(JSUTree<T>* tree) {
this->mTree = tree;
return *this;
}
bool operator==(JSUTree<T>* other) {
return this->mTree == other;
}
bool operator!=(JSUTree<T>* other) {
return this->mTree != other;
}
JSUTreeIterator<T> operator++(int) NO_INLINE {
JSUTreeIterator<T> prev = *this;
this->mTree = this->mTree->getNextChild();
return prev;
}
JSUTreeIterator<T>& operator++() NO_INLINE {
this->mTree = this->mTree->getNextChild();
return *this;
}
T& operator*() {
return *this->getObject();
}
T* operator->() {
return this->getObject();
}
JSUTree<T>* mTree; // _0
};

View File

@ -0,0 +1,28 @@
#pragma once
#include <revolution.h>
#include "nw4r/ut/Rect.h"
namespace nw4r {
namespace lyt {
class DrawInfo {
public:
DrawInfo();
virtual ~DrawInfo();
Mtx mViewMtx; // _4
ut::Rect mViewRect; // _34
f32 _44;
f32 _48;
f32 mGlobalAlpha; // _4C
struct {
u8 mulViewDraw : 1;
u8 influencedAlpha : 1;
u8 locationAdjust : 1;
u8 invisiblePaneCalculateMtx : 1;
} mFlag; // _50
};
};
};

View File

@ -0,0 +1,7 @@
#pragma once
namespace nw4r {
namespace lyt {
void LytInit();
};
};

View File

@ -0,0 +1,14 @@
#pragma once
#include <revolution/mem.h>
namespace nw4r {
namespace lyt {
class Layout {
public:
static MEMAllocator* mspAllocator;
};
MEMAllocator* Layout::mspAllocator;
};
};

View File

@ -0,0 +1,14 @@
#pragma once
#include <revolution.h>
namespace nw4r {
namespace lyt {
class Pane {
public:
virtual ~Pane();
u8 _4[0xD0];
};
};
};

View File

@ -0,0 +1,21 @@
#pragma once
#include <revolution.h>
namespace nw4r {
namespace ut {
class Font;
};
namespace lyt {
class ResourceAccessor {
public:
ResourceAccessor();
virtual ~ResourceAccessor();
virtual void* GetResource(u32, const char *, u32 *) = 0;
virtual ut::Font* GetFont(const char *);
};
};
};

15
include/nw4r/ut/Rect.h Normal file
View File

@ -0,0 +1,15 @@
#pragma once
#include <revolution.h>
namespace nw4r {
namespace ut {
class Rect {
public:
f32 mLeft; // _0
f32 mTop; // _4
f32 mRight; // _8
f32 mBottom; // _C
};
};
};

View File

@ -0,0 +1,44 @@
#pragma once
#include "nw4r/ut/Rect.h"
#include <revolution.h>
namespace nw4r {
namespace ut {
template <typename T>
class TextWriterBase;
template<typename T>
class PrintContext {
TextWriterBase<T>* mWriter; // _0
const T* mString; // _4
f32 mXOrigin; // _8
f32 mYOrigin; // _C
u32 mFlags; // _10
};
template<typename T>
class TagProcessorBase {
public:
typedef PrintContext<T> ContextType;
enum Operation
{
OPERATION_DEFAULT,
OPERATION_NO_CHAR_SPACE,
OPERATION_CHAR_SPACE,
OPERATION_NEXT_LINE,
OPERATION_END_DRAW,
NUM_OF_OPERATION
};
TagProcessorBase();
virtual ~TagProcessorBase();
virtual Operation Process(u16, PrintContext<T> *);
virtual Operation CalcRect(Rect *, u16, PrintContext<T> *);
};
};
};

View File

@ -1,6 +1,5 @@
#include "Game/Screen/LayoutActor.h"
#include "Game/Screen/PaneEffectKeeper.h"
#include <nw4r/lyt/pane.h>
LayoutActor::LayoutActor(const char *pName, bool) : NameObj(pName),
mManager(NULL), mSpine(NULL), mPaneEffectKeeper(NULL), mStarPointerTargetKeeper(NULL) {

View File

@ -3,7 +3,7 @@
#include "Game/System/FileRipper.h"
#include "Game/System/HeapMemoryWatcher.h"
#include "Game/SingletonHolder.h"
#include "nw4r/lyt/init.h"
#include "nw4r/lyt/lyt_init.h"
#include "Game/Util.h"
void main(void) {
@ -24,7 +24,7 @@ void main(void) {
DVDInit();
VIInit();
HeapMemoryWatcher::createRootHeap();
//HeapMemoryWatcher::createRootHeap();
OSInitMutex(&MR::MutexHolder<0>::sMutex);
OSInitMutex(&MR::MutexHolder<1>::sMutex);
OSInitMutex(&MR::MutexHolder<2>::sMutex);
@ -37,9 +37,9 @@ void main(void) {
SingletonHolder<HeapMemoryWatcher>::sInstance->setCurrentHeapToStationedHeap();
JKRHeap* napaHeap = MR::getStationedHeapNapa();
FileRipper::setup(0x20000, napaHeap);
GameSystemException::init();
MR::initAcosTable();
//FileRipper::setup(0x20000, napaHeap);
//GameSystemException::init();
//MR::initAcosTable();
if (!SingletonHolder<GameSystem>::sInstance) {
SingletonHolder<GameSystem>::sInstance = new GameSystem();

View File

@ -0,0 +1,9 @@
#include "Game/Util/SystemUtil.h"
#include "Game/Util/MemoryUtil.h"
#include "nw4r/lyt/lyt_layout.h"
namespace MR {
void setLayoutDefaultAllocator() {
nw4r::lyt::Layout::mspAllocator = &MR::NewDeleteAllocator::sAllocator;
}
};

View File

@ -4,8 +4,188 @@ JKRHeap* JKRHeap::sCurrentHeap;
JKRHeap* JKRHeap::sRootHeap;
JKRHeap* JKRHeap::sSystemHeap;
static u32 ARALT_AramStartAddr = 0x90000000;
JKRHeap::~JKRHeap() {
JSUTree<JKRHeap>* tree = mChildTree.getParent();
tree->removeChild(&mChildTree);
JSUTree<JKRHeap>* next = sRootHeap->mChildTree.getFirstChild();
JKRHeap* root = sRootHeap;
JKRHeap* current = sCurrentHeap;
if (current == this) {
sCurrentHeap = next == NULL ? root : next->getObject();
}
JKRHeap* system = sSystemHeap;
if (system == this) {
sSystemHeap = next == NULL ? root : next->getObject();
}
}
JKRHeap* JKRHeap::becomeSystemHeap() {
JKRHeap* sys = sSystemHeap;
sSystemHeap = this;
return sys;
}
JKRHeap* JKRHeap::becomeCurrentHeap() {
JKRHeap* cur = sCurrentHeap;
sCurrentHeap = this;
sCurrentHeap = this;
return cur;
}
void JKRHeap::destroy(JKRHeap *pHeap) {
pHeap->do_destroy();
}
void* JKRHeap::alloc(u32 size, int align, JKRHeap *pHeap) {
if (pHeap != NULL) {
return pHeap->alloc(size, align);
}
if (JKRHeap::sCurrentHeap != NULL) {
return JKRHeap::sCurrentHeap->alloc(size, align);
}
return NULL;
}
void* JKRHeap::alloc(u32 size, int align) {
return do_alloc(size, align);
}
void JKRHeap::free(void *pData, JKRHeap *pHeap) {
if (!pHeap) {
pHeap = findFromRoot(pData);
if (!pHeap) {
return;
}
}
pHeap->do_free(pData);
}
void JKRHeap::free(void *pData) {
do_free(pData);
}
void JKRHeap::callAllDisposer() {
while (mDisposerList.mHead != NULL) {
reinterpret_cast<JKRDisposer*>(mDisposerList.mHead->mData)->~JKRDisposer();
}
}
void JKRHeap::freeAll() {
do_freeAll();
}
void JKRHeap::freeTail() {
do_freeTail();
}
s32 JKRHeap::resize(void *pData, u32 size) {
return do_resize(pData, size);
}
JKRHeap* JKRHeap::findFromRoot(void *pData) {
JKRHeap* root = sRootHeap;
if (root == NULL) {
return NULL;
}
if ((void*)root->mStart <= pData && pData < (void*)root->mEnd) {
return root->find(pData);
}
return root->findAllHeap(pData);
}
#ifdef NON_MATCHING
// some loading issues with the first line
JKRHeap* JKRHeap::find(void *pData) const {
if (getStartAddr() <= pData && pData < getEndAddr()) {
const JSUTree<JKRHeap>& tree = mChildTree;
if (tree.getNumChildren() != 0) {
JSUTreeIterator<JKRHeap> it;
for (it = tree.getFirstChild(); it != tree.getEndChild(); ++it) {
JKRHeap* childHeap = it.getObject();
JKRHeap* resHeap = childHeap->find(pData);
if (resHeap) {
return resHeap;
}
}
}
// this is to avoid returning a const JKRHeap ptr
return (JKRHeap*)this;
}
return NULL;
}
#endif
#ifdef NON_MATCHING
// shrug
void JKRHeap::dispose_subroutine(u32 start, u32 end) {
JSUListIterator<JKRDisposer> last_it;
JSUListIterator<JKRDisposer> next_it;
JSUListIterator<JKRDisposer> it = mDisposerList.getFirst();
for (; it != NULL; it = next_it) {
JKRDisposer* disp = it.getObject();
if ((void*)start <= disp && disp < (void*)end) {
disp->~JKRDisposer();
if (last_it == NULL) {
next_it = mDisposerList.getFirst();
}
else {
next_it = last_it;
next_it++;
}
}
else {
last_it = it;
next_it = it;
next_it++;
}
}
}
#endif
void* operator new(u32 size) {
return JKRHeap::alloc(size, 4, NULL);
}
void* operator new(u32 size, int align) {
return JKRHeap::alloc(size, align, NULL);
}
void* operator new(u32 size, JKRHeap *pHeap, int align) {
return JKRHeap::alloc(size, align, pHeap);
}
void* operator new[](u32 size) {
return JKRHeap::alloc(size, 4, NULL);
}
void* operator new[](u32 size, int align) {
return JKRHeap::alloc(size, align, NULL);
}
void* operator new[](u32 size, JKRHeap *pHeap, int align) {
return JKRHeap::alloc(size, align, pHeap);
}
void operator delete(void *pData) {
JKRHeap::free(pData, NULL);
}

View File

@ -0,0 +1,29 @@
#include "nw4r/lyt/lyt_init.h"
#include <revolution/os.h>
namespace {
static const char* NW4R_LYT_Version_ = "<< NW4R - LYT \tfinal build: Jul 17 2007 12:25:23 (0x4199_60831) >>";
};
namespace nw4r {
namespace lyt {
void LytInit() {
OSRegisterVersion(NW4R_LYT_Version_);
__asm {
li r3, 4
oris r3, r3, 4
mtspr 0x392, r3
li r3, 5
oris r3, r3, 5
mtspr 0x393, r3
li r3, 6
oris r3, r3, 6
mtspr 0x394, r3
li r3, 7
oris r3, r3, 7
mtspr 0x395, r3
};
}
};
};