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