diff --git a/common.py b/common.py index 86fd282..4d329e6 100644 --- a/common.py +++ b/common.py @@ -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) diff --git a/config/MarioClub_us/dol_slices.yml b/config/MarioClub_us/dol_slices.yml index 216963c..92eba6e 100644 --- a/config/MarioClub_us/dol_slices.yml +++ b/config/MarioClub_us/dol_slices.yml @@ -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] diff --git a/config/Release_eu/dol_slices.yml b/config/Release_eu/dol_slices.yml index 738c428..3257c9b 100644 --- a/config/Release_eu/dol_slices.yml +++ b/config/Release_eu/dol_slices.yml @@ -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] diff --git a/config/Release_eu/symbols.yml b/config/Release_eu/symbols.yml index 2a635e2..b5e4808 100644 --- a/config/Release_eu/symbols.yml +++ b/config/Release_eu/symbols.yml @@ -671,9 +671,15 @@ global: 0x80090084: pow2__7JASCalcFf 0x80090198: clamp__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 diff --git a/configure.py b/configure.py index eb30731..e83adfe 100644 --- a/configure.py +++ b/configure.py @@ -577,16 +577,20 @@ class CSource(Source): elif path.startswith("src/Kaneshige/"): self.cflags = c.KANESHIGE_CFLAGS - if c.VERSION == "Release": - if path.startswith("libs/JSystem/"): - self.cflags = c.JSYSTEM_RELEASE_CFLAGS + if c.VERSION == "Release": + 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 + self.cc = c.CC_1_3_2 else: if path.startswith("libs/JSystem/JUtility/"): 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 diff --git a/include/JSystem/JAudio/JASHeap.h b/include/JSystem/JAudio/JASHeap.h new file mode 100644 index 0000000..f52b5d3 --- /dev/null +++ b/include/JSystem/JAudio/JASHeap.h @@ -0,0 +1,8 @@ +#ifndef JSYSTEM_JASHEAP_H +#define JSYSTEM_JASHEAP_H + +#include + +extern JKRHeap *JASDram; + +#endif diff --git a/include/JSystem/JAudio/JASTaskThread.h b/include/JSystem/JAudio/JASTaskThread.h new file mode 100644 index 0000000..6d01e3b --- /dev/null +++ b/include/JSystem/JAudio/JASTaskThread.h @@ -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 */ \ No newline at end of file diff --git a/include/JSystem/JAudio/System/JASDvd.h b/include/JSystem/JAudio/System/JASDvd.h new file mode 100644 index 0000000..770e735 --- /dev/null +++ b/include/JSystem/JAudio/System/JASDvd.h @@ -0,0 +1,11 @@ +#ifndef JSYSTEM_JASDVD_H +#define JSYSTEM_JASDVD_H +#include "types.h" +#include + +namespace JASDvd { + bool createThread(s32 threadPriority, int msgCount, u32 stackSize); + JASTaskThread *getThreadPointer(); +}; + +#endif diff --git a/include/JSystem/JKernel/JKRThread.h b/include/JSystem/JKernel/JKRThread.h index e3a445a..3085ac4 100644 --- a/include/JSystem/JKernel/JKRThread.h +++ b/include/JSystem/JKernel/JKRThread.h @@ -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 sThreadList; @@ -134,16 +139,16 @@ struct JKRThread : public JKRDisposer // _00 = VTBL // _00-_18 = JKRDisposer JSULink 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 }; /** diff --git a/include/JSystem/JUtility/JUTDbg.h b/include/JSystem/JUtility/JUTDbg.h index c2838f9..e8e5d2b 100644 --- a/include/JSystem/JUtility/JUTDbg.h +++ b/include/JSystem/JUtility/JUTDbg.h @@ -4,6 +4,8 @@ #include #include +// 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(...) diff --git a/libs/JSystem/JAudio/JASCalc.cpp b/libs/JSystem/JAudio/JASCalc.cpp index 1edaba5..9972af4 100644 --- a/libs/JSystem/JAudio/JASCalc.cpp +++ b/libs/JSystem/JAudio/JASCalc.cpp @@ -3,11 +3,6 @@ #include #include -// 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 diff --git a/libs/JSystem/JAudio/JASDvdThread.cpp b/libs/JSystem/JAudio/JASDvdThread.cpp new file mode 100644 index 0000000..9a17787 --- /dev/null +++ b/libs/JSystem/JAudio/JASDvdThread.cpp @@ -0,0 +1,29 @@ +#include "types.h" +#include +#include +#include + +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; + } +}