Use original code instead of frankensteining
This commit is contained in:
@@ -3,95 +3,8 @@
|
||||
#include <PSX/System/IOPorts/interrupt_io.hpp>
|
||||
#include <PSX/System/syscalls.hpp>
|
||||
#include <stdio.hpp>
|
||||
struct Registers {
|
||||
union {
|
||||
struct {
|
||||
uint32_t r0, at, v0, v1, a0, a1, a2, a3;
|
||||
uint32_t t0, t1, t2, t3, t4, t5, t6, t7;
|
||||
uint32_t s0, s1, s2, s3, s4, s5, s6, s7;
|
||||
uint32_t t8, t9, k0, k1, gp, sp, fp, ra;
|
||||
} n;
|
||||
uint32_t r[32];
|
||||
} GPR;
|
||||
uint32_t returnPC;
|
||||
uint32_t hi, lo;
|
||||
uint32_t SR;
|
||||
uint32_t Cause;
|
||||
};
|
||||
|
||||
struct Thread {
|
||||
uint32_t flags, flags2;
|
||||
struct Registers registers;
|
||||
uint32_t unknown[9];
|
||||
};
|
||||
|
||||
struct Process {
|
||||
struct Thread* thread;
|
||||
};
|
||||
|
||||
struct Globals {
|
||||
/* 100 */ struct HandlersStorage* handlersArray;
|
||||
/* 104 */ uint32_t handlersArraySize;
|
||||
/* 108 */ struct Process* processes;
|
||||
/* 10c */ uint32_t processBlockSize;
|
||||
/* 110 */ struct Thread* threads;
|
||||
/* 114 */ uint32_t threadBlockSize;
|
||||
/* 118 */ uint32_t xxx_06;
|
||||
/* 11c */ uint32_t xxx_07;
|
||||
/* 120 */ struct EventInfo* events;
|
||||
/* 124 */ uint32_t eventsSize;
|
||||
/* 128 */ uint32_t xxx_0a;
|
||||
/* 12c */ uint32_t xxx_0b;
|
||||
/* 130 */ uint32_t xxx_0c;
|
||||
/* 134 */ uint32_t xxx_0d;
|
||||
/* 138 */ uint32_t xxx_0e;
|
||||
/* 13c */ uint32_t xxx_0f;
|
||||
/* 140 */ struct File* files;
|
||||
/* 144 */ uint32_t filesSize;
|
||||
/* 148 */ uint32_t xxx_12;
|
||||
/* 14c */ uint32_t xxx_13;
|
||||
/* 150 */ struct Device* devices;
|
||||
/* 154 */ struct Device* devicesEnd;
|
||||
/* 158 */ uint32_t xxx_16;
|
||||
/* 15c */ uint32_t xxx_17;
|
||||
/* 160 */ uint32_t xxx_18;
|
||||
/* 164 */ uint32_t xxx_19;
|
||||
/* 168 */ uint32_t xxx_1a;
|
||||
/* 16c */ uint32_t xxx_1b;
|
||||
/* 170 */ uint32_t xxx_1c;
|
||||
/* 174 */ uint32_t xxx_1d;
|
||||
/* 178 */ uint32_t xxx_1e;
|
||||
/* 17c */ uint32_t xxx_1f;
|
||||
};
|
||||
|
||||
Globals *__globals;
|
||||
|
||||
namespace JabyEngine {
|
||||
struct ToT {
|
||||
unsigned long *head;
|
||||
long size;
|
||||
};
|
||||
|
||||
struct TCBH {
|
||||
TCB *entry; /* NULL */
|
||||
long flag;
|
||||
};
|
||||
|
||||
TCBH *exec_TCB;
|
||||
TCB *mainFlow;
|
||||
|
||||
inline unsigned short getSystemTableNumber(uint32_t thread)
|
||||
{
|
||||
return (thread & 0xFFFF);
|
||||
}
|
||||
|
||||
inline TCB* getTCB(uint32_t thread)
|
||||
{
|
||||
return (TCB*) (((ToT*)0x100)[2]).head + getSystemTableNumber(thread);
|
||||
}
|
||||
|
||||
int changeThread(int threadId) { return SysCall::changeThreadSubFunction((uint32_t)&__globals->threads[threadId & 0xffff]); }
|
||||
|
||||
namespace CD {
|
||||
namespace internal {
|
||||
static constexpr auto AudioSectorMode = CD_IO::Mode::from(CD_IO::Mode::SingleSpeed, CD_IO::Mode::AutoPauseTrack, CD_IO::Mode::CDDA);
|
||||
@@ -213,7 +126,7 @@ int changeThread(int threadId) { return SysCall::changeThreadSubFunction((uint32
|
||||
if(thread != 0) {
|
||||
//changeThread(thread);
|
||||
printf("About to change...\n");
|
||||
exec_TCB->entry = reinterpret_cast<TCB*>(&__globals->threads[thread & 0xffff]);
|
||||
table_of_tables.processes->current_tcb = &table_of_tables.threads[thread&0xFFFF];
|
||||
printf("Changed!\n");
|
||||
}
|
||||
} break;
|
||||
@@ -226,8 +139,6 @@ int changeThread(int threadId) { return SysCall::changeThreadSubFunction((uint32
|
||||
// No masking required because we can only write bit 0 - 2
|
||||
CD_IO::IndexStatus.write(old_status);
|
||||
Interrupt::ack_irq(Interrupt::CDROM);
|
||||
Interrupt::enable_irq(Interrupt::CDROM);
|
||||
printf("RET-E\n");
|
||||
SysCall::ReturnFromException();
|
||||
__builtin_unreachable();
|
||||
}
|
||||
@@ -253,35 +164,18 @@ int changeThread(int threadId) { return SysCall::changeThreadSubFunction((uint32
|
||||
|
||||
void enable_CDDA() {
|
||||
if(thread == 0) {
|
||||
__globals = reinterpret_cast<Globals*>(0x100);
|
||||
ToT *table = (ToT*)0x100;
|
||||
exec_TCB = (TCBH*)table[1].head;
|
||||
mainFlow = exec_TCB->entry;
|
||||
|
||||
SysCall::EnterCriticalSection();
|
||||
thread = SysCall::OpenTh([]() {
|
||||
printf("Hallo!\n");
|
||||
printf("Me: 0x%p - 0x%p\n", get_tcb_of_th(thread), &get_current_tcb());
|
||||
|
||||
printf("Blubb!\n");
|
||||
CD_IO::PortIndex0::change_to();
|
||||
printf("Schwupp!\n");
|
||||
Command::send<CD_IO::PortIndex0>(CD_IO::Command::SetLoc, static_cast<uint8_t>(0x0), static_cast<uint8_t>(0x09), static_cast<uint8_t>(0x0));
|
||||
printf("Mupp\n");
|
||||
Command::send<CD_IO::PortIndex0>(CD_IO::Command::Play);
|
||||
printf("Done!!\n");
|
||||
|
||||
exec_TCB->entry = mainFlow;
|
||||
table_of_tables.processes->current_tcb = &table_of_tables.threads[0];
|
||||
SysCall::ReturnFromException();
|
||||
//changeThread(0);
|
||||
}, reinterpret_cast<uint32_t*>(0x80010000), reinterpret_cast<uint32_t*>(mainFlow->reg[28]));
|
||||
}, reinterpret_cast<uint32_t*>(0x80010000), SysCall::get_gp());
|
||||
SysCall::ExitCriticalSection();
|
||||
|
||||
printf("Raw: %x, TCB: %i\n", thread, thread & 0xFFFF);
|
||||
//__globals->threads[thread & 0xffff].registers.SR = 0x404;
|
||||
|
||||
//mainFlow = exec_TCB->entry;
|
||||
//changeThread(thread);
|
||||
}
|
||||
|
||||
Command::wait_completed();
|
||||
|
Reference in New Issue
Block a user