Ejemplo n.º 1
0
static FishSoundComment *
fs_comment_new (const char * name, const char * value)
{
  FishSoundComment * comment;

  if (!fs_comment_validate_byname (name, value)) return NULL;
  /* Ensures that name != NULL, value != NULL, and validates strings */

  comment = fs_malloc (sizeof (FishSoundComment));
  if (comment == NULL) return NULL;

  comment->name = fs_strdup (name);
  if (comment->name == NULL) {
    fs_free (comment);
    return NULL;
  }

  comment->value = fs_strdup (value);
  if (comment->value == NULL) {
    fs_free (comment->name);
    fs_free (comment);
    return NULL;
  }

  return comment;
}
Ejemplo n.º 2
0
fs_emu_dialog* fs_emu_dialog_create(const char *title,
        const char *affirmative, const char *negative) {
    fs_emu_dialog* dialog = g_malloc0(sizeof(fs_emu_dialog));
    if (title) {
        dialog->title = fs_strdup(title);
    }
    if (affirmative) {
        dialog->affirmative = fs_strdup(affirmative);
    }
    if (negative) {
        dialog->negative = fs_strdup(negative);
    }
    return dialog;
}
Ejemplo n.º 3
0
char *fs_emu_theme_get_resource(const char *name) {
    if (fs_path_exists(name)) {
        return fs_strdup(name);
    }
    char *path, *p;

    p = fs_path_join(g_fs_emu_theme.path, name, NULL);
    if (fs_path_exists(p)) {
        return p;
    }
    free(p);

    p = fs_path_join(g_fs_emu_theme.name, name, NULL);
    path = fs_get_program_data_file(p);
    free(p);
    if (path) {
        return path;
    }
    //p = fs_path_join("default", name, NULL);
    path = fs_get_program_data_file(name);
    //free(p);
    if (path) {
        return path;
    }
    return NULL;
}
Ejemplo n.º 4
0
void fs_uae_read_custom_uae_options(int argc, char **argv) {
	fs_log("read_custom_uae_options\n");
    if (g_fs_uae_config_file_path) {
        FILE *f = fs_fopen(g_fs_uae_config_file_path, "rb");
		read_custom_uae_options_from_file(f);
        fclose(f);
    }

    for (int i = 0; i < argc; i++) {
        char *arg = argv[i];
        if (!fs_str_has_prefix(arg, "--")) {
            continue;
        }
        char *key = arg + 2;
        char *value = strchr(arg, '=');
        if (value) {
            char *k = fs_strndup(key, value - key);
            fs_strdelimit (k, "-", '_');
            char *v = fs_strdup(value + 1);
            char *key_lower = fs_ascii_strdown(k, -1);
            free(k);
            parse_option(key_lower, v);
            free(key_lower);
            free(v);
        }
    }
}
Ejemplo n.º 5
0
void fs_emu_init_overlays(const char **overlay_names) {
    int k = FS_EMU_FIRST_CUSTOM_OVERLAY;
    const char **name = overlay_names;
    while(*name) {
        if (k < FS_EMU_MAX_OVERLAYS) {
            g_fs_emu_theme.overlays[k].name = fs_strdup(*name);
        }
        k = k + 1;
        name++;
    }
}
Ejemplo n.º 6
0
void fs_emu_dialog_set_line(fs_emu_dialog *dialog, int line,
        const char *text) {
    if (line < 0 || line >= DIALOG_MAX_LINES) {
        fs_log("warning: invalid dialog line number");
        return;
    }
    if (dialog->lines[line]) {
        free(dialog->lines[line]);
    }
    dialog->lines[line] = fs_strdup(text);
}
Ejemplo n.º 7
0
int
fish_sound_comment_set_vendor (FishSound * fsound, const char * vendor_string)
{
  if (fsound == NULL) return FISH_SOUND_ERR_BAD;

  if (fsound->vendor) fs_free (fsound->vendor);

  if ((fsound->vendor = fs_strdup (vendor_string)) == NULL)
    return FISH_SOUND_ERR_OUT_OF_MEMORY;

  return 0;
}
Ejemplo n.º 8
0
static void load_defaults() {
    // this determines the coordinate system for overlays, etc
    g_fs_emu_theme.width = 1920;
    g_fs_emu_theme.height = 1080;

    g_fs_emu_theme.floor_height = 361;

    set_color(g_fs_emu_theme.floor_color_1, 20.0 / 255.0, 22.0 / 255.0,
            26.0 / 255.0, 1.0);
    set_color(g_fs_emu_theme.floor_color_2, 0.0, 0.0, 0.0, 1.0);

    set_color(g_fs_emu_theme.wall_color_1, 0.0, 0.0, 0.0, 1.0);
    set_color(g_fs_emu_theme.wall_color_2, 39.0 / 255.0, 44.0 / 255.0,
            51.0 / 255.0, 1.0);
    //set_color(g_fs_emu_theme.wall_color_2, 239.0 / 255.0, 44.0 / 255.0,
    //      51.0 / 255.0, 1.0);

    set_color(g_fs_emu_theme.heading_color, 0.0, 1.0 * 0x99 / 0xff,
            1.0 * 0xcc / 0xff, 1.0);
    set_color(g_fs_emu_theme.item_color, 1.0, 1.0, 1.0, 1.0);
    set_color(g_fs_emu_theme.fade_color, 0.0, 0.0, 0.0, 1.0);
    g_fs_emu_theme.overlay_image = fs_strdup("overlay.png");
}
Ejemplo n.º 9
0
char *uae_expand_path(const char *path) {
    /*
    write_log("expand_path %s\n", path);
    gchar* lower = g_ascii_strdown(path, -1);
    int replace = 0;
    if (g_str_has_prefix(lower, "~/") || g_str_has_prefix(lower, "~\\")) {
        replace = 2;
    }
    if (g_str_has_prefix(lower, "$home/") ||
            g_str_has_prefix(lower, "$home\\")) {
        replace = 6;
    }
    free(lower);
    if (replace) {
        const gchar *src = path + replace;
        printf("... %s\n", g_build_filename(g_get_home_dir(), src, NULL));
        return g_build_filename(g_get_home_dir(), src, NULL);
    }
    else {
        return fs_strdup(path);
    }
    */
    return fs_strdup(path);
}
Ejemplo n.º 10
0
fs_emu_texture *fs_emu_texture_new_from_file(const char *name) {
    char *full_name;
    char *path;
    if (fs_path_exists(name)) {
        full_name = fs_strdup(name);
        path = fs_strdup(name);
    }
    else {
        full_name = fs_strconcat(name, ".png", NULL);
        path = fs_get_program_data_file(full_name);
        if (path == NULL) {
            fs_emu_warning("Could not find texture %s\n", full_name);
            return NULL;
        }
    }
    fs_image *image = fs_image_new_from_file(path);
    fs_emu_log("loading texture \"%s\"\n", path);
    free(path);
    if (image == NULL) {
        fs_emu_warning("Could not load texture from %s\n", full_name);
        free(full_name);
        return NULL;
    }
    free(full_name);

    if (fs_emu_get_video_format() == FS_EMU_VIDEO_FORMAT_BGRA) {
        // convert to premultiplied alpha
        if (image->format == FS_IMAGE_FORMAT_RGBA) {
            int num_pixels = image->width * image->height;
            unsigned char *pixels = image->data;
            for (int i = 0; i < num_pixels; i++) {
                unsigned char alpha = pixels[3];
                unsigned char temp = pixels[2];
                pixels[2] = ((int) pixels[0]) * alpha / 255;
                pixels[1] = ((int) pixels[1]) * alpha / 255;
                pixels[0] = ((int) temp) * alpha / 255;
                pixels += 4;
            }
        }
        else {
            // FIXME: should swap R and B here...
        }
    }
    else {
        // convert to premultiplied alpha
        if (image->format == FS_IMAGE_FORMAT_RGBA) {
            int num_pixels = image->width * image->height;
            unsigned char *pixels = image->data;
            for (int i = 0; i < num_pixels; i++) {
                unsigned char alpha = pixels[3];
                // should really divide by 255, but 256 is faster...
                //pixels[0] = ((int) pixels[0]) * alpha / 256;
                //pixels[1] = ((int) pixels[1]) * alpha / 256;
                //pixels[2] = ((int) pixels[2]) * alpha / 256;
                pixels[0] = ((int) pixels[0]) * alpha / 255;
                pixels[1] = ((int) pixels[1]) * alpha / 255;
                pixels[2] = ((int) pixels[2]) * alpha / 255;
                //pixels[0] = (unsigned char) ((pixels[0] * alpha + 0.5) / 255.0);
                //pixels[1] = (unsigned char) ((pixels[1] * alpha + 0.5) / 255.0);
                //pixels[2] = (unsigned char) ((pixels[2] * alpha + 0.5) / 255.0);
                pixels += 4;
            }
        }
    }

    fs_emu_texture *texture = fs_new(fs_emu_texture, 1);
    texture->width = image->width;
    texture->height = image->height;
    texture->image = image;
    load_texture(texture);
    fs_emu_set_texture(texture);

    fs_gl_add_context_notification(context_notification_handler, texture);

    return texture;
}
Ejemplo n.º 11
0
void fs_emu_theme_init() {
    fs_log("fs_emu_theme_init\n");

    fs_emu_theme_overlay* o = g_fs_emu_theme.overlays;
    o[FS_EMU_TOP_LEFT_OVERLAY].name = fs_strdup("top_left_overlay");
    o[FS_EMU_TOP_RIGHT_OVERLAY].name = fs_strdup("top_right_overlay");
    o[FS_EMU_TOP_RIGHT_OVERLAY].anchor = FS_EMU_ANCHOR_TOP_RIGHT;
    o[FS_EMU_BOTTOM_RIGHT_OVERLAY].name = fs_strdup("bottom_right_overlay");
    o[FS_EMU_BOTTOM_RIGHT_OVERLAY].anchor = FS_EMU_ANCHOR_BOTTOM_RIGHT;
    o[FS_EMU_BOTTOM_LEFT_OVERLAY].name = fs_strdup("bottom_left_overlay");
    o[FS_EMU_BOTTOM_LEFT_OVERLAY].anchor = FS_EMU_ANCHOR_BOTTOM_LEFT;

    o[FS_EMU_AUDIO_LED_OVERLAY].name = fs_strdup("audio_led");
    o[FS_EMU_FPS_LED_OVERLAY].name = fs_strdup("fps_led");
    o[FS_EMU_VSYNC_LED_OVERLAY].name = fs_strdup("vsync_led");

    const char *theme = fs_config_get_const_string("theme");
    if (theme) {
        g_fs_emu_theme.name = fs_strdup(theme);
        // first try to find the theme in the user's theme dir
        const char *themes_dir = fs_config_get_const_string("themes_dir");
        if (themes_dir) {
            g_fs_emu_theme.path = fs_path_join(themes_dir,
                    g_fs_emu_theme.name, NULL);
            if (!fs_path_exists(g_fs_emu_theme.path)) {
                free(g_fs_emu_theme.path);
                g_fs_emu_theme.path = NULL;
            }
        }
        // or by direct path lookup
        if (!g_fs_emu_theme.path) {
            if (fs_path_exists(theme)) {
                g_fs_emu_theme.path = fs_strdup(theme);
            }
        }
        // then try to find a bundled / installed theme
        if (!g_fs_emu_theme.path) {
            g_fs_emu_theme.path = fs_get_program_data_file(
                    g_fs_emu_theme.name);
        }
        if (g_fs_emu_theme.path) {
            fs_log("theme found at %s\n", g_fs_emu_theme.path);
        }
        else {
            fs_emu_warning(_("Theme not found: %s"), g_fs_emu_theme.name);
            free(g_fs_emu_theme.name);
            // resources will not be found, but path should not be NULL...
            g_fs_emu_theme.path = fs_strdup("");
        }
    }
    else {
        g_fs_emu_theme.name = fs_strdup("");
        g_fs_emu_theme.path = fs_strdup("");
    }

    load_defaults();
    load_theme();
}
Ejemplo n.º 12
0
void fs_uae_configure_hard_drives() {
	static const char *ro_string = "ro";
	static const char *rw_string = "rw";
    const char *read_write = rw_string;
    fs_emu_log("fs_uae_configure_hard_drives\n");
    for(int i = 0; i < 10; i++) {
        char *fs_uae_option = fs_strdup_printf("hard_drive_%d", i);
        char *path = fs_config_get_string(fs_uae_option);
        free(fs_uae_option);
        if (path == NULL) {
            continue;
        }
        if (path[0] == '\0') {
        	continue;
        }
        path = fs_uae_expand_path_and_free(path);
        path = fs_uae_resolve_path_and_free(path, FS_UAE_HD_PATHS);
        if (!fs_path_exists(path)) {
            char *msg = fs_strdup_printf("HD path \"%s\" does not exist",
                    path);
            fs_emu_warning(msg);
            free(msg);
            continue;
        }
        int boot_priority = -i;
        read_write = rw_string;
        char *device = fs_strdup_printf("DH%d", i);

        int virtual = 0;
        if (fs_path_is_dir(path)) {
            virtual = 1;
        }
        else if (fs_str_has_suffix(path, ".zip")) {
            virtual = 1;
            read_write = ro_string;
        }

        fs_uae_option = fs_strdup_printf("hard_drive_%d_read_only", i);
        if (fs_config_get_boolean(fs_uae_option) == 1) {
        	read_write = ro_string;
        }
        free(fs_uae_option);

        if (virtual) {
            char *type = fs_strdup("dir");
            int surfaces = 1;
            int reserved = 2;
            //char *hd_controller = g_strdup("ide0");
            int sectors = 32;
            int block_size = 512;

            char *mount_name;
            char *label_option_name = fs_strdup_printf(
                    "hard_drive_%d_label", i);
            char *label_option = fs_config_get_string(label_option_name);
            if (label_option) {
                mount_name = label_option;
            }
            else {
                mount_name = fs_path_get_basename(path);
            }

            fs_emu_log("hard drive mount: %s\n", path);
            fs_emu_log("device: %s\n", device);
            fs_emu_log("mount name: %s\n", mount_name);
            fs_emu_log("read/write: %s\n", read_write);
            fs_emu_log("boot priority: %d\n", boot_priority);
            /*
            char *option = fs_strdup_printf("uaehf%d", i);
            char *value = fs_strdup_printf("%s,%s,%s:%s:%s,%d",
                    type, read_write, device, mount_name, path,
                    boot_priority);
            amiga_set_option(option, value);
            */

            char *option2 = fs_strdup("filesystem2");
            char *value2 = fs_strdup_printf("%s,%s:%s:%s,%d",
                    read_write, device, mount_name, path,
                    boot_priority);
            amiga_set_option(option2, value2);
            free(option2);
            free(value2);

            // uaehf0=hdf,rw,DH0:path.hdf,32,1,2,512,0,,uae;

            //free(option);
            //free(value);
            free(device);
            free(type);
            free(mount_name);
            continue;
        }
        else if (fs_path_exists(path)) {