From 6838117fdd6fbcca29af33690dcce78f8d4fa88a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Hrdli=C4=8Dka?= Date: Sun, 26 Apr 2020 14:19:58 +0200 Subject: [PATCH] win: Add helper methods for mounting images --- src/win/win_cdrom.c | 28 ++++++++++++++++++++++++++++ src/win/win_media_menu.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/src/win/win_cdrom.c b/src/win/win_cdrom.c index 82f4adbe0..3a1eecf87 100644 --- a/src/win/win_cdrom.c +++ b/src/win/win_cdrom.c @@ -77,6 +77,20 @@ mo_eject(uint8_t id) } +void +mo_mount(uint8_t id, wchar_t *fn, uint8_t wp) +{ + mo_t *dev = (mo_t *) mo_drives[id].priv; + + mo_disk_close(dev); + mo_drives[id].read_only = wp; + mo_load(dev, fn); + mo_insert(dev); + + config_save(); +} + + void mo_reload(uint8_t id) { @@ -116,6 +130,20 @@ zip_eject(uint8_t id) } +void +zip_mount(uint8_t id, wchar_t *fn, uint8_t wp) +{ + zip_t *dev = (zip_t *) zip_drives[id].priv; + + zip_disk_close(dev); + zip_drives[id].read_only = wp; + zip_load(dev, fn); + zip_insert(dev); + + config_save(); +} + + void zip_reload(uint8_t id) { diff --git a/src/win/win_media_menu.c b/src/win/win_media_menu.c index af5d380eb..6250d42d7 100644 --- a/src/win/win_media_menu.c +++ b/src/win/win_media_menu.c @@ -262,4 +262,32 @@ media_menu_init() /* Populate the Media and status bar menus. */ media_menu_reset(); +} + +static void +fdd_mount(uint8_t id, wchar_t *fn, uint8_t wp) +{ + fdd_close(id); + ui_writeprot[id] = wp; + fdd_load(id, fn); + + config_save(); +} + +static void +cdrom_mount(uint8_t id, wchar_t *fn) +{ + cdrom[id].prev_host_drive = cdrom[id].host_drive; + wcscpy(cdrom[id].prev_image_path, cdrom[id].image_path); + if (cdrom[id].ops && cdrom[id].ops->exit) + cdrom[id].ops->exit(&(cdrom[id])); + cdrom[id].ops = NULL; + memset(cdrom[id].image_path, 0, sizeof(cdrom[id].image_path)); + cdrom_image_open(&(cdrom[id]), fn); + /* Signal media change to the emulated machine. */ + if (cdrom[id].insert) + cdrom[id].insert(cdrom[id].priv); + cdrom[id].host_drive = (wcslen(cdrom[id].image_path) == 0) ? 0 : 200; + + config_save(); } \ No newline at end of file