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