diff --git a/README.md b/README.md index ce78d2fa..c0bd0512 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,8 @@ When launched with a valid disk image the emulator will automatically launch the There are also options to write protect floppy disks as well as an option to enable/disable fast floppy access. +There is an option in the RetroMapper where you can assign a button to "Auto Rotate" the disks (M3U). Be cautious about what button you assign it to ( You've been warned ). + ## M3U Support and Disk control When you have a multi disk game, you can use a m3u file to specify each disk of the game and change them from the RetroArch Disk control interface. diff --git a/libretro/hatari-mapper.c b/libretro/hatari-mapper.c index b076406d..7f07e0b1 100644 --- a/libretro/hatari-mapper.c +++ b/libretro/hatari-mapper.c @@ -13,6 +13,7 @@ //RETRO LIB extern void retro_message(unsigned int frames, int level, const char* format, ...); extern void retro_status(unsigned int frames, const char* format, ...); +extern void disk_rotate_images(); //CORE VAR extern const char *retro_save_directory; @@ -742,6 +743,21 @@ void update_input(void) Screen_SetFullUpdate(); } } + d = RETRO_DEVICE_ID_JOYPAD_L3;//not mapped + if (mapper_keys[i] == ROTATE_DISKS) + { + if (which && mbt[d] == 0) + { + mbt[d] = 1; + selected[d] = i; + } + else if (mbt[d] == 1 && !which && selected[d] == i) + { + mbt[d] = 0; + selected[d] = -1; + disk_rotate_images(); + } + } } // do these only when VKBD is active. else diff --git a/libretro/hatari-mapper.h b/libretro/hatari-mapper.h index 31bc071e..e7a6eff8 100644 --- a/libretro/hatari-mapper.h +++ b/libretro/hatari-mapper.h @@ -38,7 +38,8 @@ #define TOGGLE_VKBS -33 #define TOGGLE_STATUSBAR -34 #define TOGGLE_SETTINGS -35 -//#define SWITCH_JOYPORT -36 +#define ROTATE_DISKS -36 +//#define SWITCH_JOYPORT -37 #define MOUSE_SLOWER -5 #define MOUSE_FASTER -6 #define JOYSTICK_UP -11 @@ -93,6 +94,7 @@ static retro_keymap retro_keys[RETROK_LAST] = {TOGGLE_VKBS, "TOGGLE_VKBS", "Toggle VKBD Shift"}, {TOGGLE_SETTINGS, "TOGGLE_SETTINGS", "Hatari Settings"}, {TOGGLE_STATUSBAR, "TOGGLE_STATUSBAR", "Toggle Status Display"}, + {ROTATE_DISKS, "ROTATE_DISKS", "Rotate Disks"}, /* {SWITCH_JOYPORT, "SWITCH_JOYPORT", "Switch Joyport"}, */ {JOYSTICK_UP, "JOYSTICK_UP", "Joystick Up"}, {JOYSTICK_DOWN, "JOYSTICK_DOWN", "Joystick Down"}, diff --git a/libretro/libretro.c b/libretro/libretro.c index 941f83a6..51bcb11e 100644 --- a/libretro/libretro.c +++ b/libretro/libretro.c @@ -132,6 +132,8 @@ static struct retro_input_descriptor input_descriptors[] = { { 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R3, "Set in RetroPad Mapping" }, { 0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X, "Set in RetroPad Mapping" }, { 0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y, "Set in RetroPad Mapping" }, + { 0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X, "Set in RetroPad Mapping" }, + { 0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y, "Set in RetroPad Mapping" }, { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "Joystick Up" }, { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "Joystick Down" }, { 1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "Joystick Left" }, @@ -1006,6 +1008,7 @@ void retro_shutdown_hatari(void) //***************************************************************************** // Disk control extern bool Floppy_EjectDiskFromDrive(int Drive); +extern const char* Floppy_SetDiskFileNameNone(int Drive); extern const char* Floppy_SetDiskFileName(int Drive, const char *pszFileName, const char *pszZipPath); extern bool Floppy_InsertDiskIntoDrive(int Drive); @@ -1030,6 +1033,13 @@ static void disk_insert_image() { if (dc->unit == DC_IMAGE_TYPE_FLOPPY) { + // check if in Drive B ( mount to A will fail if so ). If it is.. eject from drive B first + if (strcmp(dc->files[dc->index], ConfigureParams.DiskImage.szDiskFileName[1]) == 0) + { + Floppy_EjectDiskFromDrive(1); + Floppy_SetDiskFileNameNone(1); + } + if (Floppy_SetDiskFileName(0, dc->files[dc->index], NULL) == NULL) { retro_message(3000, RETRO_LOG_ERROR, "[disk_insert_image] mount in Drive A failed.\n", dc->files[dc->index]); @@ -1218,6 +1228,34 @@ static bool disk_get_image_label(unsigned index, char* label, size_t len) return false; } +void disk_rotate_images() +{ + char *p = 0; + + //nothing to see here..move along! + if (dc->count < 2) + return; + + // eject current disk + disk_set_eject_state(true); + + // rotate + dc->index++; + if (dc->index >= dc->count) + dc->index = 0; + + // insert next disk in line + disk_set_eject_state(false); + + //let the user know + p = strrchr(dc->files[dc->index], RETRO_PATH_SEPARATOR[0]); + + if (p) + retro_message(3000, RETRO_LOG_INFO, "Rotate to disk %s in drive A.", p+1 ); + else + retro_message(3000, RETRO_LOG_INFO, "Rotate to disk %s in drive A.", dc->files[dc->index]); +} + static struct retro_disk_control_callback disk_interface = { disk_set_eject_state, disk_get_eject_state,