Skip to content

Commit 6fc98e6

Browse files
committed
rename globals
1 parent 2055766 commit 6fc98e6

File tree

1 file changed

+74
-74
lines changed

1 file changed

+74
-74
lines changed

libretro.c

+74-74
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,17 @@ static char g_ROMS_DIR[PATH_MAX_LENGTH];
4949
// disk swapping
5050
#define M3U_MAX_FILE 4
5151

52-
static char disk_paths[M3U_MAX_FILE][PATH_MAX_LENGTH];
53-
static char disk_labels[M3U_MAX_FILE][PATH_MAX_LENGTH];
52+
static char g_DISK_PATHS[M3U_MAX_FILE][PATH_MAX_LENGTH];
53+
static char g_DISK_LABELS[M3U_MAX_FILE][PATH_MAX_LENGTH];
5454

55-
static unsigned disk_initial_index = 0;
56-
static char disk_initial_path[PATH_MAX];
57-
static unsigned disk_index = 0;
58-
static unsigned disk_total = 0;
59-
static bool disk_tray_open = false;
55+
static unsigned g_DISK_INITIAL_INDEX = 0;
56+
static char g_DISK_INITIAL_PATH[PATH_MAX];
57+
static unsigned g_DISK_INDEX = 0;
58+
static unsigned g_DISK_TOTAL = 0;
59+
static bool g_DISK_TRAY_OPEN = false;
6060

61-
static struct retro_disk_control_callback retro_disk_control_cb;
62-
static struct retro_disk_control_ext_callback retro_disk_control_ext_cb;
61+
static struct retro_disk_control_callback g_DISK_CONTROL_CB;
62+
static struct retro_disk_control_ext_callback g_DISK_CONTROL_EXT_CB;
6363

6464
static
6565
bool
@@ -69,15 +69,15 @@ read_m3u(const char *file)
6969
char name[PATH_MAX];
7070
FILE *f = fopen(file, "r");
7171

72-
disk_total = 0;
72+
g_DISK_TOTAL = 0;
7373

7474
if (!f)
7575
{
7676
retro_log_printf_cb(RETRO_LOG_ERROR, "Could not read file\n");
7777
return false;
7878
}
7979

80-
while (fgets(line, sizeof(line), f) && disk_total <= M3U_MAX_FILE)
80+
while (fgets(line, sizeof(line), f) && g_DISK_TOTAL <= M3U_MAX_FILE)
8181
{
8282
if (line[0] == '#')
8383
continue;
@@ -104,14 +104,14 @@ read_m3u(const char *file)
104104

105105
if (line[0] != '\0')
106106
{
107-
snprintf(disk_paths[disk_total], sizeof(disk_paths[disk_total]), "%s%c%s", g_ROMS_DIR, slash, line);
108-
fill_pathname(disk_labels[disk_total], path_basename(disk_paths[disk_total]), "", sizeof(disk_labels[disk_total]));
109-
disk_total++;
107+
snprintf(g_DISK_PATHS[g_DISK_TOTAL], sizeof(g_DISK_PATHS[g_DISK_TOTAL]), "%s%c%s", g_ROMS_DIR, slash, line);
108+
fill_pathname(g_DISK_LABELS[g_DISK_TOTAL], path_basename(g_DISK_PATHS[g_DISK_TOTAL]), "", sizeof(g_DISK_LABELS[g_DISK_TOTAL]));
109+
g_DISK_TOTAL++;
110110
}
111111
}
112112

113113
fclose(f);
114-
return (disk_total != 0);
114+
return (g_DISK_TOTAL != 0);
115115
}
116116

