diff --git a/Makefile b/Makefile index 26e503e..a0f778b 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ VERSION_MAJOR := 1 VERSION_MINOR := 0 -VERSION_REVISION := 1 +VERSION_REVISION := 2 all: mkdir -p plugin/build diff --git a/app/Makefile b/app/Makefile index 396a523..fb66e71 100644 --- a/app/Makefile +++ b/app/Makefile @@ -26,7 +26,7 @@ LIBRARIES := ctru VERSION_MAJOR := 1 VERSION_MINOR := 0 -VERSION_MICRO := 1 +VERSION_MICRO := 2 BUILD_FLAGS := -march=armv6k -mtune=mpcore -mfloat-abi=hard BUILD_FLAGS_CC := -g -Wall -Wno-strict-aliasing -O3 -mword-relocations \ diff --git a/app/sources/Logger.cpp b/app/sources/Logger.cpp index 5daaf07..9c8c610 100644 --- a/app/sources/Logger.cpp +++ b/app/sources/Logger.cpp @@ -150,12 +150,12 @@ void Logger::Handler() { printf("[I] %s\n", log.string.c_str()); break; case PendingLog::Type::WARNING: - topScreenConsole.fg = 19; + topScreenConsole.fg = 3; printf("[W] %s\n", log.string.c_str()); topScreenConsole.fg = 0; break; case PendingLog::Type::ERROR: - topScreenConsole.fg = 17; + topScreenConsole.fg = 1; printf("[E] %s\n", log.string.c_str()); topScreenConsole.fg = 0; break; diff --git a/app/sources/main.cpp b/app/sources/main.cpp index 8f8cff4..7960d69 100644 --- a/app/sources/main.cpp +++ b/app/sources/main.cpp @@ -127,6 +127,12 @@ bool launchPlugin() { return true; } +bool checkEmulator() { + s64 out = 0; + svcGetSystemInfo(&out, 0x20000, 0); + return out != 0; +} + PrintConsole topScreenConsole, bottomScreenConsole; int transferedBytes = 0; void Main() { @@ -148,14 +154,20 @@ void Main() { consoleSelect(&topScreenConsole); consoleClear(); + bool isEmulator = checkEmulator(); + { CTRPluginFramework::BCLIM((void*)__data_logo_bin, __data_logo_bin_size).Render(CTRPluginFramework::Rect((320 - 128) / 2, (240 - 128) / 2, 128, 128)); } logger.Raw(false, "\n Azahar Artic Setup v%d.%d.%d\n", VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION); - logger.Raw(false, " Press A to launch setup tool."); + logger.Raw(false, isEmulator ? " " : " Press A to launch setup tool."); logger.Raw(false, " Press B or START to exit."); logger.Raw(true, ""); logger.Info("Welcome to Azahar Artic Setup Tool!\n Only use this tool with Azahar Emulator\n\n Check bottom screen for controls."); + + if (isEmulator) { + logger.Error("This tool can only be used on a real console."); + } bool do_jump = false; while (aptMainLoop()) @@ -170,7 +182,7 @@ void Main() { break; } - if (kDown & KEY_A) { + if ((kDown & KEY_A) && !isEmulator) { logger.Info("Launching Azahar Artic Setup"); bool done = extractPlugin() && launchPlugin(); if (done) { diff --git a/plugin/ArticProtocol b/plugin/ArticProtocol index faa3a2d..eca355a 160000 --- a/plugin/ArticProtocol +++ b/plugin/ArticProtocol @@ -1 +1 @@ -Subproject commit faa3a2d62172fd0964a495a8b4143827cad1b0db +Subproject commit eca355a4961f7550f8a1d1a7e1d3b90e34a7b920 diff --git a/plugin/Makefile b/plugin/Makefile index abc46a8..08d476b 100644 --- a/plugin/Makefile +++ b/plugin/Makefile @@ -16,7 +16,7 @@ SOURCES := ArticProtocol/sources sources sources/CTRPluginFramework VERSION_MAJOR := 1 VERSION_MINOR := 0 -VERSION_REVISION := 1 +VERSION_REVISION := 2 SERVER_PORT := 5543 IP := 19 diff --git a/plugin/sources/ArticFunctions.cpp b/plugin/sources/ArticFunctions.cpp index 5042bae..370bc33 100644 --- a/plugin/sources/ArticFunctions.cpp +++ b/plugin/sources/ArticFunctions.cpp @@ -15,7 +15,7 @@ extern "C" { } extern bool isControllerMode; -constexpr u32 INITIAL_SETUP_APP_VERSION = 0; +constexpr u32 INITIAL_SETUP_APP_VERSION = 1; enum class HandleType { FILE, @@ -523,10 +523,25 @@ namespace ArticFunctions { } void System_IsAzaharInitialSetup(ArticProtocolServer::MethodInterface& mi) { + // This function is stubbed, only kept for compatibility reasons + bool good = true; if (good) mi.FinishInputParameters(); + logger.Error("Tool and Azahar version mismatch.\n Please check for updates."); + + mi.FinishGood(-1); + } + + void System_ArticSetupVersion(ArticProtocolServer::MethodInterface& mi) { + bool good = true; + s32 expected; + + if (good) good = mi.GetParameterS32(expected); + + if (good) mi.FinishInputParameters(); + ArticProtocolCommon::Buffer* ret_buf = mi.ReserveResultBuffer(0, 4); if (!ret_buf) { return; @@ -534,6 +549,37 @@ namespace ArticFunctions { reinterpret_cast(ret_buf->data)[0] = INITIAL_SETUP_APP_VERSION; isAzaharCalled = true; + if ((u32)expected != INITIAL_SETUP_APP_VERSION) { + logger.Error("Tool and Azahar version mismatch.\n Please check for updates."); + } + + mi.FinishGood(0); + } + + void System_ReportDeviceID(ArticProtocolServer::MethodInterface& mi) { + bool good = true; + s32 deviceID; + + if (good) good = mi.GetParameterS32(deviceID); + + if (good) mi.FinishInputParameters(); + + Result res = amInit(); + if (R_FAILED(res)) { + mi.FinishGood(res); + return; + } + + u32 myDeviceID; + res = AM_GetDeviceId(&myDeviceID); + amExit(); + + if ((u32)deviceID != myDeviceID) { + logger.Error("Azahar is linked to a different console than this one. Please unlink your previous console from emulator settings before continuing."); + mi.FinishGood(-1); + return; + } + mi.FinishGood(0); } @@ -898,6 +944,8 @@ namespace ArticFunctions { {METHOD_NAME("FSDIR_Close"), FSDIR_Close_}, {METHOD_NAME("System_IsAzaharInitialSetup"), System_IsAzaharInitialSetup}, + {METHOD_NAME("System_ArticSetupVersion"), System_ArticSetupVersion}, + {METHOD_NAME("System_ReportDeviceID"), System_ReportDeviceID}, {METHOD_NAME("System_GetSystemFile"), System_GetSystemFile}, {METHOD_NAME("System_GetNIM"), System_GetNIM}, };