1 /*
2  * vicii-cmdline-options.c - Command-line options for the MOS 6569 (VIC-II)
3  * emulation.
4  *
5  * Written by
6  *  Ettore Perazzoli <ettore@comm2000.it>
7  *  Andreas Boose <viceteam@t-online.de>
8  *  Gunnar Ruthenberg <Krill.Plush@gmail.com>
9  *
10  * This file is part of VICE, the Versatile Commodore Emulator.
11  * See README for copyright notice.
12  *
13  *  This program is free software; you can redistribute it and/or modify
14  *  it under the terms of the GNU General Public License as published by
15  *  the Free Software Foundation; either version 2 of the License, or
16  *  (at your option) any later version.
17  *
18  *  This program is distributed in the hope that it will be useful,
19  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
20  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  *  GNU General Public License for more details.
22  *
23  *  You should have received a copy of the GNU General Public License
24  *  along with this program; if not, write to the Free Software
25  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
26  *  02111-1307  USA.
27  * */
28 
29 #include "vice.h"
30 
31 #include <stdio.h>
32 #include <string.h>
33 
34 #include "cmdline.h"
35 #include "machine.h"
36 #include "raster-cmdline-options.h"
37 #include "resources.h"
38 #include "vicii-cmdline-options.h"
39 #include "vicii-resources.h"
40 #include "vicii-timing.h"
41 #include "vicii.h"
42 #include "viciitypes.h"
43 
44 
border_set_func(const char * value,void * extra_param)45 static int border_set_func(const char *value, void *extra_param)
46 {
47     int video;
48 
49     resources_get_int("MachineVideoStandard", &video);
50 
51     if (strcmp(value, "1") == 0 || strcmp(value, "full") == 0) {
52         vicii_resources.border_mode = VICII_FULL_BORDERS;
53     } else if (strcmp(value, "2") == 0 || strcmp(value, "debug") == 0) {
54         vicii_resources.border_mode = VICII_DEBUG_BORDERS;
55     } else if (strcmp(value, "3") == 0 || strcmp(value, "none") == 0) {
56         vicii_resources.border_mode = VICII_NO_BORDERS;
57     } else {
58         vicii_resources.border_mode = VICII_NORMAL_BORDERS;
59     }
60 
61     machine_change_timing(video, vicii_resources.border_mode);
62 
63     return 0;
64 }
65 
66 struct model_s {
67     const char *name;
68     int model;
69 };
70 
71 static struct model_s model_match[] = {
72     /* PAL, 63 cycle, 9 luma, "old" */
73     { "6569", VICII_MODEL_6569 },
74     { "6569r3", VICII_MODEL_6569 },
75     { "pal", VICII_MODEL_6569 },
76 
77     /* PAL, 63 cycle, 9 luma, "new" */
78     { "8565", VICII_MODEL_8565 },
79     { "newpal", VICII_MODEL_8565 },
80 
81     /* PAL, 63 cycle, 5 luma, "old" */
82     { "6569r1", VICII_MODEL_6569R1 },
83     { "oldpal", VICII_MODEL_6569R1 },
84 
85     /* NTSC, 65 cycle, 9 luma, "old" */
86     { "6567", VICII_MODEL_6567 },
87     { "ntsc", VICII_MODEL_6567 },
88 
89     /* NTSC, 65 cycle, 9 luma, "new" */
90     { "8562", VICII_MODEL_8562 },
91     { "newntsc", VICII_MODEL_8562 },
92 
93     /* NTSC, 64 cycle, ? luma, "old" */
94     { "6567r56a", VICII_MODEL_6567R56A },
95     { "oldntsc", VICII_MODEL_6567R56A },
96 
97     /* PAL-N, 65 cycle, ? luma, "old" */
98     { "6572", VICII_MODEL_6572 },
99     { "paln", VICII_MODEL_6572 },
100     { "drean", VICII_MODEL_6572 },
101 
102     { NULL, -1 }
103 };
104 
set_vicii_model(const char * param,void * extra_param)105 static int set_vicii_model(const char *param, void *extra_param)
106 {
107     int model = -1;
108     int i = 0;
109 
110     if (!param) {
111         return -1;
112     }
113 
114     do {
115         if (strcmp(model_match[i].name, param) == 0) {
116             model = model_match[i].model;
117         }
118         i++;
119     } while ((model == -1) && (model_match[i].name != NULL));
120 
121     if (model == -1) {
122         return -1;
123     }
124 
125     return resources_set_int("VICIIModel", model);
126 }
127 
128 /* VIC-II command-line options.  */
129 static const cmdline_option_t cmdline_options[] =
130 {
131     { "-VICIIborders", CALL_FUNCTION, CMDLINE_ATTRIB_NEED_ARGS,
132       border_set_func, NULL, "VICIIBorderMode", (void *)0,
133       "<Mode>", "Set border display mode (0: normal, 1: full, 2: debug, 3: none)" },
134     { "-VICIIchecksb", SET_RESOURCE, CMDLINE_ATTRIB_NONE,
135       NULL, NULL, "VICIICheckSbColl", (void *)1,
136       NULL, "Enable sprite-background collision registers" },
137     { "+VICIIchecksb", SET_RESOURCE, CMDLINE_ATTRIB_NONE,
138       NULL, NULL, "VICIICheckSbColl", (void *)0,
139       NULL, "Disable sprite-background collision registers" },
140     { "-VICIIcheckss", SET_RESOURCE, CMDLINE_ATTRIB_NONE,
141       NULL, NULL, "VICIICheckSsColl", (void *)1,
142       NULL, "Enable sprite-sprite collision registers" },
143     { "+VICIIcheckss", SET_RESOURCE, CMDLINE_ATTRIB_NONE,
144       NULL, NULL, "VICIICheckSsColl", (void *)0,
145       NULL, "Disable sprite-sprite collision registers" },
146     { "-VICIIvspbug", SET_RESOURCE, CMDLINE_ATTRIB_NONE,
147       NULL, NULL, "VICIIVSPBug", (void *)1,
148       NULL, "Enable VSP bug emulation" },
149     { "+VICIIvspbug", SET_RESOURCE, CMDLINE_ATTRIB_NONE,
150       NULL, NULL, "VICIIVSPBug", (void *)0,
151       NULL, "Disable VSP bug emulation" },
152     { "-VICIImodel", CALL_FUNCTION, CMDLINE_ATTRIB_NEED_ARGS,
153       set_vicii_model, NULL, NULL, NULL,
154       "<Model>", "Set VIC-II model (6569/6569r1/8565/6567/8562/6567r56a/6572)" },
155     CMDLINE_LIST_END
156 };
157 
vicii_cmdline_options_init(void)158 int vicii_cmdline_options_init(void)
159 {
160     if (raster_cmdline_options_chip_init("VICII", vicii.video_chip_cap) < 0) {
161         return -1;
162     }
163 
164     return cmdline_register_options(cmdline_options);
165 }
166