- [NEW] Minim makefile
- [NEW] Sound stops while debugging - [CHG] Now all sound related code is in the zx_ula module
This commit is contained in:
35
zx_ula.cpp
35
zx_ula.cpp
@@ -97,4 +97,39 @@ namespace zx_ula
|
||||
|
||||
uint8_t get_border_color() { return border_color; }
|
||||
uint8_t get_ear() { return ear; }
|
||||
|
||||
|
||||
|
||||
|
||||
SDL_AudioDeviceID sdlAudioDevice;
|
||||
uint8_t sound_buffer[1024];
|
||||
uint16_t sound_pos;
|
||||
|
||||
void audioCallback(void * userdata, uint8_t * stream, int len)
|
||||
{
|
||||
const uint16_t top = sound_pos < len ? sound_pos : len;
|
||||
memcpy(stream, sound_buffer, top);
|
||||
sound_pos=0;
|
||||
}
|
||||
|
||||
void sound_init()
|
||||
{
|
||||
SDL_AudioSpec audioSpec{11025, AUDIO_U8, 1, 0, 220, 0, 0, &audioCallback, NULL};
|
||||
sdlAudioDevice = SDL_OpenAudioDevice(NULL, 0, &audioSpec, NULL, 0);
|
||||
}
|
||||
|
||||
void sound_enable()
|
||||
{
|
||||
SDL_PauseAudioDevice(sdlAudioDevice, 0);
|
||||
}
|
||||
|
||||
void sound_disable()
|
||||
{
|
||||
SDL_PauseAudioDevice(sdlAudioDevice, 1);
|
||||
}
|
||||
|
||||
void sound_update()
|
||||
{
|
||||
sound_buffer[sound_pos++] = ear*128;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user