Update SPU

This commit is contained in:
jaby 2024-09-28 13:52:36 +02:00
parent a76784065a
commit 4a46392f24
4 changed files with 10 additions and 9 deletions

View File

@ -21,13 +21,11 @@ namespace JabyEngine {
} }
namespace DMA { namespace DMA {
using words_t = size_t;
struct WordsReady { struct WordsReady {
uint32_t words_to_use; uint32_t words_to_use;
bool is_last; bool is_last;
static constexpr WordsReady calculate(const State::Configuration& config, words_t words_left) { static constexpr WordsReady calculate(const State::Configuration& config, size_t words_left) {
const auto config_data_words = (config.data_bytes/sizeof(uint32_t)); const auto config_data_words = (config.data_bytes/sizeof(uint32_t));
const auto words_to_use = (config_data_words > words_left) ? words_left : config_data_words; const auto words_to_use = (config_data_words > words_left) ? words_left : config_data_words;
@ -39,7 +37,7 @@ namespace JabyEngine {
}; };
template<typename T> template<typename T>
static words_t send_words(words_t words_to_send, bool send_all) { static size_t send_words(size_t words_to_send, bool send_all) {
auto blocks_to_send = words_to_send/16; auto blocks_to_send = words_to_send/16;
while(blocks_to_send > 0) { while(blocks_to_send > 0) {
const auto block_send = (blocks_to_send > UI16_MAX) ? UI16_MAX : blocks_to_send; const auto block_send = (blocks_to_send > UI16_MAX) ? UI16_MAX : blocks_to_send;

View File

@ -6,6 +6,7 @@ namespace JabyEngine {
namespace SPU_IO_Values { namespace SPU_IO_Values {
namespace MemoryMap { namespace MemoryMap {
static constexpr uintptr_t ADPCM = 0x01000; static constexpr uintptr_t ADPCM = 0x01000;
static constexpr uintptr_t End = 0x7FFFF;
} }
__declare_io_value(AD, uint16_t) { __declare_io_value(AD, uint16_t) {

View File

@ -3,7 +3,6 @@
namespace JabyEngine { namespace JabyEngine {
namespace SPU_MMU { namespace SPU_MMU {
// TODO: Make this work with words? Word align?
const uint8_t* allocate(uint8_t voice, size_t size); const uint8_t* allocate(uint8_t voice, size_t size);
void deallocate(uint8_t voice); void deallocate(uint8_t voice);
} }

View File

@ -12,7 +12,6 @@ namespace JabyEngine {
namespace SPU_MemoryMap = SPU_IO::MemoryMap; namespace SPU_MemoryMap = SPU_IO::MemoryMap;
struct SPUMemory { struct SPUMemory {
// TODO: v change to uint16_t??
const uint8_t* adr; const uint8_t* adr;
size_t size; size_t size;
@ -76,15 +75,19 @@ namespace JabyEngine {
} }
}; };
static VoiceManager voice_mgr; static VoiceManager voice_mgr;
static const uint8_t* reverb_adr = reinterpret_cast<const uint8_t*>(SPU_MemoryMap::End);
// ^ change this to allocate reverb
using MemoryFoundCallback = const uint8_t* (AllocatedVoice& new_entry, AllocatedVoice* &prev_entry, AllocatedVoice* next_entry); using MemoryFoundCallback = const uint8_t* (AllocatedVoice& new_entry, AllocatedVoice* &prev_entry, AllocatedVoice* next_entry);
static const uint8_t* verify_and_add(AllocatedVoice& new_entry, AllocatedVoice* &prev_entry, AllocatedVoice* next_entry) { static const uint8_t* verify_and_add(AllocatedVoice& new_entry, AllocatedVoice* &prev_entry, AllocatedVoice* next_entry) {
// TODO: Verify that we are not crashing into reverb or that we are higher then SPU if(new_entry.memory.adr >= reverb_adr) {
return nullptr;
}
prev_entry = &new_entry; prev_entry = &new_entry;
new_entry.next_entry = next_entry; new_entry.next_entry = next_entry;
return new_entry.memory.adr; return new_entry.memory.adr;
} }