//--------------------------------------------------------------------------------- bool sdio_IsInserted() { //--------------------------------------------------------------------------------- fifoSendValue32(FIFO_SDMMC,SDMMC_SD_IS_INSERTED); fifoWaitValue32(FIFO_SDMMC); int result = fifoGetValue32(FIFO_SDMMC); return result == 1; }
//--------------------------------------------------------------------------------- bool sdio_Startup() { //--------------------------------------------------------------------------------- fifoSendValue32(FIFO_SDMMC,SDMMC_HAVE_SD); while(!fifoCheckValue32(FIFO_SDMMC)); int result = fifoGetValue32(FIFO_SDMMC); if(result==0) return false; fifoSendValue32(FIFO_SDMMC,SDMMC_SD_START); fifoWaitValue32(FIFO_SDMMC); result = fifoGetValue32(FIFO_SDMMC); return result == 0; }
//--------------------------------------------------------------------------------- bool sdio_WriteSectors(sec_t sector, sec_t numSectors,const void* buffer) { //--------------------------------------------------------------------------------- FifoMessage msg; DC_FlushRange(buffer,numSectors * 512); msg.type = SDMMC_SD_WRITE_SECTORS; msg.sdParams.startsector = sector; msg.sdParams.numsectors = numSectors; msg.sdParams.buffer = (void*)buffer; fifoSendDatamsg(FIFO_SDMMC, sizeof(msg), (u8*)&msg); fifoWaitValue32(FIFO_SDMMC); int result = fifoGetValue32(FIFO_SDMMC); return result == 0; }
int main( int argc, char **argv) { // defaultExceptionHandler(); if (fatInitDefault()) { fifoWaitValue32(FIFO_USER_02); if (fifoGetValue32(FIFO_USER_01) == 0) { int size = 32; FILE* ResetData = fopen("sd:/hiya/ResetData.bin","rb"); fread((void*)0x02000300,1,size,ResetData); fclose(ResetData); fifoSendValue32(FIFO_USER_08, 1); for (int i = 0; i < 5; i++) { swiWaitForVBlank(); } } LoadSettings(); bool gotoSettings = false; if (access("sd:/hiya/settings.ini", F_OK)) { gotoSettings = true; } scanKeys(); if(keysHeld() & KEY_SELECT) gotoSettings = true; if(gotoSettings) { // Subscreen as a console videoSetMode(MODE_0_2D); vramSetBankG(VRAM_G_MAIN_BG); videoSetModeSub(MODE_0_2D); vramSetBankH(VRAM_H_SUB_BG); int pressed = 0; bool menuprinted = true; while(1) { if(menuprinted) { consoleInit(NULL, 0, BgType_Text4bpp, BgSize_T_256x256, 15, 0, true, true); consoleClear(); printf("HiyaCFW v1.0 configuration\n"); printf("Press A to select, START to save"); printf("\n"); if(cursorPosition == 0) printf(">"); else printf(" "); printf("Splash: "); if(splash) printf("Off( ), On(x)"); else printf("Off(x), On( )"); printf("\n\n"); if(cursorPosition == 1) printf(">"); else printf(" "); if(dsiSplash) printf("(x)"); else printf("( )"); printf(" DSi Splash/H&S screen"); consoleInit(NULL, 1, BgType_Text4bpp, BgSize_T_256x256, 15, 0, false, true); consoleClear(); if(cursorPosition == 0) { printf("Enable splash screen."); } else if(cursorPosition == 1) { printf("Enable showing the DSi Splash/\n"); printf("Health & Safety screen."); } menuprinted = false; } do { scanKeys(); pressed = keysDownRepeat(); swiWaitForVBlank(); } while (!pressed); if (pressed & KEY_A) { switch(cursorPosition){ case 0: default: splash = !splash; break; case 1: dsiSplash = !dsiSplash; break; } menuprinted = true; } if (pressed & KEY_UP) { cursorPosition -= 1; menuprinted = true; } else if (pressed & KEY_DOWN) { cursorPosition += 1; menuprinted = true; } if (cursorPosition < 0) cursorPosition = 1; if (cursorPosition > 1) cursorPosition = 0; if (pressed & KEY_START) { SaveSettings(); break; } } } if(dsiSplash) fifoSendValue32(FIFO_USER_03, 1); if(splash) { BootSplashInit(); LoadScreen(); for (int i = 0; i < 60*3; i++) { swiWaitForVBlank(); } } runNdsFile("/BOOTLOADER.NDS", 0, NULL); } else { BootSplashInit(); // Display Error Screen swiDecompressLZSSVram ((void*)topErrorTiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); swiDecompressLZSSVram ((void*)subErrorTiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); vramcpy_ui (&BG_PALETTE[0], topErrorPal, topErrorPalLen); vramcpy_ui (&BG_PALETTE_SUB[0], subErrorPal, subErrorPalLen); } while(1) { swiWaitForVBlank(); } }