- Afegim el tap i el savestate de Alien 8 per a provar
- Provant el berserk mode - Medint els t-states de altra forma - iff1, iff2 i im afegits al array de registres de la cpu - [NEW] getRegs() del modul z80 - [NEW] loadstate() i savestate() al modul z80debug - [NEW] "load arxiu" i "save arxiu" en consola per a carregar i guardar savestates - [ONGOING] "tape load arxiu" i "tape play" per a canviar de cinta i playarla - Buffer de audio més gran. Ara el buffer es circular. Continuem intentant desfer-se del jittering
This commit is contained in:
44
zx_ula.cpp
44
zx_ula.cpp
@@ -1,6 +1,8 @@
|
||||
#include "zx_ula.h"
|
||||
#include <SDL2/SDL.h>
|
||||
|
||||
#define AUDIO_BUFFER_SIZE 2048
|
||||
|
||||
namespace zx_ula
|
||||
{
|
||||
#define KEY_SHIFT 0
|
||||
@@ -218,17 +220,22 @@ namespace zx_ula
|
||||
|
||||
|
||||
SDL_AudioDeviceID sdlAudioDevice;
|
||||
uint8_t sound_buffer[1024];
|
||||
uint16_t sound_pos;
|
||||
uint8_t sound_buffer[AUDIO_BUFFER_SIZE];
|
||||
uint16_t sound_pos=0;
|
||||
uint16_t sound_start=0;
|
||||
uint16_t t_sound=0;
|
||||
|
||||
void audioCallback(void * userdata, uint8_t * stream, int len)
|
||||
{
|
||||
const uint16_t top = sound_pos < len ? sound_pos : len;
|
||||
printf("top: %i, len: %i, pos: %i\n", top, len, sound_pos);
|
||||
memcpy(stream, sound_buffer, top);
|
||||
if (top<len) memchr(&stream[top], sound_buffer[top-1], len-top);
|
||||
if (top<sound_pos)
|
||||
//const uint16_t top = sound_pos < len ? sound_pos : len;
|
||||
//if (top<len) printf("top: %i, len: %i, pos: %i\n", top, len, sound_pos);
|
||||
//memcpy(stream, sound_buffer, top);
|
||||
for (int i=0;i<len;++i)
|
||||
{
|
||||
stream[i] = sound_buffer[(sound_start++)&(AUDIO_BUFFER_SIZE-1)];
|
||||
}
|
||||
//if (top<len) memchr(&stream[top], sound_buffer[top-1], len-top);
|
||||
/*if (top<sound_pos)
|
||||
{
|
||||
if (last_1>top)
|
||||
{
|
||||
@@ -244,12 +251,12 @@ namespace zx_ula
|
||||
else
|
||||
{
|
||||
sound_pos=last_1=0;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
void sound_init()
|
||||
{
|
||||
SDL_AudioSpec audioSpec{11025, AUDIO_U8, 1, 0, 220, 0, 0, &audioCallback, NULL};
|
||||
SDL_AudioSpec audioSpec{11025, AUDIO_U8, 1, 0, AUDIO_BUFFER_SIZE>>2, 0, 0, &audioCallback, NULL};
|
||||
sdlAudioDevice = SDL_OpenAudioDevice(NULL, 0, &audioSpec, NULL, 0);
|
||||
sound_enable();
|
||||
}
|
||||
@@ -267,22 +274,15 @@ namespace zx_ula
|
||||
void sound_update(const uint8_t dt)
|
||||
{
|
||||
t_sound += dt;
|
||||
if (t_sound>=316) {
|
||||
t_sound-=316;
|
||||
if (t_sound>=317) {
|
||||
t_sound-=317;
|
||||
//sound_pos = (sound_pos+1) & 0x3ff;
|
||||
//sound_buffer[sound_pos] = ear*128;
|
||||
|
||||
if (sound_pos<1024)
|
||||
{
|
||||
sound_buffer[sound_pos++] = ear*128;
|
||||
if (ear) last_1 = sound_pos;
|
||||
}
|
||||
else
|
||||
{
|
||||
//for now, drop then buffer
|
||||
sound_pos = last_1 = 0;
|
||||
//printf("WARNING! Sound buffer overflow!\n");
|
||||
}
|
||||
//if (sound_pos>=AUDIO_BUFFER_SIZE) sound_pos = last_1 = 0;
|
||||
|
||||
sound_buffer[(sound_pos++)&(AUDIO_BUFFER_SIZE-1)] = ear*128;
|
||||
//if (ear) last_1 = sound_pos;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user