Skip to content

Commit

Permalink
FRESH EDITION
Browse files Browse the repository at this point in the history
  • Loading branch information
Naim2000 committed Jul 19, 2024
1 parent 2de86a4 commit 2dd873f
Show file tree
Hide file tree
Showing 8 changed files with 464 additions and 276 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map
#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS := -lwiiuse -lbte -logc -lm
LIBS := -lwiiuse -lbte -logc -lm -lwiikeyboard

#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
Expand Down
4 changes: 2 additions & 2 deletions source/fatfs/ffconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
/ 3: f_lseek() function is removed in addition to 2. */


#define FF_USE_FIND 1
#define FF_USE_FIND 0
/* This option switches filtered directory read functions, f_findfirst() and
/ f_findnext(). (0:Disable, 1:Enable 2:Enable with matching altname[] too) */

Expand All @@ -52,7 +52,7 @@
/ (0:Disable or 1:Enable) */


#define FF_USE_FORWARD 1
#define FF_USE_FORWARD 0
/* This option switches f_forward() function. (0:Disable or 1:Enable) */


Expand Down
147 changes: 119 additions & 28 deletions source/main.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <gccore.h>
#include <wiiuse/wpad.h>

Expand All @@ -22,13 +23,50 @@ static void PrintHeader(void) {
clearln('\315');
}

static int SelectionMenu(const char* const options[], int count) {
int posX, posY, selected = 0;
CON_GetPosition(&posX, &posY);

while (true) {
printf("\x1b[%i;0H", posY);
for (int i = 0; i < count; i++)
printf(" %s %s%s\n", i == selected ? "\x1b[47;1m\x1b[30m>>" : " ", options[i], i == selected ? "\x1b[40m\x1b[39m" : "");

wait_button(0);

if (buttons_down(WPAD_BUTTON_UP)) {
if (!selected--)
selected = count - 1;
continue;
}

else if (buttons_down(WPAD_BUTTON_DOWN)) {
if (++selected == count)
selected = 0;
continue;
}

else if (buttons_down(WPAD_BUTTON_A)) {
selected++;
break;
}

else if (buttons_down(WPAD_BUTTON_B | WPAD_BUTTON_HOME)) {
selected = -1;
break;
}
}

putchar('\n');
putchar('\n');
return selected;
}

