~ubuntu-branches/ubuntu/raring/vice/raring

« back to all changes in this revision

Viewing changes to src/arch/unix/uiide64.c

  • Committer: Bazaar Package Importer
  • Author(s): Zed Pobre
  • Date: 2005-02-01 11:30:26 UTC
  • mto: (9.1.1 lenny) (1.1.6 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20050201113026-6gy97mcqlg2ykg4z
Tags: upstream-1.16
ImportĀ upstreamĀ versionĀ 1.16

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * uiide64.c
 
3
 *
 
4
 * Written by
 
5
 *  Andreas Boose <viceteam@t-online.de>
 
6
 *
 
7
 * This file is part of VICE, the Versatile Commodore Emulator.
 
8
 * See README for copyright notice.
 
9
 *
 
10
 *  This program is free software; you can redistribute it and/or modify
 
11
 *  it under the terms of the GNU General Public License as published by
 
12
 *  the Free Software Foundation; either version 2 of the License, or
 
13
 *  (at your option) any later version.
 
14
 *
 
15
 *  This program is distributed in the hope that it will be useful,
 
16
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
17
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
18
 *  GNU General Public License for more details.
 
19
 *
 
20
 *  You should have received a copy of the GNU General Public License
 
21
 *  along with this program; if not, write to the Free Software
 
22
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 
23
 *  02111-1307  USA.
 
24
 *
 
25
 */
 
26
 
 
27
#include "vice.h"
 
28
 
 
29
#include <stdio.h>
 
30
#include <stdlib.h>
 
31
 
 
32
#include "lib.h"
 
33
#include "resources.h"
 
34
#include "uiide64.h"
 
35
#include "uilib.h"
 
36
#include "uimenu.h"
 
37
#include "vsync.h"
 
38
 
 
39
 
 
40
UI_CALLBACK(set_ide64_image_name)
 
41
{
 
42
    uilib_select_string((char *)UI_MENU_CB_PARAM, _("IDE64 image name"),
 
43
                        _("Name:"));
 
44
}
 
45
 
 
46
UI_MENU_DEFINE_TOGGLE(IDE64AutodetectSize)
 
47
 
 
48
static UI_CALLBACK(set_cylinders)
 
49
{
 
50
    static char input_string[32];
 
51
 
 
52
    if (CHECK_MENUS) {
 
53
        int autosize;
 
54
 
 
55
        resources_get_value("IDE64AutodetectSize", (void *)&autosize);
 
56
 
 
57
        if (autosize)
 
58
            ui_menu_set_sensitive(w, False);
 
59
        else
 
60
            ui_menu_set_sensitive(w, True);
 
61
    } else {
 
62
        char *msg_string;
 
63
        ui_button_t button;
 
64
        int i;
 
65
        int cylinders;
 
66
 
 
67
        vsync_suspend_speed_eval();
 
68
 
 
69
        resources_get_value("IDE64Cylinders", (void *)&cylinders);
 
70
 
 
71
        sprintf(input_string, "%d", cylinders);
 
72
 
 
73
        msg_string = lib_stralloc(_("Enter number of cylinders"));
 
74
        button = ui_input_string(_("IDE64 cylinders"), msg_string, input_string,
 
75
                                 32);
 
76
        lib_free(msg_string);
 
77
        if (button == UI_BUTTON_OK) {
 
78
            i = atoi(input_string);
 
79
            if (cylinders > 0 && cylinders <= 1024 && cylinders != i) {
 
80
                resources_set_value("IDE64Cylinders", (resource_value_t)i);
 
81
                ui_update_menus();
 
82
            }
 
83
        }
 
84
    }
 
85
}
 
86
 
 
87
static UI_CALLBACK(set_heads)
 
88
{
 
89
    static char input_string[32];
 
90
 
 
91
    if (CHECK_MENUS) {
 
92
        int autosize;
 
93
 
 
94
        resources_get_value("IDE64AutodetectSize", (void *)&autosize);
 
95
 
 
96
        if (autosize)
 
97
            ui_menu_set_sensitive(w, False);
 
98
        else
 
99
            ui_menu_set_sensitive(w, True);
 
100
    } else {
 
101
        char *msg_string;
 
102
        ui_button_t button;
 
103
        int i;
 
104
        int heads;
 
105
 
 
106
        vsync_suspend_speed_eval();
 
107
 
 
108
        resources_get_value("IDE64Heads", (void *)&heads);
 
109
 
 
110
        sprintf(input_string, "%d", heads);
 
111
 
 
112
        msg_string = lib_stralloc(_("Enter number of heads"));
 
113
        button = ui_input_string(_("IDE64 heads"), msg_string, input_string,
 
114
                                 32);
 
115
        lib_free(msg_string);
 
116
        if (button == UI_BUTTON_OK) {
 
117
            i = atoi(input_string);
 
118
            if (heads > 0 && heads <= 16 && heads != i) {
 
119
                resources_set_value("IDE64Heads", (resource_value_t)i);
 
120
                ui_update_menus();
 
121
            }
 
122
        }
 
123
    }
 
124
}
 
125
 
 
126
static UI_CALLBACK(set_sectors)
 
127
{
 
128
    static char input_string[32];
 
129
 
 
130
    if (CHECK_MENUS) {
 
131
        int autosize;
 
132
 
 
133
        resources_get_value("IDE64AutodetectSize", (void *)&autosize);
 
134
 
 
135
        if (autosize)
 
136
            ui_menu_set_sensitive(w, False);
 
137
        else
 
138
            ui_menu_set_sensitive(w, True);
 
139
    } else {
 
140
        char *msg_string;
 
141
        ui_button_t button;
 
142
        int i;
 
143
        int sectors;
 
144
 
 
145
        vsync_suspend_speed_eval();
 
146
 
 
147
        resources_get_value("IDE64Sectors", (void *)&sectors);
 
148
 
 
149
        sprintf(input_string, "%d", sectors);
 
150
 
 
151
        msg_string = lib_stralloc(_("Enter number of sectors"));
 
152
        button = ui_input_string(_("IDE64 sectors"), msg_string, input_string,
 
153
                                 32);
 
154
        lib_free(msg_string);
 
155
        if (button == UI_BUTTON_OK) {
 
156
            i = atoi(input_string);
 
157
            if (sectors >= 0 && sectors <= 63 && sectors != i) {
 
158
                resources_set_value("IDE64Sectors", (resource_value_t)i);
 
159
                ui_update_menus();
 
160
            }
 
161
        }
 
162
    }
 
163
}
 
164
 
 
165
ui_menu_entry_t ide64_submenu[] = {
 
166
    { N_("IDE64 image name..."),
 
167
      (ui_callback_t)set_ide64_image_name,
 
168
      (ui_callback_data_t)"IDE64Image", NULL },
 
169
    { N_("*Autodetect image size"),
 
170
      (ui_callback_t)toggle_IDE64AutodetectSize, NULL, NULL },
 
171
    { N_("*Cylinders..."),
 
172
      (ui_callback_t)set_cylinders, NULL, NULL },
 
173
    { N_("*Heads..."),
 
174
      (ui_callback_t)set_heads, NULL, NULL },
 
175
    { N_("*Sectors..."),
 
176
      (ui_callback_t)set_sectors, NULL, NULL },
 
177
    { NULL }
 
178
};
 
179