Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion config/RSBE01_02/splits.txt
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,11 @@ sora/snd/snd_init_thread.cpp:

sora/mv/mv_THPAudioDecode.cpp:
.text start:0x8007B0B4 end:0x8007B4A4
.sbss start:0x805A01E0 end:0x805A01E8
.sbss start:0x805A01E0 end:0x805A01E4

sora/mv/mv_THPRead.cpp:
.text start:0x8007E0EC end:0x8007E3A4
.sbss start:0x805A0200 end:0x805A0204

sora/cm/cm_controller_default.cpp:
.text start:0x8009F560 end:0x8009F564
Expand Down
24 changes: 12 additions & 12 deletions config/RSBE01_02/symbols.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3938,16 +3938,16 @@ fn_8007D9F8 = .text:0x8007D9F8; // type:function size:0x290
fn_8007DC88 = .text:0x8007DC88; // type:function size:0x118
fn_8007DDA0 = .text:0x8007DDA0; // type:function size:0x330
fn_8007E0D0 = .text:0x8007E0D0; // type:function size:0x1C
fn_8007E0EC = .text:0x8007E0EC; // type:function size:0x8
fn_8007E0F4 = .text:0x8007E0F4; // type:function size:0x1C
fn_8007E110 = .text:0x8007E110; // type:function size:0xC
fn_8007E11C = .text:0x8007E11C; // type:function size:0xA0
fn_8007E1BC = .text:0x8007E1BC; // type:function size:0x1C
fn_8007E1D8 = .text:0x8007E1D8; // type:function size:0x40
fn_8007E218 = .text:0x8007E218; // type:function size:0xFC
GetSizeTHPReadWork__Fv = .text:0x8007E0EC; // type:function size:0x8
SetTHPReadWork__FP11THPReadWork = .text:0x8007E0F4; // type:function size:0x1C
FreeTHPReadWork__Fv = .text:0x8007E110; // type:function size:0xC
CreateReadThread__Fl = .text:0x8007E11C; // type:function size:0xA0
ReadThreadStart__Fv = .text:0x8007E1BC; // type:function size:0x1C
ReadThreadCancel__Fv = .text:0x8007E1D8; // type:function size:0x40
Reader__FPv = .text:0x8007E218; // type:function size:0xFC
PopReadedBuffer__Fv = .text:0x8007E314; // type:function size:0x34
fn_8007E348 = .text:0x8007E348; // type:function size:0x14
fn_8007E35C = .text:0x8007E35C; // type:function size:0x34
PushFreeReadBuffer__FPv = .text:0x8007E348; // type:function size:0x14
PopReadedBuffer2__Fv = .text:0x8007E35C; // type:function size:0x34
PushReadedBuffer2__FPv = .text:0x8007E390; // type:function size:0x14
fn_8007E3A4 = .text:0x8007E3A4; // type:function size:0x8
fn_8007E3AC = .text:0x8007E3AC; // type:function size:0x1C
Expand Down Expand Up @@ -9317,7 +9317,7 @@ fn_801F6524 = .text:0x801F6524; // type:function size:0x24
fn_801F6548 = .text:0x801F6548; // type:function size:0x1C0
fn_801F6708 = .text:0x801F6708; // type:function size:0xD0
fn_801F67D8 = .text:0x801F67D8; // type:function size:0x18
fn_801F67F0 = .text:0x801F67F0; // type:function size:0x128
DVDReadPrio = .text:0x801F67F0; // type:function size:0x128
fn_801F6918 = .text:0x801F6918; // type:function size:0x8
fn_801F6920 = .text:0x801F6920; // type:function size:0xB0
fn_801F69D0 = .text:0x801F69D0; // type:function size:0x8
Expand Down Expand Up @@ -30726,13 +30726,13 @@ lbl_805A01CC = .sbss:0x805A01CC; // type:object size:0x1 data:byte
g_sndSystem = .sbss:0x805A01D0; // type:object size:0x4 data:4byte
lbl_805A01D4 = .sbss:0x805A01D4; // type:object size:0x4 data:4byte
lbl_805A01D8 = .sbss:0x805A01D8; // type:object size:0x8 data:4byte
g_audioDecWork = .sbss:0x805A01E0; // type:object size:0x8 data:4byte
g_audioDecWork = .sbss:0x805A01E0; // type:object size:0x4 data:4byte
lbl_805A01E8 = .sbss:0x805A01E8; // type:object size:0x4 data:4byte
lbl_805A01EC = .sbss:0x805A01EC; // type:object size:0x4 data:4byte
lbl_805A01F0 = .sbss:0x805A01F0; // type:object size:0x4 data:4byte
lbl_805A01F4 = .sbss:0x805A01F4; // type:object size:0x4 data:4byte
lbl_805A01F8 = .sbss:0x805A01F8; // type:object size:0x8 data:4byte
lbl_805A0200 = .sbss:0x805A0200; // type:object size:0x8 data:4byte
g_readWork = .sbss:0x805A0200; // type:object size:0x4 scope:local data:4byte
lbl_805A0208 = .sbss:0x805A0208; // type:object size:0x8 data:4byte
lbl_805A0210 = .sbss:0x805A0210; // type:object size:0x4 data:4byte
lbl_805A0214 = .sbss:0x805A0214; // type:object size:0x4 data:4byte
Expand Down
1 change: 1 addition & 0 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ def MatchingFor(*versions):
Object(Matching, "sora/ec/ec_trace_mgr.cpp"),
Object(Matching, "sora/snd/snd_init_thread.cpp"),
Object(Matching, "sora/mv/mv_THPAudioDecode.cpp"),
Object(Matching, "sora/mv/mv_THPRead.cpp"),
Object(Matching, "sora/cm/cm_controller_default.cpp", extra_cflags=["-RTTI off"]),
Object(NonMatching, "sora/cm/cm_controller_menu_fixed.cpp"),
Object(Matching, "sora/cm/cm_controller_melee_fixed.cpp"),
Expand Down
6 changes: 3 additions & 3 deletions src/sora/mv/mv_THPAudioDecode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ bool CreateAudioDecodeThread(s32 prio, void* funcArg) {
if (funcArg) {
if (!OSCreateThread(&g_audioDecWork->m_thread, AudioDecoderForOnMemory,
funcArg, g_audioDecWork->m_stack + THPAudioDecWork::StackSize,
THPAudioDecWork::StackSize, prio, 1)) {
THPAudioDecWork::StackSize, prio, OS_THREAD_DETACHED)) {
return false;
}
} else {
if (!OSCreateThread(&g_audioDecWork->m_thread, AudioDecoder, nullptr,
g_audioDecWork->m_stack + THPAudioDecWork::StackSize, THPAudioDecWork::StackSize,
prio, 1)) {
prio, OS_THREAD_DETACHED)) {
return false;
}
}
Expand Down Expand Up @@ -76,7 +76,7 @@ void* AudioDecoder(void* p1) {
if (r29 == 2) {
PrepareReady(true);
}
PushReadedBuffer2(static_cast<OSMessage>(r30));
PushReadedBuffer2(r30);
r29++;
}
}
Expand Down
114 changes: 114 additions & 0 deletions src/sora/mv/mv_THPRead.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
#include <mv/mv_THPPlayer.h>
#include <mv/mv_THPRead.h>
#include <revolution/DVD/dvdfs.h>
#include <revolution/OS/OSMessage.h>
#include <revolution/OS/OSThread.h>
#include <types.h>

