mirror of
https://github.com/SMGCommunity/Petari.git
synced 2024-12-02 10:36:39 +00:00
start some work on JKR and JSU decompilng
This commit is contained in:
parent
858114c622
commit
1395e3ada2
@ -1,7 +1,7 @@
|
||||
#ifndef JKRDISPOSER_H
|
||||
#define JKRDISPOSER_H
|
||||
|
||||
#include "jsu/JSUPtrLink.h"
|
||||
#include "JSU/JSUList.h"
|
||||
|
||||
class JKRHeap;
|
||||
|
||||
@ -13,7 +13,7 @@ public:
|
||||
virtual ~JKRDisposer();
|
||||
|
||||
JKRHeap* mRootHeap; // _4
|
||||
JSUPtrLink mPointerLinks; // _8
|
||||
JSULink<JKRDisposer> mPointerLinks; // _8
|
||||
};
|
||||
|
||||
#endif // JKRDISPOSER_H
|
15
include/JKR/JKRHeap.h
Normal file
15
include/JKR/JKRHeap.h
Normal file
@ -0,0 +1,15 @@
|
||||
#ifndef JKRHEAP_H
|
||||
#define JKRHEAP_H
|
||||
|
||||
#include "JSU/JSUList.h"
|
||||
|
||||
class JKRHeap
|
||||
{
|
||||
public:
|
||||
static JKRHeap* findFromRoot(void *);
|
||||
|
||||
u8 _0[0x5C];
|
||||
JSUPtrList mPtrList; // _5C
|
||||
};
|
||||
|
||||
#endif // JKRHEAP_H
|
46
include/JSU/JSUList.h
Normal file
46
include/JSU/JSUList.h
Normal file
@ -0,0 +1,46 @@
|
||||
#ifndef JSULIST_H
|
||||
#define JSULIST_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
class JSUPtrLink;
|
||||
|
||||
class JSUPtrList
|
||||
{
|
||||
public:
|
||||
JSUPtrList(bool hasBeenInit);
|
||||
~JSUPtrList();
|
||||
|
||||
void initiate();
|
||||
void setFirst(JSUPtrLink* link);
|
||||
void append(JSUPtrLink* link);
|
||||
void prepend(JSUPtrLink* link);
|
||||
void remove(JSUPtrLink* link);
|
||||
|
||||
JSUPtrLink* mFirst; // _0
|
||||
JSUPtrLink* mNext; // _4
|
||||
u32 mNumPtrs; // _8
|
||||
};
|
||||
|
||||
class JSUPtrLink
|
||||
{
|
||||
public:
|
||||
JSUPtrLink(void *);
|
||||
~JSUPtrLink();
|
||||
|
||||
void* mPtr; // _0
|
||||
JSUPtrList* mPtrList; // _4
|
||||
u32 _8;
|
||||
JSUPtrLink* _C;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class JSULink : public JSUPtrLink
|
||||
{
|
||||
public:
|
||||
inline JSULink(void* ptr) : JSUPtrLink(ptr) { }
|
||||
|
||||
~JSULink();
|
||||
};
|
||||
|
||||
#endif // JSULIST_H
|
@ -1,20 +0,0 @@
|
||||
#ifndef JSUPTRLINK_H
|
||||
#define JSUPTRLINK_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
class JSUPtrList;
|
||||
|
||||
class JSUPtrLink
|
||||
{
|
||||
public:
|
||||
JSUPtrLink(void *);
|
||||
~JSUPtrLink();
|
||||
|
||||
void* mPtr; // _0
|
||||
JSUPtrList* mPtrList; // _4
|
||||
u32 _8;
|
||||
u32 _C;
|
||||
};
|
||||
|
||||
#endif // JSUPTRLINK_H
|
@ -1,24 +0,0 @@
|
||||
#ifndef JSUPTRLIST_H
|
||||
#define JSUPTRLIST_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
class JSUPtrLink;
|
||||
|
||||
class JSUPtrList
|
||||
{
|
||||
public:
|
||||
JSUPtrList(bool isInitiated);
|
||||
~JSUPtrList();
|
||||
|
||||
void initiate();
|
||||
void setFirst(JSUPtrLink* link);
|
||||
void append(JSUPtrLink* link);
|
||||
void prepend(JSUPtrLink* link);
|
||||
|
||||
u32 _0;
|
||||
u32 _4;
|
||||
u32 mNumPtrs; // _8
|
||||
};
|
||||
|
||||
#endif // JSUPTRLIST_H
|
26
source/JKR/JKRDisposer.cpp
Normal file
26
source/JKR/JKRDisposer.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
#include "JKR/JKRDisposer.h"
|
||||
#include "JKR/JKRHeap.h"
|
||||
|
||||
JKRDisposer::JKRDisposer() : mPointerLinks(this)
|
||||
{
|
||||
JKRHeap* heap = JKRHeap::findFromRoot(this);
|
||||
this->mRootHeap = heap;
|
||||
|
||||
if (heap != 0)
|
||||
{
|
||||
heap->mPtrList.append(&this->mPointerLinks);
|
||||
}
|
||||
}
|
||||
|
||||
JKRDisposer::~JKRDisposer()
|
||||
{
|
||||
if (this)
|
||||
{
|
||||
JKRHeap* heap = this->mRootHeap;
|
||||
|
||||
if (heap != 0)
|
||||
{
|
||||
heap->mPtrList.remove(&this->mPointerLinks);
|
||||
}
|
||||
}
|
||||
}
|
63
source/JSU/JSUList.cpp
Normal file
63
source/JSU/JSUList.cpp
Normal file
@ -0,0 +1,63 @@
|
||||
#include "JSU/JSUList.h"
|
||||
|
||||
JSUPtrLink::JSUPtrLink(void* ptr)
|
||||
{
|
||||
u32 val = 0;
|
||||
this->mPtr = ptr;
|
||||
this->mPtrList = 0;
|
||||
this->_8 = 0;
|
||||
this->_C = 0;
|
||||
}
|
||||
|
||||
JSUPtrLink::~JSUPtrLink()
|
||||
{
|
||||
if (!this)
|
||||
{
|
||||
if (this->mPtrList != 0)
|
||||
{
|
||||
this->mPtrList->remove(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JSUPtrList::JSUPtrList(bool hasBeenInit)
|
||||
{
|
||||
if (hasBeenInit != 0)
|
||||
{
|
||||
this->initiate();
|
||||
}
|
||||
}
|
||||
|
||||
JSUPtrList::~JSUPtrList()
|
||||
{
|
||||
if (this != 0)
|
||||
{
|
||||
JSUPtrLink* curLink = this->mFirst;
|
||||
u32 curIdx = 0;
|
||||
|
||||
while(curIdx < this->mNumPtrs)
|
||||
{
|
||||
curLink->mPtrList = 0;
|
||||
curIdx++;
|
||||
curLink = curLink->_C;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void JSUPtrList::initiate()
|
||||
{
|
||||
this->mFirst = 0;
|
||||
this->mNext = 0;
|
||||
this->mNumPtrs = 0;
|
||||
}
|
||||
|
||||
void JSUPtrList::setFirst(JSUPtrLink *link)
|
||||
{
|
||||
link->mPtrList = this;
|
||||
u32 defaultCount = 1;
|
||||
link->_8 = 0;
|
||||
link->_C = 0;
|
||||
this->mNext = link;
|
||||
this->mFirst = link;
|
||||
this->mNumPtrs = defaultCount;
|
||||
}
|
Loading…
Reference in New Issue
Block a user