Play CDDA track
This commit is contained in:
parent
01622fd5d6
commit
f91a7b470c
|
@ -1,4 +1,5 @@
|
||||||
#include "include/menu.hpp"
|
#include "include/menu.hpp"
|
||||||
|
#include <PSX/Audio/CDDA.hpp>
|
||||||
#include <PSX/Periphery/periphery.hpp>
|
#include <PSX/Periphery/periphery.hpp>
|
||||||
|
|
||||||
namespace Menu {
|
namespace Menu {
|
||||||
|
@ -41,6 +42,9 @@ namespace Menu {
|
||||||
}
|
}
|
||||||
|
|
||||||
void BackMenu :: setup(JabyEngine::FontWriter* font_writer) {
|
void BackMenu :: setup(JabyEngine::FontWriter* font_writer) {
|
||||||
|
const auto [first_track, last_track] = CDDA::get_tracks();
|
||||||
|
CDDA::play(first_track);
|
||||||
|
|
||||||
this->font_writer = font_writer;
|
this->font_writer = font_writer;
|
||||||
this->timeout.reset();
|
this->timeout.reset();
|
||||||
this->waiting = false;
|
this->waiting = false;
|
||||||
|
|
|
@ -33,4 +33,5 @@
|
||||||
</Directory>
|
</Directory>
|
||||||
</Track>
|
</Track>
|
||||||
<CD_Audio>../assets/audio/Evacuation_cdda.wav</CD_Audio>
|
<CD_Audio>../assets/audio/Evacuation_cdda.wav</CD_Audio>
|
||||||
|
<CD_Audio>../assets/audio/Evacuation_cdda.wav</CD_Audio>
|
||||||
</ISO_Project>
|
</ISO_Project>
|
|
@ -0,0 +1,20 @@
|
||||||
|
#pragma once
|
||||||
|
#include "../jabyengine_defines.hpp"
|
||||||
|
|
||||||
|
namespace JabyEngine {
|
||||||
|
namespace CDDA {
|
||||||
|
struct TrackList {
|
||||||
|
uint8_t first_track;
|
||||||
|
uint8_t last_track;
|
||||||
|
|
||||||
|
static constexpr TrackList empty() {
|
||||||
|
return TrackList{.first_track = 0, .last_track = 0};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
TrackList get_tracks();
|
||||||
|
|
||||||
|
void play(uint8_t track);
|
||||||
|
void stop();
|
||||||
|
}
|
||||||
|
}
|
|
@ -153,10 +153,12 @@ namespace JabyEngine {
|
||||||
|
|
||||||
static constexpr Desc GetStat{0x01, Interrupt::Type::Acknowledge};
|
static constexpr Desc GetStat{0x01, Interrupt::Type::Acknowledge};
|
||||||
static constexpr Desc SetLoc{0x02, Interrupt::Type::Acknowledge};
|
static constexpr Desc SetLoc{0x02, Interrupt::Type::Acknowledge};
|
||||||
|
static constexpr Desc Play{0x03, Interrupt::Type::Acknowledge};
|
||||||
static constexpr Desc ReadN{0x06, Interrupt::Type::DataReady};
|
static constexpr Desc ReadN{0x06, Interrupt::Type::DataReady};
|
||||||
static constexpr Desc Pause{0x09, Interrupt::Type::Complete};
|
static constexpr Desc Pause{0x09, Interrupt::Type::Complete};
|
||||||
static constexpr Desc Init{0x0A, Interrupt::Type::Complete};
|
static constexpr Desc Init{0x0A, Interrupt::Type::Complete};
|
||||||
static constexpr Desc SetMode{0x0E, Interrupt::Type::Acknowledge};
|
static constexpr Desc SetMode{0x0E, Interrupt::Type::Acknowledge};
|
||||||
|
static constexpr Desc GetTN{0x13, Interrupt::Type::Acknowledge};
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr auto IORegister1Adr = 0x1F801801;
|
static constexpr auto IORegister1Adr = 0x1F801801;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "ioport.hpp"
|
#include "ioport.hpp"
|
||||||
|
#include <limits.hpp>
|
||||||
|
|
||||||
namespace JabyEngine {
|
namespace JabyEngine {
|
||||||
namespace SPU_IO {
|
namespace SPU_IO {
|
||||||
|
@ -156,6 +157,10 @@ namespace JabyEngine {
|
||||||
__declare_io_port_w_type(inline, Adr, WorkAreaAdr, 0x1F801DA2);
|
__declare_io_port_w_type(inline, Adr, WorkAreaAdr, 0x1F801DA2);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static constexpr SimpleVolume operator""_vol(long double fraction) {
|
||||||
|
return {static_cast<int16_t>(static_cast<long double>(I16_MAX)*fraction)};
|
||||||
|
}
|
||||||
|
|
||||||
__declare_io_port(, ControlRegister, 0x1F801DAA);
|
__declare_io_port(, ControlRegister, 0x1F801DAA);
|
||||||
__declare_io_port(, DataTransferControl, 0x1F801DAC);
|
__declare_io_port(, DataTransferControl, 0x1F801DAC);
|
||||||
__declare_io_port(, PMON, 0x1F801D90);
|
__declare_io_port(, PMON, 0x1F801D90);
|
||||||
|
|
|
@ -45,6 +45,8 @@ namespace JabyEngine {
|
||||||
|
|
||||||
void read_file(AutoLBAEntry file_info, const SectorBufferAllocator& buffer_allocator);
|
void read_file(AutoLBAEntry file_info, const SectorBufferAllocator& buffer_allocator);
|
||||||
void continue_reading();
|
void continue_reading();
|
||||||
|
|
||||||
|
void enable_CDDA();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
#include "../../internal-include/CD/cd_internal.hpp"
|
||||||
|
#include <PSX/Audio/CDDA.hpp>
|
||||||
|
#include <stdio.hpp>
|
||||||
|
|
||||||
|
namespace JabyEngine {
|
||||||
|
namespace CDDA {
|
||||||
|
namespace CD = JabyEngine::CD::internal;
|
||||||
|
|
||||||
|
TrackList get_tracks() {
|
||||||
|
CD::Command::wait_completed();
|
||||||
|
|
||||||
|
CD_IO::PortIndex0::change_to();
|
||||||
|
CD::Command::send_wait<CD_IO::PortIndex0>(CD_IO::Command::GetTN);
|
||||||
|
|
||||||
|
const auto stat = CD_IO::PortIndex0::ResponseFifo.read();
|
||||||
|
const auto first = CD_IO::PortIndex0::ResponseFifo.read().raw;
|
||||||
|
const auto end = CD_IO::PortIndex0::ResponseFifo.read().raw;
|
||||||
|
const auto last_track = (end - first) + 1;
|
||||||
|
|
||||||
|
if(last_track == 1) {
|
||||||
|
return TrackList::empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
return TrackList{.first_track = 2, .last_track = static_cast<uint8_t>(last_track)};
|
||||||
|
}
|
||||||
|
|
||||||
|
void play(uint8_t track) {
|
||||||
|
CD::enable_CDDA(); // < Command waits
|
||||||
|
CD::Command::send<CD_IO::PortIndex0>(CD_IO::Command::Play, track);
|
||||||
|
}
|
||||||
|
|
||||||
|
void stop() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,8 +15,8 @@ namespace JabyEngine {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void clear_cd_and_ext_audio_volume() {
|
static void clear_cd_and_ext_audio_volume() {
|
||||||
CDVolume::Left.write({0});
|
CDVolume::Left.write(0.5_vol);
|
||||||
CDVolume::Right.write({0});
|
CDVolume::Right.write(0.5_vol);
|
||||||
|
|
||||||
ExternalAudioInputVolume::Left.write({0});
|
ExternalAudioInputVolume::Left.write({0});
|
||||||
ExternalAudioInputVolume::Right.write({0});
|
ExternalAudioInputVolume::Right.write({0});
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
namespace JabyEngine {
|
namespace JabyEngine {
|
||||||
namespace CD {
|
namespace CD {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
static constexpr auto DataSectorMode = CD_IO::Mode::from(CD_IO::Mode::DoubleSpeed, CD_IO::Mode::DataSector);
|
static constexpr auto AudioSectorMode = CD_IO::Mode::from(CD_IO::Mode::SingleSpeed, 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();
|
static SysCall::InterruptVerifierResult interrupt_verifier();
|
||||||
static uint32_t interrupt_handler(uint32_t);
|
static uint32_t interrupt_handler(uint32_t);
|
||||||
|
@ -136,6 +137,12 @@ namespace JabyEngine {
|
||||||
read_cd(cur_lba);
|
read_cd(cur_lba);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void enable_CDDA() {
|
||||||
|
Command::wait_completed();
|
||||||
|
CD_IO::PortIndex0::change_to();
|
||||||
|
Command::send_wait<CD_IO::PortIndex0>(CD_IO::Command::SetMode, AudioSectorMode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue