mirror of
https://github.com/ApacheThunder/ntr-hb-menu.git
synced 2025-06-18 19:25:31 -04:00

* Text on icon area of top screen graphics show "No Icon" instead of original text of DS Cart. This text is only visible if no NDS file is selected or an NDS file that is selected has no icon. * Fix top screen text on load to display HBMenu instead of Acekard 2i (this project was originally setup as a bootstrap for that cart when I initially did this UI overhaul) * Center text for Fat Init Fail error text for bottom screen. * Added new line of text for bottom screen displayed during FAT init. Only really visible if you have an especially slow card or if DLDI init hangs. This replaces original HBMenu's extra text that used to be displayed with it's name on top screen during init.
112 lines
3.2 KiB
C++
112 lines
3.2 KiB
C++
/*-----------------------------------------------------------------
|
|
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 <nds.h>
|
|
#include <stdio.h>
|
|
#include <fat.h>
|
|
#include <sys/stat.h>
|
|
#include <limits.h>
|
|
|
|
#include <string.h>
|
|
#include <unistd.h>
|
|
|
|
#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<string> extensionList = argsGetExtensionList();
|
|
chdir("/nds");
|
|
while(1) {
|
|
string filename = browseForFile(extensionList);
|
|
// Construct a command line
|
|
vector<string> 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<const char*> 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;
|
|
}
|
|
|