From 16fb3a7080e5e08ecb094eba750a8996249d846a Mon Sep 17 00:00:00 2001 From: Maschell Date: Fri, 1 Mar 2019 19:31:45 +0100 Subject: [PATCH] Formatting --- src/Application.cpp | 2 +- src/custom/gui/DefaultGuiSelectBox.cpp | 22 +++++++-------- src/custom/gui/DefaultGuiSelectBox.h | 32 ++++++++++----------- src/custom/gui/DefaultGuiSwitch.cpp | 22 +++++++-------- src/custom/gui/DefaultGuiSwitch.h | 32 ++++++++++----------- src/main.cpp | 2 +- src/menu/content/ContentHome.cpp | 2 +- src/mykernel/kernel_defs.h | 9 ++---- src/mykernel/kernel_utils.c | 39 +++++++++++++------------- src/mymemory/memory_mapping.cpp | 28 +++++++++--------- src/mymemory/memory_mapping.h | 6 ++-- src/myutils/ConfigInformation.cpp | 2 +- src/myutils/ConfigUtils.cpp | 24 ++++++++-------- src/myutils/ConfigUtils.h | 10 +++---- src/myutils/mem_utils.cpp | 8 +++--- src/myutils/overlay_helper.cpp | 8 ++++-- src/myutils/texture_utils.cpp | 21 +++++++------- src/patcher/hooks_patcher_static.cpp | 10 +++---- src/plugin/DynamicLinkingHelper.h | 12 ++++---- src/plugin/ElfTools.cpp | 5 ++-- src/plugin/PluginLoader.cpp | 4 +-- src/resources/filelist.cpp | 39 +++++++++++++------------- src/settings/ConfigSettings.h | 2 +- src/utils.cpp | 14 ++++----- 24 files changed, 177 insertions(+), 178 deletions(-) diff --git a/src/Application.cpp b/src/Application.cpp index 225ad21..da15b99 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -187,7 +187,7 @@ void Application::executeThread(void) { bool result = linkPluginsCallback(); if(!result) { // On linking errors return to the HBL. - #warning TODO: proper error handling when linking fails. +#warning TODO: proper error handling when linking fails. exitCode = APPLICATION_CLOSE_MIIMAKER; } } diff --git a/src/custom/gui/DefaultGuiSelectBox.cpp b/src/custom/gui/DefaultGuiSelectBox.cpp index 935d142..aee146c 100644 --- a/src/custom/gui/DefaultGuiSelectBox.cpp +++ b/src/custom/gui/DefaultGuiSelectBox.cpp @@ -20,16 +20,15 @@ */ DefaultGuiSelectBox::DefaultGuiSelectBox(std::string caption, GuiFrame *parent) - : GuiSelectBox(NULL,caption) - ,topBackgroundImg_imgdata(Resources::GetImageData("gameSettingsButton.png")) - ,topBackgroundImg_img(topBackgroundImg_imgdata) - ,topHighlightedImg_imgdata(Resources::GetImageData("gameSettingsButtonSelected.png")) - ,topHighlightedImg_img(topHighlightedImg_imgdata) - ,valueImageData(Resources::GetImageData("gameSettingsButtonEx.png")) - ,valueSelectedImageData(Resources::GetImageData("gameSettingsButtonExSelected.png")) - ,valueHighlightedImageData(Resources::GetImageData("gameSettingsButtonExHighlighted.png")) - ,buttonClickSound(Resources::GetSound("settings_click_2.mp3")) -{ + : GuiSelectBox(NULL,caption) + ,topBackgroundImg_imgdata(Resources::GetImageData("gameSettingsButton.png")) + ,topBackgroundImg_img(topBackgroundImg_imgdata) + ,topHighlightedImg_imgdata(Resources::GetImageData("gameSettingsButtonSelected.png")) + ,topHighlightedImg_img(topHighlightedImg_imgdata) + ,valueImageData(Resources::GetImageData("gameSettingsButtonEx.png")) + ,valueSelectedImageData(Resources::GetImageData("gameSettingsButtonExSelected.png")) + ,valueHighlightedImageData(Resources::GetImageData("gameSettingsButtonExHighlighted.png")) + ,buttonClickSound(Resources::GetSound("settings_click_2.mp3")) { setSize(topBackgroundImg_img.getWidth(),topBackgroundImg_img.getHeight()); this->setImageTopBackground(&topBackgroundImg_img); this->setImageTopHighlighted(&topHighlightedImg_img); @@ -41,8 +40,7 @@ DefaultGuiSelectBox::DefaultGuiSelectBox(std::string caption, GuiFrame *parent) /** * Destructor for the DefaultGuiSelectBox class. */ -DefaultGuiSelectBox::~DefaultGuiSelectBox() -{ +DefaultGuiSelectBox::~DefaultGuiSelectBox() { Resources::RemoveImageData(topBackgroundImg_imgdata); Resources::RemoveImageData(topHighlightedImg_imgdata); Resources::RemoveImageData(valueImageData); diff --git a/src/custom/gui/DefaultGuiSelectBox.h b/src/custom/gui/DefaultGuiSelectBox.h index 310e08a..8c0295e 100644 --- a/src/custom/gui/DefaultGuiSelectBox.h +++ b/src/custom/gui/DefaultGuiSelectBox.h @@ -20,26 +20,26 @@ #include //!A simple select box with default values. -class DefaultGuiSelectBox : public GuiSelectBox{ - public: - //!Constructor - //!\param checked Checked - DefaultGuiSelectBox(std::string caption, GuiFrame *parent = NULL); - //!Destructor - virtual ~DefaultGuiSelectBox(); +class DefaultGuiSelectBox : public GuiSelectBox { +public: + //!Constructor + //!\param checked Checked + DefaultGuiSelectBox(std::string caption, GuiFrame *parent = NULL); + //!Destructor + virtual ~DefaultGuiSelectBox(); - protected: - GuiImageData * topBackgroundImg_imgdata; - GuiImage topBackgroundImg_img; +protected: + GuiImageData * topBackgroundImg_imgdata; + GuiImage topBackgroundImg_img; - GuiImageData * topHighlightedImg_imgdata; - GuiImage topHighlightedImg_img; + GuiImageData * topHighlightedImg_imgdata; + GuiImage topHighlightedImg_img; - GuiImageData * valueImageData; - GuiImageData * valueSelectedImageData; - GuiImageData * valueHighlightedImageData; + GuiImageData * valueImageData; + GuiImageData * valueSelectedImageData; + GuiImageData * valueHighlightedImageData; - GuiSound * buttonClickSound; + GuiSound * buttonClickSound; }; #endif diff --git a/src/custom/gui/DefaultGuiSwitch.cpp b/src/custom/gui/DefaultGuiSwitch.cpp index 4205697..8b15328 100644 --- a/src/custom/gui/DefaultGuiSwitch.cpp +++ b/src/custom/gui/DefaultGuiSwitch.cpp @@ -20,16 +20,15 @@ */ DefaultGuiSwitch::DefaultGuiSwitch(bool checked) - : GuiSwitch(NULL,checked) - ,switchbase_imgdata(Resources::GetImageData("switchIconBase.png")) - ,switchbase_img(switchbase_imgdata) - ,switchbase_highlighted_imgdata(Resources::GetImageData("switchIconBaseHighlighted.png")) - ,switchbase_highlighted_img(switchbase_highlighted_imgdata) - ,switchOn_imgdata(Resources::GetImageData("switchIconOn.png")) - ,switchOn_img(switchOn_imgdata) - ,switchOff_imgdata(Resources::GetImageData("switchIconOff.png")) - ,switchOff_img(switchOff_imgdata) -{ + : GuiSwitch(NULL,checked) + ,switchbase_imgdata(Resources::GetImageData("switchIconBase.png")) + ,switchbase_img(switchbase_imgdata) + ,switchbase_highlighted_imgdata(Resources::GetImageData("switchIconBaseHighlighted.png")) + ,switchbase_highlighted_img(switchbase_highlighted_imgdata) + ,switchOn_imgdata(Resources::GetImageData("switchIconOn.png")) + ,switchOn_img(switchOn_imgdata) + ,switchOff_imgdata(Resources::GetImageData("switchIconOff.png")) + ,switchOff_img(switchOff_imgdata) { setSize(switchbase_img.getWidth(),switchbase_img.getHeight()); this->setImageBackground(&switchbase_img); this->setImageHighlighted(&switchbase_highlighted_img); @@ -39,8 +38,7 @@ DefaultGuiSwitch::DefaultGuiSwitch(bool checked) /** * Destructor for the DefaultGuiSwitch class. */ -DefaultGuiSwitch::~DefaultGuiSwitch() -{ +DefaultGuiSwitch::~DefaultGuiSwitch() { Resources::RemoveImageData(switchbase_imgdata); Resources::RemoveImageData(switchbase_highlighted_imgdata); Resources::RemoveImageData(switchOn_imgdata); diff --git a/src/custom/gui/DefaultGuiSwitch.h b/src/custom/gui/DefaultGuiSwitch.h index da6c563..ea1f07f 100644 --- a/src/custom/gui/DefaultGuiSwitch.h +++ b/src/custom/gui/DefaultGuiSwitch.h @@ -20,26 +20,26 @@ #include //!A simple switch -class DefaultGuiSwitch : public GuiSwitch{ - public: - //!Constructor - //!\param checked Checked - DefaultGuiSwitch(bool checked); - //!Destructor - virtual ~DefaultGuiSwitch(); +class DefaultGuiSwitch : public GuiSwitch { +public: + //!Constructor + //!\param checked Checked + DefaultGuiSwitch(bool checked); + //!Destructor + virtual ~DefaultGuiSwitch(); - protected: - GuiImageData * switchbase_imgdata = NULL; - GuiImage switchbase_img; +protected: + GuiImageData * switchbase_imgdata = NULL; + GuiImage switchbase_img; - GuiImageData * switchbase_highlighted_imgdata = NULL; - GuiImage switchbase_highlighted_img; + GuiImageData * switchbase_highlighted_imgdata = NULL; + GuiImage switchbase_highlighted_img; - GuiImageData * switchOn_imgdata = NULL; - GuiImage switchOn_img; + GuiImageData * switchOn_imgdata = NULL; + GuiImage switchOn_img; - GuiImageData * switchOff_imgdata = NULL; - GuiImage switchOff_img; + GuiImageData * switchOff_imgdata = NULL; + GuiImage switchOff_img; }; #endif diff --git a/src/main.cpp b/src/main.cpp index dfa7274..26b110a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -148,7 +148,7 @@ extern "C" int32_t Menu_Main(int32_t argc, char **argv) { g_vid_originalContextSave = NULL; g_vid_ownContextState = NULL; g_NotInLoader = false; - }else{ + } else { g_NotInLoader = true; } diff --git a/src/menu/content/ContentHome.cpp b/src/menu/content/ContentHome.cpp index d597d2a..4c3ca03 100644 --- a/src/menu/content/ContentHome.cpp +++ b/src/menu/content/ContentHome.cpp @@ -231,7 +231,7 @@ bool ContentHome::linkPlugins() { void ContentHome::update(GuiController * c) { ContentTemplate::update(c); - if(updateButtons){ + if(updateButtons) { for (auto const& x : selectionMapping) { int index = x.first; GuiToggle* toggle = x.second; diff --git a/src/mykernel/kernel_defs.h b/src/mykernel/kernel_defs.h index efdd44c..47c187a 100644 --- a/src/mykernel/kernel_defs.h +++ b/src/mykernel/kernel_defs.h @@ -8,20 +8,17 @@ extern "C" { #endif -typedef struct _sr_table_t -{ +typedef struct _sr_table_t { uint32_t value[16]; uint32_t sdr1; } sr_table_t; -typedef struct _bat_t -{ +typedef struct _bat_t { uint32_t h; uint32_t l; } bat_t; -typedef struct _bat_table_t -{ +typedef struct _bat_table_t { bat_t bat[8]; } bat_table_t; diff --git a/src/mykernel/kernel_utils.c b/src/mykernel/kernel_utils.c index 1ca5df4..17b3e61 100644 --- a/src/mykernel/kernel_utils.c +++ b/src/mykernel/kernel_utils.c @@ -58,22 +58,23 @@ static void KernelWriteSRs(sr_table_t * table) { // Writing didn't work for all at once so we only write number 8. // TODO: fix this and change it if required. - /*asm volatile("mtsr 0, %0" : : "r" (table->value[i])); i++; - asm volatile("mtsr 1, %0" : : "r" (table->value[i])); i++; - asm volatile("mtsr 2, %0" : : "r" (table->value[i])); i++; - asm volatile("mtsr 3, %0" : : "r" (table->value[i])); i++; - asm volatile("mtsr 4, %0" : : "r" (table->value[i])); i++; - asm volatile("mtsr 5, %0" : : "r" (table->value[i])); i++;*/ - //asm volatile("mtsr 6, %0" : : "r" (table->value[6])); i++; - /*asm volatile("mtsr 7, %0" : : "r" (table->value[i])); i++;*/ - asm volatile("mtsr 8, %0" : : "r" (table->value[8])); i++; - /*asm volatile("mtsr 9, %0" : : "r" (table->value[i])); i++; - asm volatile("mtsr 10, %0" : : "r" (table->value[i])); i++; - asm volatile("mtsr 11, %0" : : "r" (table->value[i])); i++; - asm volatile("mtsr 12, %0" : : "r" (table->value[i])); i++; - asm volatile("mtsr 13, %0" : : "r" (table->value[i])); i++; - asm volatile("mtsr 14, %0" : : "r" (table->value[i])); i++; - asm volatile("mtsr 15, %0" : : "r" (table->value[i])); i++;*/ + /*asm volatile("mtsr 0, %0" : : "r" (table->value[i])); i++; + asm volatile("mtsr 1, %0" : : "r" (table->value[i])); i++; + asm volatile("mtsr 2, %0" : : "r" (table->value[i])); i++; + asm volatile("mtsr 3, %0" : : "r" (table->value[i])); i++; + asm volatile("mtsr 4, %0" : : "r" (table->value[i])); i++; + asm volatile("mtsr 5, %0" : : "r" (table->value[i])); i++;*/ + //asm volatile("mtsr 6, %0" : : "r" (table->value[6])); i++; + /*asm volatile("mtsr 7, %0" : : "r" (table->value[i])); i++;*/ + asm volatile("mtsr 8, %0" : : "r" (table->value[8])); + i++; + /*asm volatile("mtsr 9, %0" : : "r" (table->value[i])); i++; + asm volatile("mtsr 10, %0" : : "r" (table->value[i])); i++; + asm volatile("mtsr 11, %0" : : "r" (table->value[i])); i++; + asm volatile("mtsr 12, %0" : : "r" (table->value[i])); i++; + asm volatile("mtsr 13, %0" : : "r" (table->value[i])); i++; + asm volatile("mtsr 14, %0" : : "r" (table->value[i])); i++; + asm volatile("mtsr 15, %0" : : "r" (table->value[i])); i++;*/ asm volatile("isync"); @@ -87,7 +88,7 @@ void KernelReadPTE(uint32_t* dest, uint32_t size) { asm volatile("mfmsr %0" : "=r" (msr)); oldmsr = msr; msr &= ~0x10; - for(uint32_t i = 0;i= curMemValues[j].start_address && phyiscalAddress < curMemValues[j].end_address){ + if(phyiscalAddress >= curMemValues[j].start_address && phyiscalAddress < curMemValues[j].end_address) { // calculate the EA result = (phyiscalAddress - curMemValues[j].start_address) + (mem_mapping[i].effective_start_address + curOffsetInEA); return result; @@ -712,33 +712,33 @@ uint32_t MemoryMapping::PhysicalToEffective(uint32_t phyiscalAddress){ return result; } -uint32_t MemoryMapping::EffectiveToPhysical(uint32_t effectiveAddress){ +uint32_t MemoryMapping::EffectiveToPhysical(uint32_t effectiveAddress) { uint32_t result = 0; // CAUTION: The data may be fragmented between multiple areas in PA. const memory_values_t * curMemValues = NULL; int32_t curOffset = 0; - for(int32_t i = 0;true;i++){ - if(mem_mapping[i].physical_addresses == NULL){ + for(int32_t i = 0; true; i++) { + if(mem_mapping[i].physical_addresses == NULL) { break; } - if(effectiveAddress >= mem_mapping[i].effective_start_address && effectiveAddress < mem_mapping[i].effective_end_address){ + if(effectiveAddress >= mem_mapping[i].effective_start_address && effectiveAddress < mem_mapping[i].effective_end_address) { curMemValues = mem_mapping[i].physical_addresses; curOffset = mem_mapping[i].effective_start_address; break; } } - if(curMemValues == NULL){ + if(curMemValues == NULL) { return result; } - for(int32_t i= 0;true;i++){ - if(curMemValues[i].end_address == 0){ + for(int32_t i= 0; true; i++) { + if(curMemValues[i].end_address == 0) { break; } int32_t curChunkSize = curMemValues[i].end_address - curMemValues[i].start_address; - if(effectiveAddress < (curOffset + curChunkSize)){ + if(effectiveAddress < (curOffset + curChunkSize)) { result = (effectiveAddress - curOffset) + curMemValues[i].start_address; break; } diff --git a/src/mymemory/memory_mapping.h b/src/mymemory/memory_mapping.h index 372155a..299d3c2 100644 --- a/src/mymemory/memory_mapping.h +++ b/src/mymemory/memory_mapping.h @@ -53,12 +53,12 @@ typedef struct _memory_mapping_t { #define MEMORY_START_PLUGIN_HEAP_END MEMORY_START_PLUGIN_HEAP + MEMORY_PLUGIN_HEAP_SIZE const memory_values_t mem_vals_loader[] = { - {0x28000000 + 0x06620000 , 0x28000000 + 0x06E20000}, // 8MB 0x80000000 0x80800000 -> 0x2E700000 0x2EF00000 + {0x28000000 + 0x06620000, 0x28000000 + 0x06E20000}, // 8MB 0x80000000 0x80800000 -> 0x2E700000 0x2EF00000 {0,0} }; const memory_values_t mem_vals_plugins[] = { - {0x28000000 + 0x06E20000 , 0x28000000 + 0x07E20000}, // 16MB 0x80800000 0x81800000 -> 0x2EF00000 0x2FF00000 + {0x28000000 + 0x06E20000, 0x28000000 + 0x07E20000}, // 16MB 0x80800000 0x81800000 -> 0x2EF00000 0x2FF00000 {0,0} }; @@ -85,7 +85,7 @@ const memory_values_t mem_vals_video[] = { // size += 0x20000; // value have to be a multiple of 0x20000; // } // - {0x1A020000 , 0x1A020000 +0xE60000}, // size: 14720 kB + {0x1A020000, 0x1A020000 +0xE60000}, // size: 14720 kB // The following chunk were empty while early tests and are maybe promising. However we can get 15mb from // a loader heap. Which should be enough for now. //{0x14000000 + 0x02E00000 , 0x14000000 +0x034E0000}, // size: 7040 kB diff --git a/src/myutils/ConfigInformation.cpp b/src/myutils/ConfigInformation.cpp index 72fb13b..e7accf2 100644 --- a/src/myutils/ConfigInformation.cpp +++ b/src/myutils/ConfigInformation.cpp @@ -104,7 +104,7 @@ bool ConfigInformation::updateConfigSettings() { for (auto & curItem : curCat->getItems()) { std::string configID = curItem->getConfigID(); std::string newValue = curItem->persistValue(); - if(this->configSettings->setValueAsString(this->configSettings->getIdByName(configID), newValue)){ + if(this->configSettings->setValueAsString(this->configSettings->getIdByName(configID), newValue)) { // When the value has changed, call the callback. DEBUG_FUNCTION_LINE("Called callback. Reason. Menu was closed and value has changed\n"); curItem->callCallback(); diff --git a/src/myutils/ConfigUtils.cpp b/src/myutils/ConfigUtils.cpp index 8ecd997..5594433 100644 --- a/src/myutils/ConfigUtils.cpp +++ b/src/myutils/ConfigUtils.cpp @@ -166,19 +166,19 @@ void ConfigUtils::configMenuOpenedCallback(wups_overlay_options_type_t screen, v } if(vpad_data.btns_d & VPAD_BUTTON_RIGHT) { pressedButtons |= WUPS_CONFIG_BUTTON_RIGHT; - } - if(vpad_data.btns_d & VPAD_BUTTON_L) { + } + if(vpad_data.btns_d & VPAD_BUTTON_L) { pressedButtons |= WUPS_CONFIG_BUTTON_L; } if(vpad_data.btns_d & VPAD_BUTTON_R) { pressedButtons |= WUPS_CONFIG_BUTTON_R; } - if(vpad_data.btns_d & VPAD_BUTTON_ZL) { + if(vpad_data.btns_d & VPAD_BUTTON_ZL) { pressedButtons |= WUPS_CONFIG_BUTTON_ZL; } if(vpad_data.btns_d & VPAD_BUTTON_ZR) { pressedButtons |= WUPS_CONFIG_BUTTON_ZR; - } + } if(vpad_data.btns_r & VPAD_BUTTON_DOWN) { newSelect++; @@ -229,9 +229,9 @@ void ConfigUtils::configMenuOpenedCallback(wups_overlay_options_type_t screen, v if(!ignore && curSelect == inSelect) { if(curSelect == 0) { curScreenOffset = 0; - }else if(cur_visible_rows + curScreenOffset >= visible_rows_range) { + } else if(cur_visible_rows + curScreenOffset >= visible_rows_range) { curScreenOffset -= (cur_visible_rows + curScreenOffset) - visible_rows_range; - }else if(cur_visible_rows + curScreenOffset < visible_rows_range/2 && cur_visible_rows >= visible_rows_range/2) { + } else if(cur_visible_rows + curScreenOffset < visible_rows_range/2 && cur_visible_rows >= visible_rows_range/2) { curScreenOffset -= (cur_visible_rows + curScreenOffset) - visible_rows_range/2; } ignore = true; @@ -343,27 +343,27 @@ void ConfigUtils::deleteConfigInformation(std::vector confi void ConfigUtils::loadConfigFromSD() { std::vector configInfos = getConfigInformation(); - + for (auto & curConfig : configInfos) { curConfig->loadValuesFromSD(); } - + deleteConfigInformation(configInfos); } void ConfigUtils::saveConfigToSD() { std::vector configInfos = getConfigInformation(); - + for (auto & curConfig : configInfos) { curConfig->updateAndSaveSettings(true); } - + deleteConfigInformation(configInfos); } void ConfigUtils::openConfigMenu() { std::vector configInfos = getConfigInformation(); - + // We rely on the default values here. //if(loadFromSD){ // for (auto & curConfig : configInfos) { @@ -386,7 +386,7 @@ void ConfigUtils::openConfigMenu() { for (auto & curConfig : configs) { DCFlushRange(curConfig, sizeof(WUPSConfig)); } - + for (auto & curConfig : configInfos) { curConfig->updateAndSaveSettings(false); } diff --git a/src/myutils/ConfigUtils.h b/src/myutils/ConfigUtils.h index 05cc848..daea4f3 100644 --- a/src/myutils/ConfigUtils.h +++ b/src/myutils/ConfigUtils.h @@ -29,10 +29,10 @@ public: and triggers the "callback" if they differ the default/current value. **/ static void loadConfigFromSD(); - - /** - Get the current values from all plugins via the WUPS_GET_CONFIG() hook and - save them to the SD Card. + + /** + Get the current values from all plugins via the WUPS_GET_CONFIG() hook and + save them to the SD Card. **/ static void saveConfigToSD(); @@ -72,7 +72,7 @@ private: default value. This behaviour may change in the future. See the ConfigInformation class for more information. **/ - static std::vector getConfigInformation(); + static std::vector getConfigInformation(); /** Delete a list of ConfigInformation. diff --git a/src/myutils/mem_utils.cpp b/src/myutils/mem_utils.cpp index 6674412..66c30d2 100644 --- a/src/myutils/mem_utils.cpp +++ b/src/myutils/mem_utils.cpp @@ -24,14 +24,14 @@ int32_t memHandle __attribute__((section(".data"))) = -1; -void MemoryUtils::init(){ +void MemoryUtils::init() { memHandle = MEMCreateExpHeapEx((void*)MemoryMapping::getVideoMemoryAddress(), MemoryMapping::getVideoMemorySize(), 0); } -void* MemoryUtils::alloc(uint32_t size, int32_t align){ +void* MemoryUtils::alloc(uint32_t size, int32_t align) { return MEMAllocFromExpHeapEx(memHandle,size, align); } -void MemoryUtils::free(void * ptr){ - MEMFreeToExpHeap(memHandle,ptr); +void MemoryUtils::free(void * ptr) { + MEMFreeToExpHeap(memHandle,ptr); } diff --git a/src/myutils/overlay_helper.cpp b/src/myutils/overlay_helper.cpp index 8258f9e..6d7d492 100644 --- a/src/myutils/overlay_helper.cpp +++ b/src/myutils/overlay_helper.cpp @@ -18,8 +18,12 @@ uint32_t * getFromGX2Buffer(struct buffer_store store, uint32_t size) { } void overlay_helper(wups_overlay_options_type_t screen, overlay_callback callback, void * args) { - if(callback == NULL) return; - if(!OSIsHomeButtonMenuEnabled()) return; // This pauses the game. Make sure to only do it when the home button is allowed. + if(callback == NULL) { + return; + } + if(!OSIsHomeButtonMenuEnabled()) { + return; // This pauses the game. Make sure to only do it when the home button is allowed. + } //TODO: Make sure this actually pauses the game (Hook on GX2VSync?) . Currently only tested from VPADRead which also pauses the game. diff --git a/src/myutils/texture_utils.cpp b/src/myutils/texture_utils.cpp index efd59b7..80ee23b 100644 --- a/src/myutils/texture_utils.cpp +++ b/src/myutils/texture_utils.cpp @@ -22,15 +22,14 @@ #include #include "mem_utils.h" -void gdImageToUnormR8G8B8A8(gdImagePtr gdImg, u32 *imgBuffer, u32 width, u32 height, u32 pitch){ - for(u32 y = 0; y < height; ++y) - { - for(u32 x = 0; x < width; ++x) - { - u32 pixel = gdImageGetPixel(gdImg, x, y); +void gdImageToUnormR8G8B8A8(gdImagePtr gdImg, u32 *imgBuffer, u32 width, u32 height, u32 pitch) { + for(u32 y = 0; y < height; ++y) { + for(u32 x = 0; x < width; ++x) { + u32 pixel = gdImageGetPixel(gdImg, x, y); - u8 a = 254 - 2*((u8)gdImageAlpha(gdImg, pixel)); - if(a == 254) a++; + u8 a = 254 - 2*((u8)gdImageAlpha(gdImg, pixel)); + if(a == 254) + a++; u8 r = gdImageRed(gdImg, pixel); u8 g = gdImageGreen(gdImg, pixel); @@ -111,8 +110,8 @@ void TextureUtils::copyToTexture(GX2ColorBuffer* sourceBuffer, GX2Texture * targ } } -bool TextureUtils::convertImageToTexture(const uint8_t *img, int32_t imgSize, void * _texture){ - if(!img || (imgSize < 8) || _texture == NULL){ +bool TextureUtils::convertImageToTexture(const uint8_t *img, int32_t imgSize, void * _texture) { + if(!img || (imgSize < 8) || _texture == NULL) { return false; } GX2Texture * texture = (GX2Texture *) _texture; @@ -137,7 +136,7 @@ bool TextureUtils::convertImageToTexture(const uint8_t *img, int32_t imgSize, vo //gdImg = gdImageCreateFromTgaPtr(imgSize, (uint8_t*) img); } - if(gdImg == 0){ + if(gdImg == 0) { return false; } diff --git a/src/patcher/hooks_patcher_static.cpp b/src/patcher/hooks_patcher_static.cpp index e65f9ed..3ce26d7 100644 --- a/src/patcher/hooks_patcher_static.cpp +++ b/src/patcher/hooks_patcher_static.cpp @@ -25,7 +25,7 @@ DECL(void, __PPCExit, void) { DECL_FUNCTION(uint32_t, __OSPhysicalToEffectiveCached, uint32_t phyiscalAddress) { uint32_t result = real___OSPhysicalToEffectiveCached(phyiscalAddress); - if(result == 0){ + if(result == 0) { result = MemoryMapping::PhysicalToEffective(phyiscalAddress); //DEBUG_FUNCTION_LINE("__OSPhysicalToEffectiveCached in %08X out %08X\n",phyiscalAddress,result); } @@ -34,7 +34,7 @@ DECL_FUNCTION(uint32_t, __OSPhysicalToEffectiveCached, uint32_t phyiscalAddress) DECL_FUNCTION(uint32_t, __OSPhysicalToEffectiveUncached, uint32_t phyiscalAddress) { uint32_t result = real___OSPhysicalToEffectiveUncached(phyiscalAddress); - if(result == 0){ + if(result == 0) { result = MemoryMapping::PhysicalToEffective(phyiscalAddress); //DEBUG_FUNCTION_LINE("__OSPhysicalToEffectiveUncached in %08X out %08X\n",phyiscalAddress,result); return result; @@ -45,7 +45,7 @@ DECL_FUNCTION(uint32_t, __OSPhysicalToEffectiveUncached, uint32_t phyiscalAddres DECL_FUNCTION(uint32_t, OSEffectiveToPhysical, uint32_t virtualAddress) { uint32_t result = real_OSEffectiveToPhysical(virtualAddress); - if(result == 0){ + if(result == 0) { result = MemoryMapping::EffectiveToPhysical(virtualAddress); //DEBUG_FUNCTION_LINE("OSEffectiveToPhysical in %08X out %08X\n",virtualAddress,result); return result; @@ -53,9 +53,9 @@ DECL_FUNCTION(uint32_t, OSEffectiveToPhysical, uint32_t virtualAddress) { return result; } -DECL_FUNCTION(int32_t, OSIsAddressValid, uint32_t virtualAddress){ +DECL_FUNCTION(int32_t, OSIsAddressValid, uint32_t virtualAddress) { int32_t result = real_OSIsAddressValid(virtualAddress); - if(result == 0){ + if(result == 0) { result = (MemoryMapping::EffectiveToPhysical(virtualAddress) > 0); //DEBUG_FUNCTION_LINE("OSIsAddressValid in %08X out %d\n",virtualAddress,result); return result; diff --git a/src/plugin/DynamicLinkingHelper.h b/src/plugin/DynamicLinkingHelper.h index f337346..7a5bef8 100644 --- a/src/plugin/DynamicLinkingHelper.h +++ b/src/plugin/DynamicLinkingHelper.h @@ -81,14 +81,14 @@ public: protected: private: - DynamicLinkingHelper() { - } + DynamicLinkingHelper() { + } - ~DynamicLinkingHelper() { + ~DynamicLinkingHelper() { - } + } - static DynamicLinkingHelper *instance; - }; + static DynamicLinkingHelper *instance; +}; #endif // DYNAMICLINKINGHELPER_H diff --git a/src/plugin/ElfTools.cpp b/src/plugin/ElfTools.cpp index 6cb18cb..e6fc23a 100644 --- a/src/plugin/ElfTools.cpp +++ b/src/plugin/ElfTools.cpp @@ -272,7 +272,7 @@ bool ElfTools::elfLink(Elf *elf, size_t shndx, void *destination, Elf32_Sym *sym uint32_t size = symtab[symbol].st_size; uint32_t address = pluginData->getMemoryForCommonBySymbol(symbol, align, size); - if(address == 0){ + if(address == 0) { DEBUG_FUNCTION_LINE("Failed to get memory for common relocation\n"); return false; } @@ -494,7 +494,8 @@ bool ElfTools::elfLinkOne(char type, size_t offset, int32_t addend, void *destin result = true; exit_error: - if (!result) DEBUG_FUNCTION_LINE("Plugin_ElfLinkOne: exit_error\n"); + if (!result) + DEBUG_FUNCTION_LINE("Plugin_ElfLinkOne: exit_error\n"); return result; } diff --git a/src/plugin/PluginLoader.cpp b/src/plugin/PluginLoader.cpp index db97361..2215e29 100644 --- a/src/plugin/PluginLoader.cpp +++ b/src/plugin/PluginLoader.cpp @@ -75,7 +75,7 @@ std::vector PluginLoader::getPluginInformation(const char * } } } - if(dfd != NULL){ + if(dfd != NULL) { closedir(dfd); } @@ -467,7 +467,7 @@ void PluginLoader::copyPluginDataIntoGlobalStruct(std::vector plug replacement_data_plugin_t * plugin_data = &gbl_replacement_data.plugin_data[plugin_index]; - #warning TODO: add GUI option to let the user choose +#warning TODO: add GUI option to let the user choose plugin_data->kernel_allowed = true; plugin_data->kernel_init_done = false; diff --git a/src/resources/filelist.cpp b/src/resources/filelist.cpp index 7d87b69..2a5e0bd 100644 --- a/src/resources/filelist.cpp +++ b/src/resources/filelist.cpp @@ -54,25 +54,26 @@ extern const uint32_t switchIconOn_png_size; extern const uint8_t TwitterIcon_png[]; extern const uint32_t TwitterIcon_png_size; -static ResourceFile ResourceList[] = -{ - {"font.ttf", font_ttf, font_ttf_size, NULL, 0}, - {"gameSettingsButton.png", gameSettingsButton_png, gameSettingsButton_png_size, NULL, 0}, - {"gameSettingsButtonEx.png", gameSettingsButtonEx_png, gameSettingsButtonEx_png_size, NULL, 0}, - {"gameSettingsButtonExHighlighted.png", gameSettingsButtonExHighlighted_png, gameSettingsButtonExHighlighted_png_size, NULL, 0}, - {"gameSettingsButtonExSelected.png", gameSettingsButtonExSelected_png, gameSettingsButtonExSelected_png_size, NULL, 0}, - {"gameSettingsButtonSelected.png", gameSettingsButtonSelected_png, gameSettingsButtonSelected_png_size, NULL, 0}, - {"GithubIcon.png", GithubIcon_png, GithubIcon_png_size, NULL, 0}, - {"HomeButtonIcon.png", HomeButtonIcon_png, HomeButtonIcon_png_size, NULL, 0}, - {"PlusButtonIcon.png", PlusButtonIcon_png, PlusButtonIcon_png_size, NULL, 0}, - {"settings_click_2.mp3", settings_click_2_mp3, settings_click_2_mp3_size, NULL, 0}, - {"switchIconBase.png", switchIconBase_png, switchIconBase_png_size, NULL, 0}, - {"switchIconBaseHighlighted.png", switchIconBaseHighlighted_png, switchIconBaseHighlighted_png_size, NULL, 0}, - {"switchIconOff.png", switchIconOff_png, switchIconOff_png_size, NULL, 0}, - {"switchIconOn.png", switchIconOn_png, switchIconOn_png_size, NULL, 0}, - {"TwitterIcon.png", TwitterIcon_png, TwitterIcon_png_size, NULL, 0}, - {NULL, NULL, 0, NULL, 0} +static ResourceFile ResourceList[] = { + {"font.ttf", font_ttf, font_ttf_size, NULL, 0}, + {"gameSettingsButton.png", gameSettingsButton_png, gameSettingsButton_png_size, NULL, 0}, + {"gameSettingsButtonEx.png", gameSettingsButtonEx_png, gameSettingsButtonEx_png_size, NULL, 0}, + {"gameSettingsButtonExHighlighted.png", gameSettingsButtonExHighlighted_png, gameSettingsButtonExHighlighted_png_size, NULL, 0}, + {"gameSettingsButtonExSelected.png", gameSettingsButtonExSelected_png, gameSettingsButtonExSelected_png_size, NULL, 0}, + {"gameSettingsButtonSelected.png", gameSettingsButtonSelected_png, gameSettingsButtonSelected_png_size, NULL, 0}, + {"GithubIcon.png", GithubIcon_png, GithubIcon_png_size, NULL, 0}, + {"HomeButtonIcon.png", HomeButtonIcon_png, HomeButtonIcon_png_size, NULL, 0}, + {"PlusButtonIcon.png", PlusButtonIcon_png, PlusButtonIcon_png_size, NULL, 0}, + {"settings_click_2.mp3", settings_click_2_mp3, settings_click_2_mp3_size, NULL, 0}, + {"switchIconBase.png", switchIconBase_png, switchIconBase_png_size, NULL, 0}, + {"switchIconBaseHighlighted.png", switchIconBaseHighlighted_png, switchIconBaseHighlighted_png_size, NULL, 0}, + {"switchIconOff.png", switchIconOff_png, switchIconOff_png_size, NULL, 0}, + {"switchIconOn.png", switchIconOn_png, switchIconOn_png_size, NULL, 0}, + {"TwitterIcon.png", TwitterIcon_png, TwitterIcon_png_size, NULL, 0}, + {NULL, NULL, 0, NULL, 0} }; -ResourceFile * getResourceList(){ return ResourceList; } +ResourceFile * getResourceList() { + return ResourceList; +} diff --git a/src/settings/ConfigSettings.h b/src/settings/ConfigSettings.h index 26ff0ab..c0c0d7a 100644 --- a/src/settings/ConfigSettings.h +++ b/src/settings/ConfigSettings.h @@ -202,7 +202,7 @@ public: int32_t getIdByName(std::string configID); - bool hasChanged(){ + bool hasChanged() { return bChanged; } diff --git a/src/utils.cpp b/src/utils.cpp index b57012a..61c7889 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -25,9 +25,9 @@ void CallHook(wups_loader_hook_type_t hook_type) { #ifdef __cplusplus extern "C" { #endif - // Part of libutils - extern uint32_t kern_read(const void *addr); - extern void kern_write(void *addr, uint32_t value); +// Part of libutils +extern uint32_t kern_read(const void *addr); +extern void kern_write(void *addr, uint32_t value); #ifdef __cplusplus } #endif @@ -54,7 +54,7 @@ void CallHookEx(wups_loader_hook_type_t hook_type, int32_t plugin_index_needed) continue; } - #warning TODO: change the order of the wups_loader_hook_type_t enum before an offical release. +#warning TODO: change the order of the wups_loader_hook_type_t enum before an offical release. //DEBUG_FUNCTION_LINE("Checking hook functions for %s.\n",plugin_data->plugin_name); //DEBUG_FUNCTION_LINE("Found hooks: %d\n",plugin_data->number_used_hooks); for(int32_t j=0; jnumber_used_hooks; j++) { @@ -99,7 +99,7 @@ void CallHookEx(wups_loader_hook_type_t hook_type, int32_t plugin_index_needed) if(gSDInitDone & WUPS_USB_MOUNTED) { args.usb_mounted = true; } - if(plugin_data->kernel_allowed && plugin_data->kernel_init_done){ + if(plugin_data->kernel_allowed && plugin_data->kernel_init_done) { args.kernel_access = true; } ((void (*)(wups_loader_app_started_args_t))((uint32_t*)func_ptr) )(args); @@ -121,9 +121,9 @@ void CallHookEx(wups_loader_hook_type_t hook_type, int32_t plugin_index_needed) status = WUPS_APP_STATUS_UNKNOWN; } ((void (*)(wups_loader_app_status_t))((uint32_t*)func_ptr))(status); - } else if(hook_type == WUPS_LOADER_HOOK_INIT_KERNEL){ + } else if(hook_type == WUPS_LOADER_HOOK_INIT_KERNEL) { // Only call the hook if kernel is allowed. - if(plugin_data->kernel_allowed){ + if(plugin_data->kernel_allowed) { wups_loader_init_kernel_args_t args; args.kern_read_ptr = &kern_read; args.kern_write_ptr = &kern_write;