int main(void) {
initpads();
if (!SDMount()) goto exit;

if (!MSET9Start()) goto exit;

int consoleVer = 0;
if (!MSET9Start() || !MSET9SanityCheckA()) goto exit;

PrintHeader();
puts("\n"
Expand All @@ -52,53 +90,106 @@ int main(void) {
"New 3DS, 11.4 up to 11.7"
};

int posX, posY;
CON_GetPosition(&posX, &posY);
int consoleVer = SelectionMenu(options, 4);

while (true) {
if (consoleVer < 0)
goto exit;

printf("\x1b[%i;0H", posY);
for (int ii = 0; ii < 4; ii++)
printf(" %s %s\x1b[40m\x1b[39m\n", ii == consoleVer ? "\x1b[47;1m\x1b[30m>>" : " ", options[ii]);
PrintHeader();
if (!mset9.hasHaxID1) { // Create hax ID1
puts(
"\x1b[41;39m=== !! DISCLAIMER !! ===\x1b[40m\x1b[39m\n\n"

wait_button(0);
"This process will temporarily reset all your 3DS data.\n"
"All your applications and themes will disappear.\n"
"This is perfectly normal, and if everything goes right. it will re-appear\n"
"at the end of the process.\n\n"

"In any case, it is highly recommended to make a backup of your SD card's\n"
"contents to a folder on your PC.\n"
"(Especially the 'Nintendo 3DS' folder.)\n"
);

if (buttons_down(WPAD_BUTTON_UP)) { if (!consoleVer--) consoleVer = 3; continue; }
sleep(7);

else if (buttons_down(WPAD_BUTTON_DOWN)) { if (++consoleVer == 4) consoleVer = 0; continue; }
puts("Press (+) to confirm.\n"
"Press any other button to cancel.\n");

else if (buttons_down(WPAD_BUTTON_A)) { consoleVer++; break; }
wait_button(0);
if (buttons_down(WPAD_BUTTON_PLUS))
MSET9CreateHaxID1((MSET9Version)consoleVer);

else if (buttons_down(WPAD_BUTTON_B | WPAD_BUTTON_HOME)) { consoleVer = 0; break; }
goto exit;
}
else if (mset9.consoleVer != consoleVer) {
puts(pBad "Error #03: Don't change console model/version during MSET9!\n");

printf("Earlier, you selected: '%s'!\n", shortNames[mset9.consoleVer]);
printf("Are you sure you want to switch to: '%s'?\n\n", shortNames[consoleVer]);

sleep(3);

if (!consoleVer) goto exit;
puts("Press (+) to confirm.\n"
"Press any other button to cancel.\n");

wait_button(0);
if (!buttons_down(WPAD_BUTTON_PLUS))
goto exit;

MSET9SetConsoleVer((MSET9Version)consoleVer);
MSET9CreateHaxID1((MSET9Version)consoleVer);
}

while (true) {
PrintHeader();
if (MSET9SanityCheck()) {
printf(pNote "Selected console version: %s\n", shortNames[consoleVer - 1]);
if (mset9.hasTriggerFile) {
MSET9Injection(false);
puts(pWarn "Try again?\n\n"

pInfo "Press (+) to try again.\n"
pInfo "Press (-) to remove MSET9.\n");

wait_button(WPAD_BUTTON_PLUS | WPAD_BUTTON_MINUS);
if (buttons_down(WPAD_BUTTON_MINUS)) {
MSET9Remove();
goto exit;
}
}
else if (mset9.homeExtdataOK && mset9.miiExtdataOK && mset9.titleDbsOK) {
printf(pNote "Selected console version: %s\n", shortNames[consoleVer]);
printf(pNote "Inject MSET9 now?\n\n"

pInfo "Press (A) to confirm.\n"
pInfo "Press [B] to cancel.\n");
wait_button(WPAD_BUTTON_A | WPAD_BUTTON_B | WPAD_BUTTON_HOME);
if (buttons_down(WPAD_BUTTON_A)) MSET9Injection();
if (buttons_down(WPAD_BUTTON_A)) MSET9Injection(true);
}
else {
if (!mset9.homeExtdataOK) {
puts(pBad "HOME menu extdata: Missing!\n"
pInfo "Please power on your console with your SD inserted, then try again.\n"
pInfo "If this does not work, power it on while holding L+R+Down+B.\n");
}
// else puts(pGood "HOME menu extdata: OK!\n");

if (!mset9.miiExtdataOK) {
puts(pBad "Mii Maker extdata: Missing!\n"
pInfo "Please power on your console with your SD inserted,\n"
pInfo "then launch Mii Maker.\n");
}
// else puts(pGood "Mii Maker extdata: OK!\n");

if (!mset9.titleDbsOK) {
puts(pBad "Title database: Not initialized!\n"
pInfo "Please power on your console with your SD inserted,\n"
pInfo "open System Setttings, navigate to Data Management\n"
pInfo "-> Nintendo 3DS -> Software, then select Reset.\n");
// else puts(pGood "Title database: OK!");
}
}

if (!SDRemount()) break;
PrintHeader();
int ret = MSET9Start();
if (!ret) break;
else if (ret == 2) {
printf(pWarn "Try again?\n\n"

pInfo "Press (A) to confirm.\n"
pInfo "Press [B] to cancel.\n");
wait_button(WPAD_BUTTON_A | WPAD_BUTTON_B | WPAD_BUTTON_HOME);
if (!buttons_down(WPAD_BUTTON_A)) break;
}
}

exit:
Expand Down
Loading

0 comments on commit 2dd873f

Please sign in to comment.