1 /*
2  * scpu64-cmdline-options.c
3  *
4  * Written by
5  *  Kajtar Zsolt <soci@c64.rulez.org>
6  *  Andreas Boose <viceteam@t-online.de>
7  *  Ettore Perazzoli <ettore@comm2000.it>
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 #include <stdlib.h>
33 #include <string.h>
34 
35 #include "c64model.h"
36 #include "scpu64-cmdline-options.h"
37 #include "scpu64-resources.h"
38 #include "cmdline.h"
39 #include "machine.h"
40 #include "resources.h"
41 #include "vicii.h"
42 
set_cia_model(const char * value,void * extra_param)43 static int set_cia_model(const char *value, void *extra_param)
44 {
45     int model;
46 
47     model = atoi(value);
48     scpu64_resources_update_cia_models(model);
49 
50     return 0;
51 }
52 
53 struct model_s {
54     const char *name;
55     int model;
56 };
57 
58 static struct model_s model_match[] = {
59     { "c64", C64MODEL_C64_PAL },
60     { "breadbox", C64MODEL_C64_PAL },
61     { "pal", C64MODEL_C64_PAL },
62     { "c64c", C64MODEL_C64C_PAL },
63     { "c64new", C64MODEL_C64C_PAL },
64     { "newpal", C64MODEL_C64C_PAL },
65     { "c64old", C64MODEL_C64_OLD_PAL },
66     { "oldpal", C64MODEL_C64_OLD_PAL },
67     { "ntsc", C64MODEL_C64_NTSC },
68     { "c64ntsc", C64MODEL_C64_NTSC },
69     { "c64cntsc", C64MODEL_C64C_NTSC },
70     { "newntsc", C64MODEL_C64C_NTSC },
71     { "c64newntsc", C64MODEL_C64C_NTSC },
72     { "oldntsc", C64MODEL_C64_OLD_NTSC },
73     { "c64oldntsc", C64MODEL_C64_OLD_NTSC },
74     { "paln", C64MODEL_C64_PAL_N },
75     { "drean", C64MODEL_C64_PAL_N },
76     { "sx64", C64MODEL_C64SX_PAL },
77     { "sx64pal", C64MODEL_C64SX_PAL },
78     { "sx64ntsc", C64MODEL_C64SX_NTSC },
79     { "gs", C64MODEL_C64_GS },
80     { "c64gs", C64MODEL_C64_GS },
81     { "jap", C64MODEL_C64_JAP },
82     { "c64jap", C64MODEL_C64_JAP },
83     { NULL, C64MODEL_UNKNOWN }
84 };
85 
set_c64_model(const char * param,void * extra_param)86 static int set_c64_model(const char *param, void *extra_param)
87 {
88     int model = C64MODEL_UNKNOWN;
89     int i = 0;
90 
91     if (!param) {
92         return -1;
93     }
94 
95     do {
96         if (strcmp(model_match[i].name, param) == 0) {
97             model = model_match[i].model;
98         }
99         i++;
100     } while ((model == C64MODEL_UNKNOWN) && (model_match[i].name != NULL));
101 
102     if (model == C64MODEL_UNKNOWN) {
103         return -1;
104     }
105 
106     c64model_set(model);
107 
108     return 0;
109 }
110 
set_video_standard(const char * param,void * extra_param)111 static int set_video_standard(const char *param, void *extra_param)
112 {
113     int value = vice_ptr_to_int(extra_param);
114     int vicii_model;
115 
116     resources_get_int("VICIIModel", &vicii_model);
117 
118     switch (value) {
119         case MACHINE_SYNC_PAL:
120         default:
121             if (vicii_model == VICII_MODEL_8562 || vicii_model == VICII_MODEL_8565) {
122                 return resources_set_int("VICIIModel", VICII_MODEL_8565);
123             } else if (vicii_model == VICII_MODEL_6567R56A) {
124                 return resources_set_int("VICIIModel", VICII_MODEL_6569R1);
125             } else {
126                 return resources_set_int("VICIIModel", VICII_MODEL_6569);
127             }
128             break;
129         case MACHINE_SYNC_NTSC:
130             if (vicii_model == VICII_MODEL_8562 || vicii_model == VICII_MODEL_8565) {
131                 return resources_set_int("VICIIModel", VICII_MODEL_8562);
132             } else {
133                 return resources_set_int("VICIIModel", VICII_MODEL_6567);
134             }
135             break;
136         case MACHINE_SYNC_NTSCOLD:
137                 return resources_set_int("VICIIModel", VICII_MODEL_6567R56A);
138         case MACHINE_SYNC_PALN:
139                 return resources_set_int("VICIIModel", VICII_MODEL_6572);
140     }
141     return 0;
142 }
143 
144 static const cmdline_option_t cmdline_options[] =
145 {
146     { "-pal", CALL_FUNCTION, CMDLINE_ATTRIB_NONE,
147       set_video_standard, (void *)MACHINE_SYNC_PAL, NULL, NULL,
148       NULL, "Use PAL sync factor" },
149     { "-ntsc", CALL_FUNCTION, CMDLINE_ATTRIB_NONE,
150       set_video_standard, (void *)MACHINE_SYNC_NTSC, NULL, NULL,
151       NULL, "Use NTSC sync factor" },
152     { "-ntscold", CALL_FUNCTION, CMDLINE_ATTRIB_NONE,
153       set_video_standard, (void *)MACHINE_SYNC_NTSCOLD, NULL, NULL,
154       NULL, "Use old NTSC sync factor" },
155     { "-paln", CALL_FUNCTION, CMDLINE_ATTRIB_NONE,
156       set_video_standard, (void *)MACHINE_SYNC_PALN, NULL, NULL,
157       NULL, "Use PAL-N sync factor" },
158     { "-scpu64", SET_RESOURCE, CMDLINE_ATTRIB_NEED_ARGS,
159       NULL, NULL, "SCPU64Name", NULL,
160       "<Name>", "Specify name of SCPU64 ROM image" },
161     { "-chargen", SET_RESOURCE, CMDLINE_ATTRIB_NEED_ARGS,
162       NULL, NULL, "ChargenName", NULL,
163       "<Name>", "Specify name of character generator ROM image" },
164 #if defined(HAVE_RS232DEV) || defined(HAVE_RS232NET)
165     { "-acia1", SET_RESOURCE, CMDLINE_ATTRIB_NONE,
166       NULL, NULL, "Acia1Enable", (void *)1,
167       NULL, "Enable the ACIA RS232 interface emulation" },
168     { "+acia1", SET_RESOURCE, CMDLINE_ATTRIB_NONE,
169       NULL, NULL, "Acia1Enable", (void *)0,
170       NULL, "Disable the ACIA RS232 interface emulation" },
171 #endif
172     { "-ciamodel", CALL_FUNCTION, CMDLINE_ATTRIB_NEED_ARGS,
173       set_cia_model, NULL, NULL, NULL,
174       "<Model>", "Set both CIA models (0 = old 6526, 1 = new 8521)" },
175     { "-cia1model", SET_RESOURCE, CMDLINE_ATTRIB_NEED_ARGS,
176       NULL, NULL, "CIA1Model", NULL,
177       "<Model>", "Set CIA 1 model (0 = old 6526, 1 = new 8521)" },
178     { "-cia2model", SET_RESOURCE, CMDLINE_ATTRIB_NEED_ARGS,
179       NULL, NULL, "CIA2Model", NULL,
180       "<Model>", "Set CIA 2 model (0 = old 6526, 1 = new 8521)" },
181     { "-model", CALL_FUNCTION, CMDLINE_ATTRIB_NEED_ARGS,
182       set_c64_model, NULL, NULL, NULL,
183       "<Model>", "Set C64 model (c64/c64c/c64old, ntsc/newntsc/oldntsc, drean, jap, c64gs)" },
184     { "-burstmod", SET_RESOURCE, CMDLINE_ATTRIB_NEED_ARGS,
185       NULL, NULL, "BurstMod", NULL,
186       "<value>", "Burst modification (0 = None, 1 = CIA1, 2 = CIA2)" },
187     { "-iecreset", SET_RESOURCE, CMDLINE_ATTRIB_NEED_ARGS,
188       NULL, NULL, "IECReset", NULL,
189       "<value>", "Computer reset goes to IEC bus (0 = No, 1 = Yes)" },
190     { "-simmsize", SET_RESOURCE, CMDLINE_ATTRIB_NEED_ARGS,
191       NULL, NULL, "SIMMSize", NULL,
192       "<number>", "Size of the SIMM RAM (0/1/4/8/16 MiB)" },
193     { "-jiffyswitch", SET_RESOURCE, CMDLINE_ATTRIB_NONE,
194       NULL, NULL, "JiffySwitch", (void *)1,
195       NULL, "Turn on Jiffy switch" },
196     { "+jiffyswitch", SET_RESOURCE, CMDLINE_ATTRIB_NONE,
197       NULL, NULL, "JiffySwitch", (void *)0,
198       NULL, "Turn off Jiffy switch" },
199     { "-speedswitch", SET_RESOURCE, CMDLINE_ATTRIB_NONE,
200       NULL, NULL, "SpeedSwitch", (void *)1,
201       NULL, "Turn on Speed switch" },
202     { "+speedswitch", SET_RESOURCE, CMDLINE_ATTRIB_NONE,
203       NULL, NULL, "SpeedSwitch", (void *)0,
204       NULL, "Turn off Speed switch" },
205     CMDLINE_LIST_END
206 };
207 
scpu64_cmdline_options_init(void)208 int scpu64_cmdline_options_init(void)
209 {
210     return cmdline_register_options(cmdline_options);
211 }
212