int main(int argc, char *argv[]) { srand(time(NULL)); // set the screen size set_screen_size(argc, argv); // prepare a tileset for graphical rendering active_tileset = new Tileset(); // ncurses stuff initscr(); // Initialize ncurses noecho(); // Don't echo keypresses cbreak(); // C-style breaks (e.g. ^C to SIGINT) keypad(stdscr, true); // Numpad is numbers init_colors(); // See color.cpp curs_set(0); // Invisible cursor rand(); // For some reason a call to rand() seems to be necessary to avoid // repetion. bool quit_game = false; game *g; do { g = new game(); while (!g->do_turn()); if (g->game_quit()) quit_game = true; delete g; } while (!quit_game); erase(); // Clear screen endwin(); // End ncurses system("clear"); // Tell the terminal to clear itself return 0; }
int main(int argc, char *argv[]) { prog = argv[0]; fps_flag = (getenv("FPS") != NULL); load_config("lsc"); init_font_locale(lookup("locale", 0, 0)); srandom(0); set_screen_size(SCREEN_WIDTH, SCREEN_HEIGHT); layout_screen(); init_polar(); init_transforms(); init_video_in(); init_display(argc, argv, prog); set_category(primary_buttons[Cat_change_color].b); gettimeofday(&last_busy, 0); ARGBEGIN { case 'd': debug++; break; case 'g': grabtimeout = atoi(ARGF()); break; case 'i': idletime = atoi(ARGF()); break; default: return usage(); } ARGEND; if (grabtimeout != 0 && grabtimeout < ALARMTIME) { fprintf(stderr, "unreasonable grab time limit\n"); exit(14); } state = Live; io_main_loop(); return 0; }
void macosx_resize_window(int *lines_per_page, int *chars_per_line) { int new_lines_per_page = UINT_MAX; int new_chars_per_line = UINT_MAX; int ret; if (isatty(fileno(stdout))) { struct winsize window_size; ret = ioctl(fileno(stdout), TIOCGWINSZ, &window_size); if (ret == 0) { new_lines_per_page = window_size.ws_row; new_chars_per_line = window_size.ws_col; } } if (((unsigned int)*lines_per_page != UINT_MAX) && (*lines_per_page != 0)) { *lines_per_page = new_lines_per_page; } if (((unsigned int)*chars_per_line != UINT_MAX) && (*chars_per_line != 0)) { *chars_per_line = new_chars_per_line; } set_screen_size(); set_width(); }
void Preferences::copy(const Preferences& preferences) { for (size_t i = 0; i < KEY_COUNT; ++i) { set_key(i, preferences.key(i)); } set_play_idle_music(preferences.play_idle_music()); set_play_music_in_game(preferences.play_music_in_game()); set_speech_on(preferences.speech_on()); set_volume(preferences.volume()); set_screen_size(preferences.screen_size()); set_scenario_identifier(preferences.scenario_identifier()); }
void RedrawMain() { ResetVideo(); setupFont(); #ifndef CDROM1 set_tile_data(MB_bg); load_tile(0x1000); load_palette(0, MB_pal, 1); set_map_data(MB_map, 40, 30); load_map(0, 0, 0, 0, 40, 30); #ifdef SGFX if(sgx_detect()) { vpc_win_size(VPC_WIN_A, 0x01ff); vpc_win_size(VPC_WIN_B, 0x01ff); vpc_win_reg(VPC_WIN_A, VDC_ON+VPC_NORM); vpc_win_reg(VPC_WIN_B, VDC_ON+VPC_NORM); vpc_win_reg(VPC_WIN_AB, VDC_ON+VPC_NORM); vpc_win_reg(VPC_WIN_NONE, VDC_ON+VPC_NORM); sgx_set_screen_size(SCR_SIZE_32x32); sgx_disp_off(); sgx_set_tile_data(SMPTE75_bg); sgx_load_tile(0x1000); sgx_set_map_data(SMPTE75_map, 40, 30); sgx_load_map(0, 0, 0, 0, 40, 30); //load_palette(0, SMPTE75_pal, 16); sgx_disp_on(); sgx_scroll(40, 40); } #endif #else set_screen_size(SCR_SIZE_64x32); cd_loaddata(GPHX_OVERLAY, OFS_mainbg_PAL_bin, palCD, SIZE_mainbg_PAL_bin); load_palette(0, palCD, 1); cd_loadvram(GPHX_OVERLAY, OFS_mainbg_DATA_bin, 0x1000, SIZE_mainbg_DATA_bin); cd_loadvram(GPHX_OVERLAY, OFS_mainbg_BAT_bin, 0x0000, SIZE_mainbg_BAT_bin); #endif init_satb(); DrawSP(); satb_update(); Center224in240(); DisplaySystemInfo(); }
int main(int argc, char *argv[]) { int x, y; prog = argv[0]; load_config("menu"); init_font_locale(lookup("locale", 0, 0)); set_screen_size(SCREEN_WIDTH, SCREEN_HEIGHT); layout_screen(); init_display(argc, argv, prog); ARGBEGIN { case 'd': debug++; break; default: return usage(); } ARGEND; set_available(argv); io_main_loop(); return 0; }
void DrawN() { unsigned char end = 1; redraw = 1; do { vsync(); end = 1; if(redraw) { ResetVideo(); set_xres(256, xres_flags); scroll(0, 0, -32, 0, 240, 0xC0); #ifndef CDROM1 load_background(n_bg, n_pal, n_map, 32, 20); #else set_screen_size(SCR_SIZE_32x32); cd_loaddata(GPHX_OVERLAY, OFS_N_PAL_bin, palCD, SIZE_N_PAL_bin); load_palette(0, palCD, 16); cd_loadvram(GPHX_OVERLAY, OFS_N_DATA_bin, 0x1000, SIZE_N_DATA_bin); cd_loadvram(GPHX_OVERLAY, OFS_N_BAT_bin, 0, SIZE_N_BAT_bin); // Why these get zapped to 0 when in CDROM1... RestoreGlobals(); #endif redraw = 0; disp_on(); } controller = joy(0); if(controller & JOY_SEL) end = 0; }while(!end); }
main() { char i,j,k,l,m,n; disp_off(); /* <- I don't think this works.... */ spr_set(); spr_hide(); load_default_font(); set_screen_size(SCR_SIZE_32x32); disp_on(); if(!sgx_detect()) { put_string("Halt: SGX not hardware found", 2, 13); for(;;){} } /* These NEED to be set, else you won't see the SGX 2nd layer BG or sprites. */ vpc_win_size( VPC_WIN_A, 0x01ff); vpc_win_size( VPC_WIN_B, 0x01ff); vpc_win_reg( VPC_WIN_A, VDC_ON+VPC_NORM); vpc_win_reg( VPC_WIN_B, VDC_ON+VPC_NORM); vpc_win_reg( VPC_WIN_AB, VDC_ON+VPC_NORM); vpc_win_reg( VPC_WIN_NONE, VDC_ON+VPC_NORM); set_font_pal(4); set_font_color(14,0); load_default_font(); put_string("SGX hardware found", 2, 3); sgx_set_screen_size(SCR_SIZE_32x32); sgx_load_vram(0x0000,map, 0x400); sgx_load_vram(0x1000,tile, 0x4000); load_palette(0, pal,16); sgx_spr_hide(); sgx_spr_set(1); sgx_disp_on(); put_string("Arcade Card: ", 2, 4); if ( ac_init() ) { put_string("detected.", 15, 4); /* initialize AC register 0 to address 0x000000 and +1 auto-increment */ ac_full_reg0(0x00,0x0000,0x0000,0x0001,0x11); put_string("CD->AC xfer... ", 2, 5); /* transfer 8k at a time from CD to AC memory via AC reg #0 */ ac_cd_xfer(AC_REG0,0,0x1c2,4); ac_cd_xfer(AC_REG0,0,0x1c6,4); ac_cd_xfer(AC_REG0,0,0x1ca,4); ac_cd_xfer(AC_REG0,0,0x1ce,4); ac_cd_xfer(AC_REG0,0,0x1d2,4); ac_cd_xfer(AC_REG0,0,0x1d6,4); ac_cd_xfer(AC_REG0,0,0x1da,4); ac_cd_xfer(AC_REG0,0,0x1de,4); put_string("finished.", 17, 5); sgx_bg_on(); /* reset AC reg #0 address to 0x000000 */ ac_addr_reg0(0x00,0x0000); ac_vram_dma(AC_REG0 ,0x1000,0x3c00, SGX); ac_addr_reg0(0x00,0x8000); ac_vram_dma(AC_REG0 ,0x0000,0x800, SGX); ac_addr_reg0(0x00,0x8800); ac_vce_copy( AC_REG0, 0x00, 0x100 ); vsync(60); vsync(60); } else { put_string("not detected.", 15, 4); for(;;){} } put_string("Scrolling SGX layer ", 2, 6); for(;;) { for( j=0; j<0xff; j++) { vsync(); sgx_scroll( j , j); } } }
void DrawCredits() { unsigned char end = 0; int counter = 0; redraw = 1; refresh = 1; while(!end) { vsync(); if(redraw) { ResetVideo(); setupFont(); SetFontColors(15, RGB(3, 3, 3), RGB(0, 6, 0), 0); SetFontColors(13, RGB(3, 3, 3), RGB(1, 6, 6), 0); set_xres(512, xres_flags); #ifndef CDROM1 set_map_data(MB512_map, 64, 30); set_tile_data(MB512_bg); load_tile(0x1000); load_map(0, 0, 0, 0, 64, 30); load_palette(0, MB512_pal, 1); #else set_screen_size(SCR_SIZE_64x32); cd_loaddata(GPHX_OVERLAY, OFS_back512_PAL_bin, palCD, SIZE_back512_PAL_bin); load_palette(0, palCD, 1); cd_loadvram(GPHX_OVERLAY, OFS_back512_DATA_bin, 0x1000, SIZE_back512_DATA_bin); cd_loadvram(GPHX_OVERLAY, OFS_back512_BAT_bin, 0, SIZE_back512_BAT_bin); #endif Center224in240(); redraw = 0; refresh = 1; disp_on(); } if(refresh) { RefreshCredits(); refresh = 0; } set_font_pal(14); if(counter == 1) put_string("Artemio Urbina ", HPOS+2, 8); if(counter == 60*4) put_string("@Artemio (twitter) ", HPOS+2, 8); if(counter == 60*8) put_string("*****@*****.**", HPOS+2, 8); if(counter == 60*16) counter = 0; counter++; controller = joytrg(0); if (controller & JOY_II) end = 1; if (controller & JOY_SEL) { DrawN(); redraw = 1; } } }
void Preferences::reset() { set_key(kUpKeyNum, 1 + Keys::N8); set_key(kDownKeyNum, 1 + Keys::N5); set_key(kLeftKeyNum, 1 + Keys::N4); set_key(kRightKeyNum, 1 + Keys::N6); set_key(kOneKeyNum, 1 + Keys::OPTION); set_key(kTwoKeyNum, 1 + Keys::COMMAND); set_key(kEnterKeyNum, 1 + Keys::SPACE); set_key(kWarpKeyNum, 1 + Keys::TAB); set_key(kSelectFriendKeyNum, 1 + Keys::N_CLEAR); set_key(kSelectFoeKeyNum, 1 + Keys::N_EQUALS); set_key(kSelectBaseKeyNum, 1 + Keys::N_DIVIDE); set_key(kDestinationKeyNum, 1 + Keys::SHIFT); set_key(kOrderKeyNum, 1 + Keys::CONTROL); set_key(kZoomInKeyNum, 1 + Keys::N_PLUS); set_key(kZoomOutKeyNum, 1 + Keys::N_MINUS); set_key(kCompUpKeyNum, 1 + Keys::UP_ARROW); set_key(kCompDownKeyNum, 1 + Keys::DOWN_ARROW); set_key(kCompAcceptKeyNum, 1 + Keys::RIGHT_ARROW); set_key(kCompCancelKeyNum, 1 + Keys::LEFT_ARROW); set_key(kTransferKeyNum, 1 + Keys::F8); set_key(kScale121KeyNum, 1 + Keys::F9); set_key(kScale122KeyNum, 1 + Keys::F10); set_key(kScale124KeyNum, 1 + Keys::F11); set_key(kScale1216KeyNum, 1 + Keys::F12); set_key(kScaleHostileKeyNum, 1 + Keys::HELP); set_key(kScaleObjectKeyNum, 1 + Keys::PAGE_UP); set_key(kScaleAllKeyNum, 1 + Keys::HOME); set_key(kMessageNextKeyNum, 1 + Keys::BACKSPACE); set_key(kHelpKeyNum, 1 + Keys::F1); set_key(kVolumeDownKeyNum, 1 + Keys::F2); set_key(kVolumeUpKeyNum, 1 + Keys::F3); set_key(kActionMusicKeyNum, 1 + Keys::F4); set_key(kNetSettingsKeyNum, 1 + Keys::F5); set_key(kFastMotionKeyNum, 1 + Keys::F6); set_key(kFirstHotKeyNum + 0, 1 + Keys::K1); set_key(kFirstHotKeyNum + 1, 1 + Keys::K2); set_key(kFirstHotKeyNum + 2, 1 + Keys::K3); set_key(kFirstHotKeyNum + 3, 1 + Keys::K4); set_key(kFirstHotKeyNum + 4, 1 + Keys::K5); set_key(kFirstHotKeyNum + 5, 1 + Keys::K6); set_key(kFirstHotKeyNum + 6, 1 + Keys::K7); set_key(kFirstHotKeyNum + 7, 1 + Keys::K8); set_key(kFirstHotKeyNum + 8, 1 + Keys::K9); set_key(kFirstHotKeyNum + 9, 1 + Keys::K0); set_play_idle_music(true); set_play_music_in_game(false); set_speech_on(false); set_volume(7); set_screen_size(Size(640, 480)); _scenario_identifier.assign("com.biggerplanet.ares"); }