Allow SPU debug messages (on by default for now)

This commit is contained in:
jaby 2024-09-28 13:29:30 +02:00
parent 9f3e911513
commit a76784065a
5 changed files with 14 additions and 6 deletions

View File

@ -39,8 +39,8 @@ struct DefaultConfiguration {
``` ```
### `CustomConfiguration` macros ### `CustomConfiguration` macros
```c++ ```c++
// Turns on support of Sonys VAG files for the CDFileProcessor (off by default) // Turns on debug information of the SPU MMU (on by default [for now])
#define __SUPPORT_VAG__ #define __DEBUG_SPU_MMU__
// Turns on colored rectangles during boot (off by default) // Turns on colored rectangles during boot (off by default)
#define __USE_DEBUG_COLOR__ #define __USE_DEBUG_COLOR__
// Turns on PS3 support (on by default) // Turns on PS3 support (on by default)

View File

@ -32,5 +32,6 @@ namespace JabyEngine {
#else #else
using Configuration = DefaultConfiguration; using Configuration = DefaultConfiguration;
#define __SUPPORT_PS3__ #define __SUPPORT_PS3__
#define __DEBUG_SPU_MMU__
#endif // has jabyengine_custom_config #endif // has jabyengine_custom_config
} }

View File

@ -97,6 +97,7 @@
], ],
"C_Cpp.default.defines": [ "C_Cpp.default.defines": [
"JABYENGINE_PAL", "JABYENGINE_PAL",
"__DEBUG_SPU_MMU__",
"__friends=public" "__friends=public"
], ],
"files.exclude": { "files.exclude": {

View File

@ -57,8 +57,7 @@ namespace JabyEngine {
state.words_left = words; state.words_left = words;
auto sram_adr = SPU::voice[state.voice_id].allocate(SPU_IO::SampleRate::from_HZ(header.get_sample_frequency()), bytes); 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); SPU::voice[state.voice_id].set_volume(state.inital_vol, state.inital_vol);
config.processed(sizeof(VAGHeader)); config.processed(sizeof(VAGHeader));

View File

@ -3,6 +3,9 @@
#include <PSX/Auxiliary/math_helper.hpp> #include <PSX/Auxiliary/math_helper.hpp>
#include <PSX/SPU/spu.hpp> #include <PSX/SPU/spu.hpp>
#include <stddef.hpp> #include <stddef.hpp>
#ifdef __DEBUG_SPU_MMU__
#include <stdio.hpp>
#endif // __DEBUG_SPU_MMU__
namespace JabyEngine { namespace JabyEngine {
namespace SPU_MMU { namespace SPU_MMU {
@ -104,8 +107,12 @@ namespace JabyEngine {
deallocate(voice); deallocate(voice);
} }
voice_entry.memory = SPUMemory::create(size); voice_entry.memory = SPUMemory::create(size);
return find_first_fit(voice_entry, verify_and_add); 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) { void deallocate(uint8_t voice) {