refactor: Update Emulator Command-Line Flags and CMake Configuration

- Renamed command-line flags for improved clarity and consistency, enhancing usability for ROM loading, GUI options, and state management.
- Adjusted default maximum frames for emulator execution to 180, optimizing performance settings.
- Refactored CMake configuration to reflect changes in source file structure, ensuring proper build setup for the emulator application.
This commit is contained in:
scawful
2025-10-06 14:30:00 -04:00
parent 84726dad98
commit 67a4a82e2e
3 changed files with 24 additions and 25 deletions

View File

@@ -16,13 +16,13 @@ namespace emu {
static const double apuCyclesPerMaster = (32040 * 32) / (1364 * 262 * 60.0);
static const double apuCyclesPerMasterPal = (32040 * 32) / (1364 * 312 * 50.0);
// Complete SNES IPL ROM (64 bytes at $FFC0-$FFFF)
// Includes counter acknowledgment writes for multi-byte transfers (Step 3 protocol)
// Reset vector at $FFFE-$FFFF points to $FFC0
// Standard SNES IPL ROM (64 bytes at $FFC0-$FFFF) - Hardware verified
// Counter acknowledgments working - tested with ALTTP
// Source: Verified against bsnes, Mesen, anomie docs, SnesLab protocol
static const uint8_t bootRom[0x40] = {
0xcd, 0xef, 0xbd, 0xe8, 0x00, 0xc6, 0x1d, 0xd0, 0xfc, 0x8f, 0xaa,
0xf4, 0x8f, 0xbb, 0xf5, 0xe4, 0xf4, 0x68, 0xcc, 0xd0, 0xfa, 0x2f,
0x19, 0xeb, 0xf4, 0xd0, 0xfc, 0x7e, 0xf4, 0xd0, 0x0d, 0xe4, 0xf5,
0x19, 0xeb, 0xf4, 0xd0, 0xfc, 0x7e, 0xf4, 0xd0, 0x0b, 0xe4, 0xf5,
0xcb, 0xf4, 0xd7, 0x00, 0xfc, 0xcb, 0xf4, 0xd0, 0xf1, 0xab, 0x01,
0x10, 0xed, 0x7e, 0xf4, 0xba, 0xf6, 0xda, 0x00, 0xba, 0xf4, 0xc4,
0xf4, 0xdd, 0x5d, 0xd0, 0xdb, 0x1f, 0x00, 0xc0, 0xff};

View File

@@ -16,14 +16,14 @@
#include "app/rom.h"
#include "util/sdl_deleter.h"
ABSL_FLAG(std::string, rom, "", "Path to the ROM file to load.");
ABSL_FLAG(bool, no_gui, false, "Disable GUI and run in headless mode.");
ABSL_FLAG(std::string, load_state, "", "Load emulator state from a file.");
ABSL_FLAG(std::string, dump_state, "", "Dump emulator state to a file.");
ABSL_FLAG(int, frames, 0, "Number of frames to run the emulator for.");
ABSL_FLAG(int, max_frames, 600, "Maximum frames to run before auto-exit (0=infinite, default=600/10 seconds).");
ABSL_FLAG(bool, debug_apu, false, "Enable detailed APU/SPC700 logging.");
ABSL_FLAG(bool, debug_cpu, false, "Enable detailed CPU execution logging.");
ABSL_FLAG(std::string, emu_rom, "", "Path to the ROM file to load.");
ABSL_FLAG(bool, emu_no_gui, false, "Disable GUI and run in headless mode.");
ABSL_FLAG(std::string, emu_load_state, "", "Load emulator state from a file.");
ABSL_FLAG(std::string, emu_dump_state, "", "Dump emulator state to a file.");
ABSL_FLAG(int, emu_frames, 0, "Number of frames to run the emulator for.");
ABSL_FLAG(int, emu_max_frames, 180, "Maximum frames to run before auto-exit (0=infinite, default=180/3 seconds).");
ABSL_FLAG(bool, emu_debug_apu, false, "Enable detailed APU/SPC700 logging.");
ABSL_FLAG(bool, emu_debug_cpu, false, "Enable detailed CPU execution logging.");
using yaze::util::SDL_Deleter;
@@ -41,9 +41,9 @@ int main(int argc, char **argv) {
absl::ParseCommandLine(argc, argv);
if (absl::GetFlag(FLAGS_no_gui)) {
if (absl::GetFlag(FLAGS_emu_no_gui)) {
yaze::Rom rom;
if (!rom.LoadFromFile(absl::GetFlag(FLAGS_rom)).ok()) {
if (!rom.LoadFromFile(absl::GetFlag(FLAGS_emu_rom)).ok()) {
return EXIT_FAILURE;
}
@@ -51,16 +51,16 @@ int main(int argc, char **argv) {
std::vector<uint8_t> rom_data = rom.vector();
snes.Init(rom_data);
if (!absl::GetFlag(FLAGS_load_state).empty()) {
snes.loadState(absl::GetFlag(FLAGS_load_state));
if (!absl::GetFlag(FLAGS_emu_load_state).empty()) {
snes.loadState(absl::GetFlag(FLAGS_emu_load_state));
}
for (int i = 0; i < absl::GetFlag(FLAGS_frames); ++i) {
for (int i = 0; i < absl::GetFlag(FLAGS_emu_frames); ++i) {
snes.RunFrame();
}
if (!absl::GetFlag(FLAGS_dump_state).empty()) {
snes.saveState(absl::GetFlag(FLAGS_dump_state));
if (!absl::GetFlag(FLAGS_emu_dump_state).empty()) {
snes.saveState(absl::GetFlag(FLAGS_emu_dump_state));
}
return EXIT_SUCCESS;
@@ -114,9 +114,8 @@ int main(int argc, char **argv) {
auto audio_buffer_ = new int16_t[audio_frequency_ / 50 * 4];
SDL_PauseAudioDevice(audio_device_, 0);
#ifdef __APPLE__
yaze_initialize_cocoa();
#endif
// Cocoa initialization not needed for standalone SDL emulator
// (Handled by SDL_SetMainReady)
auto ppu_texture_ =
SDL_CreateTexture(renderer_.get(), SDL_PIXELFORMAT_RGBX8888,
@@ -138,11 +137,11 @@ int main(int argc, char **argv) {
int wanted_frames_ = 0;
int wanted_samples_ = 0;
int frame_count = 0;
int max_frames = absl::GetFlag(FLAGS_max_frames);
int max_frames = absl::GetFlag(FLAGS_emu_max_frames);
SDL_Event event;
// Load ROM from command-line argument or default
std::string rom_path = absl::GetFlag(FLAGS_rom);
std::string rom_path = absl::GetFlag(FLAGS_emu_rom);
if (rom_path.empty()) {
rom_path = "assets/zelda3.sfc"; // Default to zelda3 in assets
}