Skip to content
This repository has been archived by the owner on Jul 20, 2023. It is now read-only.

Commit

Permalink
Merge branch 'master' of https://github.com/LumaTeam/Luma3DS into off…
Browse files Browse the repository at this point in the history
…icial
  • Loading branch information
PabloMK7 committed Apr 21, 2022
2 parents d7bfebe + b79717e commit 2472411
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 2 deletions.
2 changes: 1 addition & 1 deletion arm9/source/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ bool readConfig(void)
memset(&configData, 0, sizeof(CfgData));
configData.formatVersionMajor = CONFIG_VERSIONMAJOR;
configData.formatVersionMinor = CONFIG_VERSIONMINOR;
configData.config |= 1 << PATCHGAMES;
configData.config |= 1u << PATCHVERSTRING;
configData.splashDurationMsec = 3000;
configData.hbldr3dsxTitleId = 0x000400000D921E00ull;
configData.rosalinaMenuCombo = 1u << 9 | 1u << 7 | 1u << 2; // L+Start+Select
Expand Down
21 changes: 20 additions & 1 deletion arm9/source/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ bool fileCopy(const char *pathSrc, const char *pathDst, bool replace, void *tmpB
{
char path[FF_MAX_LFN + 1];
strncpy(path, pathDst, c - pathDst);
path[FF_MAX_LFN] = '\0';
path[c - pathDst] = '\0';
res = f_mkdir(path);
}

Expand Down Expand Up @@ -398,6 +398,16 @@ void findDumpFile(const char *folderPath, char *fileName)

static u8 fileCopyBuffer[0x10000];

static const u8 boot9Sha256[32] = {
0x2F, 0x88, 0x74, 0x4F, 0xEE, 0xD7, 0x17, 0x85, 0x63, 0x86, 0x40, 0x0A, 0x44, 0xBB, 0xA4, 0xB9,
0xCA, 0x62, 0xE7, 0x6A, 0x32, 0xC7, 0x15, 0xD4, 0xF3, 0x09, 0xC3, 0x99, 0xBF, 0x28, 0x16, 0x6F
};

static const u8 boot11Sha256[32] = {
0x74, 0xDA, 0xAC, 0xE1, 0xF8, 0x06, 0x7B, 0x66, 0xCC, 0x81, 0xFC, 0x30, 0x7A, 0x3F, 0xDB, 0x50,
0x9C, 0xBE, 0xDC, 0x32, 0xF9, 0x03, 0xAE, 0xBE, 0x90, 0x61, 0x44, 0xDE, 0xA7, 0xA0, 0x75, 0x12
};

static bool backupEssentialFiles(void)
{
size_t sz = sizeof(fileCopyBuffer);
Expand Down Expand Up @@ -430,6 +440,15 @@ static bool backupEssentialFiles(void)
ok = ok && fileWrite(fileCopyBuffer, "backups/HWCAL_01_EEPROM.dat", 0x1000);
}

// B9S bootrom backups
u32 hash[32/4];
sha(hash, (const void *)0x08080000, 0x10000, SHA_256_MODE);
if (memcmp(hash, boot9Sha256, 32) == 0 && getFileSize("backups/boot9.bin") != 0x10000)
ok = ok && fileWrite((const void *)0x08080000, "backups/boot9.bin", 0x10000);
sha(hash, (const void *)0x08090000, 0x10000, SHA_256_MODE);
if (memcmp(hash, boot11Sha256, 32) == 0 && getFileSize("backups/boot11.bin") != 0x10000)
ok = ok && fileWrite((const void *)0x08090000, "backups/boot11.bin", 0x10000);

return ok;
}

Expand Down
1 change: 1 addition & 0 deletions sysmodules/rosalina/include/menus/sysconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ void SysConfigMenu_ToggleWireless(void);
void SysConfigMenu_TogglePowerButton(void);
void SysConfigMenu_ControlWifi(void);
void SysConfigMenu_DisableForcedWifiConnection(void);
void SysConfigMenu_ToggleCardIfPower(void);
44 changes: 44 additions & 0 deletions sysmodules/rosalina/source/menus/sysconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Menu sysconfigMenu = {
{ "Toggle LEDs", METHOD, .method = &SysConfigMenu_ToggleLEDs },
{ "Toggle Wireless", METHOD, .method = &SysConfigMenu_ToggleWireless },
{ "Toggle Power Button", METHOD, .method=&SysConfigMenu_TogglePowerButton },
{ "Toggle power to card slot", METHOD, .method=&SysConfigMenu_ToggleCardIfPower},
{},
}
};
Expand Down Expand Up @@ -334,3 +335,46 @@ void SysConfigMenu_DisableForcedWifiConnection(void)
}
while(!menuShouldExit);
}

void SysConfigMenu_ToggleCardIfPower(void)
{
Draw_Lock();
Draw_ClearFramebuffer();
Draw_FlushFramebuffer();
Draw_Unlock();

bool cardIfStatus = false;
bool updatedCardIfStatus = false;

do
{
Result res = FSUSER_CardSlotGetCardIFPowerStatus(&cardIfStatus);
if (R_FAILED(res)) cardIfStatus = false;

Draw_Lock();
Draw_DrawString(10, 10, COLOR_TITLE, "System configuration menu");
u32 posY = Draw_DrawString(10, 30, COLOR_WHITE, "Press A to toggle, press B to go back.\n\n");
posY = Draw_DrawString(10, posY, COLOR_WHITE, "Inserting or removing a card will reset the status,\nand you'll need to reinsert the cart if you want to\nplay it.\n\n");
Draw_DrawString(10, posY, COLOR_WHITE, "Current status:");
Draw_DrawString(100, posY, !cardIfStatus ? COLOR_RED : COLOR_GREEN, !cardIfStatus ? " DISABLED" : " ENABLED ");

Draw_FlushFramebuffer();
Draw_Unlock();

u32 pressed = waitInputWithTimeout(1000);

if(pressed & KEY_A)
{
if (!cardIfStatus)
res = FSUSER_CardSlotPowerOn(&updatedCardIfStatus);
else
res = FSUSER_CardSlotPowerOff(&updatedCardIfStatus);

if (R_SUCCEEDED(res))
cardIfStatus = !updatedCardIfStatus;
}
else if(pressed & KEY_B)
return;
}
while(!menuShouldExit);
}

0 comments on commit 2472411

Please sign in to comment.