decompile JASDvdThread

This commit is contained in:
SwareJonge 2023-05-28 20:12:00 +02:00
parent 4fa696813e
commit aae88727f5
12 changed files with 157 additions and 36 deletions

View File

@ -335,7 +335,8 @@ CFLAGS = [
]
JSYSTEM_SPEED = CFLAGS + [ "-O4,p" ]
JSYSTEM_RELEASE = CFLAGS + [ "-opt level=4, schedule"]
JSYSTEM_RELEASE = CFLAGS + ["-opt level=4, schedule"]
JAUDIO_RELEASE = CFLAGS + ["-opt level=4, schedule, speed"]
# confusion
MSL_C_DEBUG = [
@ -385,6 +386,7 @@ MSL_C_CFLAGS = ' '.join(MSL_C + LOCAL_CFLAGS)
JSYSTEM_SPEED_CFLAGS = ' '.join(JSYSTEM_SPEED + LOCAL_CFLAGS)
JSYSTEM_RELEASE_CFLAGS = ' '.join(JSYSTEM_RELEASE + LOCAL_CFLAGS)
JAUDIO_RELEASE_CFLAGS = ' '.join(JAUDIO_RELEASE + LOCAL_CFLAGS)
KANESHIGE_CFLAGS = ' '.join(BASE_GAME_CFLAGS + LOCAL_CFLAGS)
if (VERSION == "MarioClub"):
KANESHIGE_CFLAGS = ' '.join(KANESHIGE + LOCAL_CFLAGS)

View File

@ -248,6 +248,12 @@ libs/JSystem/JAudio/JASCalc.cpp:
.rodata: [0x80368090, 0x80368520]
.sdata2: [0x80417d10, 0x80417d48]
libs/JSystem/JAudio/JASDvdThread.cpp:
.text: [0x8008fd8c, 0x8008fee0]
.rodata: [0x80368520, 0x80368570]
.sbss: [0x80415a10, 0x80415a18]
.sdata2: [0x80417d48, 0x80417d60]
libs/JSystem/JAudio/JASReport.cpp:
.text: [0x80090df4, 0x80090ef0]
.bss: [0x803aec98, 0x803aecb0]

View File

@ -238,6 +238,10 @@ libs/JSystem/JAudio/JASCalc.cpp:
.rodata: [0x80332810, 0x80332c28]
.sdata2: [0x803d6cd8, 0x803d6d08]
libs/JSystem/JAudio/JASDvdThread.cpp:
.text: [0x800905c4, 0x8009067c]
.sbss: [0x803d4ca0, 0x803d4ca8]
libs/JSystem/JAudio/JASReport.cpp:
.text: [0x80091270, 0x8009136c]
.bss: [0x8036e7c8, 0x8036e7e0]

View File

@ -671,9 +671,15 @@ global:
0x80090084: pow2__7JASCalcFf
0x80090198: clamp<s,l>__7JASCalcFl
0x80332810: CUTOFF_TO_IIR_TABLE__7JASCalc
# JASDvdThread.cpp
0x800905c4: getThreadPointer__6JASDvdFv
0x800905cc: createThread__6JASDvdFliUl
# JASHeapCtrl.cpp
0x803d4ca8: JASDram
# JASReport.cpp
0x80091270: JASReport__FPCce
# JASTaskThread.cpp
0x80091498: __ct__13JASTaskThreadFiiUl
# JASSoundParams.cpp
0x80096134: combine__14JASSoundParamsFRC14JASSoundParamsRC14JASSoundParams
# Dolphin

View File

@ -578,7 +578,9 @@ class CSource(Source):
elif path.startswith("src/Kaneshige/"):
self.cflags = c.KANESHIGE_CFLAGS
if c.VERSION == "Release":
if path.startswith("libs/JSystem/"):
if (path.startswith("libs/JSystem/JAudio/")):
self.cflags = c.JAUDIO_RELEASE_CFLAGS
elif path.startswith("libs/JSystem/"):
self.cflags = c.JSYSTEM_RELEASE_CFLAGS
if path.endswith("JKRSolidHeap.cpp"):
self.cc = c.CC_1_3_2
@ -587,6 +589,8 @@ class CSource(Source):
self.cflags = c.DOL_CFLAGS
elif path.startswith("libs/JSystem/JKernel/"):
self.cflags = c.DOL_CFLAGS
elif path.startswith("libs/JSystem/JAudio/"):
self.cflags = c.JSYSTEM_SPEED_CFLAGS
elif path.startswith("libs/JSystem/"): # once i have a file for every library this can finally be removed
self.cflags = c.JSYSTEM_SPEED_CFLAGS

View File

@ -0,0 +1,8 @@
#ifndef JSYSTEM_JASHEAP_H
#define JSYSTEM_JASHEAP_H
#include <JSystem/JKernel/JKRHeap.h>
extern JKRHeap *JASDram;
#endif

View File

@ -0,0 +1,24 @@
#ifndef JSYSTEM_JASTASKTHREAD_H
#define JSYSTEM_JASTASKTHREAD_H
#include "JSystem/JKernel/JKRThread.h"
#include "types.h"
class JASTaskThread : public JKRThread
{
public:
JASTaskThread(int, int, u32);
void allocCallStack(void (*)(void *), void *);
void allocCallStack(void (*)(void *), void const *, u32);
void sendCmdMsg(void (*)(void *), void *);
int sendCmdMsg(void (*)(void *), void const *, u32);
void pause(bool);
virtual ~JASTaskThread();
virtual void *run();
/* 0x7C */ OSThreadQueue mpThreadQueue;
/* 0x84 */ bool field_0x84;
};
#endif /* JASTASKTHREAD_H */

View File

@ -0,0 +1,11 @@
#ifndef JSYSTEM_JASDVD_H
#define JSYSTEM_JASDVD_H
#include "types.h"
#include <JSystem/JAudio/JASTaskThread.h>
namespace JASDvd {
bool createThread(s32 threadPriority, int msgCount, u32 stackSize);
JASTaskThread *getThreadPointer();
};
#endif

View File

@ -9,7 +9,6 @@
#include "types.h"
struct JKRThread;
struct JUTFont;
struct JKRThreadName_ {
s32 id;
@ -121,12 +120,18 @@ struct JKRThread : public JKRDisposer
void setCurrentHeap(JKRHeap *heap)
{
if (!heap)
{
heap = JKRGetCurrentHeap();
/*
JKRHeap *curHeap;
if(heap) {
curHeap = heap;
}
else {
curHeap = JKRGetCurrentHeap();
}
mCurrentHeap = curHeap;
*/
mCurrentHeap = heap;
mCurrentHeap = heap ? heap : JKRGetCurrentHeap();
}
static JSUList<JKRThread> sThreadList;
@ -134,16 +139,16 @@ struct JKRThread : public JKRDisposer
// _00 = VTBL
// _00-_18 = JKRDisposer
JSULink<JKRThread> mThreadListLink; // _18
JKRHeap *mHeap; // _28
OSThread *mThreadRecord; // _2C
OSMessageQueue mMessageQueue; // _30
OSMessage *mMesgBuffer; // _50
s32 mMessageCount; // _54
void *mStackMemory; // _58
u32 mStackSize; // _5C
TLoad mLoadInfo; // _60
JKRHeap *mCurrentHeap; // _74
s32 mCurrentHeapError; // _78
JKRHeap *mHeap; // _28
OSThread *mThreadRecord; // _2C
OSMessageQueue mMessageQueue; // _30
OSMessage *mMesgBuffer; // _50
s32 mMessageCount; // _54
void *mStackMemory; // _58
u32 mStackSize; // _5C
TLoad mLoadInfo; // _60
JKRHeap *mCurrentHeap; // _74
s32 mCurrentHeapError; // _78
};
/**

View File

@ -4,6 +4,8 @@
#include <JSystem/JUtility/JUTAssert.h>
#include <JSystem/JUtility/JUTException.h>
// TODO: use #pragma line instead of hacky line argument
// Panic functions
#define JUT_PANIC(LINE, MSG) \
JUTException::panic(__FILE__, LINE, MSG);
@ -16,39 +18,63 @@
JUTAssertion::setConfirmMessage(JUTAssertion::getSDevice(), __FILE__, LINE, COND, #COND);
// not sure if it's conditional?
#define JUT_WARNING(LINE, COND) \
if (!(COND)) \
#define JUT_WARNING(LINE, COND) \
if ((COND)) \
{ \
1 == 1; \
} \
else \
{ \
JUTAssertion::setWarningMessage(JUTAssertion::getSDevice(), __FILE__, LINE, #COND); \
}
#define JUT_WARNING_F(LINE, COND, ...) \
if (!(COND)) \
#define JUT_WARNING_F(LINE, COND, ...) \
if ((COND)) \
{ \
1 == 1; \
} \
else \
{ \
JUTAssertion::setWarningMessage_f(JUTAssertion::getSDevice(), __FILE__, LINE, __VA_ARGS__); \
}
#define JUT_WARNING_F2(LINE, ...) \
JUTAssertion::setWarningMessage_f(JUTAssertion::getSDevice(), __FILE__, LINE, __VA_ARGS__);
// perhaps "%s" is already added here
#define JUT_CRITICAL_WARNING_F(...) \
JUTAssertion::setWarningMessage_f(2, __FILE__, __LINE__, __VA_ARGS__);
#define JUT_ASSERT(LINE, COND) \
if (!(COND)) \
if ((COND)) \
{ \
1 == 1; \
} \
else \
{ \
JUTAssertion::showAssert(JUTAssertion::getSDevice(), __FILE__, LINE, #COND); \
OSHalt(LINE, "Halt"); \
OSHalt(LINE, "Halt"); \
}
#define JUT_ASSERT_F(LINE, COND, ...) \
if (!(COND)) \
if ((COND)) \
{ \
1 == 1; \
} \
else \
{ \
JUTAssertion::showAssert_f(JUTAssertion::getSDevice(), __FILE__, LINE, __VA_ARGS__); \
OSHalt(LINE, "Halt"); \
OSHalt(LINE, "Halt"); \
}
#define JUT_ASSERT_MSG(LINE, COND, MSG) \
if (!(COND)) \
if ((COND)) \
{ \
1 == 1; \
} \
else \
{ \
JUTAssertion::showAssert(JUTAssertion::getSDevice(), __FILE__, LINE, MSG); \
OSHalt(LINE, "Halt"); \
OSHalt(LINE, "Halt"); \
}
#define JUT_MINMAX_ASSERT(LINE, min, cur, max) \
@ -68,6 +94,7 @@
#define JUT_WARNING(...)
#define JUT_WARNING_F(...)
#define JUT_WARNING_F2(...) // remove condintional?
#define JUT_CRITICAL_WARNING_F(...)
#define JUT_ASSERT(...)
#define JUT_ASSERT_F(...)
#define JUT_ASSERT_MSG(...)

View File

@ -3,11 +3,6 @@
#include <JSYstem/JUtility/JUTDbg.h>
#include <JSystem/JAudio/JASCalc.h>
// Note: currently i don't know the compiler flags for JAudio
// So far the release version used the non peephole flags for every sublibrary
// However currently there's no difference between speed and space for the 3 JAudio files i have decompiled
#pragma optimize_for_size off
namespace JASCalc
{
// There is some sort of pattern, this probably got calculated in some way

View File

@ -0,0 +1,29 @@
#include "types.h"
#include <JSystem/JAudio/System/JASDvd.h>
#include <JSystem/JAudio/JASHeap.h>
#include <JSystem/JUtility/JUTDbg.h>
namespace JASDvd
{
static JASTaskThread *sThread;
JASTaskThread *getThreadPointer() { return sThread; }
bool createThread(s32 threadPriority, int msgCount, u32 stackSize)
{
// check if createThread already has been called
if (sThread != 0) // could be conditional JUT_CRITICAL_WARNING_F, who knows
{
#line 32
JUT_CRITICAL_WARNING_F("%s", "JASDvd::createThread が2回呼び出されました");
return false;
}
sThread = new (JASDram, 0) JASTaskThread(threadPriority, msgCount, stackSize);
JUT_ASSERT(36, sThread);
JKRHeap *pCurrentHeap = JKRGetSystemHeap();
JUT_ASSERT(38, pCurrentHeap);
sThread->setCurrentHeap(pCurrentHeap);
sThread->resume();
return true;
}
}