Current buggy state

This commit is contained in:
2024-07-04 06:47:47 +02:00
parent f5020e152b
commit 8624abb048
7 changed files with 94 additions and 52 deletions

View File

@@ -7,8 +7,6 @@
namespace JabyEngine {
namespace CD {
extern volatile uint8_t zero;
namespace internal {
enum struct State {
Ready = 0,
@@ -21,9 +19,36 @@ namespace JabyEngine {
Error,
};
extern State current_state;
extern State current_state;
extern uint8_t irq_bit_pending;
extern uint8_t last_cmd;
struct NewCommand {
struct Command {
static void wait_completed() {
while(const_cast<volatile uint8_t&>(irq_bit_pending));
}
template<typename...ARGS>
static void send(CD_IO::Command::Desc cmd, ARGS...args) {
Command::wait_completed();
while(CD_IO::IndexStatus.read().is_set(CD_IO::IndexStatus::IsTransmissionBusy));
irq_bit_pending = bit::set(irq_bit_pending, cmd.complete_irq);
last_cmd = cmd.id;
CD_IO::PortIndex0::change_to();
((CD_IO::PortIndex0::ParameterFifo.write(CD_IO::ParameterFifo{args})),...);
CD_IO::PortIndex0::CommandFifo.write(CD_IO::CommandFifo{cmd.id});
}
template<typename...ARGS>
static void send_wait_response(CD_IO::Command::Desc cmd, ARGS...args) {
Command::send(cmd, args...);
Command::wait_completed();
}
};
/*struct NewCommand {
struct Internal {
static void wait_completed(CD_IO::Interrupt::Type irq) {
static const auto get_next_irq = []() -> CD_IO::Interrupt::Type {
@@ -69,7 +94,7 @@ namespace JabyEngine {
Internal::wait_completed(cmd.complete_irq);
Interrupt::enable_irq(Interrupt::CDROM);
}
};
};*/
namespace IRQ {
void process(uint32_t irq);
@@ -93,8 +118,7 @@ namespace JabyEngine {
void enable_CDXA(bool double_speed);
static void pause() {
CD_IO::PortIndex0::change_to();
NewCommand::send(CD_IO::Command::Pause);
Command::send(CD_IO::Command::Pause);
}
}
}

View File

@@ -1,14 +1,20 @@
#pragma once
#include "threads.hpp"
#include <stdio.hpp>
namespace JabyEngine {
namespace Callback {
namespace internal {
static void execute_callback(Thread::Handle thread_handle, uint32_t parm) {
static void execute_callback(Thread::Handle thread_handle, uint32_t parm, uint8_t irq_bit_pending, uint8_t irq, uint8_t last_cmd) {
if(CurrentThread::is_me(MainThread::Handle)) {
CurrentThread::replace_with(thread_handle);
CurrentThread::force_a0(parm);
}
else {
//printf("%i +> %i +> %i\n", irq_bit_pending, irq, last_cmd);
}
//printf("C\n");
SysCall::ReturnFromException();
}
@@ -26,7 +32,7 @@ namespace JabyEngine {
void routine();
static void [[deprecated("Currently not in use")]] execute() {
execute_callback(VSync::thread_handle, 0);
execute_callback(VSync::thread_handle, 0, 0, 0, 0);
}
}
@@ -37,8 +43,8 @@ namespace JabyEngine {
extern uint32_t stack[StackSize];
void routine(uint32_t irq);
static void execute(uint32_t irq) {
execute_callback(CD::thread_handle, irq);
static void execute(uint32_t irq, uint8_t irq_bit_pending, uint8_t irq2, uint8_t last_cmd) {
execute_callback(CD::thread_handle, irq, irq_bit_pending, irq2, last_cmd);
}
static uint32_t resume() {