117117
static
@@ -411,7 +411,7 @@ static
411411
bool
412412
disk_set_eject_state(bool ejected)
413413
{
414-
disk_tray_open = ejected;
414+
g_DISK_TRAY_OPEN = ejected;
415415
if (ejected)
416416
return true;
417417

@@ -427,7 +427,7 @@ disk_set_eject_state(bool ejected)
427427
opera_lr_opts_reset();
428428

429429
// load
430-
rv = open_cdimage(disk_paths[disk_index]);
430+
rv = open_cdimage(g_DISK_PATHS[g_DISK_INDEX]);
431431
if (rv == -1)
432432
return false;
433433

@@ -450,16 +450,16 @@ static
450450
bool
451451
disk_get_eject_state()
452452
{
453-
return disk_tray_open;
453+
return g_DISK_TRAY_OPEN;
454454
}
455455

456456
static
457457
bool
458458
disk_set_image_index(unsigned index)
459459
{
460-
if (disk_tray_open && index < disk_total)
460+
if (g_DISK_TRAY_OPEN && index < g_DISK_TOTAL)
461461
{
462-
disk_index = index;
462+
g_DISK_INDEX = index;
463463
return true;
464464
}
465465
return false;
@@ -469,25 +469,25 @@ static
469469
unsigned
470470
disk_get_image_index()
471471
{
472-
return disk_index;
472+
return g_DISK_INDEX;
473473
}
474474

475475
static
476476
unsigned
477477
disk_get_num_images(void)
478478
{
479-
return disk_total;
479+
return g_DISK_TOTAL;
480480
}
481481

482482
static
483483
bool
484484
disk_add_image_index(void)
485485
{
486-
if (disk_total >= M3U_MAX_FILE)
486+
if (g_DISK_TOTAL >= M3U_MAX_FILE)
487487
return false;
488-
disk_total++;
489-
disk_paths[disk_total - 1][0] = '\0';
490-
disk_labels[disk_total - 1][0] = '\0';
488+
g_DISK_TOTAL++;
489+
g_DISK_PATHS[g_DISK_TOTAL - 1][0] = '\0';
490+
g_DISK_LABELS[g_DISK_TOTAL - 1][0] = '\0';
491491
return true;
492492
}
493493

@@ -496,23 +496,23 @@ bool
496496
disk_replace_image_index(unsigned index,
497497
const struct retro_game_info *info)
498498
{
499-
if ((index >= disk_total))
499+
if ((index >= g_DISK_TOTAL))
500500
return false;
501501

502502
if (!info)
503503
{
504-
disk_paths[index][0] = '\0';
505-
disk_labels[index][0] = '\0';
506-
disk_total--;
504+
g_DISK_PATHS[index][0] = '\0';
505+
g_DISK_LABELS[index][0] = '\0';
506+
g_DISK_TOTAL--;
507507

508-
if ((disk_index >= index) && (disk_index > 0))
509-
disk_index--;
508+
if ((g_DISK_INDEX >= index) && (g_DISK_INDEX > 0))
509+
g_DISK_INDEX--;
510510
}
511511
else
512512
{
513-
snprintf(disk_paths[index], sizeof(disk_paths[index]), "%s", info->path);
514-
fill_pathname(disk_labels[index], path_basename(disk_paths[index]), "",
515-
sizeof(disk_labels[index]));
513+
snprintf(g_DISK_PATHS[index], sizeof(g_DISK_PATHS[index]), "%s", info->path);
514+
fill_pathname(g_DISK_LABELS[index], path_basename(g_DISK_PATHS[index]), "",
515+
sizeof(g_DISK_LABELS[index]));
516516
}
517517
return true;
518518
}
@@ -521,8 +521,8 @@ static bool disk_set_initial_image(unsigned index, const char *path) {
521521
if (!path || (*path == '\0'))
522522
return false;
523523

524-
disk_initial_index = index;
525-
snprintf(disk_initial_path, sizeof(disk_initial_path), "%s", path);
524+
g_DISK_INITIAL_INDEX = index;
525+
snprintf(g_DISK_INITIAL_PATH, sizeof(g_DISK_INITIAL_PATH), "%s", path);
526526

527527
return true;
528528
}
@@ -534,13 +534,13 @@ disk_get_image_path(unsigned index, char *path, size_t len)
534534
if (len < 1)
535535
return false;
536536

537-
if (index >= disk_total)
537+
if (index >= g_DISK_TOTAL)
538538
return false;
539539

540-
if (disk_paths[index][0] == '\0')
540+
if (g_DISK_PATHS[index][0] == '\0')
541541
return false;
542542

543-
strncpy(path, disk_paths[index], len - 1);
543+
strncpy(path, g_DISK_PATHS[index], len - 1);
544544
path[len - 1] = '\0';
545545

546546
return true;
@@ -553,13 +553,13 @@ disk_get_image_label(unsigned index, char *label, size_t len)
553553
if (len < 1)
554554
return false;
555555

556-
if (index >= disk_total)
556+
if (index >= g_DISK_TOTAL)
557557
return false;
558558

559-
if (disk_labels[index][0] == '\0')
559+
if (g_DISK_LABELS[index][0] == '\0')
560560
return false;
561561

562-
strncpy(label, disk_labels[index], len - 1);
562+
strncpy(label, g_DISK_LABELS[index], len - 1);
563563
label[len - 1] = '\0';
564564

565565
return true;
@@ -571,31 +571,31 @@ init_disk_control_interface(void)
571571
{
572572
unsigned dci_version = 0;
573573

574-
retro_disk_control_cb.set_eject_state = disk_set_eject_state;
575-
retro_disk_control_cb.get_eject_state = disk_get_eject_state;
576-
retro_disk_control_cb.set_image_index = disk_set_image_index;
577-
retro_disk_control_cb.get_image_index = disk_get_image_index;
578-
retro_disk_control_cb.get_num_images = disk_get_num_images;
579-
retro_disk_control_cb.add_image_index = disk_add_image_index;
580-
retro_disk_control_cb.replace_image_index = disk_replace_image_index;
581-
582-
retro_disk_control_ext_cb.set_eject_state = disk_set_eject_state;
583-
retro_disk_control_ext_cb.get_eject_state = disk_get_eject_state;
584-
retro_disk_control_ext_cb.set_image_index = disk_set_image_index;
585-
retro_disk_control_ext_cb.get_image_index = disk_get_image_index;
586-
retro_disk_control_ext_cb.get_num_images = disk_get_num_images;
587-
retro_disk_control_ext_cb.add_image_index = disk_add_image_index;
588-
retro_disk_control_ext_cb.replace_image_index = disk_replace_image_index;
589-
retro_disk_control_ext_cb.set_initial_image = disk_set_initial_image;
590-
retro_disk_control_ext_cb.get_image_path = disk_get_image_path;
591-
retro_disk_control_ext_cb.get_image_label = disk_get_image_label;
592-
593-
disk_initial_index = 0;
594-
disk_initial_path[0] = '\0';
574+
g_DISK_CONTROL_CB.set_eject_state = disk_set_eject_state;
575+
g_DISK_CONTROL_CB.get_eject_state = disk_get_eject_state;
576+
g_DISK_CONTROL_CB.set_image_index = disk_set_image_index;
577+
g_DISK_CONTROL_CB.get_image_index = disk_get_image_index;
578+
g_DISK_CONTROL_CB.get_num_images = disk_get_num_images;
579+
g_DISK_CONTROL_CB.add_image_index = disk_add_image_index;
580+
g_DISK_CONTROL_CB.replace_image_index = disk_replace_image_index;
581+
582+
g_DISK_CONTROL_EXT_CB.set_eject_state = disk_set_eject_state;
583+
g_DISK_CONTROL_EXT_CB.get_eject_state = disk_get_eject_state;
584+
g_DISK_CONTROL_EXT_CB.set_image_index = disk_set_image_index;
585+
g_DISK_CONTROL_EXT_CB.get_image_index = disk_get_image_index;
586+
g_DISK_CONTROL_EXT_CB.get_num_images = disk_get_num_images;
587+
g_DISK_CONTROL_EXT_CB.add_image_index = disk_add_image_index;
588+
g_DISK_CONTROL_EXT_CB.replace_image_index = disk_replace_image_index;
589+
g_DISK_CONTROL_EXT_CB.set_initial_image = disk_set_initial_image;
590+
g_DISK_CONTROL_EXT_CB.get_image_path = disk_get_image_path;
591+
g_DISK_CONTROL_EXT_CB.get_image_label = disk_get_image_label;
592+
593+
g_DISK_INITIAL_INDEX = 0;
594+
g_DISK_INITIAL_PATH[0] = '\0';
595595
if (retro_environment_cb(RETRO_ENVIRONMENT_GET_DISK_CONTROL_INTERFACE_VERSION, &dci_version) && (dci_version >= 1))
596-
retro_environment_cb(RETRO_ENVIRONMENT_SET_DISK_CONTROL_EXT_INTERFACE, &retro_disk_control_ext_cb);
596+
retro_environment_cb(RETRO_ENVIRONMENT_SET_DISK_CONTROL_EXT_INTERFACE, &g_DISK_CONTROL_EXT_CB);
597597
else
598-
retro_environment_cb(RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE, &retro_disk_control_cb);
598+
retro_environment_cb(RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE, &g_DISK_CONTROL_CB);
599599
}
600600

601601
bool
@@ -615,21 +615,21 @@ retro_load_game(const struct retro_game_info *info_)
615615
}
616616
else
617617
{
618-
disk_index = 0;
618+
g_DISK_INDEX = 0;
619619

620-
if ((disk_total > 1) && (disk_initial_index > 0) && (disk_initial_index < disk_total))
621-
if (strcmp(disk_paths[disk_initial_index], disk_initial_path) == 0)
622-
disk_index = disk_initial_index;
620+
if ((g_DISK_TOTAL > 1) && (g_DISK_INITIAL_INDEX > 0) && (g_DISK_INITIAL_INDEX < g_DISK_TOTAL))
621+
if (strcmp(g_DISK_PATHS[g_DISK_INITIAL_INDEX], g_DISK_INITIAL_PATH) == 0)
622+
g_DISK_INDEX = g_DISK_INITIAL_INDEX;
623623
}
624624
}
625625
else
626626
{
627-
snprintf(disk_paths[disk_total], sizeof(disk_paths[disk_total]), "%s", info_->path);
628-
fill_pathname(disk_labels[disk_total], path_basename(disk_paths[disk_total]), "", sizeof(disk_labels[disk_total]));
629-
disk_total++;
627+
snprintf(g_DISK_PATHS[g_DISK_TOTAL], sizeof(g_DISK_PATHS[g_DISK_TOTAL]), "%s", info_->path);
628+
fill_pathname(g_DISK_LABELS[g_DISK_TOTAL], path_basename(g_DISK_PATHS[g_DISK_TOTAL]), "", sizeof(g_DISK_LABELS[g_DISK_TOTAL]));
629+
g_DISK_TOTAL++;
630630
}
631631

632-
rv = open_cdimage(disk_paths[disk_index]);
632+
rv = open_cdimage(g_DISK_PATHS[g_DISK_INDEX]);
633633
if(rv == -1)
634634
return false;
635635

0 commit comments

Comments
 (0)