s32 Enable_Emu(int selection) { if (mounted != 0) return -1; if (selection == 0) return 0; s32 ret; nandDevice *ndev = NULL; ndev = &ndevList[selection]; ret = Nand_Mount(ndev); if (ret < 0) { Print(" ERROR Mount! (ret = %d)\n", ret); return ret; } ret = Nand_Enable(ndev); if (ret < 0) { Print(" ERROR Enable! (ret = %d)\n", ret); Nand_Unmount(ndev); return ret; } u32 temp = 0; ret = ISFS_ReadDir("/", NULL, &temp); if (ret < 0) { Print("ISFS_ReadDir('/') failed ret = %d. No FAT partition?", ret); Nand_Disable(); Nand_Unmount(ndev); return ret; } mounted = selection; return 0; }
void Menu_NandDevice(void) { s32 ret, selected = 0; /* Disable NAND emulator */ if (ndev) { Nand_Unmount(ndev); Nand_Disable(); } /* Select source device */ if (gConfig.nandDeviceIndex < 0) { for (;;) { /* Clear console */ Con_Clear(); /* Selected device */ ndev = &ndevList[selected]; printf("\t>> Select NAND emulator device: < %s >\n\n", ndev->name); printf("\t Press LEFT/RIGHT to change the selected device.\n\n"); printf("\t Press A button to continue.\n"); printf("\t Press HOME button to restart.\n\n"); u32 buttons = WaitButtons(); /* LEFT/RIGHT buttons */ if (buttons & WPAD_BUTTON_LEFT) { if ((--selected) <= -1) selected = (NB_NAND_DEVICES - 1); } if (buttons & WPAD_BUTTON_RIGHT) { if ((++selected) >= NB_NAND_DEVICES) selected = 0; } /* HOME button */ if (buttons & WPAD_BUTTON_HOME) Restart(); /* A button */ if (buttons & WPAD_BUTTON_A) break; } } else { ndev = &ndevList[gConfig.nandDeviceIndex]; } /* No NAND device */ if (!ndev->mode) return; printf("[+] Enabling NAND emulator..."); fflush(stdout); /* Mount NAND device */ ret = Nand_Mount(ndev); if (ret < 0) { printf(" ERROR! (ret = %d)\n", ret); goto err; } /* Enable NAND emulator */ ret = Nand_Enable(ndev); if (ret < 0) { printf(" ERROR! (ret = %d)\n", ret); goto err; } else printf(" OK!\n"); return; err: printf("\n"); printf(" Press any button to continue...\n"); WaitButtons(); /* Prompt menu again */ Menu_NandDevice(); }