Esempio n. 1
0
/*
 * vUpdateWriteable - update a writeable icon with a string
 */
void
vUpdateWriteable(window_handle tWindow, icon_handle tIconNumber,
	const char *szString)
{
	icon_block	tIcon;
	caret_block	tCaret;
	int		iLen;

	fail(szString == NULL);

	NO_DBG_DEC(tIconNumber);
	NO_DBG_MSG(szString);

	Error_CheckFatal(Wimp_GetIconState(tWindow, tIconNumber, &tIcon));
	NO_DBG_HEX(tIcon.flags);
	if (!tIcon.flags.data.text || !tIcon.flags.data.indirected) {
		werr(1, "Icon %d must be indirected text", (int)tIconNumber);
		return;
	}
	strncpy(tIcon.data.indirecttext.buffer,
		szString,
		tIcon.data.indirecttext.bufflen - 1);
	/* Ensure the caret is behind the last character of the text */
	Error_CheckFatal(Wimp_GetCaretPosition(&tCaret));
	if (tCaret.window == tWindow && tCaret.icon == tIconNumber) {
		iLen = strlen(tIcon.data.indirecttext.buffer);
		if (tCaret.index != iLen) {
			tCaret.index = iLen;
			Error_CheckFatal(Wimp_SetCaretPosition(&tCaret));
		}
	}
	Error_CheckFatal(Wimp_SetIconState(tWindow, tIconNumber, 0, 0));
	vUpdateIcon(tWindow, &tIcon);
} /* end of vUpdateWriteable */
Esempio n. 2
0
int ui_message_window_open(message_window_e mwin, const char *title, const char *message, int cols, int rows)
{
  text_window_t *tw;
  message_window_t *mw;

  switch (mwin)
  {
    case msg_win_monitor:
      Wimp_GetCaretPosition(&LastCaret);
      tw = MsgWinDescs;
      mw = MsgWindows;
      if (mw->win == NULL)
      {
        mw->win = wimp_window_clone(MessageWindow);
        wimp_window_create((int*)(mw->win), title);
      }
      if (mw->tw == NULL)
      {
        mw->tw = tw;
        ui_msgwin_set_dimensions(mw, cols, rows);
        textwin_init(tw, mw->win, message, NULL);
        (tw->Events)[WimpEvt_CloseWin] = MsgCloseEvents[msg_win_monitor];
      }
      textwin_open_centered(tw, tw->MaxWidth, 1024, ScreenMode.resx, ScreenMode.resy);
      textwin_set_caret(tw, 0, 0);
      MsgWindows[mwin].Flags |= MSGWIN_FLAG_OPEN;
      break;
    case msg_win_license:
    case msg_win_warranty:
    case msg_win_contrib:
    case msg_win_log:
      tw = MsgWinDescs + mwin;
      mw = MsgWindows + mwin;
      if (mw->win == NULL)
      {
        mw->win = wimp_window_clone(MessageWindow);
        wimp_window_create((int*)(mw->win), title);
      }
      if (mw->tw == NULL)
      {
        mw->tw = tw;
        ui_msgwin_set_dimensions(mw, cols, rows);
        textwin_init(tw, mw->win, message, NULL);
        (tw->Events)[WimpEvt_CloseWin] = MsgCloseEvents[mwin];
      }

      if (mwin == msg_win_log)
      {
        int block[WindowB_WFlags+1];

        /* if already opened then raise, otherwise open in bottom left corner */
        block[WindowB_Handle] = mw->win->Handle;
        Wimp_GetWindowState(block);
        block[WindowB_Stackpos] = -1;
        if ((block[WindowB_WFlags] & (1<<16)) == 0)
        {
          /* open in the bottom left corner, but leave room below for the icon bar */
          textwin_open(tw, tw->MaxWidth, tw->MinHeight, 0, 160 + tw->MinHeight);
        }
        else
        {
          /* just raise */
          Wimp_OpenWindow(block);
        }
        /* always set caret at end */
        textwin_caret_to_end(tw);
      }
      else
      {
        textwin_open_centered(tw, tw->MaxWidth, 1024, ScreenMode.resx, ScreenMode.resy);
      }

      MsgWindows[mwin].Flags |= MSGWIN_FLAG_OPEN;
      break;
    default:
      return -1;
  }
  return 0;
}
Esempio n. 3
0
int vsync_do_vsync(struct video_canvas_s *canvas, int been_skipped)
{
    int skip_next_frame = 0;
    int frame_delay;
    int now, dopoll;

    /* this can happen in some rare cases; make sure emulation stops then */
    while (EmuPaused != 0) {
        ui_poll(1);
    }

    if (FullScreenMode != 0) {
        EmuWindowHasInputFocus = 1;
    } else {
        RO_Caret caret;

        Wimp_GetCaretPosition(&caret);

        /* This will be used by keyboard and joystick code */
        EmuWindowHasInputFocus = (canvas_for_handle(caret.WHandle) == NULL) ? 0 : 1;
    }

    now = OS_ReadMonotonicTime();

    if (warp_mode_enabled) {
        if (skip_counter < MaxSkippedFrames) {
            skip_next_frame = 1;
            skip_counter++;
        } else {
            skip_counter = 0;
        }
    } else if (refresh_rate != 0) {
        if (skip_counter < refresh_rate - 1) {
            skip_next_frame = 1;
            skip_counter++;
        } else {
            skip_counter = 0;
        }
    } else {
        /* Use NumberOfFrames+1 because this frame isn't counted yet */
        if ((VSYNC_TIME_DELTA(now, NumberOfFrames+1) < 0) && (skip_counter < MaxSkippedFrames)) {
            skip_next_frame = 1;
            skip_counter++;
        } else {
            skip_counter = 0;
        }
    }

    /* always pass the actual speed unless in reSID mode */
    frame_delay = sound_flush();

    if (frame_counter >= refresh_frequency * 2) {
        num_skipped_frames = 0;
        frame_counter = 0;
    } else {
        frame_counter++;
    }

    if (skip_next_frame == 0) {
        NumberOfRefreshes++;
    }

    vsync_hook();

    joystick();
    mousedrv_sync();

    NumberOfFrames += 1 - frame_delay;

    /* Speed limiter? Wait */
    if ((CurrentSpeedLimit != 0) && (warp_mode_enabled == 0)) {
        while (VSYNC_TIME_DELTA(now, NumberOfFrames) > 0) {
            now = OS_ReadMonotonicTime();
        }
    }
    LastFrame = now;

    if (speed_eval_suspended) {
        vsync_resync_speed();
        speed_eval_suspended = 0;
    } else {
        if ((now - LastSpeed) >= SpeedEvery) {
            int val;

            RelativeSpeed = (10000 * NumberOfFrames) / (FramesPerSecond * (now - LastSpeed));
            ui_display_speed(RelativeSpeed, (100 * NumberOfRefreshes) / (now - LastSpeed), 0);
            LastSpeed = now;
            NumberOfFrames = 0;
            NumberOfRefreshes = 0;
            resources_get_int("MachineVideoStandard", &val);
            FramesPerSecond = (val == MACHINE_SYNC_PAL) ? 50 : 60;
        }
    }

    dopoll = 0;
    if ((now - LastPoll) >= PollEvery) {
        dopoll = 1;
        LastPoll = now;
    }

    ui_poll(dopoll);

    video_full_screen_plot_status();

    kbdbuf_flush();

    return skip_next_frame;
}