Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
716 | lvd | 1 | #include "std.h" |
2 | |||
3 | #include <io.h> |
||
4 | #include <fcntl.h> |
||
5 | #include <sys/stat.h> |
||
6 | |||
7 | #include "emul.h" |
||
8 | #include "vars.h" |
||
9 | #include "memory.h" |
||
10 | #include "debug.h" |
||
11 | #include "dbglabls.h" |
||
12 | #include "draw.h" |
||
13 | #include "dx.h" |
||
14 | #include "fontatm2.h" |
||
15 | #include "snapshot.h" |
||
16 | #include "sound.h" |
||
17 | #include "sdcard.h" |
||
18 | #include "zc.h" |
||
19 | #include "util.h" |
||
20 | #include "init.h" |
||
21 | |||
22 | char load_errors; |
||
23 | |||
24 | void loadkeys(action*); |
||
25 | void loadzxkeys(CONFIG*); |
||
26 | void load_arch(const char*); |
||
27 | |||
28 | unsigned load_rom(const char *path, unsigned char *bank, unsigned max_banks = 1) |
||
29 | { |
||
30 | if (!*path) { norom: memset(bank, 0xFF, max_banks*PAGE); return 0; } |
||
31 | char tmp[FILENAME_MAX]; strcpy(tmp, path); |
||
32 | char *x = strrchr(tmp+2, ':'); |
||
33 | unsigned page = 0; |
||
34 | if (x) { *x = 0; page = atoi(x+1); } |
||
35 | if (max_banks == 16) page *= 16; // bank for scorp prof.rom |
||
36 | |||
37 | FILE *ff = fopen(tmp, "rb"); |
||
38 | |||
39 | if (!ff) { |
||
40 | errmsg("ROM file %s not found", tmp); |
||
41 | err: |
||
42 | load_errors = 1; |
||
43 | goto norom; |
||
44 | } |
||
45 | |||
46 | if (fseek(ff, page*PAGE, SEEK_SET)) { |
||
47 | badrom: |
||
48 | fclose(ff); |
||
49 | errmsg("Incorrect ROM file: %s", path); |
||
50 | goto err; |
||
51 | } |
||
52 | |||
53 | unsigned size = fread(bank, 1, max_banks*PAGE, ff); |
||
54 | if (!size || (size & (PAGE-1))) goto badrom; |
||
55 | |||
56 | fclose(ff); |
||
57 | return size / 1024; |
||
58 | } |
||
59 | |||
60 | void load_atm_font() |
||
61 | { |
||
62 | FILE *ff = fopen("SGEN.ROM", "rb"); |
||
63 | if (!ff) |
||
64 | { |
||
65 | memcpy(fontatm2, fontatm2_default, sizeof(fontatm2)); |
||
66 | return; |
||
67 | } |
||
68 | unsigned char font[0x800]; |
||
69 | unsigned sz = fread(font, 1, 0x800, ff); |
||
70 | if (sz == 0x800) { |
||
71 | color(CONSCLR_INFO); |
||
72 | printf("using ATM font from external SGEN.ROM\n"); |
||
73 | for (unsigned chr = 0; chr < 0x100; chr++) |
||
74 | for (unsigned l = 0; l < 8; l++) |
||
75 | fontatm2[chr+l*0x100] = font[chr*8+l]; |
||
76 | } |
||
77 | fclose(ff); |
||
78 | } |
||
79 | |||
80 | void load_atariset() |
||
81 | { |
||
82 | memset(temp.ataricolors, 0, sizeof temp.ataricolors); |
||
83 | if (!conf.atariset[0]) |
||
84 | return; |
||
85 | char defs[4000]; *defs = 0; // =12*256, strlen("07:aabbccdd,")=12 |
||
86 | char keyname[80]; |
||
87 | sprintf(keyname, "atari.%s", conf.atariset); |
||
88 | GetPrivateProfileString("COLORS", keyname, nil, defs, sizeof defs, ininame); |
||
89 | if (!*defs) |
||
90 | conf.atariset[0] = 0; |
||
91 | for (char *ptr = defs; *ptr; ) |
||
92 | { |
||
93 | if (ptr[2] != ':') |
||
94 | return; |
||
95 | for (int i = 0; i < 11; i++) |
||
96 | if (i != 2 && !ishex(ptr[i])) |
||
97 | return; |
||
98 | unsigned index, val; |
||
99 | sscanf(ptr, "%02X:%08X", &index, &val); |
||
100 | temp.ataricolors[index] = val; |
||
101 | // temp.ataricolors[(index*16 + index/16) & 0xFF] = val; // swap ink-paper |
||
102 | ptr += 12; |
||
103 | if (ptr [-1] != ',') |
||
104 | return; |
||
105 | } |
||
106 | } |
||
107 | |||
108 | void addpath(char *dst, const char *fname = 0) |
||
109 | { |
||
110 | if (!fname) |
||
111 | fname = dst; |
||
112 | else |
||
113 | strcpy(dst, fname); |
||
114 | if (!*fname) |
||
115 | return; // empty filenames have special meaning |
||
116 | if (fname[1] == ':' || (fname[0] == '\\' || fname[1] == '\\')) |
||
117 | return; // already full name |
||
118 | |||
119 | char tmp[FILENAME_MAX]; |
||
120 | GetModuleFileName(0, tmp, sizeof tmp); |
||
121 | char *xx = strrchr(tmp, '\\'); |
||
122 | if (*fname == '?') |
||
123 | *xx = 0; // "?" to get exe directory |
||
124 | else |
||
125 | strcpy(xx+1, fname); |
||
126 | strcpy(dst, tmp); |
||
127 | } |
||
128 | |||
129 | void save_nv() |
||
130 | { |
||
131 | char line[0x200]; addpath(line, "CMOS"); |
||
132 | FILE *f0 = fopen(line, "wb"); |
||
133 | if (f0) fwrite(cmos, 1, sizeof cmos, f0), fclose(f0); |
||
134 | |||
135 | addpath(line, "NVRAM"); |
||
136 | if ((f0 = fopen(line, "wb"))) fwrite(nvram, 1, sizeof nvram, f0), fclose(f0); |
||
137 | } |
||
138 | |||
139 | void load_romset(CONFIG *conf, const char *romset) |
||
140 | { |
||
141 | char sec[0x200]; |
||
142 | sprintf(sec, "ROM.%s", romset); |
||
143 | GetPrivateProfileString(sec, "sos", nil, conf->sos_rom_path, sizeof conf->sos_rom_path, ininame); |
||
144 | GetPrivateProfileString(sec, "dos", nil, conf->dos_rom_path, sizeof conf->dos_rom_path, ininame); |
||
145 | GetPrivateProfileString(sec, "128", nil, conf->zx128_rom_path, sizeof conf->zx128_rom_path, ininame); |
||
146 | GetPrivateProfileString(sec, "sys", nil, conf->sys_rom_path, sizeof conf->sys_rom_path, ininame); |
||
147 | addpath(conf->sos_rom_path); |
||
148 | addpath(conf->dos_rom_path); |
||
149 | addpath(conf->zx128_rom_path); |
||
150 | addpath(conf->sys_rom_path); |
||
151 | } |
||
152 | |||
153 | void add_presets(const char *section, const char *prefix0, unsigned *num, char **tab, unsigned char *curr) |
||
154 | { |
||
155 | *num = 0; |
||
156 | char buf[0x7F00], defval[64]; |
||
157 | GetPrivateProfileSection(section, buf, sizeof buf, ininame); |
||
158 | GetPrivateProfileString(section, prefix0, "none", defval, sizeof defval, ininame); |
||
159 | char *p = strchr(defval, ';'); |
||
160 | if (p) *p = 0; |
||
161 | |||
162 | for (p = defval+strlen(defval)-1; p>=defval && *p == ' '; *p-- = 0); |
||
163 | |||
164 | char prefix[0x200]; |
||
165 | strcpy(prefix, prefix0); |
||
166 | strcat(prefix, "."); |
||
167 | unsigned plen = strlen(prefix); |
||
168 | for (char *ptr = buf; *ptr; ) |
||
169 | { |
||
170 | if (!strnicmp(ptr, prefix, plen)) |
||
171 | { |
||
172 | ptr += plen; |
||
173 | tab[*num] = setptr; |
||
174 | while (*ptr && *ptr != '=') |
||
175 | *setptr++ = *ptr++; |
||
176 | *setptr++ = 0; |
||
177 | |||
178 | if (!stricmp(tab[*num], defval)) |
||
179 | *curr = (unsigned char)*num; |
||
180 | (*num)++; |
||
181 | } |
||
182 | while (*ptr) ptr++; |
||
183 | ptr++; |
||
184 | } |
||
185 | } |
||
186 | |||
187 | void load_ula_preset() |
||
188 | { |
||
189 | if (conf.ula_preset >= num_ula) return; |
||
190 | char line[128], name[64]; |
||
191 | sprintf(name, "PRESET.%s", ulapreset[conf.ula_preset]); |
||
192 | static char defaults[] = "71680,17989,224,50,32,0,0,0,0,0,320,240,24,32,384,288,48,64"; |
||
193 | GetPrivateProfileString("ULA", name, defaults, line, sizeof line, ininame); |
||
194 | unsigned t1, t2, t3, t4, t5; |
||
195 | sscanf(line, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%u,%u,%u,%u,%u,%u,%u,%u,%u", &/*conf.frame*/frametime/*Alone Coder*/, &conf.paper, |
||
196 | &conf.t_line, &conf.intfq, &conf.intlen, &t1, &t2, &t3, &t4, &t5, |
||
197 | &conf.mcx_small, &conf.mcy_small, &conf.b_top_small, &conf.b_left_small, |
||
198 | &conf.mcx_full, &conf.mcy_full, &conf.b_top_full, &conf.b_left_full); |
||
199 | conf.even_M1 = (unsigned char)t1; conf.border_4T = (unsigned char)t2; |
||
200 | conf.floatbus = (unsigned char)t3; conf.floatdos = (unsigned char)t4; |
||
201 | conf.portff = t5 & 1; |
||
202 | |||
203 | if(conf.mcx_small < 256) |
||
204 | conf.mcx_small = 256; |
||
205 | if(conf.mcy_small < 192) |
||
206 | conf.mcy_small = 192; |
||
207 | |||
208 | if(conf.mcx_full < 256) |
||
209 | conf.mcx_full = 256; |
||
210 | if(conf.mcy_full < 192) |
||
211 | conf.mcy_full = 192; |
||
212 | |||
213 | if(conf.b_left_full & 7) |
||
214 | { |
||
215 | err_printf("PRESET.%s:b_left_full not multiple of 8\n", ulapreset[conf.ula_preset]); |
||
216 | exit(); |
||
217 | } |
||
218 | } |
||
219 | |||
220 | void load_ay_stereo() |
||
221 | { |
||
222 | char line[128], name[64]; sprintf(name, "STEREO.%s", aystereo[conf.sound.ay_stereo]); |
||
223 | GetPrivateProfileString("AY", name, "100,10,66,66,10,100", line, sizeof line, ininame); |
||
224 | unsigned *stereo = conf.sound.ay_stereo_tab; |
||
225 | sscanf(line, "%d,%d,%d,%d,%d,%d", stereo+0, stereo+1, stereo+2, stereo+3, stereo+4, stereo+5); |
||
226 | } |
||
227 | |||
228 | void load_ay_vols() |
||
229 | { |
||
230 | char line[512] = { 0 }; |
||
231 | static char defaults[] = "0000,0340,04C0,06F2,0A44,0F13,1510,227E,289F,414E,5B21,7258,905E,B550,D7A0,FFFF"; |
||
232 | char name[64]; sprintf(name, "VOLTAB.%s", ayvols[conf.sound.ay_vols]); |
||
233 | GetPrivateProfileString("AY", name, defaults, line, sizeof line, ininame); |
||
234 | if (line[74] != ',') strcpy(line, defaults); |
||
235 | if (line[79] == ',') { // YM |
||
236 | for (int i = 0; i < 32; i++) |
||
237 | sscanf(line+i*5, "%X", &conf.sound.ay_voltab[i]); |
||
238 | } else { // AY |
||
239 | for (int i = 0; i < 16; i++) |
||
240 | sscanf(line+i*5, "%X", &conf.sound.ay_voltab[2*i]), conf.sound.ay_voltab[2*i+1] = conf.sound.ay_voltab[2*i]; |
||
241 | } |
||
242 | } |
||
243 | |||
244 | void load_config(const char *fname) |
||
245 | { |
||
246 | char line[FILENAME_MAX]; |
||
247 | load_errors = 0; |
||
248 | |||
249 | GetModuleFileName(0, ininame, sizeof ininame); |
||
250 | strlwr(ininame); *(unsigned*)(strstr(ininame, ".exe")+1) = WORD4('i','n','i',0); |
||
251 | |||
252 | if (fname && *fname) { |
||
253 | char *dst = strrchr(ininame, '\\'); |
||
254 | if (strchr(fname, '/') || strchr(fname, '\\')) dst = ininame; else dst++; |
||
255 | strcpy(dst, fname); |
||
256 | } |
||
257 | color(CONSCLR_DEFAULT); printf("ini: "); |
||
258 | color(CONSCLR_INFO); printf("%s\n", ininame); |
||
259 | |||
260 | if (GetFileAttributes(ininame) == -1) errexit("config file not found"); |
||
261 | |||
262 | static const char* misc = "MISC"; |
||
263 | static const char* video = "VIDEO"; |
||
264 | static const char* ula = "ULA"; |
||
265 | static const char* beta128 = "Beta128"; |
||
266 | static const char* leds = "LEDS"; |
||
267 | static const char* sound = "SOUND"; |
||
268 | static const char* input = "INPUT"; |
||
269 | static const char* colors = "COLORS"; |
||
270 | static const char* ay = "AY"; |
||
271 | static const char* saa1099 = "SAA1099"; |
||
272 | static const char* atm = "ATM"; |
||
273 | static const char* hdd = "HDD"; |
||
274 | static const char* rom = "ROM"; |
||
275 | static const char* ngs = "NGS"; |
||
276 | static const char* zc = "ZC"; |
||
277 | |||
278 | #ifdef MOD_MONITOR |
||
279 | addpath(conf.sos_labels_path, "sos.l"); |
||
280 | #endif |
||
281 | |||
282 | GetPrivateProfileString("*", "UNREAL", nil, line, sizeof line, ininame); |
||
283 | int a,b,c; |
||
284 | sscanf(line, "%u.%u.%u", &a, &b, &c); |
||
285 | if ((((a << 8U) | b) != VER_HL) || (c != (VER_A & 0x7F))) |
||
286 | errexit("wrong ini-file version"); |
||
287 | |||
288 | GetPrivateProfileString(misc, "Help", "help_eng.html", helpname, sizeof helpname, ininame); |
||
289 | addpath(helpname); |
||
290 | |||
291 | if (GetPrivateProfileInt(misc, "HideConsole", 0, ininame)) |
||
292 | { |
||
293 | FreeConsole(); |
||
294 | nowait = 1; |
||
295 | } |
||
296 | |||
297 | conf.ConfirmExit = GetPrivateProfileInt(misc, "ConfirmExit", 0, ininame); |
||
298 | |||
299 | conf.sleepidle = GetPrivateProfileInt(misc, "ShareCPU", 0, ininame); |
||
300 | conf.highpriority = GetPrivateProfileInt(misc, "HighPriority", 0, ininame); |
||
301 | GetPrivateProfileString(misc, "SyncMode", "SOUND", line, sizeof line, ininame); |
||
302 | conf.SyncMode = SM_SOUND; |
||
303 | if(!strnicmp(line, "SOUND", 5)) |
||
304 | conf.SyncMode = SM_SOUND; |
||
305 | else if(!strnicmp(line, "VIDEO", 5)) |
||
306 | conf.SyncMode = SM_VIDEO; |
||
307 | else if(!strnicmp(line, "TSC", 3)) |
||
308 | conf.SyncMode = SM_TSC; |
||
309 | conf.HighResolutionTimer = GetPrivateProfileInt(misc, "HighResolutionTimer", 0, ininame); |
||
310 | conf.tape_traps = GetPrivateProfileInt(misc, "TapeTraps", 1, ininame); |
||
311 | conf.tape_autostart = GetPrivateProfileInt(misc, "TapeAutoStart", 1, ininame); |
||
312 | conf.EFF7_mask = GetPrivateProfileInt(misc, "EFF7mask", 0, ininame); |
||
313 | |||
314 | GetPrivateProfileString(rom, "ATM1", nil, conf.atm1_rom_path, sizeof conf.atm1_rom_path, ininame); |
||
315 | GetPrivateProfileString(rom, "ATM2", nil, conf.atm2_rom_path, sizeof conf.atm2_rom_path, ininame); |
||
316 | GetPrivateProfileString(rom, "ATM3", nil, conf.atm3_rom_path, sizeof conf.atm3_rom_path, ininame); |
||
317 | GetPrivateProfileString(rom, "SCORP", nil, conf.scorp_rom_path, sizeof conf.scorp_rom_path, ininame); |
||
318 | GetPrivateProfileString(rom, "PROFROM", nil, conf.prof_rom_path, sizeof conf.prof_rom_path, ininame); |
||
319 | GetPrivateProfileString(rom, "PROFI", nil, conf.profi_rom_path, sizeof conf.profi_rom_path, ininame); |
||
320 | //[vv] GetPrivateProfileString(rom, "KAY", nil, conf.kay_rom_path, sizeof conf.kay_rom_path, ininame); |
||
321 | GetPrivateProfileString(rom, "PLUS3", nil, conf.plus3_rom_path, sizeof conf.plus3_rom_path, ininame); |
||
322 | GetPrivateProfileString(rom, "QUORUM", nil, conf.quorum_rom_path, sizeof conf.quorum_rom_path, ininame); |
||
323 | #ifdef MOD_GSZ80 |
||
324 | GetPrivateProfileString(rom, "GS", nil, conf.gs_rom_path, sizeof conf.gs_rom_path, ininame); |
||
325 | addpath(conf.gs_rom_path); |
||
326 | #endif |
||
327 | addpath(conf.atm1_rom_path); |
||
328 | addpath(conf.atm2_rom_path); |
||
329 | addpath(conf.atm3_rom_path); |
||
330 | addpath(conf.scorp_rom_path); |
||
331 | addpath(conf.prof_rom_path); |
||
332 | addpath(conf.profi_rom_path); |
||
333 | addpath(conf.plus3_rom_path); |
||
334 | addpath(conf.quorum_rom_path); |
||
335 | //[vv] addpath(conf.kay_rom_path); |
||
336 | |||
337 | GetPrivateProfileString(rom, "ROMSET", "default", line, sizeof line, ininame); |
||
338 | if (*line) load_romset(&conf, line), conf.use_romset = 1; else conf.use_romset = 0; |
||
339 | |||
340 | conf.smuc = GetPrivateProfileInt(misc, "SMUC", 0, ininame); |
||
341 | GetPrivateProfileString(misc, "CMOS", nil, line, sizeof line, ininame); |
||
342 | conf.cmos = 0; |
||
343 | if (!strnicmp(line, "DALLAS", 6)) conf.cmos=1; |
||
344 | if (!strnicmp(line, "512Bu1", 6)) conf.cmos=2; |
||
345 | conf.cache = GetPrivateProfileInt(misc, "Cache", 0, ininame); |
||
346 | if (conf.cache && conf.cache!=16 && conf.cache!=32) conf.cache = 0; |
||
347 | GetPrivateProfileString(misc, "HIMEM", nil, line, sizeof line, ininame); |
||
348 | conf.mem_model = MM_PENTAGON; |
||
349 | unsigned i; //Alone Coder 0.36.7 |
||
350 | for (/*unsigned*/ i = 0; i < N_MM_MODELS; i++) |
||
351 | if (!strnicmp(line, mem_model[i].shortname, strlen(mem_model[i].shortname))) |
||
352 | conf.mem_model = mem_model[i].Model; |
||
353 | conf.ramsize = GetPrivateProfileInt(misc, "RamSize", 128, ininame); |
||
354 | conf.Sna128Lock = GetPrivateProfileInt(misc, "Sna128Lock", 1, ininame); |
||
355 | |||
356 | GetPrivateProfileString(misc, "DIR", nil, conf.workdir, sizeof conf.workdir, ininame); |
||
357 | |||
358 | GetCurrentDirectory(_countof(line), line); |
||
359 | SetCurrentDirectory(conf.workdir); |
||
360 | GetCurrentDirectory(_countof(temp.SnapDir), temp.SnapDir); |
||
361 | SetCurrentDirectory(line); |
||
362 | strcpy(temp.RomDir, temp.SnapDir); |
||
363 | strcpy(temp.HddDir, temp.SnapDir); |
||
364 | |||
365 | conf.reset_rom = RM_SOS; |
||
366 | GetPrivateProfileString(misc, "RESET", nil, line, sizeof line, ininame); |
||
367 | if (!strnicmp(line, "DOS", 3)) conf.reset_rom = RM_DOS; |
||
368 | if (!strnicmp(line, "MENU", 4)) conf.reset_rom = RM_128; |
||
369 | if (!strnicmp(line, "SYS", 3)) conf.reset_rom = RM_SYS; |
||
370 | |||
371 | GetPrivateProfileString(misc, "Modem", nil, line, sizeof line, ininame); |
||
372 | conf.modem_port = 0; |
||
373 | |||
374 | sscanf(line, "COM%d", &conf.modem_port); |
||
375 | |||
376 | conf.paper = GetPrivateProfileInt(ula, "Paper", 17989, ininame); |
||
377 | conf.t_line = GetPrivateProfileInt(ula, "Line", 224, ininame); |
||
378 | conf.intfq = GetPrivateProfileInt(ula, "int", 50, ininame); |
||
379 | conf.intlen = GetPrivateProfileInt(ula, "intlen", 32, ininame); |
||
380 | /*conf.frame*/frametime/*Alone Coder*/ = GetPrivateProfileInt(ula, "Frame", 71680, ininame); |
||
381 | conf.border_4T = GetPrivateProfileInt(ula, "4TBorder", 0, ininame); |
||
382 | conf.even_M1 = GetPrivateProfileInt(ula, "EvenM1", 0, ininame); |
||
383 | conf.floatbus = GetPrivateProfileInt(ula, "FloatBus", 0, ininame); |
||
384 | conf.floatdos = GetPrivateProfileInt(ula, "FloatDOS", 0, ininame); |
||
385 | conf.portff = GetPrivateProfileInt(ula, "PortFF", 0, ininame) != 0; |
||
386 | conf.mcx_small = GetPrivateProfileInt(ula, "mcx_small", 320, ininame); |
||
387 | conf.mcy_small = GetPrivateProfileInt(ula, "mcy_small", 240, ininame); |
||
388 | conf.b_top_small = GetPrivateProfileInt(ula, "b_top_small", 24, ininame); |
||
389 | conf.b_left_small = GetPrivateProfileInt(ula, "b_left_small", 32, ininame); |
||
390 | conf.mcx_full = GetPrivateProfileInt(ula, "mcx_full", 384, ininame); |
||
391 | conf.mcy_full = GetPrivateProfileInt(ula, "mcy_full", 288, ininame); |
||
392 | conf.b_top_full = GetPrivateProfileInt(ula, "b_top_full", 48, ininame); |
||
393 | conf.b_left_full = GetPrivateProfileInt(ula, "b_left_full", 64, ininame); |
||
394 | |||
395 | conf.ula_preset=-1; |
||
396 | add_presets(ula, "preset", &num_ula, ulapreset, &conf.ula_preset); |
||
397 | |||
398 | load_ula_preset(); |
||
399 | |||
400 | conf.atm.mem_swap = GetPrivateProfileInt(ula, "AtmMemSwap", 0, ininame); |
||
401 | conf.use_comp_pal = GetPrivateProfileInt(ula, "UsePalette", 1, ininame); |
||
402 | conf.profi_monochrome = GetPrivateProfileInt(ula, "ProfiMonochrome", 0, ininame); |
||
403 | |||
404 | conf.flashcolor = GetPrivateProfileInt(video, "FlashColor", 0, ininame); |
||
405 | conf.frameskip = GetPrivateProfileInt(video, "SkipFrame", 0, ininame); |
||
406 | conf.flip = (conf.SyncMode == SM_VIDEO) ? 1 : GetPrivateProfileInt(video, "VSync", 0, ininame); |
||
407 | conf.fullscr = GetPrivateProfileInt(video, "FullScr", 1, ininame); |
||
408 | conf.refresh = GetPrivateProfileInt(video, "Refresh", 0, ininame); |
||
409 | conf.frameskipmax = GetPrivateProfileInt(video, "SkipFrameMaxSpeed", 33, ininame); |
||
410 | conf.updateb = GetPrivateProfileInt(video, "Update", 1, ininame); |
||
411 | conf.ch_size = GetPrivateProfileInt(video, "ChunkSize", 0, ininame); |
||
412 | conf.noflic = GetPrivateProfileInt(video, "NoFlic", 0, ininame); |
||
413 | conf.alt_nf = GetPrivateProfileInt(video, "AltNoFlic", 0, ininame); |
||
414 | conf.scanbright = GetPrivateProfileInt(video, "ScanIntens", 66, ininame); |
||
415 | conf.pixelscroll = GetPrivateProfileInt(video, "PixelScroll", 0, ininame); |
||
416 | conf.detect_video = GetPrivateProfileInt(video, "DetectModel", 1, ininame); |
||
417 | conf.fontsize = 8; |
||
418 | |||
419 | conf.videoscale = GetPrivateProfileInt(video, "scale", 2, ininame); |
||
420 | |||
421 | conf.rsm.mix_frames = GetPrivateProfileInt(video, "rsm.frames", 8, ininame); |
||
422 | GetPrivateProfileString(video, "rsm.mode", nil, line, sizeof line, ininame); |
||
423 | conf.rsm.mode = RSM_FIR0; |
||
424 | if (!strnicmp(line, "FULL", 4)) conf.rsm.mode = RSM_FIR0; |
||
425 | if (!strnicmp(line, "2C", 2)) conf.rsm.mode = RSM_FIR1; |
||
426 | if (!strnicmp(line, "3C", 2)) conf.rsm.mode = RSM_FIR2; |
||
427 | if (!strnicmp(line, "SIMPLE", 6)) conf.rsm.mode = RSM_SIMPLE; |
||
428 | |||
429 | GetPrivateProfileString(video, "AtariPreset", nil, conf.atariset, sizeof conf.atariset, ininame); |
||
430 | |||
431 | GetPrivateProfileString(video, video, nil, line, sizeof line, ininame); |
||
432 | conf.render = 0; |
||
433 | for (i = 0; renders[i].func; i++) |
||
434 | if (!strnicmp(line, renders[i].nick, strlen(renders[i].nick))) |
||
435 | conf.render = i; |
||
436 | |||
437 | GetPrivateProfileString(video, "driver", nil, line, sizeof line, ininame); |
||
438 | conf.driver = DRIVER_DDRAW; |
||
439 | for (i = 0; drivers[i].nick; i++) |
||
440 | if (!strnicmp(line, drivers[i].nick, strlen(drivers[i].nick))) |
||
441 | conf.driver = i; |
||
442 | |||
443 | conf.fast_sl = GetPrivateProfileInt(video, "fastlines", 0, ininame); |
||
444 | |||
445 | GetPrivateProfileString(video, "Border", nil, line, sizeof line, ininame); |
||
446 | conf.bordersize = 1; |
||
447 | if (!strnicmp(line, "none", 4)) |
||
448 | conf.bordersize = 0; |
||
449 | else if (!strnicmp(line, "small", 5)) |
||
450 | conf.bordersize = 1; |
||
451 | else if (!strnicmp(line, "wide", 4)) |
||
452 | conf.bordersize = 2; |
||
453 | conf.minres = GetPrivateProfileInt(video, "MinRes", 0, ininame); |
||
454 | |||
455 | GetPrivateProfileString(video, "Hide", nil, line, sizeof line, ininame); |
||
456 | char *ptr = strchr(line, ';'); if (ptr) *ptr = 0; |
||
457 | for (ptr = line;;) |
||
458 | { |
||
459 | unsigned max = renders_count - 1; |
||
460 | for (i = 0; renders[i].func; i++) |
||
461 | { |
||
462 | unsigned sl = strlen(renders[i].nick); |
||
463 | if (!strnicmp(ptr, renders[i].nick, sl) && !isalnum(ptr[sl])) |
||
464 | { |
||
465 | ptr += sl; |
||
466 | memcpy(&renders[i], &renders[i+1], (sizeof *renders) * (max-i)); |
||
467 | break; |
||
468 | } |
||
469 | } |
||
470 | if (!*ptr++) |
||
471 | break; |
||
472 | } |
||
473 | |||
474 | GetPrivateProfileString(video, "ScrShotDir", ".", conf.scrshot_dir, sizeof(conf.scrshot_dir), ininame); |
||
475 | |||
476 | GetPrivateProfileString(video, "ScrShot", nil, line, sizeof line, ininame); |
||
477 | conf.scrshot = 0; |
||
478 | if(!strnicmp(line, "scr", 3)) |
||
479 | conf.scrshot = 0; |
||
480 | else if(!strnicmp(line, "bmp", 3)) |
||
481 | conf.scrshot = 1; |
||
482 | else if(!strnicmp(line, "png", 3)) |
||
483 | conf.scrshot = 2; |
||
484 | |||
485 | GetPrivateProfileString(video, "ffmpeg.exec", "ffmpeg.exe", conf.ffmpeg.exec, sizeof conf.ffmpeg.exec, ininame); |
||
486 | GetPrivateProfileString(video, "ffmpeg.parm", nil, conf.ffmpeg.parm, sizeof conf.ffmpeg.parm, ininame); |
||
487 | GetPrivateProfileString(video, "ffmpeg.vout", "video#.avi", conf.ffmpeg.vout, sizeof conf.ffmpeg.vout, ininame); |
||
488 | conf.ffmpeg.newcons = GetPrivateProfileInt(video, "ffmpeg.newconsole", 1, ininame); |
||
489 | |||
490 | conf.trdos_present = GetPrivateProfileInt(beta128, "beta128", 1, ininame); |
||
491 | conf.trdos_traps = GetPrivateProfileInt(beta128, "Traps", 1, ininame); |
||
492 | conf.wd93_nodelay = GetPrivateProfileInt(beta128, "Fast", 1, ininame); |
||
493 | conf.trdos_interleave = GetPrivateProfileInt(beta128, "IL", 1, ininame)-1; |
||
494 | if (conf.trdos_interleave > 2) conf.trdos_interleave = 0; |
||
495 | conf.fdd_noise = GetPrivateProfileInt(beta128, "Noise", 0, ininame); |
||
496 | GetPrivateProfileString(beta128, "BOOT", nil, conf.appendboot, sizeof conf.appendboot, ininame); |
||
497 | addpath(conf.appendboot); |
||
498 | |||
499 | conf.led.enabled = GetPrivateProfileInt(leds, "leds", 1, ininame); |
||
500 | conf.led.flash_ay_kbd = GetPrivateProfileInt(leds, "KBD_AY", 1, ininame); |
||
501 | conf.led.perf_t = GetPrivateProfileInt(leds, "PerfShowT", 0, ininame); |
||
502 | conf.led.bandBpp = GetPrivateProfileInt(leds, "BandBpp", 512, ininame); |
||
503 | if (conf.led.bandBpp != 64 && conf.led.bandBpp != 128 && conf.led.bandBpp != 256 && conf.led.bandBpp != 512) conf.led.bandBpp = 512; |
||
504 | |||
505 | static char nm[] = "AY\0Perf\0LOAD\0Input\0Time\0OSW\0MemBand"; |
||
506 | char *n2 = nm; |
||
507 | for (i = 0; i < NUM_LEDS; i++) { |
||
508 | GetPrivateProfileString(leds, n2, nil, line, sizeof line, ininame); |
||
509 | int x, y, z; unsigned r; n2 += strlen(n2)+1; |
||
510 | if (sscanf(line, "%d:%d,%d", &z, &x, &y) != 3) r = 0; |
||
511 | else r = (x & 0xFFFF) + ((y << 16) & 0x7FFFFFFF) + z*0x80000000; |
||
512 | *(&conf.led.ay+i) = r; |
||
513 | } |
||
514 | |||
515 | conf.sound.do_sound = do_sound_none; |
||
516 | GetPrivateProfileString(sound, "SoundDrv", nil, line, sizeof line, ininame); |
||
517 | if (!strnicmp(line, "wave", 4)) { |
||
518 | conf.sound.do_sound = do_sound_wave; |
||
519 | conf.soundbuffer = GetPrivateProfileInt(sound, "SoundBuffer", 0, ininame); |
||
520 | if (!conf.soundbuffer) conf.soundbuffer = 6; |
||
521 | if (conf.soundbuffer >= MAXWQSIZE) conf.soundbuffer = MAXWQSIZE-1; |
||
522 | } |
||
523 | if (!strnicmp(line, "ds", 2)) { |
||
524 | conf.sound.do_sound = do_sound_ds; |
||
525 | // conf.soundbuffer = GetPrivateProfileInt(sound, "DSoundBuffer", 1000, ininame); |
||
526 | // conf.soundbuffer *= 4; // 16-bit, stereo |
||
527 | } |
||
528 | |||
529 | conf.sound.enabled = GetPrivateProfileInt(sound, "Enabled", 1, ininame); |
||
530 | #ifdef MOD_GS |
||
531 | conf.sound.gsreset = GetPrivateProfileInt(sound, "GSReset", 0, ininame); |
||
532 | #endif |
||
533 | conf.sound.fq = GetPrivateProfileInt(sound, "Fq", 44100, ininame); |
||
534 | conf.sound.dsprimary = GetPrivateProfileInt(sound, "DSPrimary", 0, ininame); |
||
535 | |||
536 | conf.gs_type = 0; |
||
537 | #ifdef MOD_GS |
||
538 | GetPrivateProfileString(sound, "GSTYPE", nil, line, sizeof line, ininame); |
||
539 | #ifdef MOD_GSZ80 |
||
540 | if (!strnicmp(line, "Z80", 3)) conf.gs_type = 1; |
||
541 | #endif |
||
542 | #ifdef MOD_GSBASS |
||
543 | if (!strnicmp(line, "BASS", 4)) conf.gs_type = 2; |
||
544 | #endif |
||
545 | conf.gs_ramsize = GetPrivateProfileInt(ngs, "RamSize", 2048, ininame); |
||
546 | #endif |
||
547 | |||
548 | conf.soundfilter = GetPrivateProfileInt(sound, "SoundFilter", 0, ininame); //Alone Coder 0.36.4 |
||
549 | conf.RejectDC = GetPrivateProfileInt(sound, "RejectDC", 1, ininame); |
||
550 | |||
551 | conf.sound.beeper_vol = GetPrivateProfileInt(sound, "BeeperVol", 4000, ininame); |
||
552 | conf.sound.micout_vol = GetPrivateProfileInt(sound, "MicOutVol", 1000, ininame); |
||
553 | conf.sound.micin_vol = GetPrivateProfileInt(sound, "MicInVol", 1000, ininame); |
||
554 | conf.sound.ay_vol = GetPrivateProfileInt(sound, "AYVol", 4000, ininame); |
||
555 | conf.sound.covoxFB = GetPrivateProfileInt(sound, "CovoxFB", 0, ininame); |
||
556 | conf.sound.covoxFB_vol = GetPrivateProfileInt(sound, "CovoxFBVol", 8192, ininame); |
||
557 | conf.sound.covoxDD = GetPrivateProfileInt(sound, "CovoxDD", 0, ininame); |
||
558 | conf.sound.covoxDD_vol = GetPrivateProfileInt(sound, "CovoxDDVol", 4000, ininame); |
||
559 | conf.sound.sd = GetPrivateProfileInt(sound, "SD", 0, ininame); |
||
560 | conf.sound.sd_vol = GetPrivateProfileInt(sound, "SDVol", 4000, ininame); |
||
561 | conf.sound.saa1099 = GetPrivateProfileInt(sound, "Saa1099", 0, ininame); |
||
562 | |||
563 | #ifdef MOD_GS |
||
564 | conf.sound.gs_vol = GetPrivateProfileInt(sound, "GSVol", 8000, ininame); |
||
565 | #endif |
||
566 | |||
567 | #ifdef MOD_GSBASS |
||
568 | conf.sound.bass_vol = GetPrivateProfileInt(sound, "BASSVol", 8000, ininame); |
||
569 | #endif |
||
570 | |||
571 | conf.sound.saa1099fq = GetPrivateProfileInt(saa1099, "Fq", 8000000, ininame); |
||
572 | |||
573 | add_presets(ay, "VOLTAB", &num_ayvols, ayvols, &conf.sound.ay_vols); |
||
574 | add_presets(ay, "STEREO", &num_aystereo, aystereo, &conf.sound.ay_stereo); |
||
575 | conf.sound.ayfq = GetPrivateProfileInt(ay, "Fq", 1774400, ininame); |
||
576 | |||
577 | GetPrivateProfileString(ay, "Chip", nil, line, sizeof line, ininame); |
||
578 | conf.sound.ay_chip = SNDCHIP::CHIP_YM; |
||
579 | if (!strnicmp(line, "AY", 2)) conf.sound.ay_chip = SNDCHIP::CHIP_AY; |
||
580 | if (!strnicmp(line, "YM2203", 6)) conf.sound.ay_chip = SNDCHIP::CHIP_YM2203;else //Dexus |
||
581 | if (!strnicmp(line, "YM", 2)) conf.sound.ay_chip = SNDCHIP::CHIP_YM; |
||
582 | |||
583 | conf.sound.ay_samples = GetPrivateProfileInt(ay, "UseSamples", 0, ininame); |
||
584 | |||
585 | GetPrivateProfileString(ay, "Scheme", nil, line, sizeof line, ininame); |
||
586 | conf.sound.ay_scheme = AY_SCHEME_NONE; |
||
587 | if (!strnicmp(line, "default", 7)) conf.sound.ay_scheme = AY_SCHEME_SINGLE; |
||
588 | if (!strnicmp(line, "PSEUDO", 6)) conf.sound.ay_scheme = AY_SCHEME_PSEUDO; |
||
589 | if (!strnicmp(line, "QUADRO", 6)) conf.sound.ay_scheme = AY_SCHEME_QUADRO; |
||
590 | if (!strnicmp(line, "POS", 3)) conf.sound.ay_scheme = AY_SCHEME_POS; |
||
591 | if (!strnicmp(line, "CHRV", 4)) conf.sound.ay_scheme = AY_SCHEME_CHRV; |
||
592 | |||
593 | GetPrivateProfileString(input, "ZXKeyMap", "default", conf.zxkeymap, sizeof conf.zxkeymap, ininame); |
||
594 | for (i = 0; i < zxk_maps_count; i++) |
||
595 | { |
||
596 | if (!strnicmp(conf.zxkeymap, zxk_maps[i].name, strlen(zxk_maps[i].name))) |
||
597 | { |
||
598 | conf.input.active_zxk = &zxk_maps[i]; |
||
599 | break; |
||
600 | } |
||
601 | } |
||
602 | |||
603 | if(!conf.input.active_zxk) |
||
604 | { |
||
605 | errmsg("Invalid keyboard layout '%s' specified, default used", conf.zxkeymap); |
||
606 | conf.input.active_zxk = &zxk_maps[0]; // default |
||
607 | } |
||
608 | |||
609 | GetPrivateProfileString(input, "KeybLayout", "default", line, sizeof(line), ininame); |
||
610 | ptr = strtok(line, " ;"); |
||
611 | strcpy(conf.keyset, ptr ? ptr : line); |
||
612 | |||
613 | GetPrivateProfileString(input, "Mouse", nil, line, sizeof line, ininame); |
||
614 | conf.input.mouse = 0; |
||
615 | if (!strnicmp(line, "KEMPSTON", 8)) conf.input.mouse = 1; |
||
616 | if (!strnicmp(line, "AY", 2)) conf.input.mouse = 2; |
||
617 | //0.36.6 from 0.35b2 |
||
618 | GetPrivateProfileString(input, "Wheel", nil, line, sizeof line, ininame); |
||
619 | conf.input.mousewheel = MOUSE_WHEEL_NONE; |
||
620 | if (!strnicmp(line, "KEMPSTON", 8)) conf.input.mousewheel = MOUSE_WHEEL_KEMPSTON; |
||
621 | if (!strnicmp(line, "KEYBOARD", 8)) conf.input.mousewheel = MOUSE_WHEEL_KEYBOARD; |
||
622 | //~ |
||
623 | conf.input.joymouse = GetPrivateProfileInt(input, "JoyMouse", 0, ininame); |
||
624 | conf.input.mousescale = GetPrivateProfileInt(input, "MouseScale", 0, ininame); |
||
625 | conf.input.mouseswap = GetPrivateProfileInt(input, "SwapMouse", 0, ininame); |
||
626 | conf.input.kjoy = GetPrivateProfileInt(input, "KJoystick", 1, ininame); |
||
627 | conf.input.keymatrix = GetPrivateProfileInt(input, "Matrix", 1, ininame); |
||
628 | conf.input.firedelay = GetPrivateProfileInt(input, "FireRate", 1, ininame); |
||
629 | conf.input.altlock = GetPrivateProfileInt(input, "AltLock", 1, ininame); |
||
630 | conf.input.paste_hold = GetPrivateProfileInt(input, "HoldDelay", 2, ininame); |
||
631 | conf.input.paste_release = GetPrivateProfileInt(input, "ReleaseDelay", 5, ininame); |
||
632 | conf.input.paste_newline = GetPrivateProfileInt(input, "NewlineDelay", 20, ininame); |
||
633 | conf.input.keybpcmode = GetPrivateProfileInt(input, "KeybPCMode", 0, ininame); |
||
634 | conf.atm.xt_kbd = GetPrivateProfileInt(input, "ATMKBD", 0, ininame); |
||
635 | conf.input.JoyId = GetPrivateProfileInt(input, "Joy", 0, ininame); |
||
636 | |||
637 | GetPrivateProfileString(input, "Fire", "0", line, sizeof line, ininame); |
||
638 | conf.input.firenum = 0; conf.input.fire = 0; |
||
639 | zxkeymap *active_zxk = conf.input.active_zxk; |
||
640 | for (i = 0; i < active_zxk->zxk_size; i++) |
||
641 | if (!stricmp(line, active_zxk->zxk[i].name)) |
||
642 | { conf.input.firenum = i; break; } |
||
643 | |||
644 | char buff[0x7000]; |
||
645 | GetPrivateProfileSection(colors, buff, sizeof buff, ininame); |
||
646 | GetPrivateProfileString(colors, "color", "default", line, sizeof line, ininame); |
||
647 | conf.pal = 0; |
||
648 | |||
649 | for (i = 1, ptr = buff; i < _countof(pals); ptr += strlen(ptr)+1) |
||
650 | { |
||
651 | if (!*ptr) |
||
652 | break; |
||
653 | if (!isalnum(*ptr) || !strnicmp(ptr, "color=", 6)) |
||
654 | continue; |
||
655 | char *ptr1 = strchr(ptr, '='); |
||
656 | if (!ptr1) |
||
657 | continue; |
||
658 | *ptr1 = 0; strcpy(pals[i].name, ptr); ptr = ptr1+1; |
||
659 | sscanf(ptr, "%02X,%02X,%02X,%02X,%02X,%02X:%X,%X,%X;%X,%X,%X;%X,%X,%X", |
||
660 | &pals[i].ZZ, &pals[i].ZN, &pals[i].NN, |
||
661 | &pals[i].NB, &pals[i].BB, &pals[i].ZB, |
||
662 | &pals[i].r11, &pals[i].r12, &pals[i].r13, |
||
663 | &pals[i].r21, &pals[i].r22, &pals[i].r23, |
||
664 | &pals[i].r31, &pals[i].r32, &pals[i].r33); |
||
665 | |||
666 | pals[i].r11 = min(pals[i].r11, 256U); |
||
667 | pals[i].r12 = min(pals[i].r12, 256U); |
||
668 | pals[i].r13 = min(pals[i].r13, 256U); |
||
669 | |||
670 | pals[i].r21 = min(pals[i].r21, 256U); |
||
671 | pals[i].r22 = min(pals[i].r22, 256U); |
||
672 | pals[i].r23 = min(pals[i].r23, 256U); |
||
673 | |||
674 | pals[i].r31 = min(pals[i].r31, 256U); |
||
675 | pals[i].r32 = min(pals[i].r32, 256U); |
||
676 | pals[i].r33 = min(pals[i].r33, 256U); |
||
677 | |||
678 | if (!strnicmp(line, pals[i].name, strlen(pals[i].name))) |
||
679 | conf.pal = i; |
||
680 | i++; |
||
681 | } |
||
682 | conf.num_pals = i; |
||
683 | |||
684 | GetPrivateProfileString(hdd, "SCHEME", nil, line, sizeof line, ininame); |
||
685 | conf.ide_scheme = IDE_NONE; |
||
686 | if(!strnicmp(line, "ATM", 3)) |
||
687 | conf.ide_scheme = IDE_ATM; |
||
688 | else if(!strnicmp(line, "NEMO-DIVIDE", 11)) |
||
689 | conf.ide_scheme = IDE_NEMO_DIVIDE; |
||
690 | else if(!strnicmp(line, "NEMO-A8", 7)) |
||
691 | conf.ide_scheme = IDE_NEMO_A8; |
||
692 | else if(!strnicmp(line, "NEMO", 4)) |
||
693 | conf.ide_scheme = IDE_NEMO; |
||
694 | else if(!strnicmp(line, "SMUC", 4)) |
||
695 | conf.ide_scheme = IDE_SMUC; |
||
696 | else if(!strnicmp(line, "PROFI", 5)) |
||
697 | conf.ide_scheme = IDE_PROFI; |
||
698 | else if(!strnicmp(line, "DIVIDE", 6)) |
||
699 | conf.ide_scheme = IDE_DIVIDE; |
||
700 | |||
701 | conf.ide_skip_real = GetPrivateProfileInt(hdd, "SkipReal", 0, ininame); |
||
702 | GetPrivateProfileString(hdd, "CDROM", "SPTI", line, sizeof line, ininame); |
||
703 | conf.cd_aspi = !strnicmp(line, "ASPI", 4) ? 1 : 0; |
||
704 | |||
705 | for (int ide_device = 0; ide_device < 2; ide_device++) |
||
706 | { |
||
707 | char param[32]; |
||
708 | sprintf(param, "LBA%d", ide_device); |
||
709 | |||
710 | GetPrivateProfileString(hdd, param, "0", line, sizeof(line), ininame); |
||
711 | conf.ide[ide_device].lba = strtoull(line, 0, 10); |
||
712 | sprintf(param, "CHS%d", ide_device); |
||
713 | GetPrivateProfileString(hdd, param, "0/0/0", line, sizeof line, ininame); |
||
714 | unsigned c, h, s; |
||
715 | |||
716 | sscanf(line, "%u/%u/%u", &c, &h, &s); |
||
717 | if(h > 16) |
||
718 | { |
||
719 | sprintf(line, "HDD%d heads count > 16 : %u\n", ide_device, h); |
||
720 | errexit(line); |
||
721 | } |
||
722 | if(s > 63) |
||
723 | { |
||
724 | sprintf(line, "error HDD%d sectors count > 63 : %u\n", ide_device, s); |
||
725 | errexit(line); |
||
726 | } |
||
727 | if(c > 16383) |
||
728 | { |
||
729 | sprintf(line, "error HDD%d cylinders count > 16383 : %u\n", ide_device, c); |
||
730 | errexit(line); |
||
731 | } |
||
732 | |||
733 | conf.ide[ide_device].c = c; |
||
734 | conf.ide[ide_device].h = h; |
||
735 | conf.ide[ide_device].s = s; |
||
736 | |||
737 | sprintf(param, "Image%d", ide_device); |
||
738 | GetPrivateProfileString(hdd, param, nil, conf.ide[ide_device].image, sizeof conf.ide[ide_device].image, ininame); |
||
739 | |||
740 | if(conf.ide[ide_device].image[0] && |
||
741 | conf.ide[ide_device].image[0] != '<') |
||
742 | addpath(conf.ide[ide_device].image); |
||
743 | |||
744 | sprintf(param, "HD%dRO", ide_device); |
||
745 | conf.ide[ide_device].readonly = (BYTE)GetPrivateProfileInt(hdd, param, 0, ininame); |
||
746 | sprintf(param, "CD%d", ide_device); |
||
747 | conf.ide[ide_device].cd = (BYTE)GetPrivateProfileInt(hdd, param, 0, ininame); |
||
748 | |||
749 | if(!conf.ide[ide_device].cd && |
||
750 | conf.ide[ide_device].lba == 0 && |
||
751 | conf.ide[ide_device].image[0] && |
||
752 | conf.ide[ide_device].image[0] != '<') |
||
753 | { |
||
754 | int file = open(conf.ide[ide_device].image, O_RDONLY | O_BINARY, S_IREAD); |
||
755 | if(file >= 0) |
||
756 | { |
||
757 | __int64 sz = _filelengthi64(file); |
||
758 | close(file); |
||
759 | conf.ide[ide_device].lba = unsigned(sz / 512); |
||
760 | } |
||
761 | } |
||
762 | } |
||
763 | |||
764 | addpath(line, "CMOS"); |
||
765 | FILE *f0 = fopen(line, "rb"); |
||
766 | if (f0) |
||
767 | { |
||
768 | fread(cmos, 1, sizeof cmos, f0); |
||
769 | fclose(f0); |
||
770 | } |
||
771 | else |
||
772 | cmos[0x11] = 0xAA; |
||
773 | |||
774 | addpath(line, "NVRAM"); |
||
775 | if ((f0 = fopen(line, "rb"))) |
||
776 | { |
||
777 | fread(nvram, 1, sizeof nvram, f0); |
||
778 | fclose(f0); |
||
779 | } |
||
780 | |||
781 | if(conf.gs_type == 1) // z80gs mode |
||
782 | { |
||
783 | GetPrivateProfileString(ngs, "SDCARD", 0, conf.ngs_sd_card_path, _countof(conf.ngs_sd_card_path), ininame); |
||
784 | addpath(conf.ngs_sd_card_path); |
||
785 | if(conf.ngs_sd_card_path[0]) |
||
786 | printf("NGS SDCARD=`%s'\n", conf.ngs_sd_card_path); |
||
787 | } |
||
788 | |||
789 | conf.zc = GetPrivateProfileInt(misc, "ZC", 0, ininame); |
||
790 | if(conf.zc) |
||
791 | { |
||
792 | GetPrivateProfileString(zc, "SDCARD", 0, conf.zc_sd_card_path, _countof(conf.zc_sd_card_path), ininame); |
||
793 | addpath(conf.zc_sd_card_path); |
||
794 | if(conf.zc_sd_card_path[0]) |
||
795 | printf("ZC SDCARD=`%s'\n", conf.zc_sd_card_path); |
||
796 | } |
||
797 | |||
798 | GetPrivateProfileString("AUTOLOAD", "DefaultDrive", nil, line, sizeof(line), ininame); |
||
799 | if(!strnicmp(line, "Auto", 4)) |
||
800 | DefaultDrive = -1; |
||
801 | else if(!strnicmp(line, "A", 1)) |
||
802 | DefaultDrive = 0; |
||
803 | else if(!strnicmp(line, "B", 1)) |
||
804 | DefaultDrive = 1; |
||
805 | else if(!strnicmp(line, "C", 1)) |
||
806 | DefaultDrive = 2; |
||
807 | else if(!strnicmp(line, "D", 1)) |
||
808 | DefaultDrive = 3; |
||
809 | |||
810 | load_arch(ininame); |
||
811 | loadkeys(ac_main); |
||
812 | #ifdef MOD_MONITOR |
||
813 | loadkeys(ac_main_xt); |
||
814 | loadkeys(ac_regs); |
||
815 | loadkeys(ac_trace); |
||
816 | loadkeys(ac_mem); |
||
817 | #endif |
||
818 | temp.scale = GetPrivateProfileInt(video, "winscale", 1, ininame); |
||
819 | } |
||
820 | |||
821 | void autoload() |
||
822 | { |
||
823 | static char autoload[] = "AUTOLOAD"; |
||
824 | char line[512]; |
||
825 | |||
826 | for (int disk = 0; disk < 4; disk++) { |
||
827 | char key[8]; sprintf(key, "disk%c", 'A'+disk); |
||
828 | GetPrivateProfileString(autoload, key, nil, line, sizeof line, ininame); |
||
829 | if (!*line) continue; |
||
830 | addpath(line); |
||
831 | trd_toload = disk; |
||
832 | if (!loadsnap(line)) errmsg("failed to autoload <%s>", line); |
||
833 | } |
||
834 | |||
835 | GetPrivateProfileString(autoload, "snapshot", nil, line, sizeof line, ininame); |
||
836 | if (!*line) return; |
||
837 | addpath(line); |
||
838 | if (!loadsnap(line)) { color(CONSCLR_ERROR); printf("failed to start snapshot <%s>\n", line); } |
||
839 | } |
||
840 | |||
841 | void apply_memory() |
||
842 | { |
||
843 | #ifdef MOD_GSZ80 |
||
844 | if (conf.gs_type == 1) |
||
845 | { |
||
846 | if(load_rom(conf.gs_rom_path, ROM_GS_M, 32) != 512) // 512k rom |
||
847 | { |
||
848 | errmsg("invalid ROM size for NGS (need 512kb), NGS disabled\n"); |
||
849 | conf.gs_type = 0; |
||
850 | } |
||
851 | } |
||
852 | #endif |
||
853 | |||
854 | if (conf.ramsize != 128 && conf.ramsize != 256 && conf.ramsize != 512 && conf.ramsize != 1024 && conf.ramsize != 4096) |
||
855 | conf.ramsize = 0; |
||
856 | if (!(mem_model[conf.mem_model].availRAMs & conf.ramsize)) { |
||
857 | conf.ramsize = mem_model[conf.mem_model].defaultRAM; |
||
858 | color(CONSCLR_ERROR); |
||
859 | printf("invalid RAM size for %s, using default (%dK)\n", |
||
860 | mem_model[conf.mem_model].fullname, conf.ramsize); |
||
861 | } |
||
862 | |||
863 | switch(conf.mem_model) |
||
864 | { |
||
865 | case MM_ATM710: |
||
866 | case MM_ATM3: |
||
867 | base_sos_rom = ROM_BASE_M + 0*PAGE; |
||
868 | base_dos_rom = ROM_BASE_M + 1*PAGE; |
||
869 | base_128_rom = ROM_BASE_M + 2*PAGE; |
||
870 | base_sys_rom = ROM_BASE_M + 3*PAGE; |
||
871 | break; |
||
872 | |||
873 | case MM_ATM450: |
||
874 | case MM_PROFI: |
||
875 | base_sys_rom = ROM_BASE_M + 0*PAGE; |
||
876 | base_dos_rom = ROM_BASE_M + 1*PAGE; |
||
877 | base_128_rom = ROM_BASE_M + 2*PAGE; |
||
878 | base_sos_rom = ROM_BASE_M + 3*PAGE; |
||
879 | break; |
||
880 | |||
881 | case MM_PLUS3: |
||
882 | base_128_rom = ROM_BASE_M + 0*PAGE; |
||
883 | base_sys_rom = ROM_BASE_M + 1*PAGE; |
||
884 | base_dos_rom = ROM_BASE_M + 2*PAGE; |
||
885 | base_sos_rom = ROM_BASE_M + 3*PAGE; |
||
886 | break; |
||
887 | |||
888 | case MM_QUORUM: |
||
889 | base_sys_rom = ROM_BASE_M + 0*PAGE; |
||
890 | base_dos_rom = ROM_BASE_M + 1*PAGE; |
||
891 | base_128_rom = ROM_BASE_M + 2*PAGE; |
||
892 | base_sos_rom = ROM_BASE_M + 3*PAGE; |
||
893 | break; |
||
894 | |||
895 | /* |
||
896 | case MM_KAY: |
||
897 | base_128_rom = ROM_BASE_M + 0*PAGE; |
||
898 | base_sos_rom = ROM_BASE_M + 1*PAGE; |
||
899 | base_dos_rom = ROM_BASE_M + 2*PAGE; |
||
900 | base_sys_rom = ROM_BASE_M + 3*PAGE; |
||
901 | break; |
||
902 | */ |
||
903 | |||
904 | default: |
||
905 | base_128_rom = ROM_BASE_M + 0*PAGE; |
||
906 | base_sos_rom = ROM_BASE_M + 1*PAGE; |
||
907 | base_sys_rom = ROM_BASE_M + 2*PAGE; |
||
908 | base_dos_rom = ROM_BASE_M + 3*PAGE; |
||
909 | } |
||
910 | |||
911 | unsigned romsize; |
||
912 | if (conf.use_romset) |
||
913 | { |
||
914 | if (!load_rom(conf.sos_rom_path, base_sos_rom)) |
||
915 | errexit("failed to load BASIC48 ROM"); |
||
916 | if (!load_rom(conf.zx128_rom_path, base_128_rom) && conf.reset_rom == RM_128) |
||
917 | conf.reset_rom = RM_SOS; |
||
918 | if (!load_rom(conf.dos_rom_path, base_dos_rom)) |
||
919 | conf.trdos_present = 0; |
||
920 | if (!load_rom(conf.sys_rom_path, base_sys_rom) && conf.reset_rom == RM_SYS) |
||
921 | conf.reset_rom = RM_SOS; |
||
922 | romsize = 64; |
||
923 | } |
||
924 | else |
||
925 | { |
||
926 | if (conf.mem_model == MM_ATM710 || conf.mem_model == MM_ATM3) |
||
927 | { |
||
928 | romsize = load_rom(conf.mem_model == MM_ATM710 ? conf.atm2_rom_path : conf.atm3_rom_path, ROM_BASE_M, 64); |
||
929 | if (romsize != 64 && romsize != 128 && romsize != 512 && romsize != 1024) |
||
930 | errexit("invalid ROM size for ATM bios"); |
||
931 | unsigned char *lastpage = ROM_BASE_M + (romsize - 64) * 1024; |
||
932 | base_sos_rom = lastpage + 0*PAGE; |
||
933 | base_dos_rom = lastpage + 1*PAGE; |
||
934 | base_128_rom = lastpage + 2*PAGE; |
||
935 | base_sys_rom = lastpage + 3*PAGE; |
||
936 | } |
||
937 | else if (conf.mem_model == MM_PROFSCORP) |
||
938 | { |
||
939 | romsize = load_rom(conf.prof_rom_path, ROM_BASE_M, 16); |
||
940 | if (romsize != 64 && romsize != 128 && romsize != 256) |
||
941 | errexit("invalid PROF-ROM size"); |
||
942 | } |
||
943 | else |
||
944 | { |
||
945 | char *romname = 0; |
||
946 | switch(conf.mem_model) |
||
947 | { |
||
948 | case MM_PROFI: romname = conf.profi_rom_path; break; |
||
949 | case MM_SCORP: romname = conf.scorp_rom_path; break; |
||
950 | //[vv] case MM_KAY: romname = conf.kay_rom_path; break; |
||
951 | case MM_ATM450: romname = conf.atm1_rom_path; break; |
||
952 | case MM_PLUS3: romname = conf.plus3_rom_path; break; |
||
953 | case MM_QUORUM: romname = conf.quorum_rom_path; break; |
||
954 | |||
955 | default: |
||
956 | errexit("ROMSET should be defined for this memory model"); |
||
957 | } |
||
958 | |||
959 | romsize = load_rom(romname, ROM_BASE_M, 64); |
||
960 | if (romsize != 64) |
||
961 | errexit("invalid ROM filesize"); |
||
962 | } |
||
963 | } |
||
964 | |||
965 | if (conf.mem_model == MM_PROFSCORP) |
||
966 | { |
||
967 | temp.profrom_mask = 0; |
||
968 | if (romsize == 128) |
||
969 | temp.profrom_mask = 1; |
||
970 | if (romsize == 256) |
||
971 | temp.profrom_mask = 3; |
||
972 | |||
973 | comp.profrom_bank &= temp.profrom_mask; |
||
974 | set_scorp_profrom(0); |
||
975 | } |
||
976 | |||
977 | #ifdef MOD_MONITOR |
||
978 | load_labels(conf.sos_labels_path, base_sos_rom, 0x4000); |
||
979 | #endif |
||
980 | |||
981 | temp.gs_ram_mask = (conf.gs_ramsize-1) >> 4; |
||
982 | temp.ram_mask = (conf.ramsize-1) >> 4; |
||
983 | temp.rom_mask = (romsize-1) >> 4; |
||
984 | set_banks(); |
||
985 | |||
986 | for(unsigned i = 0; i < CpuMgr.GetCount(); i++) |
||
987 | { |
||
988 | Z80 &cpu = CpuMgr.Cpu(i); |
||
989 | cpu.dbgchk = isbrk(cpu); |
||
990 | } |
||
991 | } |
||
992 | |||
993 | |||
994 | void applyconfig() |
||
995 | { |
||
996 | // printf("%s\n", __FUNCTION__); |
||
997 | load_atm_font(); |
||
998 | |||
999 | //[vv] disable turbo |
||
1000 | comp.pEFF7 |= EFF7_GIGASCREEN; |
||
1001 | |||
1002 | //Alone Coder 0.36.4 |
||
1003 | conf.frame = frametime; |
||
1004 | cpu.SetTpi(conf.frame); |
||
1005 | /* |
||
1006 | if ((conf.mem_model == MM_PENTAGON)&&(comp.pEFF7 & EFF7_GIGASCREEN)) |
||
1007 | conf.frame = 71680; |
||
1008 | */ |
||
1009 | //~Alone Coder |
||
1010 | temp.ticks_frame = (unsigned)(temp.cpufq / double(conf.intfq) + 1.0); |
||
1011 | loadzxkeys(&conf); |
||
1012 | apply_memory(); |
||
1013 | |||
1014 | temp.snd_frame_ticks = (conf.sound.fq << TICK_FF) / conf.intfq; |
||
1015 | temp.snd_frame_samples = temp.snd_frame_ticks >> TICK_FF; |
||
1016 | temp.frameskip = conf.sound.enabled? conf.frameskip : conf.frameskipmax; |
||
1017 | |||
1018 | input.firedelay = 1; // if conf.input.fire changed |
||
1019 | input.clear_zx(); |
||
1020 | |||
1021 | modem.open(conf.modem_port); |
||
1022 | |||
1023 | load_atariset(); |
||
1024 | apply_video(); |
||
1025 | apply_sound(); |
||
1026 | |||
1027 | hdd.dev[0].configure(conf.ide+0); |
||
1028 | hdd.dev[1].configure(conf.ide+1); |
||
1029 | if (conf.atm.xt_kbd) input.atm51.clear(); |
||
1030 | |||
1031 | if(conf.gs_type == 1) |
||
1032 | { |
||
1033 | SdCard.Close(); |
||
1034 | SdCard.Open(conf.ngs_sd_card_path); |
||
1035 | } |
||
1036 | |||
1037 | if(conf.zc) |
||
1038 | { |
||
1039 | Zc.Close(); |
||
1040 | Zc.Open(conf.zc_sd_card_path); |
||
1041 | } |
||
1042 | |||
1043 | setpal(0); |
||
1044 | } |
||
1045 | |||
1046 | void load_arch(const char *fname) |
||
1047 | { |
||
1048 | GetPrivateProfileString("ARC", "SkipFiles", nil, skiparc, sizeof skiparc, fname); |
||
1049 | char *p; //Alone Coder 0.36.7 |
||
1050 | for (/*char * */p = skiparc;;) { |
||
1051 | char *nxt = strchr(p, ';'); |
||
1052 | if (!nxt) break; |
||
1053 | *nxt = 0; p = nxt+1; |
||
1054 | } |
||
1055 | p[strlen(p)+1] = 0; |
||
1056 | |||
1057 | GetPrivateProfileSection("ARC", arcbuffer, sizeof arcbuffer, fname); |
||
1058 | for (char *x = arcbuffer; *x; ) { |
||
1059 | char *newx = x + strlen(x)+1; |
||
1060 | char *y = strchr(x, '='); |
||
1061 | if (!y) { |
||
1062 | ignore_line: |
||
1063 | memcpy(x, newx, sizeof arcbuffer - (newx-arcbuffer)); |
||
1064 | } else { |
||
1065 | *y = 0; if (!stricmp(x, "SkipFiles")) goto ignore_line; |
||
1066 | x = newx; |
||
1067 | } |
||
1068 | } |
||
1069 | } |
||
1070 | |||
1071 | void loadkeys(action *table) |
||
1072 | { |
||
1073 | unsigned num[0x300], i = 0; |
||
1074 | unsigned j; //Alone Coder 0.36.7 |
||
1075 | if (!table->name) |
||
1076 | return; // empty table (can't sort) |
||
1077 | for (action *p = table; p->name; p++, i++) |
||
1078 | { |
||
1079 | char line[0x400]; |
||
1080 | GetPrivateProfileString("SYSTEM.KEYS", p->name, "`", line, sizeof line, ininame); |
||
1081 | if (*line == '`') |
||
1082 | { |
||
1083 | errmsg("keydef for %s not found", p->name); |
||
1084 | load_errors = 1; |
||
1085 | bad_key: |
||
1086 | p->k1 = 0xFE, p->k2 = 0xFF, p->k3 = 0xFD; |
||
1087 | continue; |
||
1088 | } |
||
1089 | char *s = strchr(line, ';'); |
||
1090 | if(s) |
||
1091 | *s = 0; |
||
1092 | p->k1 = p->k2 = p->k3 = p->k4 = 0; num[i] = 0; |
||
1093 | for (s = line;;) |
||
1094 | { |
||
1095 | while (*s == ' ') s++; |
||
1096 | if (!*s) |
||
1097 | break; |
||
1098 | char *s1 = s; |
||
1099 | while (isalnum(*s)) |
||
1100 | s++; |
||
1101 | for (j = 0; j < pckeys_count; j++) |
||
1102 | { |
||
1103 | if ((int)strlen(pckeys[j].name)==s-s1 && !strnicmp(s1, pckeys[j].name, s-s1)) |
||
1104 | { |
||
1105 | switch (num[i]) |
||
1106 | { |
||
1107 | case 0: p->k1 = pckeys[j].virtkey; break; |
||
1108 | case 1: p->k2 = pckeys[j].virtkey; break; |
||
1109 | case 2: p->k3 = pckeys[j].virtkey; break; |
||
1110 | case 3: p->k4 = pckeys[j].virtkey; break; |
||
1111 | default: |
||
1112 | color(CONSCLR_ERROR); |
||
1113 | printf("warning: too many keys in %s=%s\n", p->name, line); |
||
1114 | load_errors = 1; |
||
1115 | } |
||
1116 | num[i]++; |
||
1117 | break; |
||
1118 | } |
||
1119 | } |
||
1120 | if (j == pckeys_count) |
||
1121 | { |
||
1122 | color(CONSCLR_ERROR); |
||
1123 | char x = *s; *s = 0; |
||
1124 | printf("bad key: %s\n", s1); *s = x; |
||
1125 | load_errors = 1; |
||
1126 | } |
||
1127 | } |
||
1128 | if (!num[i]) |
||
1129 | goto bad_key; |
||
1130 | } |
||
1131 | |||
1132 | // sort keys |
||
1133 | for (unsigned k = 0; k < i-1; k++) |
||
1134 | { |
||
1135 | unsigned max = k; |
||
1136 | for (unsigned l = k+1; l < i; l++) |
||
1137 | if (num[l] > num[max]) |
||
1138 | max = l; |
||
1139 | |||
1140 | action tmp = table[k]; |
||
1141 | table[k] = table[max]; |
||
1142 | table[max] = tmp; |
||
1143 | |||
1144 | unsigned tm = num[k]; |
||
1145 | num[k] = num[max]; |
||
1146 | num[max] = tm; |
||
1147 | } |
||
1148 | } |
||
1149 | |||
1150 | void loadzxkeys(CONFIG *conf) |
||
1151 | { |
||
1152 | char section[0x200]; |
||
1153 | sprintf(section, "ZX.KEYS.%s", conf->keyset); |
||
1154 | char line[0x300]; |
||
1155 | char *s; //Alone Coder 0.36.7 |
||
1156 | unsigned k; //Alone Coder 0.36.7 |
||
1157 | zxkeymap *active_zxk = conf->input.active_zxk; |
||
1158 | |||
1159 | for (unsigned i = 0; i < VK_MAX; i++) |
||
1160 | { |
||
1161 | inports[i].port1 = inports[i].port2 = &input.kjoy; |
||
1162 | inports[i].mask1 = inports[i].mask2 = 0xFF; |
||
1163 | for (unsigned j = 0; j < pckeys_count; j++) |
||
1164 | { |
||
1165 | if (pckeys[j].virtkey == i) |
||
1166 | { |
||
1167 | GetPrivateProfileString(section, pckeys[j].name, "", line, sizeof line, ininame); |
||
1168 | s = strtok(line, " ;"); |
||
1169 | if(s) |
||
1170 | { |
||
1171 | for(k = 0; k < active_zxk->zxk_size; k++) |
||
1172 | { |
||
1173 | if (!stricmp(s, active_zxk->zxk[k].name)) |
||
1174 | { |
||
1175 | inports[i].port1 = active_zxk->zxk[k].port; |
||
1176 | inports[i].mask1 = active_zxk->zxk[k].mask; |
||
1177 | switch(i) |
||
1178 | { |
||
1179 | case DIK_CONTROL: |
||
1180 | inports[DIK_LCONTROL].port1 = active_zxk->zxk[k].port; |
||
1181 | inports[DIK_LCONTROL].mask1 = active_zxk->zxk[k].mask; |
||
1182 | inports[DIK_RCONTROL].port1 = active_zxk->zxk[k].port; |
||
1183 | inports[DIK_RCONTROL].mask1 = active_zxk->zxk[k].mask; |
||
1184 | break; |
||
1185 | |||
1186 | case DIK_SHIFT: |
||
1187 | inports[DIK_LSHIFT].port1 = active_zxk->zxk[k].port; |
||
1188 | inports[DIK_LSHIFT].mask1 = active_zxk->zxk[k].mask; |
||
1189 | inports[DIK_RSHIFT].port1 = active_zxk->zxk[k].port; |
||
1190 | inports[DIK_RSHIFT].mask1 = active_zxk->zxk[k].mask; |
||
1191 | break; |
||
1192 | |||
1193 | case DIK_MENU: |
||
1194 | inports[DIK_LMENU].port1 = active_zxk->zxk[k].port; |
||
1195 | inports[DIK_LMENU].mask1 = active_zxk->zxk[k].mask; |
||
1196 | inports[DIK_RMENU].port1 = active_zxk->zxk[k].port; |
||
1197 | inports[DIK_RMENU].mask1 = active_zxk->zxk[k].mask; |
||
1198 | break; |
||
1199 | } |
||
1200 | break; |
||
1201 | } |
||
1202 | } |
||
1203 | } |
||
1204 | s = strtok(NULL, " ;"); |
||
1205 | if(s) |
||
1206 | { |
||
1207 | for (k = 0; k < active_zxk->zxk_size; k++) |
||
1208 | { |
||
1209 | if (!stricmp(s, active_zxk->zxk[k].name)) |
||
1210 | { |
||
1211 | inports[i].port2 = active_zxk->zxk[k].port; |
||
1212 | inports[i].mask2 = active_zxk->zxk[k].mask; |
||
1213 | |||
1214 | switch(i) |
||
1215 | { |
||
1216 | case DIK_CONTROL: |
||
1217 | inports[DIK_LCONTROL].port2 = active_zxk->zxk[k].port; |
||
1218 | inports[DIK_LCONTROL].mask2 = active_zxk->zxk[k].mask; |
||
1219 | inports[DIK_RCONTROL].port2 = active_zxk->zxk[k].port; |
||
1220 | inports[DIK_RCONTROL].mask2 = active_zxk->zxk[k].mask; |
||
1221 | break; |
||
1222 | |||
1223 | case DIK_SHIFT: |
||
1224 | inports[DIK_LSHIFT].port2 = active_zxk->zxk[k].port; |
||
1225 | inports[DIK_LSHIFT].mask2 = active_zxk->zxk[k].mask; |
||
1226 | inports[DIK_RSHIFT].port2 = active_zxk->zxk[k].port; |
||
1227 | inports[DIK_RSHIFT].mask2 = active_zxk->zxk[k].mask; |
||
1228 | break; |
||
1229 | |||
1230 | case DIK_MENU: |
||
1231 | inports[DIK_LMENU].port2 = active_zxk->zxk[k].port; |
||
1232 | inports[DIK_LMENU].mask2 = active_zxk->zxk[k].mask; |
||
1233 | inports[DIK_RMENU].port2 = active_zxk->zxk[k].port; |
||
1234 | inports[DIK_RMENU].mask2 = active_zxk->zxk[k].mask; |
||
1235 | break; |
||
1236 | } |
||
1237 | break; |
||
1238 | } |
||
1239 | } |
||
1240 | } |
||
1241 | break; |
||
1242 | } |
||
1243 | } |
||
1244 | } |
||
1245 | } |