1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static char *rcsid = "$Id: rt-config.c,v 1.4 1998/02/21 14:51:54 david Exp $";
#define FALSE 0
#define TRUE 1
#include "atari.h"
#include "prompts.h"
#include "rt-config.h"
#ifdef VGA
/*This procedure processes lines not recognized by RtConfigLoad.
Currently only DOS port support it.*/
extern int Atari_Configure(char* option,char *parameters);
#endif
char atari_osa_filename[MAX_FILENAME_LEN];
char atari_osb_filename[MAX_FILENAME_LEN];
char atari_xlxe_filename[MAX_FILENAME_LEN];
char atari_basic_filename[MAX_FILENAME_LEN];
char atari_5200_filename[MAX_FILENAME_LEN];
char atari_disk_dirs[MAX_DIRECTORIES][MAX_FILENAME_LEN];
char atari_rom_dir[MAX_FILENAME_LEN];
char atari_h1_dir[MAX_FILENAME_LEN];
char atari_h2_dir[MAX_FILENAME_LEN];
char atari_h3_dir[MAX_FILENAME_LEN];
char atari_h4_dir[MAX_FILENAME_LEN];
char print_command[256];
int refresh_rate;
int default_system;
int default_tv_mode;
int hold_option;
int enable_c000_ram;
int enable_rom_patches;
int enable_sio_patch;
int disk_directories;
extern int Ram256;
static char *rtconfig_filename1 = "atari800.cfg";
static char *rtconfig_filename2 = "/etc/atari800.cfg";
int RtConfigLoad(char *rtconfig_filename)
{
FILE *fp;
int status = TRUE;
/* Win32 version doesn't use any of the RTxxx functions, but needs the variable
declarations above, so all of these are stubbed out by ifndefs in Win32 */
#ifndef WIN32
/*
* Set Configuration Parameters to sensible values
* in case the configuration file is missing.
*/
atari_osa_filename[0] = '\0';
atari_osb_filename[0] = '\0';
atari_xlxe_filename[0] = '\0';
atari_basic_filename[0] = '\0';
atari_5200_filename[0] = '\0';
atari_disk_dirs[0][0] = '\0';
disk_directories = 0;
atari_rom_dir[0] = '\0';
atari_h1_dir[0] = '\0';
atari_h2_dir[0] = '\0';
atari_h3_dir[0] = '\0';
atari_h4_dir[0] = '\0';
strcpy(print_command, "lpr %s");
refresh_rate = 1;
default_system = 3;
default_tv_mode = 1;
hold_option = 1;
enable_c000_ram = 0;
enable_rom_patches = 1;
enable_sio_patch = 1;
if (rtconfig_filename) {
fp = fopen(rtconfig_filename, "r");
if (!fp) {
perror(rtconfig_filename);
exit(1);
}
}
else {
fp = fopen(rtconfig_filename1, "r");
if (!fp)
fp = fopen(rtconfig_filename2, "r");
}
if (fp) {
char string[256];
char *ptr;
fgets(string, 256, fp);
printf("Configuration Created by %s", string);
while (fgets(string, 256, fp)) {
RemoveLF(string);
ptr = strchr(string, '=');
if (ptr) {
*ptr++ = '\0';
if (strcmp(string, "OS/A_ROM") == 0)
strcpy(atari_osa_filename, ptr);
else if (strcmp(string, "OS/B_ROM") == 0)
strcpy(atari_osb_filename, ptr);
else if (strcmp(string, "XL/XE_ROM") == 0)
strcpy(atari_xlxe_filename, ptr);
else if (strcmp(string, "BASIC_ROM") == 0)
strcpy(atari_basic_filename, ptr);
else if (strcmp(string, "5200_ROM") == 0)
strcpy(atari_5200_filename, ptr);
else if (strcmp(string, "DISK_DIR") == 0) {
if (disk_directories == MAX_DIRECTORIES)
printf("All disk directory slots used!\n");
else
strcpy(atari_disk_dirs[disk_directories++], ptr);
}
else if (strcmp(string, "ROM_DIR") == 0)
strcpy(atari_rom_dir, ptr);
else if (strcmp(string, "H1_DIR") == 0)
strcpy(atari_h1_dir, ptr);
else if (strcmp(string, "H2_DIR") == 0)
strcpy(atari_h2_dir, ptr);
else if (strcmp(string, "H3_DIR") == 0)
strcpy(atari_h3_dir, ptr);
else if (strcmp(string, "H4_DIR") == 0)
strcpy(atari_h4_dir, ptr);
else if (strcmp(string, "PRINT_COMMAND") == 0)
strcpy(print_command, ptr);
else if (strcmp(string, "SCREEN_REFRESH_RATIO") == 0)
sscanf(ptr, "%d", &refresh_rate);
else if (strcmp(string, "HOLD_OPTION") == 0)
sscanf(ptr, "%d", &hold_option);
else if (strcmp(string, "ENABLE_C000_RAM") == 0)
sscanf(ptr, "%d", &enable_c000_ram);
else if (strcmp(string, "ENABLE_ROM_PATCH") == 0)
sscanf(ptr, "%d", &enable_rom_patches);
else if (strcmp(string, "ENABLE_SIO_PATCH") == 0) {
if (enable_rom_patches)
sscanf(ptr, "%d", &enable_sio_patch);
else
enable_sio_patch = 0;
}
else if (strcmp(string, "DEFAULT_SYSTEM") == 0) {
if (strcmp(ptr, "Atari OS/A") == 0)
default_system = 1;
else if (strcmp(ptr, "Atari OS/B") == 0)
default_system = 2;
else if (strcmp(ptr, "Atari XL") == 0)
default_system = 3;
else if (strcmp(ptr, "Atari XE") == 0)
default_system = 4;
else if (strcmp(ptr, "Atari 320XE (RAMBO)") == 0) {
default_system = 5;
Ram256 = 1;
}
else if (strcmp(ptr, "Atari 320XE (COMPY SHOP)") == 0) {
default_system = 5;
Ram256 = 2;
}
else if (strcmp(ptr, "Atari 5200") == 0)
default_system = 6;
else
printf("Invalid System: %s\n", ptr);
}
else if (strcmp(string, "DEFAULT_TV_MODE") == 0) {
if (strcmp(ptr, "PAL") == 0)
default_tv_mode = 1;
else if (strcmp(ptr, "NTSC") == 0)
default_tv_mode = 2;
else
printf("Invalid TV Mode: %s\n", ptr);
}
else
#ifdef VGA
if (!Atari_Configure(string,ptr))
printf("Unrecognized variable or bad parameters: %s=%s\n", string,ptr);
#else
printf("Unrecognized Variable: %s\n", string);
#endif
}
else {
printf("Ignored Config Line: %s\n", string);
}
}
fclose(fp);
}
else {
status = FALSE;
}
#endif /* Win32 */
return status;
}
void RtConfigSave(void)
{
#ifndef WIN32
FILE *fp;
int i;
fp = fopen(rtconfig_filename1, "w");
if (!fp) {
perror(rtconfig_filename1);
exit(1);
}
printf("\nWriting: %s\n\n", rtconfig_filename1);
fprintf(fp, "%s\n", ATARI_TITLE);
fprintf(fp, "OS/A_ROM=%s\n", atari_osa_filename);
fprintf(fp, "OS/B_ROM=%s\n", atari_osb_filename);
fprintf(fp, "XL/XE_ROM=%s\n", atari_xlxe_filename);
fprintf(fp, "BASIC_ROM=%s\n", atari_basic_filename);
fprintf(fp, "5200_ROM=%s\n", atari_5200_filename);
for (i = 0; i < disk_directories; i++)
fprintf(fp, "DISK_DIR=%s\n", atari_disk_dirs[i]);
fprintf(fp, "ROM_DIR=%s\n", atari_rom_dir);
fprintf(fp, "H1_DIR=%s\n", atari_h1_dir);
fprintf(fp, "H2_DIR=%s\n", atari_h2_dir);
fprintf(fp, "H3_DIR=%s\n", atari_h3_dir);
fprintf(fp, "H4_DIR=%s\n", atari_h4_dir);
fprintf(fp, "PRINT_COMMAND=%s\n", print_command);
fprintf(fp, "SCREEN_REFRESH_RATIO=%d\n", refresh_rate);
fprintf(fp, "DEFAULT_SYSTEM=Atari ");
switch (default_system) {
case 1:
fprintf(fp, "OS/A\n");
break;
case 2:
fprintf(fp, "OS/B\n");
break;
case 3:
fprintf(fp, "XL\n");
break;
case 4:
fprintf(fp, "XE\n");
break;
case 5:
if (Ram256 == 1)
fprintf(fp, "320XE (RAMBO)\n");
else if (Ram256 == 2)
fprintf(fp, "320XE (COMPY SHOP)\n");
break;
case 6:
fprintf(fp, "5200\n");
break;
}
if (default_tv_mode == 1)
fprintf(fp, "DEFAULT_TV_MODE=PAL\n");
else
fprintf(fp, "DEFAULT_TV_MODE=NTSC\n");
fprintf(fp, "HOLD_OPTION=%d\n", hold_option);
fprintf(fp, "ENABLE_C000_RAM=%d\n", enable_c000_ram);
fprintf(fp, "ENABLE_ROM_PATCH=%d\n", enable_rom_patches);
fprintf(fp, "ENABLE_SIO_PATCH=%d\n", enable_rom_patches ? enable_sio_patch : 0);
fclose(fp);
#endif /* Win32 */
}
void RtConfigUpdate(void)
{
#ifndef WIN32
strcpy(atari_osa_filename, "atariosa.rom");
strcpy(atari_osb_filename, "atariosb.rom");
strcpy(atari_xlxe_filename, "atarixl.rom");
strcpy(atari_basic_filename, "ataribas.rom");
strcpy(atari_disk_dirs[0], ".");
disk_directories = 1;
strcpy(atari_rom_dir, ".");
GetString("Enter path with filename of Atari OS/A ROM [%s] ", atari_osa_filename);
GetString("Enter path with filename of Atari OS/B ROM [%s] ", atari_osb_filename);
GetString("Enter path with filename of Atari XL/XE ROM [%s] ", atari_xlxe_filename);
GetString("Enter path with filename of Atari BASIC ROM [%s] ", atari_basic_filename);
GetString("Enter path with filename of Atari 5200 ROM [%s] ", atari_5200_filename);
GetString("Enter path for disk images [%s] ", atari_disk_dirs[0]);
GetString("Enter path for ROM images [%s] ", atari_rom_dir);
GetString("Enter path for H1: device [%s] ", atari_h1_dir);
GetString("Enter path for H2: device [%s] ", atari_h2_dir);
GetString("Enter path for H3: device [%s] ", atari_h3_dir);
GetString("Enter path for H4: device [%s] ", atari_h4_dir);
GetString("Enter print command [%s] ", print_command);
GetNumber("Enter default screen refresh ratio 1:[%d] ", &refresh_rate);
if (refresh_rate < 1)
refresh_rate = 1;
else if (refresh_rate > 60)
refresh_rate = 60;
do {
GetNumber("Default System 1=OS/A 2=OS/B 3=800XL 4=130XE 5=320XE 6=5200 [%d] ",
&default_system);
} while ((default_system < 1) || (default_system > 6));
if (default_system == 5) {
do {
if (!Ram256)
Ram256 = 2;
GetNumber("320XE memory bank control 1=RAMBO, 2=COMPY SHOP [%d] ",
&Ram256);
} while ((Ram256 < 1) || (Ram256 > 2));
}
do {
GetNumber("Default TV mode 1=PAL 2=NTSC [%d] ",
&default_tv_mode);
} while ((default_tv_mode < 1) || (default_tv_mode > 2));
do {
GetNumber("Hold OPTION during Coldstart [%d] ",
&hold_option);
} while ((hold_option < 0) || (hold_option > 1));
do {
GetNumber("Enable C000-CFFF RAM in Atari800 mode [%d] ",
&enable_c000_ram);
} while ((enable_c000_ram < 0) || (enable_c000_ram > 1));
do {
GetNumber("Enable ROM PATCH (for H: device and SIO PATCH) [%d] ",
&enable_rom_patches);
} while ((enable_rom_patches < 0) || (enable_rom_patches > 1));
if (enable_rom_patches) {
do {
GetNumber("Enable SIO PATCH (Recommended for speed) [%d] ",
&enable_sio_patch);
} while ((enable_sio_patch < 0) || (enable_sio_patch > 1));
}
else
enable_sio_patch = 0; /* sio_patch only if rom_patches */
#ifdef VGA
printf("Standard joysticks configuration selected.\n"
"Use joycfg.exe to change it. Press RETURN to continue ");
fflush(stdout);
getchar();
#endif
#endif /* Win32 */
}
|