Improve SPU code and support state of voice

This commit is contained in:
2024-09-24 22:21:58 +02:00
parent f2800aaf1e
commit b79dd47982
7 changed files with 59 additions and 67 deletions

View File

@@ -11,7 +11,7 @@ namespace JabyEngine {
// TODO: Rename to sample...?
struct Voice {
size_t get_id() {
size_t get_id() const {
return reinterpret_cast<size_t>(this);
}
@@ -33,11 +33,22 @@ namespace JabyEngine {
SPU_IO::Key::On.write(SPU_IO::KeyOn::for_specific(Voice::get_id()));
}
void play_if_end() {
if(Voice::is_end()) {
Voice::play();
}
}
void stop() {
SPU_IO::Key::Off.write(SPU_IO::KeyOff::for_specific(Voice::get_id()));
}
bool is_end() const {
// TODO: Make work in XEBRA
return SPU_IO::Key::Status.read().is_set(Voice::get_id());
}
};
extern Voice voice[SPU_IO::VoiceCount];
static auto& voice = __new_declare_io_port_array(Voice, SPU_IO::VoiceCount, 0x0);
}
}