multi discs
you can specify a directory as the second -d argument and then cycle among them by dragging to trash. Using eject doesn't work very well, because it leaves a ghost on the desktop and accessing it has no way of completing.
This commit is contained in:
parent
46c886d9e5
commit
b4e41a6739
3 changed files with 35 additions and 15 deletions
|
|
@ -27,10 +27,13 @@
|
|||
|
||||
#include <inttypes.h>
|
||||
|
||||
typedef struct disc_desc disc_descr_t;
|
||||
|
||||
typedef int (*disc_op_read)(void *ctx, uint8_t *data, unsigned int offset, unsigned int len);
|
||||
typedef int (*disc_op_write)(void *ctx, uint8_t *data, unsigned int offset, unsigned int len);
|
||||
typedef int (*disc_op_next)(void *ctx);
|
||||
typedef struct disc_desc {
|
||||
typedef disc_descr_t *(*disc_op_next)(void *ctx);
|
||||
|
||||
struct disc_desc {
|
||||
uint8_t *base;
|
||||
unsigned int size;
|
||||
int read_only;
|
||||
|
|
@ -38,7 +41,7 @@ typedef struct disc_desc {
|
|||
disc_op_read op_read;
|
||||
disc_op_write op_write;
|
||||
disc_op_next op_next;
|
||||
} disc_descr_t;
|
||||
};
|
||||
|
||||
#define DISC_NUM_DRIVES 2
|
||||
|
||||
|
|
|
|||
31
src/disc.c
31
src/disc.c
|
|
@ -144,6 +144,7 @@ typedef struct sony_drive_info {
|
|||
void *op_ctx;
|
||||
disc_op_read op_read; // Callback for read (when data == 0)
|
||||
disc_op_write op_write; // '' '' write ''
|
||||
disc_op_next op_next; // Callback for mount next disc
|
||||
} sony_drinfo_t;
|
||||
|
||||
// List of drives handled by this driver
|
||||
|
|
@ -166,17 +167,23 @@ static sony_drinfo_t *get_drive_info(int num)
|
|||
* Initialization
|
||||
*/
|
||||
|
||||
void SonyInit(disc_descr_t discs[DISC_NUM_DRIVES])
|
||||
static void SonyInit1(sony_drinfo_t *drive, disc_descr_t *disc)
|
||||
{
|
||||
drive->to_be_mounted = 1;
|
||||
drive->read_only = disc->read_only;
|
||||
drive->data = disc->base;
|
||||
drive->size = disc->size;
|
||||
drive->op_ctx = disc->op_ctx;
|
||||
drive->op_read = disc->op_read;
|
||||
drive->op_write = disc->op_write;
|
||||
drive->op_next = disc->op_next;
|
||||
}
|
||||
|
||||
static void SonyInit(disc_descr_t discs[DISC_NUM_DRIVES])
|
||||
{
|
||||
for(int i = 0; i < DISC_NUM_DRIVES; i++) {
|
||||
drives[i].num = 0; // set in SonyOpen
|
||||
drives[i].to_be_mounted = 1;
|
||||
drives[i].read_only = discs[i].read_only;
|
||||
drives[i].data = discs[i].base;
|
||||
drives[i].size = discs[i].size;
|
||||
drives[i].op_ctx = discs[i].op_ctx;
|
||||
drives[i].op_read = discs[i].op_read;
|
||||
drives[i].op_write = discs[i].op_write;
|
||||
SonyInit1(&drives[i], &discs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -419,7 +426,13 @@ int16_t SonyControl(uint32_t pb, uint32_t dce)
|
|||
WriteMacInt8(info->status + dsDiskInPlace, 0);
|
||||
|
||||
if(info->num == 1)
|
||||
umac_disc_ejected();
|
||||
umac_disc_ejected();
|
||||
else if(info->op_next) {
|
||||
disc_descr_t *new_disc = info->op_next(info->op_ctx);
|
||||
if (new_disc) {
|
||||
SonyInit1(info, new_disc);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
|||
|
|
@ -129,13 +129,17 @@ static int open_disc_single(unix_disc_descr_t *desc, int slot, int opt_write, co
|
|||
|
||||
extern int asprintf(char **restrict strp, const char *restrict fmt, ...);
|
||||
|
||||
static int disc_open_next(void *desc_in) {
|
||||
static disc_descr_t *disc_open_next(void *desc_in) {
|
||||
unix_disc_descr_t *desc = desc_in;
|
||||
if (desc->num_names == 0) {
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
munmap(desc->desc->base, desc->desc->size);
|
||||
desc->desc->base = 0;
|
||||
desc->idx = (desc->idx + 1) % desc->num_names;
|
||||
return open_disc_single(desc, desc->slot, desc->opt_write, desc->names[desc->idx]);
|
||||
int r = open_disc_single(desc, desc->slot, desc->opt_write, desc->names[desc->idx]);
|
||||
if (r == 0) return desc->desc;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int open_disc_collection(unix_disc_descr_t *desc, int slot, int opt_write, const char *disc_filename) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue