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 LDFLAGS = -specs=ds_arm7.specs -g $(ARCH) -Wl,--nmagic -Wl,-Map,$(notdir $*).map
#LIBS := -ldswifi7 -lmm7 -lnds7 #LIBS := -ldswifi7 -lmm7 -lnds7
LIBS := -lnds7 LIBS := -lmm7 -lnds7
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing # list of directories containing libraries, this must be the top level containing

View File

@ -28,7 +28,7 @@
---------------------------------------------------------------------------------*/ ---------------------------------------------------------------------------------*/
#include "my_sdmmc.h" #include "my_sdmmc.h"
#include <maxmod7.h>
#include <nds.h> #include <nds.h>
#include <string.h> #include <string.h>
@ -117,6 +117,12 @@ int main()
fifoInit(); fifoInit();
touchInit(); touchInit();
mmInstall(FIFO_MAXMOD);
SetYtrigger(202);
installSoundFIFO();
installSystemFIFO();
if (isDSiMode() /*|| ((REG_SCFG_EXT & BIT(17)) && (REG_SCFG_EXT & BIT(18)))*/) if (isDSiMode() /*|| ((REG_SCFG_EXT & BIT(17)) && (REG_SCFG_EXT & BIT(18)))*/)
{ {
u8 *out=(u8*)0x02300000; u8 *out=(u8*)0x02300000;
@ -164,10 +170,6 @@ int main()
SetYtrigger(80); SetYtrigger(80);
installSoundFIFO();
installSystemFIFO();
irqSet(IRQ_VCOUNT, VcountHandler); irqSet(IRQ_VCOUNT, VcountHandler);
irqEnable( IRQ_VBLANK | IRQ_VCOUNT | IRQ_NETWORK); 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 INCLUDES := include src/nand src/lib/libfat/include
DATA := ../data DATA := ../data
GRAPHICS := fonts GRAPHICS := fonts
MUSIC := ../sounds
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
# options for code generation # 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 # 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 # list of directories containing libraries, this must be the top level containing
# include and lib # include and lib
@ -89,8 +90,9 @@ CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
BMPFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.bmp))) BMPFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.bmp)))
PNGFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.png))) 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 # use CXX for linking C++ projects, CC for standard C
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
@ -124,13 +126,13 @@ export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
$(BUILD): $(BUILD):
@[ -d $@ ] || mkdir -p $@ @[ -d $@ ] || mkdir -p $@
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
clean: clean:
@echo clean ... @echo clean ...
@rm -fr $(BUILD) *.elf *.srl* *.bin @rm -fr $(BUILD) *.elf *.srl* *.bin
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
else else
@ -140,6 +142,12 @@ else
$(ARM9ELF) : $(OFILES) $(ARM9ELF) : $(OFILES)
@echo linking $(notdir $@) @echo linking $(notdir $@)
@$(LD) $(LDFLAGS) $(OFILES) $(LIBPATHS) $(LIBS) -o $@ @$(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 # you need a rule like this for each extension you use as binary data
@ -165,7 +173,7 @@ $(ARM9ELF) : $(OFILES)
grit $< -fts -o$* grit $< -fts -o$*
-include $(DEPSDIR)/*.d -include $(DEPSDIR)/*.d
#--------------------------------------------------------------------------------------- #---------------------------------------------------------------------------------------
endif 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/sysfile.h"
#include "nand/hwinfo.h" #include "nand/hwinfo.h"
#include "video.h" #include "video.h"
#include "audio.h"
#include "nitrofs.h" #include "nitrofs.h"
#include "font.h" #include "font.h"
#include <stdlib.h> #include <stdlib.h>
@ -21,14 +22,12 @@
TODO: TODO:
- LESS NAND WRITES!!!!! - LESS NAND WRITES!!!!!
- Write good NAND read routine
- Detect debugger vs dev (less important currently) - Detect debugger vs dev (less important currently)
- Recover HWInfo byte by byte
- HWInfo verify - HWInfo verify
- HWInfo sign (can wait for a very long time) - HWInfo sign (can wait for a very long time)
- Why doesn't unmounting NAND get reflected in the file test? - Why doesn't unmounting NAND get reflected in the file test?
- NandFirm hash checking <-- very very very important! - NandFirm hash checking <-- very very very important!
- Wipe TWLCFG, launcher saves, etc - Make dummy TWLCFG, launcher saves, etc
- product.log reading and writing - product.log reading and writing
- TAD stuff - TAD stuff
- Title verification (exception for HNAG) - Title verification (exception for HNAG)
@ -85,42 +84,42 @@ static int _mainMenu(int cursor)
clearScreen(cSUB); clearScreen(cSUB);
clearScreen(cMAIN); clearScreen(cMAIN);
//menu //menu
Menu* m = newMenu(); Menu* m = newMenu();
setMenuHeader(m, "TwlNandTool"); setMenuHeader(m, "TwlNandTool");
setListHeader(m, "START MENU"); setListHeader(m, "START MENU");
addMenuItem(m, "FileSystem Menu", NULL, 0, "Options such as repairing MBR\n and formatting TWL_MAIN/PHOTO."); 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, "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, "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, "Chip Info Menu", NULL, 0, "Info on the NAND and CPU.");
addMenuItem(m, "---------------", NULL, 0, ""); addMenuItem(m, "---------------", NULL, 0, "");
addMenuItem(m, "Debug1", NULL, 0, "Font display."); addMenuItem(m, "Debug1", NULL, 0, "Font display.");
addMenuItem(m, "Debug2", NULL, 0, "MBR corruption test."); addMenuItem(m, "Debug2", NULL, 0, "MBR corruption test.");
addMenuItem(m, "Debug3", NULL, 0, "NAND AGING test."); addMenuItem(m, "Debug3", NULL, 0, "NAND AGING test.");
addMenuItem(m, "Exit", NULL, 0, "Leave the program."); addMenuItem(m, "Exit", NULL, 0, "Leave the program.");
m->cursor = (cursor); m->cursor = (cursor);
//bottom screen //bottom screen
printMenu(m, 0); printMenu(m, 0);
while (!programEnd) while (!programEnd)
{ {
swiWaitForVBlank(); swiWaitForVBlank();
scanKeys(); scanKeys();
if (moveCursor(m)) if (moveCursor(m))
printMenu(m, 0); printMenu(m, 0);
if (keysDown() & KEY_A) if (keysDown() & KEY_A)
break; break;
} }
int result = m->cursor; int result = m->cursor;
freeMenu(m); freeMenu(m);
return result; return result;
} }
void fifoHandlerPower(u32 value32, void* userdata) void fifoHandlerPower(u32 value32, void* userdata)
@ -142,38 +141,39 @@ int main(int argc, char **argv)
{ {
fifoWaitValue32(FIFO_USER_01); fifoWaitValue32(FIFO_USER_01);
consoleSign = fifoGetValue32(FIFO_USER_01); consoleSign = fifoGetValue32(FIFO_USER_01);
if (consoleSign == 0x00) { if (consoleSign == 0x00) {
strcpy(consoleSignName, "prod"); strcpy(consoleSignName, "prod");
} else { } else {
strcpy(consoleSignName, "dev"); strcpy(consoleSignName, "dev");
} }
if (consoleSign == 0x00) { if (consoleSign == 0x00) {
strcpy(consoleType, "Retail"); strcpy(consoleType, "Retail");
} else if (consoleSign == 0x02) { } else if (consoleSign == 0x02) {
strcpy(consoleType, "Panda"); strcpy(consoleType, "Panda");
}/* }/*
Do some check here to determine retail, panda, and debugger. 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. 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" strcpy consoleType, "Debugger"
} }
*/ */
videoInit(); videoInit();
soundInit();
srand(time(0)); srand(time(0));
keysSetRepeat(25, 5); keysSetRepeat(25, 5);
//_setupScreens(); //_setupScreens();
fifoSetValue32Handler(FIFO_USER_01, fifoHandlerPower, NULL); fifoSetValue32Handler(FIFO_USER_01, fifoHandlerPower, NULL);
fifoSetValue32Handler(FIFO_USER_03, fifoHandlerBattery, NULL); fifoSetValue32Handler(FIFO_USER_03, fifoHandlerBattery, NULL);
iprintf("\x1B[30m"); iprintf("\x1B[30m");
if (!isDSiMode()) { if (!isDSiMode()) {
messageBox("\x1B[31mError:\x1B[30m This app is only for DSi."); 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) { if (keysDown() & KEY_START || keysDown() & KEY_SELECT) {
} else { } else {
recoverHWInfoDeep(); //recoverHWInfoDeep();
//debug3();
} }
clearScreen(cSUB); clearScreen(cSUB);
clearScreen(cMAIN); clearScreen(cMAIN);
int cursor = 0; soundPlayStartup();
wait(10);
while (!programEnd) int cursor = 0;
{
cursor = _mainMenu(cursor);
switch (cursor) while (!programEnd)
{ {
cursor = _mainMenu(cursor);
case STARTMENU_FS_MENU: switch (cursor)
fsMain(); {
break;
case STARTMENU_NF_MENU: case STARTMENU_FS_MENU:
nfMain(); soundPlaySelect();
break; fsMain();
break;
case STARTMENU_SYSFILE_MENU: case STARTMENU_NF_MENU:
sysfileMain(); soundPlaySelect();
break; nfMain();
break;
case STARTMENU_CHIP_MENU: case STARTMENU_SYSFILE_MENU:
chipMain(); soundPlaySelect();
break; sysfileMain();
break;
case STARTMENU_NULL: case STARTMENU_CHIP_MENU:
break; soundPlaySelect();
chipMain();
break;
case STARTMENU_TEST: case STARTMENU_NULL:
debug1(); soundPlaySelect();
break; break;
case STARTMENU_TEST2: case STARTMENU_TEST:
debug2(); soundPlaySelect();
break; debug1();
break;
case STARTMENU_TEST3: case STARTMENU_TEST2:
debug3(); soundPlaySelect();
break; debug2();
break;
case STARTMENU_EXIT: case STARTMENU_TEST3:
programEnd = true; soundPlaySelect();
break; debug3();
} break;
}
clearScreen(cSUB); case STARTMENU_EXIT:
printf("Unmounting NAND...\n"); soundPlaySelect();
if(nandMounted) { programEnd = true;
fatUnmount("nand"); 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 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. // 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"); //printf("Merging stages...\n");
//nandio_shutdown(); //nandio_shutdown();
fifoSendValue32(FIFO_USER_02, 0x54495845); // 'EXIT' fifoSendValue32(FIFO_USER_02, 0x54495845); // 'EXIT'
while (arm7Exiting) while (arm7Exiting)
swiWaitForVBlank(); swiWaitForVBlank();
return 0; return 0;
} }
int debug1(void) { int debug1(void) {
@ -281,12 +293,12 @@ int debug1(void) {
clearScreen(cSUB); clearScreen(cSUB);
iprintf("\n>> Debug1"); iprintf("\n>> Debug1");
iprintf("\n Show font "); iprintf("\n Show font ");
iprintf("\n--------------------------------"); iprintf("\n--------------------------------");
for (int i = 0; i <= 200; i++) { for (int i = 0; i <= 200; i++) {
printf("%c ", (char)i); printf("%c ", (char)i);
} }
exitFunction(); exitFunction();
return success; return success;
@ -296,102 +308,78 @@ int debug2(void) {
success = true; success = true;
clearScreen(cSUB); clearScreen(cSUB);
iprintf("\n>> Corrupt MBR "); iprintf("\n>> Corrupt MBR ");
iprintf("\n--------------------------------"); iprintf("\n--------------------------------");
memset(sector_buf, 0, 0x200); memset(sector_buf, 0, 0x200);
iprintf("\nWriting new MBR..."); iprintf("\nWriting new MBR...");
nand_WriteSectors(0, 1, sector_buf); nand_WriteSectors(0, 1, sector_buf);
iprintf("\nTesting new MBR..."); iprintf("\nTesting new MBR...");
nand_ReadSectors(0, 1, sector_buf); nand_ReadSectors(0, 1, sector_buf);
dsi_nand_crypt(sector_buf, sector_buf, 0, SECTOR_SIZE / AES_BLOCK_SIZE); dsi_nand_crypt(sector_buf, sector_buf, 0, SECTOR_SIZE / AES_BLOCK_SIZE);
if(!parse_mbr(sector_buf, is3DS)) { if(!parse_mbr(sector_buf, is3DS)) {
iprintf("\n\n \x1B[31mERROR!\x1B[30m Failed to break MBR."); iprintf("\n\n \x1B[31mERROR!\x1B[30m Failed to break MBR.");
success = false; success = false;
} else { } else {
iprintf("\n\x1B[32mMBR corrupted okay!\x1B[30m"); iprintf("\n\x1B[32mMBR corrupted okay!\x1B[30m");
} }
exitFunction(); exitFunction();
return success; return success;
} }
int debug3(void) { int debug3(void) {
success = true; bool agingSuccess = false;
agingMode = true; agingMode = true;
clearScreen(cSUB); clearScreen(cSUB);
iprintf("\n>> NAND AGING tester "); iprintf("\n>> NAND AGING tester ");
iprintf("\n--------------------------------"); iprintf("\n--------------------------------");
if (success == true && !cpuPrintInfo()) { if (cpuPrintInfo()) {
success = false; if (nandPrintInfo()) {
} if (importNandFirm(1)) {
if (success == true && !nandPrintInfo()) { if (readNandFirm()) {
success = false; if (repairMbr(true)) {
} if (readMbr()) {
if (success == true && !importNandFirm(true)) { if (mountNAND(false) || (formatMain() && mountNAND(false))) {
success = false; if (mountNAND(true) || (formatPhoto() && mountNAND(true))) {
} if (recoverHWInfo(false) || recoverHWInfoDeep()) {
if (success == true && !readNandFirm()) { if (filetestNAND(false)) {
success = false; if (filetestNAND(true)) {
} if (makeSystemFolders()) {
if (success == true && !repairMbr(true)) { if (makeCertChain()) {
success = false; if (makeFontTable()) {
} if (unmountNAND(false)) {
if (success == true && !readMbr()) { if (unmountNAND(true)) {
success = false; if (filetestNitro()) {
} agingSuccess = true;
if (success == true && !mountNAND(false)) { }
if (!formatMain() && !mountNAND(false)) { }
success = false; }
}
}
}
}
}
}
}
}
}
}
}
}
} }
} }
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; agingMode = false;
clearScreen(cSUB); clearScreen(cSUB);
iprintf("\n>> NAND AGING tester result "); iprintf("\n>> NAND AGING tester result ");
iprintf("\n--------------------------------"); iprintf("\n--------------------------------");
success = agingSuccess;
if (success == true) { if (success == true) {
iprintf("\nAll tests passed okay."); iprintf("\nAll tests passed okay.");
setBackdropColorSub(0x1FE0);
} else { } else {
iprintf("\nTests failed!"); iprintf("\nTests failed!");
setBackdropColorSub(0x00FF);
} }
exitFunction(); exitFunction();

View File

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

View File

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

View File

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

View File

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

View File

@ -14,12 +14,14 @@
#include "../message.h" #include "../message.h"
#include "../main.h" #include "../main.h"
#include "../video.h" #include "../video.h"
#include "../audio.h"
static size_t i; static size_t i;
enum { enum {
NFMENU_CHECK_VER, NFMENU_CHECK_VER,
NFMENU_IMPORT, NFMENU_IMPORT,
NFMENU_IMPORT_OLD,
NFMENU_IMPORT_SDMC NFMENU_IMPORT_SDMC
}; };
@ -31,7 +33,8 @@ static int _nfMenu(int cursor)
setListHeader(m, "NandFirm"); setListHeader(m, "NandFirm");
addMenuItem(m, "Check NandFirm", NULL, 0, "Check the stage2 (bootloader)\n version and type."); 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."); 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; m->cursor = cursor;
@ -50,8 +53,10 @@ static int _nfMenu(int cursor)
if (keysDown() & KEY_A) if (keysDown() & KEY_A)
break; break;
if (keysDown() & KEY_B) if (keysDown() & KEY_B) {
soundPlayBack();
programEnd = true; programEnd = true;
}
} }
int result = m->cursor; int result = m->cursor;
@ -74,15 +79,23 @@ int nfMain(void)
{ {
case NFMENU_CHECK_VER: case NFMENU_CHECK_VER:
soundPlaySelect();
readNandFirm(); readNandFirm();
break; break;
case NFMENU_IMPORT: case NFMENU_IMPORT:
importNandFirm(false); soundPlaySelect();
importNandFirm(0);
break;
case NFMENU_IMPORT_OLD:
soundPlaySelect();
importNandFirm(2);
break; break;
case NFMENU_IMPORT_SDMC: case NFMENU_IMPORT_SDMC:
importNandFirm(true); soundPlaySelect();
importNandFirm(1);
break; break;
} }
} }
@ -105,7 +118,7 @@ bool readNandFirm(void) {
printf("\n Ver: "); printf("\n Ver: ");
for (i = 0; i < 10; i++) { for (i = 0; i < 10; i++) {
if (sector_buf[i] == 0x0A) { if (sector_buf[i] == 0x0A && i < 8) {
printf("-"); printf("-");
} else if (sector_buf[i] == 0x0D) { } else if (sector_buf[i] == 0x0D) {
// Print nothing // Print nothing
@ -119,17 +132,34 @@ bool readNandFirm(void) {
return success; return success;
} }
bool importNandFirm(bool sdmc) { bool importNandFirm(int firmtype) {
success = true; success = true;
clearScreen(cSUB); 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--------------------------------"); iprintf("\n--------------------------------");
printf("\nOpening NandFirm...\n"); printf("\nOpening NandFirm...\n");
char file_path[100]; 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"); FILE *file = fopen(file_path, "r");
printf("\n%s\n\n", file_path); printf("\n%s\n\n", file_path);

View File

@ -18,4 +18,4 @@ void wait(int ticks);
int nfMain(void); int nfMain(void);
bool readNandFirm(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; return -1;
} }
ref_ptable = is3DS?ptable_3DS:ptable_DSi; 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))) if (memcmp(&ref_ptable[0], &m->partitions[0], sizeof(mbr_partition_t)))
{ {
return -2; return -2;
@ -108,38 +107,4 @@ int parse_mbr(const uint8_t sector0[SECTOR_SIZE], const int is3DS)
return -2; return -2;
} }
return 0; 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 "../main.h"
#include "../video.h" #include "../video.h"
#include "../storage.h" #include "../storage.h"
#include "../audio.h"
//static size_t i; //static size_t i;
@ -62,8 +63,10 @@ static int _sysfileMenu(int cursor)
if (keysDown() & KEY_A) if (keysDown() & KEY_A)
break; break;
if (keysDown() & KEY_B) if (keysDown() & KEY_B) {
soundPlayBack();
programEnd = true; programEnd = true;
}
} }
int result = m->cursor; int result = m->cursor;
@ -86,31 +89,39 @@ int sysfileMain(void)
{ {
case SYSFILEMENU_RECOVER: case SYSFILEMENU_RECOVER:
soundPlaySelect();
recoverHWInfo(false); recoverHWInfo(false);
break; break;
case SYSFILEMENU_RECOVER2: case SYSFILEMENU_RECOVER2:
soundPlaySelect();
recoverHWInfoDeep(); recoverHWInfoDeep();
break; break;
case SYSFILEMENU_NULL: case SYSFILEMENU_NULL:
soundPlaySelect();
break; break;
case SYSFILEMENU_INIT_FOLDER: case SYSFILEMENU_INIT_FOLDER:
soundPlaySelect();
makeSystemFolders(); makeSystemFolders();
break; break;
case SYSFILEMENU_INIT_S: case SYSFILEMENU_INIT_S:
soundPlaySelect();
break; break;
case SYSFILEMENU_INIT_N: case SYSFILEMENU_INIT_N:
soundPlaySelect();
break; break;
case SYSFILEMENU_INIT_CERT: case SYSFILEMENU_INIT_CERT:
soundPlaySelect();
makeCertChain(); makeCertChain();
break; break;
case SYSFILEMENU_INIT_FONT: case SYSFILEMENU_INIT_FONT:
soundPlaySelect();
makeFontTable(); makeFontTable();
break; 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.