forked from jeremyrayner/beebem-rg350
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbeebconfig.cc
853 lines (695 loc) · 23.1 KB
/
beebconfig.cc
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
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
#include "beebconfig.h"
#include "sysvia.h"
#include "main.h"
#include "disc8271.h"
#include "video.h"
#include "keyboard.h"
#include "messagebox.h"
#include "messages.h"
#include "stick.h"
//#include "virtualkeyboard.h"
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <gui/gui.h>
#include <sys/stat.h>
/* BeebEm configuration:
*/
BeebConfig config;
void ClearXX(void)
{
// unsigned char *p = (unsigned char*) config.files.xx;
//
// for(int i=0; i<1024*5; i++)
// *p++ = 'X';
}
void PrintXX(char* name_p)
{
// unsigned char *p = (unsigned char*) config.files.xx;
//
// printf("%s:\n", name_p);
//
// for(int i=0; i<1024*5; i++) {
// printf("%c", (int) *p == 0x00 ? '.' : *p);
// p++;
// }
//
// printf("\n");
// SDL_Delay(1000);
}
static int LoadDiscImage(const char *filename_p)
{
char filepath[256+1], mappingpath[256+1], *tmp_p;
FILE *test;
int is_invalid_format;
/* If no filename given then do nothing:
* No name is considered successful.
*/
if (filename_p == NULL || strlen(filename_p) == 0)
return 1;
/* Determine full file path:
*/
if (filename_p[0] == '/') {
strcpy(filepath, filename_p);
} else {
strcpy(filepath, config.files.disc_images_dir);
strcat(filepath, filename_p);
}
printf("Trying to load disc image: '%s'\n", filepath);
/* Make sure the file exists:
*/
test = fopen(filepath, "r");
if (test) fclose(test); else {
printf("Disc image does not exist.\n");
EG_MessageBox(frame_buffer_p, EG_MESSAGEBOX_STOP
, BEEBCONFIG_IMAGEDOESNOTEXIST_T
, BEEBCONFIG_IMAGEDOESNOTEXIST_M, "Continue"
, NULL, NULL, NULL, 0);
return 0;
}
/* Is the file extension legal (BeebEm disc images MUST
* have one):
*/
is_invalid_format = 1;
if (strlen(filepath) >= 4) {
/* single sided disc image:
*/
if (strcasecmp(filepath + strlen(filepath)-4, ".ssd") == 0) {
// strcpy(config.drive_0_path, filepath);
LoadSimpleDiscImage(filepath, 0, 0, 80);
is_invalid_format = 0;
}
/* double sided disc image:
*/
if (strcasecmp(filepath + strlen(filepath)-4, ".dsd") == 0) {
// strcpy(config.drive_0_path, filepath);
LoadSimpleDSDiscImage(filepath, 0, 80);
is_invalid_format = 0;
}
}
/* If file extension is not recognized, warn user and fail:
*/
if (is_invalid_format == 1) {
EG_MessageBox(frame_buffer_p, EG_MESSAGEBOX_STOP
, BEEBCONFIG_ILLEGALFILEEXTENSION_T, BEEBCONFIG_ILLEGALFILEEXTENSION_M, "Continue"
, NULL, NULL, NULL, 0);
return 0;
}
/* Load the disc image's mapping file (if there is one):
*/
/* Try loading mapping file from the same dir as the disc image:
*/
strcpy(mappingpath, filepath);
mappingpath[strlen(mappingpath)-4] = '\0';
strcat(mappingpath, ".kbd");
if (LoadKeyboardMapping(mappingpath) ) {
printf("Loaded mapping file '%s'.\n", mappingpath);
} else {
/* Try and load mapping file from /kbd/
*/
mappingpath[0]='\0';
if ( (tmp_p=strrchr(filepath, (int) '/')) != NULL) {
tmp_p++;
strcpy(mappingpath, config.files.kbd_files_dir);
strcat(mappingpath, tmp_p);
mappingpath[strlen(mappingpath)-4] = '\0';
strcat(mappingpath, ".kbd");
}
if ( ! LoadKeyboardMapping(mappingpath) ) {
printf("Unable to determine a mapping file for this disc image, falling back to defaults.\n");
EG_MessageBox(frame_buffer_p, EG_MESSAGEBOX_STOP
, BEEBCONFIG_NOMAPPINGFILE_T, BEEBCONFIG_NOMAPPINGFILE_M, "Continue", NULL, NULL, NULL, 0);
} else {
printf("Loaded mapping file '%s'.\n", mappingpath);
}
}
/* Tell emulator core beeb is being 'Shift booted' + depress SHIFT on Beeb.
*/
if (mainWin!=NULL) mainWin->ShiftBooted = true;
BeebKeyDown(0, 0);
// [TODO] Depress shift on the virtual keyboard.
return 1;
}
int Config_LoadDiscConfig(const char *filename_p)
{
int ret;
/* Reset config to default settings:
*/
if ( ! LoadKeyboardMapping(config.files.default_config_loc) )
printf("Unable to load default keyboard mapping file '%s'.\n", config.files.default_config_loc);
else
printf("Loaded default keyboard mapping file '%s'.\n", config.files.default_config_loc);
/* Try and load disc image and it's specific settings:
*/
ret = LoadDiscImage(filename_p);
/* Set FORCED settings:
*/
if ( ! LoadKeyboardMapping(config.files.forced_config_loc) )
printf("Unable to load force keyboard mapping file '%s'.\n", config.files.forced_config_loc);
else
printf("Loaded default force mapping file '%s'.\n", config.files.forced_config_loc);
/* Successful:
*/
return ret;
}
static void Initialize_Files(const char *executable_name_p)
{
char cwd[MAX_DIR_LEN], test_buf[MAX_DIR_LEN], test_buf2[MAX_DIR_LEN], *tmp_p;
char beebem_home[MAX_DIR_LEN], beebem_home_roms[MAX_DIR_LEN], beebem_home_config[MAX_DIR_LEN];
char beebem_home_kbd[MAX_DIR_LEN], beebem_home_saves[MAX_DIR_LEN];
FILE *test;
/* Test for /startup.cnf in cwd, if not found
* then test C's arg[0] string that contains the
* executable's file name, if that works, then use that instead:
*/
getcwd(cwd, MAX_DIR_LEN);
// -------------------------
char *beebem_home_str = getenv("HOME");
if(beebem_home_str) sprintf(beebem_home, "%s/.beebem", beebem_home_str);
printf("set beebem_home:%s\n",beebem_home);
if(access(beebem_home,0) == 0) {//exists
printf("~/.beebem dir exists\n");
}
else {
printf("~/.beebem dir does not exist, will create\n");
int status = mkdir(beebem_home, 0777);
if(status == -1) {
printf("error during mkdir:%s\n",beebem_home);
getcwd(beebem_home, MAX_DIR_LEN);
strcat(beebem_home, "/.beebem");
mkdir(beebem_home, 0777);
printf("set szAppHomePath:%s\n",beebem_home);
}
}
sprintf(beebem_home_roms, "%s/roms", beebem_home);
mkdir(beebem_home_roms, 0777);
sprintf(beebem_home_config, "%s/config", beebem_home);
mkdir(beebem_home_config, 0777);
sprintf(beebem_home_kbd, "%s/kbd", beebem_home);
mkdir(beebem_home_kbd, 0777);
sprintf(beebem_home_saves, "%s/saves", beebem_home);
mkdir(beebem_home_saves, 0777);
// -------------------------
strcpy(test_buf, cwd);
strcat(test_buf, "startup.cnf");
if ( (test=fopen(test_buf, "r")) == NULL ) {
/* If that didn't work, try the executable's name:
*/
strcpy(test_buf, executable_name_p);
if ( (tmp_p=strrchr(test_buf, (int) '/')) != NULL) {
*tmp_p = '\0';
strcpy(test_buf2, test_buf);
strcat(test_buf, "startup.cnf");
if ( (test=fopen(test_buf, "r")) != NULL) {
strcpy(cwd, test_buf2);
fclose(test);
}
}
} else {
fclose(test);
}
/* Change path for development on GP2x (I copy the executable to
* the /tmp RAM disk to save on NAND writes, so cwd will be wrong.
*/
/*
#ifdef GP2X
# ifndef PRODUCTION
strcpy(cwd, "/mnt/sd/beebem06");
# endif
#else
# ifndef PRODUCTION
strcpy(cwd, "..");
# endif
#endif
*/
/* Root dir:
*/
strcpy(config.files.root_dir, cwd);
strcat(config.files.root_dir, "/");
/* Font location:
*/
strcpy(config.files.font_loc, cwd);
strcat(config.files.font_loc, "/resources/font5x8.bmp");
/* Teletext font location:
*/
strcpy(config.files.teletext_font_loc, cwd);
strcat(config.files.teletext_font_loc, "/resources/teletext.bmp");
/* Owl location:
*/
strcpy(config.files.owl_loc, cwd);
strcat(config.files.owl_loc, "/resources/owl.bmp");
/* ROM image configuration file location:
*/
strcpy(config.files.romimg_rc_loc, beebem_home_config);
strcat(config.files.romimg_rc_loc, "/romimg.rc");
if (access(config.files.romimg_rc_loc,0) != 0) { // home override does not exist
strcpy(config.files.romimg_rc_loc, cwd);
strcat(config.files.romimg_rc_loc, "/config/romimg.rc");
}
/* romimg_dir:
*/
strcpy(config.files.romimg_dir, beebem_home_roms); // i.e. ~/.beebem/roms/
strcat(config.files.romimg_dir, "/");
/* default configuration location:
*/
strcpy(config.files.default_config_loc, beebem_home_config);
strcat(config.files.default_config_loc, "/default.kbd");
if (access(config.files.default_config_loc,0) != 0) { // home override does not exist
strcpy(config.files.default_config_loc, cwd);
strcat(config.files.default_config_loc, "/config/default.kbd");
}
/* forced configuration location:
*/
strcpy(config.files.forced_config_loc, beebem_home_config);
strcat(config.files.forced_config_loc, "/forced.kbd");
if (access(config.files.forced_config_loc,0) != 0) { // home override does not exist
strcpy(config.files.forced_config_loc, cwd);
strcat(config.files.forced_config_loc, "/config/forced.kbd");
}
/* Default disc images dir:
*/
strcpy(config.files.disc_images_dir, "/media/");
/* Default save state dir:
*/
strcpy(config.files.save_state_dir, beebem_home_saves); // i.e. ~/.beebem/saves/
strcat(config.files.save_state_dir, "/");
/* Keyboard files archive dir:
*/
strcpy(config.files.kbd_files_dir, beebem_home_kbd); // i.e. ~/.beebem/kbd/
strcat(config.files.kbd_files_dir, "/");
/* Virtual keyboard graphic location:
*/
strcpy(config.files.virtual_keyboard_loc, cwd);
strcat(config.files.virtual_keyboard_loc, "/resources/virtualkeyboard.bmp");
/* GUI font loc:
*/
// strcpy(config.files.gui_font_loc, cwd);
// strcat(config.files.gui_font_loc, "/resources/font5x8.bmp");
/* Drives:
*/
strcpy(config.drive_0_path, "");
strcpy(config.drive_1_path, "");
}
static void RunStartupScript(void)
{
char script[MAX_DIR_LEN];
strcpy(script, config.files.root_dir);
strcat(script, "startup.cnf");
if ( ! LoadKeyboardMapping(script) )
printf("Unable to load startup script '%s'.\n", script);
else
printf("Ran startup script '%s'.\n", script);
}
/* Initialize and Free resources associated with the configuration.
*/
void Config_Initialize(const char *executable_name_p)
{
memset( &config, 0, sizeof(BeebConfig) );
/* VSYNC
*/
config.settings.vsyncoffset = 32;
/* Use skinned widgets by default:
*/
config.settings.skin = 1;
/* Initialize to hardwired values - the default.cfg file will
* override these:
*/
Initialize_Files(executable_name_p);
/* Run startup.cnf - sets defaults from a file rather than
* the internal hardwiring above:
*/
RunStartupScript();
/* Load the default.cfg and forced.cfg file:
*/
(void)Config_LoadDiscConfig(NULL);
}
void Config_FreeResources()
{
// None allocated.
}
void RemoveLeadingWhiteSpace(char *p)
{
char *pp = p;
int i=0;
if (p == NULL) return;
while ( isspace( (int) *pp++) )
i++;
if (i > 0) strcpy(p, p+i);
}
void RemoveTrailingWhiteSpace(char *p)
{
int i;
if (p == NULL || strlen(p)<=0) return;
for(i=strlen(p)-1; i >= 0 && isspace(p[i]); i--)
p[i]='\0';
}
/* SET options:
*/
int ParseSetOption(char *p, char **name_pp, char **value_pp)
{
char *name_p, *value_p;
RemoveLeadingWhiteSpace(p);
if (strncasecmp(p, "SET", 3) != 0) return 0;
/* Dump the actual SET command:
*/
p+=3;
/* Get name and values the command sets:
*/
name_p = p;
if ( (value_p=strchr(p, '=')) == NULL)
return 0;
else
*value_p++='\0';
/* Remove white space:
*/
RemoveLeadingWhiteSpace(name_p);
RemoveTrailingWhiteSpace(name_p);
RemoveLeadingWhiteSpace(value_p);
RemoveTrailingWhiteSpace(value_p);
*name_pp = name_p;
*value_pp = value_p;
return 1;
}
static void AppendForwardSlashIfNone(char *p)
{
if (p == NULL) return;
if (strlen(p) <= 0) return;
if (p[strlen(p)-1] != '/')
strcat(p, "/");
}
void ActionSetOption(char *name_p, char *value_p)
{
#ifdef GP2X
int value;
/* Set processor speed:
*/
if ( !strcasecmp (name_p, "speed")) {
value = atoi(value_p);
/* Up speed slightly for old config files when running 0.6+ etc:
*/
if (value<170) value=170;
/* Make sure speed is within GP2X supported range:
*/
if (value>=100 && value<=260) {
printf("Setting processor speed to %d\n", value);
GP2x_SetCPUSpeed(value);
} else {
printf("Invalid processor speed, please enter a value between 100 and 260Mhz.\n");
}
}
/* Set volume:
*/
if ( !strcasecmp (name_p, "volume")) {
value = atoi(value_p);
if (value>=0 && value<=100) {
value= (value>>1)<<1;
printf("Setting volume to %d\n", value);
OSS_Mixer_SetVolume(value);
} else {
printf("Invalid volume, please enter a value between 0 and 100.\n");
}
}
#endif
/* Set disable_cursor:
*/
if ( !strcasecmp (name_p, "disable_cursor")) {
if ( (!strcasecmp (value_p, "1")) || (!strcasecmp (value_p, "true")) || (!strcasecmp (value_p, "yes")) || (!strcasecmp (value_p, "y")) ) {
config.settings.disable_cursor = 1;
printf("Setting hardware cursor to: DISABLED\n");
} else {
config.settings.disable_cursor = 0;
printf("Setting hardware cursor to: ENABLED\n");
}
}
/* Set vscale:
*/
if ( !strcasecmp (name_p, "vscale")) {
if ( !strcasecmp (value_p, "centered")) {
printf("Setting screen centering to: centered.\n");
SetVideoCentered();
} else if ( !strcasecmp (value_p, "centred")) {
printf("Setting screen centering to: centered.\n");
SetVideoCentered();
} else if ( !strcasecmp (value_p, "top")) {
printf("Setting screen centering to: top.\n");
SetVideoTop();
} else if ( !strcasecmp (value_p, "bottom")) {
printf("Setting screen centering to: bottom.\n");
SetVideoBottom();
} else if ( !strcasecmp (value_p, "scaled")) {
printf("Setting screen centering to: scaled.\n");
SetVideoScaled();
} else {
printf("Invalid vscale, please enter 'centered', 'centred', 'top', 'bottom' or 'scaled'.\n");
}
}
/* Set orientation:
*/
if ( !strcasecmp (name_p, "orientation")) {
if ( !strcasecmp (value_p, "normal")) {
printf("Setting screen orientation to normal.\n");
// This class is going (as it's useless anyway, so this will be cleaned up later.
if (mainWin!=NULL) mainWin->NormaliseScreenOrientation();
EG_FlipNormalSideUp();
} else if ( !strcasecmp (value_p, "flipped")) {
printf("Setting screen orientation to flipped.\n");
// ditto
if (mainWin!=NULL) mainWin->ReverseScreenOrientation();
EG_FlipUpsideDown();
} else
printf("Invalid screen orientation, please enter either 'normal' or 'flipped'.\n");
}
/* VSync nudge:
*/
if ( !strcasecmp (name_p, "vsyncoffset")) {
if ( !strcasecmp (value_p, "nudge")) {
Video_SetVHoldDown();
} else if ( !strcasecmp (value_p, "normal")) {
Video_SetVHoldNormal();
} else
printf("Invalid vsyncoffset, please enter either 'normal' or 'nudge'.\n");
}
/* Use skin'd widgets (not saved in .kbd files):
*/
if ( !strcasecmp (name_p, "skin")) {
if ( !strcasecmp (value_p, "yes"))
config.settings.skin = 1;
else if ( !strcasecmp (value_p, "no"))
config.settings.skin = 0;
else
printf("Invalid skin mode, please enter either 'on' or 'off'.\n");
}
/* Disc R/W tab:
*/
if ( !strcasecmp (name_p, "fd0_tab")) {
if ( !strcasecmp (value_p, "ro")) {
printf("Setting DF0 R/W tab to Read only.\n");
DiscWriteEnable(0, 0);
} else if ( !strcasecmp (value_p, "rw")) {
printf("Setting DF0 R/W tab to Read/Write.\n");
DiscWriteEnable(0, 1);
} else
printf("'%s' '%s' Invalid DF0 read/write tab state, please enter either 'ro' or 'rw'.\n", name_p, value_p);
}
if ( !strcasecmp (name_p, "fd1_tab")) {
if ( !strcasecmp (value_p, "ro")) {
printf("Setting DF1 R/W tab to Read only.\n");
DiscWriteEnable(1, 0);
} else if ( !strcasecmp (value_p, "rw")) {
printf("Setting DF1 R/W tab to Read/Write.\n");
DiscWriteEnable(1, 1);
} else
printf("Invalid DF1 read/write tab state, please enter either 'ro' or 'rw'.\n");
}
/* Stick mode:
*/
if ( !strcasecmp (name_p, "stick")) {
if ( !strcasecmp (value_p, "multi")) {
printf("Setting stick to MULTI mode.\n");
StickManager_Clear();
StickManager_SetMode(STICKMODE_MULTI);
} else if ( !strcasecmp (value_p, "horizontal")) {
printf("Setting stick to HORIZONTAL mode.\n");
StickManager_Clear();
StickManager_SetMode(STICKMODE_HORIZONTAL);
} else if ( !strcasecmp (value_p, "vertical")) {
printf("Setting stick to VERTICAL mode.\n");
StickManager_Clear();
StickManager_SetMode(STICKMODE_VERTICAL);
} else if ( !strcasecmp (value_p, "smart")) {
printf("Setting stick to SMART mode.\n");
StickManager_Clear();
StickManager_SetMode(STICKMODE_CRITICAL);
} else
printf("Invalid stick mode, please enter either 'smart', 'multi', 'horizontal' or 'vertical'.\n");
}
/* Default file locations and directories:
*/
if ( !strcasecmp (name_p, "gui_font_loc")) {
if (value_p[0] != '/') {
strcpy(config.files.font_loc, config.files.root_dir);
strcat(config.files.font_loc, value_p);
} else {
strcpy(config.files.font_loc, value_p);
}
printf("Setting GUI_FONT_LOC to \"%s\"\n", config.files.font_loc);
}
/* Default teletext font location:
*/
if ( !strcasecmp (name_p, "teletext_font_loc")) {
if (value_p[0] != '/') {
strcpy(config.files.teletext_font_loc, config.files.root_dir);
strcat(config.files.teletext_font_loc, value_p);
} else {
strcpy(config.files.teletext_font_loc, value_p);
}
printf("Setting TELETEXT_FONT_LOC to \"%s\"\n", config.files.teletext_font_loc);
}
/* Default owl locations and directories:
*/
if ( !strcasecmp (name_p, "gui_owl_loc")) {
if (value_p[0] != '/') {
strcpy(config.files.owl_loc, config.files.root_dir);
strcat(config.files.owl_loc, value_p);
} else {
strcpy(config.files.owl_loc, value_p);
}
printf("Setting GUI_OWL_LOC to \"%s\"\n", config.files.owl_loc);
}
/* Default ROMs config file location:
*/
if ( !strcasecmp (name_p, "roms_config_loc")) {
if (value_p[0] != '/') {
strcpy(config.files.romimg_rc_loc, config.files.root_dir);
strcat(config.files.romimg_rc_loc, value_p);
} else {
strcpy(config.files.romimg_rc_loc, value_p);
}
printf("Setting ROM_CONFIG_LOC to \"%s\"\n", config.files.romimg_rc_loc);
}
/* Default ROM image dir:
*/
if ( !strcasecmp (name_p, "roms_dir")) {
if (value_p[0] != '/') {
strcpy(config.files.romimg_dir, config.files.root_dir);
strcat(config.files.romimg_dir, value_p);
} else {
strcpy(config.files.romimg_dir, value_p);
}
AppendForwardSlashIfNone(config.files.romimg_dir);
printf("Setting ROMS_DIR to \"%s\"\n", config.files.romimg_dir);
}
/* Default config loc:
*/
if ( !strcasecmp (name_p, "default_config_loc")) {
if (value_p[0] != '/') {
strcpy(config.files.default_config_loc, config.files.root_dir);
strcat(config.files.default_config_loc, value_p);
} else {
strcpy(config.files.default_config_loc, value_p);
}
printf("Setting DEFAULT_CONFIG_LOC to \"%s\"\n", config.files.default_config_loc);
}
/* Forced config loc:
*/
if ( !strcasecmp (name_p, "forced_config_loc")) {
if (value_p[0] != '/') {
strcpy(config.files.forced_config_loc, config.files.root_dir);
strcat(config.files.forced_config_loc, value_p);
} else {
strcpy(config.files.forced_config_loc, value_p);
}
printf("Setting FORCED_CONFIG_LOC to \"%s\"\n", config.files.forced_config_loc);
}
/* Default disc images dir:
*/
if ( !strcasecmp (name_p, "disc_images_dir")) {
if (value_p[0] != '/') {
strcpy(config.files.disc_images_dir, config.files.root_dir);
strcat(config.files.disc_images_dir, value_p);
} else {
strcpy(config.files.disc_images_dir, value_p);
}
AppendForwardSlashIfNone(config.files.disc_images_dir);
printf("Setting DISC_IMAGES_DIR to \"%s\"\n", config.files.disc_images_dir);
}
/* Default save state dir:
*/
if ( !strcasecmp (name_p, "saves_dir")) {
if (value_p[0] != '/') {
strcpy(config.files.save_state_dir, config.files.root_dir);
strcat(config.files.save_state_dir, value_p);
} else {
strcpy(config.files.save_state_dir, value_p);
}
AppendForwardSlashIfNone(config.files.save_state_dir);
printf("Setting SAVES_DIR to \"%s\"\n", config.files.save_state_dir);
}
/* Keyboard mapping files dir:
*/
if ( !strcasecmp (name_p, "kbd_mappings_dir")) {
if (value_p[0] != '/') {
strcpy(config.files.kbd_files_dir, config.files.root_dir);
strcat(config.files.kbd_files_dir, value_p);
} else {
strcpy(config.files.kbd_files_dir, value_p);
}
AppendForwardSlashIfNone(config.files.kbd_files_dir);
printf("Setting KBD_MAPPINGS_DIR to \"%s\"\n", config.files.kbd_files_dir);
}
/* Virtual keyboard location:
*/
if ( !strcasecmp (name_p, "virtual_keyboard_loc") ) {
if (value_p[0] != '/') {
strcpy(config.files.virtual_keyboard_loc, config.files.root_dir);
strcat(config.files.virtual_keyboard_loc, value_p);
} else {
strcpy(config.files.virtual_keyboard_loc, value_p);
}
printf("Setting VIRTUAL_KEYBOARD_LOC to \"%s\"\n", config.files.virtual_keyboard_loc);
}
// /* GUI font location:
// */
// if ( !strcasecmp (name_p, "gui_font_loc") ) {
// if (value_p[0] != '/') {
// strcpy(config.files.gui_font_loc, config.files.root_dir);
// strcat(config.files.gui_font_loc, value_p);
// } else {
// strcpy(config.files.gui_font_loc, value_p);
// }
//
// printf("Setting GUI_FONT_LOC to \"%s\"\n", config.files.gui_font_loc);
// }
}
int ProcessSetOption(char *p)
{
char *pp, *name_p, *value_p;
int ret=0;
if (p == NULL) return 0;
if ( (pp=(char*)malloc(strlen(p)+1)) == NULL) {
printf("*** Unable to process SET option. Not enough RAM.\n");
return 0;
}
strcpy(pp, p);
if (ParseSetOption(pp, &name_p, &value_p)) {
ActionSetOption(name_p, value_p);
ret=1;
}
free(pp);
return ret;
}
const char* Config_GetDiscImageFilename(unsigned int drive)
{
if (drive == 0) return config.drive_0_path;
else return config.drive_1_path;
}
const char* Config_GetDiscImagePath(void)
{
return (const char*) config.files.disc_images_dir;
}
const char* Config_GetSaveStatePath(void)
{
return (const char*) config.files.save_state_dir;
}