Exemplo n.º 1
0
void vdc_calculate_xsync(void)
{
    double vdc_cycles_per_line, host_cycles_per_second;

    host_cycles_per_second = (double)machine_get_cycles_per_second();

    vdc_cycles_per_line = (double)(vdc.xchars_total) * 8.0
                          * host_cycles_per_second / VDC_DOT_CLOCK;

    vdc.xsync_increment = (unsigned int)(vdc_cycles_per_line * 65536);
}
Exemplo n.º 2
0
void datasette_init(void)
{
    datasette_log = log_open("Datasette");

    datasette_alarm = alarm_new(maincpu_alarm_context, "Datasette",
                                datasette_read_bit, NULL);

    clk_guard_add_callback(maincpu_clk_guard, clk_overflow_callback, NULL);

    datasette_cycles_per_second = machine_get_cycles_per_second();
    if (!datasette_cycles_per_second) {
        log_error(datasette_log,
                  "Cannot get cycles per second for this machine.");
        datasette_cycles_per_second = 985248;
    }
}
Exemplo n.º 3
0
static void ffmpegdrv_init_video(screenshot_t *screenshot)
{
    AVCodecContext *c;
    AVStream *st;

    if (ffmpegdrv_oc == NULL || ffmpegdrv_fmt == NULL) {
        return;
    }

    video_init_done = 1;

    if (ffmpegdrv_fmt->video_codec == AV_CODEC_ID_NONE) {
        return;
    }

    st = VICE_P_AVFORMAT_NEW_STREAM(ffmpegdrv_oc, avcodecvideo);
    if (!st) {
        log_debug("ffmpegdrv: Could not alloc video stream\n");
        return;
    }

    c = st->codec;

    /* put sample parameters */
    c->bit_rate = video_bitrate;
    /* resolution should be a multiple of 16 */
    /* ffmpegdrv_fill_rgb_image only implements cutting so */
    /* adding black border was removed */
    video_width = c->width = screenshot->width & ~0xf;
    video_height = c->height = screenshot->height & ~0xf;
    /* frames per second */
    st->time_base = VICE_P_AV_D2Q(machine_get_cycles_per_frame() 
                                    / (double)(video_halve_framerate ? 
                                        machine_get_cycles_per_second() / 2 :
                                        machine_get_cycles_per_second()), 
                                  (1 << 16) - 1);
    c->time_base = st->time_base;

    c->gop_size = 12; /* emit one intra frame every twelve frames at most */
    c->pix_fmt = AV_PIX_FMT_YUV420P;

#if (LIBAVUTIL_VERSION_MICRO >= 100)
    /* Avoid format conversion which would lead to loss of quality */
    if (c->codec_id == AV_CODEC_ID_FFV1) {
        c->pix_fmt = AV_PIX_FMT_0RGB32;
    }
#endif

    /* Use XVID instead of FMP4 FOURCC for better compatibility */
    if (c->codec_id == AV_CODEC_ID_MPEG4) {
        c->codec_tag = MKTAG('X', 'V', 'I', 'D');
    }

    /* Allow nonstandard framerates for MPEG1 codec */
    if (c->codec_id == AV_CODEC_ID_MPEG1VIDEO) {
        c->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL;
    }

#ifdef HAVE_FFMPEG_SWSCALE
    /* setup scaler */
    if (c->pix_fmt != PIX_FMT_RGB24) {
        sws_ctx = VICE_P_SWS_GETCONTEXT
                      (video_width, video_height, PIX_FMT_RGB24,
                      video_width, video_height, c->pix_fmt,
                      SWS_BICUBIC,
                      NULL, NULL, NULL);
        if (sws_ctx == NULL) {
            log_debug("ffmpegdrv: Can't create Scaler!\n");
        }
    }
#endif

    video_st.st = st;
    video_st.next_pts = 0;
    framecounter = 0;

    /* Some formats want stream headers to be separate. */
    if (ffmpegdrv_oc->oformat->flags & AVFMT_GLOBALHEADER) {
        c->flags |= CODEC_FLAG_GLOBAL_HEADER;
    }

    if (audio_init_done) {
        ffmpegdrv_init_file();
    }
}
Exemplo n.º 4
0
/*! \internal \brief set the ticks between characters of the ACIA according to the bps rate

 Set the ticks that will pass for one character to be transferred
 according to the current ACIA settings.
*/
static void set_acia_ticks(void)
{
    unsigned int bits;

    DEBUG_LOG_MESSAGE((acia.log, "Setting ACIA to %u bps",
                       (unsigned int) get_acia_bps()));

    switch (acia.ctrl & ACIA_CTRL_BITS_WORD_LENGTH_MASK) {
    case ACIA_CTRL_BITS_WORD_LENGTH_8:
        bits = 8;
        break;
    case ACIA_CTRL_BITS_WORD_LENGTH_7:
        bits = 7;
        break;
    case ACIA_CTRL_BITS_WORD_LENGTH_6:
        bits = 6;
        break;
    default:
    /*
     * this case is only for gcc to calm down, as it wants to warn that
     * bits is used uninitialised - which it is not.
     */
    /* FALL THROUGH */
    case ACIA_CTRL_BITS_WORD_LENGTH_5:
        bits = 5;
        break;
    }

    /*
     * we neglect the fact that we might have 1.5 stop bits instead of 2
     */
    bits += 1 /* the start bit */
            + ((acia.cmd & ACIA_CMD_BITS_PARITY_ENABLED) ? 1 : 0) /* parity or not */
            + ((acia.ctrl & ACIA_CTRL_BITS_2_STOP) ? 2 : 1);   /* 1 or 2 stop bits */

    /*
     * calculate time in ticks for the data bits
     * including start, stop and parity bits.
     */
    acia.ticks = (int) (machine_get_cycles_per_second() / get_acia_bps() * bits);

    /*
     * Note: With 10 bit, the timing is very hard to NovaTerm 9.6c with 57600 bps
     * on reception. It cannot cope and behaves erroneously, at least when configured
     * for NMI interrupts. This is because the interrupt routine needs too much
     * time to execute, leaving not more than 20 cycles for the non-NMI routine.
     * Thus, it was decided to add 25% "safety margin" to allow NovaTerm to react
     * appropriately. This gives the main program 50 extra cycles.
     * This way, NovaTerm can cope with the transmission at 57600 bps.
     */
    acia.ticks_rx = acia.ticks * 5 / 4;

    /* adjust the alarm rate for reception */
    if (acia.alarm_active_rx) {
        acia.alarm_clk_rx = myclk + acia.ticks_rx;
        alarm_set(acia.alarm_rx, acia.alarm_clk_rx);
        acia.alarm_active_rx = 1;
    }

    /*
     * set the baud rate of the physical device
     */
    rs232drv_set_bps(acia.fd, (unsigned int)get_acia_bps());
}
Exemplo n.º 5
0
static void event_alarm_handler(CLOCK offset, void *data)
{
    alarm_unset(event_alarm);

    /* when recording set a timestamp */
    if (record_active) {
        ui_display_event_time(current_timestamp++, 0);
        next_timestamp_clk = next_timestamp_clk 
                                + machine_get_cycles_per_second();
        alarm_set(event_alarm, next_timestamp_clk);
        return;
    }

    /*log_debug("EVENT PLAYBACK %i CLK %i", event_list_current->type,
              event_list_current->clk);*/

    switch (event_list->current->type) {
      case EVENT_KEYBOARD_MATRIX:
        keyboard_event_playback(offset, event_list->current->data);
        break;
      case EVENT_KEYBOARD_RESTORE:
        keyboard_restore_event_playback(offset, event_list->current->data);
        break;
      case EVENT_JOYSTICK_VALUE:
        joystick_event_playback(offset, event_list->current->data);
        break;
      case EVENT_DATASETTE:
        datasette_event_playback(offset, event_list->current->data);
        break;
      case EVENT_ATTACHIMAGE:
        event_playback_attach_image(event_list->current->data,
                                    event_list->current->size);
        break;
      case EVENT_ATTACHDISK:
      case EVENT_ATTACHTAPE:
        {
            /* old style attach via absolute filename and detach*/
            unsigned int unit;
            const char *filename;

            unit = (unsigned int)((char*)event_list->current->data)[0];
            filename = &((char*)event_list->current->data)[1];
            
            if (unit == 1)
                tape_image_event_playback(unit, filename);
            else
                file_system_event_playback(unit, filename);
        }
        break;
      case EVENT_RESETCPU:
        machine_reset_event_playback(offset, event_list->current->data);
        break;
      case EVENT_TIMESTAMP:
        ui_display_event_time(current_timestamp++, playback_time);
        break;
      case EVENT_LIST_END:
        event_playback_stop();
        break;
      case EVENT_OVERFLOW:
        break;
      default:
        log_error(event_log, "Unknow event type %i.", event_list->current->type);
    }

    if (event_list->current->type != EVENT_LIST_END
        && event_list->current->type != EVENT_RESETCPU) {
        next_current_list();
        next_alarm_set();
    }
}
Exemplo n.º 6
0
static int get_midi_ticks(void)
{
    return (int)(machine_get_cycles_per_second() / 31250);
}
Exemplo n.º 7
0
void c64_rsuser_init(void)
{
    rsuser_init(machine_get_cycles_per_second(), cia2_set_flagx,
                cia2_set_sdrx);
}