FILE *fsdb_open_meta_file_for_path(const char *path, const char *mode, int always_open) { char *meta_file = fs_strconcat(path, ".uaem", NULL); if (g_fsdb_debug) { write_log("opening meta file %s mode %s\n", meta_file, mode); } if (!always_open) { if (!fs_path_exists(meta_file)) { if (g_fsdb_debug) { write_log("- didn't exist, don't force open\n"); } return NULL; } } FILE *f = fs_fopen(meta_file, mode); if (g_fsdb_debug) { write_log("FILE is %p\n", f); } free(meta_file); return f; }
void fs_uae_configure_cdrom() { /* if (g_fs_uae_amiga_model != MODEL_CDTV && g_fs_uae_amiga_model != MODEL_CD32) { return; } */ fs_emu_log("configure_cdrom\n"); char *path = fs_config_get_string("cdrom_drive_0"); if (path) { path = fs_uae_expand_path_and_free(path); path = fs_uae_resolve_path_and_free(path, FS_UAE_CD_PATHS); //set_default_dirs_from_file_path(path); char* temp = fs_strconcat(path, ",", NULL); amiga_set_option("cdimage0", temp); free(temp); free(path); if (g_fs_uae_amiga_model != MODEL_CDTV && g_fs_uae_amiga_model != MODEL_CD32) { amiga_set_option("scsi", "true"); amiga_map_cd_drives(1); } } }
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; }