mirror of
https://github.com/rvtr/SLOT-1-Boot-Menu.git
synced 2025-10-31 13:51:08 -04:00
TwlNmenu boot code (see notes)
I can't actually test this feature right now. melonDS doesn't seem to support jumping from `nand:/tmp/jump.app`, and I can't set up WINE to test with no$gba. I'll set up my other computer later.
This commit is contained in:
parent
383053e42f
commit
65c8c11906
9
Makefile
9
Makefile
@ -3,9 +3,7 @@
|
|||||||
# Project: SLOT-1 Boot Menu
|
# Project: SLOT-1 Boot Menu
|
||||||
# File: Makefile
|
# File: Makefile
|
||||||
#
|
#
|
||||||
# This source code is derived from "os_jump" in the TwlSDK
|
# $Date:: 2024-02-04#$
|
||||||
#
|
|
||||||
# $Date:: 2024-02-01#$
|
|
||||||
# $Author: Lillian Skinner (rmc) $
|
# $Author: Lillian Skinner (rmc) $
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -13,14 +11,15 @@
|
|||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
TARGET_PLATFORM := TWL
|
TARGET_PLATFORM := TWL
|
||||||
|
|
||||||
TWL_ARCHGEN = LIMITED
|
TWL_ARCHGEN = LIMITED
|
||||||
|
|
||||||
TARGET_BIN = SLOT1_Booter.srl
|
TARGET_BIN = SLOT1_Booter.srl
|
||||||
|
|
||||||
SRCS = main.c screen.c font.c
|
INCDIR = ./include $(TWLSDK_ROOT)/build/libraries/os/common/include
|
||||||
|
SRCDIR = ./src $(TWLSDK_ROOT)/build/libraries/os/common/src
|
||||||
|
SRCS = main.c screen.c font.c twlnmenu.c
|
||||||
|
|
||||||
MAKEROM_ROMROOT = ./data
|
MAKEROM_ROMROOT = ./data
|
||||||
MAKEROM_ROMFILES = *.srl
|
MAKEROM_ROMFILES = *.srl
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
/*---------------------------------------------------------------------------*
|
/*---------------------------------------------------------------------------*
|
||||||
Project: SLOT-1 Boot Menu
|
Project: SLOT-1 Boot Menu
|
||||||
File: screen.h
|
File: twlnmenu.h
|
||||||
|
|
||||||
This source code is derived from "os_jump" in the TwlSDK
|
This source code is derived from "os_jump" in the TwlSDK
|
||||||
|
|
||||||
$Date:: 2024-02-01#$
|
$Date:: 2024-02-03#$
|
||||||
$Author: Lillian Skinner (rmc) $
|
$Author: Lillian Skinner (rmc) $
|
||||||
*---------------------------------------------------------------------------*/
|
*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
@ -16,19 +16,16 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*===========================================================================*/
|
|
||||||
#include <nitro/types.h>
|
#include <nitro/types.h>
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*
|
BOOL WriteTwlNmenu(void);
|
||||||
Function Definitions
|
void JumpTwlNmenu(void);
|
||||||
*---------------------------------------------------------------------------*/
|
|
||||||
static BOOL WriteTwlNmenu(void);
|
|
||||||
static void JumpTwlNmenu(void)
|
|
||||||
|
|
||||||
/*===========================================================================*/
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
} /* extern "C" */
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* SCREEN_H_ */
|
#endif
|
||||||
|
|||||||
15
src/main.c
15
src/main.c
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
This source code is derived from "os_jump" in the TwlSDK
|
This source code is derived from "os_jump" in the TwlSDK
|
||||||
|
|
||||||
$Date:: 2024-02-01#$
|
$Date:: 2024-02-03#$
|
||||||
$Author: Lillian Skinner (rmc) $
|
$Author: Lillian Skinner (rmc) $
|
||||||
*---------------------------------------------------------------------------*/
|
*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
@ -19,7 +19,7 @@
|
|||||||
/*---------------------------------------------------------------------------*
|
/*---------------------------------------------------------------------------*
|
||||||
Constant Definitions
|
Constant Definitions
|
||||||
*---------------------------------------------------------------------------*/
|
*---------------------------------------------------------------------------*/
|
||||||
#define VERSION 61
|
#define VERSION 83
|
||||||
#define KEY_REPEAT_START 25 // Number of frames until key repeat starts
|
#define KEY_REPEAT_START 25 // Number of frames until key repeat starts
|
||||||
#define KEY_REPEAT_SPAN 10 // Number of frames between key repeats
|
#define KEY_REPEAT_SPAN 10 // Number of frames between key repeats
|
||||||
#define DMA_NO_FS 1
|
#define DMA_NO_FS 1
|
||||||
@ -40,6 +40,7 @@ typedef struct KeyInfo
|
|||||||
// Key input
|
// Key input
|
||||||
static KeyInfo gKey;
|
static KeyInfo gKey;
|
||||||
|
|
||||||
|
BOOL result;
|
||||||
/*---------------------------------------------------------------------------*
|
/*---------------------------------------------------------------------------*
|
||||||
Payload stuffs
|
Payload stuffs
|
||||||
*---------------------------------------------------------------------------*/
|
*---------------------------------------------------------------------------*/
|
||||||
@ -115,7 +116,6 @@ void TwlMain(void)
|
|||||||
if (gKey.trg & PAD_BUTTON_A)
|
if (gKey.trg & PAD_BUTTON_A)
|
||||||
{
|
{
|
||||||
if (FALSE == OS_JumpToSystemMenu() )
|
if (FALSE == OS_JumpToSystemMenu() )
|
||||||
// OSi_CanArbitraryJumpTo(0x00030015484e4241)
|
|
||||||
{
|
{
|
||||||
//Jump failure
|
//Jump failure
|
||||||
PutSubScreen(0, 22, 0xf1, " Failed jump to Launcher ");
|
PutSubScreen(0, 22, 0xf1, " Failed jump to Launcher ");
|
||||||
@ -125,6 +125,7 @@ void TwlMain(void)
|
|||||||
if (gKey.trg & PAD_BUTTON_B)
|
if (gKey.trg & PAD_BUTTON_B)
|
||||||
{
|
{
|
||||||
if (FALSE == OS_JumpToWirelessSetting())
|
if (FALSE == OS_JumpToWirelessSetting())
|
||||||
|
// OSi_CanArbitraryJumpTo(0x00030015484e4241)
|
||||||
{
|
{
|
||||||
//Jump failure
|
//Jump failure
|
||||||
PutSubScreen(0, 22, 0xf1, " Failed jump to MachineSettings ");
|
PutSubScreen(0, 22, 0xf1, " Failed jump to MachineSettings ");
|
||||||
@ -134,11 +135,13 @@ void TwlMain(void)
|
|||||||
if (gKey.trg & PAD_BUTTON_X)
|
if (gKey.trg & PAD_BUTTON_X)
|
||||||
{
|
{
|
||||||
result = WriteTwlNmenu();
|
result = WriteTwlNmenu();
|
||||||
if(result = TRUE )
|
if (result == TRUE)
|
||||||
{
|
{
|
||||||
JumpTwlNmenu();
|
JumpTwlNmenu();
|
||||||
}
|
}
|
||||||
PutSubScreen(0, 22, 0xf1, " Failed to write to TwlNmenu ");
|
|
||||||
|
PutSubScreen(0, 22, 0xf1, " Something went very wrong! ");
|
||||||
|
OS_Terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gKey.trg & PAD_BUTTON_Y)
|
if (gKey.trg & PAD_BUTTON_Y)
|
||||||
|
|||||||
@ -1,31 +1,33 @@
|
|||||||
/*---------------------------------------------------------------------------*
|
/*---------------------------------------------------------------------------*
|
||||||
Project: SLOT-1 Boot Menu
|
Project: SLOT-1 Boot Menu
|
||||||
File: main.c
|
File: twlnmenu.c
|
||||||
|
|
||||||
This source code is derived from "os_jump" in the TwlSDK
|
This source code is derived from "NandInitializer" in TwlIPL
|
||||||
|
|
||||||
$Date:: 2024-02-01#$
|
$Date:: 2024-02-04#$
|
||||||
$Author: Lillian Skinner (rmc) $
|
$Author: Lillian Skinner (rmc) $
|
||||||
*---------------------------------------------------------------------------*/
|
*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include <twl.h>
|
#include <twl.h>
|
||||||
|
#include <twl/os.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "DEMO.h"
|
#include "DEMO.h"
|
||||||
#include "twlnmenu.h"
|
#include "twlnmenu.h"
|
||||||
|
#include "application_jump_private.h"
|
||||||
|
|
||||||
|
#define ROUND_UP(value, alignment) \
|
||||||
|
(((u32)(value) + (alignment-1)) & ~(alignment-1))
|
||||||
|
|
||||||
static u64 ROM_SRL_TID[1] =
|
static u64 ROM_SRL_TID[1] =
|
||||||
{
|
{
|
||||||
0x0003001134544E41
|
0x0003001134544E41
|
||||||
};
|
};
|
||||||
static const char ROM_SRL_PATH[1][32] =
|
|
||||||
{
|
|
||||||
"rom:/TwlNmenu.srl"
|
|
||||||
};
|
|
||||||
|
|
||||||
|
#define ROM_SRL_PATH "rom:/TwlNmenu.srl"
|
||||||
|
|
||||||
static BOOL WriteTwlNmenu(void)
|
BOOL WriteTwlNmenu(void)
|
||||||
{
|
{
|
||||||
FSFile file;
|
FSFile file;
|
||||||
BOOL open_is_ok;
|
BOOL open_is_ok;
|
||||||
@ -34,21 +36,20 @@ static BOOL WriteTwlNmenu(void)
|
|||||||
u32 file_size;
|
u32 file_size;
|
||||||
u32 alloc_size;
|
u32 alloc_size;
|
||||||
BOOL result = TRUE;
|
BOOL result = TRUE;
|
||||||
|
//PutSubScreen(0, 22, 0xf2, " Copying TwlNmenu... ");
|
||||||
FS_InitFile(&file);
|
FS_InitFile(&file);
|
||||||
open_is_ok = FS_OpenFile(&file, OS_TMP_APP_PATH);
|
open_is_ok = FS_OpenFile(&file, OS_TMP_APP_PATH);
|
||||||
if (open_is_ok)
|
if (open_is_ok)
|
||||||
{
|
{
|
||||||
FS_CloseFile(&file);
|
FS_CloseFile(&file);
|
||||||
OS_Printf("%s is already exist.", OS_TMP_APP_PATH);
|
//PutSubScreen(0, 22, 0xf1, " Error: NAND SRL already exists!");
|
||||||
return TRUE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
FS_InitFile(&file);
|
FS_InitFile(&file);
|
||||||
open_is_ok = FS_OpenFile(&file, ROM_SRL_PATH);
|
open_is_ok = FS_OpenFile(&file, ROM_SRL_PATH);
|
||||||
if (!open_is_ok)
|
if (!open_is_ok)
|
||||||
{
|
{
|
||||||
OS_Printf("FS_OpenFile(%s) ERROR!", ROM_SRL_PATH);
|
//PutSubScreen(0, 22, 0xf1, " Error: can't open TwlNmenu! (1)");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,47 +58,61 @@ static BOOL WriteTwlNmenu(void)
|
|||||||
pTempBuf = OS_Alloc( alloc_size );
|
pTempBuf = OS_Alloc( alloc_size );
|
||||||
SDK_NULL_ASSERT(pTempBuf);
|
SDK_NULL_ASSERT(pTempBuf);
|
||||||
DC_InvalidateRange(pTempBuf, alloc_size);
|
DC_InvalidateRange(pTempBuf, alloc_size);
|
||||||
|
//PutSubScreen(0, 22, 0xf2, " Writing TwlNmenu to buffer ");
|
||||||
read_is_ok = FS_ReadFile( &file, pTempBuf, (s32)file_size );
|
read_is_ok = FS_ReadFile( &file, pTempBuf, (s32)file_size );
|
||||||
if (!read_is_ok)
|
if (!read_is_ok)
|
||||||
{
|
{
|
||||||
OS_Panic("FS_ReadFile(%s) ERROR!", ROM_SRL_PATH);
|
//PutSubScreen(0, 22, 0xf1, " Error: can't write TwlNmenu! (1)");
|
||||||
FS_CloseFile(&file);
|
FS_CloseFile(&file);
|
||||||
OS_Free(pTempBuf);
|
OS_Free(pTempBuf);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
FS_CloseFile(&file);
|
FS_CloseFile(&file);
|
||||||
|
//PutSubScreen(0, 22, 0xf2, " Creating TwlNmenu in NAND ");
|
||||||
if (!FS_CreateFile(OS_TMP_APP_PATH, FS_PERMIT_R | FS_PERMIT_W))
|
if (!FS_CreateFile(OS_TMP_APP_PATH, FS_PERMIT_R | FS_PERMIT_W))
|
||||||
{
|
{
|
||||||
OS_Panic("FS_CreateFile(%s) failed.", OS_TMP_APP_PATH);
|
//PutSubScreen(0, 22, 0xf1, " Error: can't create NAND file! ");
|
||||||
result = FALSE;
|
result = FALSE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FS_InitFile(&file);
|
FS_InitFile(&file);
|
||||||
|
//PutSubScreen(0, 22, 0xf2, " Opening TwlNmenu in NAND");
|
||||||
open_is_ok = FS_OpenFileEx(&file, OS_TMP_APP_PATH, FS_FILEMODE_W);
|
open_is_ok = FS_OpenFileEx(&file, OS_TMP_APP_PATH, FS_FILEMODE_W);
|
||||||
if (!open_is_ok)
|
if (!open_is_ok)
|
||||||
|
|
||||||
{
|
{
|
||||||
OS_Panic("FS_OpenFile(%s) failed.\n", OS_TMP_APP_PATH);
|
//PutSubScreen(0, 22, 0xf1, " Error: can't open TwlNmenu! (2)");
|
||||||
result = FALSE;
|
result = FALSE;
|
||||||
}
|
}
|
||||||
else if (FS_WriteFile(&file, pTempBuf, (s32)file_size) == -1)
|
else if (FS_WriteFile(&file, pTempBuf, (s32)file_size) == -1)
|
||||||
{
|
{
|
||||||
OS_Panic("FS_WritFile() failed.\n");
|
//PutSubScreen(0, 22, 0xf1, " Error: can't write TwlNmenu! (2)");
|
||||||
result = FALSE;
|
result = FALSE;
|
||||||
}
|
}
|
||||||
(void)FS_CloseFile(&file);
|
//PutSubScreen(0, 22, 0xf2, " Closing file TwlNmenu ");
|
||||||
|
//(void)FS_CloseFile(&file);
|
||||||
|
// This isn't working no matter what I try. Commenting out for now, hopefully files on NAND don't need any write protection lol
|
||||||
}
|
}
|
||||||
|
//PutSubScreen(0, 22, 0xf2, " Freeing buffer ");
|
||||||
OS_Free(pTempBuf);
|
OS_Free(pTempBuf);
|
||||||
|
//PutSubScreen(0, 22, 0xf2, " Done writing TwlNmenu ");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void JumpTwlNmenu(void) {
|
void JumpTwlNmenu(void) {
|
||||||
OS_DoApplicationJump( ROM_SRL_TID[0], OS_APP_JUMP_TMP );
|
LauncherBootFlags flag;
|
||||||
PutSubScreen(0, 22, 0xf1, " Failed jump to TwlNmenu ");
|
flag.bootType = LAUNCHER_BOOTTYPE_NAND;
|
||||||
|
flag.isValid = TRUE;
|
||||||
|
flag.isLogoSkip = TRUE;
|
||||||
|
flag.isInitialShortcutSkip = FALSE;
|
||||||
|
flag.isAppLoadCompleted = FALSE;
|
||||||
|
flag.isAppRelocate = FALSE;
|
||||||
|
flag.rsv = 0;
|
||||||
|
//PutSubScreen(0, 22, 0xf2, " Jumping to TwlNmenu ");
|
||||||
|
OS_SetLauncherParamAndResetHardware(ROM_SRL_TID[1], &flag);
|
||||||
|
//PutSubScreen(0, 22, 0xf1, " Failed jump to TwlNmenu ");
|
||||||
|
OS_Terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user