~ubuntu-branches/ubuntu/quantal/vice/quantal

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Zed Pobre
  • Date: 2005-03-27 13:06:04 UTC
  • mfrom: (4 hoary)
  • mto: This revision was merged to the branch mainline in revision 5.
  • Revision ID: james.westby@ubuntu.com-20050327130604-zodmv0i60dbbmcik
Tags: 1.16-3
Apply patch from Andreas Jochens <aj@andaco.de> to correct building on
AMD64 and GCC 4.x (closes: #300936)

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 *
4
4
 * Written by
5
5
 *  Ettore Perazzoli <ettore@comm2000.it>
 
6
 *  Andreas Boose <viceteam@t-online.de>
6
7
 *
7
8
 * This file is part of VICE, the Versatile Commodore Emulator.
8
9
 * See README for copyright notice.
28
29
 
29
30
#include <stdio.h>
30
31
#include <stdlib.h>
31
 
#include <unistd.h>
 
32
#include <string.h>
32
33
 
33
34
#include "cartridge.h"
34
 
#include "drive.h"
 
35
#include "debug.h"
35
36
#include "icon.h"
36
 
#include "joystick.h"
 
37
#include "joy.h"
 
38
#include "lib.h"
 
39
#include "machine-video.h"
37
40
#include "resources.h"
 
41
#include "uiattach.h"
38
42
#include "uicommands.h"
39
43
#include "uidatasette.h"
40
44
#include "uidrive.h"
41
 
#include "uipalette.h"
42
 
#include "uiperipheral.h"
 
45
#include "uidrivec64vic20.h"
 
46
#include "uikeyboard.h"
43
47
#include "uimenu.h"
 
48
#include "uiperipheraliec.h"
 
49
#include "uiromset.h"
44
50
#include "uirs232.h"
 
51
#include "uirs232user.h"
45
52
#include "uiscreenshot.h"
46
53
#include "uisettings.h"
47
54
#include "uisound.h"
48
 
#include "utils.h"
 
55
#include "uivic.h"
 
56
#include "util.h"
49
57
#include "vsync.h"
50
58
 
51
59
 
52
 
/* ------------------------------------------------------------------------- */
53
 
 
54
60
enum {
55
61
    MEM_NONE,
56
62
    MEM_ALL,
110
116
    vsync_suspend_speed_eval();
111
117
}
112
118
 
113
 
static ui_menu_entry_t vic20_romset_submenu[] = {
114
 
    { N_("Load default ROMs"),
115
 
      (ui_callback_t)ui_set_romset, (ui_callback_data_t)"default.vrs", NULL },
116
 
    { "--" },
 
119
static ui_menu_entry_t vic20ui_main_romset_submenu[] = {
117
120
    { N_("Load new Kernal ROM"),
118
121
      (ui_callback_t)ui_load_rom_file,
119
122
      (ui_callback_data_t)"KernalName", NULL },
123
126
    { N_("Load new Character ROM"),
124
127
      (ui_callback_t)ui_load_rom_file,
125
128
      (ui_callback_data_t)"ChargenName", NULL },
126
 
    { "--" },
127
 
    { N_("Load custom ROM set from file"),
128
 
      (ui_callback_t)ui_load_romset, NULL, NULL },
129
 
    { N_("Dump ROM set definition to file"),
130
 
      (ui_callback_t)ui_dump_romset, NULL, NULL },
 
129
    { NULL }
 
130
};
 
131
 
 
132
static ui_menu_entry_t vic20_romset_submenu[] = {
 
133
    { N_("Load default ROMs"),
 
134
      (ui_callback_t)ui_set_romset, (ui_callback_data_t)"default.vrs", NULL },
 
135
    { "--" },
 
136
    { N_("Load new computer ROM"),
 
137
      NULL, NULL, vic20ui_main_romset_submenu },
 
138
    { N_("Load new drive ROM"),
 
139
      NULL, NULL, ui_drivec64vic20_romset_submenu },
 
140
    { "--" },
 
141
    { N_("ROM set type"),
 
142
      NULL, NULL, uiromset_type_submenu },
 
143
    { "--" },
 
144
    { N_("ROM set archive"),
 
145
      NULL, NULL, uiromset_archive_submenu },
 
146
    { N_("ROM set file"),
 
147
      NULL, NULL, uiromset_file_submenu },
131
148
    { NULL }
132
149
};
133
150
 
180
197
    { NULL }
181
198
};
182
199
 
 
200
#if 0
183
201
static ui_menu_entry_t memory_settings_menu[] = {
184
202
    { N_("Memory expansions"),
185
203
      NULL, NULL, memory_settings_submenu },
186
204
    { NULL }
187
205
};
188
 
 
 
206
#endif
189
207
 
190
208
/* ------------------------------------------------------------------------- */
191
209
 
198
216
 
199
217
    vsync_suspend_speed_eval();
200
218
    filename = ui_select_file(_("Attach cartridge image"),
201
 
                              NULL, False, last_dir, "*.prg", &button, False,
202
 
                              NULL);
 
219
                              NULL, 0, False, last_dir, "*.prg", &button,
 
220
                              False, NULL);
