diff --git a/source/apu.cpp b/source/apu.cpp index 24babaa..c7ca770 100644 --- a/source/apu.cpp +++ b/source/apu.cpp @@ -1,6 +1,6 @@ #include "apu.h" #include -//#include "audio_viewer.h" + namespace apu { #define SAMPLING_FREQ 44100 @@ -10,9 +10,7 @@ namespace apu SDL_AudioDeviceID sdlAudioDevice; uint8_t sound_buffer[AUDIO_BUFFER_SIZE]; uint16_t sound_pos=0; - uint16_t sound_start=0; float t_sound = 0.0f; - uint32_t samples_generated=0; #define CH1 channels[0] #define CH2 channels[1] @@ -87,9 +85,11 @@ namespace apu void init() { + for (int i=0; i=1000) { SDL_QueueAudio(sdlAudioDevice, sound_buffer, sound_pos); sound_pos = 0; - while (SDL_GetQueuedAudioSize(sdlAudioDevice) > 4096 ) {} + while (SDL_GetQueuedAudioSize(sdlAudioDevice) > 4096 ) { SDL_Delay(1); } } + } } \ No newline at end of file diff --git a/source/gameboy.cpp b/source/gameboy.cpp new file mode 100644 index 0000000..79e6264 --- /dev/null +++ b/source/gameboy.cpp @@ -0,0 +1,16 @@ +#include "gameboy.h" + +gameboy::gameboy(const std::string &rom_file) +{ + +} + +gameboy::~gameboy() +{ + +} + +void gameboy::step() +{ + +} diff --git a/source/gameboy.h b/source/gameboy.h new file mode 100644 index 0000000..59791e8 --- /dev/null +++ b/source/gameboy.h @@ -0,0 +1,15 @@ +#pragma once + +#include + +class gameboy +{ + public: + gameboy(const std::string &rom_file); + ~gameboy(); + + void step(); + + private: + +}; diff --git a/source/main.cpp b/source/main.cpp index 91f9a71..06beb81 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -108,9 +108,10 @@ int main(int argc, char *argv[]) time = SDL_GetTicks(); t_states = 0; - + uint8_t wait = 125; while (!should_exit) { + if (wait==0) { while (SDL_PollEvent(&e)) { bool result = true; @@ -175,10 +176,11 @@ int main(int argc, char *argv[]) if (!result) should_exit = true; break; } + } if (!debug::debugging() && !debug::paused()) { // En cada pas de bucle fem 10 pasos de la CPU, sino s'ofega - for (int i=0;i<20;++i) { + //for (int i=0;i<20;++i) { if (debug::isbreak(sm83::getPC(), 9)) { debug::stop(); display::redraw(); @@ -186,11 +188,10 @@ int main(int argc, char *argv[]) } else { uint8_t dt = sm83::step(); t_states += dt; - //zx_ula::sound_update(dt); ppu::refresh(dt); if (debug::debugging()) break; } - } + //} // Sincronització: // la frequència del rellotge diu quants t_states pot executar per segon. @@ -198,12 +199,12 @@ int main(int argc, char *argv[]) // pot executar cada 125 ms. Ací comprobem si ja havem executat eixe nombre // de t_states i, si ho havem fet, esperem fins que passen 125ms des de l'ultima // vegada que ho comprobarem. - if (t_states>=update_freq) - { - while (SDL_GetTicks()<(time+125)) {} - t_states -= update_freq; - time = SDL_GetTicks(); - } + //if (t_states>=update_freq) + //{ + // while (SDL_GetTicks()<(time+125)) {} + // t_states -= update_freq; + // time = SDL_GetTicks(); + //} } else if (!debug::debugging() && debug::paused()) { @@ -211,7 +212,12 @@ int main(int argc, char *argv[]) ui::menu::show(); display::present(); } - ui::setClicked(false); + if (wait == 0) { + ui::setClicked(false); + wait = 125; + } else { + wait--; + } } return 0; diff --git a/source/sm83.cpp b/source/sm83.cpp index eef6c67..0b16aa6 100644 --- a/source/sm83.cpp +++ b/source/sm83.cpp @@ -552,13 +552,7 @@ namespace sm83 halted = true; } } - /*if (exit_from_halt) { - exit_from_halt = false; - halted = false; - } else {*/ - //printf("HALT\n"); - rPC--; - //} + rPC--; } void STOP()