Beispiel #1
0
void vsyncarch_presync(void)
{
    /* Update mouse */
    mouse_update_mouse();

    /* Flush keypresses emulated through the keyboard buffer.  */
    kbdbuf_flush();
    joystick_update();
}
Beispiel #2
0
void vsyncarch_presync(void)
{
#if defined(HAVE_MOUSE) && !defined(MACOSX_COCOA)
    {
        extern void x11_lightpen_update(void);
        x11_lightpen_update();
    }
#endif /* HAVE_MOUSE !MACOSX_COCOA */
    kbdbuf_flush();
#ifdef HAS_JOYSTICK
    joystick();
#endif
}
Beispiel #3
0
void vsyncarch_presync(void)
{
#if defined(GP2X) || defined(WIZ)
    (*ui_dispatch_hook)();
#endif
#if defined(HAVE_MOUSE) && !defined(GP2X) && !defined(WIZ) && !defined(MACOSX_COCOA)
    {
        extern void x11_lightpen_update(void);
        x11_lightpen_update();
    }
#endif /* HAVE_MOUSE !GP2X !WIZ !MACOSX_COCOA */
    kbdbuf_flush();
#ifdef HAS_JOYSTICK
    joystick();
#endif
}
Beispiel #4
0
/* Feed `string' into the incoming queue.  */
static int string_to_queue(const char *string)
{
    const int num = (int)strlen(string);
    int i, p;

    if ((num_pending + num) > QUEUE_SIZE || !kbd_buf_enabled) {
        return -1;
    }

    for (p = (head_idx + num_pending) % QUEUE_SIZE, i = 0;
         i < num; p = (p + 1) % QUEUE_SIZE, i++) {
        queue[p] = string[i];
        /* printf("string_to_queue %d:'%c'\n",p,queue[p]); */
    }

    num_pending += num;

    kbdbuf_flush();

    return 0;
}
Beispiel #5
0
/* Feed `s' into the queue.  */
int kbdbuf_feed(const char *string)
{
    const int num = strlen(string);
    int i, p;

    if (num_pending + num > QUEUE_SIZE || !kbd_buf_enabled)
        return -1;

    for (p = (head_idx + num_pending) % QUEUE_SIZE, i = 0;
        i < num; p = (p + 1) % QUEUE_SIZE, i++) {
        queue[p] = string[i];
    }

    num_pending += num;

    /* XXX: We waste time this way, as we copy into the queue and then into
       memory.  */
    kbdbuf_flush();

    return 0;
}
Beispiel #6
0
/* This is called at the end of each screen frame.  It flushes the audio buffer
   and keeps control of the emulation speed.  */
int vsync_do_vsync(int been_skipped)
{
    static unsigned short frame_counter = USHRT_MAX;
    static unsigned short num_skipped_frames;
    static int skip_counter;
    int skip_next_frame = 0;

    vsync_hook();

    if (been_skipped) num_skipped_frames++;

    if (timer_speed != relative_speed) {
	frame_counter = USHRT_MAX;
        if (set_timer_speed(relative_speed) < 0) {
	    log_error(LOG_DEFAULT, "Trouble setting timers... giving up.");
            /* FIXME: Hm, maybe we should be smarter.  But this is should
               never happen.*/
	    exit(-1);
	}
    }

    if (warp_mode_enabled) {
        /* "Warp Mode".  Just skip as many frames as possible and do not
           limit the maximum speed at all.  */
        if (skip_counter < MAX_SKIPPED_FRAMES) {
            skip_next_frame = 1;
            skip_counter++;
        }
        else skip_counter = elapsed_frames = 0;
        sound_flush(0);
    }
    else
        if (refresh_rate != 0) {
            update_elapsed_frames(0); /* Fixed refresh rate.  */
            if (timer_speed && skip_counter >= elapsed_frames) timer_sleep();
            if (skip_counter < refresh_rate - 1) {
                skip_next_frame = 1;
                skip_counter++;
            }
            else skip_counter = elapsed_frames = 0;
            patch_timer(sound_flush(relative_speed));
        }
        else
        {
            /* Dynamically adjusted refresh rate.  */
            update_elapsed_frames(0);
            if (skip_counter >= elapsed_frames) {
                elapsed_frames = -1;
                timer_sleep();
                skip_counter = 0;
            }
            else
                if (skip_counter < MAX_SKIPPED_FRAMES) {
                    skip_next_frame = 1;
                    skip_counter++;
                }
                else skip_counter = elapsed_frames = 0;
            patch_timer(sound_flush(relative_speed));
        }

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


    kbdbuf_flush();

#ifdef HAS_JOYSTICK
    joystick_update();
#endif

    return skip_next_frame;
}
Beispiel #7
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;
}