Make SPU wait for boot up sound to finish
This commit is contained in:
parent
f5d1453555
commit
b5533733c3
|
@ -25,6 +25,8 @@ namespace SPU {
|
|||
//0..3 = +7, +6, +5, +4 or -6, -7, -6, -5
|
||||
typedef uint8_t Step;
|
||||
|
||||
typedef int16_t SimpleVolume;
|
||||
|
||||
struct __no_align SampleRate : public ComplexBitMap<uint16_t> {
|
||||
__io_port_inherit_complex_bit_map(SampleRate);
|
||||
|
||||
|
@ -74,14 +76,14 @@ namespace SPU {
|
|||
};
|
||||
|
||||
struct __no_align Voice {
|
||||
IOPort<SweepVolume> volumeLeft; //Offset: 0x0
|
||||
IOPort<SweepVolume> volumeRight; //Offset: 0x2
|
||||
IOPort<SampleRate> sampleRate; //Offset: 0x4;
|
||||
IOPort<uint16_t> adr; //Offset: 0x6
|
||||
IOPort<AD> ad; //Offset: 0x8
|
||||
IOPort<SR> sr; //Offset: 0xA
|
||||
IOPort<SweepVolume> currentVolume; //Offset: 0xC
|
||||
IOPort<uint16_t> repeatAdr; //Offset: 0xE
|
||||
IOPort<SweepVolume> volumeLeft; //Offset: 0x0
|
||||
IOPort<SweepVolume> volumeRight; //Offset: 0x2
|
||||
IOPort<SampleRate> sampleRate; //Offset: 0x4;
|
||||
IOPort<uint16_t> adr; //Offset: 0x6
|
||||
IOPort<AD> ad; //Offset: 0x8
|
||||
IOPort<SR> sr; //Offset: 0xA
|
||||
IOPort<SimpleVolume> currentVolume; //Offset: 0xC
|
||||
IOPort<uint16_t> repeatAdr; //Offset: 0xE
|
||||
};
|
||||
|
||||
struct __no_align ControlRegister : public ComplexBitMap<uint16_t> {
|
||||
|
@ -139,19 +141,19 @@ namespace SPU {
|
|||
}
|
||||
|
||||
namespace CDVolume {
|
||||
__declare_io_port_global(int16_t, left, 0x1F801DB0);
|
||||
__declare_io_port_global(int16_t, right, 0x1F801DB2);
|
||||
__declare_io_port_global(SimpleVolume, left, 0x1F801DB0);
|
||||
__declare_io_port_global(SimpleVolume, right, 0x1F801DB2);
|
||||
}
|
||||
|
||||
namespace ExternalAudioInputVolume {
|
||||
__declare_io_port_global(int16_t, left, 0x1F801DB4);
|
||||
__declare_io_port_global(int16_t, right, 0x1F801DB6);
|
||||
__declare_io_port_global(SimpleVolume, left, 0x1F801DB4);
|
||||
__declare_io_port_global(SimpleVolume, right, 0x1F801DB6);
|
||||
}
|
||||
|
||||
namespace Reverb {
|
||||
namespace Volume {
|
||||
__declare_io_port_global(int16_t, left, 0x1F801D84);
|
||||
__declare_io_port_global(int16_t, right, 0x1F801D86);
|
||||
__declare_io_port_global(SimpleVolume, left, 0x1F801D84);
|
||||
__declare_io_port_global(SimpleVolume, right, 0x1F801D86);
|
||||
}
|
||||
__declare_io_port_global(uint16_t, work_area_adr, 0x1F801DA2);
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ namespace GPU {
|
|||
}
|
||||
|
||||
namespace SPU {
|
||||
void stop_voices();
|
||||
void setup();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,15 +1,12 @@
|
|||
#include <PSX/System/IOPorts/SPU_IO.hpp>
|
||||
#include <PSX/System/IOPorts/DMA_IO.hpp>
|
||||
#include <stdio.h>
|
||||
#include <limits.h>
|
||||
|
||||
namespace SPU {
|
||||
using namespace Port;
|
||||
using namespace DMA::Port;
|
||||
|
||||
static void clear_key() {
|
||||
Key::off.write(UI32_MAX);
|
||||
}
|
||||
|
||||
static void clear_main_volume() {
|
||||
static constexpr auto StartVol = SweepVolume::with(SweepVolume::VolumeEnable, SweepVolume::Volume.with(I16_MAX >> 2));
|
||||
|
||||
|
@ -70,8 +67,24 @@ namespace SPU {
|
|||
DataTransferControl.write(RequiredValue);
|
||||
}
|
||||
|
||||
static void wait_voices() {
|
||||
static constexpr int16_t Treshhold = (I16_MAX*0.03);
|
||||
|
||||
try_again:
|
||||
for(const auto& voice : Voices) {
|
||||
if(voice.currentVolume.read() > Treshhold) {
|
||||
goto try_again;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void stop_voices() {
|
||||
Key::off.write(UI32_MAX);
|
||||
}
|
||||
|
||||
void setup() {
|
||||
clear_key();
|
||||
wait_voices();
|
||||
|
||||
clear_main_volume();
|
||||
clear_cd_and_ext_audio_volume();
|
||||
clear_control_register();
|
||||
|
|
|
@ -4,7 +4,13 @@
|
|||
namespace JabyEngine {
|
||||
void start() {
|
||||
printf("Hello Planschbecken\n");
|
||||
//We key off the voices
|
||||
SPU::stop_voices();
|
||||
|
||||
//Load picture here
|
||||
//Pause??
|
||||
|
||||
//Do the real setup
|
||||
GPU::setup();
|
||||
SPU::setup();
|
||||
printf("Setup done!\n");
|
||||
|
|
Loading…
Reference in New Issue