diff --git a/include/PSX/File/file_processor_helper.hpp b/include/PSX/File/file_processor_helper.hpp index facc5af2..e65efd83 100644 --- a/include/PSX/File/file_processor_helper.hpp +++ b/include/PSX/File/file_processor_helper.hpp @@ -21,13 +21,11 @@ namespace JabyEngine { } namespace DMA { - using words_t = size_t; - struct WordsReady { uint32_t words_to_use; 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 words_to_use = (config_data_words > words_left) ? words_left : config_data_words; @@ -39,7 +37,7 @@ namespace JabyEngine { }; template - 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; while(blocks_to_send > 0) { const auto block_send = (blocks_to_send > UI16_MAX) ? UI16_MAX : blocks_to_send; diff --git a/include/PSX/System/IOPorts/IOValues/spu_io_values.hpp b/include/PSX/System/IOPorts/IOValues/spu_io_values.hpp index 72865aee..b2aa186f 100644 --- a/include/PSX/System/IOPorts/IOValues/spu_io_values.hpp +++ b/include/PSX/System/IOPorts/IOValues/spu_io_values.hpp @@ -6,6 +6,7 @@ namespace JabyEngine { namespace SPU_IO_Values { namespace MemoryMap { static constexpr uintptr_t ADPCM = 0x01000; + static constexpr uintptr_t End = 0x7FFFF; } __declare_io_value(AD, uint16_t) { diff --git a/src/Library/internal-include/SPU/spu_mmu.hpp b/src/Library/internal-include/SPU/spu_mmu.hpp index 7ed0560d..58103f4e 100644 --- a/src/Library/internal-include/SPU/spu_mmu.hpp +++ b/src/Library/internal-include/SPU/spu_mmu.hpp @@ -3,7 +3,6 @@ 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); } diff --git a/src/Library/src/SPU/spu_mmu.cpp b/src/Library/src/SPU/spu_mmu.cpp index f3d1a00a..71b224ed 100644 --- a/src/Library/src/SPU/spu_mmu.cpp +++ b/src/Library/src/SPU/spu_mmu.cpp @@ -12,7 +12,6 @@ namespace JabyEngine { namespace SPU_MemoryMap = SPU_IO::MemoryMap; struct SPUMemory { - // TODO: v change to uint16_t?? const uint8_t* adr; 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(SPU_MemoryMap::End); + // ^ change this to allocate reverb 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) { - // 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; new_entry.next_entry = next_entry; - return new_entry.memory.adr; }