static void on_resize(int width, int height) { if (width == g_fs_ml_video_width && height == g_fs_ml_video_height) { fs_log("got resize event, but size was unchanged\n"); return; } if (g_fs_emu_video_fullscreen) { fs_log("not updating window size in fullscreen\n"); } else if (width == g_fullscreen_width && height == g_fullscreen_height) { fs_log("not setting window size to fullscreen size\n"); } else { g_window_width = width; g_window_height = height; fs_log("resize event %d %d\n", width, height); } set_video_mode(); }
rtems_device_driver frame_buffer_control( rtems_device_major_number major, rtems_device_minor_number minor, void *arg ) { rtems_libio_ioctl_args_t *args = arg; switch (args->command) { case FBIOGET_FSCREENINFO: args->ioctl_return = get_fix_screen_info((struct fb_fix_screeninfo *)args->buffer); return RTEMS_SUCCESSFUL; case FBIOGET_VSCREENINFO: args->ioctl_return = get_var_screen_info((struct fb_var_screeninfo *)args->buffer); return RTEMS_SUCCESSFUL; case FBIOSWAPBUFFERS: swap_buffers(); args->ioctl_return = 0; return RTEMS_SUCCESSFUL; case FBIOSETBUFFERMODE: args->ioctl_return = 0; switch ((unsigned int)args->buffer) { case FB_SINGLE_BUFFERED: init_buffers(); fb_fix.smem_start = (volatile char *)frontbuffer; MM_WRITE(MM_VGA_BASEADDRESS, (unsigned int)frontbuffer); return RTEMS_SUCCESSFUL; case FB_TRIPLE_BUFFERED: fb_fix.smem_start = (volatile char *)backbuffer; return RTEMS_SUCCESSFUL; default: return RTEMS_UNSATISFIED; } case FBIOSETVIDEOMODE: set_video_mode((int)args->buffer); return RTEMS_SUCCESSFUL; default: args->ioctl_return = -1; return RTEMS_UNSATISFIED; } }
void ef9365_device::device_reset() { m_state = 0; m_bf = 0; m_irq_state = 0; m_irq_vb = 0; m_irq_lb = 0; m_irq_rdy = 0; memset(m_registers, 0, sizeof(m_registers)); memset(m_border, 0, sizeof(m_border)); m_screen_out.fill(0); set_video_mode(); m_irq_handler(FALSE); }
SDL_DisplayMode set_video_mode_auto_select() { SDL_DisplayMode mode; //uncomment out when support for SDL_GetWindowDisplayIndex stabilizes. const int display_index = 0; //SDL_GetWindowDisplayIndex(graphics::get_window()); SDL_GetDesktopDisplayMode(display_index, &mode); std::cerr << "CURRENT MODE IS " << mode.w << "x" << mode.h << "\n"; SDL_DisplayMode best_mode = mode; if(preferences::fullscreen() == false && mode.w > 1024 && mode.h > 768) { const int nmodes = SDL_GetNumDisplayModes(display_index); for(int n = 0; n != nmodes; ++n) { SDL_DisplayMode candidate_mode; const int nvalue = SDL_GetDisplayMode(display_index, n, &candidate_mode); if(nvalue != 0) { std::cerr << "ERROR QUERYING DISPLAY INFO: " << SDL_GetError() << "\n"; continue; } const float MinReduction = 0.9; if(candidate_mode.w < mode.w && candidate_mode.h < mode.w && candidate_mode.w < mode.w*MinReduction && candidate_mode.h < mode.h*MinReduction && (candidate_mode.w >= best_mode.w && candidate_mode.h >= best_mode.h || best_mode.w == mode.w && best_mode.h == mode.h)) { std::cerr << "BETTER MODE IS " << candidate_mode.w << "x" << candidate_mode.h << "\n"; best_mode = candidate_mode; } else { std::cerr << "REJECTED MODE IS " << candidate_mode.w << "x" << candidate_mode.h << "\n"; } } } if(best_mode.w < 1024 || best_mode.h < 768) { best_mode.w = 1024; best_mode.h = 768; } const bool result = set_video_mode(best_mode.w, best_mode.h, SDL_WINDOW_OPENGL); ASSERT_LOG(result, "FAILED TO SET AUTO SELECT VIDEO MODE: " << best_mode.w << "x" << best_mode.h); return best_mode; }
OSIPhone::OSIPhone(int width, int height, String p_data_dir) { main_loop = NULL; visual_server = NULL; VideoMode vm; vm.fullscreen = true; vm.width = width; vm.height = height; vm.resizable = false; set_video_mode(vm); event_count = 0; virtual_keyboard_height = 0; // can't call set_data_dir from here, since it requires DirAccess // which is initialized in initialize_core data_dir = p_data_dir; _set_logger(memnew(SyslogLogger)); };
//------------------------------------------------- // device_reset - device-specific reset //------------------------------------------------- void ef9345_device::device_reset() { m_tgs = m_mat = m_pat = m_dor = m_ror = 0; m_state = 0; m_bf = 0; m_block = 0; m_blink = 0; m_latchc0 = 0; m_latchm = 0; m_latchi = 0; m_latchu = 0; m_char_mode = 0; memset(m_last_dial, 0, sizeof(m_last_dial)); memset(m_registers, 0, sizeof(m_registers)); memset(m_border, 0, sizeof(m_border)); memset(m_border, 0, sizeof(m_ram_base)); m_screen_out.fill(0); set_video_mode(); }
int main(int argc, char *argv[]) { /* if (argc > 0) { while (argc > 0) { dos_print ("Unknown Argument: "); dos_print (makefp argv[argc]); argc--; } return (0); } */ init_random (); load_shapes (); demo_res ( Mode_320x200, 320, 200 ); demo_res ( Mode_320x400, 320, 400 ); demo_res ( Mode_360x200, 360, 200 ); demo_res ( Mode_360x400, 360, 400 ); demo_res ( Mode_320x240, 320, 240 ); demo_res ( Mode_320x480, 320, 480 ); demo_res ( Mode_360x240, 360, 240 ); demo_res ( Mode_360x480, 360, 480 ); page_demo (); set_video_mode (3); dos_print ("This Mode X Demo is Finished"); return (0); }
/**************************************************************************** Really resize the main window. ****************************************************************************/ static void real_resize_window_callback(void *data) { struct widget *widget; Uint32 flags = Main.screen->flags; if (gui_sdl_fullscreen) { flags |= SDL_FULLSCREEN; } else { flags &= ~SDL_FULLSCREEN; } set_video_mode(gui_sdl_screen.width, gui_sdl_screen.height, flags); if (C_S_RUNNING == client_state()) { /* Move units window to botton-right corner. */ set_new_unitinfo_window_pos(); /* Move minimap window to botton-left corner. */ set_new_minimap_window_pos(); /* Move cooling/warming icons to botton-right corner. */ widget = get_widget_pointer_form_main_list(ID_WARMING_ICON); widget_set_position(widget, (Main.screen->w - adj_size(10) - (widget->size.w * 2)), widget->size.y); widget = get_widget_pointer_form_main_list(ID_COOLING_ICON); widget_set_position(widget, (Main.screen->w - adj_size(10) - widget->size.w), widget->size.y); map_canvas_resized(Main.screen->w, Main.screen->h); update_info_label(); update_unit_info_label(get_units_in_focus()); center_on_something(); /* With redrawing full map. */ update_order_widgets(); } else { draw_intro_gfx(); dirty_all(); } flush_all(); }
/** * Initialize Real Mode */ void main16(){ // This a static location (see config.h) e820map_t *mem_map = (e820map_t *)E820_LOC; // Setup video mode #if DEBUG == 1 #if VIDEOMODE == 1 set_video_mode(0x03); // Teletype #elif VIDEOMODE == 2 set_svga_mode(0x011B); // 1280x1024 (24 bit) #endif #endif // Enable A20 gate enable_a20(); // Read E820 map read_e820(mem_map); // Exit like we want it! // It's uggly, but as we can not control the entry of this function // at least we can control the exit. RET32(); }
int fs_ml_video_create_window(const char *title) { fs_log("fs_ml_video_create_window\n"); g_window_title = g_strdup(title); g_fs_ml_keyboard_input_grab = fs_config_get_boolean( "keyboard_input_grab"); if (g_fs_ml_automatic_input_grab == FS_CONFIG_NONE) { g_fs_ml_keyboard_input_grab = 1; } fs_log("keyboard input grab: %d\n", g_fs_ml_keyboard_input_grab); static int initialized = 0; #ifdef USE_SDL2 SDL_SetHint(SDL_HINT_GRAB_KEYBOARD, g_fs_ml_keyboard_input_grab ? "1" : "0"); #endif SDL_Init(SDL_INIT_VIDEO); SDL_version version; SDL_VERSION(&version); fs_log("FS-UAE was compiled for SDL %d.%d.%d\n", version.major, version.minor, version.patch); if (!initialized) { #ifdef USE_SDL2 int display_index = 0; SDL_DisplayMode mode; int should_be_zero = SDL_GetCurrentDisplayMode(display_index, &mode); if(should_be_zero != 0) { fs_log("SDL_GetCurrentDisplayMode failed\n"); SDL_ShowSimpleMessageBox( SDL_MESSAGEBOX_ERROR, "Display Error", "SDL_GetCurrentDisplayMode failed.", NULL); exit(1); } #else const SDL_VideoInfo* info = SDL_GetVideoInfo(); #endif g_fullscreen_width = fs_config_get_int("fullscreen_width"); if (g_fullscreen_width == FS_CONFIG_NONE) { #ifdef USE_SDL2 g_fullscreen_width = mode.w; #else g_fullscreen_width = info->current_w; #endif } g_fullscreen_height = fs_config_get_int("fullscreen_height"); if (g_fullscreen_height == FS_CONFIG_NONE) { #ifdef USE_SDL2 g_fullscreen_height = mode.h; #else g_fullscreen_height = info->current_h; #endif } if (g_fs_emu_video_fullscreen_mode_string == NULL) { g_fs_emu_video_fullscreen_mode = -1; } else if (g_ascii_strcasecmp(g_fs_emu_video_fullscreen_mode_string, "window") == 0) { g_fs_emu_video_fullscreen_mode = FULLSCREEN_WINDOW; } else if (g_ascii_strcasecmp(g_fs_emu_video_fullscreen_mode_string, "fullscreen") == 0) { g_fs_emu_video_fullscreen_mode = FULLSCREEN_FULLSCREEN; } #ifdef USE_SDL2 else if (g_ascii_strcasecmp(g_fs_emu_video_fullscreen_mode_string, "desktop") == 0) { g_fs_emu_video_fullscreen_mode = FULLSCREEN_DESKTOP; } #endif if (g_fs_emu_video_fullscreen_mode == -1) { #ifdef MACOSX g_fs_emu_video_fullscreen_mode = FULLSCREEN_FULLSCREEN; #else g_fs_emu_video_fullscreen_mode = FULLSCREEN_FULLSCREEN; #endif #ifdef USE_SDL2 fs_log("defaulting to fullscreen_mode = desktop for SDL2\n"); g_fs_emu_video_fullscreen_mode = FULLSCREEN_DESKTOP; #endif } initialized = 1; } if (g_fs_ml_video_sync) { g_fs_ml_vblank_sync = 1; } SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); #ifdef USE_SDL2 // setting swap interval after creating OpenGL context #else if (g_fs_ml_vblank_sync) { fs_emu_log("*** Setting swap interval to 1 ***\n"); SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1); } else { fs_emu_log("*** Setting swap interval to 0 ***\n"); SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 0); } #endif if (g_fsaa) { fs_log("setting FSAA samples to %d\n", g_fsaa); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, g_fsaa); } g_window_width = fs_config_get_int("window_width"); if (g_window_width == FS_CONFIG_NONE) { g_window_width = 1920 / 2; } g_window_height = fs_config_get_int("window_height"); if (g_window_height == FS_CONFIG_NONE) { g_window_height = 1080/ 2; } #ifdef USE_SDL2 g_window_x = fs_config_get_int("window_x"); if (g_window_x == FS_CONFIG_NONE) { g_window_x = SDL_WINDOWPOS_CENTERED; } g_window_y = fs_config_get_int("window_y"); if (g_window_y == FS_CONFIG_NONE) { g_window_y = SDL_WINDOWPOS_CENTERED; } #endif g_window_resizable = fs_config_get_boolean("window_resizable"); if (g_window_resizable == FS_CONFIG_NONE) { g_window_resizable = 1; } g_fs_ml_automatic_input_grab = fs_config_get_boolean( "automatic_input_grab"); if (g_fs_ml_automatic_input_grab == FS_CONFIG_NONE) { if (fs_ml_mouse_integration()) { g_fs_ml_automatic_input_grab = 0; } else { g_fs_ml_automatic_input_grab = 1; } } fs_log("automatic input grab: %d\n", g_fs_ml_automatic_input_grab); g_initial_input_grab = g_fs_ml_automatic_input_grab; if (fs_config_get_boolean("initial_input_grab") == 1) { g_initial_input_grab = 1; } else if (fs_config_get_boolean("initial_input_grab") == 0 || // deprecated names: fs_config_get_boolean("input_grab") == 0 || fs_config_get_boolean("grab_input") == 0) { g_initial_input_grab = 0; } set_video_mode(); #ifdef USE_SDL2 if (g_fs_ml_vblank_sync) { fs_emu_log("*** Setting swap interval to 1 ***\n"); if (SDL_GL_SetSwapInterval(1) != 0) { fs_emu_warning("SDL_GL_SetSwapInterval(1) failed"); } } else { fs_emu_log("*** Setting swap interval to 0 ***\n"); SDL_GL_SetSwapInterval(0); } #endif // we display a black frame as soon as possible (to reduce flickering on // startup) glClear(GL_COLOR_BUFFER_BIT); #ifdef USE_SDL2 SDL_GL_SwapWindow(g_fs_ml_window); #else SDL_GL_SwapBuffers(); #endif fs_gl_finish(); #ifdef USE_SDL2 // set in SDL_CreateWindow instead #else SDL_WM_SetCaption(g_window_title, fs_get_application_name()); #endif fs_log("initial input grab: %d\n", g_initial_input_grab); if (g_initial_input_grab && !g_has_input_grab) { fs_ml_grab_input(1, 1); } fs_ml_show_cursor(0, 1); // this function must be called from the video thread fs_log("init_opengl\n"); fs_emu_video_init_opengl(); #ifdef WINDOWS #ifdef USE_SDL2 // we use only SDL functions with SDL2 #else fs_ml_init_raw_input(); #endif #else #ifdef USE_SDL2 SDL_StartTextInput(); #else // enable keysym to unicode char translation SDL_EnableUNICODE(1); #endif #endif fs_log("create windows is done\n"); return 1; }
void OSBB10::initialize(const VideoMode& p_desired,int p_video_driver,int p_audio_driver) { data_dir = getenv("HOME"); //Create a screen context that will be used to create an EGL surface to to receive libscreen events screen_create_context(&screen_cxt,0); //Initialize BPS library bps_initialize(); //Use utility code to initialize EGL for 2D rendering with GL ES 1.1 enum RENDERING_API api = GL_ES_2; #ifdef BB10_LGLES_OVERRIDE api = GL_ES_1; #endif if (EXIT_SUCCESS != bbutil_init(screen_cxt, api)) { bbutil_terminate(); screen_destroy_context(screen_cxt); return; }; EGLint surface_width, surface_height; eglQuerySurface(egl_disp, egl_surf, EGL_WIDTH, &surface_width); eglQuerySurface(egl_disp, egl_surf, EGL_HEIGHT, &surface_height); printf("screen size: %ix%i\n", surface_width, surface_height); VideoMode mode; mode.width = surface_width; mode.height = surface_height; mode.fullscreen = true; mode.resizable = false; set_video_mode(mode); //Signal BPS library that navigator and screen events will be requested screen_request_events(screen_cxt); navigator_request_events(0); virtualkeyboard_request_events(0); audiodevice_request_events(0); #ifdef DEBUG_ENABLED bps_set_verbosity(3); #endif accel_supported = accelerometer_is_supported(); if (accel_supported) accelerometer_set_update_frequency(FREQ_40_HZ); pitch = 0; roll = 0; #ifdef BB10_LGLES_OVERRIDE rasterizer = memnew( RasterizerGLES1(false) ); #else rasterizer = memnew( RasterizerGLES2(false, false) ); #endif visual_server = memnew( VisualServerRaster(rasterizer) ); visual_server->init(); visual_server->cursor_set_visible(false, 0); audio_driver = memnew(AudioDriverBB10); audio_driver->set_singleton(); audio_driver->init(NULL); physics_server = memnew( PhysicsServerSW ); physics_server->init(); physics_2d_server = memnew( Physics2DServerSW ); physics_2d_server->init(); input = memnew( InputDefault ); #ifdef PAYMENT_SERVICE_ENABLED payment_service = memnew(PaymentService); Globals::get_singleton()->add_singleton(Globals::Singleton("InAppStore", payment_service)); #endif }
int main(int argc, char *argv[]) { int ret = 0; int i; allegro_init(); install_keyboard(); install_mouse(); install_timer(); srand(time(NULL)); for (i=1; i<argc; i++) { if (stricmp(argv[i], "-bpp") == 0) { if ((i >= argc-1) || (bpp > 0)) { usage(); return 1; } bpp = atoi(argv[++i]); } else if (stricmp(argv[i], "-frames") == 0) { if ((i >= argc-1) || (frames > 0)) { usage(); return 1; } frames = atoi(argv[++i]); } else if (stricmp(argv[i], "-size") == 0) { if ((i >= argc-2) || (size_x > 0) || (size_y > 0)) { usage(); return 1; } size_x = atoi(argv[++i]); size_y = atoi(argv[++i]); } else if (stricmp(argv[i], "-mode") == 0) { if ((i >= argc-2) || (mode_x > 0) || (mode_y > 0)) { usage(); return 1; } mode_x = atoi(argv[++i]); mode_y = atoi(argv[++i]); } else if (stricmp(argv[i], "-step") == 0) { step = TRUE; } else if (stricmp(argv[i], "-modesel") == 0) { modesel = TRUE; } else if (stricmp(argv[i], "-pregen") == 0) { pregen = TRUE; } else if (stricmp(argv[i], "-o") == 0) { if ((i >= argc-1) || (out_file)) { usage(); return 1; } out_file = argv[++i]; } else if (stricmp(argv[i], "-pal") == 0) { if ((i >= argc-1) || (pal_file)) { usage(); return 1; } pal_file = argv[++i]; } else { if ((*argv[i] == '-') || (in_file)) { usage(); return 1; } in_file = argv[i]; } } if (!in_file) { usage(); return 1; } if ((pregen) && ((frames <= 0) || (step))) { allegro_message("The '-pregen' option requires '-frames num' to be specified,\nand cannot be used at the same time as '-step'\n"); return 1; } if (!set_video_mode()) { ret = 1; goto getout; } the_egg = load_egg(in_file, error); if (!the_egg) { set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); allegro_message("%s", error); return 1; } if (size_x <= 0) size_x = 128; if (size_y <= 0) size_y = 128; if (pal_file) { BITMAP *tmp = load_bitmap(pal_file, pal); if (!tmp) { set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); allegro_message("Error reading palette from '%s'\n", pal_file); ret = 1; goto getout; } destroy_bitmap(tmp); } else generate_332_palette(pal); clear(screen); set_palette(pal); text_mode(0); do { if (pregen) { textprintf_centre(screen, font, SCREEN_W/2, SCREEN_H/2-24, makecol(128, 128, 128), "Rendering frame %d/%d", the_egg->frame+1, frames); textprintf_centre(screen, font, SCREEN_W/2, SCREEN_H/2+24, makecol(128, 128, 128), "Please Wait"); } if (update_egg(the_egg, error) != 0) { allegro_exit(); printf("Error running EGG script:\n%s\n\n", error); ret = 1; goto getout; } bmp[frame] = create_bitmap(size_x, size_y); lay_egg(the_egg, bmp[frame]); if (!pregen) { vsync(); blit(bmp[frame], screen, 0, 0, (SCREEN_W-size_x)/2, (SCREEN_H-size_y)/2, size_x, size_y); textprintf(screen, font, 0, 0, makecol(128, 128, 128), "Frame %d, %d particles ", the_egg->frame, the_egg->part_count); } if ((!pregen) && (!out_file)) { destroy_bitmap(bmp[frame]); bmp[frame] = NULL; } frame++; if ((step) || (keypressed())) { if ((readkey()&0xFF) == 27) break; clear_keybuf(); } } while (((frames <= 0) || (frame < frames)) && (frame < 4096)); if (pregen) view_animation(); if (out_file) save_animation(); getout: if (the_egg) destroy_egg(the_egg); for (i=0; i<frame; i++) if (bmp[frame]) destroy_bitmap(bmp[frame]); return ret; }
/** * \brief Turn fullscreen mode on/off. * \param b Tell if we want a fullscreen mode. */ void bear::visual::gl_screen::fullscreen( bool b ) { set_video_mode(m_size.x, m_size.y, b); } // gl_screen::fullscreen()
int fs_ml_video_create_window(const char *title) { fs_log("fs_ml_video_create_window\n"); g_window_title = g_strdup(title); static int initialized = 0; SDL_Init(SDL_INIT_VIDEO); #ifdef HAVE_GLES if (!EGL_Open()) exit(1); #endif if (!initialized) { const SDL_VideoInfo* info = SDL_GetVideoInfo(); g_fullscreen_width = fs_config_get_int("fullscreen_width"); if (g_fullscreen_width == FS_CONFIG_NONE) { g_fullscreen_width = info->current_w; } g_fullscreen_height = fs_config_get_int("fullscreen_height"); if (g_fullscreen_height == FS_CONFIG_NONE) { g_fullscreen_height = info->current_h; } if (g_fs_emu_video_fullscreen_mode == NULL) { g_fs_emu_video_fullscreen_window = -1; } else if (g_strcasecmp(g_fs_emu_video_fullscreen_mode, "window") == 0) { g_fs_emu_video_fullscreen_window = 1; } else if (g_strcasecmp(g_fs_emu_video_fullscreen_mode, "fullscreen") == 0) { g_fs_emu_video_fullscreen_window = 0; } if (g_fs_emu_video_fullscreen_window == -1) { #ifdef MACOSX g_fs_emu_video_fullscreen_window = 0; #else g_fs_emu_video_fullscreen_window = 0; #endif } initialized = 1; } if (g_fs_ml_video_sync) { g_fs_ml_vblank_sync = 1; } #ifndef HAVE_GLES SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); if (g_fs_ml_vblank_sync) { fs_emu_log("*** SDL_GL_SWAP_CONTROL is enabled ***\n"); SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1); } else { fs_emu_log("*** SDL_GL_SWAP_CONTROL is disabled ***\n"); SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 0); } if (g_fsaa) { fs_log("setting FSAA samples to %d\n", g_fsaa); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, g_fsaa); } #endif g_window_width = fs_config_get_int("window_width"); if (g_window_width == FS_CONFIG_NONE) { g_window_width = 1920 / 2; } g_window_height = fs_config_get_int("window_height"); if (g_window_height == FS_CONFIG_NONE) { g_window_height = 1080/ 2; } g_window_resizable = fs_config_get_boolean("window_resizable"); if (g_window_resizable == FS_CONFIG_NONE) { g_window_resizable = 1; } set_video_mode(); #ifdef HAVE_GLES EGL_Init(); #endif // we display a black frame as soon as possible (to reduce flickering on // startup) glClear(GL_COLOR_BUFFER_BIT); SDL_GL_SwapBuffers(); fs_gl_finish(); SDL_WM_SetCaption(g_window_title, g_get_application_name()); if (fs_config_get_boolean("grab_input") != 0) { fs_ml_grab_input(1, 1); } fs_ml_show_cursor(0, 1); // this function must be called from the video thread fs_log("init_opengl\n"); fs_emu_video_init_opengl(); #ifdef WINDOWS fs_ml_init_raw_input(); #else // enable keysym to unicode char translation SDL_EnableUNICODE(1); #endif fs_log("create windows is done\n"); return 1; }
void page_demo () { char *Error1 = "Failure during SET_VGA_MODEX (0, 320, 200, 2) call"; int Last_Objects[2], Visible_Objects; int Screen_X = 384; int Screen_Y = 224; int x, y, z; int c, dc; int x1, y1, x2, y2; int Sprite_X, Sprite_Y; int Current_Page; int New_X, New_Y; int View_X, View_Y, View_Max, View_Cnt, View_XD, View_YD; int Set_Color, Prev_Color, S_Dir, P_Dir; int Demo_Running = True; int redo, code; int pee; pee = set_vga_modex(Mode_320x200, Screen_X, Screen_Y, 3); if ( pee > 0) { set_video_mode (3); dos_print (Error1); fprintf(stdout, "return value is %d\n", pee); //error_out (Error1); exit (EXIT_SUCCESS); } set_active_page (0); clear_vga_screen (c_BLACK); print_str ("This is a Test of the Following Functions:", 99, 10, 9, c_bWHITE, c_BLACK); draw_line (10, 18, 350, 18, c_YELLOW); print_str ("SET_ACTIVE_PAGE", 99, 10, 20, c_bBLUE, c_BLACK); print_str ("SET_DISPLAY_PAGE", 99, 10, 30, c_GREEN, c_BLACK); print_str ("SET_DAC_REGISTER", 99, 10, 40, c_RED, c_BLACK); print_str ("CLEAR_VGA_SCREEN", 99, 10, 50, c_CYAN, c_BLACK); print_str ("TDRAW_BITMAP", 99, 10, 60, c_PURPLE, c_BLACK); print_str ("COPY_PAGE", 99, 10, 70, c_GREEN, c_BLACK); print_str ("COPY_BITMAP", 99, 10, 80, c_CYAN, c_BLACK); print_str ("GPRINTC", 99, 10, 90, c_BLUE, c_BLACK); print_str ("TGPRINTC", 99, 10, 100, c_GREEN, c_BLACK); print_str ("SET_WINDOW", 99, 10, 110, c_RED, c_BLACK); print_str ("VIRTUAL SCREEN SIZES", 20, 190, 20, c_bBLUE, c_BLACK); print_str (" SMOOTH SCROLLING", 20, 190, 30, c_GREEN, c_BLACK); print_str (" SPRITE ANIMATION", 20, 190, 40, c_CYAN, c_BLACK); print_str (" PAGE FLIPPING", 20, 190, 50, c_RED, c_BLACK); print_str (" COLOR CYCLING", 20, 190, 60, c_PURPLE, c_BLACK); for (x = 0; x <=60; x++) { set_dac_register (50 + x, 3 + x, 0, 60 - x); set_dac_register (150 + x, 3 + x, 0, 60 - x); } c = 0; dc = 1; for (x = 0; x <= (Screen_X / 2); x++) { draw_line (Screen_X / 2 - 1, Screen_Y / 4, x, Screen_Y - 1, c + 50); draw_line (Screen_X / 2, Screen_Y / 4, Screen_X - x - 1, Screen_Y - 1, c + 50); c+= dc; if ((c == 0) || (c == 60) ) { dc = -dc;} } tprint_str ("Press <ANY KEY> to Continue", 99, 72, 190, c_bWHITE); tprint_str ("< > = Faster < > = Slower", 99, 72, 204, c_bGREEN); tprint_str ("< > = Fewer Shapes < > = More Shapes", 99, 32, 218, c_bCYAN); tgprintc (43, 80, 204, c_YELLOW); tgprintc (45, 200, 204, c_YELLOW); tgprintc (25, 40, 218, c_YELLOW); tgprintc (24, 200, 218, c_YELLOW); copy_page (0, 1); copy_page (0, 2); for (x = 0; x < MAX_SPRITES; x++) { do { Obj[x].X_Dir = random_int(7) - 3; Obj[x].Y_Dir = random_int(7) - 3; } while ( (Obj[x].X_Dir == 0) && (Obj[x].Y_Dir == 0) ); Obj[x].Shape = x % MAX_SHAPES; Sprite_X = Img[Obj[x].Shape].X_Width; Sprite_Y = Img[Obj[x].Shape].Y_Width; Obj[x].X_pos = 1 + random_int(Screen_X - Sprite_X - 2); Obj[x].Y_pos = 1 + random_int(Screen_Y - Sprite_Y - 2); Obj[x].Last_X[0] = Obj[x].X_pos; Obj[x].Last_X[1] = Obj[x].X_pos; Obj[x].Last_Y[0] = Obj[x].Y_pos; Obj[x].Last_Y[1] = Obj[x].Y_pos; } Current_Page = 0; View_X = 0; View_Y = 0; View_Max = 3; View_Cnt = 0; View_XD = 1; View_YD = 1; Set_Color = 3; S_Dir = 1; Prev_Color = 0; P_Dir = 1; Visible_Objects = MAX_SPRITES / 2; Last_Objects[0] = 0; Last_Objects[1] = 0; while (Demo_Running) { set_active_page (Current_Page); /* Erase Old Images */ for (x = 0; x <= Last_Objects[Current_Page]; x++) { z = 2; y = Obj[x].Shape; x1 = Obj[x].Last_X[Current_Page]; y1 = Obj[x].Last_Y[Current_Page]; x2 = x1 + Img[y].X_Width -1; y2 = y1 + Img[y].Y_Width -1; x1 = x1 & 0xfffc; x2 = x2 | 0x0003; copy_bitmap (z, x1, y1, x2, y2, Current_Page, x1, y1); } /* Draw new images */ for (x = 0; x <= Visible_Objects; x++) { Sprite_X = Img[Obj[x].Shape].X_Width; Sprite_Y = Img[Obj[x].Shape].Y_Width; /* Move Sprite */ do { redo = False; New_X = Obj[x].X_pos + Obj[x].X_Dir; if (( New_X < 0 ) || (New_X + Sprite_X > Screen_X) ) { Obj[x].X_Dir = -Obj[x].X_Dir; if (random_int(20) == 1) { do { Obj[x].X_Dir = random_int(7) - 3; Obj[x].Y_Dir = random_int(7) - 3; } while ( (Obj[x].X_Dir == 0) && (Obj[x].Y_Dir == 0) ); redo = True; } } } while (redo); Obj[x].X_pos = Obj[x].X_pos + Obj[x].X_Dir; do { redo = False; New_Y = Obj[x].Y_pos + Obj[x].Y_Dir; if ( (New_Y < 0) || (New_Y + Sprite_Y > Screen_Y) ) { Obj[x].Y_Dir = -Obj[x].Y_Dir; if (random_int(20) == 1) { do { Obj[x].X_Dir = random_int(7) - 3; Obj[x].Y_Dir = random_int(7) - 3; } while ( (Obj[x].X_Dir == 0) && (Obj[x].Y_Dir == 0) ); redo = True; } } } while (redo); Obj[x].Y_pos = Obj[x].Y_pos + Obj[x].Y_Dir; /* Draw Sprite */ tdraw_bitmap ((char far*) &Img[Obj[x].Shape], Obj[x].X_pos, Obj[x].Y_pos, Sprite_X, Sprite_Y); Obj[x].Last_X[Current_Page] = Obj[x].X_pos; Obj[x].Last_Y[Current_Page] = Obj[x].Y_pos; } Last_Objects[Current_Page] = Visible_Objects; /* Pan Screen Back & Forth */ View_Cnt++; if (View_Cnt >= View_Max) { View_X+= View_XD; if ( (View_X == 0) || (View_X == 39) ) {View_XD = -View_XD;} if (View_XD < 0) { View_Y+= View_YD; if ( (View_Y == 0) || (View_Y == 39) ) {View_YD = -View_YD;} } set_window (Current_Page, View_X, View_Y); View_Cnt = 0; } else { set_display_page (Current_Page); } /* Cycle Colors */ set_dac_register (50 + Prev_Color, 3 + Prev_Color, 0, 60 - Prev_Color); set_dac_register (50 + Set_Color, Set_Color, 10, 63 - Set_Color); set_dac_register (150 + Prev_Color, 3 + Prev_Color, 0, 60 - Prev_Color); set_dac_register (150 + Set_Color, 63, 63, Set_Color); Set_Color+= S_Dir; if ( (Set_Color == 60) || (Set_Color == 0) ) {S_Dir = -S_Dir;} Prev_Color+= P_Dir; if ( (Prev_Color == 60) || (Prev_Color == 0) ) {P_Dir = -P_Dir;} /* Check for Keystroke */ Current_Page = Current_Page ^ 0x01; code = scan_keyboard (); if (code == Ky_ESC) {Demo_Running = False;} if (code == Ky_Plus) { if (View_Max < 12) {View_Max++;} } if (code == Ky_Minus) { if (View_Max > 1) {View_Max--;} if (View_Cnt >= View_Max) {View_Cnt = 0;} } if (code == Ky_Up) { if (Visible_Objects < MAX_SPRITES-1) {Visible_Objects++;} } if (code == Ky_Down) { if (Visible_Objects > 0) {Visible_Objects--;} } } }
int graph_init_video(void) { int rc = 0; int screen_colours; vga_modeinfo *vminfo; if (tcgetpgrp(STDIN_FILENO) != getpid()) { fprintf(stderr, "Sorry, this application cannot start in background\n"); return 0; } pltf = PLTF_SVGA; /*-----------------------------------------------------------*/ /* Checking libvga version, 1.4.0 and prior will return (-1) */ /* Currently you need IOPERM for 1.9.x to run as a non-priv */ /* user, however set IOPERM upsets upsets previous versions */ /*-----------------------------------------------------------*/ if (vga_setmode(-1) >= 0x1900) setenv("IOPERM", "1", 0); rc = vga_init(); if (rc != 0) { fprintf(stderr, "Can't initialise SVGA library. \n" "Possible solution: log as root, and enter:\n" "\tchown 0 ifrac\n" "\tchmod 4755 ifrac\n"); return 0; } #ifdef SVGALIB_BACKGROUND_SUPPORT set_background_routines(); #else run_background = 0; #endif if (!set_video_mode()) { fprintf(stderr, "Sorry, unable to set video mode. \n"); return 0; } vminfo = vga_getmodeinfo(vga_getcurrentmode()); WndWidth = ScrWidth = vminfo->width; WndHeight = ScrHeight = vminfo->height; screen_colours = vminfo->colors; if (screen_colours < 16) { fprintf (stderr, "This application requires at least 16-colour mode\n"); return 0; } ScrDepth = 0; while((screen_colours>>=1) != 0) ScrDepth++; if (ScrDepth <= 8) { BytesPerPixel = 1; stored_colours = 1; } else { BytesPerPixel = vminfo->bytesperpixel; stored_colours = 0; } scan_line_width = vminfo->linewidth; screen_size = scan_line_width * ScrHeight; if (ScrDepth < 8) DirVideo = 0; else { vga_setpage(screen_page=0); if (DirVideo == 2 && (vminfo->flags & CAPABLE_LINEAR)) lbuf_len = vga_setlinearaddressing(); if (DirVideo > 0) lbuf_addr = vga_getgraphmem(); } return 1; }
surface& surface::set_video_as_hard_dbl_alpha(int width,int height,bool full_screen) { uint32_t flags=SDL_HWSURFACE|SDL_DOUBLEBUF; if(full_screen) flags|=SDL_FULLSCREEN; return set_video_mode(width,height,32,flags); }
int main(int argc, char *argv[]) { int result = ACTION_NONE; int leave = 0; /* i18n */ #ifdef ENABLE_NLS setlocale (LC_ALL, ""); bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); #endif /* ltris info */ printf( "LTris %s\nCopyright 2002-2005 Michael Speck\nPublished under GNU GPL\n---\n", VERSION ); printf( "Looking up data in: %s\n", SRC_DIR ); #ifndef SOUND printf( "Compiled without sound and music\n" ); #endif set_random_seed(); /* set random seed */ /* game ids - not translated to be fixed independant of language */ strcpy(gametype_ids[0],"demo"); strcpy(gametype_ids[1],"classic"); strcpy(gametype_ids[2],"figures"); strcpy(gametype_ids[3],"vshuman"); strcpy(gametype_ids[4],"vscpu"); strcpy(gametype_ids[5],"vshumanhuman"); strcpy(gametype_ids[6],"vshumancpu"); strcpy(gametype_ids[7],"vscpucpu"); /* game names - translated for display */ strcpy(gametype_names[0],_("Demo")); strcpy(gametype_names[1],_("Classic")); strcpy(gametype_names[2],_("Figures")); strcpy(gametype_names[3],_("Vs Human")); strcpy(gametype_names[4],_("Vs CPU")); strcpy(gametype_names[5],_("Vs Human&Human")); strcpy(gametype_names[6],_("Vs Human&CPU")); strcpy(gametype_names[7],_("Vs CPU&CPU")); config_load(); init_sdl( SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER ); set_video_mode( std_video_mode( config.fullscreen ) ); SDL_WM_SetCaption( "LTris", 0 ); sdl.fade = config.fade; SDL_SetEventFilter( event_filter ); #ifdef SOUND audio_open(); sound_enable( config.sound ); sound_volume( config.volume * 16 ); #endif /* create */ hint_load_res(); manager_create(); tetris_create(); chart_load(); /* run game */ manager_fade( FADE_IN ); while( !leave && !term_game ) { result = manager_run(); switch( result ) { case ACTION_QUIT: leave = 1; break; case ACTION_MAKE_STAT: manager_fade( FADE_OUT ); tetris_make_stat(); manager_fade( FADE_IN ); break; case ACTION_PLAY: manager_fade( FADE_OUT ); if ( tetris_init() ) { tetris_run(); tetris_clear(); } manager_fade( FADE_IN ); break; default: break; } } manager_fade( FADE_OUT ); /* delete stuff */ tetris_delete(); manager_delete(); chart_save(); chart_delete(); hint_delete_res(); #ifdef SOUND audio_close(); #endif config_save(); return EXIT_SUCCESS; }
static int init(void) { int i; struct palm_color *pal; init_timer(under_windows ? 0 : 100); set_video_mode(0x13); signal(SIGINT, sighandler); signal(SIGSEGV, sighandler); signal(SIGFPE, sighandler); signal(SIGILL, sighandler); signal(SIGABRT, sighandler); have_mouse(); if(mgl_init(320, 200) == -1) { fprintf(stderr, "mgl init failed\n"); return -1; } fbuf = mgl_framebuffer(); if(!texfile) { palm_add_color(255, 255, 255); palm_add_color(255, 0, 0); palm_add_color(0, 255, 0); palm_add_color(0, 0, 255); palm_build(); white_base = palm_color_base(255, 255, 255); red_base = palm_color_base(255, 0, 0); green_base = palm_color_base(0, 255, 0); blue_base = palm_color_base(0, 0, 255); tex = tex_gen_checker(64, 64, 3, 3, red_base, blue_base); } else { if(!(tex = load_texture(texfile))) { return -1; } palm_build(); get_texture_pixels(tex); mgl_enable(MGL_TEXTURE_2D); } grad_range = palm_color_range(); pal = palm_palette(); for(i=0; i<palm_palette_size(); i++) { set_pal_entry(i, pal[i].r, pal[i].g, pal[i].b); } mgl_enable(MGL_CULL_FACE); mgl_enable(MGL_DEPTH_TEST); mgl_enable(MGL_SMOOTH); mgl_color_range(grad_range - 1); /* gradient range */ mgl_enable(MGL_LIGHTING); mgl_light_intensity(0, 1.0); mgl_light_position(0, -0.5, 0.5, 1, 0); mgl_matrix_mode(MGL_PROJECTION); mgl_load_identity(); mgl_perspective(45.0, 320.0 / 200.0, 0.5, 100.0); mgl_teximage(tex->width, tex->height, tex->pixels); return 0; }
static void shutdown(void) { mgl_free(); set_video_mode(3); }
/************************************************************************** The main loop for the UI. This is called from main(), and when it exits the client will exit. **************************************************************************/ void ui_main(int argc, char *argv[]) { SDL_Event __Net_User_Event; SDL_Event __GGZ_User_Event; SDL_Event __Anim_User_Event; SDL_Event __Info_User_Event; SDL_Event __Flush_User_Event; SDL_Event __pMap_Scroll_User_Event; parse_options(argc, argv); __Net_User_Event.type = SDL_USEREVENT; __Net_User_Event.user.code = NET; __Net_User_Event.user.data1 = NULL; __Net_User_Event.user.data2 = NULL; pNet_User_Event = &__Net_User_Event; __GGZ_User_Event.type = SDL_USEREVENT; __GGZ_User_Event.user.code = GGZ; __GGZ_User_Event.user.data1 = NULL; __GGZ_User_Event.user.data2 = NULL; pGGZ_User_Event = &__GGZ_User_Event; __Anim_User_Event.type = SDL_USEREVENT; __Anim_User_Event.user.code = EVENT_ERROR; __Anim_User_Event.user.data1 = NULL; __Anim_User_Event.user.data2 = NULL; pAnim_User_Event = &__Anim_User_Event; __Info_User_Event.type = SDL_USEREVENT; __Info_User_Event.user.code = SHOW_WIDGET_INFO_LABBEL; __Info_User_Event.user.data1 = NULL; __Info_User_Event.user.data2 = NULL; pInfo_User_Event = &__Info_User_Event; __Flush_User_Event.type = SDL_USEREVENT; __Flush_User_Event.user.code = FLUSH; __Flush_User_Event.user.data1 = NULL; __Flush_User_Event.user.data2 = NULL; pFlush_User_Event = &__Flush_User_Event; __pMap_Scroll_User_Event.type = SDL_USEREVENT; __pMap_Scroll_User_Event.user.code = MAP_SCROLL; __pMap_Scroll_User_Event.user.data1 = NULL; __pMap_Scroll_User_Event.user.data2 = NULL; pMap_Scroll_User_Event = &__pMap_Scroll_User_Event; is_unit_move_blocked = FALSE; SDL_Client_Flags |= (CF_DRAW_PLAYERS_NEUTRAL_STATUS| CF_DRAW_PLAYERS_WAR_STATUS| CF_DRAW_PLAYERS_CEASEFIRE_STATUS| CF_DRAW_PLAYERS_PEACE_STATUS| CF_DRAW_PLAYERS_ALLIANCE_STATUS); tileset_init(tileset); tileset_load_tiles(tileset); tileset_use_prefered_theme(tileset); load_cursors(); callbacks = callback_list_new(); diplomacy_dialog_init(); intel_dialog_init(); clear_double_messages_call(); setup_auxiliary_tech_icons(); if (gui_sdl_fullscreen) { #ifdef SMALL_SCREEN #ifdef UNDER_CE /* set 320x240 fullscreen */ set_video_mode(gui_sdl_screen.width, gui_sdl_screen.height, SDL_SWSURFACE | SDL_ANYFORMAT | SDL_FULLSCREEN); #else /* UNDER_CE */ /* small screen on desktop -> don't set 320x240 fullscreen mode */ set_video_mode(gui_sdl_screen.width, gui_sdl_screen.height, SDL_SWSURFACE | SDL_ANYFORMAT); #endif /* UNDER_CE */ #else /* SMALL_SCREEN */ set_video_mode(gui_sdl_screen.width, gui_sdl_screen.height, SDL_SWSURFACE | SDL_ANYFORMAT | SDL_FULLSCREEN); #endif /* SMALL_SCREEN */ } else { #ifdef SMALL_SCREEN #ifdef UNDER_CE set_video_mode(gui_sdl_screen.width, gui_sdl_screen.height, SDL_SWSURFACE | SDL_ANYFORMAT); #else /* UNDER_CE */ set_video_mode(gui_sdl_screen.width, gui_sdl_screen.height, SDL_SWSURFACE | SDL_ANYFORMAT); #endif /* UNDER_CE */ #else /* SMALL_SCREEN */ set_video_mode(gui_sdl_screen.width, gui_sdl_screen.height, SDL_SWSURFACE | SDL_ANYFORMAT); #endif /* SMALL_SCREEN */ #if 0 /* * call this for other that X enviroments - currently not supported. */ center_main_window_on_screen(); #endif /* 0 */ } /* SDL_WM_SetCaption(_("SDL Client for Freeciv"), _("Freeciv")); */ /* this need correct Main.screen size */ init_mapcanvas_and_overview(); set_client_state(C_S_DISCONNECTED); /* Main game loop */ gui_event_loop(NULL, NULL, main_key_down_handler, main_key_up_handler, main_mouse_button_down_handler, main_mouse_button_up_handler, main_mouse_motion_handler); }
/************************************************************************** Do any necessary pre-initialization of the UI, if necessary. **************************************************************************/ void ui_init(void) { char device[20]; /* struct widget *pInit_String = NULL;*/ SDL_Surface *pBgd; Uint32 iSDL_Flags; button_behavior.counting = FALSE; button_behavior.button_down_ticks = 0; button_behavior.hold_state = MB_HOLD_SHORT; button_behavior.event = fc_calloc(1, sizeof(SDL_MouseButtonEvent)); SDL_Client_Flags = 0; iSDL_Flags = SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE; /* auto center new windows in X enviroment */ putenv((char *)"SDL_VIDEO_CENTERED=yes"); init_sdl(iSDL_Flags); log_normal(_("Using Video Output: %s"), SDL_VideoDriverName(device, sizeof(device))); /* create splash screen */ #ifdef SMALL_SCREEN { SDL_Surface *pTmpSurf = load_surf(fileinfoname(get_data_dirs(), "misc/intro.png")); pBgd = zoomSurface(pTmpSurf, DEFAULT_ZOOM, DEFAULT_ZOOM, 0); FREESURFACE(pTmpSurf); } #else /* SMALL_SCREEN */ pBgd = load_surf(fileinfoname(get_data_dirs(), "misc/intro.png")); #endif /* SMALL_SCREEN */ if (pBgd && SDL_GetVideoInfo()->wm_available) { set_video_mode(pBgd->w, pBgd->h, SDL_SWSURFACE | SDL_ANYFORMAT); #if 0 /* * call this for other than X enviroments - currently not supported. */ center_main_window_on_screen(); #endif /* 0 */ alphablit(pBgd, NULL, Main.map, NULL); putframe(Main.map, 0, 0, Main.map->w - 1, Main.map->h - 1, &(SDL_Color) { 255, 255, 255, 255 }); FREESURFACE(pBgd); SDL_WM_SetCaption(_("SDL Client for Freeciv"), _("Freeciv")); } else { #ifndef SMALL_SCREEN set_video_mode(640, 480, SDL_SWSURFACE | SDL_ANYFORMAT); #else /* SMALL_SCREEN */ set_video_mode(320, 240, SDL_SWSURFACE | SDL_ANYFORMAT); #endif /* SMALL_SCREEN */ if(pBgd) { blit_entire_src(pBgd, Main.map, (Main.map->w - pBgd->w) / 2, (Main.map->h - pBgd->h) / 2); FREESURFACE(pBgd); } else { SDL_FillRect(Main.map, NULL, SDL_MapRGB(Main.map->format, 0, 0, 128)); SDL_WM_SetCaption(_("SDL Client for Freeciv"), _("Freeciv")); } } #if 0 /* create label beackground */ pBgd = create_surf_alpha(adj_size(350), adj_size(50), SDL_SWSURFACE); SDL_FillRect(pBgd, NULL, SDL_MapRGBA(pBgd->format, 255, 255, 255, 128)); putframe(pBgd, 0, 0, pBgd->w - 1, pBgd->h - 1, SDL_MapRGB(pBgd->format, 0, 0, 0)); pInit_String = create_iconlabel(pBgd, Main.gui, create_str16_from_char(_("Initializing Client"), adj_font(20)), WF_ICON_CENTER|WF_FREE_THEME); pInit_String->string16->style |= SF_CENTER; draw_label(pInit_String, (Main.screen->w - pInit_String->size.w) / 2, (Main.screen->h - pInit_String->size.h) / 2); flush_all(); copy_chars_to_string16(pInit_String->string16, _("Waiting for the beginning of the game")); #endif /* 0 */ flush_all(); }
void setup (void) { SDL_Surface * image; TTF_Font *temp1, *temp2; SDL_Color color; SDL_Rect rect, rect2; int g; char buffer_file[8192]; char *systemdata_path = get_systemdata_path (); /* Inicializar el Video SDL */ if (SDL_Init(SDL_INIT_VIDEO) < 0) { fprintf (stderr, _("Error: Can't initialize the video subsystem\n" "The error returned by SDL is:\n" "%s\n"), SDL_GetError()); exit (1); } sprintf (buffer_file, "%simages/icon.png", systemdata_path); image = IMG_Load (buffer_file); if (image) { SDL_WM_SetIcon (image, NULL); SDL_FreeSurface (image); } SDL_WM_SetCaption (_("Paddle Puffle"), _("Paddle Puffle")); /* Crear la pantalla de dibujado */ screen = set_video_mode (0); if (screen == NULL) { fprintf (stderr, _("Error: Can't setup 760x480 video mode.\n" "The error returned by SDL is:\n" "%s\n"), SDL_GetError()); exit (1); } use_sound = 1; if (SDL_InitSubSystem (SDL_INIT_AUDIO) < 0) { fprintf (stdout, _("Warning: Can't initialize the audio subsystem\n" "Continuing...\n")); use_sound = 0; } if (use_sound) { /* Inicializar el sonido */ if (Mix_OpenAudio (22050, AUDIO_S16, 2, 4096) < 0) { fprintf (stdout, _("Warning: Can't initialize the SDL Mixer library\n")); use_sound = 0; } } for (g = 0; g < NUM_IMAGES; g++) { sprintf (buffer_file, "%s%s", systemdata_path, images_names[g]); image = IMG_Load (buffer_file); if (image == NULL) { fprintf (stderr, _("Failed to load data file:\n" "%s\n" "The error returned by SDL is:\n" "%s\n"), buffer_file, SDL_GetError()); SDL_Quit (); exit (1); } images[g] = image; /* TODO: Mostrar la carga de porcentaje */ } /* Pre-Dibujar la pantalla gris */ grey_screen = SDL_CreateRGBSurface (SDL_SWSURFACE | SDL_SRCALPHA, 760, 480, 32, 0, 0, 0, 0); SDL_FillRect (grey_screen, NULL, SDL_MapRGB (grey_screen->format, 0, 0, 0)); /* Negro */ SDL_SetAlpha (grey_screen, SDL_SRCALPHA, 128); /* Alpha al 50 % */ if (use_sound) { for (g = 0; g < NUM_SOUNDS; g++) { sprintf (buffer_file, "%s%s", systemdata_path, sound_names[g]); sounds[g] = Mix_LoadWAV (buffer_file); if (sounds[g] == NULL) { fprintf (stderr, _("Failed to load data file:\n" "%s\n" "The error returned by SDL is:\n" "%s\n"), buffer_file, SDL_GetError ()); SDL_Quit (); exit (1); } Mix_VolumeChunk (sounds[g], MIX_MAX_VOLUME / 2); } /* Cargar la música */ sprintf (buffer_file, "%s%s", systemdata_path, MUS_CARNIE); mus_carnie = Mix_LoadMUS (buffer_file); if (mus_carnie == NULL) { fprintf (stderr, _("Failed to load data file:\n" "%s\n" "The error returned by SDL is:\n" "%s\n"), buffer_file, SDL_GetError ()); SDL_Quit (); exit (1); } } if (TTF_Init () < 0) { fprintf (stderr, _("Error: Can't initialize the SDL TTF library\n" "%s\n"), TTF_GetError ()); SDL_Quit (); exit (1); } /* Tipografias 10, 14, 16, 26 */ sprintf (buffer_file, "%s%s", systemdata_path, "ccfacefront.ttf"); ttf_facefront = SDL_RWFromFile (buffer_file, "rb"); if (ttf_facefront == NULL) { fprintf (stderr, _("Failed to load font file 'CCFaceFront'\n" "The error returned by SDL is:\n" "%s\n"), TTF_GetError ()); SDL_Quit (); exit (1); } SDL_RWseek (ttf_facefront, 0, RW_SEEK_SET); temp1 = TTF_OpenFontRW (ttf_facefront, 0, 10); SDL_RWseek (ttf_facefront, 0, RW_SEEK_SET); ttf14_normal = TTF_OpenFontRW (ttf_facefront, 0, 14); SDL_RWseek (ttf_facefront, 0, RW_SEEK_SET); ttf16_normal = TTF_OpenFontRW (ttf_facefront, 0, 16); SDL_RWseek (ttf_facefront, 0, RW_SEEK_SET); ttf26_normal = TTF_OpenFontRW (ttf_facefront, 0, 26); if (!temp1 || !ttf14_normal || !ttf16_normal || !ttf26_normal) { SDL_Quit (); exit (1); } SDL_RWseek (ttf_facefront, 0, RW_SEEK_SET); ttf20_normal = TTF_OpenFontRW (ttf_facefront, 0, 20); SDL_RWseek (ttf_facefront, 0, RW_SEEK_SET); ttf20_outline = TTF_OpenFontRW (ttf_facefront, 0, 20); SDL_RWseek (ttf_facefront, 0, RW_SEEK_SET); ttf16_outline = TTF_OpenFontRW (ttf_facefront, 1, 16); if (!ttf20_normal || !ttf20_outline || !ttf16_outline) { SDL_Quit (); exit (1); } TTF_SetFontStyle (temp1, TTF_STYLE_ITALIC); TTF_SetFontStyle (ttf14_normal, TTF_STYLE_ITALIC); TTF_SetFontStyle (ttf16_normal, TTF_STYLE_ITALIC); TTF_SetFontStyle (ttf26_normal, TTF_STYLE_ITALIC); TTF_SetFontStyle (ttf16_outline, TTF_STYLE_ITALIC); TTF_SetFontStyle (ttf20_outline, TTF_STYLE_ITALIC); TTF_SetFontStyle (ttf20_normal, TTF_STYLE_ITALIC); TTF_SetFontOutline (ttf16_outline, OUTLINE_TEXT); TTF_SetFontOutline (ttf20_outline, OUTLINE_TEXT); /* Generar textos */ bind_textdomain_codeset (PACKAGE, "UTF-8"); color.r = color.g = color.b = 0; /* Negro */ for (g = 0; g < NUM_TEXTS; g++) { switch (text_info [g]) { case 10: temp2 = temp1; break; case 14: temp2 = ttf14_normal; break; case 16: temp2 = ttf16_normal; break; case 26: temp2 = ttf26_normal; break; default: temp2 = ttf16_normal; } texts[g] = draw_text (temp2, _(text_strings[g]), &color); } /* Copiar la palabra "Tickets" en el background */ /* También copiar el nombre del juego al titulo y al fondo */ rect.x = 607 + ((135 - texts[TEXT_TICKETS]->w) / 2); rect.y = 38; rect.w = texts[TEXT_TICKETS]->w; rect.h = texts[TEXT_TICKETS]->h; rect2.x = 191; rect2.y = 96; rect2.w = images[IMG_TITLE]->w; rect2.h = images[IMG_TITLE]->h; for (g = IMG_BACKGROUND_NORMAL; g <= IMG_BACKGROUND_FAIL_1; g++) { SDL_BlitSurface (texts[TEXT_TICKETS], NULL, images[g], &rect); SDL_BlitSurface (images[IMG_TITLE], NULL, images[g], &rect2); } /* X = 84.35, Y = 50.85 */ rect2.x = 84; rect2.y = 51; SDL_BlitSurface (images[IMG_TITLE], NULL, images[IMG_TITLE_OPENING], &rect2); TTF_CloseFont (temp1); /* Generador de números aleatorios */ srand ((unsigned int) getpid ()); }
int fs_ml_video_create_window(const char *title) { fs_log("fs_ml_video_create_window\n"); g_window_title = g_strdup(title); g_fs_ml_keyboard_input_grab = fs_config_get_boolean( "keyboard_input_grab"); if (g_fs_ml_automatic_input_grab == FS_CONFIG_NONE) { g_fs_ml_keyboard_input_grab = 1; } fs_log("keyboard input grab: %d\n", g_fs_ml_keyboard_input_grab); static int initialized = 0; SDL_SetHint(SDL_HINT_GRAB_KEYBOARD, g_fs_ml_keyboard_input_grab ? "1" : "0"); SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0"); #ifdef WINDOWS SDL_SetHint(SDL_HINT_WINDOWS_NO_CLOSE_ON_ALT_F4, "1"); #endif SDL_Init(SDL_INIT_VIDEO); SDL_version cversion, lversion; SDL_VERSION(&cversion); SDL_GetVersion(&lversion); fs_log("[SDL] Version %d.%d.%d (Compiled against %d.%d.%d)\n", lversion.major, lversion.minor, lversion.patch, cversion.major, cversion.minor, cversion.patch); if (!initialized) { int display_index = 0; SDL_DisplayMode mode; int error = SDL_GetCurrentDisplayMode(display_index, &mode); if (error) { fs_log("SDL_GetCurrentDisplayMode failed\n"); SDL_ShowSimpleMessageBox( SDL_MESSAGEBOX_ERROR, "Display Error", "SDL_GetCurrentDisplayMode failed.", NULL); exit(1); } fs_emu_monitor_init(); const char *mon = fs_config_get_const_string("monitor"); int mon_flag = -1; if (mon == NULL) { mon = "middle-left"; } if (strcmp(mon, "left") == 0) { mon_flag = FS_EMU_MONITOR_FLAG_LEFT; } else if (strcmp(mon, "middle-left") == 0) { mon_flag = FS_EMU_MONITOR_FLAG_MIDDLE_LEFT; } else if (strcmp(mon, "middle-right") == 0) { mon_flag = FS_EMU_MONITOR_FLAG_MIDDLE_RIGHT; } else if (strcmp(mon, "right") == 0) { mon_flag = FS_EMU_MONITOR_FLAG_RIGHT; } else { mon_flag = FS_EMU_MONITOR_FLAG_MIDDLE_LEFT; } FSEmuMonitor monitor; fs_emu_monitor_get_by_flag(mon_flag, &monitor); fs_log("Monitor \"%s\" (flag %d) => index %d\n", mon, mon_flag, monitor.index); g_display = monitor.index; g_fullscreen_width = fs_config_get_int("fullscreen_width"); if (g_fullscreen_width == FS_CONFIG_NONE) { g_fullscreen_width = mode.w; } g_fullscreen_height = fs_config_get_int("fullscreen_height"); if (g_fullscreen_height == FS_CONFIG_NONE) { g_fullscreen_height = mode.h; } if (g_fs_emu_video_fullscreen_mode_string == NULL) { g_fs_emu_video_fullscreen_mode = -1; } else if (g_ascii_strcasecmp(g_fs_emu_video_fullscreen_mode_string, "window") == 0) { g_fs_emu_video_fullscreen_mode = FULLSCREEN_WINDOW; } else if (g_ascii_strcasecmp(g_fs_emu_video_fullscreen_mode_string, "fullscreen") == 0) { g_fs_emu_video_fullscreen_mode = FULLSCREEN_FULLSCREEN; } else if (g_ascii_strcasecmp(g_fs_emu_video_fullscreen_mode_string, "desktop") == 0) { g_fs_emu_video_fullscreen_mode = FULLSCREEN_DESKTOP; } if (g_fs_emu_video_fullscreen_mode == -1) { #ifdef MACOSX g_fs_emu_video_fullscreen_mode = FULLSCREEN_FULLSCREEN; #else g_fs_emu_video_fullscreen_mode = FULLSCREEN_FULLSCREEN; #endif fs_log("[SDL] Defaulting to fullscreen_mode = desktop for SDL 2\n"); g_fs_emu_video_fullscreen_mode = FULLSCREEN_DESKTOP; } initialized = 1; } if (g_fs_ml_video_sync) { g_fs_ml_vblank_sync = 1; } SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); if (g_fsaa) { fs_log("setting FSAA samples to %d\n", g_fsaa); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, g_fsaa); } g_window_width = fs_config_get_int("window_width"); if (g_window_width == FS_CONFIG_NONE) { g_window_width = 1920 / 2; } g_window_height = fs_config_get_int("window_height"); if (g_window_height == FS_CONFIG_NONE) { g_window_height = 1080/ 2; } g_window_x = fs_config_get_int("window_x"); if (g_window_x == FS_CONFIG_NONE) { g_window_x = SDL_WINDOWPOS_CENTERED; } g_window_y = fs_config_get_int("window_y"); if (g_window_y == FS_CONFIG_NONE) { g_window_y = SDL_WINDOWPOS_CENTERED; } g_window_resizable = fs_config_get_boolean("window_resizable"); if (g_window_resizable == FS_CONFIG_NONE) { g_window_resizable = 1; } g_fs_ml_automatic_input_grab = fs_config_get_boolean( "automatic_input_grab"); if (g_fs_ml_automatic_input_grab == FS_CONFIG_NONE) { if (fs_ml_mouse_integration()) { g_fs_ml_automatic_input_grab = 0; } else { g_fs_ml_automatic_input_grab = 1; } } fs_log("automatic input grab: %d\n", g_fs_ml_automatic_input_grab); g_initial_input_grab = g_fs_ml_automatic_input_grab; if (fs_config_get_boolean("initial_input_grab") == 1) { g_initial_input_grab = 1; } else if (fs_config_get_boolean("initial_input_grab") == 0 || // deprecated names: fs_config_get_boolean("input_grab") == 0 || fs_config_get_boolean("grab_input") == 0) { g_initial_input_grab = 0; } set_video_mode(); if (g_fs_ml_vblank_sync) { fs_emu_log("*** Setting swap interval to 1 ***\n"); if (SDL_GL_SetSwapInterval(1) != 0) { fs_emu_warning("SDL_GL_SetSwapInterval(1) failed"); } } else { fs_emu_log("*** Setting swap interval to 0 ***\n"); SDL_GL_SetSwapInterval(0); } fs_log("initial input grab: %d\n", g_initial_input_grab); if (g_initial_input_grab && !g_has_input_grab) { fs_ml_set_input_grab(true); } fs_ml_show_cursor(0, 1); /* This looks a bit peculiar, but it helps to show the window in * fullscreen mode as soon as possible to reduce flickering, at least under GNOME 3. */ glClearColor(0.0, 0.0, 0.0, 1.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); SDL_GL_SwapWindow(g_fs_ml_window); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); SDL_GL_SwapWindow(g_fs_ml_window); int64_t start_time = fs_emu_monotonic_time(); SDL_Event event; while (fs_emu_monotonic_time() - start_time < 100 * 1000) { SDL_WaitEventTimeout(&event, 10); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); SDL_GL_SwapWindow(g_fs_ml_window); } // this function must be called from the video thread fs_log("init_opengl\n"); fse_init_video_opengl(); SDL_StartTextInput(); #ifdef WINDOWS if (!fs_config_false(OPTION_RAW_INPUT)) { fs_ml_init_raw_input(); } #endif fs_log("create windows is done\n"); return 1; }
void read_pcemurc(void) { /* This procedure is a bit of a hack :) - will be redone later */ FILE *f1; char buffer[1024]; /* Maximum path length. Should really be a #define */ char keyword[1024]; char value[1024]; int line = 0; int i; /* Try current directory first... */ if ((f1 = fopen(".pcemurc","r")) == NULL) { /* Try home directory */ sprintf(buffer,"%s/.pcemurc", getenv("HOME")); if ((f1 = fopen(buffer,"r")) == NULL) { printf("Warning: .pcemurc not found - using compile time defaults\n"); return; } } /* This bit hacked by David Given to, er, improve... */ while (fgets(buffer,sizeof buffer,f1) != NULL) { line++; i = 0; /* Strip leading spaces */ while(buffer[i] == ' ') i++; strcpy(keyword, buffer+i); while(buffer[i] != ' ') /* Skip to end of keyword */ i++; while(buffer[i] == ' ') i++; strcpy(value, buffer+i); /* Write value */ i = 0; /* Trim keyword to one word */ while(keyword[i] != ' ') i++; keyword[i] = '\0'; i = 0; /* Strip out \n */ while(value[i] != '\0') { if (value[i] == '\n') value[i] = '\0'; i++; } if ((keyword[0] == '#') || (keyword[0] == ' ') || (keyword[0] == '\n')) continue; if (strcasecmp(keyword, "floppy") == 0) { int drive; char device[1024]; int sectors; int cylinders; int heads; if (sscanf(value, "%d %s %d %d %d", &drive, device, §ors, &cylinders, &heads) == 5) check_error(set_floppy_drive(drive, device, sectors, cylinders, heads), line); else check_error("Syntax error in \"floppy\" directive", line); } else if (strcasecmp(keyword, "harddrive") == 0) { int drive; char device[1024]; int sectors; int cylinders; int heads; if (sscanf(value, "%d %s %d %d %d", &drive, device, §ors, &cylinders, &heads) == 5) check_error(set_hard_drive(drive, device, sectors, cylinders, heads), line); else check_error("Syntax error in \"hard\" directive", line); } else if (strcasecmp(keyword, "numharddrives") == 0) check_error(set_num_hdrives(strtol(value, NULL, 10)), line); else if (strcasecmp(keyword, "numfloppydrives") == 0) check_error(set_num_fdrives(strtol(value, NULL, 10)), line); else if (strcasecmp(keyword,"updatespeed") == 0) check_error(set_update_rate(strtol(value, NULL,10)), line); else if (strcasecmp(keyword,"cursorspeed") == 0) check_error(set_cursor_rate(strtol(value, NULL,10)), line); /* else if (strcasecmp(keyword,"keymap") == 0) check_error(set_keymap(buffer), line);*/ else if (strcasecmp(keyword, "video") == 0) check_error(set_video_mode(value), line); else check_error("Syntax error in .pcemu file", line); } fclose(f1); }
int fs_ml_video_create_window(const char *title) { fs_log("fs_ml_video_create_window\n"); g_window_title = g_strdup(title); g_fs_ml_keyboard_input_grab = fs_config_get_boolean( "keyboard_input_grab"); if (g_fs_ml_automatic_input_grab == FS_CONFIG_NONE) { g_fs_ml_keyboard_input_grab = 1; } fs_log("keyboard input grab: %d\n", g_fs_ml_keyboard_input_grab); static int initialized = 0; SDL_SetHint(SDL_HINT_GRAB_KEYBOARD, g_fs_ml_keyboard_input_grab ? "1" : "0"); SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0"); SDL_Init(SDL_INIT_VIDEO); SDL_version version; SDL_VERSION(&version); fs_log("FS-UAE was compiled for SDL %d.%d.%d\n", version.major, version.minor, version.patch); if (!initialized) { int display_index = 0; SDL_DisplayMode mode; int error = SDL_GetCurrentDisplayMode(display_index, &mode); if (error) { fs_log("SDL_GetCurrentDisplayMode failed\n"); SDL_ShowSimpleMessageBox( SDL_MESSAGEBOX_ERROR, "Display Error", "SDL_GetCurrentDisplayMode failed.", NULL); exit(1); } fs_emu_monitor_init(); const char *mon = fs_config_get_const_string("monitor"); int mon_flag = -1; if (mon == NULL) { mon = "middle-left"; } if (strcmp(mon, "left") == 0) { mon_flag = FS_EMU_MONITOR_FLAG_LEFT; } else if (strcmp(mon, "middle-left") == 0) { mon_flag = FS_EMU_MONITOR_FLAG_MIDDLE_LEFT; } else if (strcmp(mon, "middle-right") == 0) { mon_flag = FS_EMU_MONITOR_FLAG_MIDDLE_RIGHT; } else if (strcmp(mon, "right") == 0) { mon_flag = FS_EMU_MONITOR_FLAG_RIGHT; } else { mon_flag = FS_EMU_MONITOR_FLAG_MIDDLE_LEFT; } FSEmuMonitor monitor; fs_emu_monitor_get_by_flag(mon_flag, &monitor); fs_log("Monitor \"%s\" (flag %d) => index %d\n", mon, mon_flag, monitor.index); g_display = monitor.index; g_fullscreen_width = fs_config_get_int("fullscreen_width"); if (g_fullscreen_width == FS_CONFIG_NONE) { g_fullscreen_width = mode.w; } g_fullscreen_height = fs_config_get_int("fullscreen_height"); if (g_fullscreen_height == FS_CONFIG_NONE) { g_fullscreen_height = mode.h; } if (g_fs_emu_video_fullscreen_mode_string == NULL) { g_fs_emu_video_fullscreen_mode = -1; } else if (g_ascii_strcasecmp(g_fs_emu_video_fullscreen_mode_string, "window") == 0) { g_fs_emu_video_fullscreen_mode = FULLSCREEN_WINDOW; } else if (g_ascii_strcasecmp(g_fs_emu_video_fullscreen_mode_string, "fullscreen") == 0) { g_fs_emu_video_fullscreen_mode = FULLSCREEN_FULLSCREEN; } else if (g_ascii_strcasecmp(g_fs_emu_video_fullscreen_mode_string, "desktop") == 0) { g_fs_emu_video_fullscreen_mode = FULLSCREEN_DESKTOP; } if (g_fs_emu_video_fullscreen_mode == -1) { #ifdef MACOSX g_fs_emu_video_fullscreen_mode = FULLSCREEN_FULLSCREEN; #else g_fs_emu_video_fullscreen_mode = FULLSCREEN_FULLSCREEN; #endif fs_log("defaulting to fullscreen_mode = desktop for SDL2\n"); g_fs_emu_video_fullscreen_mode = FULLSCREEN_DESKTOP; } initialized = 1; } if (g_fs_ml_video_sync) { g_fs_ml_vblank_sync = 1; } SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); if (g_fsaa) { fs_log("setting FSAA samples to %d\n", g_fsaa); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, g_fsaa); } g_window_width = fs_config_get_int("window_width"); if (g_window_width == FS_CONFIG_NONE) { g_window_width = 1920 / 2; } g_window_height = fs_config_get_int("window_height"); if (g_window_height == FS_CONFIG_NONE) { g_window_height = 1080/ 2; } g_window_x = fs_config_get_int("window_x"); if (g_window_x == FS_CONFIG_NONE) { g_window_x = SDL_WINDOWPOS_CENTERED; } g_window_y = fs_config_get_int("window_y"); if (g_window_y == FS_CONFIG_NONE) { g_window_y = SDL_WINDOWPOS_CENTERED; } g_window_resizable = fs_config_get_boolean("window_resizable"); if (g_window_resizable == FS_CONFIG_NONE) { g_window_resizable = 1; } g_fs_ml_automatic_input_grab = fs_config_get_boolean( "automatic_input_grab"); if (g_fs_ml_automatic_input_grab == FS_CONFIG_NONE) { if (fs_ml_mouse_integration()) { g_fs_ml_automatic_input_grab = 0; } else { g_fs_ml_automatic_input_grab = 1; } } fs_log("automatic input grab: %d\n", g_fs_ml_automatic_input_grab); g_initial_input_grab = g_fs_ml_automatic_input_grab; if (fs_config_get_boolean("initial_input_grab") == 1) { g_initial_input_grab = 1; } else if (fs_config_get_boolean("initial_input_grab") == 0 || // deprecated names: fs_config_get_boolean("input_grab") == 0 || fs_config_get_boolean("grab_input") == 0) { g_initial_input_grab = 0; } set_video_mode(); if (g_fs_ml_vblank_sync) { fs_emu_log("*** Setting swap interval to 1 ***\n"); if (SDL_GL_SetSwapInterval(1) != 0) { fs_emu_warning("SDL_GL_SetSwapInterval(1) failed"); } } else { fs_emu_log("*** Setting swap interval to 0 ***\n"); SDL_GL_SetSwapInterval(0); } // we display a black frame as soon as possible (to reduce flickering on // startup) glClear(GL_COLOR_BUFFER_BIT); SDL_GL_SwapWindow(g_fs_ml_window); fs_gl_finish(); fs_log("initial input grab: %d\n", g_initial_input_grab); if (g_initial_input_grab && !g_has_input_grab) { fs_ml_set_input_grab(true); } fs_ml_show_cursor(0, 1); // this function must be called from the video thread fs_log("init_opengl\n"); fs_emu_video_init_opengl(); SDL_StartTextInput(); fs_log("create windows is done\n"); return 1; }