Increase PoolBox to Version 0.9.0

This commit is contained in:
Jaby 2024-07-29 13:36:06 -05:00
parent 7b189445af
commit e609d2b406
12 changed files with 119 additions and 54 deletions

View File

@ -23,6 +23,7 @@ namespace Assets {
void load_bios_info(); void load_bios_info();
void load_controller_test(); void load_controller_test();
void load_gpu_test(); void load_gpu_test();
void load_large_gpu_test();
void load_gte_test(); void load_gte_test();
void load_font_cycler(); void load_font_cycler();
void load_screen_center(); void load_screen_center();

View File

@ -13,10 +13,32 @@ namespace GPUTest {
}; };
__declare_lba_header(LBA); __declare_lba_header(LBA);
CDFile Assets[18] = { CDFile Assets[2] = {
CDFileBuilder::simple_tim(LBA::TEX, TexPageTIM), CDFileBuilder::simple_tim(LBA::TEX, TexPageTIM),
CDFileBuilder::simple_tim(LBA::ICON, IconTIM), CDFileBuilder::simple_tim(LBA::ICON, IconTIM),
};
CDFile LargeAssets[36] = {
CDFileBuilder::simple_tim(LBA::TEX, TexPageTIM),
CDFileBuilder::simple_tim(LBA::ICON, IconTIM),
CDFileBuilder::simple_tim(LBA::TEX, TexPageTIM),
CDFileBuilder::simple_tim(LBA::TEX, TexPageTIM),
CDFileBuilder::simple_tim(LBA::ICON, IconTIM),
CDFileBuilder::simple_tim(LBA::ICON, IconTIM),
CDFileBuilder::simple_tim(LBA::ICON, IconTIM),
CDFileBuilder::simple_tim(LBA::TEX, TexPageTIM),
CDFileBuilder::simple_tim(LBA::TEX, TexPageTIM),
CDFileBuilder::simple_tim(LBA::ICON, IconTIM),
CDFileBuilder::simple_tim(LBA::TEX, TexPageTIM),
CDFileBuilder::simple_tim(LBA::TEX, TexPageTIM),
CDFileBuilder::simple_tim(LBA::ICON, IconTIM),
CDFileBuilder::simple_tim(LBA::ICON, IconTIM),
CDFileBuilder::simple_tim(LBA::ICON, IconTIM),
CDFileBuilder::simple_tim(LBA::TEX, TexPageTIM),
CDFileBuilder::simple_tim(LBA::TEX, TexPageTIM),
CDFileBuilder::simple_tim(LBA::ICON, IconTIM),
CDFileBuilder::simple_tim(LBA::TEX, TexPageTIM),
CDFileBuilder::simple_tim(LBA::ICON, IconTIM),
CDFileBuilder::simple_tim(LBA::TEX, TexPageTIM), CDFileBuilder::simple_tim(LBA::TEX, TexPageTIM),
CDFileBuilder::simple_tim(LBA::TEX, TexPageTIM), CDFileBuilder::simple_tim(LBA::TEX, TexPageTIM),
CDFileBuilder::simple_tim(LBA::ICON, IconTIM), CDFileBuilder::simple_tim(LBA::ICON, IconTIM),

View File

@ -14,7 +14,8 @@ namespace ControllerTest {
namespace GPUTest { namespace GPUTest {
extern const volatile JabyEngine::AutoLBAEntry lba[]; extern const volatile JabyEngine::AutoLBAEntry lba[];
extern JabyEngine::CDFile Assets[18]; extern JabyEngine::CDFile Assets[2];
extern JabyEngine::CDFile LargeAssets[36];
void main(); void main();
} }

View File

@ -5,7 +5,7 @@
#include "Overlay/Overlays.hpp" #include "Overlay/Overlays.hpp"
#include <FontWriter/fonts.hpp> #include <FontWriter/fonts.hpp>
#include <FontWriter/font_writer.hpp> #include <FontWriter/font_writer.hpp>
//#include <PSX/Audio/CDDA.hpp> #include <PSX/Audio/CDDA.hpp>
#include <PSX/Audio/CDXA.hpp> #include <PSX/Audio/CDXA.hpp>
#include <PSX/Periphery/periphery.hpp> #include <PSX/Periphery/periphery.hpp>
#include <stdio.hpp> #include <stdio.hpp>
@ -13,35 +13,68 @@
using namespace JabyEngine; using namespace JabyEngine;
using DigitalButton = Periphery::GenericController::Button; using DigitalButton = Periphery::GenericController::Button;
struct XAPlayer { struct CDPlayer {
static constexpr auto MaxChannels = 2; static constexpr auto MaxChannels = 2;
uint8_t channel; uint8_t channel;
bool is_xa;
static XAPlayer create() { static constexpr CDPlayer create() {
return XAPlayer{0}; return CDPlayer{.channel = 0, .is_xa = true};
} }
void play() { void play() {
this->channel = 0; if(this->is_xa) {
Assets::XAAudio::play_fox(); Assets::XAAudio::play_fox();
}
else {
const auto [first_track, last_track] = CDDA::get_tracks();
CDDA::play(first_track);
}
} }
void stop() { void stop() {
CDXA::stop(); if(this->is_xa) {
CDXA::stop();
}
else {
CDDA::stop();
}
} }
void change_channel(int8_t step) { void change_channel(int8_t step) {
this->channel = static_cast<uint8_t>((this->channel + step))%MaxChannels; if(this->is_xa) {
CDXA::set_channel(this->channel); this->channel = static_cast<uint8_t>((this->channel + step))%MaxChannels;
CDXA::set_channel(this->channel);
}
}
void change_audio() {
CDPlayer::stop();
this->is_xa = !this->is_xa;
CDPlayer::play();
} }
void push() { void push() {
CDXA::push_play(); if(this->is_xa) {
CDXA::push_play();
}
else {
CDDA::push_play();
}
} }
void pop() { void pop() {
CDXA::pop_play(); if(this->is_xa) {
CDXA::pop_play();
}
else {
CDDA::pop_play();
}
} }
}; };
@ -80,7 +113,7 @@ static const auto doener_fish = Make::SPRT(
GPU::Color24::Grey() GPU::Color24::Grey()
); );
static XAPlayer xa = XAPlayer::create(); static CDPlayer cd_player = CDPlayer::create();
static object::Paco paco; static object::Paco paco;
static Menu::SimpleMenu menu; static Menu::SimpleMenu menu;
static StateChange state_changer; static StateChange state_changer;
@ -101,8 +134,9 @@ static void setup() {
const auto& controller = Periphery::get_primary_controller_as<JabyEngine::Periphery::GenericController>(); const auto& controller = Periphery::get_primary_controller_as<JabyEngine::Periphery::GenericController>();
// With this approach we can default load_test to true for debugging reasons // With this approach we can default load_test to true for debugging reasons
if(controller.button.is_down(DigitalButton::R2) && controller.button.is_down(DigitalButton::L2)) { if(controller.is_connected()) {
Shared::load_test = true; // TODO: Make this work on the PS3
Shared::load_test = controller.button.is_down(DigitalButton::R2) && controller.button.is_down(DigitalButton::L2);
} }
Assets::Main::load(); Assets::Main::load();
@ -144,11 +178,7 @@ static void setup() {
} }
},MenuEntries); },MenuEntries);
// TODO: CDDA? cd_player.play();
// const auto [first_track, last_track] = CDDA::get_tracks();
// CDDA::play(first_track);
xa.play();
} }
namespace NormalScene { namespace NormalScene {
@ -161,12 +191,16 @@ namespace NormalScene {
Periphery::query_controller(); Periphery::query_controller();
const auto& controller = Periphery::get_primary_controller_as<JabyEngine::Periphery::GenericController>(); const auto& controller = Periphery::get_primary_controller_as<JabyEngine::Periphery::GenericController>();
if(controller.button.went_down(DigitalButton::SEL)) {
cd_player.change_audio();
}
if(controller.button.went_down(DigitalButton::R1)) { if(controller.button.went_down(DigitalButton::R1)) {
xa.change_channel(1); cd_player.change_channel(1);
} }
if(controller.button.went_down(DigitalButton::L1)) { if(controller.button.went_down(DigitalButton::L1)) {
xa.change_channel(-1); cd_player.change_channel(-1);
} }
auto cursor = FontWriter::update(Make::PositionI16((GPU::Display::Width-TitleLength)/2, 16)); auto cursor = FontWriter::update(Make::PositionI16((GPU::Display::Width-TitleLength)/2, 16));
@ -176,10 +210,9 @@ namespace NormalScene {
FontWriter::new_font_writer.write(cursor.change_position(Make::PositionI16((GPU::Display::Width-VersionLength)/2, 16 + DefaultFont::Info.get_kern_size().height)), Version, GPU::Color24::Green(0xD0), &FontWriter::wiggle); FontWriter::new_font_writer.write(cursor.change_position(Make::PositionI16((GPU::Display::Width-VersionLength)/2, 16 + DefaultFont::Info.get_kern_size().height)), Version, GPU::Color24::Green(0xD0), &FontWriter::wiggle);
menu.update(FontWriter::bios_font_writer, cursor, Make::PositionI16(8, 64)); menu.update(FontWriter::bios_font_writer, cursor, Make::PositionI16(8, 64));
if(Shared::load_test) { if(Shared::load_test) {
// Force state change if we are in the load_test state // Force state change if we are in the load_test state
state_changer.asset_load = Assets::Overlay::load_gpu_test; state_changer.asset_load = Assets::Overlay::load_large_gpu_test;
state_changer.main = GPUTest::main; state_changer.main = GPUTest::main;
} }
@ -220,10 +253,10 @@ namespace LoadingScene {
render(); render();
GPU::swap_buffers_vsync(1); GPU::swap_buffers_vsync(1);
xa.push(); cd_player.push();
state_changer.asset_load(); state_changer.asset_load();
old_state_changer = state_changer; old_state_changer = state_changer;
xa.pop(); cd_player.pop();
} }
state_changer.main(); state_changer.main();

View File

@ -96,6 +96,10 @@ namespace Assets {
load(CDFileBuilder::overlay(LBA::GPU_TEST_OVL, &__gpu_tests_start), GPUTest::lba, GPUTest::Assets); load(CDFileBuilder::overlay(LBA::GPU_TEST_OVL, &__gpu_tests_start), GPUTest::lba, GPUTest::Assets);
} }
void load_large_gpu_test() {
load(CDFileBuilder::overlay(LBA::GPU_TEST_OVL, &__gpu_tests_start), GPUTest::lba, GPUTest::LargeAssets);
}
void load_gte_test() { void load_gte_test() {
load(CDFileBuilder::overlay(LBA::GTE_TEST_OVL, &__gpu_tests_start), GTETest::lba, GTETest::Assets); load(CDFileBuilder::overlay(LBA::GTE_TEST_OVL, &__gpu_tests_start), GTETest::lba, GTETest::Assets);
} }

View File

@ -4,14 +4,13 @@
<Defaults> <Defaults>
<Data lead-out="0:2:0"\> <Data lead-out="0:2:0"\>
<Directory hidden="true"\> <Directory hidden="true"\>
<File lz4="already"\><<<<> <File lz4="already"\>
<CD_Audio Alignment="True"\> <CD_Audio Alignment="True"\>
</Defaults>--> </Defaults>-->
<Description> <Description>
<Publisher>Jaby</Publisher> <Publisher>Jaby</Publisher>
<License>%PSX_LICENSE_PATH%/%PSX_LICENSE%.DAT</License> <License>%PSX_LICENSE_PATH%/%PSX_LICENSE%.DAT</License>
</Description> </Description>
<!--TODO: Rename `Track` to `Data`-->
<Filesystem lead-out="0:2:0"> <Filesystem lead-out="0:2:0">
<File name = "SYSTEM.CNF">System.cnf.subst</File> <File name = "SYSTEM.CNF">System.cnf.subst</File>
<Main name = "%PSX_BOOT_FILE%" lba_source = "../application/src/asset_mgr.cpp" >../application/bin/%PSX_TV_FORMAT%/PSX-release/PoolBox.psexe</Main> <Main name = "%PSX_BOOT_FILE%" lba_source = "../application/src/asset_mgr.cpp" >../application/bin/%PSX_TV_FORMAT%/PSX-release/PoolBox.psexe</Main>

View File

@ -1,32 +1,30 @@
#pragma once #pragma once
#include "../../stdint.hpp" #include "../../stdint.hpp"
namespace JabyEngine { static constexpr int8_t operator""_i8(unsigned long long int value) {
static constexpr int8_t operator""_i8(unsigned long long int value) { return static_cast<int8_t>(value);
return static_cast<int8_t>(value); }
}
static constexpr uint8_t operator""_u8(unsigned long long int value) { static constexpr uint8_t operator""_u8(unsigned long long int value) {
return static_cast<uint8_t>(value); return static_cast<uint8_t>(value);
} }
// ################################################################### // ###################################################################
static constexpr int16_t operator""_i16(unsigned long long int value) { static constexpr int16_t operator""_i16(unsigned long long int value) {
return static_cast<int16_t>(value); return static_cast<int16_t>(value);
} }
static constexpr uint16_t operator""_u16(unsigned long long int value) { static constexpr uint16_t operator""_u16(unsigned long long int value) {
return static_cast<uint16_t>(value); return static_cast<uint16_t>(value);
} }
// ################################################################### // ###################################################################
static constexpr int32_t operator""_i32(unsigned long long int value) { static constexpr int32_t operator""_i32(unsigned long long int value) {
return static_cast<int32_t>(value); return static_cast<int32_t>(value);
} }
static constexpr uint32_t operator""_u32(unsigned long long int value) { static constexpr uint32_t operator""_u32(unsigned long long int value) {
return static_cast<uint32_t>(value); return static_cast<uint32_t>(value);
}
} }

View File

@ -3,9 +3,6 @@
namespace JabyEngine { namespace JabyEngine {
namespace Make { namespace Make {
using JabyEngine::operator""_i16;
using JabyEngine::operator""_u16;
template<typename T, typename...ARGS> template<typename T, typename...ARGS>
static constexpr T creator_template(const ARGS&...args) { static constexpr T creator_template(const ARGS&...args) {
return T::create(args...); return T::create(args...);

View File

@ -50,6 +50,10 @@ namespace JabyEngine {
return RawController::header.rumble1; return RawController::header.rumble1;
} }
bool is_connected() const {
return RawController::header.state != RawController::State::Disconnected;
}
bool is_useable() const { bool is_useable() const {
const auto type = RawController::get_type(); const auto type = RawController::get_type();
return ((RawController::header.state == RawController::State::Stable) && (type == ControllerType::Controller || type == ControllerType::DualShock)); return ((RawController::header.state == RawController::State::Stable) && (type == ControllerType::Controller || type == ControllerType::DualShock));

View File

@ -1,4 +1,5 @@
#pragma once #pragma once
#include "Auxiliary/literals.hpp"
#include <stddef.hpp> #include <stddef.hpp>
#define __used __attribute__((used)) #define __used __attribute__((used))

View File

@ -30,7 +30,10 @@ namespace JabyEngine {
playing_track.min = CD_IO::PortIndex0::ResponseFifo.read().raw; playing_track.min = CD_IO::PortIndex0::ResponseFifo.read().raw;
playing_track.sec = CD_IO::PortIndex0::ResponseFifo.read().raw; playing_track.sec = CD_IO::PortIndex0::ResponseFifo.read().raw;
CD::Command::send(CD_IO::Command::Play, track); CD::Command::send(CD_IO::Command::SetLoc, playing_track.min, playing_track.sec, 0x0_u8);
CD::Command::send(CD_IO::Command::Play);
// The PS3 does not support playing a track by track id
//CD::Command::send(CD_IO::Command::Play, track);
} }
void stop() { void stop() {

View File

@ -5,6 +5,8 @@
#include <PSX/System/syscalls.hpp> #include <PSX/System/syscalls.hpp>
#include <stdio.hpp> #include <stdio.hpp>
// TODO: Outsource the interrupt handler to new source file?
// TODO: Do not spawn a new thread for handling the CD interrupt but use that thread for loading files or something?
namespace JabyEngine { namespace JabyEngine {
namespace CDDA { namespace CDDA {
extern CD::internal::BCDTimeStamp playing_track; extern CD::internal::BCDTimeStamp playing_track;