203
221
    switch (button) {
204
222
      case UI_BUTTON_OK:
205
223
        if (cartridge_attach_image(type, filename) < 0)
206
224
            ui_error(_("Invalid cartridge image"));
207
225
        if (last_dir)
208
 
            free(last_dir);
 
226
            lib_free(last_dir);
209
227
        util_fname_split(filename, &last_dir, NULL);
210
228
        ui_update_menus();
211
229
        break;
214
232
        break;
215
233
    }
216
234
    if (filename != NULL)
217
 
        free(filename);
 
235
        lib_free(filename);
218
236
}
219
237
 
220
238
static UI_CALLBACK(detach_cartridge)
274
292
    } else {
275
293
        int tmp;
276
294
 
277
 
        resources_get_value("JoyDevice1", (resource_value_t *)&tmp);
 
295
        resources_get_value("JoyDevice1", (void *)&tmp);
278
296
        ui_menu_set_tick(w, tmp == (int)UI_MENU_CB_PARAM);
279
297
    }
280
298
}
304
322
      (ui_callback_t)set_joystick_device,
305
323
      (ui_callback_data_t)JOYDEV_DIGITAL_1, NULL },
306
324
#endif
 
325
#ifdef HAS_USB_JOYSTICK
 
326
    { N_("*USB Joystick 0"),
 
327
      (ui_callback_t)set_joystick_device,
 
328
      (ui_callback_data_t)JOYDEV_USB_0, NULL },
 
329
    { N_("*USB Joystick 1"),
 
330
      (ui_callback_t)set_joystick_device,
 
331
      (ui_callback_data_t)JOYDEV_USB_1, NULL },
 
332
#endif
307
333
#endif
308
334
    { NULL }
309
335
};
316
342
 
317
343
/*------------------------------------------------------------*/
318
344
 
319
 
UI_MENU_DEFINE_RADIO(RsUser)
 
345
UI_MENU_DEFINE_TOGGLE(RsUserEnable)
320
346
 
321
347
static ui_menu_entry_t vic20_rs232_submenu[] = {
322
 
    { N_("*No Userport RS232 emulation"),
323
 
      (ui_callback_t)radio_RsUser, (ui_callback_data_t)0, NULL },
324
 
    { N_("*Userport 300 baud RS232 emulation"),
325
 
      (ui_callback_t)radio_RsUser, (ui_callback_data_t)300, NULL },
326
 
    { N_("*Userport 1200 baud RS232 emulation"),
327
 
      (ui_callback_t)radio_RsUser, (ui_callback_data_t)1200, NULL },
 
348
    { N_("*Userport RS232 emulation"),
 
349
      (ui_callback_t)toggle_RsUserEnable, NULL, NULL },
 
350
    { N_("Userport RS232 baud rate"),
 
351
      NULL, NULL, rs232user_baudrate_submenu },
328
352
    { N_("Userport RS232 device"),
329
 
      NULL, NULL, rsuser_device_submenu },
 
353
      NULL, NULL, rs232user_device_submenu },
330
354
    { "--" },
331
355
    { N_("Serial 1 device..."), (ui_callback_t)set_rs232_device_file,
332
356
      (ui_callback_data_t)"RsDevice1", NULL },
354
378
 
