Added TWL EVA sound effects

This commit is contained in:
Lillian Skinner 2024-11-27 05:42:57 -05:00
parent da2ae15e7c
commit 1c88010927
No known key found for this signature in database
22 changed files with 423 additions and 268 deletions

View File

@ -37,7 +37,7 @@ ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=ds_arm7.specs -g $(ARCH) -Wl,--nmagic -Wl,-Map,$(notdir $*).map
#LIBS := -ldswifi7 -lmm7 -lnds7
LIBS := -lnds7
LIBS := -lmm7 -lnds7
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing

View File

@ -28,7 +28,7 @@
---------------------------------------------------------------------------------*/
#include "my_sdmmc.h"
#include <maxmod7.h>
#include <nds.h>
#include <string.h>
@ -117,6 +117,12 @@ int main()
fifoInit();
touchInit();
mmInstall(FIFO_MAXMOD);
SetYtrigger(202);
installSoundFIFO();
installSystemFIFO();
if (isDSiMode() /*|| ((REG_SCFG_EXT & BIT(17)) && (REG_SCFG_EXT & BIT(18)))*/)
{
u8 *out=(u8*)0x02300000;
@ -164,10 +170,6 @@ int main()
SetYtrigger(80);
installSoundFIFO();
installSystemFIFO();
irqSet(IRQ_VCOUNT, VcountHandler);
irqEnable( IRQ_VBLANK | IRQ_VCOUNT | IRQ_NETWORK);

View File

@ -43,6 +43,7 @@ SOURCES := src src/nand src/nand/polarssl src/nand/twltool src/lib/libfat/sourc
INCLUDES := include src/nand src/lib/libfat/include
DATA := ../data
GRAPHICS := fonts
MUSIC := ../sounds
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
@ -63,7 +64,7 @@ LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS := -lfilesystem -lnds9
LIBS := -lmm9 -lfilesystem -lnds9
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
@ -89,8 +90,9 @@ CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
BMPFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.bmp)))
PNGFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.png)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) soundbank.bin
export AUDIOFILES := $(foreach dir,$(notdir $(wildcard $(MUSIC)/*.*)),$(CURDIR)/$(MUSIC)/$(dir))
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
@ -124,13 +126,13 @@ export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) *.elf *.srl* *.bin
#---------------------------------------------------------------------------------
else
@ -140,6 +142,12 @@ else
$(ARM9ELF) : $(OFILES)
@echo linking $(notdir $@)
@$(LD) $(LDFLAGS) $(OFILES) $(LIBPATHS) $(LIBS) -o $@
#---------------------------------------------------------------------------------
# rule to build soundbank from music files
#---------------------------------------------------------------------------------
soundbank.bin soundbank.h : $(AUDIOFILES)
#---------------------------------------------------------------------------------
@mmutil $^ -d -osoundbank.bin -hsoundbank.h
#---------------------------------------------------------------------------------
# you need a rule like this for each extension you use as binary data
@ -165,7 +173,7 @@ $(ARM9ELF) : $(OFILES)
grit $< -fts -o$*
-include $(DEPSDIR)/*.d
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------

79
arm9/src/audio.c Normal file
View File

@ -0,0 +1,79 @@
#include <nds.h>
#include <maxmod9.h>
#include <stdio.h>
#include "audio.h"
#include "soundbank.h"
#include "soundbank_bin.h"
mm_sound_effect STARTUP = {
{ SFX_STARTUP } , // id
(int)(1.0f * (1<<10)), // rate
0, // handle
255, // volume
127, // panning
};
mm_sound_effect SELECT = {
{ SFX_SELECT } , // id
(int)(1.0f * (1<<10)), // rate
0, // handle
255, // volume
127, // panning
};
mm_sound_effect BACK = {
{ SFX_BACK } , // id
(int)(1.0f * (1<<10)), // rate
0, // handle
255, // volume
127, // panning
};
mm_sound_effect OK = {
{ SFX_OK } , // id
(int)(1.0f * (1<<10)), // rate
0, // handle
255, // volume
127, // panning
};
mm_sound_effect NG = {
{ SFX_NG } , // id
(int)(1.0f * (1<<10)), // rate
0, // handle
255, // volume
127, // panning
};
mm_sound_effect CHIME = {
{ SFX_CHIME } , // id
(int)(1.0f * (1<<10)), // rate
0, // handle
255, // volume
127, // panning
};
void soundInit() {
mmInitDefaultMem((mm_addr)soundbank_bin);
mmLoadEffect( SFX_STARTUP );
mmLoadEffect( SFX_SELECT );
mmLoadEffect( SFX_BACK );
mmLoadEffect( SFX_OK );
mmLoadEffect( SFX_NG );
}
void soundPlayStartup() {
mmEffectEx(&STARTUP);
}
void soundPlaySelect() {
mmEffectEx(&SELECT);
}
void soundPlayBack() {
mmEffectEx(&BACK);
}
void soundPlayPass() {
mmEffectEx(&OK);
}
void soundPlayFail() {
mmEffectEx(&NG);
}
void soundPlayChime() {
mmEffectEx(&CHIME);
}

13
arm9/src/audio.h Normal file
View File

@ -0,0 +1,13 @@
#include <nds.h>
#include <maxmod9.h>
#include <stdio.h>
#include "soundbank.h"
#include "soundbank_bin.h"
void soundInit();
void soundPlayStartup();
void soundPlaySelect();
void soundPlayBack();
void soundPlayPass();
void soundPlayFail();
void soundPlayChime();

View File

@ -12,6 +12,7 @@
#include "nand/sysfile.h"
#include "nand/hwinfo.h"
#include "video.h"
#include "audio.h"
#include "nitrofs.h"
#include "font.h"
#include <stdlib.h>
@ -21,14 +22,12 @@
TODO:
- LESS NAND WRITES!!!!!
- Write good NAND read routine
- Detect debugger vs dev (less important currently)
- Recover HWInfo byte by byte
- HWInfo verify
- HWInfo sign (can wait for a very long time)
- Why doesn't unmounting NAND get reflected in the file test?
- NandFirm hash checking <-- very very very important!
- Wipe TWLCFG, launcher saves, etc
- Make dummy TWLCFG, launcher saves, etc
- product.log reading and writing
- TAD stuff
- Title verification (exception for HNAG)
@ -85,42 +84,42 @@ static int _mainMenu(int cursor)
clearScreen(cSUB);
clearScreen(cMAIN);
//menu
Menu* m = newMenu();
setMenuHeader(m, "TwlNandTool");
setListHeader(m, "START MENU");
//menu
Menu* m = newMenu();
setMenuHeader(m, "TwlNandTool");
setListHeader(m, "START MENU");
addMenuItem(m, "FileSystem Menu", NULL, 0, "Options such as repairing MBR\n and formatting TWL_MAIN/PHOTO.");
addMenuItem(m, "NandFirm Menu", NULL, 0, "NandFirm (stage2) installers\n and verification.");
addMenuItem(m, "Sys File Menu", NULL, 0, "Create/recover system files\n like HWInfo, FontTable, and\n cert.sys");
addMenuItem(m, "Chip Info Menu", NULL, 0, "Info on the NAND and CPU.");
addMenuItem(m, "---------------", NULL, 0, "");
addMenuItem(m, "Debug1", NULL, 0, "Font display.");
addMenuItem(m, "Debug2", NULL, 0, "MBR corruption test.");
addMenuItem(m, "Debug3", NULL, 0, "NAND AGING test.");
addMenuItem(m, "Exit", NULL, 0, "Leave the program.");
addMenuItem(m, "FileSystem Menu", NULL, 0, "Options such as repairing MBR\n and formatting TWL_MAIN/PHOTO.");
addMenuItem(m, "NandFirm Menu", NULL, 0, "NandFirm (stage2) installers\n and verification.");
addMenuItem(m, "Sys File Menu", NULL, 0, "Create/recover system files\n like HWInfo, FontTable, and\n cert.sys");
addMenuItem(m, "Chip Info Menu", NULL, 0, "Info on the NAND and CPU.");
addMenuItem(m, "---------------", NULL, 0, "");
addMenuItem(m, "Debug1", NULL, 0, "Font display.");
addMenuItem(m, "Debug2", NULL, 0, "MBR corruption test.");
addMenuItem(m, "Debug3", NULL, 0, "NAND AGING test.");
addMenuItem(m, "Exit", NULL, 0, "Leave the program.");
m->cursor = (cursor);
m->cursor = (cursor);
//bottom screen
printMenu(m, 0);
//bottom screen
printMenu(m, 0);
while (!programEnd)
{
swiWaitForVBlank();
scanKeys();
while (!programEnd)
{
swiWaitForVBlank();
scanKeys();
if (moveCursor(m))
printMenu(m, 0);
if (moveCursor(m))
printMenu(m, 0);
if (keysDown() & KEY_A)
break;
}
if (keysDown() & KEY_A)
break;
}
int result = m->cursor;
freeMenu(m);
int result = m->cursor;
freeMenu(m);
return result;
return result;
}
void fifoHandlerPower(u32 value32, void* userdata)
@ -142,38 +141,39 @@ int main(int argc, char **argv)
{
fifoWaitValue32(FIFO_USER_01);
consoleSign = fifoGetValue32(FIFO_USER_01);
consoleSign = fifoGetValue32(FIFO_USER_01);
if (consoleSign == 0x00) {
strcpy(consoleSignName, "prod");
} else {
strcpy(consoleSignName, "dev");
}
if (consoleSign == 0x00) {
strcpy(consoleSignName, "prod");
} else {
strcpy(consoleSignName, "dev");
}
if (consoleSign == 0x00) {
strcpy(consoleType, "Retail");
} else if (consoleSign == 0x02) {
strcpy(consoleType, "Panda");
}/*
if (consoleSign == 0x00) {
strcpy(consoleType, "Retail");
} else if (consoleSign == 0x02) {
strcpy(consoleType, "Panda");
}/*
Do some check here to determine retail, panda, and debugger.
Then block debuggers due to different FW and a higher chance of messing stuff up without an easy fix.
else if (consoleSign == 0x02 || ) {
else if (consoleSign == 0x02 || ) {
strcpy consoleType, "Debugger"
}
*/
}
*/
videoInit();
videoInit();
soundInit();
srand(time(0));
keysSetRepeat(25, 5);
//_setupScreens();
srand(time(0));
keysSetRepeat(25, 5);
//_setupScreens();
fifoSetValue32Handler(FIFO_USER_01, fifoHandlerPower, NULL);
fifoSetValue32Handler(FIFO_USER_03, fifoHandlerBattery, NULL);
fifoSetValue32Handler(FIFO_USER_01, fifoHandlerPower, NULL);
fifoSetValue32Handler(FIFO_USER_03, fifoHandlerBattery, NULL);
iprintf("\x1B[30m");
iprintf("\x1B[30m");
if (!isDSiMode()) {
messageBox("\x1B[31mError:\x1B[30m This app is only for DSi.");
@ -205,75 +205,87 @@ int main(int argc, char **argv)
if (keysDown() & KEY_START || keysDown() & KEY_SELECT) {
} else {
recoverHWInfoDeep();
//recoverHWInfoDeep();
//debug3();
}
clearScreen(cSUB);
clearScreen(cMAIN);
int cursor = 0;
soundPlayStartup();
wait(10);
while (!programEnd)
{
cursor = _mainMenu(cursor);
int cursor = 0;
switch (cursor)
{
while (!programEnd)
{
cursor = _mainMenu(cursor);
case STARTMENU_FS_MENU:
fsMain();
break;
switch (cursor)
{
case STARTMENU_NF_MENU:
nfMain();
break;
case STARTMENU_FS_MENU:
soundPlaySelect();
fsMain();
break;
case STARTMENU_SYSFILE_MENU:
sysfileMain();
break;
case STARTMENU_NF_MENU:
soundPlaySelect();
nfMain();
break;
case STARTMENU_CHIP_MENU:
chipMain();
break;
case STARTMENU_SYSFILE_MENU:
soundPlaySelect();
sysfileMain();
break;
case STARTMENU_NULL:
break;
case STARTMENU_CHIP_MENU:
soundPlaySelect();
chipMain();
break;
case STARTMENU_TEST:
debug1();
break;
case STARTMENU_NULL:
soundPlaySelect();
break;
case STARTMENU_TEST2:
debug2();
break;
case STARTMENU_TEST:
soundPlaySelect();
debug1();
break;
case STARTMENU_TEST3:
debug3();
break;
case STARTMENU_TEST2:
soundPlaySelect();
debug2();
break;
case STARTMENU_EXIT:
programEnd = true;
break;
}
}
case STARTMENU_TEST3:
soundPlaySelect();
debug3();
break;
clearScreen(cSUB);
printf("Unmounting NAND...\n");
if(nandMounted) {
fatUnmount("nand");
case STARTMENU_EXIT:
soundPlaySelect();
programEnd = true;
break;
}
}
clearScreen(cSUB);
agingMode = true;
unmountNAND(false);
unmountNAND(true);
// I think this was some safety thing but it wants to re-write the entire NAND...
// I'm the one person always saying "NANDs aren't that weak", so you know it's excessive when I comment it out.
//printf("Merging stages...\n");
//nandio_shutdown();
//printf("Merging stages...\n");
//nandio_shutdown();
fifoSendValue32(FIFO_USER_02, 0x54495845); // 'EXIT'
fifoSendValue32(FIFO_USER_02, 0x54495845); // 'EXIT'
while (arm7Exiting)
swiWaitForVBlank();
while (arm7Exiting)
swiWaitForVBlank();
return 0;
return 0;
}
int debug1(void) {
@ -281,12 +293,12 @@ int debug1(void) {
clearScreen(cSUB);
iprintf("\n>> Debug1");
iprintf("\n Show font ");
iprintf("\n Show font ");
iprintf("\n--------------------------------");
for (int i = 0; i <= 200; i++) {
printf("%c ", (char)i);
}
for (int i = 0; i <= 200; i++) {
printf("%c ", (char)i);
}
exitFunction();
return success;
@ -296,102 +308,78 @@ int debug2(void) {
success = true;
clearScreen(cSUB);
iprintf("\n>> Corrupt MBR ");
iprintf("\n>> Corrupt MBR ");
iprintf("\n--------------------------------");
memset(sector_buf, 0, 0x200);
iprintf("\nWriting new MBR...");
nand_WriteSectors(0, 1, sector_buf);
iprintf("\nTesting new MBR...");
iprintf("\nTesting new MBR...");
nand_ReadSectors(0, 1, sector_buf);
dsi_nand_crypt(sector_buf, sector_buf, 0, SECTOR_SIZE / AES_BLOCK_SIZE);
if(!parse_mbr(sector_buf, is3DS)) {
iprintf("\n\n \x1B[31mERROR!\x1B[30m Failed to break MBR.");
success = false;
} else {
iprintf("\n\x1B[32mMBR corrupted okay!\x1B[30m");
}
if(!parse_mbr(sector_buf, is3DS)) {
iprintf("\n\n \x1B[31mERROR!\x1B[30m Failed to break MBR.");
success = false;
} else {
iprintf("\n\x1B[32mMBR corrupted okay!\x1B[30m");
}
exitFunction();
return success;
}
int debug3(void) {
success = true;
bool agingSuccess = false;
agingMode = true;
clearScreen(cSUB);
iprintf("\n>> NAND AGING tester ");
iprintf("\n>> NAND AGING tester ");
iprintf("\n--------------------------------");
if (success == true && !cpuPrintInfo()) {
success = false;
}
if (success == true && !nandPrintInfo()) {
success = false;
}
if (success == true && !importNandFirm(true)) {
success = false;
}
if (success == true && !readNandFirm()) {
success = false;
}
if (success == true && !repairMbr(true)) {
success = false;
}
if (success == true && !readMbr()) {
success = false;
}
if (success == true && !mountNAND(false)) {
if (!formatMain() && !mountNAND(false)) {
success = false;
if (cpuPrintInfo()) {
if (nandPrintInfo()) {
if (importNandFirm(1)) {
if (readNandFirm()) {
if (repairMbr(true)) {
if (readMbr()) {
if (mountNAND(false) || (formatMain() && mountNAND(false))) {
if (mountNAND(true) || (formatPhoto() && mountNAND(true))) {
if (recoverHWInfo(false) || recoverHWInfoDeep()) {
if (filetestNAND(false)) {
if (filetestNAND(true)) {
if (makeSystemFolders()) {
if (makeCertChain()) {
if (makeFontTable()) {
if (unmountNAND(false)) {
if (unmountNAND(true)) {
if (filetestNitro()) {
agingSuccess = true;
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
if (success == true && !mountNAND(true)) {
if (!formatPhoto() && !mountNAND(true)) {
success = false;
}
}
if (success == true && !recoverHWInfo(false)) {
if (success == true && !recoverHWInfoDeep()) {
success = false;
}
}
if (success == true && !filetestNAND(false)) {
success = false;
}
if (success == true && !filetestNAND(true)) {
success = false;
}
if (success == true && !makeSystemFolders()) {
success = false;
}
if (success == true && !makeCertChain()) {
success = false;
}
if (success == true && !makeFontTable()) {
success = false;
}
if (success == true && !unmountNAND(false)) {
success = false;
}
if (success == true && !unmountNAND(true)) {
success = false;
}
if (success == true && !filetestNitro()) {
success = false;
}
agingMode = false;
clearScreen(cSUB);
iprintf("\n>> NAND AGING tester result ");
iprintf("\n>> NAND AGING tester result ");
iprintf("\n--------------------------------");
success = agingSuccess;
if (success == true) {
iprintf("\nAll tests passed okay.");
setBackdropColorSub(0x1FE0);
} else {
iprintf("\nTests failed!");
setBackdropColorSub(0x00FF);
}
exitFunction();

View File

@ -1,6 +1,7 @@
#include "menu.h"
#include "main.h"
#include "video.h"
#include "audio.h"
#include "version.h"
#include "nand/nandio.h"
@ -343,20 +344,24 @@ bool moveCursor(Menu* m)
u32 down = keysDownRepeat();
if (down & KEY_DOWN)
if (down & KEY_DOWN) {
soundPlaySelect();
_moveCursor(m, 1);
else if (down & KEY_UP)
} else if (down & KEY_UP) {
soundPlaySelect();
_moveCursor(m, -1);
}
if (down & KEY_RIGHT)
{
soundPlaySelect();
repeat(10)
_moveCursor(m, 1);
}
else if (down & KEY_LEFT)
{
soundPlaySelect();
repeat(10)
_moveCursor(m, -1);
}
@ -382,14 +387,24 @@ char downloadPlayLoading(int number) {
void exitFunction() {
if (agingMode == false) {
wait(25);
if (success == true) {
setBackdropColorSub(0x1FE0);
soundPlayPass();
} else {
setBackdropColorSub(0x00FF);
soundPlayFail();
}
iprintf("\n\n Please Push Select To Return ");
while (true)
{
swiWaitForVBlank();
scanKeys();
if (keysDown() & KEY_SELECT )
if (keysDown() & KEY_SELECT ) {
soundPlayBack();
break;
}
}
} else {
wait(50);

View File

@ -13,6 +13,7 @@
#include "../message.h"
#include "../main.h"
#include "../video.h"
#include "../audio.h"
static size_t i;
@ -47,8 +48,10 @@ static int _chipMenu(int cursor)
if (keysDown() & KEY_A)
break;
if (keysDown() & KEY_B)
if (keysDown() & KEY_B) {
soundPlayBack();
programEnd = true;
}
}
int result = m->cursor;
@ -71,10 +74,12 @@ int chipMain(void)
{
case CHIPMENU_NAND_INFO:
soundPlaySelect();
nandPrintInfo();
break;
case CHIPMENU_CPU_INFO:
soundPlaySelect();
cpuPrintInfo();
break;
}

View File

@ -16,6 +16,7 @@
#include "../main.h"
#include "../video.h"
#include "../menu.h"
#include "../audio.h"
#include "../lib/libfat/include/fat.h"
extern bool nand_Startup();
@ -111,8 +112,10 @@ static int _fsMenu(int cursor)
if (keysDown() & KEY_A)
break;
if (keysDown() & KEY_B)
if (keysDown() & KEY_B) {
soundPlayBack();
programEnd = true;
}
}
int result = m->cursor;
@ -135,56 +138,70 @@ int fsMain(void)
{
case FSMENU_READ_MBR:
soundPlaySelect();
readMbr();
break;
case FSMENU_REPAIR_MBR:
soundPlaySelect();
repairMbr(false);
break;
case FSMENU_FORMAT_MAIN:
soundPlaySelect();
formatMain();
break;
case FSMENU_FORMAT_PHOTO:
soundPlaySelect();
formatPhoto();
break;
case FSMENU_NULL:
soundPlaySelect();
break;
case FSMENU_MOUNT_MAIN:
soundPlaySelect();
mountNAND(false);
break;
case FSMENU_UNMOUNT_MAIN:
soundPlaySelect();
unmountNAND(false);
break;
case FSMENU_MOUNT_PHOTO:
soundPlaySelect();
mountNAND(true);
break;
case FSMENU_UNMOUNT_PHOTO:
soundPlaySelect();
unmountNAND(true);
break;
case FSMENU_MOUNT_NITRO:
soundPlaySelect();
mountNitroFS();
break;
case FSMENU_NULL2:
soundPlaySelect();
break;
case FSMENU_FILETEST_MAIN:
soundPlaySelect();
filetestNAND(false);
break;
case FSMENU_FILETEST_PHOTO:
soundPlaySelect();
filetestNAND(true);
break;
case FSMENU_FILETEST_NITRO:
soundPlaySelect();
filetestNitro();
break;
}
@ -485,7 +502,7 @@ bool filetestNAND(bool isPhoto) {
char partition_path[10];
snprintf(partition_path, 10, isPhoto ? "photo" : "nand");
iprintf("\n>> Read %s file", partition_name);
iprintf("\n>> Read %s file\n", partition_name);
iprintf("\n--------------------------------");
if (isPhoto ? nandPhotoMounted : nandMounted) {

View File

@ -27,16 +27,19 @@ bool clearHWInfoStruct() {
}
hwsData.HWS_HEADER = 0x01000000;
hwsData.HWS_SIZE = 0x1C000000;
hwsData.HWS_LANG = 0x01000000;
hwsData.HWS_LANG = (LANG_BITMAP_JAPAN << 24);
hwsData.HWS_LANG &= 0xFF000000;
//hwsData.HWS_LANG = 0x01000000;
hwsData.HWS_PAD = 0x00000000;
hwsData.HWS_REGION = 0x00;
hwsData.HWS_REGION = LANG_JAPANESE;
strcpy(hwsData.HWS_SERIAL, "AAAMP1234567"); // You're a real one if you understand this serial.
hwsData.HWS_TID = 0x50414E48;
hwsData.HWS_TID = 0x4A414E48;
return true;
}
bool loadHWInfoStruct() {
return true;
bool loadHWInfoStruct(u8 *hwinfo_buf) {
// 0xA4 is the HWInfo size (trimmed)
memcpy(&hwsData, hwinfo_buf, 0xA4);
}
bool recoverHWInfo(bool simple) {
@ -67,15 +70,25 @@ bool recoverHWInfo(bool simple) {
}
if (simple == false) {
agingMode = true;
if (recoverHWInfoOffset(HWS_OFFSET_OTHER)) {
hwinfofound = true;
} else if (recoverHWInfoOffset(HWS_OFFSET_BOX)) {
hwinfofound = true;
} else if (recoverHWInfoOffset(HWS_OFFSET_HANDHELD)) {
hwinfofound = true;
if (!agingMode) {
agingMode = true;
if (recoverHWInfoOffset(HWS_OFFSET_OTHER)) {
hwinfofound = true;
} else if (recoverHWInfoOffset(HWS_OFFSET_BOX)) {
hwinfofound = true;
} else if (recoverHWInfoOffset(HWS_OFFSET_HANDHELD)) {
hwinfofound = true;
}
agingMode = false;
} else {
if (recoverHWInfoOffset(HWS_OFFSET_OTHER)) {
hwinfofound = true;
} else if (recoverHWInfoOffset(HWS_OFFSET_BOX)) {
hwinfofound = true;
} else if (recoverHWInfoOffset(HWS_OFFSET_HANDHELD)) {
hwinfofound = true;
}
}
agingMode = false;
}
clearScreen(cSUB);
@ -179,7 +192,9 @@ bool recoverHWInfoOffset(int address) {
memset(sector_buf, 0, 0xA4);
iprintf("\nLoading HWInfo...");
good_nandio_read(address, 0xA4, file_buf, true);
memcpy(&hwsData, file_buf, 0xA4);
loadHWInfoStruct(file_buf);
success = saveHWInfoSDMC();
clearScreen(cSUB);
@ -232,9 +247,10 @@ bool recoverHWInfoDeep(void) {
}
iprintf("\nDone.");
if (success == true) { // also if (verify)
memset(sector_buf, 0, SECTOR_SIZE);
good_nandio_read(0x10EE00 + (i * SECTOR_SIZE), SECTOR_SIZE, sector_buf, true);
printf("\n%02X%02X%02X", sector_buf[0 + 0xA1], sector_buf[1 + 0xA1], sector_buf[2 + 0xA1]);
memset(file_buf, 0, SECTOR_SIZE);
good_nandio_read(0x10EE00 + (i * SECTOR_SIZE), SECTOR_SIZE, file_buf, true);
printf("\n%02X%02X%02X", file_buf[0 + 0xA1], file_buf[1 + 0xA1], file_buf[2 + 0xA1]);
loadHWInfoStruct(file_buf);
if (!agingMode) {
agingMode = true;
success = saveHWInfoSDMC();
@ -243,7 +259,7 @@ bool recoverHWInfoDeep(void) {
success = saveHWInfoSDMC();
}
clearScreen(cSUB);
iprintf("\n>> Recover HWInfo Secure Deep ");
iprintf("\n>> Recover HWInfo Secure Deep ");
iprintf("\n--------------------------------");
if (success == true) {
iprintf("\nRecovery was ok!");
@ -266,20 +282,26 @@ bool saveHWInfoSDMC(void) {
iprintf("\n>> Save HWInfo Secure to SDMC ");
iprintf("\n--------------------------------");
// I need to do region checking (world/korea/china)
printf("\nRemoving old HWInfo...");
remove(HWS_PATH_SD);
printf("\nWriting HWInfo...");
printf("\nClearing HWInfo buffer...");
memset(file_buf, 0, 0x4000);
FILE *file = fopen(HWS_PATH_SD, "wb");
if(file) {
fwrite(sector_buf, 1, 0xA4, file);
fclose(file);
iprintf("\nFile written.");
} else {
success = false;
iprintf("\nFile failed to open!");
}
// I need to do region checking (world/korea/china)
// ^^^^ huh??? What for? Regions shouldn't be needed HWInfo R/W.
printf("\nRemoving old HWInfo...");
remove(HWS_PATH_SD);
printf("\nWriting HWInfo...");
FILE *file = fopen(HWS_PATH_SD, "wb");
if(file) {
fwrite(sector_buf, 1, 0xA4, file);
fclose(file);
iprintf("\nFile written.");
} else {
success = false;
iprintf("\nFile failed to open!");
}
exitFunction();
return success;

View File

@ -14,12 +14,14 @@
#include "../message.h"
#include "../main.h"
#include "../video.h"
#include "../audio.h"
static size_t i;
enum {
NFMENU_CHECK_VER,
NFMENU_IMPORT,
NFMENU_IMPORT_OLD,
NFMENU_IMPORT_SDMC
};
@ -31,7 +33,8 @@ static int _nfMenu(int cursor)
setListHeader(m, "NandFirm");
addMenuItem(m, "Check NandFirm", NULL, 0, "Check the stage2 (bootloader)\n version and type.");
addMenuItem(m, "Import NandFirm", NULL, 0, "Install the standard stage2\n (bootloader).\n\n This stage2 works normally,\n but it is an updated version:\n - v2265-9336 (prod)\n - v2725-9336 (dev)");
addMenuItem(m, "Import NandFirm", NULL, 0, "Install the standard stage2\n (bootloader).\n\n This stage2 works normally,\n but it is an updated version:\n\n - v2265-9336 (prod)\n - v2725-9336 (dev)");
addMenuItem(m, "Import NandFirm (old)", NULL, 0, "Install the standard stage2\n (bootloader).\n\n This is the release version,\n but it is not the latest ver:\n\n - v2435-8325 (dev/prod)\n\n The updated NandFirm should\n be used instead.");
addMenuItem(m, "Import NandFirm (SDMC)", NULL, 0, "Install the SDMC Launcher\n stage2 (bootloader).\n\n SDMC will remove access to\n the firmware and SHOULD NOT\n BE USED unless otherwise\n told to do so.");
m->cursor = cursor;
@ -50,8 +53,10 @@ static int _nfMenu(int cursor)
if (keysDown() & KEY_A)
break;
if (keysDown() & KEY_B)
if (keysDown() & KEY_B) {
soundPlayBack();
programEnd = true;
}
}
int result = m->cursor;
@ -74,15 +79,23 @@ int nfMain(void)
{
case NFMENU_CHECK_VER:
soundPlaySelect();
readNandFirm();
break;
case NFMENU_IMPORT:
importNandFirm(false);
soundPlaySelect();
importNandFirm(0);
break;
case NFMENU_IMPORT_OLD:
soundPlaySelect();
importNandFirm(2);
break;
case NFMENU_IMPORT_SDMC:
importNandFirm(true);
soundPlaySelect();
importNandFirm(1);
break;
}
}
@ -105,7 +118,7 @@ bool readNandFirm(void) {
printf("\n Ver: ");
for (i = 0; i < 10; i++) {
if (sector_buf[i] == 0x0A) {
if (sector_buf[i] == 0x0A && i < 8) {
printf("-");
} else if (sector_buf[i] == 0x0D) {
// Print nothing
@ -119,17 +132,34 @@ bool readNandFirm(void) {
return success;
}
bool importNandFirm(bool sdmc) {
bool importNandFirm(int firmtype) {
success = true;
clearScreen(cSUB);
iprintf("\n>> Import NandFirm (%s) ", sdmc ? "sdmc" : "menu");
if (firmtype > 2 || firmtype < 0) {
return false;
}
char firmname[10];
switch (firmtype) {
case 0:
snprintf(firmname, 10, "menu");
break;
case 1:
snprintf(firmname, 10, "sdmc");
break;
case 2:
snprintf(firmname, 10, "old");
break;
}
iprintf("\n>> Import NandFirm (%s)\n", firmname);
iprintf("\n--------------------------------");
printf("\nOpening NandFirm...\n");
char file_path[100];
snprintf(file_path, 100, "nitro:/import/%s/%s-launcher.nand", consoleSignName, sdmc ? "sdmc" : "menu");
snprintf(file_path, 100, "nitro:/import/%s/%s-launcher.nand", consoleSignName, firmname);
FILE *file = fopen(file_path, "r");
printf("\n%s\n\n", file_path);

View File

@ -18,4 +18,4 @@ void wait(int ticks);
int nfMain(void);
bool readNandFirm(void);
bool importNandFirm(bool sdmc);
bool importNandFirm(int firmtype);

View File

@ -97,8 +97,7 @@ int parse_mbr(const uint8_t sector0[SECTOR_SIZE], const int is3DS)
return -1;
}
ref_ptable = is3DS?ptable_3DS:ptable_DSi;
// only test the 1st partition now, we've seen variations on the 3rd partition
// and after all we only care about the 1st partition
if (memcmp(&ref_ptable[0], &m->partitions[0], sizeof(mbr_partition_t)))
{
return -2;
@ -108,38 +107,4 @@ int parse_mbr(const uint8_t sector0[SECTOR_SIZE], const int is3DS)
return -2;
}
return 0;
}
/*
// return 0 for valid MBR
int parse_mbr(const uint8_t sector0[SECTOR_SIZE], int is3DS, int verbose) {
const mbr_t *m = (mbr_t*)sector0;
const mbr_partition_t *ref_ptable; // reference partition table
int ret = 0;
if (m->boot_signature_0 != 0x55 || m->boot_signature_1 != 0xaa) {
//printf("invalid boot signature(0x55, 0xaa)\n");
ret = -1;
}
if (!is3DS) {
for (unsigned i = 0; i < sizeof(m->bootstrap); ++i) {
if (m->bootstrap[i]) {
//printf("bootstrap on DSi should be all zero\n");
ret = 0;
break;
}
}
ref_ptable = ptable_DSi;
} else {
ref_ptable = ptable_3DS;
}
// Only check the first two as those are the only ones we mount
// There's some variation in the 3rd
for(int i = 0; i < 2; i++) {
if (memcmp(&ref_ptable[i], &m->partitions[i], sizeof(mbr_partition_t))) {
//printf("invalid partition table\n");
ret = -2;
}
}
return ret;
}
*/
}

View File

@ -16,6 +16,7 @@
#include "../main.h"
#include "../video.h"
#include "../storage.h"
#include "../audio.h"
//static size_t i;
@ -62,8 +63,10 @@ static int _sysfileMenu(int cursor)
if (keysDown() & KEY_A)
break;
if (keysDown() & KEY_B)
if (keysDown() & KEY_B) {
soundPlayBack();
programEnd = true;
}
}
int result = m->cursor;
@ -86,31 +89,39 @@ int sysfileMain(void)
{
case SYSFILEMENU_RECOVER:
soundPlaySelect();
recoverHWInfo(false);
break;
case SYSFILEMENU_RECOVER2:
soundPlaySelect();
recoverHWInfoDeep();
break;
case SYSFILEMENU_NULL:
soundPlaySelect();
break;
case SYSFILEMENU_INIT_FOLDER:
soundPlaySelect();
makeSystemFolders();
break;
case SYSFILEMENU_INIT_S:
soundPlaySelect();
break;
case SYSFILEMENU_INIT_N:
soundPlaySelect();
break;
case SYSFILEMENU_INIT_CERT:
soundPlaySelect();
makeCertChain();
break;
case SYSFILEMENU_INIT_FONT:
soundPlaySelect();
makeFontTable();
break;
}

BIN
sounds/BACK.wav Normal file

Binary file not shown.

BIN
sounds/CHIME.wav Normal file

Binary file not shown.

BIN
sounds/NG.wav Normal file

Binary file not shown.

BIN
sounds/OK.wav Normal file

Binary file not shown.

BIN
sounds/SELECT.wav Normal file

Binary file not shown.

BIN
sounds/STARTUP.wav Normal file

Binary file not shown.