Ejemplo n.º 1
0
static int set_ramsize(int size, void *param)
{
    int i;
    const int sizes[] = { 4, 8, 16, 32, 96, 128 };

    for (i = 0; i < util_arraysize(sizes); i++) {
        if (size <= sizes[i])
            break;
    }

    if (i > util_arraysize(sizes) - 1)
        i = util_arraysize(sizes) - 1;

    size = sizes[i];

    petres.ramSize = size;
    petres.map = 0;

    if (size == 96) {
        petres.map = PET_MAP_8096;         /* 8096 mapping */
    } else if (size == 128) {
        petres.map = PET_MAP_8296;         /* 8296 mapping */
    }

    petmem_check_info(&petres);
    mem_initialize_memory();

    return 0;
}
Ejemplo n.º 2
0
static void init_xv_settings(video_canvas_t *canvas)
{
    /* Find XVideo color setting limits. */
    if (canvas->videoconfig->hwscale && canvas->xv_image) {
        int i, j;
        int numattr = 0;
        Display *dpy = x11ui_get_display_ptr();
        XvAttribute *attr = XvQueryPortAttributes(dpy, canvas->xv_port, &numattr);

        xv_settings[0].value = &(canvas->videoconfig->video_resources.color_saturation);
        xv_settings[1].value = &(canvas->videoconfig->video_resources.color_contrast);
        xv_settings[2].value = &(canvas->videoconfig->video_resources.color_brightness);
        xv_settings[3].value = &(canvas->videoconfig->video_resources.color_gamma);

        for (i = 0; i < (int)util_arraysize(xv_settings); i++) {
            xv_settings[i].atom = 0;

            for (j = 0; j < numattr; j++) {
                if (!(attr[j].flags & XvSettable)) {
                    continue; /* useless, can't be set */
                }
                if (strcmp(xv_settings[i].name, attr[j].name) == 0) {
                    xv_settings[i].atom = XInternAtom(dpy, xv_settings[i].name, False);
                    xv_settings[i].min = attr[j].min_value;
                    xv_settings[i].max = attr[j].max_value;
                    if ((attr[j].flags & XvGettable) && !xv_settings[i].restore) {
                        xv_settings[i].restore = (XvGetPortAttribute(dpy, canvas->xv_port,
                                xv_settings[i].atom, &xv_settings[i].xv_default) == Success);
                        if (!xv_settings[i].restore) {
                            xv_settings[i].restore = 2;
                        }
                    }
                    break;
                }
            }
        }

        if (attr) {
            XFree(attr);
        }

        /* Apply color settings to XVideo. */
        video_canvas_set_palette(canvas, canvas->palette);
    }
}
Ejemplo n.º 3
0
static int fsimage_create_gcr(disk_image_t *image)
{
    BYTE gcr_header[12], gcr_track[7930], *gcrptr;
    DWORD gcr_track_p[MAX_TRACKS_1541 * 2];
    DWORD gcr_speed_p[MAX_TRACKS_1541 * 2];
    unsigned int track, sector;
    fsimage_t *fsimage;

    fsimage = image->media.fsimage;

    strcpy((char *)gcr_header, "GCR-1541");

    gcr_header[8] = 0;
    gcr_header[9] = MAX_TRACKS_1541 * 2;
    gcr_header[10] = 7928 % 256;
    gcr_header[11] = 7928 / 256;

    if (fwrite((char *)gcr_header, sizeof(gcr_header), 1, fsimage->fd) < 1) {
        log_error(createdisk_log, "Cannot write GCR header.");
        return -1;
    }

    for (track = 0; track < MAX_TRACKS_1541; track++) {
        gcr_track_p[track * 2] = 12 + MAX_TRACKS_1541 * 16 + track * 7930;
        gcr_track_p[track * 2 + 1] = 0;
        gcr_speed_p[track * 2] = disk_image_speed_map_1541(track);
        gcr_speed_p[track * 2 + 1] = 0;
    }

    if (util_dword_write(fsimage->fd, gcr_track_p, util_arraysize(gcr_track_p)) < 0) {
        log_error(createdisk_log, "Cannot write track header.");
        return -1;
    }
    if (util_dword_write(fsimage->fd, gcr_speed_p, util_arraysize(gcr_speed_p)) < 0) {
        log_error(createdisk_log, "Cannot write speed header.");
        return -1;
    }
    for (track = 0; track < MAX_TRACKS_1541; track++) {
        const int raw_track_size[4] = { 6250, 6666, 7142, 7692 };

        memset(&gcr_track[2], 0x55, 7928);
        gcr_track[0] = raw_track_size[disk_image_speed_map_1541(track)] % 256;
        gcr_track[1] = raw_track_size[disk_image_speed_map_1541(track)] / 256;
        gcrptr = &gcr_track[2];

        for (sector = 0;
        sector < disk_image_sector_per_track(DISK_IMAGE_TYPE_D64, track + 1);
        sector++) {
            BYTE chksum, id[2], rawdata[260];
            int i;

            id[0] = id[1] = 0xa0;
            memset(rawdata, 0, 260);
            rawdata[0] = 7;
            chksum = rawdata[1];
            for (i = 1; i < 256; i++)
                chksum ^= rawdata[i + 1];
            rawdata[257] = chksum;

            gcr_convert_sector_to_GCR(rawdata, gcrptr, track + 1, sector,
                                      id[0], id[1], 0);
            gcrptr += 360;
        }
        if (fwrite((char *)gcr_track, sizeof(gcr_track), 1, fsimage->fd) < 1 ) {
            log_error(createdisk_log, "Cannot write track data.");
            return -1;
        }
    }
    return 0;
}
Ejemplo n.º 4
0
void ui_create_status_bar(Widget pane, int width, Widget below, video_canvas_t *c, int app_shell)
{
    Widget notification_porthole;
    Widget speed_label, statustext_label;
    Widget notification_box;
    Widget drive_status[NUM_DRIVES];
    Widget drive_track_label[NUM_DRIVES], drive_led[NUM_DRIVES];
    Widget drive_led1[NUM_DRIVES], drive_led2[NUM_DRIVES];
    Widget tape_counter_label[NUM_TAPES];
    Widget tape_button_status[NUM_TAPES];
    Widget pal_ctrl_widget;
    char *button_title;
    int has_tape, notification_width;
    int i;

#define DD      2               /* default distance */
#define BW      1               /* border width */

    Dimension height;
    Dimension led_width = 14, led_height = 5;
    Dimension led_dist = 6;
    Widget fromvert;

    speed_label = XtVaCreateManagedWidget("speedStatus",
                                            labelWidgetClass, pane,
                                            XtNlabel, "",
                                            XtNwidth, width / 3,
                                            XtNborderWidth, 0,
                                            XtNtip, _("Emulation Speed Status"),
#if DEBUG_LAYOUT
                                            XtNbackground, "green",
#endif
                                            /* Constraints: */
                                            XtNfromVert, below,
                                            XtNtop, XawChainBottom,
                                            XtNbottom, XawChainBottom,
                                            XtNjustify, XtJustifyLeft,
                                            NULL);

    fromvert = speed_label;

    XtVaGetValues(speed_label, XtNheight, &height, NULL);

    if (machine_class != VICE_MACHINE_VSID) {
        Widget drivefromvert, drivefromhoriz;

        Arg args[] = {
            { XtNlabel, (XtArgVal)_("CRT Controls") },
            { XtNwidth, width / 3 - DD },
            { XtNheight, height },
            { XtNfromVert, (XtArgVal)fromvert },
            { XtNvertDistance, DD + 2*BW }, /* DD + missing borders of speed_label */
            { XtNtop, XawChainBottom },
            { XtNbottom, XawChainBottom },
        };
        pal_ctrl_widget = build_pal_ctrl_widget(c, pane,
                                    args, util_arraysize(args));

        fromvert = pal_ctrl_widget;
        drivefromvert = below;
        drivefromhoriz = speed_label;

        for (i = 0; i < NUM_DRIVES; i++) {
            char *name;
            Widget form;
            int status_width = (width / 3) - DD;
            int d = i ^ 1;

            name = lib_msprintf("driveStatus%d", d + 1);
            form =
            drive_status[d] = XtVaCreateManagedWidget(name,
                                formWidgetClass, pane,
                                XtNmappedWhenManaged, False,
                                XtNwidth, status_width,
                                XtNheight, height,
                                XtNborderWidth, 0,
                                /* Constraints: */
#if DEBUG_LAYOUT
                                XtNbackground, "yellow",
#endif
                                XtNdefaultDistance, 0,
                                XtNfromVert, drivefromvert,
                                XtNfromHoriz, drivefromhoriz,
                                XtNhorizDistance, DD,
                                XtNtop, XawChainBottom,
                                XtNbottom, XawChainBottom,
                                XtNleft, XawRubber,
                                XtNright, XawRubber,
                                NULL);
            lib_free(name);

            /* Position for the next Drive GUI element */
            if (i & 1) {
                drivefromhoriz = speed_label;
                drivefromvert = form;
            } else {
                drivefromhoriz = form;
            }

            name = lib_msprintf("driveTrack%d", d + 1);
            drive_track_label[d] = XtVaCreateManagedWidget(name,
                                commandWidgetClass, form,
                                XtNlabel, "",
                                XtNwidth, status_width - led_width - 2 * led_dist - DD,
                                /* Constraints: */
                                XtNhorizDistance, 0,
                                XtNvertDistance, 0,
                                XtNtop, XawChainBottom,
                                XtNbottom, XawChainBottom,
                                XtNleft, XawChainLeft,
                                XtNright, XawChainRight,
                                XtNjustify, XtJustifyRight,
                                NULL);
            lib_free(name);

            /* single LED */

            name = lib_msprintf("driveLed%d", d + 1);
            drive_led[d] = XtVaCreateManagedWidget(name,
                                xfwfcanvasWidgetClass, form,
                                XtNmappedWhenManaged, False,
                                XtNwidth, led_width,
                                XtNheight, led_height,
                                /* Constraints: */
                                XtNfromHoriz, drive_track_label[d],
                                XtNhorizDistance, led_dist,
                                XtNvertDistance, (height-led_height)/2 + BW,
                                XtNtop, XawChainBottom,
                                XtNbottom, XawChainBottom,
                                XtNleft, XawChainRight,
                                XtNright, XawChainRight,
                                XtNborderWidth, 0,
                                NULL);
            lib_free(name);

            /* double LEDs */

            name = lib_msprintf("driveLedA%d", d + 1);
            drive_led1[d] = XtVaCreateManagedWidget(name,
                                xfwfcanvasWidgetClass, form,
                                XtNmappedWhenManaged, False,
                                XtNwidth, led_width / 2 - BW,
                                XtNheight, led_height,
                                XtNborderWidth, BW,
                                /* Constraints: */
                                XtNfromHoriz, drive_track_label[d],
                                XtNhorizDistance, led_dist,
                                XtNvertDistance, (height-led_height)/2 + BW,
                                XtNtop, XawChainBottom,
                                XtNbottom, XawChainBottom,
                                XtNleft, XawChainRight,
                                XtNright, XawChainRight,
                                NULL);
            lib_free(name);

            name = lib_msprintf("driveLedB%d", d + 1);
            drive_led2[d] = XtVaCreateManagedWidget(name,
                                xfwfcanvasWidgetClass, form,
                                XtNmappedWhenManaged, False,
                                XtNwidth, led_width / 2 - BW,
                                XtNheight, led_height,
                                XtNborderWidth, BW,
                                /* Constraints: */
                                XtNfromHoriz, drive_led1[d],
                                XtNhorizDistance, led_dist,
                                XtNvertDistance, (height-led_height)/2 + BW,
                                XtNtop, XawChainBottom,
                                XtNbottom, XawChainBottom,
                                XtNleft, XawChainRight,
                                XtNright, XawChainRight,
                                NULL);
            lib_free(name);

            app_shells[app_shell].drive_widgets[d].track_label = drive_track_label[d];
            app_shells[app_shell].drive_widgets[d].driveled = drive_led[d];
            app_shells[app_shell].drive_widgets[d].driveled1 = drive_led1[d];
            app_shells[app_shell].drive_widgets[d].driveled2 = drive_led2[d];
            app_shells[app_shell].drive_widgets[d].status = drive_status[d];
            strcpy(&(last_attached_images[d][0]), "");
        }
    }

    /*
     * Pack the notification elements, which are sometimes turned on but
     * mostly turned off, into a horizontal Box, and manage/unmanage
     * them as needed. This will automatically re-layout them inside
     * the box.
     * Wrap the box in a Porthole widget to control the size of the
     * space that is used (clipping the stuff that doesn't fit).
     * Too bad there isn't just a single widget doing this. That would
     * make it easier to try to shrink the children when everything
     * doesn't fit, or automatically switch between a one-line and a
     * two-line statusbar, or something like that.
     */
    has_tape = machine_class != VICE_MACHINE_VSID &&
               machine_class != VICE_MACHINE_C64DTV &&
               machine_class != VICE_MACHINE_SCPU64;

    if (has_tape) {
        notification_width = 2 * width / 3 - DD; /* spans 2 columns */
    } else {
        notification_width = width;
    }

    notification_porthole = XtVaCreateManagedWidget("notificationPorthole",
                                            portholeWidgetClass, pane,
                                            XtNwidth, notification_width,
                                            XtNheight, height + 2 * BW,
                                            XtNborderWidth, 0,
                                            XtNorientation, XtorientHorizontal,
#if DEBUG_LAYOUT
                                            XtNbackground, "red1",
#endif
                                            /* Constraints: */
                                            XtNfromVert, drive_status[2],
                                            XtNtop, XawChainBottom,
                                            XtNbottom, XawChainBottom,
                                            XtNleft, XawChainLeft,
                                            XtNright, XawRubber,
                                            NULL);

    notification_box = XtVaCreateManagedWidget("notificationBox",
                                         boxWidgetClass, notification_porthole,
                                         XtNwidth, notification_width,
                                         XtNorientation, XtorientHorizontal,
                                         XtNborderWidth, 0,
                                         XtNvSpace, 0,
                                         XtNhSpace, DD,
#if DEBUG_LAYOUT
                                         XtNbackground, "pink1",
#endif
                                         NULL);

    statustext_label = XtVaCreateManagedWidget("statustext",
                                            labelWidgetClass, notification_box,
                                            XtNjustify, XtJustifyLeft,
                                            XtNlabel, "",
                                            XtNborderWidth, 0,
                                            NULL);

    button_title = util_concat(_("recording"), "...", NULL);
    rec_button = XtVaCreateManagedWidget("recButton",
                                          commandWidgetClass, notification_box,
                                          XtNtip, _("click to stop recording"),
                                          XtNjustify, XtJustifyLeft,
                                          XtNlabel, button_title,
                                          NULL);
    lib_free(button_title);

    XtAddCallback(rec_button, XtNcallback, rec_button_callback, NULL);

    button_title = util_concat(_("event recording"), "...", NULL);
    event_recording_button = XtVaCreateManagedWidget("eventRecButton",
                                        commandWidgetClass, notification_box,
                                        XtNtip, _("click to stop recording"),
                                        XtNjustify, XtJustifyLeft,
                                        XtNlabel, button_title,
                                        NULL);
    lib_free(button_title);
    XtAddCallback(event_recording_button, XtNcallback, event_recording_button_callback, NULL);

    button_title = util_concat(_("event playback"), "...", NULL);
    event_playback_button = XtVaCreateManagedWidget("eventPlayButton",
                                        commandWidgetClass, notification_box,
                                        XtNtip, _("click to stop playback"),
                                        XtNjustify, XtJustifyLeft,
                                        XtNlabel, button_title,
                                        NULL);
    lib_free(button_title);
    XtAddCallback(event_playback_button, XtNcallback, event_playback_button_callback, NULL);

    {
        Widget list[3];
        list[0] = rec_button;
        list[1] = event_recording_button;
        list[2] = event_playback_button;

#if !DEBUG_LAYOUT
        XtUnmanageChildren(list, util_arraysize(list));
#endif /* DEBUG_LAYOUT */
    }

    /* End of the notification_porthole */
    /* Start of TAPE #1 */

    if (has_tape) {
        Dimension tape_btn_d = 4;
        Dimension tape_btn_w = 24;

        for (i = 0; i < NUM_TAPES; i++) {
            char *name = lib_msprintf("tapeCounter%d", i + 1);
            tape_counter_label[i] = XtVaCreateManagedWidget(name,
                                            commandWidgetClass, pane,
                                            XtNwidth, width / 3 - DD - tape_btn_d - tape_btn_w - 4 * BW - DD, /* 4 borderwidths for 2 widgets */
                                            XtNjustify, XtJustifyRight,
                                            XtNlabel, "Tape #1",
                                            /* Constraints: */
                                            XtNfromVert, drive_status[3],
                                            XtNfromHoriz, drive_status[3],
                                            XtNtop, XawChainBottom,
                                            XtNbottom, XawChainBottom,
                                            XtNright, XawChainRight,
                                            NULL);
            lib_free(name);

            name = lib_msprintf("tapeButtons%d", i + 1);
            tape_button_status[i] = XtVaCreateManagedWidget(name,
                                            simpleWidgetClass, pane,
                                            XtNwidth, tape_btn_w,
                                            XtNheight, height,
                                            XtNjustify, XtJustifyLeft,
                                            /* Constraints: */
                                            XtNhorizDistance, tape_btn_d,
                                            XtNfromVert, drive_status[3],
                                            XtNfromHoriz, tape_counter_label[i],
                                            XtNtop, XawChainBottom,
                                            XtNbottom, XawChainBottom,
                                            XtNleft, XawChainRight,
                                            XtNright, XawChainRight,
                                            NULL);
            lib_free(name);

            app_shells[app_shell].tape_widgets[i].counter_value = -1;
            app_shells[app_shell].tape_widgets[i].counter_label = tape_counter_label[i];
            app_shells[app_shell].tape_widgets[i].button_status = tape_button_status[i];

            build_tape_status_widget(&app_shells[app_shell].tape_widgets[i], pane, tape_btn_w, height);
        }
    }

    app_shells[app_shell].speed_label = speed_label;
    app_shells[app_shell].statustext_label = statustext_label;
}