1 /** \file   cbm2ui.c
2  * \brief   Native GTK3 CBM2 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 "crtc.h"
38 #include "crtcontrolwidget.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 "settings_model.h"
46 
47 #include "cbm2ui.h"
48 
49 /** \brief  List of CBM-II models
50  *
51  * Used in the machine-model widget
52  *
53  * \note    Careful: the first entry has an ID of 2 when calling cbm2model_*()
54  *          since xcbm2 skips the 5x0 models.
55  */
56 static const char *cbm2_model_list[] = {
57     "CBM 610 PAL", "CBM 610 NTSC", "CBM 620 PAL", "CBM 620 NTSC",
58     "CBM 620+ (1M) PAL", "CBM 620+ (1M) NTSC", "CBM 710 NTSC", "CBM 720 NTSC",
59     "CBM 720+ (1M) NTSC", NULL
60 };
61 
62 
63 /** \brief  Identify the canvas used to create a window
64  *
65  * \param[in]   canvas  video canvas
66  *
67  * \return  window index on success, -1 on failure
68  */
identify_canvas(video_canvas_t * canvas)69 static int identify_canvas(video_canvas_t *canvas)
70 {
71     if (canvas != crtc_get_canvas()) {
72         return -1;
73     }
74 
75     return PRIMARY_WINDOW;
76 }
77 
78 /** \brief  Create CRT controls widget for \a target window
79  *
80  * \param[in]   target_window   target window index
81  *
82  * \return  GtkGrid
83  */
create_crt_widget(int target_window)84 static GtkWidget *create_crt_widget(int target_window)
85 {
86     return crt_control_widget_create(NULL, "CRTC", TRUE);
87 }
88 
89 /** \brief  Pre-initialize the UI before the canvas window gets created
90  *
91  * \return  0 on success, -1 on failure
92  */
cbm2ui_init_early(void)93 int cbm2ui_init_early(void)
94 {
95     ui_machine_window_init();
96     ui_set_identify_canvas_func(identify_canvas);
97     ui_set_create_controls_widget_func(create_crt_widget);
98     return 0;
99 }
100 
101 
102 /** \brief  Initialize the UI
103  *
104  * \return  0 on success, -1 on failure
105  */
cbm2ui_init(void)106 int cbm2ui_init(void)
107 {
108     machine_model_widget_getter(cbm2model_get);
109     machine_model_widget_setter(cbm2model_set);
110     machine_model_widget_set_models(cbm2_model_list);
111 
112     settings_sampler_set_devices_getter(sampler_get_devices);
113 
114     /* uicart_set_detect_func(cartridge_detect); only cbm2/plus4 */
115     /*uicart_set_list_func(cartridge_get_info_list);*/
116     uicart_set_attach_func(cartridge_attach_image);
117     /*uicart_set_freeze_func(cartridge_trigger_freeze);*/
118     uicart_set_detach_func(cartridge_detach_image);
119 
120     settings_model_widget_set_model_func(cbm2model_get);
121     return 0;
122 }
123 
124 
125 /** \brief  Shut down the UI
126  */
cbm2ui_shutdown(void)127 void cbm2ui_shutdown(void)
128 {
129     /* NOP */
130 }
131