From c69f43c4c2d271fcadc1c056e832b9d30b113e2a Mon Sep 17 00:00:00 2001 From: angie Date: Sat, 25 May 2024 11:00:15 -0400 Subject: [PATCH] format files again --- librecomp/include/recomp_overlays.h | 3 +- librecomp/src/overlays.cpp | 21 ++++++------ librecomp/src/patch_loading.cpp | 2 +- librecomp/src/recomp.cpp | 52 ++++++++++++++--------------- 4 files changed, 40 insertions(+), 38 deletions(-) diff --git a/librecomp/include/recomp_overlays.h b/librecomp/include/recomp_overlays.h index 1589e30..718f5fd 100644 --- a/librecomp/include/recomp_overlays.h +++ b/librecomp/include/recomp_overlays.h @@ -2,6 +2,7 @@ #define __RECOMP_OVERLAYS_H__ #include + #include "sections.h" namespace recomp { @@ -18,7 +19,7 @@ namespace recomp { extern void register_overlays(const overlay_section_table_data_t& sections, const overlays_by_index_t& overlays); extern void register_patch_section(SectionTableEntry* code_sections); -}; +}; // namespace recomp extern "C" void load_overlays(uint32_t rom, int32_t ram_addr, uint32_t size); extern "C" void unload_overlays(int32_t ram_addr, uint32_t size); diff --git a/librecomp/src/overlays.cpp b/librecomp/src/overlays.cpp index 87e5829..3927d30 100644 --- a/librecomp/src/overlays.cpp +++ b/librecomp/src/overlays.cpp @@ -7,8 +7,8 @@ #include "recomp_overlays.h" #include "sections.h" -static recomp::overlay_section_table_data_t sections_info {}; -static recomp::overlays_by_index_t overlays_info {}; +static recomp::overlay_section_table_data_t sections_info{}; +static recomp::overlays_by_index_t overlays_info{}; void recomp::register_overlays(const recomp::overlay_section_table_data_t& sections, const recomp::overlays_by_index_t& overlays) { sections_info = sections; @@ -58,12 +58,13 @@ int32_t* section_addresses = nullptr; extern "C" void load_overlays(uint32_t rom, int32_t ram_addr, uint32_t size) { // Search for the first section that's included in the loaded rom range // Sections were sorted by `init_overlays` so we can use the bounds functions - auto lower = std::lower_bound(§ions_info.code_sections[0], §ions_info.code_sections[sections_info.num_code_sections], rom, + auto lower = std::lower_bound( + §ions_info.code_sections[0], §ions_info.code_sections[sections_info.num_code_sections], rom, [](const SectionTableEntry& entry, uint32_t addr) { return entry.rom_addr < addr; - } - ); - auto upper = std::upper_bound(§ions_info.code_sections[0], §ions_info.code_sections[sections_info.num_code_sections], (uint32_t)(rom + size), + }); + auto upper = std::upper_bound( + §ions_info.code_sections[0], §ions_info.code_sections[sections_info.num_code_sections], (uint32_t)(rom + size), [](uint32_t addr, const SectionTableEntry& entry) { return addr < entry.size + entry.rom_addr; }); @@ -146,18 +147,18 @@ extern "C" void unload_overlays(int32_t ram_addr, uint32_t size) { void load_patch_functions(); void init_overlays() { - section_addresses = (int32_t *)malloc(sections_info.total_num_sections * sizeof(int32_t)); + section_addresses = (int32_t*)malloc(sections_info.total_num_sections * sizeof(int32_t)); for (size_t section_index = 0; section_index < sections_info.total_num_sections; section_index++) { section_addresses[sections_info.code_sections[section_index].index] = sections_info.code_sections[section_index].ram_addr; } // Sort the executable sections by rom address - std::sort(§ions_info.code_sections[0], §ions_info.code_sections[sections_info.num_code_sections], + std::sort( + §ions_info.code_sections[0], §ions_info.code_sections[sections_info.num_code_sections], [](const SectionTableEntry& a, const SectionTableEntry& b) { return a.rom_addr < b.rom_addr; - } - ); + }); load_patch_functions(); } diff --git a/librecomp/src/patch_loading.cpp b/librecomp/src/patch_loading.cpp index 3d8a9fb..59a32ad 100644 --- a/librecomp/src/patch_loading.cpp +++ b/librecomp/src/patch_loading.cpp @@ -3,8 +3,8 @@ #include #include "recomp.h" -#include "sections.h" #include "recomp_overlays.h" +#include "sections.h" static SectionTableEntry* code_sections = nullptr; diff --git a/librecomp/src/recomp.cpp b/librecomp/src/recomp.cpp index 13790f9..9b33859 100644 --- a/librecomp/src/recomp.cpp +++ b/librecomp/src/recomp.cpp @@ -1,21 +1,20 @@ +#include #include #include #include #include #include #include -#include -#include -#include #include #include +#include #include #include #ifdef _WIN32 -#include +# include #elif defined(__linux__) -#include +# include #endif #include "recomp.h" @@ -89,7 +88,7 @@ static std::vector read_file(const std::filesystem::path& path) { bool write_file(const std::filesystem::path& path, const std::vector& data) { std::ofstream out_file{ path, std::ios::binary }; - recomp::g + if (!out_file.good()) { return false; } @@ -107,7 +106,7 @@ std::filesystem::path recomp::get_app_folder_path() { PWSTR known_path = NULL; HRESULT result = SHGetKnownFolderPath(FOLDERID_LocalAppData, 0, NULL, &known_path); if (result == S_OK) { - recomp_dir = std::filesystem::path{known_path} / recomp::get_program_id(); + recomp_dir = std::filesystem::path{ known_path } / recomp::get_program_id(); } CoTaskMemFree(known_path); @@ -118,9 +117,9 @@ std::filesystem::path recomp::get_app_folder_path() { homedir = getpwuid(getuid())->pw_dir; } - if (homedir != nullptr) { - recomp_dir = std::filesystem::path{homedir} / (std::u8string{u8".config/"} + recomp::get_program_id()); - } + if (homedir != nullptr) { + recomp_dir = std::filesystem::path{ homedir } / (std::u8string{ u8".config/" } + recomp::get_program_id()); + } #endif return recomp_dir; @@ -455,20 +454,20 @@ void recomp::start( std::unique_ptr rdram_buffer = std::make_unique(ultramodern::rdram_size); std::memset(rdram_buffer.get(), 0, ultramodern::rdram_size); - std::thread game_thread{[](ultramodern::WindowHandle window_handle, uint8_t* rdram) { - debug_printf("[Recomp] Starting\n"); + std::thread game_thread{ + [](ultramodern::WindowHandle window_handle, uint8_t* rdram) { + debug_printf("[Recomp] Starting\n"); - ultramodern::set_native_thread_name("Game Start Thread"); + ultramodern::set_native_thread_name("Game Start Thread"); - ultramodern::preinit(rdram, window_handle); + ultramodern::preinit(rdram, window_handle); game_status.wait(GameStatus::None); recomp_context context{}; switch (game_status.load()) { // TODO refactor this to allow a project to specify what entrypoint function to run for a give game. - case GameStatus::Running: - { + case GameStatus::Running: { if (!recomp::load_stored_rom(current_game.value())) { recomp::message_box("Error opening stored ROM! Please restart this program."); } @@ -481,20 +480,21 @@ void recomp::start( try { recomp_entrypoint(rdram, &context); } catch (ultramodern::thread_terminated& terminated) { - } - } - break; + } break; - case GameStatus::Quit: - break; + case GameStatus::Quit: + break; - case GameStatus::None: - break; - } + case GameStatus::None: + break; + } - debug_printf("[Recomp] Quitting\n"); - }, window_handle, rdram_buffer.get(),}; + debug_printf("[Recomp] Quitting\n"); + }, + window_handle, + rdram_buffer.get(), + }; while (!exited) { ultramodern::sleep_milliseconds(1);