Merge branch 'ToolBox_CDDA' into ToolBox_CDDA_CDXA
This commit is contained in:
@@ -8,6 +8,10 @@ namespace JabyEngine {
|
||||
void identify();
|
||||
}
|
||||
|
||||
namespace Callbacks {
|
||||
void setup();
|
||||
}
|
||||
|
||||
namespace CD {
|
||||
void setup();
|
||||
}
|
||||
|
@@ -4,9 +4,8 @@
|
||||
namespace JabyEngine {
|
||||
namespace CD {
|
||||
namespace internal {
|
||||
extern State current_state;
|
||||
extern CD_IO::Interrupt::Type last_interrupt;
|
||||
extern uint8_t cmd_interrupt_bit;
|
||||
extern State current_state;
|
||||
extern uint8_t cmd_interrupt_bit;
|
||||
|
||||
struct Command {
|
||||
static void wait_completed() {
|
||||
|
21
src/Library/internal-include/System/callbacks_internal.hpp
Normal file
21
src/Library/internal-include/System/callbacks_internal.hpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
#include <PSX/System/threads.hpp>
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace Callback {
|
||||
namespace internal {
|
||||
namespace VSync {
|
||||
static constexpr size_t StackSize = 64;
|
||||
|
||||
extern SysCall::ThreadHandle thread_handle;
|
||||
extern uint32_t stack[StackSize];
|
||||
void routine();
|
||||
|
||||
static void execute() {
|
||||
MainThread::prepare_if_main(VSync::thread_handle);
|
||||
Thread::execute_next();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,11 +1,11 @@
|
||||
#include "../../internal-include/CD/cd_internal.hpp"
|
||||
#include <PSX/Audio/CDDA.hpp>
|
||||
#include <stdio.hpp>
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace CDDA {
|
||||
namespace CD = JabyEngine::CD::internal;
|
||||
|
||||
static CD::CDTimeStamp playing_track;
|
||||
static CD::CDTimeStamp last_track;
|
||||
|
||||
TrackList get_tracks() {
|
||||
@@ -28,16 +28,22 @@ namespace JabyEngine {
|
||||
|
||||
void play(uint8_t track) {
|
||||
CD::enable_CDDA(); // < Command waits
|
||||
|
||||
CD::Command::send_wait<CD_IO::PortIndex0>(CD_IO::Command::GetTD, track);
|
||||
const auto stats = CD_IO::PortIndex0::ResponseFifo.read().raw;
|
||||
playing_track.min = CD_IO::PortIndex0::ResponseFifo.read().raw;
|
||||
playing_track.sec = CD_IO::PortIndex0::ResponseFifo.read().raw;
|
||||
|
||||
CD::Command::send<CD_IO::PortIndex0>(CD_IO::Command::Play, track);
|
||||
}
|
||||
|
||||
void pause() {
|
||||
void stop() {
|
||||
CD::Command::wait_completed();
|
||||
CD::Command::send<CD_IO::PortIndex0>(CD_IO::Command::Pause);
|
||||
}
|
||||
|
||||
void push_play() {
|
||||
pause();
|
||||
stop();
|
||||
CD::Command::wait_completed();
|
||||
CD::Command::send_wait<CD_IO::PortIndex0>(CD_IO::Command::GetLocP);
|
||||
|
||||
@@ -53,8 +59,8 @@ namespace JabyEngine {
|
||||
|
||||
void pop_play() {
|
||||
CD::Command::wait_completed();
|
||||
CD::Command::send_wait<CD_IO::PortIndex0>(CD_IO::Command::SetLoc, last_track.min, last_track.sec, last_track.sector);
|
||||
CD::enable_CDDA(); // < Command waits
|
||||
CD::Command::send_wait<CD_IO::PortIndex0>(CD_IO::Command::SetLoc, last_track.min, last_track.sec, last_track.sector);
|
||||
CD::Command::send<CD_IO::PortIndex0>(CD_IO::Command::Play);
|
||||
}
|
||||
}
|
||||
|
21
src/Library/src/BootLoader/callbacks_boot.cpp
Normal file
21
src/Library/src/BootLoader/callbacks_boot.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#include "../../internal-include/BootLoader/boot_loader.hpp"
|
||||
#include "../../internal-include/System/callbacks_internal.hpp"
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace boot {
|
||||
namespace Callbacks {
|
||||
namespace InternalCallback = JabyEngine::Callback::internal;
|
||||
|
||||
void setup() {
|
||||
SysCall::EnterCriticalSection();
|
||||
InternalCallback::VSync::thread_handle = SysCall::OpenThread(
|
||||
InternalCallback::VSync::routine,
|
||||
&InternalCallback::VSync::stack[InternalCallback::VSync::StackSize - 1],
|
||||
SysCall::get_gp()
|
||||
);
|
||||
Thread::set_user_mode_for(InternalCallback::VSync::thread_handle);
|
||||
SysCall::ExitCriticalSection();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -47,6 +47,7 @@ namespace JabyEngine {
|
||||
static constexpr auto DebugScale = 1.0;
|
||||
|
||||
BIOS::identify();
|
||||
Callbacks::setup();
|
||||
|
||||
__debug_boot_color_at(::JabyEngine::GPU::Color24::Grey(), DebugX, DebugY, DebugScale);
|
||||
DMA::setup();
|
||||
@@ -69,7 +70,6 @@ namespace JabyEngine {
|
||||
test_bios_font();
|
||||
test_gte_scale();
|
||||
|
||||
//Pause??
|
||||
SPU::setup();
|
||||
}
|
||||
}
|
||||
|
@@ -2,11 +2,12 @@
|
||||
#include <PSX/System/IOPorts/dma_io.hpp>
|
||||
#include <PSX/System/IOPorts/interrupt_io.hpp>
|
||||
#include <PSX/System/syscalls.hpp>
|
||||
#include <stdio.hpp>
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace CD {
|
||||
namespace internal {
|
||||
static constexpr auto AudioSectorMode = CD_IO::Mode::from(CD_IO::Mode::SingleSpeed, CD_IO::Mode::CDDA);
|
||||
static constexpr auto AudioSectorMode = CD_IO::Mode::from(CD_IO::Mode::SingleSpeed, CD_IO::Mode::AutoPauseTrack, CD_IO::Mode::CDDA);
|
||||
static constexpr auto DataSectorMode = CD_IO::Mode::from(CD_IO::Mode::DoubleSpeed, CD_IO::Mode::DataSector);
|
||||
|
||||
static SysCall::InterruptVerifierResult interrupt_verifier();
|
||||
@@ -16,7 +17,6 @@ namespace JabyEngine {
|
||||
static uint32_t cur_lba;
|
||||
static uint32_t dst_lba;
|
||||
|
||||
CD_IO::Interrupt::Type last_interrupt = CD_IO::Interrupt::Type::None;
|
||||
uint8_t cmd_interrupt_bit = 0;
|
||||
State current_state = State::Free;
|
||||
SysCall::InterrupCallback callback = {
|
||||
@@ -84,32 +84,45 @@ namespace JabyEngine {
|
||||
|
||||
CD_IO::PortIndex1::change_to();
|
||||
const auto cur_irq = CD_IO::Interrupt::get_type(CD_IO::PortIndex1::InterruptFlag);
|
||||
last_interrupt = cur_irq;
|
||||
CD_IO::Interrupt::ack_extended(CD_IO::PortIndex1::InterruptFlag);
|
||||
|
||||
cmd_interrupt_bit = bit::clear(cmd_interrupt_bit, cur_irq);
|
||||
if(cur_irq == CD_IO::Interrupt::DataReady) {
|
||||
// Obtain sector content here
|
||||
auto* sector = sector_allocator.allocate_sector();
|
||||
if(sector) {
|
||||
//Now obtain sector
|
||||
read_sector_to(*sector);
|
||||
switch(cur_irq) {
|
||||
case CD_IO::Interrupt::DataReady: {
|
||||
// Obtain sector content here
|
||||
auto* sector = sector_allocator.allocate_sector();
|
||||
if(sector) {
|
||||
//Now obtain sector
|
||||
read_sector_to(*sector);
|
||||
|
||||
cur_lba++;
|
||||
if(cur_lba == dst_lba) {
|
||||
current_state = State::Done;
|
||||
cur_lba++;
|
||||
if(cur_lba == dst_lba) {
|
||||
current_state = State::Done;
|
||||
pause_cd();
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
current_state = State::BufferFull;
|
||||
pause_cd();
|
||||
}
|
||||
}
|
||||
} break;
|
||||
|
||||
else {
|
||||
current_state = State::BufferFull;
|
||||
pause_cd();
|
||||
}
|
||||
}
|
||||
case CD_IO::Interrupt::DataEnd: {
|
||||
CD_IO::PortIndex0::change_to();
|
||||
Command::send<CD_IO::PortIndex0>(CD_IO::Command::SetLoc, static_cast<uint8_t>(0x0), static_cast<uint8_t>(0x09), static_cast<uint8_t>(0x0));
|
||||
|
||||
else if(cur_irq == CD_IO::Interrupt::DiskError) {
|
||||
current_state = State::Error;
|
||||
CD_IO::PortIndex1::change_to();
|
||||
while(CD_IO::Interrupt::get_type(CD_IO::PortIndex1::InterruptFlag) != CD_IO::Interrupt::Acknowledge);
|
||||
CD_IO::Interrupt::ack_extended(CD_IO::PortIndex1::InterruptFlag);
|
||||
|
||||
CD_IO::PortIndex0::change_to();
|
||||
Command::send<CD_IO::PortIndex0>(CD_IO::Command::Play);
|
||||
} break;
|
||||
|
||||
case CD_IO::Interrupt::DiskError: {
|
||||
current_state = State::Error;
|
||||
} break;
|
||||
}
|
||||
|
||||
// No masking required because we can only write bit 0 - 2
|
||||
@@ -141,7 +154,7 @@ namespace JabyEngine {
|
||||
void enable_CDDA() {
|
||||
Command::wait_completed();
|
||||
CD_IO::PortIndex0::change_to();
|
||||
Command::send_wait<CD_IO::PortIndex0>(CD_IO::Command::SetMode, AudioSectorMode);
|
||||
Command::send_wait<CD_IO::PortIndex0>(CD_IO::Command::SetMode, AudioSectorMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
#include "../../internal-include/GPU/gpu_internal.hpp"
|
||||
#include "../../internal-include/System/callbacks_internal.hpp"
|
||||
#include <PSX/Timer/frame_timer.hpp>
|
||||
#include <PSX/System/IOPorts/interrupt_io.hpp>
|
||||
#include <PSX/System/syscalls.hpp>
|
||||
@@ -40,8 +41,7 @@ namespace JabyEngine {
|
||||
MasterTime::value++;
|
||||
|
||||
Interrupt::ack_irq(Interrupt::VBlank);
|
||||
SysCall::ReturnFromException();
|
||||
__builtin_unreachable();
|
||||
Callback::internal::VSync::execute();
|
||||
}
|
||||
|
||||
uint32_t Display :: exchange_buffer_and_display() {
|
||||
|
26
src/Library/src/System/callbacks.cpp
Normal file
26
src/Library/src/System/callbacks.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#include "../../internal-include/System/callbacks_internal.hpp"
|
||||
#include <PSX/System/callbacks.hpp>
|
||||
|
||||
#include <stdio.hpp>
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace Callback {
|
||||
VSyncCallback::Function VSyncCallback :: callback = nullptr;
|
||||
|
||||
namespace internal {
|
||||
namespace VSync {
|
||||
SysCall::ThreadHandle thread_handle = 0;
|
||||
uint32_t stack[StackSize] = {0};
|
||||
|
||||
void routine() {
|
||||
while(true) {
|
||||
if(VSyncCallback::callback) {
|
||||
VSyncCallback::callback();
|
||||
}
|
||||
MainThread::restore();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user