From b7bf149dc715ca6c520138afbf33de7578cee78f Mon Sep 17 00:00:00 2001 From: JeffRuLz Date: Fri, 14 Sep 2018 13:02:46 -0500 Subject: [PATCH] Add files via upload --- Makefile | 15 +++++++++++++-- src/installmenu.c | 20 ++++++++++++++++++-- src/testmenu.c | 1 - src/titlemenu.c | 44 +++++++++++++++++++++++++++----------------- 4 files changed, 58 insertions(+), 22 deletions(-) diff --git a/Makefile b/Makefile index af7775c..3c58374 100644 --- a/Makefile +++ b/Makefile @@ -20,11 +20,15 @@ BUILD := build SOURCES := src DATA := data INCLUDES := include +#GAME_ICON := $(CURDIR)/icon.bmp GAME_TITLE := TMFH GAME_SUBTITLE1 := Title Manager for HiyaCFW GAME_SUBTITLE2 := JeffRuLz +GAME_CODE := TMFH +GAME_LABEL := TITLEMANFH + #--------------------------------------------------------------------------------- # options for code generation #--------------------------------------------------------------------------------- @@ -111,8 +115,9 @@ endif #--------------------------------------------------------------------------------- $(BUILD): @[ -d $@ ] || mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile + @echo built ... $(notdir $@) + #--------------------------------------------------------------------------------- clean: @echo clean ... @@ -126,6 +131,12 @@ else #--------------------------------------------------------------------------------- $(OUTPUT).nds : $(OUTPUT).elf $(OUTPUT).elf : $(OFILES) + +$(OUTPUT).nds: $(OUTPUT).elf + @ndstool -u "00030004" \ + -g "$(GAME_CODE)" "00" "$(GAME_LABEL)" \ + -c $(OUTPUT).nds -9 $(OUTPUT).elf \ + -b $(GAME_ICON) "$(GAME_TITLE);$(GAME_SUBTITLE1);$(GAME_SUBTITLE2)" #--------------------------------------------------------------------------------- %.bin.o : %.bin diff --git a/src/installmenu.c b/src/installmenu.c index 8904e6e..126ee51 100644 --- a/src/installmenu.c +++ b/src/installmenu.c @@ -393,7 +393,7 @@ void install(char* fpath) if (!f) { - iprintf("Error: could not open file.\nPress B to exit.\n"); + iprintf("Error: could not open file.\n\nPress B to exit.\n"); keyWait(KEY_A | KEY_B); } else @@ -408,6 +408,22 @@ void install(char* fpath) fseek(f, header.ndshdr.bannerOffset, SEEK_SET); fread(&banner, sizeof(tNDSBanner), 1, f); } +/* + //Check header size + if (header.ndshdr.headerSize != 0x4000) + { + iprintf("Error: no DSi header."); + goto error; + } +*/ + //Check high title id + if (header.tid_high != 0x00030004 && + header.tid_high != 0x00030005 && + header.tid_high != 0x00030015) + { + iprintf("This file cannot be installed.\nInvalid title ID."); + goto error; + } //Print file size int fileSize = -1; @@ -635,7 +651,7 @@ complete: error: fclose(f); - iprintf("\nInstallation failed.\nPress B to exit.\n"); + iprintf("\nInstallation failed.\n\nPress B to exit.\n"); keyWait(KEY_A | KEY_B); return; diff --git a/src/testmenu.c b/src/testmenu.c index a844b5b..d808136 100644 --- a/src/testmenu.c +++ b/src/testmenu.c @@ -7,7 +7,6 @@ void testMenu() consoleClear(); iprintf("Storage Check Test\n\n"); - iprintf("Verify these are accurate and\nreport if they're not.\n"); consoleSelect(&bottomScreen); consoleClear(); diff --git a/src/titlemenu.c b/src/titlemenu.c index 8f2731d..ffdd204 100644 --- a/src/titlemenu.c +++ b/src/titlemenu.c @@ -435,28 +435,38 @@ void subMenu() else { - tNDSHeader header; - tNDSBanner banner; + int fsize = getFileSize(f); - fread(&header, sizeof(tNDSHeader), 1, f); - fseek(f, header.bannerOffset, SEEK_SET); - fread(&banner, sizeof(tNDSBanner), 1, f); - fclose(f); + if (fsize > getSDCardFree()) + messageBox("Not enough free space on SD card.\n"); - char outpath[256]; - sprintf(outpath, "%s%.12s - %.4s.nds", ROM_PATH, header.gameTitle, header.gameCode); - - char msg[512]; - sprintf(msg, "Dump title to\n%s\n", outpath); - - if (choiceBox(msg) == YES) + else { - if (copyFile(fpath, outpath) == 1) - messageBox("Title saved.\n"); - else - messageBox("Title dump failed.\n"); + tNDSHeader header; + tNDSBanner banner; + + fread(&header, sizeof(tNDSHeader), 1, f); + fseek(f, header.bannerOffset, SEEK_SET); + fread(&banner, sizeof(tNDSBanner), 1, f); + fclose(f); + + char outpath[256]; + sprintf(outpath, "%s%.12s - %.4s.nds", ROM_PATH, header.gameTitle, header.gameCode); + + char msg[512]; + sprintf(msg, "Dump title to\n%s\n", outpath); + + if (choiceBox(msg) == YES) + { + if (copyFile(fpath, outpath) == 1) + messageBox("Title saved.\n"); + else + messageBox("Title dump failed.\n"); + } } } + + fclose(f); } break;