1 /** \file cbm5x0ui.c
2 * \brief Native GTK3 CBM5x0 UI
3 *
4 * \author Marco van den Heuvel <blackystardust68@yahoo.com>
5 * \author Bas Wassink <b.wassink@ziggo.nl>
6 */
7
8 /*
9 * This file is part of VICE, the Versatile Commodore Emulator.
10 * See README for copyright notice.
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
25 * 02111-1307 USA.
26 *
27 */
28
29 #include "vice.h"
30
31 #include <stdio.h>
32
33 #include "debug_gtk3.h"
34 #include "cbm2model.h"
35 #include "cartridge.h"
36 #include "carthelpers.h"
37 #include "crtcontrolwidget.h"
38 #include "machine.h"
39 #include "machinemodelwidget.h"
40 #include "sampler.h"
41 #include "ui.h"
42 #include "uicart.h"
43 #include "uimachinewindow.h"
44 #include "settings_sampler.h"
45 #include "vicii.h"
46 #include "videomodelwidget.h"
47 #include "widgethelpers.h"
48 #include "settings_model.h"
49
50 #include "cbm2ui.h"
51
52
53 /** \brief List of CBM-II models
54 *
55 * Used in the machine-model widget. Only 5x0 models are supported by xcbm5x0.
56 */
57 static const char *cbm5x0_model_list[] = {
58 "CBM 510 PAL", "CBM 510 NTSC", NULL
59 };
60
61
62 /** \brief List of VIC-II models
63 *
64 * Used in the VIC-II model widget
65 */
66 static const vice_gtk3_radiogroup_entry_t cbm5x0_vicii_models[] = {
67 { "PAL", MACHINE_SYNC_PAL },
68 { "NTSC", MACHINE_SYNC_NTSC },
69 { NULL, -1 }
70 };
71
72
73 /** \brief Identify the canvas used to create a window
74 *
75 * \param[in] canvas video canvas
76 *
77 * \return window index on success, -1 on failure
78 */
identify_canvas(video_canvas_t * canvas)79 static int identify_canvas(video_canvas_t *canvas)
80 {
81 if (canvas != vicii_get_canvas()) {
82 return -1;
83 }
84
85 return PRIMARY_WINDOW;
86 }
87
88
89 /** \brief Create CRT controls widget for \a target window
90 *
91 * \param[in] target_window target window index
92 *
93 * \return GtkGrid
94 */
create_crt_widget(int target_window)95 static GtkWidget *create_crt_widget(int target_window)
96 {
97 return crt_control_widget_create(NULL, "VICII", TRUE);
98 }
99
100 /** \brief Pre-initialize the UI before the canvas window gets created
101 *
102 * \return 0 on success, -1 on failure
103 */
cbm5x0ui_init_early(void)104 int cbm5x0ui_init_early(void)
105 {
106 ui_machine_window_init();
107 ui_set_identify_canvas_func(identify_canvas);
108 ui_set_create_controls_widget_func(create_crt_widget);
109 return 0;
110 }
111
112
113 /** \brief Initialize the UI
114 *
115 * \return 0 on success, -1 on failure
116 */
cbm5x0ui_init(void)117 int cbm5x0ui_init(void)
118 {
119 machine_model_widget_getter(cbm2model_get);
120 machine_model_widget_setter(cbm2model_set);
121 machine_model_widget_set_models(cbm5x0_model_list);
122
123 video_model_widget_set_title("VIC-II model");
124 video_model_widget_set_resource("MachineVideoStandard");
125 video_model_widget_set_models(cbm5x0_vicii_models);
126
127 settings_sampler_set_devices_getter(sampler_get_devices);
128
129 /* uicart_set_detect_func(cartridge_detect); only cbm2/plus4 */
130 /*uicart_set_list_func(cartridge_get_info_list);*/
131 uicart_set_attach_func(cartridge_attach_image);
132 /*uicart_set_freeze_func(cartridge_trigger_freeze);*/
133 uicart_set_detach_func(cartridge_detach_image);
134
135 settings_model_widget_set_model_func(cbm2model_get);
136 return 0;
137 }
138
139
140 /** \brief Shut down the UI
141 */
cbm5x0ui_shutdown(void)142 void cbm5x0ui_shutdown(void)
143 {
144 /* NOP */
145 }
146