void LoadScreen() { // Display Load Screen swiDecompressLZSSVram ((void*)topLoadTiles, (void*)CHAR_BASE_BLOCK(2), 0, &decompressBiosCallback); swiDecompressLZSSVram ((void*)subLoadTiles, (void*)CHAR_BASE_BLOCK_SUB(2), 0, &decompressBiosCallback); vramcpy_ui (&BG_PALETTE[0], topLoadPal, topLoadPalLen); vramcpy_ui (&BG_PALETTE_SUB[0], subLoadPal, subLoadPalLen); }
void arm9_consoleInit() { powerON(/*POWER_ALL*/POWER_LCD); // Use the main screen for output videoSetMode(MODE_0_2D | DISPLAY_BG0_ACTIVE); vramSetBankA(VRAM_A_MAIN_BG); BG0_CR = BG_MAP_BASE(31); // Set the colour of the font to White. BG_PALETTE[255] = RGB15(31,31,31); consoleInitDefault((u16*)SCREEN_BASE_BLOCK(31), (u16*)CHAR_BASE_BLOCK(0), 16); }
int main(void) { lcdMainOnBottom(); // Register vblank IRQ irqEnable(IRQ_VBLANK); // Set banks vramSetMainBanks(VRAM_A_MAIN_BG_0x06000000, VRAM_B_MAIN_BG_0x06020000, VRAM_C_SUB_BG_0x06200000 , VRAM_D_LCD); // Set modes videoSetMode(MODE_5_2D); videoSetModeSub(MODE_5_2D); // sub display int sub_bg3 = bgInitSub(3, BgType_Bmp16, BgSize_B16_256x256, 2, 0); bgSetPriority(sub_bg3, 1); #ifdef DEBUG // Text bg on sub PrintConsole *pc = consoleInit(NULL, 0, BgType_Text4bpp, BgSize_T_256x256, 4, 0, false); bgSetPriority(pc->bgId, 0); BG_PALETTE_SUB[255] = RGB15(31,0,31); #endif // The main display is for graphics. // Set up an extended rotation background for background gfx int main_bg2 = bgInit(2, BgType_Bmp16, BgSize_B16_256x256, 2, 0); bgSetPriority(main_bg2, 1); // Set up tile mode for the keyboard int main_bg0 = bgInit(0, BgType_Text4bpp, BgSize_T_256x256, 8, 0); bgSetPriority(main_bg0, 0); // Clear tile mem u16 *tile_ram = (u16*)bgGetGfxPtr(main_bg0); u32 i; for(i=0; i<(32*1024); ++i) { tile_ram[i] = 0; } // Copy tiles and palettes dmaCopy((uint16*)keyboard_Palette, (uint16*)BG_PALETTE, 32); dmaCopy((uint16*)keyboard_fullnotehighlight_Palette, (uint16*)BG_PALETTE+16, 32); dmaCopy((uint16*)keyboard_halfnotehighlight_Palette, (uint16*)BG_PALETTE+32, 32); dmaCopy((uint16*)keyboard_Tiles, (uint16*)CHAR_BASE_BLOCK(0), 736); // Fill screen with empty tiles u16 *map = (u16*)bgGetMapPtr(main_bg0); for(i=0;i<768;++i) { map[i] = 28; } // Draw the backgrounds main_vram = (u16*)bgGetGfxPtr(main_bg2); for(i=0; i<192*256; ++i) { main_vram[i] = ((uint16*)bg_main)[i]; } u16 *sub_vram = (u16*)bgGetGfxPtr(sub_bg3); for(i=0; i<192*256; ++i) { sub_vram[i] = ((uint16*)bg_sub)[i]; } displayChannel(channel); displayOctave(baseOctave); drawString("connecting ...", 89, 96); iprintf("Connecting\n"); int res = dsmi_connect(); if(res == 1) { iprintf("OK\n"); } else { iprintf("Oh no! Could not connect\n"); drawString("failed!", 180, 96); while(1); } iprintf("Ready.\n"); // Copy the keyboard to the screen kb_map = (u16*)bgGetMapPtr(main_bg0); u8 x, y; for(y=0; y<5; ++y) { for(x=0; x<28; ++x) { kb_map[32*(y+keyb_ypos)+(x+keyb_xpos)] = keyboard_Map[29*y+x+1]; } } while(1) { VblankHandler(); swiWaitForVBlank(); } return 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(); } }