From a76784065ad493c78aa974c1ef81de1f60d162d0 Mon Sep 17 00:00:00 2001 From: jaby Date: Sat, 28 Sep 2024 13:29:30 +0200 Subject: [PATCH] Allow SPU debug messages (on by default for now) --- config/Readme.md | 4 ++-- include/PSX/jabyengine_config.hpp | 1 + src/Library/Library.code-workspace | 1 + src/Library/src/File/Processor/vag_processor.cpp | 3 +-- src/Library/src/SPU/spu_mmu.cpp | 11 +++++++++-- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/config/Readme.md b/config/Readme.md index cf73d137..1957ab90 100644 --- a/config/Readme.md +++ b/config/Readme.md @@ -39,8 +39,8 @@ struct DefaultConfiguration { ``` ### `CustomConfiguration` macros ```c++ -// Turns on support of Sonys VAG files for the CDFileProcessor (off by default) -#define __SUPPORT_VAG__ +// Turns on debug information of the SPU MMU (on by default [for now]) +#define __DEBUG_SPU_MMU__ // Turns on colored rectangles during boot (off by default) #define __USE_DEBUG_COLOR__ // Turns on PS3 support (on by default) diff --git a/include/PSX/jabyengine_config.hpp b/include/PSX/jabyengine_config.hpp index 3a92f80d..64b5cd2a 100644 --- a/include/PSX/jabyengine_config.hpp +++ b/include/PSX/jabyengine_config.hpp @@ -32,5 +32,6 @@ namespace JabyEngine { #else using Configuration = DefaultConfiguration; #define __SUPPORT_PS3__ + #define __DEBUG_SPU_MMU__ #endif // has jabyengine_custom_config } \ No newline at end of file diff --git a/src/Library/Library.code-workspace b/src/Library/Library.code-workspace index 9f76f6c2..afb872fc 100644 --- a/src/Library/Library.code-workspace +++ b/src/Library/Library.code-workspace @@ -97,6 +97,7 @@ ], "C_Cpp.default.defines": [ "JABYENGINE_PAL", + "__DEBUG_SPU_MMU__", "__friends=public" ], "files.exclude": { diff --git a/src/Library/src/File/Processor/vag_processor.cpp b/src/Library/src/File/Processor/vag_processor.cpp index 7ef5d5d6..9d0dcf05 100644 --- a/src/Library/src/File/Processor/vag_processor.cpp +++ b/src/Library/src/File/Processor/vag_processor.cpp @@ -57,8 +57,7 @@ namespace JabyEngine { state.words_left = words; 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)); diff --git a/src/Library/src/SPU/spu_mmu.cpp b/src/Library/src/SPU/spu_mmu.cpp index 967d8b83..f3d1a00a 100644 --- a/src/Library/src/SPU/spu_mmu.cpp +++ b/src/Library/src/SPU/spu_mmu.cpp @@ -3,6 +3,9 @@ #include #include #include +#ifdef __DEBUG_SPU_MMU__ + #include +#endif // __DEBUG_SPU_MMU__ namespace JabyEngine { namespace SPU_MMU { @@ -104,8 +107,12 @@ namespace JabyEngine { deallocate(voice); } - voice_entry.memory = SPUMemory::create(size); - return find_first_fit(voice_entry, verify_and_add); + voice_entry.memory = SPUMemory::create(size); + const auto* mem_adr = find_first_fit(voice_entry, verify_and_add); + #ifdef __DEBUG_SPU_MMU__ + printf("SPU: Allocated %i @0x%p to 0x%p (%i bytes)\n", voice, mem_adr, (mem_adr + size), size); + #endif // __DEBUG_SPU_MMU__ + return mem_adr; } void deallocate(uint8_t voice) {