1 /** \file   vic20ui.c
2  * \brief   Native GTK3 VIC20 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 "crtcontrolwidget.h"
35 #include "machine.h"
36 #include "machinemodelwidget.h"
37 #include "sampler.h"
38 #include "ui.h"
39 #include "uimachinewindow.h"
40 #include "settings_sampler.h"
41 #include "vic.h"
42 #include "vic20model.h"
43 #include "videomodelwidget.h"
44 #include "widgethelpers.h"
45 
46 #include "cartridge.h"
47 #include "carthelpers.h"
48 #include "settings_io_georam.h"
49 #include "uicart.h"
50 
51 #include "vic20ui.h"
52 
53 
54 /** \brief  List of VIC-20 models
55  *
56  * Used in the machine-model widget
57  */
58 static const char *vic20_model_list[] = {
59     "VIC20 PAL",
60     "VIC20 NTSC",
61     "VIC21",
62     NULL
63 };
64 
65 
66 /** \brief  List of VIC models
67  *
68  * Used in the VIC model widget
69  */
70 static const vice_gtk3_radiogroup_entry_t vic20_vic_models[] = {
71     { "PAL", MACHINE_SYNC_PAL },
72     { "NTSC", MACHINE_SYNC_NTSC },
73     { NULL, -1 }
74 };
75 
76 
77 /** \brief  Identify the canvas used to create a window
78  *
79  * \return  window index on success, -1 on failure
80  */
identify_canvas(video_canvas_t * canvas)81 static int identify_canvas(video_canvas_t *canvas)
82 {
83     if (canvas != vic_get_canvas()) {
84         return -1;
85     }
86 
87     return PRIMARY_WINDOW;
88 }
89 
90 /** \brief  Create CRT controls widget for \a target window
91  *
92  * \return  GtkGrid
93  */
create_crt_widget(int target_window)94 static GtkWidget *create_crt_widget(int target_window)
95 {
96     return crt_control_widget_create(NULL, "VIC", TRUE);
97 }
98 
99 /** \brief  Pre-initialize the UI before the canvas window gets created
100  *
101  * \return  0 on success, -1 on failure
102  */
vic20ui_init_early(void)103 int vic20ui_init_early(void)
104 {
105     ui_machine_window_init();
106     ui_set_identify_canvas_func(identify_canvas);
107     ui_set_create_controls_widget_func(create_crt_widget);
108     return 0;
109 }
110 
111 
112 /** \brief  Initialize the UI
113  *
114  * \return  0 on success, -1 on failure
115  */
vic20ui_init(void)116 int vic20ui_init(void)
117 {
118     machine_model_widget_getter(vic20model_get);
119     machine_model_widget_setter(vic20model_set);
120     machine_model_widget_set_models(vic20_model_list);
121 
122     video_model_widget_set_title("VIC model");
123     video_model_widget_set_resource("MachineVideoStandard");
124     video_model_widget_set_models(vic20_vic_models);
125 
126     settings_sampler_set_devices_getter(sampler_get_devices);
127 
128     /* I/O extension function pointers */
129     carthelpers_set_functions(cartridge_save_image, cartridge_flush_image,
130             cartridge_type_enabled, NULL, NULL);
131 
132     /* uicart_set_detect_func(cartridge_detect); only cbm2/plus4 */
133 /*    uicart_set_list_func(cartridge_get_info_list); */
134     uicart_set_attach_func(cartridge_attach_image);
135 /*    uicart_set_freeze_func(cartridge_trigger_freeze); */
136     uicart_set_detach_func(cartridge_detach_image);
137     uicart_set_default_func(cartridge_set_default);
138     return 0;
139 }
140 
141 
142 /** \brief  Shut down the UI
143  */
vic20ui_shutdown(void)144 void vic20ui_shutdown(void)
145 {
146     /* NOP */
147 }
148