- [NEW] EAR getter in the ULA module

- [NEW] Flash attribute implemented
- [NEW] Sound somewhat working (BEEP hangs)
This commit is contained in:
2024-04-15 20:47:00 +02:00
parent 6dfb24da10
commit 2d0b0e45cc
5 changed files with 64 additions and 3 deletions

View File

@@ -8,8 +8,31 @@
#include <SDL2/SDL.h>
#include <string.h>
SDL_AudioDeviceID sdlAudioDevice;
uint8_t memory[65536];
uint32_t t = 0;
uint16_t ts = 0;
uint8_t ft = 0;
uint32_t fps=0;
uint32_t fps_time=0;
uint8_t sound_buffer[1024];
uint16_t sound_pos;
void audioCallback(void * userdata, uint8_t * stream, int len)
{
uint16_t top = len;
if (sound_pos < len)
{
top = sound_pos;
//printf("buffer underrun!\n");
}
memcpy(stream, sound_buffer, top);
sound_pos=0;
}
uint8_t test = 0;
int main(int argc, char *argv[])
{
@@ -24,6 +47,10 @@ int main(int argc, char *argv[])
z80debug::show();
zxscreen::show();
SDL_AudioSpec audioSpec{11025, AUDIO_U8, 1, 0, 220, 0, 0, &audioCallback, NULL};
sdlAudioDevice = SDL_OpenAudioDevice(NULL, 0, &audioSpec, NULL, 0);
SDL_PauseAudioDevice(sdlAudioDevice, 0);
bool should_exit = false;
SDL_Event e;
@@ -48,6 +75,8 @@ int main(int argc, char *argv[])
} else if (e.key.keysym.scancode==SDL_SCANCODE_F5) {
z80::step();
z80debug::cont();
fps=0;
fps_time = SDL_GetTicks();
zxscreen::refresh();
} else if (e.key.keysym.scancode==SDL_SCANCODE_RETURN) {
z80debug::executeConsole();
@@ -72,9 +101,31 @@ int main(int argc, char *argv[])
z80debug::stop();
zxscreen::refresh();
} else {
t += z80::step();
uint8_t t_states = z80::step();
t += t_states;
ts += t_states;
if (ts>=400) {
ts-=400;
uint8_t ear = zx_ula::get_ear();
//if (ear)
sound_buffer[sound_pos++] = ear*128;
//SDL_QueueAudio(sdlAudioDevice, &beep[ear], 1);
//else
//SDL_ClearQueuedAudio(sdlAudioDevice);
}
if (t>=69888) {
t=0;
ft++;
if (ft==16) { ft=0; zxscreen::flash(); }
/*
fps++;
if (SDL_GetTicks() - fps_time >= 1000) {
printf("FPS: %i\n", fps);
fps = 0;
fps_time = SDL_GetTicks();
}
*/
t=0;
zxscreen::refresh();
z80::interrupt();
}