Support pushing and poping a playing CDDA track
This commit is contained in:
parent
fe88157aba
commit
6cc38cf5c9
|
@ -5,6 +5,7 @@
|
|||
#include "Overlay/Overlays.hpp"
|
||||
#include <FontWriter/fonts.hpp>
|
||||
#include <FontWriter/font_writer.hpp>
|
||||
#include <PSX/Audio/CDDA.hpp>
|
||||
#include <PSX/Periphery/periphery.hpp>
|
||||
#include <stdio.hpp>
|
||||
|
||||
|
@ -102,6 +103,9 @@ static void setup() {
|
|||
break;
|
||||
}
|
||||
},MenuEntries);
|
||||
|
||||
const auto [first_track, last_track] = CDDA::get_tracks();
|
||||
CDDA::play(first_track);
|
||||
}
|
||||
|
||||
namespace NormalScene {
|
||||
|
@ -157,8 +161,10 @@ namespace LoadingScene {
|
|||
render();
|
||||
GPU::swap_buffers_vsync(1);
|
||||
|
||||
CDDA::push_play();
|
||||
state_changer.asset_load();
|
||||
old_state_changer = state_changer;
|
||||
CDDA::pop_play();
|
||||
}
|
||||
|
||||
state_changer.main();
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#include "include/menu.hpp"
|
||||
#include <PSX/Audio/CDDA.hpp>
|
||||
#include <PSX/Periphery/periphery.hpp>
|
||||
|
||||
namespace Menu {
|
||||
|
@ -42,9 +41,6 @@ namespace Menu {
|
|||
}
|
||||
|
||||
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->timeout.reset();
|
||||
this->waiting = false;
|
||||
|
|
|
@ -33,5 +33,4 @@
|
|||
</Directory>
|
||||
</Track>
|
||||
<CD_Audio>../assets/audio/Evacuation_cdda.wav</CD_Audio>
|
||||
<CD_Audio>../assets/audio/Evacuation_cdda.wav</CD_Audio>
|
||||
</ISO_Project>
|
|
@ -16,5 +16,8 @@ namespace JabyEngine {
|
|||
|
||||
void play(uint8_t track);
|
||||
void pause();
|
||||
|
||||
void push_play();
|
||||
void pop_play();
|
||||
}
|
||||
}
|
|
@ -158,6 +158,7 @@ namespace JabyEngine {
|
|||
static constexpr Desc Pause{0x09, Interrupt::Type::Complete};
|
||||
static constexpr Desc Init{0x0A, Interrupt::Type::Complete};
|
||||
static constexpr Desc SetMode{0x0E, Interrupt::Type::Acknowledge};
|
||||
static constexpr Desc GetLocP{0x11, Interrupt::Type::Acknowledge};
|
||||
static constexpr Desc GetTN{0x13, Interrupt::Type::Acknowledge};
|
||||
};
|
||||
|
||||
|
|
|
@ -6,6 +6,8 @@ namespace JabyEngine {
|
|||
namespace CDDA {
|
||||
namespace CD = JabyEngine::CD::internal;
|
||||
|
||||
static CD::CDTimeStamp last_track;
|
||||
|
||||
TrackList get_tracks() {
|
||||
CD::Command::wait_completed();
|
||||
|
||||
|
@ -33,5 +35,27 @@ namespace JabyEngine {
|
|||
CD::Command::wait_completed();
|
||||
CD::Command::send<CD_IO::PortIndex0>(CD_IO::Command::Pause);
|
||||
}
|
||||
|
||||
void push_play() {
|
||||
pause();
|
||||
CD::Command::wait_completed();
|
||||
CD::Command::send_wait<CD_IO::PortIndex0>(CD_IO::Command::GetLocP);
|
||||
|
||||
const auto track = CD_IO::PortIndex0::ResponseFifo.read().raw; // track number (AAh=Lead-out area) (FFh=unknown, toc, none?)
|
||||
const auto index = CD_IO::PortIndex0::ResponseFifo.read().raw; // index number (Usually 01h)
|
||||
const auto mm = CD_IO::PortIndex0::ResponseFifo.read().raw; // minute number within track (00h and up)
|
||||
const auto ss = CD_IO::PortIndex0::ResponseFifo.read().raw; // second number within track (00h to 59h)
|
||||
const auto sect = CD_IO::PortIndex0::ResponseFifo.read().raw; // sector number within track (00h to 74h)
|
||||
last_track.min = CD_IO::PortIndex0::ResponseFifo.read().raw; // minute number on entire disk (00h and up)
|
||||
last_track.sec = CD_IO::PortIndex0::ResponseFifo.read().raw; // second number on entire disk (00h to 59h)
|
||||
last_track.sector = CD_IO::PortIndex0::ResponseFifo.read().raw; // sector number on entire disk (00h to 74h)
|
||||
}
|
||||
|
||||
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<CD_IO::PortIndex0>(CD_IO::Command::Play);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -15,8 +15,8 @@ namespace JabyEngine {
|
|||
}
|
||||
|
||||
static void clear_cd_and_ext_audio_volume() {
|
||||
CDVolume::Left.write(0.5_vol);
|
||||
CDVolume::Right.write(0.5_vol);
|
||||
CDVolume::Left.write(0.75_vol);
|
||||
CDVolume::Right.write(0.75_vol);
|
||||
|
||||
ExternalAudioInputVolume::Left.write({0});
|
||||
ExternalAudioInputVolume::Right.write({0});
|
||||
|
|
Loading…
Reference in New Issue