1 /** \file   scpu64ui.c
2  * \brief   Native GTK3 SCPU64 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 "widgethelpers.h"
35 #include "c64model.h"
36 #include "crtcontrolwidget.h"
37 #include "vicii.h"
38 #include "machinemodelwidget.h"
39 #include "videomodelwidget.h"
40 #include "sampler.h"
41 #include "ui.h"
42 #include "uimachinewindow.h"
43 #include "settings_sampler.h"
44 
45 #include "clockportdevicewidget.h"
46 #include "clockport.h"
47 
48 #include "cartridge.h"
49 #include "reu.h"
50 #include "reuwidget.h"
51 #include "ramcartwidget.h"
52 #include "dqbbwidget.h"
53 #include "expertwidget.h"
54 #include "isepicwidget.h"
55 #include "gmod2widget.h"
56 #include "mmcrwidget.h"
57 #include "mmc64widget.h"
58 #include "retroreplaywidget.h"
59 #include "easyflashwidget.h"
60 #include "rrnetmk3widget.h"
61 #include "carthelpers.h"
62 #include "uicart.h"
63 #include "c64model.h"
64 #include "settings_model.h"
65 
66 #include "scpu64ui.h"
67 
68 
69 /** \brief  List of C64 models
70  *
71  * Used in the machine-model widget
72  */
73 static const char *c64scpu_model_list[] = {
74     "C64 PAL", "C64C PAL", "C64 old PAL",
75     "C64 NTSC", "C64C NTSC" "C64 old NTSC",
76     "Drean",
77     "C64 SX PAL", "C64 SX NTSC",
78     "Japanese", "C64 GS",
79     NULL
80 };
81 
82 
83 /** \brief  List of VIC-II models
84  *
85  * Used in the VIC-II model widget
86  */
87 static const vice_gtk3_radiogroup_entry_t c64scpu_vicii_models[] = {
88     { "6569 (PAL)",             VICII_MODEL_6569 },
89     { "8565 (PAL)",             VICII_MODEL_8565 },
90     { "6569R1 (old PAL)",       VICII_MODEL_6569R1 },
91     { "6567 (NTSC)",            VICII_MODEL_6567 },
92     { "8562 (NTSC)",            VICII_MODEL_8562 },
93     { "6567R56A (old NTSC)",    VICII_MODEL_6567R56A },
94     { "6572 (PAL-N)",           VICII_MODEL_6572 },
95     { NULL, -1 }
96 };
97 
98 
99 /** \brief  Identify the canvas used to create a window
100  *
101  * \param[in]   canvas  video canvas reference
102  *
103  * \return  window index on success, -1 on failure
104  */
identify_canvas(video_canvas_t * canvas)105 static int identify_canvas(video_canvas_t *canvas)
106 {
107     if (canvas != vicii_get_canvas()) {
108         return -1;
109     }
110 
111     return PRIMARY_WINDOW;
112 }
113 
114 /** \brief  Create CRT controls widget for \a target window
115  *
116  * \param[in]   target_window   target window index
117  *
118  * \return  GtkGrid
119  */
create_crt_widget(int target_window)120 static GtkWidget *create_crt_widget(int target_window)
121 {
122     return crt_control_widget_create(NULL, "VICII", TRUE);
123 }
124 
125 /** \brief  Pre-initialize the UI before the canvas window gets created
126  *
127  * \return  0 on success, -1 on failure
128  */
scpu64ui_init_early(void)129 int scpu64ui_init_early(void)
130 {
131     ui_machine_window_init();
132     ui_set_identify_canvas_func(identify_canvas);
133     ui_set_create_controls_widget_func(create_crt_widget);
134     return 0;
135 }
136 
137 
138 /** \brief  Initialize the UI
139  *
140  * \return  0 on success, -1 on failure
141  */
scpu64ui_init(void)142 int scpu64ui_init(void)
143 {
144     machine_model_widget_getter(c64model_get);
145     machine_model_widget_setter(c64model_set);
146     machine_model_widget_set_models(c64scpu_model_list);
147 
148     video_model_widget_set_title("VIC-II model");
149     video_model_widget_set_resource("VICIIModel");
150     video_model_widget_set_models(c64scpu_vicii_models);
151 
152     settings_sampler_set_devices_getter(sampler_get_devices);
153     clockport_device_widget_set_devices((void *)clockport_supported_devices);
154 
155     /* I/O extension function pointers */
156     carthelpers_set_functions(
157             cartridge_save_image,
158             cartridge_flush_image,
159             cartridge_type_enabled,
160             cartridge_enable,
161             cartridge_disable);
162 
163     /* uicart_set_detect_func(cartridge_detect); only cbm2/plus4 */
164     uicart_set_list_func(cartridge_get_info_list);
165     uicart_set_attach_func(cartridge_attach_image);
166     uicart_set_freeze_func(cartridge_trigger_freeze);
167     uicart_set_detach_func(cartridge_detach_image);
168     uicart_set_default_func(cartridge_set_default);
169     uicart_set_filename_func(cartridge_current_filename);
170     uicart_set_wipe_func(cartridge_wipe_filename);
171 
172     /* set C64 model_get function */
173     settings_model_widget_set_model_func(c64model_get);
174     return 0;
175 }
176 
177 
178 /** \brief  Shut down the UI
179  */
scpu64ui_shutdown(void)180 void scpu64ui_shutdown(void)
181 {
182     /* NOP */
183 }
184