Ejemplo n.º 1
0
void Init_video(char* argv[])
{
	allegro_init();
	install_timer();
	install_keyboard(); 
	install_joystick(JOY_TYPE_AUTODETECT);
	request_refresh_rate(FPS_VIDEO);
	set_color_depth(32);
	/*set_gfx_mode(GFX_AUTODETECT_FULLSCREEN, 320, 240, 0, 0);*/
	set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320, 240, 0, 0);
	set_window_title(game_name);
	clear_to_color(screen, makecol(0, 0, 0));
	LOCK_VARIABLE(ticks);
	LOCK_FUNCTION(ticker);
	install_int_ex(ticker, BPS_TO_TIMER(FPS_VIDEO));
}
Ejemplo n.º 2
0
int uip_vgamode(void)
{
  int depth, rate;
  unsigned long screenbase;

  for (rate = 60; rate <= 70; rate += 10) {
    for (depth = 15; depth <= 16; depth++) {
      LOG_VERBOSE(("Trying mode 640x480 depth %d rate %d", depth, rate));
      set_color_depth(depth);
      request_refresh_rate(rate);
      if ((set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 480 * 2) < 0)) {
        LOG_VERBOSE(("Mode not supported"));
        continue;
      }
      if (SCREEN_W != 640 || SCREEN_H != 480) {
        LOG_CRITICAL(("Screen not approriate for depth %d rate %d",
                      depth, rate));
        continue;
      }
      goto WHEE;
    }
  }
  LOG_CRITICAL(("Failed to find suitable mode"));
  return 1;
WHEE:
  uip_vga = 1;
  if (uip_forceredshift != -1 && uip_forcegreenshift != -1 &&
      uip_forceblueshift != -1) {
    uip_uipinfo->redshift = uip_forceredshift;
    uip_uipinfo->greenshift = uip_forcegreenshift;
    uip_uipinfo->blueshift = uip_forceblueshift;
  } else {
    uip_uipinfo->redshift = ui_topbit(makecol(255, 0, 0)) - 4;
    uip_uipinfo->greenshift = ui_topbit(makecol(0, 255, 0)) - 4;
    uip_uipinfo->blueshift = ui_topbit(makecol(0, 0, 255)) - 4;
  }
  if ((uip_bank0 = create_video_bitmap(640, 480)) == NULL ||
      (uip_bank1 = create_video_bitmap(640, 480)) == NULL) {
    uip_textmode();
    LOG_CRITICAL(("Failed to allocate memory pages"));
    return 1;
  }
  if (is_linear_bitmap(uip_bank0) == 0 ||
      is_linear_bitmap(uip_bank1) == 0 ||
      is_video_bitmap(uip_bank0) == 0 || is_video_bitmap(uip_bank1) == 0) {
    uip_textmode();
    LOG_CRITICAL(("Allocated bitmaps not suitable or linear addressing mode "
                  "not supported by hardware"));
    return 1;
  }
  /* don't you just hate MS platforms? */
  __djgpp_nearptr_enable();
  __dpmi_get_segment_base_address(uip_bank0->seg, &screenbase);
  uip_uipinfo->screenmem0 = (uint8 *)(screenbase + uip_bank0->line[0] -
                                      __djgpp_base_address);
  __dpmi_get_segment_base_address(uip_bank1->seg, &screenbase);
  uip_uipinfo->screenmem1 = (uint8 *)(screenbase + uip_bank1->line[0] -
                                      __djgpp_base_address);
  uip_uipinfo->linewidth = 2 * VIRTUAL_W;       /* 16 bit */
  uip_displaybank(0);           /* set current to 0th bank */
  uip_clearscreen();            /* clear bank */
  ui_setupscreen();             /* setup bank */
  uip_displaybank(-1);          /* toggle bank */
  uip_clearscreen();            /* clear bank */
  ui_setupscreen();             /* setup bank */
  if (install_keyboard() == -1) {
    uip_textmode();
    LOG_CRITICAL(("Unable to initialise keyboard"));
    return 1;
  }
  if (uip_bank0->y_ofs != 0 || uip_bank1->y_ofs != 480) {
    uip_textmode();
    LOG_CRITICAL(("sorry, I don't understand this video layout"));
    return 1;
  }
  keyboard_lowlevel_callback = uip_keyboardhandler;
  uip_keypoll = keyboard_needs_poll()? 1 : 0;
  return 0;
}