Example #1
0
static TUI_MENU_CALLBACK(flip_previous_callback)
{
    if (been_activated) {
        fliplist_attach_head(8, 0);
    }
    return NULL;
}
Example #2
0
static void ui_fliplist_select_cb(GtkWidget *widget, gpointer data)
{
    int unit = GPOINTER_TO_INT(data) & 0xff;
    int index = (GPOINTER_TO_INT(data) >> 8) & 0xff;
    int i;
    if (index == 0) {
        fliplist_t list = fliplist_init_iterate(unit);
        const char *image = fliplist_get_image(list);
        file_system_attach_disk(unit, image);
    } else {
        for (i = 0; i < index; ++i) {
            fliplist_attach_head(unit, 1);
        }
    }
}
Example #3
0
int fliplist_load_list(unsigned int unit, const char *filename, int autoattach)
{
    FILE *fp;
    char buffer[buffer_size];
    int all_units = 0, i;
    int listok = 0;

    if (filename == NULL || *filename == 0 || (fp = fopen(filename, MODE_READ)) == NULL) {
        return -1;
    }

    buffer[0] = '\0';
    if (fgets(buffer, buffer_size, fp) == NULL) {
        fclose(fp);
        return -1;
    }

    if (strncmp(buffer, flip_file_header, strlen(flip_file_header)) != 0) {
        log_message(LOG_DEFAULT, "File %s is not a fliplist file", filename);
        fclose(fp);
        return -1;
    }
    if (unit == FLIPLIST_ALL_UNITS) {
        all_units = 1;
        for (i = 0; i < NUM_DRIVES; i++) {
            fliplist_clear_list(i + 8);
        }
    } else {
        fliplist_clear_list(unit);
    }

    while (!feof(fp)) {
        char *b;

        buffer[0] = '\0';
        if (fgets(buffer, buffer_size, fp) == NULL) {
            break;
        }

        if (strncmp("UNIT ", buffer, 5) == 0) {
            if (all_units != 0) {
                long unit_long;

                util_string_to_long(buffer + 5, NULL, 10, &unit_long);

                unit = (unsigned int)unit_long;
            }
            continue;
        }

        /* remove trailing whitespace (linefeeds etc) */
        b = buffer + strlen(buffer);
        while ((b > buffer) && (isspace((unsigned int)(b[-1])))) {
            b--;
        }

        if (b > buffer) {
            fliplist_t tmp;

            *b = '\0';

            if (unit == FLIPLIST_ALL_UNITS) {
                log_message(LOG_DEFAULT, "Fliplist has inconsistent view for unit, assuming 8.\n");
                unit = 8;
            }

            tmp = lib_malloc(sizeof(struct fliplist_s));
            tmp->image = lib_stralloc(buffer);
            tmp->unit = unit;

            if (fliplist[unit - 8] == NULL) {
                fliplist[unit - 8] = tmp;
                tmp->prev = tmp;
                tmp->next = tmp;
            } else {
                tmp->next = fliplist[unit - 8];
                tmp->prev = fliplist[unit - 8]->prev;
                tmp->next->prev = tmp;
                tmp->prev->next = tmp;
                fliplist[unit - 8] = tmp;
            }
            listok = 1;
        }
    }

    fclose(fp);

    if (listok) {
        current_drive = unit;

        if (all_units) {
            for (i = 0; i < NUM_DRIVES; i++) {
                show_fliplist(i + 8);
            }
        } else {
            show_fliplist(unit);
        }

        if (autoattach) {
            fliplist_attach_head(unit, 1);
        }

        return 0;
    }

    return -1;
}
Example #4
0
static UI_CALLBACK(attach_from_fliplist3)
{
    fliplist_attach_head(8, (int)UI_MENU_CB_PARAM);
}
Example #5
0
static UI_CALLBACK(attach_from_fliplist)
{
    fliplist_attach_head(((struct cb_data_t *)UI_MENU_CB_PARAM)->unit,
                         (int) ((struct cb_data_t *)UI_MENU_CB_PARAM)->data);
}
Example #6
0
static MRESULT EXPENTRY pm_drive(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
    static int drive = 0;

    switch (msg) {
        case WM_INITDLG:
            {
                int val, i = 0;
                HWND ihwnd = WinWindowFromID(hwnd, CBS_IMAGE);

                while (i < 10 && ui_status.imageHist[i][0]) {
                    WinLboxInsertItem(ihwnd, ui_status.imageHist[i++]);
                }
                WinLboxInsertItem(ihwnd, "");
                resources_get_int("DriveTrueEmulation", &val);
                WinCheckButton(hwnd, CB_TRUEDRIVE, val);
                WinCheckButton(hwnd, RB_DRIVE8|drive, 1);
                WinSendMsg(hwnd, WM_SWITCH, (void*)drive, 0);
                WinSendMsg(hwnd, WM_DRIVESTATE, (void*)ui_status.lastDriveState, NULL);
                for (i = 0; i < 3; i++) {
                    WinSendMsg(hwnd, WM_TRACK, (void*)i, (void*)(int)(ui_status.lastTrack[i] * 2));
                }
        }
        break;
    case WM_COMMAND:
        switch (LONGFROMMP(mp1)) {
            case PB_CREATE:
                create_dialog(hwnd);
                return FALSE;
            case PB_ATTACH:
                ViceFileDialog(hwnd, 0x0100 | (drive + 1), FDS_OPEN_DIALOG);
                return FALSE;
            case PB_DETACH:
                file_system_detach_disk(drive + 8);
                return FALSE;
            case PB_FLIPADD:
                fliplist_add_image(drive + 8);
                return FALSE;
            case PB_FLIPREMOVE:
                fliplist_remove(drive + 8, NULL);
                return FALSE;
            case PB_FLIP:
                fliplist_attach_head(drive + 8, FLIP_NEXT);
                return FALSE;
        }
        break;
    case WM_CONTROL:
        {
            switch (SHORT1FROMMP(mp1)) {
                case RB_DRIVE8:
                case RB_DRIVE9:
                case RB_DRIVE10:
                case RB_DRIVE11:
                    WinSendMsg(hwnd, WM_SWITCH, (void*)(SHORT1FROMMP(mp1) & 0x3), 0);
                    break;
                case CB_TRUEDRIVE:
                    toggle("DriveTrueEmulation");
                    WinSendMsg(hwnd, WM_SWITCH, (void*)drive, 0);
                    break;
                case CB_CONVERTP00:
                    toggle_drive_res("FSDevice%dConvertP00", drive);//);
                    WinSendMsg(hwnd, WM_SWITCH, (void*)drive, 0);
                    break;
                case CB_SAVEP00:
                    toggle_drive_res("FileDevice%dSaveP00", drive);
                    break;
                case CB_ALLOWACCESS:
                    toggle_drive_res("FileSystemDevice%d", drive);
                    WinSendMsg(hwnd, WM_SWITCH, (void*)drive, 0);
                    break;
                case CB_HIDENONP00:
                    toggle_drive_res("FSDevice%dHideCBMFiles", drive);
                    break;
                case CB_MEM2000:
                    toggle_drive_res("Drive%dRAM2000", drive);
                    break;
                case CB_MEM4000:
                    toggle_drive_res("Drive%dRAM4000", drive);
                    break;
                case CB_MEM6000:
                    toggle_drive_res("Drive%dRAM6000", drive);
                    break;
                case CB_MEM8000:
                    toggle_drive_res("Drive%dRAM8000", drive);
                    break;
                case CB_MEMA000:
                    toggle_drive_res("Drive%dRAMA000", drive);
                    break;
                case CB_READONLY:
                    toggle_drive_res("AttachDevice%dReadonly", drive);
                    break;
                case CB_PARALLEL:
                    if (drive == 0 || drive == 1) {
                        toggle_drive_res("Drive%dParallelCable", drive);
                    }
                    break;
                case RB_NEVER:
                case RB_ASK:
                case RB_ALWAYS:
                    if (drive == 0 || drive == 1) {
                        resources_set_int_sprintf("Drive%dExtendImagePolicy", (SHORT1FROMMP(mp1) & 0x3), drive + 8);
                    }
                    break;
                case RB_NONE:
                case RB_TRAP:
                case RB_SKIP:
                    if (drive == 0 || drive == 1) {
                        resources_set_int_sprintf("Drive%dIdleMethod", (SHORT1FROMMP(mp1) & 0x3), drive + 8);
                    }
                    break;
               case CBS_IMAGE:
                   if (SHORT2FROMMP(mp1) == CBN_ENTER) {
                       char psz[CCHMAXPATH];

                       WinLboxQuerySelectedItemText(hwnd, CBS_IMAGE, psz, CCHMAXPATH);

                       if (!strlen(psz)) {
                           file_system_detach_disk(drive + 8);
                           return FALSE;
                       }

                       if (file_system_attach_disk(drive + 8, psz)) {
                           WinMessageBox(HWND_DESKTOP, hwnd, "Cannot attach specified file.", "VICE/2 Error", 0, MB_OK);
                       }
                   }
                   return FALSE;
                case CBS_PATH:
                    switch (SHORT2FROMMP(mp1)) {
                        case SPBN_CHANGE:
                            {
                                char path[255];

                                WinSendDlgMsg(hwnd, CBS_PATH, SPBM_QUERYVALUE, &path, 255);
                                if (!chdir(path)) {
                                    resources_set_string_sprintf("FSDevice%dDir", path, drive + 8);
                                }
                            }
                            break;
                        case SPBN_KILLFOCUS:
                            {
                                const char *path;

                                resources_get_string_sprintf("FSDevice%dDir", &path, drive + 8);
                                WinSendDlgMsg(hwnd, CBS_PATH, SPBM_SETARRAY, &path, 1);
                                WinSetDlgSpinVal(hwnd, CBS_PATH, 0);
                            }
                            break;
                    }
                    return FALSE;
                case CBS_TYPE:
                    if (SHORT2FROMMP(mp1) == CBN_ENTER && (drive == 0 || drive == 1)) {
                        const int nr  = WinQueryLboxSelectedItem((HWND)mp2);
                        const int val = WinLboxItemHandle((HWND)mp2, nr);

                        resources_set_int_sprintf("Drive%dType", val, drive + 8);
                    }
                    return FALSE;
            }
        }
        break;
    case WM_DRIVEIMAGE:
        {
            HWND ihwnd = WinWindowFromID(hwnd, CBS_IMAGE);
            const char *name = (char *)mp1;

            int pos;
            for (pos = 0; pos < 9; pos++) {
                WinDeleteLboxItem(ihwnd, 0);
            }

            pos = 0;
            while (pos < 10 && ui_status.imageHist[pos][0]) {
                WinLboxInsertItem(ihwnd, ui_status.imageHist[pos++]);
            }

            WinLboxInsertItem(ihwnd, "");

            if (drive == (int)mp2) {
                WinLboxSelectItem(ihwnd, name[0] ? 0 : pos);
            }
        }
        return FALSE;
    case WM_TRACK:
        if (!(ui_status.lastDriveState & (1 << (int)mp1))) {
            break;
        }

        WinSetDlgSpinVal(hwnd, SPB_TRACK8+(int)mp1, (int)((int)mp2 / 2));
        WinShowDlg(hwnd, SS_HALFTRACK8 + (int)mp1, ((int)mp2 % 2));
        break;
    case WM_DRIVELEDS:
        WinShowDlg(hwnd, SS_LED8+(int)mp1, (int)mp2);
        break;
    case WM_DRIVESTATE:
        WinShowDlg(hwnd, SPB_TRACK8, (int)mp1 & 1 == 1);
        WinShowDlg(hwnd, SS_HALFTRACK8, (int)mp1 & 1 == 1);
        WinShowDlg(hwnd, SPB_TRACK9, (int)mp1 & 2 == 1);
        WinShowDlg(hwnd, SS_HALFTRACK9, (int)mp1 & 2 == 1);
        WinShowDlg(hwnd, SS_LED8, 0);
        WinShowDlg(hwnd, SS_LED9, 0);
        break;
    case WM_SWITCH:
        drive = (int)mp1;
            {
                const HWND lbox = WinWindowFromID(hwnd, CBS_TYPE);
                int type = 0;
                int val;
                int res;
                int drive89 = (drive == 0 || drive == 1);

                resources_get_int("DriveTrueEmulation", &val);

                WinLboxEmpty(lbox);

                if (drive89) {
                    int i, nr;

                    WinCheckButton(hwnd, RB_NEVER | get_drive_res("Drive%dExtendImagePolicy", drive), 1);
                    WinCheckButton(hwnd, RB_NONE | get_drive_res("Drive%dIdleMethod", drive), 1);

                    nr = 0;
                    res = get_drive_res("Drive%dType", drive);
                    for (i = 0; i < nDRIVES; i++) {
                        if (!drive_check_type(driveRes[i], drive)) {
                            continue;
                        }

                        WinLboxInsertItem(lbox, driveName[i]);
                        WinLboxSetItemHandle(lbox, nr, driveRes[i]);

                        if (res == driveRes[i]) {
                            type = nr;
                        }

                        nr++;
                    }
                } else {
                    WinCheckButton(hwnd, RB_NEVER, 0);
                    WinCheckButton(hwnd, RB_ASK, 0);
                    WinCheckButton(hwnd, RB_ALWAYS, 0);
                    WinCheckButton(hwnd, RB_NONE, 0);
                    WinCheckButton(hwnd, RB_SKIP, 0);
                    WinCheckButton(hwnd, RB_TRAP, 0);
                }
                WinLboxSelectItem(lbox, type);

                WinCheckButton(hwnd, CB_PARALLEL, drive89 && get_drive_res("Drive%dParallelCable", drive) != 0);
                WinCheckButton(hwnd, CB_MEM2000, drive89 && get_drive_res("Drive%dRAM2000", drive) != 0);
                WinCheckButton(hwnd, CB_MEM4000, drive89 && get_drive_res("Drive%dRAM4000", drive) != 0);
                WinCheckButton(hwnd, CB_MEM6000, drive89 && get_drive_res("Drive%dRAM6000", drive) != 0);
                WinCheckButton(hwnd, CB_MEM8000, drive89 && get_drive_res("Drive%dRAM8000", drive) != 0);
                WinCheckButton(hwnd, CB_MEMA000, drive89 && get_drive_res("Drive%dRAMA000", drive) != 0);
                WinEnableControl(hwnd, CB_PARALLEL, drive89 && val);
                WinEnableControl(hwnd, RB_NEVER, drive89 && val);
                WinEnableControl(hwnd, RB_ASK, drive89 && val);
                WinEnableControl(hwnd, RB_ALWAYS, drive89 && val);
                WinEnableControl(hwnd, RB_NONE, drive89 && val);
                WinEnableControl(hwnd, RB_SKIP, drive89 && val);
                WinEnableControl(hwnd, RB_TRAP, drive89 && val);
                WinEnableControl(hwnd, CBS_TYPE, drive89 && val);
                WinEnableControl(hwnd, CB_MEM2000, drive89 && val);
                WinEnableControl(hwnd, CB_MEM4000, drive89 && val);
                WinEnableControl(hwnd, CB_MEM6000, drive89 && val);
                WinEnableControl(hwnd, CB_MEM8000, drive89 && val);
                WinEnableControl(hwnd, CB_MEMA000, drive89 && val);
                {
                    int acc  = get_drive_res("FileSystemDevice%d", drive) != 0;
                    int conv = get_drive_res("FSDevice%dConvertP00", drive) != 0;

                    if (!conv) {
                        resources_set_int_sprintf("FSDevice%dHideCBMFiles", 0, drive + 8);
                    }

                    WinCheckButton(hwnd, CB_ALLOWACCESS, acc);
                    WinCheckButton(hwnd, CB_CONVERTP00, conv);
                    WinCheckButton(hwnd, CB_SAVEP00, get_drive_res("FSDevice%dSaveP00", drive) != 0);
                    WinCheckButton(hwnd, CB_HIDENONP00, get_drive_res("FSDevice%dHideCBMFiles", drive) != 0);
                    WinEnableControl(hwnd, CB_ALLOWACCESS, !(drive89 && val));
                    WinEnableControl(hwnd, CB_SAVEP00, !(drive89 && val) && acc);
                    WinEnableControl(hwnd, CB_CONVERTP00, !(drive89 && val) && acc);
                    WinEnableControl(hwnd, CBS_PATH, !(drive89 && val) && acc);
                    WinEnableControl(hwnd, CB_HIDENONP00, !(drive89 && val) && acc && conv);

                    WinCheckButton(hwnd, CB_READONLY, get_drive_res("AttachDevice%dReadonly", drive) != 0);
                }
                {
                    char tmp[CCHMAXPATH];
                    int max = WinDlgLboxQueryCount(hwnd, CBS_IMAGE);
                    int pos = -1;

                    do {
                        WinLboxQueryItem(hwnd, CBS_IMAGE, ++pos, tmp, CCHMAXPATH);
                    }
                    while (pos < max && strcmp(ui_status.lastImage[drive], tmp));
                    WinDlgLboxSelectItem(hwnd, CBS_IMAGE, pos);
                }
                {
                    const char *path;
                    resources_get_string_sprintf("FSDevice%dDir", &path, drive + 8);
                    WinSendDlgMsg(hwnd, CBS_PATH, SPBM_SETARRAY, &path, 1);
                    WinSetDlgSpinVal(hwnd, CBS_PATH, 0);
                }
            }
            return FALSE;

    }
    return WinDefDlgProc (hwnd, msg, mp1, mp2);
}
Example #7
0
static UI_CALLBACK(attach_from_fliplist3)
{
    fliplist_attach_head(8, vice_ptr_to_int(UI_MENU_CB_PARAM));
}
Example #8
0
/* Dispatch all the pending keyboard commands.  */
void kbd_flush_commands(void)
{
    int i;

    if (num_queued_commands == 0) {
        return;
    }

    for (i = 0; i < num_queued_commands; i++) {
        switch (command_queue[i].type) {
            case KCMD_HARD_RESET:
                vsync_suspend_speed_eval();
                machine_trigger_reset(MACHINE_RESET_MODE_HARD);
                break;
            case KCMD_RESET:
                vsync_suspend_speed_eval();
                machine_trigger_reset(MACHINE_RESET_MODE_SOFT);
                break;
            case KCMD_RESTORE_PRESSED:
                machine_set_restore_key(1);
                break;
            case KCMD_RESTORE_RELEASED:
                machine_set_restore_key(0);
                break;
            case KCMD_FREEZE:
                if (freeze_function != NULL) {
                    freeze_function();
                }
                break;
            case KCMD_FLIP_NEXT:
                fliplist_attach_head(8, 1);
                break;
            case KCMD_FLIP_PREVIOUS:
                fliplist_attach_head(8, 0);
                break;
            case KCMD_FLIP_ADD:
                fliplist_add_image(8);
                break;
            case KCMD_FLIP_REMOVE:
                fliplist_remove(-1, NULL);
                break;
            case KCMD_TOGGLE_WARP:
                resources_toggle("WarpMode", NULL);
                break;
            case KCMD_MENU:
                interrupt_maincpu_trigger_trap(menu_trap, (void *)command_queue[i].data);
                break;
            case KCMD_TOGGLE_STATUSBAR:
                if (statusbar_enabled()) {
                    resources_set_int("ShowStatusbar", STATUSBAR_MODE_OFF);
                } else {
                    resources_set_int("ShowStatusbar", STATUSBAR_MODE_ON);
                }
                break;
            case KCMD_DATASETTE_START:
                datasette_control(DATASETTE_CONTROL_START);
                break;
            case KCMD_DATASETTE_STOP:
                datasette_control(DATASETTE_CONTROL_STOP);
                break;
            case KCMD_DATASETTE_FORWARD:
                datasette_control(DATASETTE_CONTROL_FORWARD);
                break;
            case KCMD_DATASETTE_REWIND:
                datasette_control(DATASETTE_CONTROL_REWIND);
                break;
            case KCMD_DATASETTE_RECORD:
                datasette_control(DATASETTE_CONTROL_RECORD);
                break;
            default:
                log_error(LOG_DEFAULT, "Unknown keyboard command %d.", (int)command_queue[i].type);
        }
    }
    num_queued_commands = 0;
}
Example #9
0
void ui_fliplist_prev_cb(GtkWidget *widget, gpointer data)
{
    int unit = GPOINTER_TO_INT(data);
    fliplist_attach_head(unit, 0);
}