~ubuntu-branches/ubuntu/maverick/vice/maverick

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Zed Pobre
  • Date: 2005-02-01 11:30:26 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20050201113026-3eyakzsmmheclvjg
Tags: 1.16-1
* New upstream version
* Fixes crash on 64-bit architectures (closes: #287640)
* x128 working again (closes: #286767)
* Works fine with /dev/dsp in use (not in the main changelog, but tested
  on my local machine as working).  Presumably, this also takes care of
  the issue with dsp being held.  I'm not sure if this is because I'm
  testing it on a 2.6 kernel now -- if you are still having problems
  with /dev/dsp, please reopen the bugs. (closes: #152952, #207942)
* Don't kill Makefile.in on clean

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * uiromset.c
 
3
 *
 
4
 * Written by
 
5
 *  Andreas Boose <viceteam@t-online.de>
 
6
 *  Ettore Perazzoli <ettore@comm2000.it>
 
7
 *
 
8
 * This file is part of VICE, the Versatile Commodore Emulator.
 
9
 * See README for copyright notice.
 
10
 *
 
11
 *  This program is free software; you can redistribute it and/or modify
 
12
 *  it under the terms of the GNU General Public License as published by
 
13
 *  the Free Software Foundation; either version 2 of the License, or
 
14
 *  (at your option) any later version.
 
15
 *
 
16
 *  This program is distributed in the hope that it will be useful,
 
17
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
18
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
19
 *  GNU General Public License for more details.
 
20
 *
 
21
 *  You should have received a copy of the GNU General Public License
 
22
 *  along with this program; if not, write to the Free Software
 
23
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 
24
 *  02111-1307  USA.
 
25
 *
 
26
 */
 
27
 
 
28
#include "vice.h"
 
29
 
 
30
#include <stdio.h>
 
31
#include <string.h>
 
32
 
 
33
#include "lib.h"
 
34
#include "machine.h"
 
35
#include "resources.h"
 
36
#include "romset.h"
 
37
#include "uimenu.h"
 
38
#include "uiromset.h"
 
39
#include "util.h"
 
40
#include "vsync.h"
 
41
 
 
42
 
 
43
UI_CALLBACK(ui_set_romset)
 
44
{
 
45
    machine_romset_file_load(UI_MENU_CB_PARAM);
 
46
    ui_update_menus();
 
47
}
 
48
 
 
49
UI_CALLBACK(ui_load_rom_file)
 
50
{
 
51
    char *filename;
 
52
    ui_button_t button;
 
53
    static char *last_dir;
 
54
 
 
55
    vsync_suspend_speed_eval();
 
56
 
 
57
    filename = ui_select_file(_("Load ROM file"),
 
58
                              NULL, 0, False, last_dir, "*", &button,
 
59
                              False, NULL);
 
60
 
 
61
    switch (button) {
 
62
      case UI_BUTTON_OK:
 
63
        if (resources_set_value(UI_MENU_CB_PARAM,
 
64
            (resource_value_t)filename) < 0)
 
65
            ui_error(_("Could not load ROM file\n'%s'"), filename);
 
66
        if (last_dir)
 
67
            lib_free(last_dir);
 
68
        util_fname_split(filename, &last_dir, NULL);
 
69
        break;
 
70
      default:
 
71
        /* Do nothing special.  */
 
72
        break;
 
73
    }
 
74
    ui_update_menus();
 
75
    if (filename != NULL)
 
76
        lib_free(filename);
 
77
}
 
78
 
 
79
UI_CALLBACK(ui_unload_rom_file)
 
80
{
 
81
    resources_set_value((char*)UI_MENU_CB_PARAM, (resource_value_t)NULL);
 
82
}
 
83
 
 
84
UI_MENU_DEFINE_RADIO(RomsetSourceFile)
 
85
 
 
86
ui_menu_entry_t uiromset_type_submenu[] = {
 
87
    { "*Archive", (ui_callback_t)radio_RomsetSourceFile,
 
88
      (ui_callback_data_t)0, NULL },
 
89
    { "*File", (ui_callback_t)radio_RomsetSourceFile,
 
90
      (ui_callback_data_t)1, NULL },
 
91
    { NULL }
 
92
};
 
93
 
 
94
static UI_CALLBACK(uiromset_archive_load)
 
95
{
 
96
    char *filename;
 
97
    ui_button_t button;
 
98
    static char *last_dir;
 
99
 
 
100
    vsync_suspend_speed_eval();
 
101
 
 
102
    filename = ui_select_file(_("Load custom ROM set archive"),
 
103
                              NULL, 0, False, last_dir, "*.vra",
 
104
                              &button, False, NULL);
 
105
 
 
106
    switch (button) {
 
107
      case UI_BUTTON_OK:
 
108
        if (romset_archive_load(filename, 0) < 0)
 
109
            ui_error(_("Could not load ROM set archive\n'%s'"), filename);
 
110
        if (last_dir)
 
111
            lib_free(last_dir);
 
112
        util_fname_split(filename, &last_dir, NULL);
 
113
        break;
 
114
      default:
 
115
        /* Do nothing special.  */
 
116
        break;
 
117
    }
 
118
 
 
119
    ui_update_menus();
 
120
 
 
121
    if (filename != NULL)
 
122
        lib_free(filename);
 
123
}
 
124
 
 
125
static UI_CALLBACK(uiromset_archive_save)
 
126
{
 
127
    char *new_value;
 
128
    ui_button_t button;
 
129
    int len = 512;
 
130
 
 
131
    vsync_suspend_speed_eval();
 
132
 
 
133
    new_value = lib_malloc(len + 1);
 
134
    strcpy(new_value, "");
 
135
 
 
136
    button = ui_input_string(_("File to save ROM set archive to"),
 
137
                             _("ROM set archive:"), new_value, len);
 
138
 
 
139
    if (button == UI_BUTTON_OK)
 
140
        romset_archive_save(new_value);
 
141
 
 
142
    lib_free(new_value);
 
143
}
 
144
 
 
145
static UI_CALLBACK(uiromset_archive_list)
 
146
{
 
147
    char *list;
 
148
 
 
149
    list = romset_archive_list();
 
150
 
 
151
    ui_show_text(_("Current ROM set archive"), list, -1, -1);
 
152
 
 
153
    lib_free(list);
 
154
}
 
155
 
 
156
static UI_CALLBACK(uiromset_archive_item_create)
 
157
{
 
158
    char *new_value;
 
159
    ui_button_t button;
 
160
    int len = 512;
 
161
 
 
162
    vsync_suspend_speed_eval();
 
163
 
 
164
    new_value = lib_malloc(len + 1);
 
165
    strcpy(new_value, "");
 
166
 
 
167
    button = ui_input_string(_("ROM set item name to create"),
 
168
                             _("ROM set name:"), new_value, len);
 
169
 
 
170
    if (button == UI_BUTTON_OK)
 
171
        machine_romset_archive_item_create(new_value);
 
172
 
 
173
    lib_free(new_value);
 
174
}
 
175
 
 
176
static UI_CALLBACK(uiromset_archive_item_delete)
 
177
{
 
178
    static char input_string[32];
 
179
    ui_button_t button;
 
180
 
 
181
    if (!CHECK_MENUS) {
 
182
        vsync_suspend_speed_eval();
 
183
        button = ui_input_string(_("Delete configuration"), _("Enter name"),
 
184
                                 input_string, 32);
 
185
        if (button == UI_BUTTON_OK) {
 
186
            romset_archive_item_delete(input_string);
 
187
            ui_update_menus();
 
188
        }
 
189
    }
 
190
}
 
191
 
 
192
static UI_CALLBACK(uiromset_archive_item_select)
 
193
{
 
194
    static char input_string[32];
 
195
    ui_button_t button;
 
196
    char *active;
 
197
 
 
198
    if (!CHECK_MENUS) {
 
199
        resources_get_value("RomsetArchiveActive", (void *)&active);
 
200
 
 
201
        if (!*input_string)
 
202
            sprintf(input_string, "%s", active);
 
203
 
 
204
        vsync_suspend_speed_eval();
 
205
        button = ui_input_string(_("Active configuration"), _("Enter name"),
 
206
                                 input_string, 32);
 
207
        if (button == UI_BUTTON_OK) {
 
208
            resources_set_value("RomsetArchiveActive",
 
209
                                (resource_value_t)input_string);
 
210
            ui_update_menus();
 
211
        }
 
212
    }
 
213
}
 
214
 
 
215
ui_menu_entry_t uiromset_archive_submenu[] = {
 
216
    { N_("Load ROM set archive"),
 
217
      (ui_callback_t)uiromset_archive_load, NULL, NULL },
 
218
    { N_("Save ROM set archive"),
 
219
      (ui_callback_t)uiromset_archive_save, NULL, NULL },
 
220
    { N_("List current ROM set archive"),
 
221
      (ui_callback_t)uiromset_archive_list, NULL, NULL },
 
222
    { "--" },
 
223
    { N_("Create ROM set item"),
 
224
      (ui_callback_t)uiromset_archive_item_create, NULL, NULL },
 
225
    { N_("Delete ROM set item"),
 
226
      (ui_callback_t)uiromset_archive_item_delete, NULL, NULL },
 
227
    { N_("Select ROM set item"),
 
228
      (ui_callback_t)uiromset_archive_item_select, NULL, NULL },
 
229
    { NULL }
 
230
};
 
231
 
 
232
void uiromset_menu_init(void)
 
233
{
 
234
}
 
235
 
 
236
static UI_CALLBACK(uiromset_file_load)
 
237
{
 
238
    char *filename;
 
239
    ui_button_t button;
 
240
    static char *last_dir;
 
241
 
 
242
    vsync_suspend_speed_eval();
 
243
 
 
244
    filename = ui_select_file(_("Load custom ROM set file"),
 
245
                              NULL, 0, False, last_dir, "*.vrs",
 
246
                              &button, False, NULL);
 
247
 
 
248
    switch (button) {
 
249
      case UI_BUTTON_OK:
 
250
        if (machine_romset_file_load(filename) < 0)
 
251
            ui_error(_("Could not load ROM set file\n'%s'"), filename);
 
252
        if (last_dir)
 
253
            lib_free(last_dir);
 
254
        util_fname_split(filename, &last_dir, NULL);
 
255
        break;
 
256
      default:
 
257
        /* Do nothing special.  */
 
258
        break;
 
259
    }
 
260
 
 
261
    ui_update_menus();
 
262
 
 
263
    if (filename != NULL)
 
264
        lib_free(filename);
 
265
}
 
266
 
 
267
static UI_CALLBACK(uiromset_file_save)
 
268
{
 
269
    char *new_value;
 
270
    ui_button_t button;
 
271
    int len = 512;
 
272
 
 
273
    vsync_suspend_speed_eval();
 
274
 
 
275
    new_value = lib_malloc(len + 1);
 
276
    strcpy(new_value, "");
 
277
 
 
278
    button = ui_input_string(_("File to save ROM set definition to"),
 
279
                             _("ROM set file:"), new_value, len);
 
280
 
 
281
    if (button == UI_BUTTON_OK)
 
282
        machine_romset_file_save(new_value);
 
283
 
 
284
    lib_free(new_value);
 
285
}
 
286
 
 
287
static UI_CALLBACK(uiromset_file_list)
 
288
{
 
289
    char *list;
 
290
 
 
291
    list = machine_romset_file_list();
 
292
 
 
293
    ui_show_text(_("Current ROM set"), list, -1, -1);
 
294
 
 
295
    lib_free(list);
 
296
}
 
297
 
 
298
ui_menu_entry_t uiromset_file_submenu[] = {
 
299
    { N_("Load custom ROM set from file"),
 
300
      (ui_callback_t)uiromset_file_load, NULL, NULL },
 
301
    { N_("Dump ROM set definition to file"),
 
302
      (ui_callback_t)uiromset_file_save, NULL, NULL },
 
303
    { N_("List current ROM set"),
 
304
      (ui_callback_t)uiromset_file_list, NULL, NULL },
 
305
    { NULL }
 
306
};
 
307