diff --git a/APU.cpp b/APU.cpp index 86f8cbf..7a85606 100644 --- a/APU.cpp +++ b/APU.cpp @@ -1,11 +1,10 @@ #include "APU.h" #include //#include "audio_viewer.h" - namespace APU { #define SAMPLING_FREQ 44100 - #define AUDIO_BUFFER_SIZE 8192 + #define AUDIO_BUFFER_SIZE 2048 const float cycles_per_sample = 4194304.0f / SAMPLING_FREQ; SDL_AudioDeviceID sdlAudioDevice; @@ -78,14 +77,6 @@ namespace APU uint16_t LFSR = 0; - void audioCallback(void * userdata, uint8_t * stream, int len) - { - for (int i=0;i>1, 0, 0, &audioCallback, NULL}; + SDL_AudioSpec audioSpec{SAMPLING_FREQ, AUDIO_U8, 1, 0, AUDIO_BUFFER_SIZE, 0, 0, NULL, NULL}; sdlAudioDevice = SDL_OpenAudioDevice(NULL, 0, &audioSpec, NULL, 0); resume(); //samples_time=SDL_GetTicks(); @@ -438,7 +429,11 @@ namespace APU sound_buffer[(sound_pos++)&(AUDIO_BUFFER_SIZE-1)] = sample; //audio_viewer::addsample(sample); - //if (ear) last_1 = sound_pos; + } + if (sound_pos>=1000) { + SDL_QueueAudio(sdlAudioDevice, sound_buffer, sound_pos); + sound_pos = 0; + while (SDL_GetQueuedAudioSize(sdlAudioDevice) > 4096 ) {} } } } \ No newline at end of file diff --git a/gbscreen.cpp b/gbscreen.cpp index d4c6b61..f295e0b 100644 --- a/gbscreen.cpp +++ b/gbscreen.cpp @@ -322,8 +322,8 @@ namespace gbscreen if ( (STAT&0x3)==3) { uint16_t current_pixel = dots_in_scanline-80; if (current_pixel<160) { - uint8_t pixel = gb_pixels[current_pixel+LY*160]; - gb_pixels[current_pixel+LY*160] = pixel > line_buffer[current_pixel] ? pixel-1 : line_buffer[current_pixel]; + //uint8_t pixel = gb_pixels[current_pixel+LY*160]; + gb_pixels[current_pixel+LY*160] = line_buffer[current_pixel];// > line_buffer[current_pixel] ? pixel-1 : line_buffer[current_pixel]; } } diff --git a/main.cpp b/main.cpp index 0ca1aa6..26514e6 100644 --- a/main.cpp +++ b/main.cpp @@ -187,7 +187,7 @@ int main(int argc, char *argv[]) bool fastload=false; // En cada bucle fem 10 pasos de la CPU, sino s'ofega - for (int i=0;i<5;++i) { + for (int i=0;i<20;++i) { if (debug::isbreak(sm83::getPC(), 9)) { debug::stop(); gbscreen::redraw();