/*----------------------------------------------------------------- Copyright (C) 2005 - 2013 Michael "Chishm" Chisholm Dave "WinterMute" Murphy Claudio "sverx" This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ------------------------------------------------------------------*/ #include #include #include #include #include #include #include #include "args.h" #include "file_browse.h" #include "font.h" #include "hbmenu_consolebg.h" #include "iconTitle.h" #include "nds_loader_arm9.h" using namespace std; void InitGUI(void) { iconTitleInit(); videoSetModeSub(MODE_4_2D); vramSetBankC(VRAM_C_SUB_BG); int bgSub = bgInitSub(3, BgType_Bmp8, BgSize_B8_256x256, 1, 0); PrintConsole *console = consoleInit(0, 0, BgType_Text4bpp, BgSize_T_256x256, 4, 6, false, false); dmaCopy(hbmenu_consolebgBitmap, bgGetGfxPtr(bgSub), 256*256); ConsoleFont font; font.gfx = (u16*)fontTiles; font.pal = (u16*)fontPal; font.numChars = 95; font.numColors = (fontPalLen / 2); font.bpp = 4; font.asciiOffset = 32; font.convertSingleColor = true; consoleSetFont(console, &font); dmaCopy(hbmenu_consolebgPal, BG_PALETTE_SUB, 256*2); BG_PALETTE_SUB[255] = RGB15(31,31,31); keysSetRepeat(25,5); consoleSetWindow(console, 1, 1, 30, 22); } int stop(void) { while (1) { swiWaitForVBlank(); scanKeys(); if (keysHeld())break; } return 0; } int FileBrowser() { consoleClear(); vector extensionList = argsGetExtensionList(); chdir("/nds"); while(1) { string filename = browseForFile(extensionList); // Construct a command line vector argarray; if (!argsFillArray(filename, argarray)) { printf("Invalid NDS or arg file selected\n"); } else { iprintf("Running %s with %d parameters\n", argarray[0].c_str(), argarray.size()); // Make a copy of argarray using C strings, for the sake of runNdsFile vector c_args; for (const auto& arg: argarray) { c_args.push_back(arg.c_str()); } // Try to run the NDS file with the given arguments int err = runNdsFile(c_args[0], c_args.size(), &c_args[0]); iprintf("Start failed. Error %i\n", err); } argarray.clear(); } return stop(); } int main(int argc, char **argv) { // overwrite reboot stub identifier // so tapping power on DSi returns to DSi menu extern u64 *fake_heap_end; *fake_heap_end = 0; InitGUI(); printf ("\n\n\n\n\n\n\n\n\n\n Initializing FAT ...\n"); if (!fatInitDefault()) { consoleClear(); printf ("\n\n\n\n\n\n\n\n\n\n FAT init failed! \n"); return stop(); } FileBrowser(); return 0; }