Add boot namespace and adjust names
This commit is contained in:
parent
974793c17b
commit
e3499dcd1e
|
@ -4,31 +4,32 @@
|
|||
|
||||
namespace JabyEngine {
|
||||
//boot namespace?
|
||||
|
||||
namespace CD {
|
||||
void setup();
|
||||
}
|
||||
namespace boot {
|
||||
namespace BootFile {
|
||||
JabyEngine::NextRoutine setup();
|
||||
}
|
||||
|
||||
namespace GPU {
|
||||
void display_logo();
|
||||
void setup();
|
||||
}
|
||||
namespace CD {
|
||||
void setup();
|
||||
}
|
||||
|
||||
namespace SPU {
|
||||
void stop_voices();
|
||||
void setup();
|
||||
}
|
||||
namespace GPU {
|
||||
void display_logo();
|
||||
void setup();
|
||||
}
|
||||
|
||||
namespace Setup {
|
||||
JabyEngine::NextRoutine start();
|
||||
}
|
||||
namespace SPU {
|
||||
void stop_voices();
|
||||
void setup();
|
||||
}
|
||||
|
||||
namespace BootFile {
|
||||
JabyEngine::NextRoutine setup();
|
||||
}
|
||||
namespace Start {
|
||||
JabyEngine::NextRoutine setup();
|
||||
}
|
||||
|
||||
namespace Timer {
|
||||
void setup();
|
||||
namespace Timer {
|
||||
void setup();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif //!BOOT_LOADER_HPP
|
|
@ -4,10 +4,12 @@
|
|||
extern JabyEngine::NextRoutine main();
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace BootFile {
|
||||
JabyEngine::NextRoutine setup() {
|
||||
printf("Running main!\n");
|
||||
return JabyEngine::NextRoutine::from(main);
|
||||
namespace boot {
|
||||
namespace BootFile {
|
||||
JabyEngine::NextRoutine setup() {
|
||||
printf("Running main!\n");
|
||||
return JabyEngine::NextRoutine::from(main);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,10 +2,12 @@
|
|||
#include <stdio.h>
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace BootFile {
|
||||
JabyEngine::NextRoutine setup() {
|
||||
printf("Overlay boot not implemented!\n");
|
||||
return JabyEngine::NextRoutine::null();
|
||||
namespace boot {
|
||||
namespace BootFile {
|
||||
JabyEngine::NextRoutine setup() {
|
||||
printf("Overlay boot not implemented!\n");
|
||||
return JabyEngine::NextRoutine::null();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,9 +2,11 @@
|
|||
#include <PSX/System/IOPorts/cd_io.hpp>
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace CD {
|
||||
void setup() {
|
||||
CD_IO::change_to_index0();
|
||||
namespace boot {
|
||||
namespace CD {
|
||||
void setup() {
|
||||
CD_IO::change_to_index0();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -13,45 +13,49 @@
|
|||
extern "C" uint32_t __boot_loader_end;
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace GPU {
|
||||
static size_t decompress_logo() {
|
||||
LZ4Decompressor lz4_decomp(reinterpret_cast<uint8_t*>(&__boot_loader_end));
|
||||
namespace boot {
|
||||
namespace GPU {
|
||||
using namespace JabyEngine::GPU;
|
||||
|
||||
static size_t decompress_logo() {
|
||||
LZ4Decompressor lz4_decomp(reinterpret_cast<uint8_t*>(&__boot_loader_end));
|
||||
|
||||
const auto [progress, bytes_ready] = lz4_decomp.process(ArrayRange(SplashScreen, sizeof(SplashScreen)), true);
|
||||
switch(progress) {
|
||||
case Progress::InProgress:
|
||||
printf("Decompressing still in progress... %llu\n", bytes_ready);
|
||||
break;
|
||||
const auto [progress, bytes_ready] = lz4_decomp.process(ArrayRange(SplashScreen, sizeof(SplashScreen)), true);
|
||||
switch(progress) {
|
||||
case Progress::InProgress:
|
||||
printf("Decompressing still in progress... %llu\n", bytes_ready);
|
||||
break;
|
||||
|
||||
case Progress::Error:
|
||||
printf("Error decompressing!!!\n");
|
||||
break;
|
||||
case Progress::Error:
|
||||
printf("Error decompressing!!!\n");
|
||||
break;
|
||||
|
||||
case Progress::Done:
|
||||
printf("Done decompressing: %llu Bytes ready\n", bytes_ready);
|
||||
break;
|
||||
case Progress::Done:
|
||||
printf("Done decompressing: %llu Bytes ready\n", bytes_ready);
|
||||
break;
|
||||
}
|
||||
|
||||
return bytes_ready;
|
||||
}
|
||||
|
||||
return bytes_ready;
|
||||
}
|
||||
void display_logo() {
|
||||
const auto bytes_ready = decompress_logo();
|
||||
|
||||
void display_logo() {
|
||||
const auto bytes_ready = decompress_logo();
|
||||
// Upload SplashScreen picture
|
||||
auto state = FileProcessor::create(&__boot_loader_end, SimpleTIM(32, 0, 0, 0));
|
||||
while(state.process((bytes_ready/sizeof(uint32_t))) == Progress::InProgress);
|
||||
|
||||
// Upload SplashScreen picture
|
||||
auto state = FileProcessor::create(&__boot_loader_end, SimpleTIM(32, 0, 0, 0));
|
||||
while(state.process((bytes_ready/sizeof(uint32_t))) == Progress::InProgress);
|
||||
Display::enable();
|
||||
}
|
||||
|
||||
Display::enable();
|
||||
}
|
||||
|
||||
void setup() {
|
||||
GPU_IO::GP1.write(GPU_IO::Command::GP1::Reset());
|
||||
internal::Screen::configurate();
|
||||
internal::Screen::exchange_buffer_and_display();
|
||||
|
||||
GPU::internal::wait_ready_for_CMD();
|
||||
GPU::internal::quick_fill_fast(Color24::Black(), PositionU16(32, 0), SizeU16(Display::Width, Display::Height));
|
||||
void setup() {
|
||||
GPU_IO::GP1.write(GPU_IO::Command::GP1::Reset());
|
||||
internal::Screen::configurate();
|
||||
internal::Screen::exchange_buffer_and_display();
|
||||
|
||||
GPU::internal::wait_ready_for_CMD();
|
||||
GPU::internal::quick_fill_fast(Color24::Black(), PositionU16(32, 0), SizeU16(Display::Width, Display::Height));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,97 +3,99 @@
|
|||
#include <limits.h>
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace SPU {
|
||||
using namespace JabyEngine;
|
||||
|
||||
static void clear_main_volume() {
|
||||
static constexpr auto StartVol = SPU_IO::SweepVolume::with(SPU_IO::SweepVolume::VolumeEnable, SPU_IO::SweepVolume::Volume.with(I16_MAX >> 2));
|
||||
|
||||
SPU_IO::MainVolume::Left.write(StartVol);
|
||||
SPU_IO::MainVolume::Right.write(StartVol);
|
||||
}
|
||||
|
||||
static void clear_cd_and_ext_audio_volume() {
|
||||
SPU_IO::CDVolume::Left.write(0);
|
||||
SPU_IO::CDVolume::Right.write(0);
|
||||
|
||||
SPU_IO::ExternalAudioInputVolume::Left.write(0);
|
||||
SPU_IO::ExternalAudioInputVolume::Right.write(0);
|
||||
}
|
||||
|
||||
static void clear_control_register() {
|
||||
SPU_IO::Control.write(SPU_IO::ControlRegister());
|
||||
}
|
||||
|
||||
static void clear_voice() {
|
||||
for(auto& voice : SPU_IO::Voice) {
|
||||
voice.volumeLeft.write(SPU_IO::SweepVolume());
|
||||
voice.volumeRight.write(SPU_IO::SweepVolume());
|
||||
voice.sampleRate.write(SPU_IO::SampleRate());
|
||||
voice.ad.write(SPU_IO::AD());
|
||||
voice.sr.write(SPU_IO::SR());
|
||||
voice.currentVolume.write(SPU_IO::SimpleVolume(0));
|
||||
|
||||
voice.adr.write(0x200);
|
||||
voice.repeatAdr.write(0x200);
|
||||
}
|
||||
}
|
||||
|
||||
static void clear_pmon() {
|
||||
SPU_IO::PMON.write(SPU_IO::PitchModFlags());
|
||||
}
|
||||
|
||||
static void clear_noise_and_echo() {
|
||||
SPU_IO::NON.write(SPU_IO::NoiseGenerator());
|
||||
SPU_IO::EON.write(SPU_IO::EchoOn());
|
||||
}
|
||||
|
||||
static void clear_reverb() {
|
||||
SPU_IO::Reverb::Volume::Left.write(0);
|
||||
SPU_IO::Reverb::Volume::Right.write(0);
|
||||
SPU_IO::Reverb::WorkAreaAdr.write(0);
|
||||
}
|
||||
|
||||
static void setup_control_register() {
|
||||
static constexpr auto SetupValue = SPU_IO::ControlRegister::with(SPU_IO::ControlRegister::Enable, SPU_IO::ControlRegister::Unmute, SPU_IO::ControlRegister::CDAudioEnable);
|
||||
|
||||
SPU_IO::Control.write(SetupValue);
|
||||
}
|
||||
|
||||
static void setup_data_transfer_control() {
|
||||
static constexpr uint16_t RequiredValue = (2 << 1);
|
||||
namespace boot {
|
||||
namespace SPU {
|
||||
using namespace JabyEngine;
|
||||
|
||||
SPU_IO::DataTransferControl.write(RequiredValue);
|
||||
}
|
||||
static void clear_main_volume() {
|
||||
static constexpr auto StartVol = SPU_IO::SweepVolume::with(SPU_IO::SweepVolume::VolumeEnable, SPU_IO::SweepVolume::Volume.with(I16_MAX >> 2));
|
||||
|
||||
static void wait_voices() {
|
||||
static constexpr int16_t Treshhold = (I16_MAX*0.03);
|
||||
SPU_IO::MainVolume::Left.write(StartVol);
|
||||
SPU_IO::MainVolume::Right.write(StartVol);
|
||||
}
|
||||
|
||||
try_again:
|
||||
for(const auto& voice : SPU_IO::Voice) {
|
||||
if(voice.currentVolume.read() > Treshhold) {
|
||||
goto try_again;
|
||||
static void clear_cd_and_ext_audio_volume() {
|
||||
SPU_IO::CDVolume::Left.write(0);
|
||||
SPU_IO::CDVolume::Right.write(0);
|
||||
|
||||
SPU_IO::ExternalAudioInputVolume::Left.write(0);
|
||||
SPU_IO::ExternalAudioInputVolume::Right.write(0);
|
||||
}
|
||||
|
||||
static void clear_control_register() {
|
||||
SPU_IO::Control.write(SPU_IO::ControlRegister());
|
||||
}
|
||||
|
||||
static void clear_voice() {
|
||||
for(auto& voice : SPU_IO::Voice) {
|
||||
voice.volumeLeft.write(SPU_IO::SweepVolume());
|
||||
voice.volumeRight.write(SPU_IO::SweepVolume());
|
||||
voice.sampleRate.write(SPU_IO::SampleRate());
|
||||
voice.ad.write(SPU_IO::AD());
|
||||
voice.sr.write(SPU_IO::SR());
|
||||
voice.currentVolume.write(SPU_IO::SimpleVolume(0));
|
||||
|
||||
voice.adr.write(0x200);
|
||||
voice.repeatAdr.write(0x200);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void stop_voices() {
|
||||
SPU_IO::Key::Off.write(UI32_MAX);
|
||||
}
|
||||
static void clear_pmon() {
|
||||
SPU_IO::PMON.write(SPU_IO::PitchModFlags());
|
||||
}
|
||||
|
||||
void setup() {
|
||||
wait_voices();
|
||||
static void clear_noise_and_echo() {
|
||||
SPU_IO::NON.write(SPU_IO::NoiseGenerator());
|
||||
SPU_IO::EON.write(SPU_IO::EchoOn());
|
||||
}
|
||||
|
||||
clear_main_volume();
|
||||
clear_cd_and_ext_audio_volume();
|
||||
clear_control_register();
|
||||
clear_voice();
|
||||
clear_pmon();
|
||||
clear_noise_and_echo();
|
||||
clear_reverb();
|
||||
static void clear_reverb() {
|
||||
SPU_IO::Reverb::Volume::Left.write(0);
|
||||
SPU_IO::Reverb::Volume::Right.write(0);
|
||||
SPU_IO::Reverb::WorkAreaAdr.write(0);
|
||||
}
|
||||
|
||||
setup_data_transfer_control();
|
||||
setup_control_register();
|
||||
static void setup_control_register() {
|
||||
static constexpr auto SetupValue = SPU_IO::ControlRegister::with(SPU_IO::ControlRegister::Enable, SPU_IO::ControlRegister::Unmute, SPU_IO::ControlRegister::CDAudioEnable);
|
||||
|
||||
SPU_IO::Control.write(SetupValue);
|
||||
}
|
||||
|
||||
static void setup_data_transfer_control() {
|
||||
static constexpr uint16_t RequiredValue = (2 << 1);
|
||||
|
||||
SPU_IO::DataTransferControl.write(RequiredValue);
|
||||
}
|
||||
|
||||
static void wait_voices() {
|
||||
static constexpr int16_t Treshhold = (I16_MAX*0.03);
|
||||
|
||||
try_again:
|
||||
for(const auto& voice : SPU_IO::Voice) {
|
||||
if(voice.currentVolume.read() > Treshhold) {
|
||||
goto try_again;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void stop_voices() {
|
||||
SPU_IO::Key::Off.write(UI32_MAX);
|
||||
}
|
||||
|
||||
void setup() {
|
||||
wait_voices();
|
||||
|
||||
clear_main_volume();
|
||||
clear_cd_and_ext_audio_volume();
|
||||
clear_control_register();
|
||||
clear_voice();
|
||||
clear_pmon();
|
||||
clear_noise_and_echo();
|
||||
clear_reverb();
|
||||
|
||||
setup_data_transfer_control();
|
||||
setup_control_register();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,28 +5,30 @@
|
|||
#include <stdio.h>
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace Setup {
|
||||
static void enable_DMA() {
|
||||
DMA_IO::DPCR.write(DMA_IO::DPCR.read() | DMA_IO::DMAControlRegister::SPUEnable | DMA_IO::DMAControlRegister::GPUEnable);
|
||||
}
|
||||
namespace boot {
|
||||
namespace Start {
|
||||
static void enable_DMA() {
|
||||
DMA_IO::DPCR.write(DMA_IO::DPCR.read() | DMA_IO::DMAControlRegister::SPUEnable | DMA_IO::DMAControlRegister::GPUEnable);
|
||||
}
|
||||
|
||||
JabyEngine::NextRoutine start() {
|
||||
enable_DMA();
|
||||
JabyEngine::NextRoutine setup() {
|
||||
enable_DMA();
|
||||
|
||||
SPU::stop_voices();
|
||||
Timer::setup();
|
||||
SPU::stop_voices();
|
||||
Timer::setup();
|
||||
|
||||
const auto start = HighResTime::get_time_stamp();
|
||||
printf("Start...\n");
|
||||
GPU::setup();
|
||||
GPU::display_logo();
|
||||
const auto end = HighResTime::get_time_stamp();
|
||||
printf("GPU setup took %ims %ius\n", start.milliseconds_to(end), start.microseconds_to(end));
|
||||
|
||||
//Pause??
|
||||
const auto start = HighResTime::get_time_stamp();
|
||||
printf("Start...\n");
|
||||
GPU::setup();
|
||||
GPU::display_logo();
|
||||
const auto end = HighResTime::get_time_stamp();
|
||||
printf("GPU setup took %ims %ius\n", start.milliseconds_to(end), start.microseconds_to(end));
|
||||
|
||||
//Pause??
|
||||
|
||||
SPU::setup();
|
||||
return BootFile::setup();
|
||||
SPU::setup();
|
||||
return BootFile::setup();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,28 +9,37 @@
|
|||
namespace JabyEngine {
|
||||
namespace Timer {
|
||||
extern InterrupCallback IRQCallback;
|
||||
void setup() {
|
||||
using namespace Timer_IO;
|
||||
}
|
||||
|
||||
static constexpr auto Mode = CounterMode::with(CounterMode::FreeRun, Counter2::SyncMode::Freerun, CounterMode::ResetAfterTarget, CounterMode::IRQAtTarget, CounterMode::IRQEveryTime, CounterMode::IRQPulse, Counter2::Source::System_Clock_Div_8);
|
||||
namespace boot {
|
||||
namespace Timer {
|
||||
using namespace JabyEngine::Timer;
|
||||
|
||||
void setup() {
|
||||
using namespace Timer_IO;
|
||||
|
||||
Interrupt::disable_irq(Interrupt::Timer2);
|
||||
static constexpr auto Mode = CounterMode::with(CounterMode::FreeRun, Counter2::SyncMode::Freerun, CounterMode::ResetAfterTarget, CounterMode::IRQAtTarget, CounterMode::IRQEveryTime, CounterMode::IRQPulse, Counter2::Source::System_Clock_Div_8);
|
||||
|
||||
__syscall_EnterCriticalSection();
|
||||
__syscall_SysEnqIntRP(Timer2Irq, &IRQCallback);
|
||||
__syscall_ExitCriticalSection();
|
||||
Interrupt::disable_irq(Interrupt::Timer2);
|
||||
|
||||
Counter2.target.write(CounterTarget::CounterTargetValue.with(HighResTime::TicksFor10ms));
|
||||
Counter2.mode.write(Mode);
|
||||
__syscall_EnterCriticalSection();
|
||||
__syscall_SysEnqIntRP(Timer2Irq, &IRQCallback);
|
||||
__syscall_ExitCriticalSection();
|
||||
|
||||
Interrupt::enable_irq(Interrupt::Timer2);
|
||||
Counter2.target.write(CounterTarget::CounterTargetValue.with(HighResTime::TicksFor10ms));
|
||||
Counter2.mode.write(Mode);
|
||||
|
||||
Interrupt::enable_irq(Interrupt::Timer2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
namespace JabyEngine {
|
||||
namespace Timer {
|
||||
void setup() {
|
||||
namespace boot {
|
||||
namespace Timer {
|
||||
void setup() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace JabyEngine {
|
|||
}
|
||||
|
||||
void start() {
|
||||
NextRoutine next_routine = JabyEngine::NextRoutine::from(Setup::start);
|
||||
NextRoutine next_routine = JabyEngine::NextRoutine::from(boot::Start::setup);
|
||||
|
||||
printf("Starting Planschbecken 0x%p\n", next_routine.value);
|
||||
while(true) {
|
||||
|
|
Loading…
Reference in New Issue