Image *load(char *path, int index, int *nframes) { static video_t *v=NULL; Image *im=NULL; if(index>=0) { if(!v) TRY(v=video_open(path),ErrorOpen); if(nframes) *nframes=video_frame_count(v); TRY(im=video_get(v,index,1),ErrorRead); } else { if(v) video_close(&v); } return im; ErrorRead: video_close(&v); return NULL; ErrorOpen: return NULL; }
/* * DANG_BEGIN_FUNCTION video_init * * description: * Set pointer to correct structure of functions to initialize, close, * etc... video routines. * * DANG_END_FUNCTION */ static int video_init(void) { if ((config.vga == -1 || config.console_video == -1) && using_kms()) { config.vga = config.console_video = config.mapped_bios = config.pci_video = 0; warn("KMS detected: using SDL mode.\n"); load_plugin("sdl"); Video = video_get("sdl"); if (Video) config.X = 1; } #if defined(USE_DL_PLUGINS) if (!config.X) load_plugin("console"); #endif /* figure out which video front end we are to use */ if (no_real_terminal() || config.dumb_video || config.cardtype == CARD_NONE) { v_printf("VID: Video set to Video_none\n"); config.cardtype = CARD_NONE; config.X = config.console_video = config.mapped_bios = config.vga = 0; Video=&Video_none; } else if (config.X) { /* already initialized */ } else if (config.vga) { v_printf("VID: Video set to Video_graphics\n"); Video = video_get("graphics"); } else if (config.console_video) { if (config.cardtype == CARD_MDA) { v_printf("VID: Video set to Video_hgc\n"); Video = video_get("hgc"); } else { v_printf("VID: Video set to Video_console\n"); Video = video_get("console"); } } else { #if defined(USE_DL_PLUGINS) && defined(USE_SLANG) if (!load_plugin("term")) { error("Terminal (S-Lang library) support not compiled in.\n" "Install slang-devel and recompile, use xdosemu or console " "dosemu (needs root) instead.\n"); /* too early to call leavedos */ exit(1); } v_printf("VID: Video set to Video_term\n"); Video = video_get("term"); /* S-Lang */ #endif } if (Video->priv_init) Video->priv_init(); /* call the specific init routine */ #if VIDEO_CHECK_DIRTY if (!config_dualmon) { vm86s.flags |= VM86_SCREEN_BITMAP; } #endif return 0; }