コード例 #1
0
ファイル: initcmdline.c プロジェクト: r-type/vice-libretro
void initcmdline_check_attach(void)
{
    if (machine_class != VICE_MACHINE_VSID) {
        /* Handle general-purpose command-line options.  */

        /* `-autostart' */
        if (autostart_string != NULL) {
            autostart_autodetect_opt_prgname(autostart_string, 0, autostart_mode);
        }
        /* `-8', `-9', `-10' and `-11': Attach specified disk image.  */
        {
            int i;

            for (i = 0; i < 4; i++) {
                if (startup_disk_images[i] != NULL
                    && file_system_attach_disk(i + 8, startup_disk_images[i])
                    < 0) {
                    log_error(LOG_DEFAULT,
                              "Cannot attach disk image `%s' to unit %d.",
                              startup_disk_images[i], i + 8);
                }
            }
        }

        /* `-1': Attach specified tape image.  */
        if (startup_tape_image && tape_image_attach(1, startup_tape_image) < 0) {
            log_error(LOG_DEFAULT, "Cannot attach tape image `%s'.",
                      startup_tape_image);
        }
    }

    cmdline_free_autostart_string();
}
コード例 #2
0
ファイル: uiattach.c プロジェクト: r-type/vice-libretro
static void uiattach_tape_dialog(HWND hwnd)
{
    TCHAR *st_name;
    int autostart_index = -1;

    SuspendFullscreenModeKeep(hwnd);
    if ((st_name = uilib_select_file_autostart(hwnd,
                   translate_text(IDS_ATTACH_TAPE_IMAGE),
                   UILIB_FILTER_TAPE |
#ifdef HAVE_ZLIB
                   UILIB_FILTER_ZIP |
#endif
                   UILIB_FILTER_ALL,
                   UILIB_SELECTOR_TYPE_FILE_LOAD, UILIB_SELECTOR_STYLE_TAPE,
                   &autostart_index, NULL)) != NULL) {
        char *name;

        name = system_wcstombs_alloc(st_name);
        if (autostart_index >= 0) {
            if (autostart_autodetect(name, NULL, autostart_index, AUTOSTART_MODE_RUN) < 0) {
                ui_error(translate_text(IDS_CANNOT_AUTOSTART_FILE));
            }
        } else {
            if (tape_image_attach(1, name) < 0) {
                ui_error(translate_text(IDS_CANNOT_ATTACH_FILE));
            }
        }
        system_wcstombs_free(name);
        lib_free(st_name);
    }
    ResumeFullscreenModeKeep(hwnd);
}
コード例 #3
0
ファイル: uiattach.c プロジェクト: martinpiper/VICE
void uiattach_aros(video_canvas_t *canvas, int unit)
{
  char *fname=NULL;
  char select_txt[50];

  if (unit==1)
  {
    fname=BrowseFile("Select file for tape","#?", canvas);
    if (fname!=NULL)
    {
      if (tape_image_attach(1, fname) < 0)
        ui_error(translate_text(IDMES_CANNOT_ATTACH_FILE));
    }
  }
  else
  {
    sprintf(select_txt,"Select file for unit %d",unit);
    fname=BrowseFile(select_txt, "#?", canvas);
    if (fname!=NULL)
    {
      if (file_system_attach_disk(unit, fname) < 0)
        ui_error(translate_text(IDMES_CANNOT_ATTACH_FILE));
    }
  }
}
コード例 #4
0
ファイル: tape-snapshot.c プロジェクト: martinpiper/VICE
static int tape_snapshot_read_tapimage_module(snapshot_t *s)
{
    BYTE major_version, minor_version;
    snapshot_module_t *m;
    char *filename = NULL;
    FILE *ftap;
    BYTE *buffer;
    long tap_size;

    m = snapshot_module_open(s, "TAPIMAGE",
                             &major_version, &minor_version);
    if (m == NULL)
        return 0;

    if (major_version > TAPIMAGE_SNAP_MAJOR
        || minor_version > TAPIMAGE_SNAP_MINOR) {
        log_error(tape_snapshot_log,
                  "Snapshot module version (%d.%d) newer than %d.%d.",
                  major_version, minor_version,
                  TAPIMAGE_SNAP_MAJOR, TAPIMAGE_SNAP_MINOR);
    }

    /* create temporary file */
    /* FIXME: Were is this file deleted? */
    ftap = archdep_mkstemp_fd(&filename, MODE_WRITE);

    if (ftap == NULL) {
        log_error(tape_snapshot_log, "Could not create temporary file!");
        snapshot_module_close(m);
        goto fail;
    }

    SMR_DW_UL(m, (unsigned long *)&tap_size);

    buffer = lib_malloc(tap_size);

    SMR_BA(m, buffer, tap_size);

    if (fwrite(buffer, tap_size, 1, ftap) != 1) {
        log_error(tape_snapshot_log, "Could not create temporary file");
        log_error(tape_snapshot_log, "filename=%s", filename);
        snapshot_module_close(m);
        fclose(ftap);
        goto fail;
    }

    lib_free(buffer);
    fclose(ftap);
    tape_image_attach(1, filename);
    lib_free(filename);
    snapshot_module_close(m);
    return 0;

fail:
    lib_free(filename);
    return -1;
}
コード例 #5
0
ファイル: autostart.c プロジェクト: martinpiper/VICE
/* Autostart tape image `file_name'.  */
int autostart_tape(const char *file_name, const char *program_name,
                   unsigned int program_number, unsigned int runmode)
{
    char *name = NULL;

    if (network_connected() || !file_name || !autostart_enabled)
        return -1;

    /* Get program name first to avoid more than one file handle open on
       image.  */
    if (!program_name && program_number > 0)
        name = image_contents_filename_by_number(IMAGE_CONTENTS_TAPE,
                                                 file_name, 0, program_number);
    else
        name = lib_stralloc(program_name ? program_name : "");

    if (!(tape_image_attach(1, file_name) < 0)) {
        log_message(autostart_log,
                    "Attached file `%s' as a tape image.", file_name);
        if (tape_tap_attched()) {
            if (program_number > 0) {
                lib_free(name);
                name = NULL;
                /* program numbers in tape_seek_to_file() start at 0 */
                tape_seek_to_file(tape_image_dev1, program_number-1);
            } else {
                tape_seek_start(tape_image_dev1);
            }
        }
        resources_set_int("VirtualDevices", 1); /* Kludge: iAN CooG - for t64 images we need devtraps ON */
        reboot_for_autostart(name, AUTOSTART_HASTAPE, runmode);
        lib_free(name);

        return 0;
    }

    autostartmode = AUTOSTART_ERROR;
    deallocate_program_name();

    if (name)
        lib_free(name);

    return -1;
}
コード例 #6
0
ファイル: uiattach.c プロジェクト: AreaScout/vice
static void uiattach_tape_dialog(video_canvas_t *canvas)
{
    char *name;
    int autostart_index = -1;

    if ((name = uilib_select_file_autostart(translate_text(IDS_ATTACH_TAPE_IMAGE),
                                            UILIB_FILTER_TAPE | UILIB_FILTER_ZIP | UILIB_FILTER_ALL,
                                            UILIB_SELECTOR_TYPE_FILE_LOAD, UILIB_SELECTOR_STYLE_TAPE,
                                            &autostart_index, NULL)) != NULL) {
        if (autostart_index >= 0) {
            if (autostart_autodetect(name, NULL, autostart_index, AUTOSTART_MODE_RUN) < 0) {
                ui_error(translate_text(IDMES_CANNOT_AUTOSTART_FILE));
            }
        } else {
            if (tape_image_attach(1, name) < 0) {
                ui_error(translate_text(IDMES_CANNOT_ATTACH_FILE));
            }
        }
        lib_free(name);
    }
}
コード例 #7
0
ファイル: autostart.c プロジェクト: aerdnar/emu-ex-plus-alpha
/* Autostart tape image `file_name'.  */
int autostart_tape(const char *file_name, const char *program_name,
                   unsigned int program_number, unsigned int runmode)
{
    BYTE do_seek = 1;

    if (network_connected() || event_record_active() || event_playback_active()
        || !file_name || !autostart_enabled) {
        return -1;
    }

    if (!(tape_image_attach(1, file_name) < 0)) {
        log_message(autostart_log,
                    "Attached file `%s' as a tape image.", file_name);
        if (!tape_tap_attached()) {
            if (program_number == 0 || program_number == 1) {
                do_seek = 0;
            }
            program_number -= 1;
        }
        if (do_seek) {
            if (program_number > 0) {
                /* program numbers in tape_seek_to_file() start at 0 */
                tape_seek_to_file(tape_image_dev1, program_number - 1);
            } else {
                tape_seek_start(tape_image_dev1);
            }
        }
        if (!tape_tap_attached()) {
            resources_set_int("VirtualDevices", 1); /* Kludge: for t64 images we need devtraps ON */
        }
        reboot_for_autostart(program_name, AUTOSTART_HASTAPE, runmode);

        return 0;
    }

    autostartmode = AUTOSTART_ERROR;
    deallocate_program_name();

    return -1;
}
コード例 #8
0
ファイル: menudefs.c プロジェクト: bobsummerwill/VICE
static TUI_MENU_CALLBACK(attach_tape_callback)
{
    const char *s;

    if (been_activated) {
        char *directory, *default_item;
        char *name, *file;

        s = tape_get_file_name();
        util_fname_split(s, &directory, &default_item);

        name = tui_file_selector("Attach a tape image", directory, "*.t64;*.tap;*.t6z;*.taz;*.zip;*.gz;*.lzh", default_item, tapecontents_read, &file, NULL);

        if (file != NULL) {
            if (autostart_tape(name, file, 0, AUTOSTART_MODE_RUN) < 0) {
                tui_error("Cannot autostart tape image.");
            } else {
                *behavior = TUI_MENU_BEH_RESUME;
            }
            lib_free(file);
        } else if (name != NULL && (s == NULL || strcasecmp(s, name) != 0) && tape_image_attach(1, name) < 0) {
            tui_error("Invalid tape image.");
        }
        ui_update_menus();
        lib_free(directory);
        lib_free(default_item);
        lib_free(name);
    }

    s = tape_get_file_name();
    if (s == NULL || *s == '\0') {
        return "(none)";
    } else {
        return s;
    }
}
コード例 #9
0
ファイル: dlg-fileio.c プロジェクト: bobsummerwill/VICE
static BOOL FdmDoLoadAction(HWND hwnd, const char *szpath, int act, int sact)
{
    switch (act) {
        case 0:
            return file_system_attach_disk(sact + 8, szpath);
        case 1:
            return tape_image_attach(1, szpath);
        case 2:
            return fliplist_load_list(sact + 8, szpath, FALSE);
        case 3:
            return fliplist_load_list(sact + 8, szpath, TRUE);
        case 4:
            return trap(hwnd, load_snapshot, szpath);
        case 5:
            switch (sact) {
                case 0:
                    return resources_set_string(VIDEO_PALETTE, szpath);
#ifdef __X128__
                case 1:
                    return resources_set_string("VDC_PaletteFile", szpath);
#endif
#ifdef __XCBM__
                case 1:
                    return resources_set_string("ViciiPaletteFile", szpath);
#endif
            }
            return -1;
        case 6: // rom img
            return resources_set_string("KeymapFile", szpath);
        case 7:
            switch (sact) {
                case 0:
                    return resources_set_string("KernalName", szpath);
                case 1:
                    return resources_set_string("ChargenName", szpath);
                case 2:
                    return resources_set_string("DosName1541", szpath);
                case 3:
                    return resources_set_string("DosName154ii", szpath);
                case 4:
                    return resources_set_string("DosName1571", szpath);
                case 5:
                    return resources_set_string("DosName1581", szpath);
                case 6:
                    return resources_set_string("DosName2031", szpath);
                case 7:
                    return resources_set_string("DosName1001", szpath);
                case 8:
                    return resources_set_string("DosName2040", szpath);
                case 9:
                    return resources_set_string("DosName3040", szpath);
                case 10:
                    return resources_set_string("DosName4040", szpath);
                case 11:
                    return resources_set_string("BasicName", szpath);
                case 12:
                    return resources_set_string("Z80BiosName", szpath);
                case 13:
                    return resources_set_string("Kernal64Name", szpath);
                case 14:
                    return resources_set_string("Basic64Name", szpath);
                case 15:
                    return resources_set_string("Chargen64Name", szpath);
                case 16:
                    return resources_set_string("ChargenIntName", szpath);
                case 17:
                    return resources_set_string("ChargenDEName", szpath);
                case 18:
                    return resources_set_string("ChargenFRName", szpath);
                case 19:
                    return resources_set_string("ChargenSEName", szpath);
                case 20:
                    return resources_set_string("KernalIntName", szpath);
                case 21:
                    return resources_set_string("KernalDEName", szpath);
                case 22:
                    return resources_set_string("KernalFIName", szpath);
                case 23:
                    return resources_set_string("KernalFRName", szpath);
                case 24:
                    return resources_set_string("KernalITName", szpath);
                case 25:
                    return resources_set_string("KernalNOName", szpath);
                case 26:
                    return resources_set_string("KernalSEName", szpath);
                case 27:
                    return resources_set_string("BasicHiName", szpath);
                case 28:
                    return resources_set_string("BasicLoName", szpath);
            }
            return -1;
        case 8:
            return machine_romset_file_load(szpath);
        case 9:
            return resources_load(szpath);
#if defined __X64__ || defined __X128__
        case 10:
            switch (sact) {
                case 0:
                    return cartridge_attach_image(CARTRIDGE_CRT, szpath);
                case 1:
                    return cartridge_attach_image(CARTRIDGE_GENERIC_8KB, szpath);
                case 2:
                    return cartridge_attach_image(CARTRIDGE_GENERIC_16KB, szpath);
                case 3:
                    return cartridge_attach_image(CARTRIDGE_ACTION_REPLAY, szpath);
                case 4:
                    return cartridge_attach_image(CARTRIDGE_ATOMIC_POWER, szpath);
                case 5:
                    return cartridge_attach_image(CARTRIDGE_EPYX_FASTLOAD, szpath);
                case 6:
                    return cartridge_attach_image(CARTRIDGE_SUPER_SNAPSHOT, szpath);
                case 7:
                    return cartridge_attach_image(CARTRIDGE_SUPER_SNAPSHOT_V5, szpath);
                case 8:
                    return cartridge_attach_image(CARTRIDGE_WESTERMANN, szpath);
                case 9:
                    return cartridge_attach_image(CARTRIDGE_IEEE488, szpath);
                case 10:
                    return cartridge_attach_image(CARTRIDGE_IDE64, szpath);
            }
            return -1;
#endif
#ifdef __XPET__
        case 10:
            switch (sact) {
                case 0:
                    return resources_set_string("RomModule9Name", szpath);
                case 1:
                    return resources_set_string("RomModuleAName", szpath);
                case 2:
                    return resources_set_string("RomModuleBName", szpath);
            }
            return -1;
#endif
#ifdef __XCBM__
        case 10:
            switch (sact) {
                case 0:
                    return resources_set_string("Cart1Name", szpath);
                case 1:
                    return resources_set_string("Cart2Name", szpath);
                case 2:
                    return resources_set_string("Cart4Name", szpath);
                case 3:
                    return resources_set_string("Cart6Name", szpath);
            }
            return -1;
#endif
#ifdef __X128__
        case 11:
            switch (sact) {
                case 0:
                    return resources_set_string("InternalFunctionName", szpath);
                case 1:
                    return resources_set_string("ExternalFunctionName", szpath);
            }
            return -1;
#endif
    }
    return -1;
}