Implement inserting blank media into drive.
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
*
|
||||
* Copyright 2018-2021 Miran Grca.
|
||||
*/
|
||||
|
||||
#include <inttypes.h>
|
||||
#ifdef ENABLE_CDROM_LOG
|
||||
#include <stdarg.h>
|
||||
@@ -26,6 +27,7 @@
|
||||
#include <86box/config.h>
|
||||
#include <86box/cdrom.h>
|
||||
#include <86box/cdrom_image.h>
|
||||
#include <86box/cdrom_image_writable.h>
|
||||
#include <86box/cdrom_interface.h>
|
||||
#ifdef USE_CDROM_MITSUMI
|
||||
#include <86box/cdrom_mitsumi.h>
|
||||
@@ -2996,6 +2998,36 @@ cdrom_update_status(cdrom_t *dev)
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
cdrom_insert_blank(cdrom_t *dev, const char *fn)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
// Create new image
|
||||
dev->local = wimage_open(dev, dev->image_path);
|
||||
|
||||
// Clear cached sectors
|
||||
dev->cached_sector = -1;
|
||||
|
||||
// If new image could not be created
|
||||
if (dev->local == NULL) {
|
||||
dev->ops = NULL;
|
||||
dev->image_path[0] = 0;
|
||||
|
||||
ret = 1;
|
||||
} else {
|
||||
// All looking good, reset state
|
||||
dev->seek_pos = 0;
|
||||
dev->cd_buflen = 0;
|
||||
dev->cd_status = CD_STATUS_BLANK_CDR;
|
||||
dev->cdrom_capacity = 0;
|
||||
cdrom_log(dev->log, "Blank CD-R created\n");
|
||||
cdrom_insert(dev->id);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
cdrom_load(cdrom_t *dev, const char *fn, const int skip_insert)
|
||||
{
|
||||
@@ -3188,15 +3220,6 @@ cdrom_insert(const uint8_t id)
|
||||
dev->insert(dev->priv);
|
||||
}
|
||||
|
||||
void
|
||||
cdrom_insert_blank(const uint8_t id)
|
||||
{
|
||||
const cdrom_t *dev = &cdrom[id];
|
||||
|
||||
if (dev->bus_type && dev->insert_blank)
|
||||
dev->insert_blank(dev->priv);
|
||||
}
|
||||
|
||||
void
|
||||
cdrom_exit(const uint8_t id)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user