From c23a2458c46abdb0d77ab34470fdc4efa40cbb36 Mon Sep 17 00:00:00 2001 From: scawful Date: Mon, 30 Dec 2024 07:50:37 -0500 Subject: [PATCH] Refactor emulator code: update SNES references to Snes for consistency, clean up includes, and remove commented-out code --- src/app/emu/emu.cc | 29 +++++++++-------------------- src/app/emu/emulator.cc | 3 --- src/app/emu/emulator.h | 32 +++----------------------------- 3 files changed, 12 insertions(+), 52 deletions(-) diff --git a/src/app/emu/emu.cc b/src/app/emu/emu.cc index c9ca0ac3..7ef80a27 100644 --- a/src/app/emu/emu.cc +++ b/src/app/emu/emu.cc @@ -1,6 +1,4 @@ -#if defined(_WIN32) -#define main SDL_main -#elif __APPLE__ +#if __APPLE__ #include "app/core/platform/app_delegate.h" #endif @@ -10,24 +8,13 @@ #include #include -#include "absl/base/internal/raw_logging.h" -#include "absl/base/macros.h" -#include "absl/container/flat_hash_map.h" #include "absl/debugging/failure_signal_handler.h" -#include "absl/debugging/leak_check.h" -#include "absl/debugging/stacktrace.h" #include "absl/debugging/symbolize.h" -#include "absl/flags/flag.h" #include "absl/status/status.h" -#include "absl/status/statusor.h" -#include "absl/strings/str_format.h" #include "app/core/utils/sdl_deleter.h" #include "app/emu/snes.h" #include "app/rom.h" -#include "imgui/imgui.h" -#include "imgui_memory_editor.h" -using namespace yaze; using yaze::core::SDL_Deleter; int main(int argc, char **argv) { @@ -38,6 +25,8 @@ int main(int argc, char **argv) { options.alarm_on_failure_secs = true; absl::InstallFailureSignalHandler(options); + SDL_SetMainReady(); + std::unique_ptr window_; std::unique_ptr renderer_; if (SDL_Init(SDL_INIT_EVERYTHING) != 0) { @@ -96,8 +85,8 @@ int main(int argc, char **argv) { return EXIT_FAILURE; } - Rom rom_; - emu::SNES snes_; + yaze::Rom rom_; + yaze::emu::Snes snes_; std::vector rom_data_; bool running = true; @@ -191,10 +180,10 @@ int main(int argc, char **argv) { SDL_PauseAudioDevice(audio_device_, 1); SDL_CloseAudioDevice(audio_device_); - delete audio_buffer_; - // ImGui_ImplSDLRenderer2_Shutdown(); - // ImGui_ImplSDL2_Shutdown(); - // ImGui::DestroyContext(); + delete[] audio_buffer_; + //ImGui_ImplSDLRenderer2_Shutdown(); + //ImGui_ImplSDL2_Shutdown(); + //ImGui::DestroyContext(); SDL_Quit(); return EXIT_SUCCESS; diff --git a/src/app/emu/emulator.cc b/src/app/emu/emulator.cc index f99f10a9..411016b8 100644 --- a/src/app/emu/emulator.cc +++ b/src/app/emu/emulator.cc @@ -3,14 +3,11 @@ #include #include -#include "app/core/constants.h" #include "app/core/platform/file_dialog.h" #include "app/core/platform/renderer.h" -#include "app/emu/snes.h" #include "app/gui/icons.h" #include "app/gui/input.h" #include "app/gui/zeml.h" -#include "app/rom.h" #include "imgui/imgui.h" #include "imgui_memory_editor.h" diff --git a/src/app/emu/emulator.h b/src/app/emu/emulator.h index a75bc80c..642883fc 100644 --- a/src/app/emu/emulator.h +++ b/src/app/emu/emulator.h @@ -17,31 +17,6 @@ namespace yaze { */ namespace emu { -// case SDLK_z: -// editor.emulator().snes().SetButtonState(1, 0, false); -// case SDLK_a: -// editor.emulator().snes().SetButtonState(1, 1, false); -// case SDLK_RSHIFT: -// editor.emulator().snes().SetButtonState(1, 2, false); -// case SDLK_RETURN: -// editor.emulator().snes().SetButtonState(1, 3, false); -// case SDLK_UP: -// editor.emulator().snes().SetButtonState(1, 4, false); -// case SDLK_DOWN: -// editor.emulator().snes().SetButtonState(1, 5, false); -// case SDLK_LEFT: -// editor.emulator().snes().SetButtonState(1, 6, false); -// case SDLK_RIGHT: -// editor.emulator().snes().SetButtonState(1, 7, false); -// case SDLK_x: -// editor.emulator().snes().SetButtonState(1, 8, false); -// case SDLK_s: -// editor.emulator().snes().SetButtonState(1, 9, false); -// case SDLK_d: -// editor.emulator().snes().SetButtonState(1, 10, false); -// case SDLK_c: -// editor.emulator().snes().SetButtonState(1, 11, false); - struct EmulatorKeybindings { ImGuiKey a_button = ImGuiKey_Z; ImGuiKey b_button = ImGuiKey_A; @@ -133,7 +108,7 @@ class Emulator : public SharedRom { } void Run(); - auto snes() -> SNES& { return snes_; } + auto snes() -> Snes& { return snes_; } auto running() const -> bool { return running_; } void set_audio_buffer(int16_t* audio_buffer) { audio_buffer_ = audio_buffer; } auto set_audio_device_id(SDL_AudioDeviceID audio_device) { @@ -178,7 +153,7 @@ class Emulator : public SharedRom { int16_t* audio_buffer_; SDL_AudioDeviceID audio_device_; - SNES snes_; + Snes snes_; SDL_Texture* ppu_texture_; std::vector rom_data_; @@ -189,7 +164,6 @@ class Emulator : public SharedRom { }; } // namespace emu - } // namespace yaze -#endif // YAZE_APP_CORE_EMULATOR_H \ No newline at end of file +#endif // YAZE_APP_CORE_EMULATOR_H