1 /** \file   uivideo.c
2  * \brief   Video chip/config helpers
3  *
4  * \author  Bas Wassink <b.wassink@ziggo.nl>
5  */
6 
7 /*
8  * This file is part of VICE, the Versatile Commodore Emulator.
9  * See README for copyright notice.
10  *
11  *  This program is free software; you can redistribute it and/or modify
12  *  it under the terms of the GNU General Public License as published by
13  *  the Free Software Foundation; either version 2 of the License, or
14  *  (at your option) any later version.
15  *
16  *  This program is distributed in the hope that it will be useful,
17  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  *  GNU General Public License for more details.
20  *
21  *  You should have received a copy of the GNU General Public License
22  *  along with this program; if not, write to the Free Software
23  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
24  *  02111-1307  USA.
25  *
26  */
27 
28 #include "vice.h"
29 
30 #include <stdio.h>
31 #include <stdlib.h>
32 #include <string.h>
33 
34 #include "archdep.h"
35 #include "machine.h"
36 
37 #include "uivideo.h"
38 
39 
40 /** \brief  Get video chip name by `machine_class`
41  *
42  * \return  Video chip name (the prefix used in "${CHIP}FooBar" resources)
43  *
44  * \warning Returns "VICII" for C128, not VDC
45  */
uivideo_chip_name(void)46 const char *uivideo_chip_name(void)
47 {
48     switch (machine_class) {
49         /* VIC */
50         case VICE_MACHINE_VIC20:
51             return "VIC";
52 
53         /* VIC-II */
54         case VICE_MACHINE_C64:      /* fall through */
55         case VICE_MACHINE_C64SC:    /* fall through */
56         case VICE_MACHINE_SCPU64:   /* fall through */
57         case VICE_MACHINE_C64DTV:   /* fall through */
58         case VICE_MACHINE_C128:     /* fall through */
59         case VICE_MACHINE_CBM5x0:   /* fall through */
60         case VICE_MACHINE_VSID:
61             return "VICII";
62 
63         /* TED */
64         case VICE_MACHINE_PLUS4:
65             return "TED";
66 
67         /* CRTC */
68         case VICE_MACHINE_PET:      /* fall through */
69         case VICE_MACHINE_CBM6x0:
70             return "Crtc";
71 
72         default:
73             /* should never get here */
74             fprintf(stderr, "%s:%d:%s(): error: got machine class %d\n",
75                     __FILE__, __LINE__, __func__, machine_class);
76             archdep_vice_exit(1);
77             return NULL;
78     }
79 }
80 
81 
82 /** \brief  Get video chip ID by `machine_class`
83  *
84  * \return  Video chip ID (\see src/arch/gtk3/uivideo.h)
85  *
86  * \warning Returns "VICII" for C128, not VDC
87  */
uivideo_chip_id(void)88 int uivideo_chip_id(void)
89 {
90     switch (machine_class) {
91         /* VIC */
92         case VICE_MACHINE_VIC20:
93             return UI_VIDEO_CHIP_VIC;
94 
95         /* VIC-II */
96         case VICE_MACHINE_C64:      /* fall through */
97         case VICE_MACHINE_C64SC:    /* fall through */
98         case VICE_MACHINE_SCPU64:   /* fall through */
99         case VICE_MACHINE_C64DTV:   /* fall through */
100         case VICE_MACHINE_C128:     /* fall through */
101         case VICE_MACHINE_CBM5x0:   /* fall through */
102         case VICE_MACHINE_VSID:
103             return UI_VIDEO_CHIP_VICII;
104 
105         /* TED */
106         case VICE_MACHINE_PLUS4:
107             return UI_VIDEO_CHIP_TED;
108 
109         /* CRTC */
110         case VICE_MACHINE_PET:      /* fall through */
111         case VICE_MACHINE_CBM6x0:
112             return UI_VIDEO_CHIP_CRTC;
113 
114         default:
115             /* should never get here */
116             fprintf(stderr, "%s:%d:%s(): error: got machine class %d\n",
117                     __FILE__, __LINE__, __func__, machine_class);
118             archdep_vice_exit(1);
119             return -1;
120     }
121 }
122 
123 
124 /** \brief  Determine if the current video chip supports VerticalStretch
125  *
126  * \param[in]   chip    chip name (only used in case of the C128
127  *
128  * \return  bool
129  */
uivideo_chip_has_vert_stretch(const char * chip)130 int uivideo_chip_has_vert_stretch(const char *chip)
131 {
132     switch (machine_class) {
133         /* CRTC */
134         case VICE_MACHINE_PET:      /* fall through */
135         case VICE_MACHINE_CBM6x0:
136             return 1;
137         /* VDC */
138         case VICE_MACHINE_C128:
139             return (strcmp(chip, "VDC") == 0);
140         /* VIC, VIC-II, TED */
141         default:
142             return 0;
143     }
144 }
145 
146 
147 /** \brief  Determine if the current video chip supports BorderMode
148  *
149  * \param[in]   chip    chip name (only used in case of the C128)
150  *
151  * \return  bool
152  */
uivideo_chip_has_border_mode(const char * chip)153 int uivideo_chip_has_border_mode(const char *chip)
154 {
155     switch (machine_class) {
156         /* CRTC */
157         case VICE_MACHINE_PET:      /* fall through */
158         case VICE_MACHINE_CBM6x0:
159             return 0;
160         /* VDC */
161         case VICE_MACHINE_C128:
162             return !(strcmp(chip, "VDC") == 0);
163         /* VIC, VIC-II, TED */
164         default:
165             return 1;
166     }
167 }
168 
169 
170 /** \brief  Determine if the current video chip supports VSP-bug emulation
171  *
172  * \param[in]   chip    chip name (only used in case of the C128)
173  *
174  * \return  bool
175  */
uivideo_chip_has_vsp_bug(const char * chip)176 int uivideo_chip_has_vsp_bug(const char *chip)
177 {
178     switch (machine_class) {
179         case VICE_MACHINE_C64SC:      /* fall through */
180         case VICE_MACHINE_SCPU64:
181             return 1;
182         /* VDC */
183         case VICE_MACHINE_C128:
184             /* not right now, unless VICII emulation in x128 gets it later */
185             /* return !(strcmp(chip, "VDC") == 0); */
186             return 0;
187 
188         default:
189             return 0;
190     }
191 }
192 
193 
194 /** \brief  Determine if the current video chip supports sprites
195  *
196  * \param[in]   chip    chip name (only used in case of the C128
197  *
198  * \return  bool
199  */
uivideo_chip_has_sprites(const char * chip)200 int uivideo_chip_has_sprites(const char *chip)
201 {
202     switch (machine_class) {
203         /* VIC-II */
204         case VICE_MACHINE_C64:      /* fall through */
205         case VICE_MACHINE_C64SC:    /* fall through */
206         case VICE_MACHINE_C64DTV:   /* fall through */
207         case VICE_MACHINE_SCPU64:   /* fall through */
208         case VICE_MACHINE_CBM5x0:
209             return 1;
210         /* VDC or VICII */
211         case VICE_MACHINE_C128:
212             return !(strcmp(chip, "VDC") == 0);
213 
214         default:
215             return 0;
216     }
217 }
218