diff --git a/examples/PoolBox/application/src/application.cpp b/examples/PoolBox/application/src/application.cpp index 88a3f630..e2ff39e6 100644 --- a/examples/PoolBox/application/src/application.cpp +++ b/examples/PoolBox/application/src/application.cpp @@ -5,6 +5,7 @@ #include "Overlay/Overlays.hpp" #include #include +#include #include #include @@ -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(); diff --git a/examples/PoolBox/application/src/menu.cpp b/examples/PoolBox/application/src/menu.cpp index 931ff4ec..afe4b942 100644 --- a/examples/PoolBox/application/src/menu.cpp +++ b/examples/PoolBox/application/src/menu.cpp @@ -1,5 +1,4 @@ #include "include/menu.hpp" -#include #include 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; diff --git a/examples/PoolBox/iso/Config.xml b/examples/PoolBox/iso/Config.xml index 66f7e8c1..fa2cc9af 100644 --- a/examples/PoolBox/iso/Config.xml +++ b/examples/PoolBox/iso/Config.xml @@ -33,5 +33,4 @@ ../assets/audio/Evacuation_cdda.wav - ../assets/audio/Evacuation_cdda.wav \ No newline at end of file diff --git a/include/PSX/Audio/CDDA.hpp b/include/PSX/Audio/CDDA.hpp index 4d72dd13..bea2d1d6 100644 --- a/include/PSX/Audio/CDDA.hpp +++ b/include/PSX/Audio/CDDA.hpp @@ -16,5 +16,8 @@ namespace JabyEngine { void play(uint8_t track); void pause(); + + void push_play(); + void pop_play(); } } \ No newline at end of file diff --git a/include/PSX/System/IOPorts/cd_io.hpp b/include/PSX/System/IOPorts/cd_io.hpp index f4b8ee97..8c1038bf 100644 --- a/include/PSX/System/IOPorts/cd_io.hpp +++ b/include/PSX/System/IOPorts/cd_io.hpp @@ -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}; }; diff --git a/src/Library/src/Audio/CDDA.cpp b/src/Library/src/Audio/CDDA.cpp index ca76bb9c..527e5ec4 100644 --- a/src/Library/src/Audio/CDDA.cpp +++ b/src/Library/src/Audio/CDDA.cpp @@ -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::Command::Pause); } + + void push_play() { + pause(); + CD::Command::wait_completed(); + CD::Command::send_wait(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::Command::SetLoc, last_track.min, last_track.sec, last_track.sector); + CD::enable_CDDA(); // < Command waits + CD::Command::send(CD_IO::Command::Play); + } } } \ No newline at end of file diff --git a/src/Library/src/BootLoader/spu_boot.cpp b/src/Library/src/BootLoader/spu_boot.cpp index fe4733fb..1e0d9ad9 100644 --- a/src/Library/src/BootLoader/spu_boot.cpp +++ b/src/Library/src/BootLoader/spu_boot.cpp @@ -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});