Refactor main function and improve file dialog implementation
- Cleaned up formatting in main function for better readability. - Simplified platform initialization in LoadConfigFile and GetConfigDirectory functions. - Introduced wrapper methods for file dialog operations to enhance modularity and maintainability. - Improved code clarity by adjusting line breaks and spacing in various functions.
This commit is contained in:
@@ -51,13 +51,12 @@ std::string LoadFile(const std::string &filename) {
|
||||
|
||||
std::string LoadConfigFile(const std::string &filename) {
|
||||
std::string contents;
|
||||
Platform platform;
|
||||
#if defined(_WIN32)
|
||||
platform = Platform::kWindows;
|
||||
Platform platform = Platform::kWindows;
|
||||
#elif defined(__APPLE__)
|
||||
platform = Platform::kMacOS;
|
||||
Platform platform = Platform::kMacOS;
|
||||
#else
|
||||
platform = Platform::kLinux;
|
||||
Platform platform = Platform::kLinux;
|
||||
#endif
|
||||
std::string filepath = GetConfigDirectory() + "/" + filename;
|
||||
std::ifstream file(filepath);
|
||||
@@ -81,19 +80,18 @@ void SaveFile(const std::string &filename, const std::string &contents) {
|
||||
|
||||
std::string GetConfigDirectory() {
|
||||
std::string config_directory = ".yaze";
|
||||
Platform platform;
|
||||
#if defined(__APPLE__) && defined(__MACH__)
|
||||
#if TARGET_IPHONE_SIMULATOR == 1 || TARGET_OS_IPHONE == 1
|
||||
platform = Platform::kiOS;
|
||||
Platform platform = Platform::kiOS;
|
||||
#elif TARGET_OS_MAC == 1
|
||||
platform = Platform::kMacOS;
|
||||
Platform platform = Platform::kMacOS;
|
||||
#endif
|
||||
#elif defined(_WIN32)
|
||||
platform = Platform::kWindows;
|
||||
Platform platform = Platform::kWindows;
|
||||
#elif defined(__linux__)
|
||||
platform = Platform::kLinux;
|
||||
Platform platform = Platform::kLinux;
|
||||
#else
|
||||
platform = Platform::kUnknown;
|
||||
Platform platform = Platform::kUnknown;
|
||||
#endif
|
||||
switch (platform) {
|
||||
case Platform::kWindows:
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace yaze {
|
||||
namespace emu {
|
||||
|
||||
@@ -22,8 +22,10 @@ int main(int argc, char **argv) {
|
||||
|
||||
absl::FailureSignalHandlerOptions options;
|
||||
options.symbolize_stacktrace = true;
|
||||
options.use_alternate_stack = false; // Disable alternate stack to avoid shutdown conflicts
|
||||
options.alarm_on_failure_secs = false; // Disable alarm to avoid false positives during SDL cleanup
|
||||
options.use_alternate_stack =
|
||||
false; // Disable alternate stack to avoid shutdown conflicts
|
||||
options.alarm_on_failure_secs =
|
||||
false; // Disable alarm to avoid false positives during SDL cleanup
|
||||
options.call_previous_handler = true;
|
||||
absl::InstallFailureSignalHandler(options);
|
||||
|
||||
@@ -183,9 +185,9 @@ 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();
|
||||
// ImGui_ImplSDLRenderer2_Shutdown();
|
||||
// ImGui_ImplSDL2_Shutdown();
|
||||
// ImGui::DestroyContext();
|
||||
SDL_Quit();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
@@ -245,7 +245,8 @@ void InitHdma(Snes* snes, MemoryImpl* memory, bool do_sync, int cpu_cycles) {
|
||||
snes->Read((channel[i].a_bank << 16) | channel[i].table_addr++);
|
||||
snes->RunCycles(8);
|
||||
channel[i].size |=
|
||||
snes->Read((channel[i].a_bank << 16) | channel[i].table_addr++) << 8;
|
||||
snes->Read((channel[i].a_bank << 16) | channel[i].table_addr++)
|
||||
<< 8;
|
||||
}
|
||||
channel[i].do_transfer = true;
|
||||
}
|
||||
@@ -286,7 +287,8 @@ void DoHdma(Snes* snes, MemoryImpl* memory, bool do_sync, int cycles) {
|
||||
channel[i].b_addr + bAdrOffsets[channel[i].mode][j],
|
||||
channel[i].from_b);
|
||||
} else {
|
||||
TransferByte(snes, memory, channel[i].table_addr++, channel[i].a_bank,
|
||||
TransferByte(snes, memory, channel[i].table_addr++,
|
||||
channel[i].a_bank,
|
||||
channel[i].b_addr + bAdrOffsets[channel[i].mode][j],
|
||||
channel[i].from_b);
|
||||
}
|
||||
@@ -317,7 +319,8 @@ void DoHdma(Snes* snes, MemoryImpl* memory, bool do_sync, int cycles) {
|
||||
}
|
||||
snes->RunCycles(8);
|
||||
channel[i].size |=
|
||||
snes->Read((channel[i].a_bank << 16) | channel[i].table_addr++) << 8;
|
||||
snes->Read((channel[i].a_bank << 16) | channel[i].table_addr++)
|
||||
<< 8;
|
||||
}
|
||||
if (channel[i].rep_count == 0) channel[i].terminated = true;
|
||||
channel[i].do_transfer = true;
|
||||
|
||||
@@ -15,17 +15,20 @@ using namespace yaze;
|
||||
|
||||
DEFINE_FLAG(std::string, rom_file, "", "The ROM file to load.");
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
int main(int argc, char **argv) {
|
||||
absl::InitializeSymbolizer(argv[0]);
|
||||
|
||||
|
||||
// Configure failure signal handler to be less aggressive
|
||||
// This prevents false positives during SDL/graphics cleanup
|
||||
absl::FailureSignalHandlerOptions options;
|
||||
options.symbolize_stacktrace = true;
|
||||
options.use_alternate_stack = false; // Avoid conflicts with normal stack during cleanup
|
||||
options.alarm_on_failure_secs = false; // Don't set alarms that can trigger on natural leaks
|
||||
options.use_alternate_stack =
|
||||
false; // Avoid conflicts with normal stack during cleanup
|
||||
options.alarm_on_failure_secs =
|
||||
false; // Don't set alarms that can trigger on natural leaks
|
||||
options.call_previous_handler = true; // Allow system handlers to also run
|
||||
options.writerfn = nullptr; // Use default writer to avoid custom handling issues
|
||||
options.writerfn =
|
||||
nullptr; // Use default writer to avoid custom handling issues
|
||||
absl::InstallFailureSignalHandler(options);
|
||||
yaze::util::FlagParser parser(yaze::util::global_flag_registry());
|
||||
RETURN_IF_EXCEPTION(parser.Parse(argc, argv));
|
||||
|
||||
Reference in New Issue
Block a user