355
379
/*------------------------------------------------------------*/
356
380
 
 
381
/*
357
382
UI_MENU_DEFINE_TOGGLE(IEEE488)
358
383
 
359
 
/*
360
384
static ui_menu_entry_t vic20_io_submenu[] = {
361
385
    { "*VIC-1112 IEEE 488 module",
362
386
      (ui_callback_t)toggle_IEEE488, NULL, NULL },
376
400
{
377
401
    /* Where does the 1024 come from?  */
378
402
    char filename[1024];
379
 
    int wid = (int)UI_MENU_CB_PARAM;
 
403
    unsigned int wid = (unsigned int)UI_MENU_CB_PARAM;
380
404
 
381
405
    vsync_suspend_speed_eval();
382
406
 
383
407
    /* The following code depends on a zeroed filename.  */
384
408
    memset(filename, 0, 1024);
385
409
 
386
 
    if (ui_screenshot_dialog(filename, wid) < 0)
 
410
    if (ui_screenshot_dialog(filename, machine_video_canvas_get(wid)) < 0)
387
411
        return;
388
412
}
389
413
 
393
417
    { NULL }
394
418
};
395
419
 
396
 
/* ------------------------------------------------------------------------- */
397
 
 
398
 
UI_MENU_DEFINE_RADIO(VideoStandard)
399
 
 
400
 
static ui_menu_entry_t set_video_standard_submenu[] = {
401
 
    { N_("*PAL-G"), (ui_callback_t)radio_VideoStandard,
402
 
      (ui_callback_data_t)DRIVE_SYNC_PAL, NULL },
403
 
    { N_("*NTSC-M"), (ui_callback_t)radio_VideoStandard,
404
 
      (ui_callback_data_t)DRIVE_SYNC_NTSC, NULL },
405
 
    { NULL }
406
 
};
407
 
 
408
 
UI_MENU_DEFINE_STRING_RADIO(PaletteFile)
409
 
 
410
 
static ui_menu_entry_t palette_submenu[] = {
411
 
    { N_("*Default"),
412
 
      (ui_callback_t)radio_PaletteFile, (ui_callback_data_t)"default", NULL },
413
 
    { N_("Load custom"),
414
 
      (ui_callback_t)ui_load_palette,
415
 
      (ui_callback_data_t)"PaletteFile", NULL },
416
 
    { NULL }
417
 
};
418
 
 
419
 
static ui_menu_entry_t vic_submenu[] = {
420
 
    { N_("Video standard"),
421
 
      NULL, NULL, set_video_standard_submenu },
422
 
    { "--" },
423
 
    { N_("Color set"),
424
 
      NULL, NULL, palette_submenu },
425
 
    { NULL }
426
 
};
427
 
 
428
420
static ui_menu_entry_t vic20_menu[] = {
429
421
    { N_("VIC settings"),
430
422
      NULL, NULL, vic_submenu },
433
425
    { NULL }
434
426
};
435
427
 
436
 
/* ------------------------------------------------------------------------- */
437
 
 
438
 
int vic20_ui_init(void)
 
428
static void vic20ui_dynamic_menu_create(void)
 
429
{
 
430
    uivic_menu_create();
 
431
}
 
432
 
 
433
static void vic20ui_dynamic_menu_shutdown(void)
 
434
{
 
435
    uivic_menu_shutdown();
 
436
}
 
