1 /** \file vsidui.c
2 * \brief Native GTK3 VSID 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
35 #include "vice_gtk3.h"
36 #include "machine.h"
37 #include "ui.h"
38 #include "uisidattach.h"
39 #include "uivsidwindow.h"
40 #include "vicii.h"
41 #include "resources.h"
42
43 #include "videomodelwidget.h"
44 #include "vsidcontrolwidget.h"
45 #include "vsidtuneinfowidget.h"
46 #include "vsidmainwidget.h"
47
48 #include "hvsc.h"
49
50 #include "vsidui.h"
51
52
53 static const vice_gtk3_radiogroup_entry_t vsid_vicii_models[] = {
54 { "PAL", MACHINE_SYNC_PAL },
55 { "NTSC", MACHINE_SYNC_NTSC },
56 { "NTSC (old)", MACHINE_SYNC_NTSCOLD },
57 { "PAL-N/Drean", MACHINE_SYNC_PALN },
58 { NULL, -1 }
59 };
60
61
vsid_ui_close(void)62 void vsid_ui_close(void)
63 {
64 hvsc_exit();
65 uisidattach_shutdown();
66 }
67
68
69 /** \brief Display tune author in the UI
70 *
71 * \param[in] author author name
72 */
vsid_ui_display_author(const char * author)73 void vsid_ui_display_author(const char *author)
74 {
75 vsid_tune_info_widget_set_author(author);
76 }
77
78
79 /** \brief Display tune copyright info in the UI
80 *
81 * \param[in] copright copyright info
82 */
vsid_ui_display_copyright(const char * copyright)83 void vsid_ui_display_copyright(const char *copyright)
84 {
85 vsid_tune_info_widget_set_copyright(copyright);
86 }
87
88
89 /** \brief Set IRQ type for the UI
90 *
91 * \param[in] irq IRQ type
92 */
vsid_ui_display_irqtype(const char * irq)93 void vsid_ui_display_irqtype(const char *irq)
94 {
95 vsid_tune_info_widget_set_irq(irq);
96 }
97
98
99 /** \brief Display tune name in the UI
100 *
101 * \param[in] name tune name
102 */
vsid_ui_display_name(const char * name)103 void vsid_ui_display_name(const char *name)
104 {
105 vsid_tune_info_widget_set_name(name);
106 }
107
108
109 /** \brief Set number of tunes for the UI
110 *
111 * \param[in] count number of tunes
112 */
vsid_ui_display_nr_of_tunes(int count)113 void vsid_ui_display_nr_of_tunes(int count)
114 {
115 vsid_main_widget_set_tune_count(count);
116 }
117
118
119 /** \brief Set SID model for the UI
120 *
121 * \param[in] model SID model
122 */
vsid_ui_display_sid_model(int model)123 void vsid_ui_display_sid_model(int model)
124 {
125 vsid_tune_info_widget_set_model(model);
126 }
127
128
129 /** \brief Set sync factor for the UI
130 *
131 * \param[in] sync sync factor
132 */
vsid_ui_display_sync(int sync)133 void vsid_ui_display_sync(int sync)
134 {
135 vsid_tune_info_widget_set_sync(sync);
136 }
137
138
139 /** \brief Set run time of tune in the UI
140 *
141 * \param[in] sec seconds of play time
142 */
vsid_ui_display_time(unsigned int sec)143 void vsid_ui_display_time(unsigned int sec)
144 {
145 vsid_tune_info_widget_set_time(sec);
146 }
147
148
149 /** \brief Set current tune number in the UI
150 *
151 * \param[in] nr tune number
152 */
vsid_ui_display_tune_nr(int nr)153 void vsid_ui_display_tune_nr(int nr)
154 {
155 vsid_main_widget_set_tune_current(nr);
156 }
157
158
159 /** \brief Set driver info text for the UI
160 *
161 * \param[in] driver_info_text text with driver info (duh)
162 */
vsid_ui_setdrv(char * driver_info_text)163 void vsid_ui_setdrv(char *driver_info_text)
164 {
165 vsid_tune_info_widget_set_driver(driver_info_text);
166 }
167
168
169 /** \brief Set default tune number in the UI
170 *
171 * \param[in] nr tune number
172 */
vsid_ui_set_default_tune(int nr)173 void vsid_ui_set_default_tune(int nr)
174 {
175 vsid_main_widget_set_tune_default(nr);
176 }
177
178
179 /** \brief Set driver address
180 *
181 * \param[in] addr driver address
182 */
vsid_ui_set_driver_addr(uint16_t addr)183 void vsid_ui_set_driver_addr(uint16_t addr)
184 {
185 vsid_tune_info_widget_set_driver_addr(addr);
186 }
187
188
189 /** \brief Set load address
190 *
191 * \param[in] addr load address
192 */
vsid_ui_set_load_addr(uint16_t addr)193 void vsid_ui_set_load_addr(uint16_t addr)
194 {
195 vsid_tune_info_widget_set_load_addr(addr);
196 }
197
198
199 /** \brief Set init routine address
200 *
201 * \param[in] addr init routine address
202 */
vsid_ui_set_init_addr(uint16_t addr)203 void vsid_ui_set_init_addr(uint16_t addr)
204 {
205 vsid_tune_info_widget_set_init_addr(addr);
206 }
207
208
209 /** \brief Set play routine address
210 *
211 * \param[in] addr play routine address
212 */
vsid_ui_set_play_addr(uint16_t addr)213 void vsid_ui_set_play_addr(uint16_t addr)
214 {
215 vsid_tune_info_widget_set_play_addr(addr);
216 }
217
218
219 /** \brief Set size of SID on actual machine
220 *
221 * \param[in] size size of SID
222 */
vsid_ui_set_data_size(uint16_t size)223 void vsid_ui_set_data_size(uint16_t size)
224 {
225 vsid_tune_info_widget_set_data_size(size);
226 }
227
228
229
230 /** \brief Identify the canvas used to create a window
231 *
232 * \return window index on success, -1 on failure
233 */
identify_canvas(video_canvas_t * canvas)234 static int identify_canvas(video_canvas_t *canvas)
235 {
236 if (canvas != vicii_get_canvas()) {
237 return -1;
238 }
239 return PRIMARY_WINDOW;
240 }
241
242
243 /** \brief Initialize the VSID UI
244 *
245 * \return 0 on success, -1 on failure
246 */
vsid_ui_init(void)247 int vsid_ui_init(void)
248 {
249 video_canvas_t *canvas = vicii_get_canvas();
250
251 video_model_widget_set_title("VIC-II model");
252 video_model_widget_set_resource("MachineVideoStandard");
253 video_model_widget_set_models(vsid_vicii_models);
254
255
256 ui_vsid_window_init();
257 ui_set_identify_canvas_func(identify_canvas);
258
259 ui_create_main_window(canvas);
260 ui_display_main_window(canvas->window_index);
261
262 /* for debugging */
263 debug_gtk3("libhvsc version: %s.", hvsc_lib_version_str());
264 return 0;
265 }
266