static THPReadWork* g_readWork;

u32 GetSizeTHPReadWork() {
return sizeof(THPReadWork);
}

void SetTHPReadWork(THPReadWork* work) {
if (!g_readWork) {
g_readWork = work;
work->m_threadActive = false;
}
}

void FreeTHPReadWork() {
g_readWork = nullptr;
}

static void* Reader(void* arg);

bool CreateReadThread(s32 prio) {
if (!OSCreateThread(&g_readWork->m_thread, Reader,
nullptr, g_readWork->m_stack + THPReadWork::StackSize,
THPReadWork::StackSize, prio, OS_THREAD_DETACHED)) {
return false;
}
OSInitMessageQueue(&g_readWork->m_freeReadQueue,
g_readWork->m_freeReadBuf, THPReadWork::BufferCap);
OSInitMessageQueue(&g_readWork->m_pastReadQueue,
g_readWork->m_pastReadBuf, THPReadWork::BufferCap);
OSInitMessageQueue(&g_readWork->m_pastRead2Queue,
g_readWork->m_pastRead2Buf, THPReadWork::BufferCap);
g_readWork->m_threadActive = true;
return true;
}

void ReadThreadStart() {
if (g_readWork->m_threadActive) {
OSResumeThread(&g_readWork->m_thread);
}
}

void ReadThreadCancel() {
if (g_readWork->m_threadActive) {
OSCancelThread(&g_readWork->m_thread);
g_readWork->m_threadActive = false;
}
}

static void* Reader(void* arg) {
s32 offs = g_thpObject.unkB8;
s32 size = g_thpObject.unkBC;
s32 i = 0;
while (true) {
THPReadMessage* readMsg = reinterpret_cast<THPReadMessage*>(PopFreeReadBuffer());
s32 bytesRead = DVDReadPrio(&g_thpObject.m_fInfo, readMsg->m_block, size, offs, 2);
if (bytesRead != size) {
if (bytesRead == DVD_RESULT_FATAL)
g_thpObject.unkA8 = -1;
if (i == 0)
PrepareReady(false);
OSSuspendThread(&g_readWork->m_thread);
}
readMsg->m_blockNum = i;
PushReadedBuffer(readMsg);
offs += size;
size = readMsg->m_block->m_nextBlockSize;

u32 pos = (i + g_thpObject.unkC0) % g_thpObject.unk50;
if (pos == (g_thpObject.unk50 - 1)) {
if (g_thpObject.unkA6 & 0x1)
offs = g_thpObject.unk64;
else
OSSuspendThread(&g_readWork->m_thread);
}
i++;
}
}

OSMessage PopReadedBuffer() {
OSMessage msg;
OSReceiveMessage(&g_readWork->m_pastReadQueue, &msg, OS_MSG_BLOCKING);
return msg;
}

void PushReadedBuffer(OSMessage msg) {
OSSendMessage(&g_readWork->m_pastReadQueue, msg, OS_MSG_BLOCKING);
}

OSMessage PopFreeReadBuffer() {
OSMessage msg;
OSReceiveMessage(&g_readWork->m_freeReadQueue, &msg, OS_MSG_BLOCKING);
return msg;
}

void PushFreeReadBuffer(OSMessage msg) {
OSSendMessage(&g_readWork->m_freeReadQueue, msg, OS_MSG_BLOCKING);
}

OSMessage PopReadedBuffer2() {
OSMessage msg;
OSReceiveMessage(&g_readWork->m_pastRead2Queue, &msg, OS_MSG_BLOCKING);
return msg;
}

void PushReadedBuffer2(OSMessage msg) {
OSSendMessage(&g_readWork->m_pastRead2Queue, msg, OS_MSG_BLOCKING);
}
Loading