437
 
 
438
int vic20ui_init(void)
439
439
{
440
440
    ui_set_application_icon(vic20_icon_data);
 
441
    vic20ui_dynamic_menu_create();
441
442
    ui_set_left_menu(ui_menu_create("LeftMenu",
442
 
                                    ui_disk_commands_menu,
 
443
                                    uiattach_disk_menu,
443
444
                                    ui_menu_separator,
444
 
                                    ui_tape_commands_menu,
 
445
                                    uiattach_tape_menu,
445
446
                                    ui_datasette_commands_menu,
446
447
                                    ui_menu_separator,
447
 
                                    ui_smart_attach_commands_menu,
 
448
                                    uiattach_smart_attach_menu,
448
449
                                    ui_menu_separator,
449
450
                                    vic20_cartridge_commands_menu,
450
451
                                    ui_menu_separator,
452
453
                                    ui_menu_separator,
453
454
                                    ui_snapshot_commands_menu,
454
455
                                    ui_screenshot_commands_menu,
 
456
                                    ui_sound_record_commands_menu,
455
457
                                    ui_menu_separator,
456
458
                                    ui_tool_commands_menu,
457
459
                                    ui_menu_separator,
465
467
    ui_set_right_menu(ui_menu_create("RightMenu",
466
468
                                     ui_performance_settings_menu,
467
469
                                     ui_menu_separator,
468
 
                                     ui_vic_video_settings_menu,
469
 
#ifdef USE_XF86_EXTENSIONS
470
 
                                     ui_fullscreen_settings_menu,
471
 
#endif
472
 
                                     ui_keyboard_settings_menu,
 
470
                                     uikeyboard_settings_menu,
473
471
                                     ui_sound_settings_menu,
474
 
                                     ui_drive_settings_menu,
475
 
                                     ui_peripheral_settings_menu,
 
472
                                     ui_drivec64vic20_settings_menu,
 
473
                                     ui_peripheraliec_settings_menu,
476
474
/*
477
475
                                     vic20_io_settings_menu,
478
476
*/
482
480
                                     vic20_menu,
483
481
                                     ui_menu_separator,
484
482
                                     ui_settings_settings_menu,
 
483
#ifdef DEBUG
 
484
                                     ui_menu_separator,
 
485
                                     ui_debug_settings_menu,
 
486
#endif
485
487
                                     NULL));
486
488
 
487
489
    ui_set_tape_menu(ui_menu_create("TapeMenu",
488
 
                                    ui_tape_commands_menu,
 
490
                                    uiattach_tape_menu,
489
491
                                    ui_menu_separator,
490
492
                                    datasette_control_submenu,
491
493
                                    NULL));
492
494
    ui_set_topmenu("TopLevelMenu",
493
495
                   _("File"),
494
496
                   ui_menu_create("File",
495
 
                                  ui_smart_attach_commands_menu,
496
 
                                  ui_menu_separator,
497
 
                                  ui_disk_commands_menu,
498
 
                                  ui_menu_separator,
499
 
                                  ui_tape_commands_menu,
 
497
                                  uiattach_smart_attach_menu,
 
498
                                  ui_menu_separator,
 
499
                                  uiattach_disk_menu,
 
500
                                  ui_menu_separator,
 
501
                                  uiattach_tape_menu,
500
502
                                  ui_datasette_commands_menu,
501
503
                                  ui_menu_separator,
502
504
                                  vic20_cartridge_commands_menu,
514
516
                                  ui_snapshot_commands_submenu,
515
517
                                  ui_menu_separator,
516
518
                                  ui_screenshot_commands_menu,
 
519
                                  ui_sound_record_commands_menu,
517
520
                                  NULL),
518
521
                   _("Options"),
519
522
                   ui_menu_create("Options",
520
523
                                  ui_performance_settings_menu,
521
524
                                  ui_menu_separator,
522
 
#ifdef USE_XF86_EXTENSIONS
523
 
                                  ui_fullscreen_settings_menu,
524
 
                                  ui_menu_separator,
525
 
#endif
526
525
                                  ui_drive_options_submenu,
527
526
                                  NULL),
528
527
                   _("Settings"),
529
528
                   ui_menu_create("Settings",
530
 
                                  ui_vic_video_settings_menu,
531
 
                                  ui_peripheral_settings_menu,
532
 
                                  ui_drive_settings_menu,
533
 
                                  ui_keyboard_settings_menu,
 
529
                                  uikeyboard_settings_menu,
 
530
                                  ui_sound_settings_menu,
 
531
                                  ui_drivec64vic20_settings_menu,
 
532
                                  ui_peripheraliec_settings_menu,
534
533
                                  joystick_settings_menu,
535
 
                                  ui_sound_settings_menu,
536
 
                                  ui_menu_separator,
537
534
                                  rs232_settings_menu,
538
535
                                  ui_menu_separator,
539
 
                                  memory_settings_menu,
 
536
                                  vic20_menu,
540
537
                                  ui_menu_separator,
541
538
                                  ui_settings_settings_menu,
542
539
                                  NULL),
555
552
    return 0;
556
553
}
557
554
 
 
555
void vic20ui_shutdown(void)
 
556
{
 
557
    vic20ui_dynamic_menu_shutdown();
 
558
}
 
559