bool Neek2oLoadKernel (void) { char path[256]; Debug ("Neek2oLoadKernel: begin"); //mt_Lock(); *path = '\0'; if (devices_Get(DEV_USB)) { sprintf (path, "%s://sneek/kernel.bin", devices_Get(DEV_USB)); kernel = fsop_ReadFile (path, 0, &kernelsize); } if (!kernel && devices_Get(DEV_SD)) { sprintf (path, "%s://sneek/kernel.bin", devices_Get(DEV_SD)); kernel = fsop_ReadFile (path, 0, &kernelsize); } //mt_Lock(); Debug ("Neek2oLoadKernel: found on %s (size = %d)", path, kernelsize); Debug ("Neek2oLoadKernel: end (0x%X)", kernel); if (!kernel ) return false; return true; }
bool ExternalBooter_LoadBins(const char *binDir) { extldr_ptr = fsop_ReadFile(fmt("%s/ext_loader.bin", binDir), &extldr_size); if(extldr_size == 0 || extldr_ptr == NULL) return false; booter_ptr = fsop_ReadFile(fmt("%s/ext_booter.bin", binDir), &booter_size); if(booter_size > 0 && booter_ptr != NULL) return true; free(extldr_ptr); extldr_ptr = NULL; extldr_size = 0; return false; }
void LoadTitlesTxt (void) { char txtpath[64]; sprintf (txtpath, "%s://ploader/titles.txt", vars.defMount); Video_WaitPanel (TEX_HGL, 0, "Please wait...|Loading titles.txt"); //mt_Lock(); vars.titlestxt = (char*)fsop_ReadFile (txtpath, 0, NULL); //mt_Unlock(); }
static char *GetLongdescFromXML (int ai) { char cfg[256]; char *buff; char *longdesc = NULL; sprintf (cfg, "%s://apps/%s/meta.xml", apps[ai].mount, apps[ai].path); buff = (char*)fsop_ReadFile (cfg, 0, NULL); if (!buff || strlen(buff) == 0) return NULL; int l; char *p1,*p2; char token[256]; ///////////////////////////////////////////////// // get long_description p1 = buff; strcpy (token, "<long_description>"); p1 = strstr (p1, token); if (p1) { p2 = strstr (p1, "</long_description>"); if (p2) { p1 += strlen(token); if (p2 > p1) { // we have the name while (*p1 <= 32 && p1 < p2) p1++; l = p2-p1; if (l > 2048) l = 2048; longdesc = malloc (l + 64); // more space for cr/lf encoding strncpy (longdesc, p1, l); longdesc[l] = 0; } } } return longdesc; }
bool SFont::fromFile(const char *path, u32 size, u32 lspacing, u32 w, u32 idx, const char *fontname) { fSize = min(max(6u, size), 1000u); weight = min(w, 32u); index = idx = 0; lineSpacing = min(max(6u, lspacing), 1000u); if(data != NULL) free(data); data = fsop_ReadFile(path, &dataSize); if(data == NULL) return false; DCFlushRange(data, dataSize); memcpy(name, fontname, 127); font = new FreeTypeGX(); font->loadFont(data, dataSize, fSize, weight, index, false); return true; }
// path is the full path to iso image bool DEVO_Boot (char *path, u8 memcardId, bool widescreen, bool activity_led, bool wifi) { //Read in loader.bin char loader_path[256]; Debug ("DEVO_Boot: %s", path); snprintf(loader_path, sizeof (loader_path), "%s://ploader/plugins/loader.bin", vars.defMount); loader_bin = fsop_ReadFile (loader_path, 0, NULL); if (!loader_bin) return false; Debug ("DEVO_Boot: loader in memory"); //start writing cfg to mem struct stat st; char full_path[256]; int data_fd; char gameID[7]; FILE *f = fopen(path, "rb"); if (!f) { free (loader_bin); return false; } fread ((u8*)0x80000000, 1, 32, f); fclose (f); memcpy (&gameID, (u8*)0x80000000, 6); stat (path, &st); // fill out the Devolution config struct memset(DEVO_CONFIG, 0, sizeof(*DEVO_CONFIG)); DEVO_CONFIG->signature = DEVO_CONFIG_SIG; DEVO_CONFIG->version = DEVO_CONFIG_VERSION; DEVO_CONFIG->device_signature = st.st_dev; DEVO_CONFIG->disc1_cluster = st.st_ino; // Pergame options if(wifi) DEVO_CONFIG->options |= DEVO_CONFIG_WIFILOG; if(widescreen) DEVO_CONFIG->options |= DEVO_CONFIG_WIDE; if(!activity_led) DEVO_CONFIG->options |= DEVO_CONFIG_NOLED; // make sure these directories exist, they are required for Devolution to function correctly snprintf(full_path, sizeof(full_path), "%s:/apps", fsop_GetDev (path)); fsop_MakeFolder(full_path); snprintf(full_path, sizeof(full_path), "%s:/apps/gc_devo", fsop_GetDev (path)); fsop_MakeFolder(full_path); if (!IsGCCardAvailable ()) { char cardname[64]; if (memcardId == 0) { if(gameID[3] == 'J') //Japanese Memory Card sprintf (cardname, "memcard_jap.bin"); else sprintf (cardname, "memcard.bin"); } else { if(gameID[3] == 'J') //Japanese Memory Card sprintf (cardname, "memcard%u_jap.bin", memcardId); else sprintf (cardname, "memcard%u.bin", memcardId); } Debug ("DEVO_Boot: using emulated card"); // find or create a memcard file for emulation(as of devolution r115 it doesn't need to be 16MB) // this file can be located anywhere since it's passed by cluster, not name if(gameID[3] == 'J') //Japanese Memory Card snprintf(full_path, sizeof(full_path), "%s:/apps/gc_devo/%s", fsop_GetDev (path), cardname); else snprintf(full_path, sizeof(full_path), "%s:/apps/gc_devo/%s", fsop_GetDev (path), cardname); // check if file doesn't exist if (stat(full_path, &st) == -1) { // need to create it data_fd = open(full_path, O_WRONLY|O_CREAT); if (data_fd >= 0) { // make it 16MB, if we're creating a new memory card image //gprintf("Resizing memcard file...\n"); ftruncate(data_fd, 16<<20); if (fstat(data_fd, &st) == -1) { // it still isn't created. Give up. st.st_ino = 0; } close(data_fd); } else { // couldn't open or create the memory card file st.st_ino = 0; } } } else { Debug ("DEVO_Boot: using real card"); st.st_ino = 0; } // set FAT cluster for start of memory card file // if this is zero memory card emulation will not be used DEVO_CONFIG->memcard_cluster = st.st_ino; // flush disc ID and Devolution config out to memory DCFlushRange((void*)0x80000000, 64); Shutdown (); // Configure video mode as "suggested" to devolution GXRModeObj *vidmode; if (gameID[3] == 'E' || gameID[3] == 'J') vidmode = &TVNtsc480IntDf; else vidmode = &TVPal528IntDf; static u8 *sfb = NULL; sfb = SYS_AllocateFramebuffer(vidmode); VIDEO_ClearFrameBuffer(vidmode, sfb, COLOR_BLACK); sfb = MEM_K0_TO_K1(sfb); VIDEO_Configure(vidmode); VIDEO_SetNextFramebuffer(sfb); VIDEO_SetBlack(FALSE); VIDEO_Flush(); VIDEO_WaitVSync(); VIDEO_WaitVSync(); // the Devolution blob has an ID string at offset 4 gprintf((const char*)loader_bin + 4); // devolution seems to like hbc stub. So we can force it. ((void(*)(void))loader_bin)(); return true; }
static void ParseXML (int ai) { char cfg[256]; char *buff; sprintf (cfg, "%s://apps/%s/meta.xml", apps[ai].mount, apps[ai].path); //mt_Lock(); buff = (char*)fsop_ReadFile (cfg, 0, NULL); //mt_Unlock(); if (!buff || strlen(buff) == 0) return; int l; int found; char folder[] = "(folder)"; char *p1,*p2; char token[256]; char args[1024]; ///////////////////////////////////////////////// // Now remove all comments from the buffer p1 = buff; do { found = 0; p1 = strstr (p1, "<!--"); if (!p1) break; p2 = strstr (p1, "-->"); if (!p2) break; if (p2 > p1) { found = 1; p2 += 3; while (p1 < p2) { *p1 = ' '; p1++; } p1 = p2; } } while (found); if (strstr (buff, "<no_ios_reload/>")) apps[ai].iosReload = 0; else apps[ai].iosReload = 1; ///////////////////////////////////////////////// // scan for application name p1 = buff; strcpy (token, "<version>"); p1 = strstr (p1, token); if (p1) { p2 = strstr (p1, "</version>"); if (p2) { p1 += strlen(token); if (p2 > p1) { // we have the name l = p2-p1; apps[ai].version = malloc (l+1); strncpy (apps[ai].version, p1, l); apps[ai].version[l] = 0; } } } ///////////////////////////////////////////////// // scan for application name p1 = buff; strcpy (token, "<name>"); p1 = strstr (p1, token); if (p1) { p2 = strstr (p1, "</name>"); if (p2) { p1 += strlen(token); if (p2 > p1) { // we have the name, check if start with space or lower chars while (*p1 <= 32 && p1 < p2) p1++; l = p2-p1; apps[ai].name = malloc (l+1); strncpy (apps[ai].name, p1, l); apps[ai].name[l] = 0; } } } ///////////////////////////////////////////////// // scan for application description p1 = buff; strcpy (token, "<short_description>"); p1 = strstr (p1, token); if (p1) { p2 = strstr (p1, "</short_description>"); if (p2) { p1 += strlen(token); if (p2 > p1) { // we have the name while (*p1 <= 32 && p1 < p2) p1++; if (apps[ai].type == AT_FOLDER) { l = (p2-p1) + strlen(folder); if (l > 2047) l = 2047; apps[ai].desc = malloc (l + 64); // more space for cr/lf encoding strcpy (apps[ai].desc, folder); strcat (apps[ai].desc, " "); strncpy (apps[ai].desc, p1, l - strlen(folder)); apps[ai].desc[l] = 0; } else { l = p2-p1; if (l > 2047) l = 2047; apps[ai].desc = malloc (l + strlen(folder) + 64); // more space for cr/lf encoding strncpy (apps[ai].desc, p1, l); apps[ai].desc[l] = 0; } } } } if (!apps[ai].desc && apps[ai].type == AT_FOLDER) { apps[ai].desc = calloc (strlen(folder) + 1,1); strcpy (apps[ai].desc, folder); } ///////////////////////////////////////////////// // scan for args args[0] = 0; p1 = buff; do { found = 0; strcpy (token, "<arg>"); p1 = strstr (p1, token); if (!p1) break; p2 = strstr (p1, "</arg>"); if (!p2) break; p1 += strlen(token); if (p2 > p1) { found = 1; strncat (args, p1, (int)(p2-p1)); strcat (args, ";"); } } while (found); if (strlen(args) > 0) { apps[ai].args = malloc (strlen(args)+1); strcpy (apps[ai].args, args); } free (buff); return; }