int appInit(int argc, char **argv) { const char *opt; _flubAppCtx.launchedFromConsole = _appLaunchedFromConsole(); if((opt = strrchr(argv[0], PLATFORM_PATH_SEP)) != NULL) { _flubAppCtx.progName = opt; } else { _flubAppCtx.progName = argv[0]; } if((!logInit()) || (!cmdlineInit(argc, argv)) || (!flubSDLInit()) || (!flubPhysfsInit(argv[0])) || (!flubCfgInit()) || (!videoInit()) || (!texmgrInit()) || (!flubFontInit()) || (!gfxInit()) || (!audioInit()) || (!inputInit()) || (!consoleInit()) || (!flubGuiThemeInit()) ) { return 0; } return 1; }
static int hwReqFunction(threadEP_t func, void* userData) { if (!bRunningDMApp) { fprintf(stderr, "Direct mode applications cannot\n"); fprintf(stderr, "be run from coop GUI apps nor\n"); fprintf(stderr, "from the emulated console.\n"); return -1; } swiWaitForVBlank(); if (g_curApp) g_curApp->OnDeactivate(); DSVideoReset(); int rc = func(userData); swiWaitForVBlank(); DSVideoReset(); if (!g_curApp) videoInit(); else g_curApp->OnActivate(); return rc; }
void initVideo(void) { videoInit(); runScript(PATH_SCRIPTS, "video.lua"); initVideoData(); consoleInit(); initArtpacks(); runScript(PATH_SCRIPTS, "menu.lua"); runScript(PATH_SCRIPTS, "menu_functions.lua"); setupDisplay(gScreen); }
void CGuiManager::SwitchTo(AppWrapper* pApp) { swiWaitForVBlank(); if (g_curApp) g_curApp->OnDeactivate(); DSVideoReset(); g_curApp = pApp; if (g_curApp) g_curApp->OnActivate(); else videoInit(); }
int EXPORT_THIS d_init_rest(const char *wtitle, int win_w, int win_h, int fullscreen, const char *icon) { int t; videoSetIcon(icon); renderInit(); tpw_cursor_show(0); d->fps.time_at_last_frame = d->fps.time_at_flip = tpw_ticks(); d->fps.time = tpw_ticks() / 1000; t = videoInit(wtitle, win_w, win_h, fullscreen); darnitSetPlatform(0); // renderLineTest(); return t; }
int main(){ // Initialize the screen and clear the console. videoInit(); console_clrscr(); /* Setup two memory addresses to store data in. tempAddress is where raw incoming binary data is stored. elfAddress is where tempAddress is copied to, post ELF verification. */ void *tempAddress = malloc(0x1000000); unsigned char *elfAddress = malloc(sizeof(tempAddress)); while(1){ // Print status. printf("Reading"); printf("."); // Variable to hold read binary data. unsigned char data = getch(); // Instantiate a counter for the number of bytes we have read. long int bytesRead = 0; // Up the counter of the number of bytes we have read. bytesRead++; int numBytes = bytesRead; // Copy data to memory buffer. memcpy(tempAddress, data, numBytes); /* If no more data is being received, perform ELF check. If check passes, copy temporary buffer contents to final buffer, free temporary buffer, and execute the elf from final memory address. */ if(data == NULL){ checkIsELF(tempAddress); if(isELF == 1){ printf("do nothing"); } } } return 0; }
int main(){ // Init console and video videoInit(); // Setup a loop to mess with the LED colors :D while(1){ printf("Party!\r"); xenon_smc_set_led(1, 1); mdelay(10); xenon_smc_set_led(2, 2); mdelay(10); xenon_smc_set_led(3, 3); mdelay(10); xenon_smc_set_led(4, 4); mdelay(10); } }
static void RunAppVBlank() { const AppInfo* info = g_curApp->GetInfo(); word_t appFlags = info->Flags; word_t kDown = keysDown(); if (!(appFlags & AppFlags::UsesSelect) && (kDown & KEY_SELECT)) { g_curApp->OnDeactivate(); g_curApp = nullptr; DSVideoReset(); videoInit(); return; } g_curApp->OnVBlank(); }
int main(int argc __attribute__((unused)), char *argv[]) { /* init allegro library */ ALLEGRO_TIMER *timer = NULL; al_init(); /* prepare random number generator */ srand(time(NULL)); /* activate all engine subsystems using the startup macro */ resetCollisionTable(); STARTUP(videoInit()) STARTUP(init_datafile(argv)) STARTUP(al_install_keyboard()) STARTUP(al_install_joystick()) STARTUP(fontInit()) STARTUP(setupSound()) timer = al_create_timer(1.0 / 60); al_start_timer(timer); initMediaLib(); initBuffers(); /* prepare game */ startGame(); /* begin game loop */ while(!state.terminate) { runState(timer); } /* finish, return control to os */ al_destroy_timer(timer); shutdownState(); shutdownGame(); videoKill(); shutdownSound(); al_uninstall_system(); PHYSFS_deinit(); /* no problems, exit false */ return EXIT_SUCCESS; }
int main(){ // Init console and video videoInit(); // Create FILE type for our elf to load from USB to memory address FILE *elfFile = fopen("uda:/xenon.elf32", "rb"); // Get the size of the elf fseek(elfFile, 0, SEEK_END); elfSize = ftell(elfFile); rewind(elfFile); /* Now that we have all the info we need about the file, we can read the executeable into the memory address we defined at the top of the file. */ fread(&elfPosition[elfSize], 1, elfSize, elfFile); // Execute the elf from the memory address elf_runFromMemory(elfPosition, elfSize); }
void CGuiManager::RunApplication(IApplication* pApp) { AppWrapper wrap(pApp); auto cookie = g_appList.AddApp(&wrap); if (!cookie) return; g_appListChanged = true; swiWaitForVBlank(); if (g_curApp) g_curApp->OnDeactivate(); DSVideoReset(); g_curApp = &wrap; pApp->OnActivate(); while (wrap.IsAlive()) swiWaitForVBlank(); if (g_curApp == &wrap) { pApp->OnDeactivate(); g_curApp = nullptr; } g_appList.RemoveApp(cookie); g_appListChanged = true; if (!g_curApp) { swiWaitForVBlank(); DSVideoReset(); videoInit(); } }
int main() { // initialize IRQ (interrupts) // this must come before everything else IRQ_INIT(); // Initialize global pointers GameStateManager gameStateMan; OamManager oamMan; AudioManager audioMan; PlayState playState(&gameStateMan); TitleScreenState titleState(&gameStateMan); PauseState pauseState(&gameStateMan); GameOverState gameOverState(&gameStateMan); StoreState storeState(&gameStateMan); StageEndState stageEndState(&gameStateMan); g_gameStateMan = &gameStateMan; g_oamMan = &oamMan; g_playState = &playState; g_titleState = &titleState; g_pauseState = &pauseState; g_gameOverState = &gameOverState; g_storeState = &storeState; g_stageEndState = &stageEndState; g_audioMan = &audioMan; // create stage events StageEvent endEvent; StageEvent event1; StageEvent event2; StageEvent event3; StageEvent event4; StageEvent event5; StageEvent event6; StageEvent firePowerPowerUpEvent; StageEvent invinciblePowerUpEvent; StageEvent bombPowerUpEvent; g_endEvent = &endEvent; g_event1 = &event1; g_event2 = &event2; g_event3 = &event3; g_event4 = &event4; g_event5 = &event5; g_event6 = &event6; g_firePowerPowerUpEvent = &firePowerPowerUpEvent; g_invinciblePowerUpEvent = &invinciblePowerUpEvent; g_bombPowerUpEvent = &bombPowerUpEvent; initializeEvents(); StageEvent * stage1Events[24]; int stage1Timing[24]; int stage1yOffset[24]; fillEventsStage1(stage1Events, stage1Timing, stage1yOffset); Stage stage1(&playState, stage1Events, stage1Timing, stage1yOffset, 24); g_stage1 = &stage1; StageEvent * stage2Events[20]; int stage2Timing[20]; int stage2yOffset[20]; fillEventsStage2(stage2Events, stage2Timing, stage2yOffset); Stage stage2(&playState, stage2Events, stage2Timing, stage2yOffset, 20); g_stage2 = &stage2; StageEvent * stage3Events[20]; int stage3Timing[20]; int stage3yOffset[20]; fillEventsStage3(stage3Events, stage3Timing, stage3yOffset); Stage stage3(&playState, stage3Events, stage3Timing, stage3yOffset, 20); g_stage3 = &stage3; videoInit(); g_gameStateMan->pushState(g_titleState); #ifdef DEBUG // timers used for debug display REG_TM1D = 0x10000 - 2808; // overflow into timer 2 every 2808 cycles, approx. 1% of a screen refresh REG_TM2D = 0; REG_TM2CNT = TM_CASCADE | TM_ENABLE; REG_TM1CNT = TM_FREQ_1 | TM_ENABLE; int oldPercent, diffPercent, oldFrac, diffFrac; char buf[15]; #endif // DEBUG while(true) { // wait until next VBlank // prefer this over vid_vsync() - it's // better for power consumption VBlankIntrWait(); #ifdef DEBUG // grab current percentage oldPercent = REG_TM2D; oldFrac = REG_TM1D; #endif // DEBUG // update shadow OAM to real OAM g_oamMan->update(); // mix the next frame's audio g_audioMan->sndMix(); // poll keys - do not do this in other places key_poll(); // update the game state g_gameStateMan->update(); #ifdef DEBUG // grab current percentage, and write it out diffPercent = REG_TM2D - oldPercent; diffFrac = REG_TM1D - oldFrac; // round the percent based on the fractional amount if (diffFrac > 1404) { diffPercent++; } else if (diffFrac < -1404) { diffPercent--; } gba_itoa(diffPercent, buf); // clear out characters from the last write write(" ", Vec2(0, 0)); write(buf, Vec2(0, 0)); // reset timer 2 to 0 REG_TM2CNT = 0; // disable timer REG_TM2D = 0; // set new value to 0 REG_TM2CNT = TM_CASCADE | TM_ENABLE; // reenable timer #endif // DEBUG } }
int hwMainFunc(void* userData) { CGrf* bootSplash = new CGrf(); if (!bootSplash) return ERR_NOMEM; if (!bootSplash->Load(GUI_ASSET_DIR "/bootsplash.grf")) { delete bootSplash; return ERR_NOLOAD; } setBrightness(3, -16); videoSetMode(MODE_3_2D); int bg = bgInit(2, BgType_Text8bpp, BgSize_T_256x256, 0, 1); dmaCopy(bootSplash->gfxData, bgGetGfxPtr(bg), MemChunk_GetSize(bootSplash->gfxData)); dmaCopy(bootSplash->mapData, bgGetMapPtr(bg), MemChunk_GetSize(bootSplash->mapData)); dmaCopy(bootSplash->palData, BG_PALETTE, MemChunk_GetSize(bootSplash->palData)); delete bootSplash; LoadApps(); if (!g_appCount) return ERR_NOAPPS; LoadFileTypes(); if (!(background.Load(GUI_ASSET_DIR "/background.grf") && dummy.Load(GUI_ASSET_DIR "/dummy.grf") && selection.Load(GUI_ASSET_DIR "/selection.grf") && topscr.Load(GUI_ASSET_DIR "/topscr.grf") && defappicon.Load(GUI_ASSET_DIR "/dummyapp.grf") && fiGenericFile.Load(GUI_ASSET_DIR "/genericfile.grf") && fiConflictFile.Load(GUI_ASSET_DIR "/conflictfile.grf") && font.Load("tahoma", 10))) return ERR_NOLOAD; for (int q = 0; q < 92; q ++) { if (q < 16) setBrightness(3, q-16); if (q >= (92-16-1)) setBrightness(3, q-(92-16-1)); if (keysDown()) break; swiWaitForVBlank(); scanKeys(); } setBrightness(3, 0); swiWaitForVBlank(); DSVideoReset(); videoInit(); EnableGuiMon(); for (;;) { swiWaitForVBlank(); scanKeys(); oamUpdate(&oamMain); oamUpdate(&oamSub); bgUpdate(); if (g_curApp) RunAppVBlank(); else if (!MainVBlank()) break; RunBgProcess(); } DisableGuiMon(); return 0; }