Improve SPU code and support state of voice
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace SPU_MMU {
|
||||
// TODO: Make this work with words? Word align?
|
||||
const uint8_t* allocate(uint8_t voice, size_t size);
|
||||
void deallocate(uint8_t voice);
|
||||
}
|
||||
|
@@ -59,7 +59,7 @@ namespace JabyEngine {
|
||||
simple_assert(2, SPU_MMU::allocate(0, 0x300), calculate_spu_adr(0x0));
|
||||
simple_assert(3, SPU_MMU::allocate(2, 0x300), calculate_spu_adr(0x300));
|
||||
|
||||
// TODO: More tests
|
||||
// TODO: More tests
|
||||
}
|
||||
|
||||
namespace boot {
|
||||
|
@@ -52,11 +52,14 @@ namespace JabyEngine {
|
||||
static Progress parse_header(State::Configuration& config, VAGState& state) {
|
||||
if(config.data_bytes >= sizeof(VAGHeader)) {
|
||||
const auto& header = *reinterpret_cast<const VAGHeader*>(config.data_adr);
|
||||
const auto bytes = header.get_sample_size();
|
||||
const auto words = bytes_to_words(header.get_sample_size());
|
||||
const auto bytes = words_to_bytes(words);
|
||||
|
||||
state.words_left = bytes_to_words(bytes);
|
||||
state.words_left = words;
|
||||
|
||||
auto sram_adr = SPU::voice[state.voice_id].allocate(SPU_IO::SampleRate::from_HZ(header.get_sample_frequency()), words_to_bytes(state.words_left));
|
||||
auto sram_adr = SPU::voice[state.voice_id].allocate(SPU_IO::SampleRate::from_HZ(header.get_sample_frequency()), bytes);
|
||||
// TODO: Keep this as optional?
|
||||
printf("SPU: Allocated %i @0x%p to 0x%p (%i bytes)\n", state.voice_id, sram_adr.raw, (sram_adr.raw + bytes), bytes);
|
||||
SPU::voice[state.voice_id].set_volume(state.inital_vol, state.inital_vol);
|
||||
|
||||
config.processed(sizeof(VAGHeader));
|
||||
|
Reference in New Issue
Block a user