mirror of
https://github.com/zeldaret/tp
synced 2026-06-23 01:10:09 -04:00
JKRDecomp OK (#58)
* JKRDecomp OK * clang-format tool * JKRThread cleanup and fixed suggestions Co-authored-by: Julgodis <> Co-authored-by: Pheenoh <pheenoh@gmail.com>
This commit is contained in:
@@ -2,38 +2,36 @@
|
||||
#include "JSystem/JKernel/JKRHeap/JKRHeap.h"
|
||||
#include "global.h"
|
||||
|
||||
// #include "JSystem/JKernel/JKRThread/asm/func_802D1568.s"
|
||||
JKRThread::JKRThread(u32 stack_size, int message_count, int param_3) : mThreadListLink(this) {
|
||||
this->mSwitchCount = 0;
|
||||
this->mCost = 0;
|
||||
this->field_0x6c = 0;
|
||||
this->field_0x60 = 0;
|
||||
this->field_0x70 = 0;
|
||||
mSwitchCount = 0;
|
||||
mCost = 0;
|
||||
field_0x6c = 0;
|
||||
field_0x60 = 0;
|
||||
field_0x70 = 0;
|
||||
|
||||
JKRHeap* heap = JKRHeap::findFromRoot(this);
|
||||
if (heap == NULL) {
|
||||
heap = lbl_80451370;
|
||||
}
|
||||
|
||||
this->setCommon_heapSpecified(heap, stack_size, param_3);
|
||||
this->setCommon_mesgQueue(this->mHeap, message_count);
|
||||
setCommon_heapSpecified(heap, stack_size, param_3);
|
||||
setCommon_mesgQueue(mHeap, message_count);
|
||||
}
|
||||
|
||||
// #include "JSystem/JKernel/JKRThread/asm/func_802D1610.s"
|
||||
JKRThread::JKRThread(JKRHeap* heap, u32 stack_size, int message_count, int param_4)
|
||||
: mThreadListLink(this) {
|
||||
this->mSwitchCount = 0;
|
||||
this->mCost = 0;
|
||||
this->field_0x6c = 0;
|
||||
this->field_0x60 = 0;
|
||||
this->field_0x70 = 0;
|
||||
mSwitchCount = 0;
|
||||
mCost = 0;
|
||||
field_0x6c = 0;
|
||||
field_0x60 = 0;
|
||||
field_0x70 = 0;
|
||||
|
||||
if (heap == NULL) {
|
||||
heap = lbl_80451374;
|
||||
}
|
||||
|
||||
this->setCommon_heapSpecified(heap, stack_size, param_4);
|
||||
this->setCommon_mesgQueue(this->mHeap, message_count);
|
||||
setCommon_heapSpecified(heap, stack_size, param_4);
|
||||
setCommon_mesgQueue(mHeap, message_count);
|
||||
}
|
||||
|
||||
asm JKRThread::JKRThread(OSThread* thread, int message_count) {
|
||||
@@ -46,43 +44,39 @@ asm JKRThread::~JKRThread() {
|
||||
#include "JSystem/JKernel/JKRThread/asm/func_802D1758.s"
|
||||
}
|
||||
|
||||
// #include "JSystem/JKernel/JKRThread/asm/func_802D1830.s"
|
||||
void JKRThread::setCommon_mesgQueue(JKRHeap* heap, int message_count) {
|
||||
this->mMessageCount = message_count;
|
||||
this->mMessages = (OSMessage*)JKRHeap::alloc(this->mMessageCount * sizeof(OSMessage), 0, heap);
|
||||
mMessageCount = message_count;
|
||||
mMessages = (OSMessage*)JKRHeap::alloc(mMessageCount * sizeof(OSMessage), 0, heap);
|
||||
|
||||
OSInitMessageQueue(&this->mQueue, this->mMessages, this->mMessageCount);
|
||||
lbl_8043428C.append(&this->mThreadListLink);
|
||||
OSInitMessageQueue(&mMessageQueue, mMessages, mMessageCount);
|
||||
lbl_8043428C.append(&mThreadListLink);
|
||||
|
||||
this->field_0x74 = (JKRHeap*)NULL;
|
||||
this->field_0x78 = (JKRHeap*)NULL;
|
||||
mCurrentHeap = NULL;
|
||||
mCurrentHeapError = NULL;
|
||||
}
|
||||
|
||||
// #include "JSystem/JKernel/JKRThread/asm/func_802D18A4.s"
|
||||
void JKRThread::setCommon_heapSpecified(JKRHeap* heap, u32 stack_size, int param_3) {
|
||||
this->mHeap = heap;
|
||||
this->mStackSize = stack_size & 0xffffffe0;
|
||||
this->mStackPtr = JKRHeap::alloc(this->mStackSize, 0x20, this->mHeap);
|
||||
this->mOSThread = (OSThread*)JKRHeap::alloc(sizeof(OSThread), 0x20, this->mHeap);
|
||||
mHeap = heap;
|
||||
mStackSize = stack_size & 0xffffffe0;
|
||||
mStackMemory = JKRAllocFromHeap(mHeap, mStackSize, 0x20);
|
||||
mThreadRecord = (OSThread*)JKRAllocFromHeap(mHeap, sizeof(OSThread), 0x20);
|
||||
|
||||
void* stackBase = (void*)((int)this->mStackPtr + this->mStackSize);
|
||||
OSCreateThread(this->mOSThread, start, this, stackBase, this->mStackSize, param_3, 1);
|
||||
void* stackBase = (void*)((int)mStackMemory + mStackSize);
|
||||
OSCreateThread(mThreadRecord, start, this, stackBase, mStackSize, param_3, 1);
|
||||
}
|
||||
|
||||
// #include "JSystem/JKernel/JKRThread/asm/func_802D1934.s"
|
||||
void* JKRThread::start(void* param) {
|
||||
JKRThread* thread = (JKRThread*)param;
|
||||
return thread->run();
|
||||
}
|
||||
|
||||
#ifdef NONMATCHING
|
||||
// #include "JSystem/JKernel/JKRThread/asm/func_802D1960.s"
|
||||
JKRThread* JKRThread::searchThread(OSThread* thread) {
|
||||
JSUList<JKRThread>* threadList = JKRThread::getList();
|
||||
JSUListIterator<JKRThread> iterator;
|
||||
for (iterator = threadList; iterator != threadList->getEnd(); iterator++) {
|
||||
JKRThread* jkrThread = iterator.getObject();
|
||||
if (jkrThread->mOSThread == thread) {
|
||||
if (jkrThread->mThreadRecord == thread) {
|
||||
return jkrThread;
|
||||
}
|
||||
}
|
||||
@@ -129,7 +123,6 @@ asm void JKRThreadSwitch::draw(JKRThreadName_* param_1, JUTConsole* param_2) {
|
||||
//
|
||||
//
|
||||
|
||||
// #include "JSystem/JKernel/JKRThread/asm/func_802D1E14.s"
|
||||
void* JKRThread::run() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user