diff --git a/.gitignore b/.gitignore
index c158858bc..d88d778a2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,6 +5,7 @@
*.3dsx
*.cia
*.nds
+*.dsi
*.elf
*.smdh
*.bin
@@ -13,4 +14,4 @@ nds/build/sprites.h
*.t3x
*.tdx
*.DS_Store
-*.vscode
\ No newline at end of file
+*.vscode
diff --git a/3ds/Universal-Core b/3ds/Universal-Core
index 4e141e645..1e77f6c8e 160000
--- a/3ds/Universal-Core
+++ b/3ds/Universal-Core
@@ -1 +1 @@
-Subproject commit 4e141e64524478291235a24865a4a7f818803846
+Subproject commit 1e77f6c8e0517a2b5d9cb1ced977df9c23fbc70f
diff --git a/include/3ds/Platform.hpp b/include/3ds/Platform.hpp
new file mode 100644
index 000000000..16160d7e5
--- /dev/null
+++ b/include/3ds/Platform.hpp
@@ -0,0 +1,79 @@
+/*
+* This file is part of Universal-Updater
+* Copyright (C) 2019-2021 Universal-Team
+*
+* This program is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see .
+*
+* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
+* * Requiring preservation of specified reasonable legal notices or
+* author attributions in that material or in the Appropriate Legal
+* Notices displayed by works containing it.
+* * Prohibiting misrepresentation of the origin of that material,
+* or requiring that modified versions of such material be marked in
+* reasonable ways as different from the original version.
+*/
+
+#ifndef _PLATFORM_3DS_HPP
+#define _PLATFORM_3DS_HPP
+
+#include <3ds.h>
+
+/* Include Definitions for Universal-Updater here. */
+#define CONFIG_PATH "sdmc:/3ds/Universal-Updater/Config.json"
+#define _STORE_PATH "sdmc:/3ds/Universal-Updater/stores/"
+#define _SHORTCUT_PATH "sdmc:/3ds/Universal-Updater/shortcuts/"
+#define THEME_JSON "sdmc:/3ds/Universal-Updater/Themes.json"
+
+#define SHEET_PATH_KEY "sheet"
+#define SHEET_URL_KEY "sheetURL"
+
+/* Meta data related things. */
+#define _META_PATH "sdmc:/3ds/Universal-Updater/MetaData.json"
+#define _OLD_UPDATE_PATH "sdmc:/3ds/Universal-Updater/updates.json"
+
+#define DEFAULT_BASE_URL "https://github.com/Universal-Team/db/raw/master/docs/unistore/"
+#define DEFAULT_UNISTORE_NAME "universal-db.unistore"
+#define DEFAULT_SPRITESHEET_NAME "universal-db.t3x"
+#define DEFAULT_UNISTORE (DEFAULT_BASE_URL DEFAULT_UNISTORE_NAME)
+#define DEFAULT_SPRITESHEET (DEFAULT_BASE_URL DEFAULT_SPRITESHEET_NAME)
+
+typedef Thread ThreadPtr;
+
+namespace Platform {
+ inline void ScanKeys(void) { return hidScanInput(); }
+ inline u32 KeysDown(void) { return hidKeysDown(); }
+ inline u32 KeysDownRepeat(void) { return hidKeysDownRepeat(); }
+ inline void TouchRead(touchPosition *data) { hidTouchRead(data); }
+
+ inline bool MainLoop() { return aptMainLoop(); }
+ inline void waitForVBlank(void) { return gspWaitForVBlank(); }
+ inline void AllowExit(bool allow) { return aptSetHomeAllowed(allow); }
+
+ inline int ThreadJoin(ThreadPtr t, u64 timeout_ns) { return threadJoin(t, timeout_ns); }
+ inline ThreadPtr CreateThread(ThreadFunc entrypoint) {
+ int32_t Prio = 0;
+ svcGetThreadPriority(&Prio, CUR_THREAD_HANDLE);
+ return threadCreate(entrypoint, NULL, 64 * 1024, Prio - 1, -2, false);
+ }
+
+ void Initialize(char *ARGV[]);
+ void Exit(void);
+
+ namespace WiFi {
+ inline void Init(void) { /* NOP */ };
+ bool Connected(void);
+ }
+};
+
+#endif
diff --git a/include/3ds/data/GFXData.hpp b/include/3ds/data/GFXData.hpp
index 853fdbd2a..a87a53ec1 100644
--- a/include/3ds/data/GFXData.hpp
+++ b/include/3ds/data/GFXData.hpp
@@ -71,6 +71,8 @@ class GFXData {
/* UniStore Sprite Handler. */
void LoadUniStoreSheet(const std::string &SheetFile);
void UnloadUniStoreSheets();
+ inline void UpdateUniStoreSprites() { /* NOP */ }
+ inline void HideUniStoreSprites() { /* NOP */ }
void DrawUniStoreIcons(const std::vector> &Indexes);
void DrawBox(const int XPos, const int YPos, const int Width = 50, const int Height = 50, const bool Selected = false);
diff --git a/include/Common.hpp b/include/Common.hpp
deleted file mode 100644
index 38aecac02..000000000
--- a/include/Common.hpp
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
-* This file is part of Universal-Updater
-* Copyright (C) 2019-2021 Universal-Team
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see .
-*
-* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
-* * Requiring preservation of specified reasonable legal notices or
-* author attributions in that material or in the Appropriate Legal
-* Notices displayed by works containing it.
-* * Prohibiting misrepresentation of the origin of that material,
-* or requiring that modified versions of such material be marked in
-* reasonable ways as different from the original version.
-*/
-
-#ifndef _UNIVERSAL_UPDATER_COMMON_HPP
-#define _UNIVERSAL_UPDATER_COMMON_HPP
-
-#include "UniversalUpdater.hpp"
-
-#endif
\ No newline at end of file
diff --git a/include/3ds/UniversalUpdater.hpp b/include/UniversalUpdater.hpp
similarity index 79%
rename from include/3ds/UniversalUpdater.hpp
rename to include/UniversalUpdater.hpp
index e8736f775..a1c9eddf7 100644
--- a/include/3ds/UniversalUpdater.hpp
+++ b/include/UniversalUpdater.hpp
@@ -31,8 +31,6 @@
#include "GFXData.hpp"
#include "Meta.hpp"
#include "MSGData.hpp"
-#include "screenCommon.hpp"
-#include "structs.hpp"
#include "ThemeData.hpp"
#include "UniStore.hpp"
@@ -42,33 +40,17 @@
#include "TopList.hpp"
#include "UniStoreSelector.hpp"
-
-#include <3ds.h>
-#include
-#include
-
-
-/* Include Definitions for Universal-Updater here. */
-#define CONFIG_PATH "sdmc:/3ds/Universal-Updater/Config.json"
-#define _STORE_PATH "sdmc:/3ds/Universal-Updater/stores/"
-#define THEME_JSON "sdmc:/3ds/Universal-Updater/Themes.json"
-
-#define SHEET_PATH_KEY "sheet"
-#define SHEET_URL_KEY "sheetURL"
-
-/* Meta data related things. */
-#define _META_PATH "sdmc:/3ds/Universal-Updater/MetaData.json"
-#define _OLD_UPDATE_PATH "sdmc:/3ds/Universal-Updater/updates.json"
-
-
class UU {
+ std::unique_ptr TGrid = nullptr;
+ std::unique_ptr TList = nullptr;
+
public:
enum class TopMode : uint8_t { Grid = 0, List };
- void Initialize();
+ void Initialize(char *ARGV[]);
void ScanInput();
void Draw();
- int Handler();
+ int Handler(char *ARGV[]);
void SwitchTopMode(const UU::TopMode TMode);
@@ -86,9 +68,6 @@ class UU {
touchPosition T = { 0, 0 };
bool Exiting = false;
TopMode TMode = TopMode::Grid;
-private:
- std::unique_ptr TGrid = nullptr;
- std::unique_ptr TList = nullptr;
};
#endif
\ No newline at end of file
diff --git a/include/menus/tabs/QueueMenu.hpp b/include/menus/tabs/QueueMenu.hpp
index 551635a41..7b4240d5b 100644
--- a/include/menus/tabs/QueueMenu.hpp
+++ b/include/menus/tabs/QueueMenu.hpp
@@ -29,6 +29,8 @@
#include "structs.hpp"
+#include
+
class QueueMenu {
public:
diff --git a/include/menus/tabs/Tabs.hpp b/include/menus/tabs/Tabs.hpp
index c5580f9fe..65c9800db 100644
--- a/include/menus/tabs/Tabs.hpp
+++ b/include/menus/tabs/Tabs.hpp
@@ -35,6 +35,7 @@
#include "QueueMenu.hpp"
#include "structs.hpp"
+#include
class Tabs {
public:
diff --git a/include/nds/UniversalUpdater.hpp b/include/nds/Platform.hpp
similarity index 57%
rename from include/nds/UniversalUpdater.hpp
rename to include/nds/Platform.hpp
index 79220ca38..63b0c8c0d 100644
--- a/include/nds/UniversalUpdater.hpp
+++ b/include/nds/Platform.hpp
@@ -24,33 +24,15 @@
* reasonable ways as different from the original version.
*/
-#ifndef _UNIVERSAL_UPDATER_HPP
-#define _UNIVERSAL_UPDATER_HPP
+#ifndef _PLATFORM_NDS_HPP
+#define _PLATFORM_NDS_HPP
-#include "ConfigData.hpp"
-#include "font.hpp"
-#include "GFXData.hpp"
-#include "Meta.hpp"
-#include "MSGData.hpp"
-#include "structs.hpp"
-#include "ThemeData.hpp"
-#include "UniStore.hpp"
-
-/* Menus. */
-#include "Tabs.hpp"
-#include "TopGrid.hpp"
-#include "TopList.hpp"
-#include "UniStoreSelector.hpp"
-
-
-#include
#include
-#include
-
/* Include Definitions for Universal-Updater here. */
#define CONFIG_PATH "/_nds/Universal-Updater/Config.json"
#define _STORE_PATH "/_nds/Universal-Updater/stores/"
+#define _SHORTCUT_PATH "/_nds/Universal-Updater/shortcuts/"
#define THEME_JSON "/_nds/Universal-Updater/Themes.json"
#define SHEET_PATH_KEY "dsSheet"
@@ -60,39 +42,38 @@
#define _META_PATH "/_nds/Universal-Updater/MetaData.json"
#define _OLD_UPDATE_PATH "/_nds/Universal-Updater/updates.json" // Technically not needed.
+#define DEFAULT_BASE_URL "https://github.com/Universal-Team/db/raw/master/docs/unistore/"
+#define DEFAULT_UNISTORE_NAME "universal-db.unistore"
+#define DEFAULT_SPRITESHEET_NAME "universal-db.tdx"
+#define DEFAULT_UNISTORE (DEFAULT_BASE_URL DEFAULT_UNISTORE_NAME)
+#define DEFAULT_SPRITESHEET (DEFAULT_BASE_URL DEFAULT_SPRITESHEET_NAME)
-class UU {
- static void VBlankHandler(void);
+typedef Thread *ThreadPtr;
- std::unique_ptr TGrid = nullptr;
- std::unique_ptr TList = nullptr;
+namespace Platform {
+ inline void ScanKeys(void) { return scanKeys(); }
+ inline u32 KeysDown(void) { return keysDown(); }
+ inline u32 KeysDownRepeat(void) { return keysDownRepeat(); }
+ inline void TouchRead(touchPosition *data) {
+ touchRead(data);
+ data->px = data->px * 5 / 4;
+ data->py = data->py * 5 / 4;
+ }
- static int QueueMenuRefresh;
+ inline bool MainLoop() {return pmMainLoop(); }
+ inline void waitForVBlank(void) { return threadWaitForVBlank(); }
+ inline void AllowExit(bool allow) { (void)allow; /* NOP */ }
-public:
- enum class TopMode : uint8_t { Grid = 0, List };
- void Initialize(char *ARGV[]);
- void ScanInput();
-
- void Draw();
- int Handler(char *ARGV[]);
+ inline int ThreadJoin(ThreadPtr t, u64 timeout_ns) { (void)timeout_ns; return threadJoin(t); }
+ ThreadPtr CreateThread(ThreadFunc entrypoint);
- void SwitchTopMode(const UU::TopMode TMode);
-
- static std::unique_ptr App;
- std::unique_ptr CData = nullptr;
- std::unique_ptr GData = nullptr;
- std::unique_ptr MData = nullptr;
- std::unique_ptr MSData = nullptr;
- std::unique_ptr Store = nullptr;
- std::unique_ptr _Tabs = nullptr;
- std::unique_ptr TData = nullptr; // TODO: Find a good way to handle the active theme through defines.
- std::unique_ptr USelector = nullptr;
+ void Initialize(char *ARGV[]);
+ inline void Exit() { /* NOP */ }
- uint32_t Down = 0, Repeat = 0;
- touchPosition T = { 0, 0 };
- bool Exiting = false;
- TopMode TMode = TopMode::Grid;
-};
+ namespace WiFi {
+ void Init(void);
+ bool Connected(void);
+ }
+}
-#endif
\ No newline at end of file
+#endif
diff --git a/include/nds/utils/WiFi.hpp b/include/nds/utils/WiFi.hpp
deleted file mode 100644
index 7eaed9dc2..000000000
--- a/include/nds/utils/WiFi.hpp
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
-* This file is part of Universal-Updater
-* Copyright (C) 2019-2021 Universal-Team
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see .
-*
-* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
-* * Requiring preservation of specified reasonable legal notices or
-* author attributions in that material or in the Appropriate Legal
-* Notices displayed by works containing it.
-* * Prohibiting misrepresentation of the origin of that material,
-* or requiring that modified versions of such material be marked in
-* reasonable ways as different from the original version.
-*/
-
-#ifndef _UNIVERSAL_UPDATER_WIFI_HPP
-#define _UNIVERSAL_UPDATER_WIFI_HPP
-
-#include
-
-class WiFi {
-public:
- static void Init(void);
-
- static bool Connected(void);
-};
-
-#endif
diff --git a/include/utils/DownloadUtils.hpp b/include/utils/DownloadUtils.hpp
index c03f8b4b1..700eb7d06 100644
--- a/include/utils/DownloadUtils.hpp
+++ b/include/utils/DownloadUtils.hpp
@@ -36,8 +36,6 @@ namespace DownloadUtils {
curl_off_t Speed();
curl_off_t CurrentProgress();
curl_off_t TotalSize();
-
- bool WiFiAvailable();
};
#endif
\ No newline at end of file
diff --git a/nds/Universal-Core b/nds/Universal-Core
index 2c19aa06c..d471c390a 160000
--- a/nds/Universal-Core
+++ b/nds/Universal-Core
@@ -1 +1 @@
-Subproject commit 2c19aa06c5f2e4af90a95de17bcf010ee8a7c6aa
+Subproject commit d471c390ae5da056e98d0723f2b21e2f47fecaad
diff --git a/nds/Universal-Updater.dsi b/nds/Universal-Updater.dsi
deleted file mode 100644
index 39dc6f69e..000000000
Binary files a/nds/Universal-Updater.dsi and /dev/null differ
diff --git a/nds/build/version.hpp b/nds/build/version.hpp
index 9e1d7eafb..fdd8973bb 100644
--- a/nds/build/version.hpp
+++ b/nds/build/version.hpp
@@ -1,6 +1,6 @@
#ifndef VERSION_HPP
#define VERSION_HPP
-#define VER_NUMBER "-07ac62d"
+#define VER_NUMBER "-ddfd63e"
#endif
diff --git a/source/nds/utils/WiFi.cpp b/source/3ds/Platform.cpp
similarity index 68%
rename from source/nds/utils/WiFi.cpp
rename to source/3ds/Platform.cpp
index 6ba1caed0..dfcba3ac5 100644
--- a/source/nds/utils/WiFi.cpp
+++ b/source/3ds/Platform.cpp
@@ -24,15 +24,39 @@
* reasonable ways as different from the original version.
*/
-#include "WiFi.hpp"
-#include
+#include "Platform.hpp"
+#include "gui.hpp"
+#include "Utils.hpp"
-void WiFi::Init() {
- Wifi_InitDefault(true);
+#include
+
+
+/*
+ Initialize everything as needed.
+*/
+void Platform::Initialize(char *ARGV[]) {
+ (void)ARGV;
+
+ romfsInit();
+ gfxInitDefault();
+ Gui::init();
+ acInit();
+ hidSetRepeatParameters(20, 8);
+ osSetSpeedupEnable(true); // Enable speed-up for New 3DS users.
+};
+
+void Platform::Exit() {
+ acExit();
+ Gui::exit();
+ gfxExit();
+ romfsExit();
}
-bool WiFi::Connected() {
- return Wifi_AssocStatus() == ASSOCSTATUS_ASSOCIATED;
+bool Platform::WiFi::Connected() {
+ // return true; // For Citra
+
+ uint32_t WifiStatus;
+ return R_SUCCEEDED(ACU_GetWifiStatus(&WifiStatus)) && WifiStatus;
}
diff --git a/source/3ds/data/GFXData.cpp b/source/3ds/data/GFXData.cpp
index 3de4ca2c7..2e001a01e 100644
--- a/source/3ds/data/GFXData.cpp
+++ b/source/3ds/data/GFXData.cpp
@@ -24,8 +24,10 @@
* reasonable ways as different from the original version.
*/
-#include "Common.hpp"
#include "GFXData.hpp"
+
+#include "gui.hpp"
+#include "UniversalUpdater.hpp"
#include
@@ -37,8 +39,8 @@ GFXData::~GFXData() { Gui::unloadSheet(this->Sprites); };
void GFXData::StartFrame() {
Gui::clearTextBufs();
- C2D_TargetClear(Top, C2D_Color32(0, 0, 0, 0));
- C2D_TargetClear(Bottom, C2D_Color32(0, 0, 0, 0));
+ C2D_TargetClear(ScreenTop, C2D_Color32(0, 0, 0, 0));
+ C2D_TargetClear(ScreenBottom, C2D_Color32(0, 0, 0, 0));
C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
};
@@ -47,7 +49,7 @@ void GFXData::EndFrame() { C3D_FrameEnd(0); };
void GFXData::DrawTop() {
- Gui::ScreenDraw(Top);
+ Gui::ScreenDraw(ScreenTop);
Gui::Draw_Rect(0, 0, 400, 25, BAR_COLOR);
Gui::Draw_Rect(0, 26, 400, 214, BG_COLOR);
Gui::Draw_Rect(0, 25, 400, 1, BAR_OUTLINE);
@@ -55,7 +57,7 @@ void GFXData::DrawTop() {
void GFXData::DrawBottom() {
- Gui::ScreenDraw(Bottom);
+ Gui::ScreenDraw(ScreenBottom);
Gui::Draw_Rect(0, 0, 320, 240, BG_COLOR);
};
diff --git a/source/3ds/data/MSGData.cpp b/source/3ds/data/MSGData.cpp
index 33c394b78..b2625fd98 100644
--- a/source/3ds/data/MSGData.cpp
+++ b/source/3ds/data/MSGData.cpp
@@ -24,9 +24,11 @@
* reasonable ways as different from the original version.
*/
-#include "Common.hpp"
#include "MSGData.hpp"
+#include "gui.hpp"
+#include "UniversalUpdater.hpp"
+
void MSGData::DisplayWaitMsg(const std::string &MSG) {
UU::App->GData->StartFrame();
diff --git a/source/Main.cpp b/source/Main.cpp
index 8992549cb..9f5fd6ecf 100644
--- a/source/Main.cpp
+++ b/source/Main.cpp
@@ -31,11 +31,5 @@ std::unique_ptr UU::App = nullptr;
int main(int ARGC, char *ARGV[]) {
UU::App = std::make_unique();
-
- #ifdef __NDS__
- return UU::App->Handler(ARGV);
-
- #else
- return UU::App->Handler();
- #endif
+ return UU::App->Handler(ARGV);
};
\ No newline at end of file
diff --git a/source/3ds/UniversalUpdater.cpp b/source/UniversalUpdater.cpp
similarity index 73%
rename from source/3ds/UniversalUpdater.cpp
rename to source/UniversalUpdater.cpp
index 98e02dc68..fd2c7fa6e 100644
--- a/source/3ds/UniversalUpdater.cpp
+++ b/source/UniversalUpdater.cpp
@@ -24,31 +24,24 @@
* reasonable ways as different from the original version.
*/
+#include "UniversalUpdater.hpp"
#include "DownloadFile.hpp"
#include "DownloadUtils.hpp"
-#include "UniversalUpdater.hpp"
-#include
-#include
-
+#include "gui.hpp"
+#include "Platform.hpp"
+#include "Utils.hpp"
/*
Initialize everything as needed.
*/
-void UU::Initialize() {
- romfsInit();
- gfxInitDefault();
- Gui::init();
- acInit();
- hidSetRepeatParameters(20, 8);
- osSetSpeedupEnable(true); // Enable speed-up for New 3DS users.
+void UU::Initialize(char *ARGV[]) {
+ Platform::Initialize(ARGV);
/* Create Directories. */
- mkdir("sdmc:/3ds", 0777);
- mkdir("sdmc:/3ds/Universal-Updater", 0777);
- mkdir("sdmc:/3ds/Universal-Updater/stores", 0777);
- mkdir("sdmc:/3ds/Universal-Updater/shortcuts", 0777);
-
+ Utils::MakeDirs(_STORE_PATH);
+ Utils::MakeDirs(_SHORTCUT_PATH);
+
/* Load classes. */
this->GData = std::make_unique();
this->CData = std::make_unique();
@@ -57,25 +50,36 @@ void UU::Initialize() {
this->MSData = std::make_unique();
this->USelector = std::make_unique();
+ /* Initialize Wi-Fi. */
+ this->GData->StartFrame();
+ this->GData->DrawTop();
+ Gui::DrawStringCentered(0, 3, TEXT_LARGE, TEXT_COLOR, "Connecting to Wi-Fi...");
+ this->GData->DrawBottom();
+ this->GData->EndFrame();
+
+ Platform::WiFi::Init();
+ while(!Platform::WiFi::Connected()) {
+ Platform::waitForVBlank();
+ }
+
this->MSData->DisplayWaitMsg("Checking UniStore...");
/* Check if LastStore is accessible. */
if (this->CData->LastStore() == "" || access((_STORE_PATH + this->CData->LastStore()).c_str(), F_OK) != 0) {
if (access(_STORE_PATH "universal-db.unistore", F_OK) != 0) {
- if (DownloadUtils::WiFiAvailable()) {
- std::unique_ptr DL = std::make_unique("https://db.universal-team.net/unistore/universal-db.unistore", _STORE_PATH "universal-db.unistore");
- this->MSData->DisplayWaitMsg("Downloading universal-db.unistore...");
+ if (Platform::WiFi::Connected()) {
+ std::unique_ptr DL = std::make_unique(DEFAULT_UNISTORE, _STORE_PATH DEFAULT_UNISTORE_NAME);
+ this->MSData->DisplayWaitMsg("Downloading " DEFAULT_UNISTORE_NAME "...");
DL->Handler();
DL = nullptr;
- DL = std::make_unique("https://db.universal-team.net/unistore/universal-db.t3x", _STORE_PATH "universal-db.t3x");
- this->MSData->DisplayWaitMsg("Downloading universal-db.t3x...");
+ DL = std::make_unique(DEFAULT_SPRITESHEET, _STORE_PATH DEFAULT_SPRITESHEET_NAME);
+ this->MSData->DisplayWaitMsg("Downloading " DEFAULT_SPRITESHEET_NAME "...");
DL->Handler();
}
-
- } else {
- this->CData->LastStore("universal-db.unistore");
}
+
+ this->CData->LastStore(DEFAULT_UNISTORE_NAME);
}
this->Store = std::make_unique(this->CData->LastStore());
@@ -83,6 +87,7 @@ void UU::Initialize() {
this->_Tabs = std::make_unique();
this->TGrid = std::make_unique();
this->TList = std::make_unique();
+ this->GData->UpdateUniStoreSprites();
};
@@ -90,10 +95,10 @@ void UU::Initialize() {
Scan the key input.
*/
void UU::ScanInput() {
- hidScanInput();
- this->Down = hidKeysDown();
- this->Repeat = hidKeysDownRepeat();
- hidTouchRead(&this->T);
+ Platform::ScanKeys();
+ this->Down = Platform::KeysDown();
+ this->Repeat = Platform::KeysDownRepeat();
+ Platform::TouchRead(&this->T);
};
@@ -128,8 +133,10 @@ void UU::Draw() {
}
this->GData->DrawBottom();
+
if (!this->USelector->Done) this->USelector->DrawBottom();
else this->_Tabs->DrawBottom();
+
this->GData->EndFrame();
};
@@ -137,11 +144,13 @@ void UU::Draw() {
/*
Main Handler of the app. Handle Input and display stuff here.
*/
-int UU::Handler() {
- this->Initialize();
+int UU::Handler(char *ARGV[]) {
+ this->Initialize(ARGV);
+ this->Draw(); // TODO: Maybe remove
- while(aptMainLoop() && !this->Exiting) {
- this->Draw();
+ while(Platform::MainLoop() && !this->Exiting) {
+ if(UU::App->Repeat) this->Draw(); // TODO: Draw every time
+ Platform::waitForVBlank();
this->ScanInput();
if (!this->USelector->Done) this->USelector->Handler();
@@ -164,10 +173,8 @@ int UU::Handler() {
}
this->CData->Sav();
- acExit();
- Gui::exit();
- gfxExit();
- romfsExit();
+
+ Platform::Exit();
return 0;
};
@@ -185,4 +192,6 @@ void UU::SwitchTopMode(const UU::TopMode TMode) {
this->TList->Update();
break;
}
+
+ this->GData->UpdateUniStoreSprites();
};
\ No newline at end of file
diff --git a/source/actions/Copying.cpp b/source/actions/Copying.cpp
index f98b142fa..0b1166bd1 100644
--- a/source/actions/Copying.cpp
+++ b/source/actions/Copying.cpp
@@ -25,7 +25,9 @@
*/
#include "Copying.hpp"
+
#include "Utils.hpp"
+
#include
#include
diff --git a/source/actions/Deleting.cpp b/source/actions/Deleting.cpp
index bd656cbc9..94e90ee3b 100644
--- a/source/actions/Deleting.cpp
+++ b/source/actions/Deleting.cpp
@@ -25,6 +25,7 @@
*/
#include "Deleting.hpp"
+
#include
diff --git a/source/actions/DownloadFile.cpp b/source/actions/DownloadFile.cpp
index 7577df9da..fccea115a 100644
--- a/source/actions/DownloadFile.cpp
+++ b/source/actions/DownloadFile.cpp
@@ -25,6 +25,7 @@
*/
#include "DownloadFile.hpp"
+
#include "DownloadUtils.hpp"
#include "GFXData.hpp"
#include "gui.hpp"
@@ -32,6 +33,7 @@
#include "QueueSystem.hpp"
#include "UniversalUpdater.hpp"
#include "Utils.hpp"
+
#include
@@ -41,7 +43,7 @@
void DownloadFile::Handler() {
Utils::MakeDirs(this->Path);
- const int Res = DownloadUtils::DownloadToFile(this->URL.c_str(), this->Path.c_str());
+ DownloadUtils::DownloadToFile(this->URL.c_str(), this->Path.c_str());
this->Done = true;
};
diff --git a/source/actions/DownloadRelease.cpp b/source/actions/DownloadRelease.cpp
index efd446191..874fc0737 100644
--- a/source/actions/DownloadRelease.cpp
+++ b/source/actions/DownloadRelease.cpp
@@ -25,11 +25,14 @@
*/
#include "DownloadRelease.hpp"
+
+#include "gui.hpp"
#include "JSON.hpp"
#include "QueueMenu.hpp"
#include "QueueSystem.hpp"
#include "UniversalUpdater.hpp"
#include "Utils.hpp"
+
#include
diff --git a/source/actions/Extracting.cpp b/source/actions/Extracting.cpp
index 2528383b2..5bdccb5d1 100644
--- a/source/actions/Extracting.cpp
+++ b/source/actions/Extracting.cpp
@@ -25,7 +25,9 @@
*/
#include "Extracting.hpp"
+
#include "Utils.hpp"
+
#include
#include
#include
diff --git a/source/actions/Moving.cpp b/source/actions/Moving.cpp
index f45178c7a..22ab1e79b 100644
--- a/source/actions/Moving.cpp
+++ b/source/actions/Moving.cpp
@@ -25,7 +25,9 @@
*/
#include "Moving.hpp"
+
#include "Utils.hpp"
+
#include
diff --git a/source/data/ConfigData.cpp b/source/data/ConfigData.cpp
index e7bfa3534..eab7a9d06 100644
--- a/source/data/ConfigData.cpp
+++ b/source/data/ConfigData.cpp
@@ -24,8 +24,11 @@
* reasonable ways as different from the original version.
*/
-#include "Common.hpp"
#include "ConfigData.hpp"
+
+#include "Platform.hpp"
+#include "UniversalUpdater.hpp"
+
#include
diff --git a/source/data/ThemeData.cpp b/source/data/ThemeData.cpp
index db71c42e6..1bc7fa1cd 100644
--- a/source/data/ThemeData.cpp
+++ b/source/data/ThemeData.cpp
@@ -24,8 +24,11 @@
* reasonable ways as different from the original version.
*/
-#include "Common.hpp"
#include "ThemeData.hpp"
+
+#include "Platform.hpp"
+// #include "UniversalUpdater.hpp"
+
#include
#include
diff --git a/source/menus/TopGrid.cpp b/source/menus/TopGrid.cpp
index 4b320484b..34c9bc489 100644
--- a/source/menus/TopGrid.cpp
+++ b/source/menus/TopGrid.cpp
@@ -24,9 +24,10 @@
* reasonable ways as different from the original version.
*/
-#include "Common.hpp"
#include "TopGrid.hpp"
+#include "UniversalUpdater.hpp"
+
void TopGrid::Draw() {
std::vector> Indexes;
diff --git a/source/menus/TopList.cpp b/source/menus/TopList.cpp
index 942a44317..aefa33c9a 100644
--- a/source/menus/TopList.cpp
+++ b/source/menus/TopList.cpp
@@ -24,8 +24,10 @@
* reasonable ways as different from the original version.
*/
-#include "Common.hpp"
#include "TopList.hpp"
+
+#include "gui.hpp"
+#include "UniversalUpdater.hpp"
#include "Utils.hpp"
diff --git a/source/menus/UniStoreSelector.cpp b/source/menus/UniStoreSelector.cpp
index 9463aafe2..a83fc8ef8 100644
--- a/source/menus/UniStoreSelector.cpp
+++ b/source/menus/UniStoreSelector.cpp
@@ -24,9 +24,13 @@
* reasonable ways as different from the original version.
*/
-#include "Common.hpp"
#include "UniStoreSelector.hpp"
+
+#include "gui.hpp"
+#include "Platform.hpp"
+#include "UniversalUpdater.hpp"
#include "Utils.hpp"
+
#include
@@ -35,9 +39,7 @@ void UniStoreSelector::InitSelector() {
this->ScreenIndex = 0, this->SelectedIndex = 0;
this->Done = false;
- #ifdef __NDS__
- UU::App->GData->HideUniStoreSprites(); // Hide the Sprites on the NDS version -- no need to on the 3DS version.
- #endif
+ UU::App->GData->HideUniStoreSprites(); // Hide the Sprites on the NDS version -- no need to on the 3DS version.
};
@@ -247,8 +249,6 @@ void UniStoreSelector::Handler() {
}
if (this->Done) {
- #ifdef __NDS__
- UU::App->GData->UpdateUniStoreSprites(); // Display the sprites again on the NDS version.
- #endif
+ UU::App->GData->UpdateUniStoreSprites(); // Display the sprites again on the NDS version.
}
};
\ No newline at end of file
diff --git a/source/menus/tabs/DownList.cpp b/source/menus/tabs/DownList.cpp
index dc2fdbbfc..b35a0445f 100644
--- a/source/menus/tabs/DownList.cpp
+++ b/source/menus/tabs/DownList.cpp
@@ -24,9 +24,11 @@
* reasonable ways as different from the original version.
*/
-#include "Common.hpp"
#include "DownList.hpp"
+
+#include "gui.hpp"
#include "QueueSystem.hpp"
+#include "UniversalUpdater.hpp"
#include "Utils.hpp"
#define DOWNLOAD_ENTRIES 7
diff --git a/source/menus/tabs/EntryInfo.cpp b/source/menus/tabs/EntryInfo.cpp
index 5b81aa619..375b9c42e 100644
--- a/source/menus/tabs/EntryInfo.cpp
+++ b/source/menus/tabs/EntryInfo.cpp
@@ -24,8 +24,10 @@
* reasonable ways as different from the original version.
*/
-#include "Common.hpp"
#include "EntryInfo.hpp"
+
+#include "gui.hpp"
+#include "UniversalUpdater.hpp"
#include "Utils.hpp"
diff --git a/source/menus/tabs/QueueMenu.cpp b/source/menus/tabs/QueueMenu.cpp
index d86912d27..76ab4a9c0 100644
--- a/source/menus/tabs/QueueMenu.cpp
+++ b/source/menus/tabs/QueueMenu.cpp
@@ -24,8 +24,10 @@
* reasonable ways as different from the original version.
*/
-#include "Common.hpp"
#include "QueueMenu.hpp"
+
+#include "GFXData.hpp"
+#include "gui.hpp"
#include "QueueSystem.hpp"
#include "Utils.hpp"
diff --git a/source/menus/tabs/SearchMenu.cpp b/source/menus/tabs/SearchMenu.cpp
index ee5283399..5c75ca8b7 100644
--- a/source/menus/tabs/SearchMenu.cpp
+++ b/source/menus/tabs/SearchMenu.cpp
@@ -24,9 +24,11 @@
* reasonable ways as different from the original version.
*/
-#include "Common.hpp"
-#include "keyboard.hpp"
#include "SearchMenu.hpp"
+
+#include "gui.hpp"
+#include "keyboard.hpp"
+#include "UniversalUpdater.hpp"
#include "Utils.hpp"
diff --git a/source/menus/tabs/SettingsMenu.cpp b/source/menus/tabs/SettingsMenu.cpp
index 97ed736f7..10709f2af 100644
--- a/source/menus/tabs/SettingsMenu.cpp
+++ b/source/menus/tabs/SettingsMenu.cpp
@@ -24,10 +24,12 @@
* reasonable ways as different from the original version.
*/
-#include "Common.hpp"
-#include "QueueSystem.hpp"
#include "SettingsMenu.hpp"
+
+#include "gui.hpp"
+#include "QueueSystem.hpp"
#include "UniStoreSelector.hpp"
+#include "UniversalUpdater.hpp"
#include "Utils.hpp"
diff --git a/source/menus/tabs/SortMenu.cpp b/source/menus/tabs/SortMenu.cpp
index b16fcf7f3..769659369 100644
--- a/source/menus/tabs/SortMenu.cpp
+++ b/source/menus/tabs/SortMenu.cpp
@@ -24,8 +24,10 @@
* reasonable ways as different from the original version.
*/
-#include "Common.hpp"
#include "SortMenu.hpp"
+
+#include "gui.hpp"
+#include "UniversalUpdater.hpp"
#include "Utils.hpp"
diff --git a/source/menus/tabs/Tabs.cpp b/source/menus/tabs/Tabs.cpp
index 6c2a81cab..91f59838b 100644
--- a/source/menus/tabs/Tabs.cpp
+++ b/source/menus/tabs/Tabs.cpp
@@ -24,10 +24,12 @@
* reasonable ways as different from the original version.
*/
-#include "Common.hpp"
-#include "QueueSystem.hpp"
#include "Tabs.hpp"
+#include "gui.hpp"
+#include "QueueSystem.hpp"
+#include "UniversalUpdater.hpp"
+
/* Init Tab components. */
Tabs::Tabs() {
diff --git a/source/nds/Platform.cpp b/source/nds/Platform.cpp
new file mode 100644
index 000000000..e887130b8
--- /dev/null
+++ b/source/nds/Platform.cpp
@@ -0,0 +1,96 @@
+/*
+* This file is part of Universal-Updater
+* Copyright (C) 2019-2021 Universal-Team
+*
+* This program is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see .
+*
+* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
+* * Requiring preservation of specified reasonable legal notices or
+* author attributions in that material or in the Appropriate Legal
+* Notices displayed by works containing it.
+* * Prohibiting misrepresentation of the origin of that material,
+* or requiring that modified versions of such material be marked in
+* reasonable ways as different from the original version.
+*/
+
+#include "Platform.hpp"
+
+#include "gui.hpp"
+#include "nitrofs.h"
+#include "tonccpy.h"
+
+#include
+#include
+
+// TODO: This is kinda terrible! Only one non-main thread at a time!
+Thread thread;
+#define THREAD_STACK_SIZE 64 * 1024
+alignas(8) u8 threadStack[THREAD_STACK_SIZE];
+u8 *stackEnd = &threadStack[THREAD_STACK_SIZE];
+
+void Platform::Initialize(char *ARGV[]) {
+ keysSetRepeat(20, 8);
+
+ if (!fatInitDefault()) {
+ consoleDemoInit();
+ iprintf("FAT init failed!\n");
+ while (pmMainLoop()) swiWaitForVBlank();
+ }
+
+ /* Try init NitroFS at a few likely locations. */
+ if (!nitroFSInit(ARGV[0])) {
+ if (!nitroFSInit("Universal-Updater.nds")) {
+ if (!nitroFSInit("/_nds/Universal-Updater/Universal-Updater.nds")) {
+ consoleDemoInit();
+ iprintf("NitroFS init failed!\n\n");
+ iprintf("Copy Universal-Updater.nds to\n\n");
+ iprintf("/_nds/Universal-Updater/\n");
+ iprintf(" Universal-Updater.nds\n");
+ iprintf("or launch using TWiLight Menu++\nor nds-hb-menu.");
+ while (pmMainLoop()) swiWaitForVBlank();
+ }
+ }
+ }
+
+ /* Initialize graphics. */
+ Gui::init(std::array, UNIVCORE_FONT_COUNT>({{
+ {"/_nds/Universal-Updater/large.nftr", "nitro:/graphics/font/large.nftr"},
+ {"/_nds/Universal-Updater/medium.nftr", "nitro:/graphics/font/medium.nftr"},
+ {"/_nds/Universal-Updater/small.nftr", "nitro:/graphics/font/small.nftr"}
+ }}));
+
+ constexpr uint16_t Palette[] = {
+ 0x0000, 0xFFFF, 0xFFFF, 0xFFFF, 0xB126, 0xB126, 0xB126, 0xB126, 0x9883, 0x9883, 0x9883, 0x9883, 0xA4A5, 0xA4A5, 0xA4A5, 0xA4A5,
+ 0xFFFF, 0xB9CE, 0xD6B5, 0xFFFF, 0xCE0D, 0xCE0D, 0xCE0D, 0xCE0D, 0xC189, 0xC189, 0xC189, 0xC189, 0xF735, 0xC1CC, 0xD22E, 0xF735
+ };
+ tonccpy(BG_PALETTE, Palette, sizeof(Palette));
+ tonccpy(BG_PALETTE_SUB, Palette, sizeof(Palette));
+}
+
+ThreadPtr Platform::CreateThread(ThreadFunc entrypoint) {
+ threadPrepare(&thread, entrypoint, NULL, stackEnd, MAIN_THREAD_PRIO + 1);
+ threadStart(&thread);
+
+ return &thread;
+}
+
+void Platform::WiFi::Init() {
+ // Don't initialize Wi-Fi if using no$gba
+ if(strncmp((const char *)0x4FFFA00, "no$gba", 6) != 0)
+ Wifi_InitDefault(true);
+}
+
+bool Platform::WiFi::Connected() {
+ return Wifi_AssocStatus() == ASSOCSTATUS_ASSOCIATED;
+}
diff --git a/source/nds/UniversalUpdater.cpp b/source/nds/UniversalUpdater.cpp
deleted file mode 100644
index bd49d0f72..000000000
--- a/source/nds/UniversalUpdater.cpp
+++ /dev/null
@@ -1,271 +0,0 @@
-/*
-* This file is part of Universal-Updater
-* Copyright (C) 2019-2021 Universal-Team
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see .
-*
-* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
-* * Requiring preservation of specified reasonable legal notices or
-* author attributions in that material or in the Appropriate Legal
-* Notices displayed by works containing it.
-* * Prohibiting misrepresentation of the origin of that material,
-* or requiring that modified versions of such material be marked in
-* reasonable ways as different from the original version.
-*/
-
-#include "UniversalUpdater.hpp"
-
-#include "DownloadFile.hpp"
-#include "DownloadUtils.hpp"
-#include "gui.hpp"
-#include "nitrofs.h"
-#include "QueueSystem.hpp"
-#include "tonccpy.h"
-#include "WiFi.hpp"
-
-#include
-#include
-#include
-
-
-int UU::QueueMenuRefresh = 0;
-
-
-/*
- Initialize everything as needed.
-*/
-void UU::Initialize(char *ARGV[]) {
- keysSetRepeat(20, 8);
-
- if (!fatInitDefault()) {
- consoleDemoInit();
- iprintf("FAT init failed!\n");
- while (pmMainLoop()) swiWaitForVBlank();
- }
-
- /* Try init NitroFS at a few likely locations. */
- if (!nitroFSInit(ARGV[0])) {
- if (!nitroFSInit("Universal-Updater.nds")) {
- if (!nitroFSInit("/_nds/Universal-Updater/Universal-Updater.nds")) {
- consoleDemoInit();
- iprintf("NitroFS init failed!\n\n");
- iprintf("Copy Universal-Updater.nds to\n\n");
- iprintf("/_nds/Universal-Updater/\n");
- iprintf(" Universal-Updater.nds\n");
- iprintf("or launch using TWiLight Menu++\nor nds-hb-menu.");
- while (pmMainLoop()) swiWaitForVBlank();
- }
- }
- }
-
- /* Create Directories. */
- mkdir("/_nds", 0777);
- mkdir("/_nds/Universal-Updater", 0777);
- mkdir("/_nds/Universal-Updater/stores", 0777);
- mkdir("/_nds/Universal-Updater/shortcuts", 0777);
-
- /* Initialize graphics. */
- Gui::init(std::array, UNIVCORE_FONT_COUNT>({{
- {"/_nds/Universal-Updater/large.nftr", "nitro:/graphics/font/large.nftr"},
- {"/_nds/Universal-Updater/medium.nftr", "nitro:/graphics/font/medium.nftr"},
- {"/_nds/Universal-Updater/small.nftr", "nitro:/graphics/font/small.nftr"}
- }}));
-
- constexpr uint16_t Palette[] = {
- 0x0000, 0xFFFF, 0xFFFF, 0xFFFF, 0xB126, 0xB126, 0xB126, 0xB126, 0x9883, 0x9883, 0x9883, 0x9883, 0xA4A5, 0xA4A5, 0xA4A5, 0xA4A5,
- 0xFFFF, 0xB9CE, 0xD6B5, 0xFFFF, 0xCE0D, 0xCE0D, 0xCE0D, 0xCE0D, 0xC189, 0xC189, 0xC189, 0xC189, 0xF735, 0xC1CC, 0xD22E, 0xF735
- };
- tonccpy(BG_PALETTE, Palette, sizeof(Palette));
- tonccpy(BG_PALETTE_SUB, Palette, sizeof(Palette));
-
- this->GData = std::make_unique();
- this->MSData = std::make_unique();
-
- /* Initialize Wi-Fi if not using no$gba. */
- if (strncmp((const char *)0x4FFFA00, "no$gba", 6) != 0) {
- this->GData->StartFrame();
- this->GData->DrawTop();
- Gui::DrawStringCentered(0, 3, TEXT_LARGE, TEXT_COLOR, "Connecting to Wi-Fi...");
- Gui::DrawStringCentered(0, 30, TEXT_MEDIUM, TEXT_COLOR, "If it doesn't connect, your router\nmay be incompatible at the moment.");
- this->GData->DrawBottom();
- this->GData->EndFrame();
-
- WiFi::Init();
- while(!WiFi::Connected()) {
- swiWaitForVBlank();
- }
- }
-
- /* Load classes. */
- this->CData = std::make_unique();
- this->TData = std::make_unique();
- this->MData = std::make_unique();
- this->USelector = std::make_unique();
-
- this->MSData->DisplayWaitMsg("Checking UniStore...");
-
- /* Check if LastStore is accessible. */
- if (this->CData->LastStore() == "" || access((_STORE_PATH + this->CData->LastStore()).c_str(), F_OK) != 0) {
- if (access(_STORE_PATH "universal-db.unistore", F_OK) != 0) {
- if (DownloadUtils::WiFiAvailable()) {
- std::unique_ptr DL = std::make_unique("https://github.com/Universal-Team/db/raw/master/docs/unistore/universal-db.unistore", _STORE_PATH "universal-db.unistore");
- this->MSData->DisplayWaitMsg("Downloading universal-db.unistore...");
- DL->Handler();
-
- DL = nullptr;
- DL = std::make_unique("https://github.com/Universal-Team/db/raw/master/docs/unistore/universal-db.tdx", _STORE_PATH "universal-db.tdx");
- this->MSData->DisplayWaitMsg("Downloading universal-db.tdx...");
- DL->Handler();
- }
- }
-
- this->CData->LastStore("universal-db.unistore");
- }
-
- this->Store = std::make_unique(this->CData->LastStore());
-
- this->_Tabs = std::make_unique();
- this->TGrid = std::make_unique();
- this->TList = std::make_unique();
- this->GData->UpdateUniStoreSprites();
-};
-
-
-/*
- Scan the key input.
-*/
-void UU::ScanInput() {
- scanKeys();
- this->Down = keysDown();
- this->Repeat = keysDownRepeat();
- touchRead(&this->T);
- this->T.px = this->T.px * 5 / 4;
- this->T.py = this->T.py * 5 / 4;
-};
-
-
-/*
- Draws Universal-Updater's UI.
-*/
-void UU::Draw() {
- this->GData->StartFrame();
-
- this->GData->DrawTop();
- if (!this->USelector->Done) this->USelector->DrawTop();
- else {
- /* Ensure it isn't a nullptr. */
- if (this->Store && this->Store->UniStoreValid()) {
- Gui::DrawStringCentered(0, 3, TEXT_LARGE, TEXT_COLOR, this->Store->GetUniStoreTitle(), 390);
-
- switch(this->TMode) {
- case TopMode::Grid:
- this->TGrid->Draw();
- break;
-
- case TopMode::List:
- this->TList->Draw();
- break;
- }
-
- this->_Tabs->DrawTop();
-
- } else {
- Gui::DrawStringCentered(0, 3, TEXT_LARGE, TEXT_COLOR, "Invalid UniStore", 390);
- }
- }
-
- this->GData->DrawBottom();
-
- if (!this->USelector->Done) this->USelector->DrawBottom();
- else this->_Tabs->DrawBottom();
-
- this->GData->EndFrame();
-};
-
-
-void UU::VBlankHandler() {
- UU::App->ScanInput();
-
- if (!UU::App->USelector->Done) {
- UU::App->USelector->Handler();
- if (UU::App->USelector->Done) UU::App->Draw();
-
- } else {
- UU::App->_Tabs->Handler(); // Tabs are always handled.
-
- /* Handle Top List if possible. */
- if (UU::App->_Tabs->HandleTopScroll()) {
- switch(UU::App->TMode) {
- case TopMode::Grid:
- UU::App->TGrid->Handler();
- break;
-
- case TopMode::List:
- UU::App->TList->Handler();
- break;
- }
- }
- }
-
- if (UU::App->Repeat) UU::App->Draw();
- else if (UU::App->_Tabs->CurrentTab() == Tabs::Tab::QueueSystem) {
- if (QueueMenuRefresh < 60) QueueMenuRefresh++;
- else {
- QueueMenuRefresh = 0;
- Gui::ScreenDraw(false);
- QueueSystem::Draw();
- }
- }
-};
-
-
-/*
- Main Handler of the app. Handle Input and display stuff here.
-*/
-int UU::Handler(char *ARGV[]) {
- this->Initialize(ARGV);
-
- // TODO: It only redraws on button press, forcing an initial draw for now
- this->Draw();
-
- /* Enable VBlank handler. */
- // irqSet(IRQ_VBLANK, this->VBlankHandler);
- // irqEnable(IRQ_VBLANK);
-
- while (!this->Exiting) {
- swiWaitForVBlank();
-
- QueueSystem::Handler();
- }
-
- this->CData->Sav();
- return 0;
-};
-
-
-void UU::SwitchTopMode(const UU::TopMode TMode) {
- this->TMode = TMode;
-
- switch(this->TMode) {
- case TopMode::Grid:
- this->TGrid->Update();
- break;
-
- case TopMode::List:
- this->TList->Update();
- break;
- }
-
- this->GData->UpdateUniStoreSprites();
-};
\ No newline at end of file
diff --git a/source/nds/data/GFXData.cpp b/source/nds/data/GFXData.cpp
index bc1a80d8c..742b90338 100644
--- a/source/nds/data/GFXData.cpp
+++ b/source/nds/data/GFXData.cpp
@@ -26,9 +26,9 @@
#include "GFXData.hpp"
-#include "Common.hpp"
#include "font.hpp"
#include "gui.hpp"
+#include "UniversalUpdater.hpp"
#include
diff --git a/source/nds/data/MSGData.cpp b/source/nds/data/MSGData.cpp
index 702cdf08a..d023ddd24 100644
--- a/source/nds/data/MSGData.cpp
+++ b/source/nds/data/MSGData.cpp
@@ -24,9 +24,10 @@
* reasonable ways as different from the original version.
*/
-#include "Common.hpp"
#include "MSGData.hpp"
+#include "UniversalUpdater.hpp"
+
void MSGData::DisplayWaitMsg(const std::string &MSG) {
/* Hide the Sprites on a message display. */
diff --git a/source/nds/utils/nitrofs.c b/source/nds/utils/nitrofs.c
index 8da418978..0b7f33a82 100644
--- a/source/nds/utils/nitrofs.c
+++ b/source/nds/utils/nitrofs.c
@@ -135,7 +135,7 @@ int __itcm nitroFSInit(const char *ndsfile) {
ndsFile = NULL;
bool noCashGba = (strncmp((const char *)0x4FFFA00, "no$gba", 6) == 0);
if(!isDSiMode() || noCashGba) {
- sysSetCartOwner(BUS_OWNER___NDS__); // give us gba slot ownership
+ sysSetCartOwner(BUS_OWNER_ARM9); // give us gba slot ownership
// We has gba rahm
// printf("yes i think this is GBA?!\n");
if(strncmp(((const char *)GBAROM) + LOADERSTROFFSET, LOADERSTR, strlen(LOADERSTR)) ==
diff --git a/source/store/Meta.cpp b/source/store/Meta.cpp
index 584dae53f..eaf47d37e 100644
--- a/source/store/Meta.cpp
+++ b/source/store/Meta.cpp
@@ -24,9 +24,12 @@
* reasonable ways as different from the original version.
*/
-#include "Common.hpp"
#include "Meta.hpp"
+
+#include "Platform.hpp"
+#include "UniversalUpdater.hpp"
#include "UniStore.hpp"
+
#include
diff --git a/source/store/UniStore.cpp b/source/store/UniStore.cpp
index edb391e51..f298d7520 100644
--- a/source/store/UniStore.cpp
+++ b/source/store/UniStore.cpp
@@ -24,10 +24,13 @@
* reasonable ways as different from the original version.
*/
+#include "UniStore.hpp"
+
#include "BrowseData.hpp"
#include "DownloadUtils.hpp"
-#include "UniStore.hpp"
+#include "Platform.hpp"
#include "UniversalUpdater.hpp"
+
#include
const std::string UniStore::emptyString = "";
@@ -146,7 +149,7 @@ void UniStore::Update(bool Force) {
if (!this->Valid) return;
/* Ensure WiFi is available. */
- if (!DownloadUtils::WiFiAvailable() || !(Force || UU::App->CData->AutoUpdate())) {
+ if (!Platform::WiFi::Connected() || !(Force || UU::App->CData->AutoUpdate())) {
this->ResetIndexes();
UU::App->GData->UnloadUniStoreSheets();
this->LoadSpriteSheets();
diff --git a/source/utils/DownloadUtils.cpp b/source/utils/DownloadUtils.cpp
index e9f5a3645..753ebca4a 100644
--- a/source/utils/DownloadUtils.cpp
+++ b/source/utils/DownloadUtils.cpp
@@ -25,17 +25,16 @@
*/
#include "DownloadUtils.hpp"
+
+#include "Platform.hpp"
+
#include
#include
+#define RESULT_BUF_SIZE (1 << 20) // 1 MiB.
+
#ifdef __3DS__
- #include <3ds.h> // For socInit stuff.
#include // memalign and free.
- #define RESULT_BUF_SIZE (1 << 20) // 1 MiB.
-
-#elif __NDS__
- #include "WiFi.hpp"
- #define RESULT_BUF_SIZE (1 << 20) // 1 MiB.
#endif
#define USER_AGENT "Universal-Updater-v4.0.0"
@@ -99,7 +98,7 @@ static int SetupContext(CURL *Hnd, const char *URL) {
int DownloadUtils::DownloadToFile(const char *URL, const char *Path) {
- if (!DownloadUtils::WiFiAvailable()) return -1;
+ if (!Platform::WiFi::Connected()) return -1;
int Ret = 0;
CURLcode CRes;
@@ -188,7 +187,7 @@ int DownloadUtils::DownloadToFile(const char *URL, const char *Path) {
int DownloadUtils::DownloadToMemory(const char *URL, void *Buffer, const size_t Size) {
- if (!DownloadUtils::WiFiAvailable()) return -1;
+ if (!Platform::WiFi::Connected()) return -1;
int Ret = 0;
CURLcode CRes;
@@ -263,16 +262,3 @@ curl_off_t DownloadUtils::CurrentProgress() { return DownloadNow; }
/* std::max with 1 so as never to divide by 0 with this. */
curl_off_t DownloadUtils::TotalSize() { return std::max(1LL, DownloadTotal); }
-
-
-bool DownloadUtils::WiFiAvailable() {
- #ifdef __3DS__
- // return true; // For Citra
-
- uint32_t WifiStatus;
- return (R_SUCCEEDED(ACU_GetWifiStatus(&WifiStatus)) && WifiStatus);
-
- #elif defined(__NDS__)
- return WiFi::Connected();
- #endif
-};
\ No newline at end of file
diff --git a/source/utils/QueueEntry.cpp b/source/utils/QueueEntry.cpp
index f011db022..0fdaa6c94 100644
--- a/source/utils/QueueEntry.cpp
+++ b/source/utils/QueueEntry.cpp
@@ -26,14 +26,14 @@
#include "QueueEntry.hpp"
-#include "Common.hpp"
#include "Copying.hpp"
#include "Deleting.hpp"
#include "DownloadFile.hpp"
#include "DownloadRelease.hpp"
#include "Extracting.hpp"
-#include "Moving.hpp"
#include "gui.hpp"
+#include "Moving.hpp"
+#include "UniversalUpdater.hpp"
bool QueueEntry::ObjectContains(const nlohmann::json &Item, const std::vector Keys) {
diff --git a/source/utils/QueueSystem.cpp b/source/utils/QueueSystem.cpp
index 1dd9fd485..6a7e6ee2c 100644
--- a/source/utils/QueueSystem.cpp
+++ b/source/utils/QueueSystem.cpp
@@ -25,10 +25,10 @@
*/
#include "QueueSystem.hpp"
-#ifdef _3DS
- #include <3ds.h>
- static Thread QueueThread = nullptr;
-#endif
+
+#include "Platform.hpp"
+
+static ThreadPtr QueueThread = nullptr;
std::deque QueueSystem::Queue;
@@ -36,21 +36,16 @@ std::deque QueueSystem::Queue;
void QueueSystem::Add(const size_t EntryIndex, const size_t DLIdx, const nlohmann::json *Script) {
Queue.emplace_back(EntryIndex, DLIdx, Script);
- #ifdef _3DS
- if (Queue.size() == 1) {
- if (QueueThread) {
- threadJoin(QueueThread, U64_MAX);
- threadFree(QueueThread);
- QueueThread = nullptr;
- }
-
- int32_t Prio = 0;
-
- svcGetThreadPriority(&Prio, CUR_THREAD_HANDLE);
- QueueThread = threadCreate((ThreadFunc)QueueSystem::Handler, NULL, 64 * 1024, Prio - 1, -2, false);
- aptSetHomeAllowed(false);
+ if (Queue.size() == 1) {
+ if (QueueThread) {
+ Platform::ThreadJoin(QueueThread, UINT64_MAX);
+ threadFree(QueueThread);
+ QueueThread = nullptr;
}
- #endif
+
+ QueueThread = Platform::CreateThread((ThreadFunc)QueueSystem::Handler);
+ Platform::AllowExit(false);
+ }
};
@@ -65,9 +60,7 @@ void QueueSystem::Handler() {
Queue.pop_front();
}
- #ifdef _3DS
- aptSetHomeAllowed(true);
- #endif
+ Platform::AllowExit(true);
};
diff --git a/source/utils/Utils.cpp b/source/utils/Utils.cpp
index 5cc6478f5..f2e046895 100644
--- a/source/utils/Utils.cpp
+++ b/source/utils/Utils.cpp
@@ -25,6 +25,7 @@
*/
#include "Utils.hpp"
+
#include
#include
#include