示例#1
0
文件: video.c 项目: fhgwright/fs-uae
void fs_emu_video_init(void)
{
    fs_log("fs_emu_video_init\n");
    fs_emu_video_init_options();

    g_video_render_mutex = fs_mutex_create();
    g_emu_video_struct_queue = g_queue_new();
    g_emu_video_struct_mutex = fs_mutex_create();
}
示例#2
0
文件: sdl.c 项目: alpine9000/fs-uae
void fs_ml_video_init()
{
    FS_ML_INIT_ONCE;

    g_video_thread_id = fs_thread_id();
    g_video_cond = fs_condition_create();
    g_video_mutex = fs_mutex_create();
    g_video_event_queue = g_queue_new();
    g_video_event_mutex = fs_mutex_create();

    fs_ml_render_init();
}
示例#3
0
文件: netplay.c 项目: adurdin/fs-uae
void fs_emu_netplay_init() {
    const char *value;

    g_send_mutex = fs_mutex_create();
    g_connection_mutex = fs_mutex_create();
    g_input_event_mutex = fs_mutex_create();
    g_input_event_queue = g_queue_new();
    g_wait_for_frame_cond = fs_condition_create();
    g_wait_for_frame_mutex = fs_mutex_create();

    value = fs_config_get_const_string("netplay_server");
    if (value) {
        g_fs_emu_netplay_server = g_strdup(value);
    }
    if (!fs_emu_netplay_enabled()) {
        return;
    }

    value = fs_config_get_const_string("netplay_tag");
    if (value) {
        strncpy(g_fs_emu_netplay_tag, value, 4);
    }
    else {
        g_fs_emu_netplay_tag[0] = 'U';
        g_fs_emu_netplay_tag[1] = 'N';
        g_fs_emu_netplay_tag[2] = 'K';
    }
    g_fs_emu_netplay_tag[3] = '\0';

    value = fs_config_get_const_string("netplay_port");
    if (value) {
        g_fs_emu_netplay_port = g_strdup(value);
    }

    char *password_value = fs_config_get_string("netplay_password");
    if (password_value) {
        GChecksum *cs = g_checksum_new(G_CHECKSUM_SHA1);
        g_checksum_update(cs, (unsigned char *) "FSNP", 4);
        int len = strlen(password_value);
        for (int i = 0; i < len; i++) {
            unsigned char c = password_value[i];
            // only include ASCII characters
            if (c < 128) {
                g_checksum_update(cs, &c, 1);
            }
        }
        gsize digest_len = 20;
        g_checksum_get_digest(cs, g_fs_emu_netplay_password, &digest_len);
        free(password_value);
        g_checksum_free(cs);
    }

}
示例#4
0
void fs_ml_video_init() {
    FS_ML_INIT_ONCE;

    fs_log("creating condition\n");
    g_video_cond = fs_condition_create();
    fs_log("creating mutex\n");
    g_video_mutex = fs_mutex_create();

    g_video_event_queue = g_queue_new();
    g_video_event_mutex = fs_mutex_create();

    g_debug_input = getenv("FS_DEBUG_INPUT") && \
            getenv("FS_DEBUG_INPUT")[0] == '1';

    fs_ml_render_init();
}
示例#5
0
文件: render.c 项目: nekoniaow/fs-uae
void fs_ml_render_init() {
    g_frame_available_cond = fs_condition_create();
    g_frame_available_mutex = fs_mutex_create();

    g_start_new_frame_cond = fs_condition_create();
    g_start_new_frame_mutex = fs_mutex_create();

    g_buffer_swap_cond = fs_condition_create();
    g_buffer_swap_mutex = fs_mutex_create();

    g_epoch = fs_get_monotonic_time();
    g_vblank_mutex = fs_mutex_create();
    //fs_emu_stat_queue_init(&g_measured_vblank_times, VBLANK_TIMES_COUNT);

    if (fs_config_get_boolean("low_latency_vsync") == 1) {
        fs_log("using low latency vsync when full vsync is enabled\n");
        g_fs_ml_video_sync_low_latency = 1;
    }
    else if (fs_config_get_boolean("low_latency_vsync") == 0) {
        fs_log("disabling use of low latency vsync\n");
        g_fs_ml_video_sync_low_latency = 0;
    }
}
示例#6
0
static void fs_emu_init_audio_stream(int stream,
                              fs_emu_audio_stream_options *options)
{
    audio_stream *s = g_malloc0(sizeof(audio_stream));
    s->buffer_size = options->buffer_size;
    s->frequency = options->frequency;
    s->num_buffers = MAX_BUFFERS;
    s->min_buffers = options->min_buffers;
    fs_log("AUDIO: Stream %d,  frequency: %d, buffers: %d buffer "
           "size: %d bytes\n", stream, s->frequency, s->num_buffers,
           s->buffer_size);
    s->mutex = fs_mutex_create();
    s->queue = g_queue_new();
    s->source_volume_current = 1.0;
    s->buffers_queued = 0;
    s->pid_last_error = 0;
    s->pid_last_last_error = 0;
    s->pid_last_time = 0;
    s->pid_last_last_time = 0;

    alGenSources(1, &s->source);
    //alSourcei (s->source, AL_SOURCE_RELATIVE, AL_TRUE);
    //alSource3f(s->source, AL_POSITION, 0.0, 0.0, -1.0);
    //alSourcef (s->source, AL_ROLLOFF_FACTOR, 0.0);
    // AL_DIRECT_CHANNELS_SOFT
    alSourcei(s->source, 0x1033, AL_TRUE);

    check_al_error("alGenSources");
    for (int i = 0; i < s->num_buffers; i++) {
        ALuint buffer;
        alGenBuffers(1, &buffer);
        check_al_error("alGenBuffers");
        g_queue_push_tail(s->queue, FS_UINT_TO_POINTER(buffer));
    }

    if (stream == 0) {
        s->fill_target = g_default_fill_target;
    } else {
        s->fill_target = 0;
    }

    g_streams[stream] = s;
}
示例#7
0
文件: emu.c 项目: alpine9000/fs-uae
void fse_init_early(void)
{
    FSE_INIT_ONCE();
    fs_log("[FSE] Init (early)\n");

    fs_init_time();

    if (fs_config_true(OPTION_STDOUT)) {
        fs_log_enable_stdout();
    }

    fs_log("[FSE] Calling fs_ml_init\n");
    fs_ml_init();

#ifdef WITH_LUA
    fs_emu_lua_init();
#endif

    g_gui_mutex = fs_mutex_create();
    fse_init_hud_early();
    // fs_emu_dialog_init();
}
示例#8
0
文件: emu.c 项目: eehrich/fs-uae
void fs_emu_init(void)
{
    fs_log("fs_emu_init\n");
    //if (!g_fs_emu_config) {
    //    g_fs_emu_config = g_key_file_new();
    //}
    fs_time_init();

    if (fs_config_get_boolean("stdout") == 1) {
        fs_log_enable_stdout();
    }

    fs_emu_log("calling fs_ml_init\n");
    fs_ml_init();

#ifdef WITH_LUA
    fs_emu_lua_init();
#endif

    g_gui_mutex = fs_mutex_create();
    fs_emu_hud_init();
    fs_emu_dialog_init();

}
示例#9
0
文件: log.c 项目: keirf/fs-uae
static void initialize()
{
    if (log.initialized) {
        return;
    }
    log.mutex = fs_mutex_create();
    log.initialized = 1;

    char *dir = g_build_filename(fs_get_user_data_dir(), "fs-uae", NULL);
    if (!fs_path_exists(dir)) {
        if (g_mkdir_with_parents(dir, 0755) == -1) {
            // could not create directory
            printf("WARNING: could not create directory %s\n", dir);
            g_free(dir);
            return;
        }
    }
    log.initial_path = g_build_filename(dir, "fs-uae.log", NULL);
    log.file = g_fopen(log.initial_path, "w");
    if (log.file) {
        // printf("[LOG] %s\n", log.initial_path);
    }
    g_free(dir);
}
示例#10
0
文件: ml.c 项目: alpine9000/fs-uae
void fs_ml_init_2(void)
{
    fs_ml_input_init();

    g_fs_ml_video_screenshot_mutex = fs_mutex_create();
}
示例#11
0
void fs_ml_input_init() {
    FS_ML_INIT_ONCE;

    SDL_Init(SDL_INIT_JOYSTICK);

    fs_log("fs_ml_input_init\n");

    if (fs_config_get_boolean(OPTION_MOUSE_INTEGRATION) == 1) {
        g_mouse_integration = 1;
    }

    g_cursor_mode = fs_config_get_boolean(OPTION_CURSOR);
    if (fs_config_check_auto(OPTION_CURSOR, FS_CONFIG_AUTO)) {
        if (fs_emu_mouse_integration()) {
            g_cursor_mode = 0;
        } else {
            g_cursor_mode = -1;
        }
    }

    g_input_queue = g_queue_new();
    g_input_mutex = fs_mutex_create();

    fs_log("calling fs_ml_video_init\n");
    fs_ml_video_init();

    int size = sizeof(fs_ml_input_device) * FS_ML_INPUT_DEVICES_MAX;
    // allocate zeroed memory
    g_fs_ml_input_devices = g_malloc0(size);

    fs_ml_initialize_keymap();

    int k = 0;
    g_fs_ml_first_joystick_index = 0;

    g_fs_ml_input_devices[k].type = FS_ML_KEYBOARD;
    g_fs_ml_input_devices[k].index = k;
    g_fs_ml_input_devices[k].name = g_strdup("KEYBOARD");
    g_fs_ml_input_devices[k].alias = g_strdup("KEYBOARD");
    k += 1;

    g_fs_ml_input_device_count = k;
    fs_ml_mouse_init();
    k = g_fs_ml_input_device_count;

    g_fs_ml_first_joystick_index = g_fs_ml_input_device_count;

    int num_joysticks = SDL_NumJoysticks();
    fs_log("num joystick devices: %d\n", num_joysticks);
    if (SDL_WasInit(SDL_INIT_JOYSTICK) == 0) {
        fs_log("WARNING: Joystick module not initialized\n");
    }
    for (int i = 0; i < num_joysticks; i++) {
        if (k == FS_ML_INPUT_DEVICES_MAX) {
            fs_log("WARNING: reached max num devices\n");
            break;
        }
        SDL_Joystick *joystick = SDL_JoystickOpen(i);

#ifdef USE_SDL2
        char* name = g_ascii_strup(SDL_JoystickName(joystick), -1);
#else
        char* name = g_ascii_strup(SDL_JoystickName(i), -1);
#endif
        name = g_strstrip(name);
        if (name[0] == '\0') {
            g_free(name);
            name = g_ascii_strup("Unnamed", -1);
        }

        // fs_ml_input_unique_device_name either returns name, or frees it
        // and return another name, so name must be malloced and owned by
        // caller
        name = fs_ml_input_unique_device_name(name);

        g_fs_ml_input_devices[k].type = FS_ML_JOYSTICK;
        g_fs_ml_input_devices[k].index = k;
        g_fs_ml_input_devices[k].name = name;
        if (i == 0) {
            g_fs_ml_input_devices[k].alias = g_strdup("JOYSTICK");
        }
        else {
            g_fs_ml_input_devices[k].alias = g_strdup_printf("JOYSTICK #%d",
                    i + 1);
        }

        g_fs_ml_input_devices[k].hats = SDL_JoystickNumHats(joystick);
        g_fs_ml_input_devices[k].buttons = SDL_JoystickNumButtons(joystick);
        g_fs_ml_input_devices[k].axes = SDL_JoystickNumAxes(joystick);
        g_fs_ml_input_devices[k].balls = SDL_JoystickNumBalls(joystick);

        fs_log("joystick device #%02d found: %s\n", i + 1, name);
        fs_log("- %d buttons %d hats %d axes %d balls\n",
                g_fs_ml_input_devices[k].buttons,
                g_fs_ml_input_devices[k].hats,
                g_fs_ml_input_devices[k].axes,
                g_fs_ml_input_devices[k].balls);
        k += 1;
    }

    g_fs_ml_input_device_count = k;

    fs_ml_initialize_keymap();
}
示例#12
0
void fs_init() {
    g_thread_init(NULL);
    g_init_mutex = fs_mutex_create();
}