Skip to content

Commit

Permalink
simplify disk control registration
Browse files Browse the repository at this point in the history
  • Loading branch information
dszakallas committed May 1, 2024
1 parent 6fc98e6 commit 1b506cb
Showing 1 changed file with 18 additions and 24 deletions.
42 changes: 18 additions & 24 deletions libretro.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ static unsigned g_DISK_INDEX = 0;
static unsigned g_DISK_TOTAL = 0;
static bool g_DISK_TRAY_OPEN = false;

static struct retro_disk_control_callback g_DISK_CONTROL_CB;
static struct retro_disk_control_ext_callback g_DISK_CONTROL_EXT_CB;
static struct retro_disk_control_ext_callback g_DISK_CONTROL;

static
bool
Expand Down Expand Up @@ -571,31 +570,26 @@ init_disk_control_interface(void)
{
unsigned dci_version = 0;

g_DISK_CONTROL_CB.set_eject_state = disk_set_eject_state;
g_DISK_CONTROL_CB.get_eject_state = disk_get_eject_state;
g_DISK_CONTROL_CB.set_image_index = disk_set_image_index;
g_DISK_CONTROL_CB.get_image_index = disk_get_image_index;
g_DISK_CONTROL_CB.get_num_images = disk_get_num_images;
g_DISK_CONTROL_CB.add_image_index = disk_add_image_index;
g_DISK_CONTROL_CB.replace_image_index = disk_replace_image_index;

g_DISK_CONTROL_EXT_CB.set_eject_state = disk_set_eject_state;
g_DISK_CONTROL_EXT_CB.get_eject_state = disk_get_eject_state;
g_DISK_CONTROL_EXT_CB.set_image_index = disk_set_image_index;
g_DISK_CONTROL_EXT_CB.get_image_index = disk_get_image_index;
g_DISK_CONTROL_EXT_CB.get_num_images = disk_get_num_images;
g_DISK_CONTROL_EXT_CB.add_image_index = disk_add_image_index;
g_DISK_CONTROL_EXT_CB.replace_image_index = disk_replace_image_index;
g_DISK_CONTROL_EXT_CB.set_initial_image = disk_set_initial_image;
g_DISK_CONTROL_EXT_CB.get_image_path = disk_get_image_path;
g_DISK_CONTROL_EXT_CB.get_image_label = disk_get_image_label;
g_DISK_CONTROL.set_eject_state = disk_set_eject_state;
g_DISK_CONTROL.get_eject_state = disk_get_eject_state;
g_DISK_CONTROL.set_image_index = disk_set_image_index;
g_DISK_CONTROL.get_image_index = disk_get_image_index;
g_DISK_CONTROL.get_num_images = disk_get_num_images;
g_DISK_CONTROL.add_image_index = disk_add_image_index;
g_DISK_CONTROL.replace_image_index = disk_replace_image_index;
g_DISK_CONTROL.set_initial_image = disk_set_initial_image;
g_DISK_CONTROL.get_image_path = disk_get_image_path;
g_DISK_CONTROL.get_image_label = disk_get_image_label;

g_DISK_INITIAL_INDEX = 0;
g_DISK_INITIAL_PATH[0] = '\0';
if (retro_environment_cb(RETRO_ENVIRONMENT_GET_DISK_CONTROL_INTERFACE_VERSION, &dci_version) && (dci_version >= 1))
retro_environment_cb(RETRO_ENVIRONMENT_SET_DISK_CONTROL_EXT_INTERFACE, &g_DISK_CONTROL_EXT_CB);
else
retro_environment_cb(RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE, &g_DISK_CONTROL_CB);

retro_environment_cb(RETRO_ENVIRONMENT_GET_DISK_CONTROL_INTERFACE_VERSION,
&dci_version);

retro_environment_cb(dci_version >= 1 ? RETRO_ENVIRONMENT_SET_DISK_CONTROL_EXT_INTERFACE
: RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE,
&g_DISK_CONTROL);
}

bool
Expand Down

0 comments on commit 1b506cb

Please sign in to comment.