void OSystem_Wii::switchVideoMode(int mode) { static const struct { gfx_video_mode_t mode; bool filter; } map[] = { { GFX_MODE_DEFAULT, false }, { GFX_MODE_DEFAULT, true }, { GFX_MODE_DS, false }, { GFX_MODE_DS, true } }; if (_gameHeight > 240) { if (mode == gmDoubleStrike) mode = gmStandard; else if (mode == gmDoubleStrikeFiltered) mode = gmStandardFiltered; } printf("switchVideoMode %d\n", mode); if (map[_actualGraphicsMode].mode != map[mode].mode) { GXRModeObj obj; gfx_video_deinit(); gfx_video_get_modeobj(&obj, GFX_STANDARD_AUTO, map[mode].mode); gfx_video_init(&obj); gfx_init(); gfx_con_init(NULL); } _actualGraphicsMode = mode; _bilinearFilter = map[mode].filter; gfx_tex_set_bilinear_filter(&_texGame, _bilinearFilter); gfx_tex_set_bilinear_filter(&_texMouse, _bilinearFilter); u16 usx, usy; if (map[mode].mode == GFX_MODE_DS) { usx = ConfMan.getInt("wii_video_ds_underscan_x", Common::ConfigManager::kApplicationDomain); usy = ConfMan.getInt("wii_video_ds_underscan_y", Common::ConfigManager::kApplicationDomain); } else { usx = ConfMan.getInt("wii_video_default_underscan_x", Common::ConfigManager::kApplicationDomain); usy = ConfMan.getInt("wii_video_default_underscan_y", Common::ConfigManager::kApplicationDomain); } gfx_set_underscan(usx, usy); gfx_coords(&_coordsOverlay, &_texOverlay, GFX_COORD_FULLSCREEN); gfx_coords(&_coordsGame, &_texGame, GFX_COORD_FULLSCREEN); updateScreenResolution(); }
// TODO this is just my console test app, clean up this mess! int main(int argc, char *argv[]) { (void) argc; (void) argv; VIDEO_Init(); PAD_Init(); SYS_SetResetCallback(stmcb); SYS_SetPowerCallback(stmcb); gfx_video_init(NULL); gfx_init(); gfx_con_init(NULL); printf("startup\n"); gfx_tex_t tex; memset(&tex, 0, sizeof(gfx_tex_t)); if (!gfx_tex_init(&tex, GFX_TF_RGB565, 0, 16, 16)) { printf("failed to init tex!\n"); return 1; } memset(tex.pixels, 0xe070, 16 * 16 * 2); gfx_tex_flush_texture(&tex); gfx_screen_coords_t coords_bg; gfx_coords(&coords_bg, &tex, GFX_COORD_FULLSCREEN); srand(gettime()); u64 frame = 0; u16 b; bool pf = false; u32 retries; u8 fg = 7, bg = 0; u32 i; char buf[32]; while (!quit) { b = 0; if (PAD_ScanPads() & 1) { b = PAD_ButtonsDown(0); gfx_con_set_alpha(0xff - PAD_TriggerR(0), 0xff - PAD_TriggerL(0)); } if (b & PAD_BUTTON_A) quit = true; if (b & PAD_BUTTON_B) pf = !pf; if (b & PAD_BUTTON_X) printf(S_RED("Hello") " " S_BLUE("world") "!\n"); if (pf) { for (i = 0; i < gfx_con_get_columns() * gfx_con_get_rows(); ++i) { printf(CON_ESC "%u;1m" CON_ESC "%um%c", 30 + IRAND(8), 40 + IRAND(8), 0x20 + IRAND(16 * 9)); } } if (b & PAD_TRIGGER_Z) { gfx_con_reset(); fg = 7; bg = 0; } if (b & 15) { if (b & PAD_BUTTON_LEFT) { fg = (fg + 8 - 1) % 8; gfx_con_set_foreground_color(fg, true); } if (b & PAD_BUTTON_RIGHT) { fg = (fg + 1) % 8; gfx_con_set_foreground_color(fg, true); } if (b & PAD_BUTTON_UP) { bg = (bg + 8 - 1) % 8; gfx_con_set_background_color(bg, false); } if (b & PAD_BUTTON_DOWN) { bg = (bg + 1) % 8; gfx_con_set_background_color(bg, false); } printf("new color selected: %u %u\n", fg, bg); } sprintf(buf, "frame: %llu", frame); gfx_con_save_attr(); gfx_con_set_pos(1, gfx_con_get_columns() - strlen(buf) + 1); printf(CON_COLRESET "%s", buf); gfx_con_restore_attr(); retries = 0; while (!gfx_frame_start()) { retries++; if (retries > 1000) { printf("gx hates you\n"); gfx_frame_abort(); return -1; } usleep(50); } gfx_draw_tex(&tex, &coords_bg); gfx_con_draw(); gfx_frame_end(); frame++; } printf("shutdown\n"); gfx_tex_deinit(&tex); gfx_con_deinit(); gfx_deinit(); gfx_video_deinit(); return 0; }
int main(int argc, char *argv[]) { s32 res; #if defined(USE_WII_DI) && !defined(GAMECUBE) DI_Init(); #endif VIDEO_Init(); PAD_Init(); DSP_Init(); AUDIO_Init(NULL); gfx_video_init(NULL); gfx_init(); gfx_con_init(NULL); #ifdef DEBUG_WII_GDB DEBUG_Init(GDBSTUB_DEVICE_USB, 1); #endif printf("startup as "); if (argc > 0) printf("'%s'\n", argv[0]); else printf("<unknown>\n"); SYS_RegisterResetFunc(&resetinfo); SYS_SetResetCallback(reset_cb); #ifndef GAMECUBE SYS_SetPowerCallback(power_cb); #endif if (!fatInitDefault()) { printf("fatInitDefault failed\n"); } else { // set the default path if libfat couldnt set it // this allows loading over tcp/usbgecko char cwd[MAXPATHLEN]; if (getcwd(cwd, MAXPATHLEN)) { size_t len = strlen(cwd); if (len > 2 && (cwd[len - 1] == ':' || cwd[len - 2] == ':')) { printf("chdir to default\n"); chdir("/apps/scummvm"); } } } g_system = new OSystem_Wii(); assert(g_system); #ifdef DYNAMIC_MODULES PluginManager::instance().addPluginProvider(new WiiPluginProvider()); #endif res = scummvm_main(argc, argv); g_system->quit(); printf("shutdown\n"); SYS_UnregisterResetFunc(&resetinfo); fatUnmountDefault(); if (res) show_console(res); if (power_btn_pressed) { printf("shutting down\n"); SYS_ResetSystem(SYS_POWEROFF, 0, 0); } printf("reloading\n"); gfx_con_deinit(); gfx_deinit(); gfx_video_deinit(); return res; }
int main(int argc, char *argv[]) { #ifdef _USE_UNPACK int clean_tmp = 0; #endif int err = 0; int i; #ifdef __APPLE__ macosx_init(); #endif #ifndef S60 putenv("SDL_MOUSE_RELATIVE=0"); /* test this! */ #endif #ifdef _WIN32_WCE libwince_init(argv[0], 1); wince_init(argv[0]); #else #ifdef S60 extern char s60_data[]; strcpy(game_cwd, s60_data); #else #ifdef _WIN32 strcpy(game_cwd, dirname(argv[0])); #else if (!getcwd(game_cwd, sizeof(game_cwd))) fprintf(stderr,"Warning: can not get current dir\n."); #endif #endif #endif unix_path(game_cwd); setdir(game_cwd); for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "-vsync")) vsync_sw = 1; else if (!strcmp(argv[i], "-nosound")) nosound_sw = 1; else if (!strcmp(argv[i], "-fullscreen")) fullscreen_sw = 1; else if (!strcmp(argv[i], "-mode")) { if ((i + 1) < argc) mode_sw = argv[++i]; else mode_sw = "-1x-1"; } else if (!strcmp(argv[i], "-window")) window_sw = 1; else if (!strcmp(argv[i], "-debug")) { if (!debug_sw) debug_init(); debug_sw = 1; } else if (!strcmp(argv[i], "-owntheme")) owntheme_sw = 1; else if (!strcmp(argv[i], "-noautosave")) noauto_sw = 1; else if (!strcmp(argv[i], "-game")) { if ((i + 1) < argc) game_sw = argv[++i]; else game_sw = ""; } else if (!strcmp(argv[i], "-theme")) { if ((i + 1) < argc) theme_sw = argv[++i]; else theme_sw = ""; } else if (!strcmp(argv[i], "-nostdgames")) { nostdgames_sw = 1; #ifdef _LOCAL_APPDATA } else if (!strcmp(argv[i], "-appdata")) { if ((i + 1) < argc) appdata_sw = argv[++i]; else appdata_sw = ""; #endif } else if (!strcmp(argv[i], "-chunksize")) { if ((i + 1) < argc) chunksize_sw = atoi(argv[++i]); else chunksize_sw = DEFAULT_CHUNKSIZE; } else if (!strcmp(argv[i], "-gamespath")) { if ((i + 1) < argc) games_sw = argv[++i]; else games_sw = ""; } else if (!strcmp(argv[i], "-themespath")) { if ((i + 1) < argc) themes_sw = argv[++i]; else themes_sw = ""; } else if (!strcmp(argv[i], "-idf")) { if ((i + 1) < argc) idf_sw = argv[++i]; else { fprintf(stderr,"No data directory specified.\n"); err = 1; goto out; } } else if (!strcmp(argv[i], "-encode")) { if ((i + 1) < argc) encode_sw = argv[++i]; else { fprintf(stderr,"No lua file specified.\n"); err = 1; goto out; } if ((i + 1) < argc) encode_output = argv[++i]; else encode_output = "lua.enc"; } else if (!strcmp(argv[i], "-version")) { version_sw = 1; } else if (!strcmp(argv[i], "-nopause")) { nopause_sw = 1; } else if (!strcmp(argv[i], "-software")) { software_sw = 1; #ifdef _USE_UNPACK } else if (!strcmp(argv[i], "-install")) { if ((i + 1) < argc) { char *file = argv[++i]; char *p; if (games_sw) p = games_sw; else p = game_local_games_path(1); if (setup_zip(file, p)) { err = 1; goto out; } } #endif } else if (!strcmp(argv[i], "-quit")) { exit(0); } else if (!strcmp(argv[i], "-hinting")) { if ((i + 1) < argc) hinting_sw = atoi(argv[++i]); else hinting_sw = 1; } else if (!strcmp(argv[i], "-lua") || !strcmp(argv[i], "-luac")) { if ((i + 1) < argc) { lua_exec = !strcmp(argv[i], "-lua"); lua_sw = argv[++ i]; opt_index = i + 1; break; } else { fprintf(stderr, "No lua script.\n"); err = 1; goto out; } } else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "-help") || !strcmp(argv[i], "--help")) { usage(); goto out; } else if (argv[i][0] == '-') { fprintf(stderr,"Unknown option: %s\n", argv[i]); usage(); err = 1; goto out; } else if (!start_idf(argv[i])) { fprintf(stderr, "Adding idf: %s\n", argv[i]); } else if (!run_game(argv[i])) { fprintf(stderr, "Opening game: %s\n", argv[i]); } #ifdef _USE_UNPACK else { char *p; if (games_sw) p = games_sw; else p = game_tmp_path(); if (setup_zip(argv[i], p)) { err = 1; goto out; } clean_tmp = 1; } #endif } cfg_load(); if (opt_debug == 1 && debug_sw == 0) { debug_sw = 1; debug_init(); } if (opt_vsync == 1 && vsync_sw == 0) vsync_sw = 1; if (version_sw) { fprintf(stdout, VERSION"\n"); goto out; } if (lua_sw) { err = instead_init_lua(dirname(lua_sw)); if (err) goto out; if (!err) err = instead_loadscript(lua_sw, argc - opt_index, argv + opt_index, lua_exec); instead_done(); goto out; } if (encode_sw) { err = instead_encode(encode_sw, encode_output); goto out; } if (idf_sw) { char *p = malloc(strlen(idf_sw) + 5); if (p) { char *b; strcpy(p, idf_sw); b = basename(p); strcat(b, ".idf"); idf_create(b, idf_sw); free(p); } else idf_create("data.idf", idf_sw); goto out; } menu_langs_lookup(dirpath(LANG_PATH)); if (!langs_nr) { fprintf(stderr, "No languages found in: %s.\n", dirpath(LANG_PATH)); err = 1; goto out; } if (!opt_lang || !opt_lang[0]) opt_lang = game_locale(); if (menu_lang_select(opt_lang) && menu_lang_select(LANG_DEF)) { fprintf(stderr, "Can not load default language.\n"); err = 1; goto out; } if (games_sw) games_lookup(games_sw); if (owntheme_sw && !opt_owntheme) { opt_owntheme = 2; } if (!nostdgames_sw && games_lookup(dirpath(GAMES_PATH))) fprintf(stderr, "No games found in: %s.\n", GAMES_PATH); if (themes_sw) themes_lookup(themes_sw); if (!nostdthemes_sw) { themes_lookup(dirpath(THEMES_PATH)); themes_lookup(game_local_themes_path()); } if (!nostdgames_sw) games_lookup(game_local_games_path(0)); if (start_idf_sw) { char *d, *b; char *dd, *bb; static char idf_game[255]; d = strdup(start_idf_sw); b = strdup(start_idf_sw); if (d && b) { dd = dirname(d); bb = basename(b); if (!games_replace(dirpath(dd), bb)) { game_sw = idf_game; strncpy(idf_game, bb, sizeof(idf_game) - 1); idf_game[sizeof(idf_game) - 1] = 0; } } if (d) free(d); if (b) free(b); } if (noauto_sw && opt_autosave) opt_autosave = 2; if (window_sw) opt_fs = 0; if (fullscreen_sw) opt_fs = 1; if (mode_sw) parse_mode(mode_sw, opt_mode); if (game_sw) { FREE(opt_game); opt_game = game_sw; } if (theme_sw) { FREE(opt_theme); opt_theme = theme_sw; } if (opt_theme) game_theme_select(opt_theme); if (!curtheme_dir) game_theme_select(DEFAULT_THEME); /* Initialize SDL */ if (gfx_init() < 0) return -1; #ifdef _USE_GTK gtk_init(&argc, &argv); /* must be called AFTER SDL_Init when using SDL2 */ #endif if (gfx_video_init() || input_init()) return -1; if (game_init(opt_game)) { game_error(); } game_loop(); cfg_save(); game_done(0); gfx_video_done(); #ifndef ANDROID gfx_done(); #endif out: if (debug_sw) debug_done(); #ifdef _USE_GTK /* gtk_main_quit (); */ #endif #ifdef _USE_UNPACK if (clean_tmp) remove_dir(game_tmp_path()); #endif #if defined(ANDROID) || defined(IOS) exit(err); #endif return err; }