diff --git a/glaurung.tap b/glaurung.tap new file mode 100644 index 0000000..26dd385 Binary files /dev/null and b/glaurung.tap differ diff --git a/main.cpp b/main.cpp index 50ed0e7..359763e 100644 --- a/main.cpp +++ b/main.cpp @@ -172,25 +172,29 @@ int main(int argc, char *argv[]) zxscreen::redraw(); } else { //if (z80::getPC()==0x05C8) zx_tape::go_berserk(); - uint8_t dt = z80::step(); - t_states += dt; - zx_tape::update(dt); - while (zx_tape::getplaying() && zx_tape::getberserk()) { zx_tape::update(z80::step()); } - zx_ula::sound_update(dt); - zxscreen::refresh(dt); + // En cada bucle fem 10 pasos de la CPU, sino s'ofega + for (int i=0;i<10;++i) { + uint8_t dt = z80::step(); + t_states += dt; + zx_tape::update(dt); + + zx_ula::sound_update(dt); + zxscreen::refresh(dt); + } - if (t_states>=3500000) + if (t_states>=350000) { //if (SDL_GetTicks()>=time+1000) //printf("%i\n", SDL_GetTicks()-(time+1000)); //else // printf("%i\n", SDL_GetTicks()-(time+1000)); //t_states = 0; + //printf("%i: %i\n", SDL_GetTicks()-(time+1000), t_states); while (SDL_GetTicks()>2, 0, 0, &audioCallback, NULL}; sdlAudioDevice = SDL_OpenAudioDevice(NULL, 0, &audioSpec, NULL, 0); sound_enable(); + samples_time=SDL_GetTicks(); } void sound_enable() @@ -274,8 +278,20 @@ namespace zx_ula void sound_update(const uint8_t dt) { t_sound += dt; + samples_t += dt; if (t_sound>=317) { t_sound-=317; + samples_generated++; + if (samples_t >=3500000) { + printf("%i\n", samples_generated); + samples_generated=0; + samples_t = 0; + } + /*if (SDL_GetTicks()>=samples_time+1000) { + printf("%i\n", samples_generated); + samples_generated=0; + samples_time = SDL_GetTicks(); + }*/ //sound_pos = (sound_pos+1) & 0x3ff; //sound_buffer[sound_pos] = ear*128;