#endif
#include "../../../source/config.h"
-#define CODE_PATH PATH_EXEFS "/0000000000000000"
+#define CODE_PATH PATH_EXEFS "/0000000000000000"
+#define LANG_PATH PATH_LOCEMU "/0000000000000000"
-static const char hexDigits[] = "0123456789ABCDEF";
+const char hexDigits[] = "0123456789ABCDEF";
int
fileOpen(Handle *file, FS_ArchiveID id, const char *path, int flags)
return;
}
+void
+hexdump_titleid(u64 progId, char* buf) {
+ u32 i = strlen(buf) - 1;
+ while (progId) {
+ buf[i--] = hexDigits[(u32)(progId & 0xF)];
+ progId >>= 4;
+ }
+}
+
static int
loadTitleLocaleConfig(u64 progId, u8 *regionId, u8 *languageId)
{
// This really does need a rewrite.
- char path[] = "/corbenik/locale/0000000000000000";
- u32 i = 32;
- while (progId) {
- path[i--] = hexDigits[(u32)(progId & 0xF)];
- progId >>= 4;
- }
+ char path[] = LANG_PATH;
+ hexdump_titleid(progId, path);
static const char *regions[] = { "JPN", "USA", "EUR", "AUS", "CHN", "KOR", "TWN" };
static const char *languages[] = { "JA", "EN", "FR", "DE", "IT", "ES", "ZH", "KO", "NL", "PT", "RU", "TW" };
u32 highTid = progId >> 0x20;
char code_path[] = CODE_PATH;
- u32 i = strlen(code_path) - 1;
Handle code_f;
- while (progId) {
- code_path[i--] = hexDigits[(u32)(progId & 0xF)];
- progId >>= 4;
- }
+ hexdump_titleid(progId, code_path);
u32 len;
#ifndef LOADER
extern int is_n3ds;
+static const char hexDigits[] = "0123456789ABCDEF";
#else
int is_n3ds = 1; // TODO - We don't really need to care, but it should still work from loader
#endif
return 0;
}
+void hexdump_titleid(uint64_t tid, char* path);
+
#ifdef LOADER
int
execb(uint64_t tid, uint16_t ver, uint8_t *text_mem, uint32_t text_len, uint8_t *data_mem, uint32_t data_len, uint8_t *ro_mem, uint32_t ro_len)
uint32_t patch_len;
#ifdef LOADER
char cache_path[] = PATH_LOADER_CACHE "/0000000000000000";
- int len = strlen(cache_path) - 16;
-
- uint8_t *title_buf = (uint8_t *)&tid;
- for (int j = 0; j < 8; j++) {
- cache_path[len + (j * 2)] = ("0123456789ABCDEF")[(title_buf[j] >> 4) & 0x0f];
- cache_path[len + (j * 2) + 1] = ("0123456789ABCDEF")[title_buf[j] & 0x0f];
- }
+ hexdump_titleid(tid, cache_path);
static uint8_t patch_dat[MAX_PATCHSIZE];
fprintf(stderr, "patch: %s\n", patch->name);
for (uint32_t i = 0; i < patch->titles; i++, title_buf += 8) {
- // FIXME - This is outputting once per boot. We need to detect and nuke the cache.
char cache_path[] = PATH_LOADER_CACHE "/0000000000000000";
- int len = strlen(cache_path) - 16;
- for (int j = 0; j < 8; j++) {
- cache_path[len + (j * 2)] = ("0123456789ABCDEF")[(title_buf[j] >> 4) & 0x0f];
- cache_path[len + (j * 2) + 1] = ("0123456789ABCDEF")[title_buf[j] & 0x0f];
+ uint32_t len = strlen(cache_path) - 1;
+ uint64_t prog = *(uint64_t*)title_buf;
+ while (prog) {
+ title_buf[i--] = hexDigits[(uint32_t)(prog & 0xF)];
+ prog >>= 4;
}
fprintf(stderr, " cache: %s\n", &cache_path[len]);
}
} else {
// BOOT patch
- // FIXME - This is outputting once per boot. We need to detect and nuke the cache.
char cache_path[] = PATH_LOADER_CACHE "/BOOT";
char reset = 0xFF;
#define PATH_CONFIG_DIR PATH_CFW "/config" // Config file directory.
#define PATH_CONFIG PATH_CONFIG_DIR "/main.conf" // Config file.
-#define PATH_LOCEMU PATH_CONFIG_DIR "/langemu.conf" // Locale emulation config
+#define PATH_LOCEMU PATH_CONFIG_DIR "/locale" // Locale emulation config
#define PATH_CPU_CFG PATH_CONFIG_DIR "/cpu.conf" // CPU settings config
#define PATH_PATCHES PATH_CFW "/patch" // Patch binary folder.
#define PATH_KEYS PATH_CFW "/keys" // Keyfiles will be loaded from this dir, and
// additionally the root if not found.
-#define PATH_EXEFS PATH_CFW "/exe" // ExeFS overrides, named like '<titleid>.exefs' - NYI
+
+#define PATH_EXEFS PATH_CFW "/exe" // ExeFS overrides, named by titleid
#define PATH_BITS PATH_CFW "/bits" // Path to misc bits we need (emunand code, reboot code, etc)
#define PATH_TWL_FIRMKEY PATH_KEYS "/twl.key"
#define PATH_AGB_FIRMKEY PATH_KEYS "/agb.key"
-// These are used with O3DS units. Keep in mind I have no way to test this.
-#define PATH_NATIVE_FIRMKEY_2 PATH_KEYS "/native_old.key"
-#define PATH_TWL_FIRMKEY_2 PATH_KEYS "/twl_old.key"
-#define PATH_AGB_FIRMKEY_2 PATH_KEYS "/agb_old.key"
-
#define PATH_SLOT0X11KEY96 PATH_KEYS "/11.key"
#define PATH_ALT_SLOT0X11KEY96 "/slot0x11key96.bin" // Hey, your perrogative, buddy. I like cleaned up