Imported CD-ROM-related changes from VARCem;

Removed cdrom_null.c/h;
Some changes to logging (will be spread to everything else soon).
This commit is contained in:
OBattler
2018-10-17 05:29:48 +02:00
parent 2cd20ea319
commit c663147d11
18 changed files with 908 additions and 972 deletions

View File

@@ -8,7 +8,7 @@
* *
* Generic CD-ROM drive core. * Generic CD-ROM drive core.
* *
* Version: @(#)cdrom.c 1.0.1 2018/10/11 * Version: @(#)cdrom.c 1.0.2 2018/10/17
* *
* Author: Miran Grca, <mgrca8@gmail.com> * Author: Miran Grca, <mgrca8@gmail.com>
* *
@@ -23,9 +23,10 @@
#include <wchar.h> #include <wchar.h>
#define HAVE_STDARG_H #define HAVE_STDARG_H
#include "../86box.h" #include "../86box.h"
#include "../config.h"
#include "cdrom.h" #include "cdrom.h"
#include "cdrom_image.h" #include "cdrom_image.h"
#include "cdrom_null.h" #include "../plat.h"
#include "../sound/sound.h" #include "../sound/sound.h"
@@ -33,50 +34,50 @@
#define MAX_SEEK 333333 #define MAX_SEEK 333333
cdrom_image_t cdrom_image[CDROM_NUM]; cdrom_t cdrom[CDROM_NUM];
cdrom_drive_t cdrom_drives[CDROM_NUM];
#ifdef ENABLE_CDROM_LOG #ifdef ENABLE_CDROM_LOG
int cdrom_do_log = ENABLE_CDROM_LOG; int cdrom_do_log = ENABLE_CDROM_LOG;
#endif
static void void
cdrom_log(const char *format, ...) cdrom_log(const char *fmt, ...)
{ {
#ifdef ENABLE_CDROM_LOG
va_list ap; va_list ap;
if (cdrom_do_log) { if (cdrom_do_log) {
va_start(ap, format); va_start(ap, fmt);
pclog_ex(format, ap); pclog_ex(fmt, ap);
va_end(ap); va_end(ap);
} }
#endif
} }
#else
#define cdrom_log(fmt, ...)
#endif
int int
cdrom_lba_to_msf_accurate(int lba) cdrom_lba_to_msf_accurate(int lba)
{ {
int temp_pos; int pos;
int m, s, f; int m, s, f;
temp_pos = lba + 150; pos = lba + 150;
f = temp_pos % 75; f = pos % 75;
temp_pos -= f; pos -= f;
temp_pos /= 75; pos /= 75;
s = temp_pos % 60; s = pos % 60;
temp_pos -= s; pos -= s;
temp_pos /= 60; pos /= 60;
m = temp_pos; m = pos;
return ((m << 16) | (s << 8) | f); return ((m << 16) | (s << 8) | f);
} }
double static double
cdrom_get_short_seek(cdrom_drive_t *dev) cdrom_get_short_seek(cdrom_t *dev)
{ {
switch(dev->cur_speed) { switch(dev->cur_speed) {
case 0: case 0:
@@ -107,8 +108,8 @@ cdrom_get_short_seek(cdrom_drive_t *dev)
} }
double static double
cdrom_get_long_seek(cdrom_drive_t *dev) cdrom_get_long_seek(cdrom_t *dev)
{ {
switch(dev->cur_speed) { switch(dev->cur_speed) {
case 0: case 0:
@@ -140,7 +141,7 @@ cdrom_get_long_seek(cdrom_drive_t *dev)
double double
cdrom_seek_time(cdrom_drive_t *dev) cdrom_seek_time(cdrom_t *dev)
{ {
uint32_t diff = dev->seek_diff; uint32_t diff = dev->seek_diff;
double sd = (double) (MAX_SEEK - MIN_SEEK); double sd = (double) (MAX_SEEK - MIN_SEEK);
@@ -157,28 +158,35 @@ cdrom_seek_time(cdrom_drive_t *dev)
void void
cdrom_seek(cdrom_drive_t *dev, uint32_t pos) cdrom_seek(cdrom_t *dev, uint32_t pos)
{ {
/* cdrom_log("CD-ROM %i: Seek %08X\n", dev->id, pos); */ /* cdrom_log("CD-ROM %i: Seek %08X\n", dev->id, pos); */
if (!dev) if (!dev)
return; return;
dev->seek_pos = pos; dev->seek_pos = pos;
if (dev->handler && dev->handler->stop) if (dev->ops && dev->ops->stop)
dev->handler->stop(dev->id); dev->ops->stop(dev);
} }
int int
cdrom_playing_completed(cdrom_drive_t *dev) cdrom_playing_completed(cdrom_t *dev)
{ {
dev->prev_status = dev->cd_status; dev->prev_status = dev->cd_status;
dev->cd_status = dev->handler->status(dev->id);
if (dev->ops && dev->ops->status)
dev->cd_status = dev->ops->status(dev);
else {
dev->cd_status = CD_STATUS_EMPTY;
return 0;
}
if (((dev->prev_status == CD_STATUS_PLAYING) || (dev->prev_status == CD_STATUS_PAUSED)) && if (((dev->prev_status == CD_STATUS_PLAYING) || (dev->prev_status == CD_STATUS_PAUSED)) &&
((dev->cd_status != CD_STATUS_PLAYING) && (dev->cd_status != CD_STATUS_PAUSED))) ((dev->cd_status != CD_STATUS_PLAYING) && (dev->cd_status != CD_STATUS_PAUSED)))
return 1; return 1;
else
return 0; return 0;
} }
@@ -187,44 +195,51 @@ void
cdrom_global_init(void) cdrom_global_init(void)
{ {
/* Clear the global data. */ /* Clear the global data. */
memset(cdrom_drives, 0x00, sizeof(cdrom_drives)); memset(cdrom, 0x00, sizeof(cdrom));
} }
static void static void
cdrom_drive_reset(cdrom_drive_t *drv) cdrom_drive_reset(cdrom_t *dev)
{ {
drv->p = NULL; dev->p = NULL;
drv->insert = NULL; dev->insert = NULL;
drv->get_volume = NULL; dev->close = NULL;
drv->get_channel = NULL; dev->get_volume = NULL;
drv->close = NULL; dev->get_channel = NULL;
} }
void void
cdrom_hard_reset(void) cdrom_hard_reset(void)
{ {
int c; cdrom_t *dev;
cdrom_drive_t *drv; int i;
for (c = 0; c < CDROM_NUM; c++) { for (i = 0; i < CDROM_NUM; i++) {
if (cdrom_drives[c].bus_type) { dev = &cdrom[i];
cdrom_log("CDROM hard_reset drive=%d\n", c); if (dev->bus_type) {
cdrom_log("CDROM %i: hard_reset\n", i);
drv = &cdrom_drives[c]; dev->id = i;
drv->id = c;
cdrom_drive_reset(drv); cdrom_drive_reset(dev);
if ((drv->bus_type == CDROM_BUS_ATAPI) || (drv->bus_type == CDROM_BUS_SCSI)) switch(dev->bus_type) {
scsi_cdrom_drive_reset(c); case CDROM_BUS_ATAPI:
case CDROM_BUS_SCSI:
scsi_cdrom_drive_reset(i);
break;
if (drv->host_drive == 200) { default:
image_open(c, cdrom_image[c].image_path); break;
image_reset(c); }
} else
cdrom_null_open(c);
if (dev->host_drive == 200) {
cdrom_image_open(dev, dev->image_path);
cdrom_image_reset(dev);
}
} }
} }
@@ -232,39 +247,111 @@ cdrom_hard_reset(void)
} }
void
cdrom_close_handler(uint8_t id)
{
cdrom_drive_t *dev = &cdrom_drives[id];
if (!dev)
return;
switch (dev->host_drive) {
case 200:
image_close(id);
break;
default:
null_close(id);
break;
}
dev->handler = NULL;
}
void void
cdrom_close(void) cdrom_close(void)
{ {
int c; cdrom_t *dev;
int i;
for (c = 0; c < CDROM_NUM; c++) { for (i = 0; i < CDROM_NUM; i++) {
if (cdrom_drives[c].handler) dev = &cdrom[i];
cdrom_close_handler(c);
if (cdrom_drives[c].close) if (dev->ops && dev->ops->exit)
cdrom_drives[c].close(cdrom_drives[c].p); dev->ops->exit(dev);
cdrom_drive_reset(&cdrom_drives[c]); dev->ops = NULL;
if (dev->close)
dev->close(dev->p);
cdrom_drive_reset(dev);
} }
} }
/* Signal disc change to the emulated machine. */
void
cdrom_insert(uint8_t id)
{
cdrom_t *dev = &cdrom[id];
if (dev->bus_type) {
if (dev->insert)
dev->insert(dev->p);
}
}
/* The mechanics of ejecting a CD-ROM from a drive. */
void
cdrom_eject(uint8_t id)
{
cdrom_t *dev = &cdrom[id];
/* This entire block should be in cdrom.c/cdrom_eject(dev*) ... */
if (dev->host_drive == 0) {
/* Switch from empty to empty. Do nothing. */
return;
}
if (dev->prev_image_path) {
free(dev->prev_image_path);
dev->prev_image_path = NULL;
}
if (dev->host_drive == 200) {
dev->prev_image_path = (wchar_t *) malloc(1024);
wcscpy(dev->prev_image_path, dev->image_path);
}
dev->prev_host_drive = dev->host_drive;
dev->host_drive = 0;
dev->ops->exit(dev);
dev->ops = NULL;
memset(dev->image_path, 0, sizeof(dev->image_path));
cdrom_insert(id);
plat_cdrom_ui_update(id, 0);
config_save();
}
/* The mechanics of re-loading a CD-ROM drive. */
void
cdrom_reload(uint8_t id)
{
cdrom_t *dev = &cdrom[id];
if ((dev->host_drive == dev->prev_host_drive) ||
(dev->prev_host_drive == 0) || (dev->host_drive != 0)) {
/* Switch from empty to empty. Do nothing. */
return;
}
if (dev->ops && dev->ops->exit)
dev->ops->exit(dev);
dev->ops = NULL;
memset(dev->image_path, 0, sizeof(dev->image_path));
if (dev->prev_host_drive == 200) {
/* Reload a previous image. */
wcscpy(dev->image_path, dev->prev_image_path);
free(dev->prev_image_path);
dev->prev_image_path = NULL;
cdrom_image_open(dev, dev->image_path);
cdrom_insert(id);
if (wcslen(dev->image_path) == 0)
dev->host_drive = 0;
else
dev->host_drive = 200;
}
plat_cdrom_ui_update(id, 1);
config_save();
}

View File

@@ -8,7 +8,7 @@
* *
* Generic CD-ROM drive core header. * Generic CD-ROM drive core header.
* *
* Version: @(#)cdrom.h 1.0.14 2018/10/09 * Version: @(#)cdrom.h 1.0.15 2018/10/17
* *
* Author: Miran Grca, <mgrca8@gmail.com> * Author: Miran Grca, <mgrca8@gmail.com>
* *
@@ -30,6 +30,14 @@
#define CDROM_IMAGE 200 #define CDROM_IMAGE 200
/* This is so that if/when this is changed to something else,
changing this one define will be enough. */
#define CDROM_EMPTY !dev->host_drive
#ifdef __cplusplus
extern "C" {
#endif
enum { enum {
CDROM_BUS_DISABLED = 0, CDROM_BUS_DISABLED = 0,
@@ -39,85 +47,91 @@ enum {
}; };
/* To shut up the GCC compilers. */
struct cdrom;
/* Define the various CD-ROM drive operations (ops). */
typedef struct { typedef struct {
int (*ready)(uint8_t id); int (*ready)(struct cdrom *dev);
int (*medium_changed)(uint8_t id); int (*medium_changed)(struct cdrom *dev);
int (*media_type_id)(uint8_t id); int (*media_type_id)(struct cdrom *dev);
int (*audio_callback)(uint8_t id, int16_t *output, int len); int (*audio_callback)(struct cdrom *dev, int16_t *output, int len);
void (*audio_stop)(uint8_t id); void (*audio_stop)(struct cdrom *dev);
int (*readtoc)(uint8_t id, uint8_t *b, uint8_t starttrack, int msf, int maxlen, int single); int (*readtoc)(struct cdrom *dev, uint8_t *b, uint8_t starttrack, int msf, int maxlen, int single);
int (*readtoc_session)(uint8_t id, uint8_t *b, int msf, int maxlen); int (*readtoc_session)(struct cdrom *dev, uint8_t *b, int msf, int maxlen);
int (*readtoc_raw)(uint8_t id, uint8_t *b, int maxlen); int (*readtoc_raw)(struct cdrom *dev, uint8_t *b, int maxlen);
uint8_t (*getcurrentsubchannel)(uint8_t id, uint8_t *b, int msf); uint8_t (*getcurrentsubchannel)(struct cdrom *dev, uint8_t *b, int msf);
int (*readsector_raw)(uint8_t id, uint8_t *buffer, int sector, int ismsf, int cdrom_sector_type, int cdrom_sector_flags, int *len); int (*readsector_raw)(struct cdrom *dev, uint8_t *buffer, int sector, int ismsf, int cdrom_sector_type, int cdrom_sector_flags, int *len);
uint8_t (*playaudio)(uint8_t id, uint32_t pos, uint32_t len, int ismsf); uint8_t (*playaudio)(struct cdrom *dev, uint32_t pos, uint32_t len, int ismsf);
void (*pause)(uint8_t id); void (*pause)(struct cdrom *dev);
void (*resume)(uint8_t id); void (*resume)(struct cdrom *dev);
uint32_t (*size)(uint8_t id); uint32_t (*size)(struct cdrom *dev);
int (*status)(uint8_t id); int (*status)(struct cdrom *dev);
void (*stop)(uint8_t id); void (*stop)(struct cdrom *dev);
void (*exit)(uint8_t id); void (*exit)(struct cdrom *dev);
} CDROM; } cdrom_ops_t;
typedef struct { typedef struct cdrom {
CDROM *handler; uint8_t id,
speed, cur_speed,
int16_t cd_buffer[BUF_SIZE]; ide_channel, scsi_device_id,
bus_type, /* 0 = ATAPI, 1 = SCSI */
uint8_t speed, ide_channel, bus_mode, /* Bit 0 = PIO suported;
pad, bus_mode; /* Bit 0 = PIO suported;
Bit 1 = DMA supportd. */ Bit 1 = DMA supportd. */
int host_drive, prev_host_drive, sound_on;
cd_status, prev_status,
cd_buflen, cd_state,
handler_inited, cur_speed,
id;
unsigned int bus_type, /* 0 = ATAPI, 1 = SCSI */ FILE* img_fp;
scsi_device_id, sound_on; int img_is_iso,
host_drive, prev_host_drive,
cd_status, prev_status,
cd_buflen, cd_state;
uint32_t seek_pos, seek_diff, uint32_t seek_pos, seek_diff,
cd_end, cdrom_capacity; cd_end,
cdrom_capacity;
const cdrom_ops_t *ops;
void *image;
void *p; void *p;
void (*insert)(void *p); void (*insert)(void *p);
void (*close)(void *p);
uint32_t (*get_volume)(void *p, int channel); uint32_t (*get_volume)(void *p, int channel);
uint32_t (*get_channel)(void *p, int channel); uint32_t (*get_channel)(void *p, int channel);
void (*close)(void *p);
} cdrom_drive_t;
typedef struct {
wchar_t image_path[1024], wchar_t image_path[1024],
*prev_image_path; *prev_image_path;
FILE* image;
int image_is_iso; int16_t cd_buffer[BUF_SIZE];
} cdrom_image_t; } cdrom_t;
extern cdrom_drive_t cdrom_drives[CDROM_NUM]; extern cdrom_t cdrom[CDROM_NUM];
extern cdrom_image_t cdrom_image[CDROM_NUM];
#ifdef __cplusplus
extern "C" {
#endif
extern int cdrom_lba_to_msf_accurate(int lba); extern int cdrom_lba_to_msf_accurate(int lba);
extern double cdrom_get_short_seek(cdrom_drive_t *dev); extern double cdrom_seek_time(cdrom_t *dev);
extern double cdrom_get_long_seek(cdrom_drive_t *dev); extern void cdrom_seek(cdrom_t *dev, uint32_t pos);
extern double cdrom_seek_time(cdrom_drive_t *dev); extern int cdrom_playing_completed(cdrom_t *dev);
extern void cdrom_seek(cdrom_drive_t *dev, uint32_t pos);
extern int cdrom_playing_completed(cdrom_drive_t *dev);
extern void cdrom_close_handler(uint8_t id); extern void cdrom_close_handler(uint8_t id);
extern void cdrom_close(void); extern void cdrom_insert(uint8_t id);
extern void cdrom_update_cdb(uint8_t *cdb, int lba_pos, int number_of_blocks); extern void cdrom_eject(uint8_t id);
extern void cdrom_reload(uint8_t id);
extern int cdrom_image_open(cdrom_t *dev, const wchar_t *fn);
extern void cdrom_image_close(cdrom_t *dev);
extern void cdrom_image_reset(cdrom_t *dev);
extern void cdrom_update_cdb(uint8_t *cdb, int lba_pos,
int number_of_blocks);
extern int find_cdrom_for_scsi_id(uint8_t scsi_id); extern int find_cdrom_for_scsi_id(uint8_t scsi_id);
extern void cdrom_close(void);
extern void cdrom_global_init(void); extern void cdrom_global_init(void);
extern void cdrom_global_reset(void); extern void cdrom_global_reset(void);
extern void cdrom_hard_reset(void); extern void cdrom_hard_reset(void);

File diff suppressed because it is too large Load Diff

View File

@@ -1,161 +0,0 @@
/*
* 86Box A hypervisor and IBM PC system emulator that specializes in
* running old operating systems and software designed for IBM
* PC systems and compatibles from 1981 through fairly recent
* system designs based on the PCI bus.
*
* This file is part of the 86Box distribution.
*
* Implementation of the CD-ROM null interface for unmounted
* guest CD-ROM drives.
*
* Version: @(#)cdrom_null.c 1.0.9 2018/10/09
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
*
* Copyright 2008-2016 Sarah Walker.
* Copyright 2016-2018 Miran Grca.
*/
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#include "../86box.h"
#include "../scsi/scsi_device.h"
#include "cdrom.h"
static CDROM null_cdrom;
static int
null_ready(uint8_t id)
{
return(0);
}
/* Always return 0, the contents of a null CD-ROM drive never change. */
static int
null_medium_changed(uint8_t id)
{
return(0);
}
static uint8_t
null_getcurrentsubchannel(uint8_t id, uint8_t *b, int msf)
{
return(0x13);
}
static int
null_readsector_raw(uint8_t id, uint8_t *buffer, int sector, int ismsf, int cdrom_sector_type, int cdrom_sector_flags, int *len)
{
*len = 0;
return(0);
}
static int
null_readtoc(uint8_t id, uint8_t *b, uint8_t starttrack, int msf, int maxlen, int single)
{
return(0);
}
static int
null_readtoc_session(uint8_t id, uint8_t *b, int msf, int maxlen)
{
return(0);
}
static int
null_readtoc_raw(uint8_t id, uint8_t *b, int maxlen)
{
return(0);
}
static uint32_t
null_size(uint8_t id)
{
return(0);
}
static int
null_status(uint8_t id)
{
return(CD_STATUS_EMPTY);
}
void
cdrom_null_reset(uint8_t id)
{
}
void cdrom_set_null_handler(uint8_t id);
int
cdrom_null_open(uint8_t id)
{
cdrom_set_null_handler(id);
return(0);
}
void
null_close(uint8_t id)
{
}
static
void null_exit(uint8_t id)
{
}
static int
null_media_type_id(uint8_t id)
{
return(0x70);
}
void
cdrom_set_null_handler(uint8_t id)
{
cdrom_drives[id].handler = &null_cdrom;
cdrom_drives[id].host_drive = 0;
memset(cdrom_image[id].image_path, 0, sizeof(cdrom_image[id].image_path));
}
static CDROM null_cdrom = {
null_ready,
null_medium_changed,
null_media_type_id,
NULL,
NULL,
null_readtoc,
null_readtoc_session,
null_readtoc_raw,
null_getcurrentsubchannel,
null_readsector_raw,
NULL,
NULL,
NULL,
null_size,
null_status,
NULL,
null_exit
};

View File

@@ -1,28 +0,0 @@
/*
* 86Box A hypervisor and IBM PC system emulator that specializes in
* running old operating systems and software designed for IBM
* PC systems and compatibles from 1981 through fairly recent
* system designs based on the PCI bus.
*
* This file is part of the 86Box distribution.
*
* Implementation of the CD-ROM null interface for unmounted
* guest CD-ROM drives.
*
* Version: @(#)cdrom_null.h 1.0.4 2018/03/31
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
* Copyright 2008-2018 Sarah Walker.
* Copyright 2016-2018 Miran Grca.
*/
#ifndef EMU_CDROM_NULL_H
#define EMU_CDROM_NULL_H
extern int cdrom_null_open(uint8_t id);
extern void cdrom_null_reset(uint8_t id);
extern void null_close(uint8_t id);
#endif /*EMU_CDROM_NULL_H*/

View File

@@ -8,7 +8,7 @@
* *
* Configuration file handler. * Configuration file handler.
* *
* Version: @(#)config.c 1.0.57 2018/10/07 * Version: @(#)config.c 1.0.58 2018/10/17
* *
* Authors: Sarah Walker, * Authors: Sarah Walker,
* Miran Grca, <mgrca8@gmail.com> * Miran Grca, <mgrca8@gmail.com>
@@ -112,22 +112,22 @@ static list_t config_head;
#ifdef ENABLE_CONFIG_LOG #ifdef ENABLE_CONFIG_LOG
int config_do_log = ENABLE_CONFIG_LOG; int config_do_log = ENABLE_CONFIG_LOG;
#endif
static void static void
config_log(const char *format, ...) config_log(const char *fmt, ...)
{ {
#ifdef ENABLE_CONFIG_LOG
va_list ap; va_list ap;
if (config_do_log) { if (config_do_log) {
va_start(ap, format); va_start(ap, fmt);
pclog_ex(format, ap); pclog_ex(fmt, ap);
va_end(ap); va_end(ap);
} }
#endif
} }
#else
#define config_log(fmt, ...)
#endif
static section_t * static section_t *
@@ -1046,46 +1046,47 @@ load_other_removable_devices(void)
char s[512]; char s[512];
unsigned int board = 0, dev = 0; unsigned int board = 0, dev = 0;
wchar_t *wp; wchar_t *wp;
int c; int c, d = 0;
memset(temp, 0x00, sizeof(temp)); memset(temp, 0x00, sizeof(temp));
for (c=0; c<CDROM_NUM; c++) { for (c=0; c<CDROM_NUM; c++) {
sprintf(temp, "cdrom_%02i_host_drive", c+1); sprintf(temp, "cdrom_%02i_host_drive", c+1);
cdrom_drives[c].host_drive = config_get_int(cat, temp, 0); cdrom[c].host_drive = config_get_int(cat, temp, 0);
cdrom_drives[c].prev_host_drive = cdrom_drives[c].host_drive; cdrom[c].prev_host_drive = cdrom[c].host_drive;
sprintf(temp, "cdrom_%02i_parameters", c+1); sprintf(temp, "cdrom_%02i_parameters", c+1);
p = config_get_string(cat, temp, NULL); p = config_get_string(cat, temp, NULL);
if (p != NULL) if (p != NULL)
sscanf(p, "%01u, %s", &cdrom_drives[c].sound_on, s); sscanf(p, "%01u, %s", &d, s);
else else
sscanf("0, none", "%01u, %s", &cdrom_drives[c].sound_on, s); sscanf("0, none", "%01u, %s", &d, s);
cdrom_drives[c].bus_type = hdd_string_to_bus(s, 1); cdrom[c].sound_on = d;
cdrom[c].bus_type = hdd_string_to_bus(s, 1);
sprintf(temp, "cdrom_%02i_speed", c+1); sprintf(temp, "cdrom_%02i_speed", c+1);
cdrom_drives[c].speed = config_get_int(cat, temp, 8); cdrom[c].speed = config_get_int(cat, temp, 8);
/* Default values, needed for proper operation of the Settings dialog. */ /* Default values, needed for proper operation of the Settings dialog. */
cdrom_drives[c].ide_channel = cdrom_drives[c].scsi_device_id = c + 2; cdrom[c].ide_channel = cdrom[c].scsi_device_id = c + 2;
sprintf(temp, "cdrom_%02i_ide_channel", c+1); sprintf(temp, "cdrom_%02i_ide_channel", c+1);
if (cdrom_drives[c].bus_type == CDROM_BUS_ATAPI) { if (cdrom[c].bus_type == CDROM_BUS_ATAPI) {
sprintf(tmp2, "%01u:%01u", (c+2)>>1, (c+2)&1); sprintf(tmp2, "%01u:%01u", (c+2)>>1, (c+2)&1);
p = config_get_string(cat, temp, tmp2); p = config_get_string(cat, temp, tmp2);
sscanf(p, "%01u:%01u", &board, &dev); sscanf(p, "%01u:%01u", &board, &dev);
board &= 3; board &= 3;
dev &= 1; dev &= 1;
cdrom_drives[c].ide_channel = (board<<1)+dev; cdrom[c].ide_channel = (board<<1)+dev;
if (cdrom_drives[c].ide_channel > 7) if (cdrom[c].ide_channel > 7)
cdrom_drives[c].ide_channel = 7; cdrom[c].ide_channel = 7;
} else { } else {
sprintf(temp, "cdrom_%02i_scsi_id", c+1); sprintf(temp, "cdrom_%02i_scsi_id", c+1);
if (cdrom_drives[c].bus_type == CDROM_BUS_SCSI) { if (cdrom[c].bus_type == CDROM_BUS_SCSI) {
cdrom_drives[c].scsi_device_id = config_get_int(cat, temp, c+2); cdrom[c].scsi_device_id = config_get_int(cat, temp, c+2);
if (cdrom_drives[c].scsi_device_id > 15) if (cdrom[c].scsi_device_id > 15)
cdrom_drives[c].scsi_device_id = 15; cdrom[c].scsi_device_id = 15;
} else } else
config_delete_var(cat, temp); config_delete_var(cat, temp);
} }
@@ -1107,20 +1108,20 @@ load_other_removable_devices(void)
* with the EXE path. Just strip * with the EXE path. Just strip
* that off for now... * that off for now...
*/ */
wcsncpy(cdrom_image[c].image_path, &wp[wcslen(usr_path)], sizeof_w(cdrom_image[c].image_path)); wcsncpy(cdrom[c].image_path, &wp[wcslen(usr_path)], sizeof_w(cdrom[c].image_path));
} else } else
#endif #endif
wcsncpy(cdrom_image[c].image_path, wp, sizeof_w(cdrom_image[c].image_path)); wcsncpy(cdrom[c].image_path, wp, sizeof_w(cdrom[c].image_path));
if (cdrom_drives[c].host_drive < 'A') if (cdrom[c].host_drive && (cdrom[c].host_drive != 200))
cdrom_drives[c].host_drive = 0; cdrom[c].host_drive = 0;
if ((cdrom_drives[c].host_drive == 0x200) && if ((cdrom[c].host_drive == 0x200) &&
(wcslen(cdrom_image[c].image_path) == 0)) (wcslen(cdrom[c].image_path) == 0))
cdrom_drives[c].host_drive = 0; cdrom[c].host_drive = 0;
/* If the CD-ROM is disabled, delete all its variables. */ /* If the CD-ROM is disabled, delete all its variables. */
if (cdrom_drives[c].bus_type == CDROM_BUS_DISABLED) { if (cdrom[c].bus_type == CDROM_BUS_DISABLED) {
sprintf(temp, "cdrom_%02i_host_drive", c+1); sprintf(temp, "cdrom_%02i_host_drive", c+1);
config_delete_var(cat, temp); config_delete_var(cat, temp);
@@ -1231,8 +1232,7 @@ config_load(void)
config_log("Loading config file '%ls'..\n", cfg_path); config_log("Loading config file '%ls'..\n", cfg_path);
memset(hdd, 0, sizeof(hard_disk_t)); memset(hdd, 0, sizeof(hard_disk_t));
memset(cdrom_drives, 0, sizeof(cdrom_drive_t) * CDROM_NUM); memset(cdrom, 0, sizeof(cdrom_t) * CDROM_NUM);
memset(cdrom_image, 0, sizeof(cdrom_image_t) * CDROM_NUM);
#ifdef USE_IOCTL #ifdef USE_IOCTL
memset(cdrom_ioctl, 0, sizeof(cdrom_ioctl_t) * CDROM_NUM); memset(cdrom_ioctl, 0, sizeof(cdrom_ioctl_t) * CDROM_NUM);
#endif #endif
@@ -1813,51 +1813,50 @@ save_other_removable_devices(void)
for (c=0; c<CDROM_NUM; c++) { for (c=0; c<CDROM_NUM; c++) {
sprintf(temp, "cdrom_%02i_host_drive", c+1); sprintf(temp, "cdrom_%02i_host_drive", c+1);
if ((cdrom_drives[c].bus_type == 0) || if ((cdrom[c].bus_type == 0) || (cdrom[c].host_drive != 200)) {
(cdrom_drives[c].host_drive < 'A') || ((cdrom_drives[c].host_drive > 'Z') && (cdrom_drives[c].host_drive != 200))) {
config_delete_var(cat, temp); config_delete_var(cat, temp);
} else { } else {
config_set_int(cat, temp, cdrom_drives[c].host_drive); config_set_int(cat, temp, cdrom[c].host_drive);
} }
sprintf(temp, "cdrom_%02i_speed", c+1); sprintf(temp, "cdrom_%02i_speed", c+1);
if ((cdrom_drives[c].bus_type == 0) || (cdrom_drives[c].speed == 8)) { if ((cdrom[c].bus_type == 0) || (cdrom[c].speed == 8)) {
config_delete_var(cat, temp); config_delete_var(cat, temp);
} else { } else {
config_set_int(cat, temp, cdrom_drives[c].speed); config_set_int(cat, temp, cdrom[c].speed);
} }
sprintf(temp, "cdrom_%02i_parameters", c+1); sprintf(temp, "cdrom_%02i_parameters", c+1);
if (cdrom_drives[c].bus_type == 0) { if (cdrom[c].bus_type == 0) {
config_delete_var(cat, temp); config_delete_var(cat, temp);
} else { } else {
sprintf(tmp2, "%u, %s", cdrom_drives[c].sound_on, sprintf(tmp2, "%u, %s", cdrom[c].sound_on,
hdd_bus_to_string(cdrom_drives[c].bus_type, 1)); hdd_bus_to_string(cdrom[c].bus_type, 1));
config_set_string(cat, temp, tmp2); config_set_string(cat, temp, tmp2);
} }
sprintf(temp, "cdrom_%02i_ide_channel", c+1); sprintf(temp, "cdrom_%02i_ide_channel", c+1);
if (cdrom_drives[c].bus_type != CDROM_BUS_ATAPI) if (cdrom[c].bus_type != CDROM_BUS_ATAPI)
config_delete_var(cat, temp); config_delete_var(cat, temp);
else { else {
sprintf(tmp2, "%01u:%01u", cdrom_drives[c].ide_channel>>1, sprintf(tmp2, "%01u:%01u", cdrom[c].ide_channel>>1,
cdrom_drives[c].ide_channel & 1); cdrom[c].ide_channel & 1);
config_set_string(cat, temp, tmp2); config_set_string(cat, temp, tmp2);
} }
sprintf(temp, "cdrom_%02i_scsi_id", c + 1); sprintf(temp, "cdrom_%02i_scsi_id", c + 1);
if (cdrom_drives[c].bus_type != CDROM_BUS_SCSI) { if (cdrom[c].bus_type != CDROM_BUS_SCSI) {
config_delete_var(cat, temp); config_delete_var(cat, temp);
} else { } else {
config_set_int(cat, temp, cdrom_drives[c].scsi_device_id); config_set_int(cat, temp, cdrom[c].scsi_device_id);
} }
sprintf(temp, "cdrom_%02i_image_path", c + 1); sprintf(temp, "cdrom_%02i_image_path", c + 1);
if ((cdrom_drives[c].bus_type == 0) || if ((cdrom[c].bus_type == 0) ||
(wcslen(cdrom_image[c].image_path) == 0)) { (wcslen(cdrom[c].image_path) == 0)) {
config_delete_var(cat, temp); config_delete_var(cat, temp);
} else { } else {
config_set_wstring(cat, temp, cdrom_image[c].image_path); config_set_wstring(cat, temp, cdrom[c].image_path);
} }
} }

View File

@@ -9,7 +9,7 @@
* Implementation of the IDE emulation for hard disks and ATAPI * Implementation of the IDE emulation for hard disks and ATAPI
* CD-ROM devices. * CD-ROM devices.
* *
* Version: @(#)hdc_ide.c 1.0.50 2018/10/10 * Version: @(#)hdc_ide.c 1.0.51 2018/10/17
* *
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/> * Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com> * Miran Grca, <mgrca8@gmail.com>
@@ -140,13 +140,11 @@ static void ide_callback(void *priv);
#ifdef ENABLE_IDE_LOG #ifdef ENABLE_IDE_LOG
int ide_do_log = ENABLE_IDE_LOG; int ide_do_log = ENABLE_IDE_LOG;
#endif
static void static void
ide_log(const char *fmt, ...) ide_log(const char *fmt, ...)
{ {
#ifdef ENABLE_IDE_LOG
va_list ap; va_list ap;
if (ide_do_log) { if (ide_do_log) {
@@ -154,8 +152,10 @@ ide_log(const char *fmt, ...)
pclog_ex(fmt, ap); pclog_ex(fmt, ap);
va_end(ap); va_end(ap);
} }
#endif
} }
#else
#define ide_log(fmt, ...)
#endif
uint8_t uint8_t
@@ -2427,8 +2427,8 @@ secondary_ide_check(void)
secondary_zips++; secondary_zips++;
} }
for (i=0; i<CDROM_NUM; i++) { for (i=0; i<CDROM_NUM; i++) {
if ((cdrom_drives[i].ide_channel >= 2) && (cdrom_drives[i].ide_channel <= 3) && if ((cdrom[i].ide_channel >= 2) && (cdrom[i].ide_channel <= 3) &&
(cdrom_drives[i].bus_type == CDROM_BUS_ATAPI)) (cdrom[i].bus_type == CDROM_BUS_ATAPI))
secondary_cdroms++; secondary_cdroms++;
} }
if (!secondary_zips && !secondary_cdroms) if (!secondary_zips && !secondary_cdroms)

View File

@@ -10,7 +10,7 @@
* word 0 - base address * word 0 - base address
* word 1 - bits 1-15 = byte count, bit 31 = end of transfer * word 1 - bits 1-15 = byte count, bit 31 = end of transfer
* *
* Version: @(#)intel_piix.c 1.0.18 2018/10/02 * Version: @(#)intel_piix.c 1.0.19 2018/10/17
* *
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/> * Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com> * Miran Grca, <mgrca8@gmail.com>
@@ -69,22 +69,22 @@ static void piix_bus_master_writel(uint16_t port, uint32_t val, void *priv);
#ifdef ENABLE_PIIX_LOG #ifdef ENABLE_PIIX_LOG
int piix_do_log = ENABLE_PIIX_LOG; int piix_do_log = ENABLE_PIIX_LOG;
#endif
static void static void
piix_log(const char *format, ...) piix_log(const char *fmt, ...)
{ {
#ifdef ENABLE_PIIX_LOG
va_list ap; va_list ap;
if (piix_do_log) { if (piix_do_log) {
va_start(ap, format); va_start(ap, fmt);
pclog_ex(format, ap); pclog_ex(fmt, ap);
va_end(ap); va_end(ap);
} }
#endif
} }
#else
#define piix_log(fmt, ...)
#endif
static void static void
@@ -427,7 +427,9 @@ static void
piix_bus_master_write(uint16_t port, uint8_t val, void *priv) piix_bus_master_write(uint16_t port, uint8_t val, void *priv)
{ {
piix_busmaster_t *dev = (piix_busmaster_t *) priv; piix_busmaster_t *dev = (piix_busmaster_t *) priv;
#ifdef ENABLE_PIIX_LOG
int channel = (port & 8) ? 1 : 0; int channel = (port & 8) ? 1 : 0;
#endif
piix_log("PIIX Bus master BYTE write: %04X %02X\n", port, val); piix_log("PIIX Bus master BYTE write: %04X %02X\n", port, val);
@@ -610,11 +612,15 @@ static int
piix_bus_master_dma_op(int channel, uint8_t *data, int transfer_length, int out, void *priv) piix_bus_master_dma_op(int channel, uint8_t *data, int transfer_length, int out, void *priv)
{ {
piix_busmaster_t *dev = (piix_busmaster_t *) priv; piix_busmaster_t *dev = (piix_busmaster_t *) priv;
#ifdef ENABLE_PIIX_LOG
char *sop; char *sop;
#endif
int force_end = 0, buffer_pos = 0; int force_end = 0, buffer_pos = 0;
#ifdef ENABLE_PIIX_LOG
sop = out ? "Writ" : "Read"; sop = out ? "Writ" : "Read";
#endif
if (!(dev->status & 1)) if (!(dev->status & 1))
return 2; /*DMA disabled*/ return 2; /*DMA disabled*/
@@ -825,7 +831,7 @@ piix_reset(void *p)
int i = 0; int i = 0;
for (i = 0; i < CDROM_NUM; i++) { for (i = 0; i < CDROM_NUM; i++) {
if (cdrom_drives[i].bus_type == CDROM_BUS_ATAPI) if (cdrom[i].bus_type == CDROM_BUS_ATAPI)
scsi_cdrom_reset(scsi_cdrom[i]); scsi_cdrom_reset(scsi_cdrom[i]);
} }
for (i = 0; i < ZIP_NUM; i++) { for (i = 0; i < ZIP_NUM; i++) {

View File

@@ -8,7 +8,7 @@
* *
* Main emulator module where most things are controlled. * Main emulator module where most things are controlled.
* *
* Version: @(#)pc.c 1.0.83 2018/10/12 * Version: @(#)pc.c 1.0.84 2018/10/17
* *
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/> * Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com> * Miran Grca, <mgrca8@gmail.com>
@@ -65,7 +65,6 @@
#include "disk/zip.h" #include "disk/zip.h"
#include "scsi/scsi_disk.h" #include "scsi/scsi_disk.h"
#include "cdrom/cdrom_image.h" #include "cdrom/cdrom_image.h"
#include "cdrom/cdrom_null.h"
#include "network/network.h" #include "network/network.h"
#include "sound/sound.h" #include "sound/sound.h"
#include "sound/midi.h" #include "sound/midi.h"

View File

@@ -8,7 +8,7 @@
* *
* Define the various platform support functions. * Define the various platform support functions.
* *
* Version: @(#)plat.h 1.0.26 2018/02/14 * Version: @(#)plat.h 1.0.27 2018/10/17
* *
* Authors: Miran Grca, <mgrca8@gmail.com> * Authors: Miran Grca, <mgrca8@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com> * Fred N. van Kempen, <decwiz@yahoo.com>
@@ -104,14 +104,7 @@ extern void do_stop(void);
/* Platform-specific device support. */ /* Platform-specific device support. */
extern uint8_t host_cdrom_drive_available[26]; extern void plat_cdrom_ui_update(uint8_t id, uint8_t reload);
extern uint8_t host_cdrom_drive_available_num;
#ifdef USE_IOCTL
extern void cdrom_init_host_drives(void);
#endif
extern void cdrom_eject(uint8_t id);
extern void cdrom_reload(uint8_t id);
extern void zip_eject(uint8_t id); extern void zip_eject(uint8_t id);
extern void zip_reload(uint8_t id); extern void zip_reload(uint8_t id);
extern int ioctl_open(uint8_t id, char d); extern int ioctl_open(uint8_t id, char d);

View File

@@ -9,7 +9,7 @@
* Implementation of the CD-ROM drive with SCSI(-like) * Implementation of the CD-ROM drive with SCSI(-like)
* commands, for both ATAPI and SCSI usage. * commands, for both ATAPI and SCSI usage.
* *
* Version: @(#)scsi_cdrom.c 1.0.52 2018/10/09 * Version: @(#)scsi_cdrom.c 1.0.53 2018/10/17
* *
* Author: Miran Grca, <mgrca8@gmail.com> * Author: Miran Grca, <mgrca8@gmail.com>
* *
@@ -32,12 +32,10 @@
#include "../nvr.h" #include "../nvr.h"
#include "../disk/hdc.h" #include "../disk/hdc.h"
#include "../disk/hdc_ide.h" #include "../disk/hdc_ide.h"
#include "../plat.h"
#include "../sound/sound.h" #include "../sound/sound.h"
#include "../plat.h"
#include "../ui.h" #include "../ui.h"
#include "../cdrom/cdrom.h" #include "../cdrom/cdrom.h"
#include "../cdrom/cdrom_image.h"
#include "../cdrom/cdrom_null.h"
#include "scsi_cdrom.h" #include "scsi_cdrom.h"
@@ -335,13 +333,11 @@ static void scsi_cdrom_callback(void *p);
#ifdef ENABLE_SCSI_CDROM_LOG #ifdef ENABLE_SCSI_CDROM_LOG
int scsi_cdrom_do_log = ENABLE_SCSI_CDROM_LOG; int scsi_cdrom_do_log = ENABLE_SCSI_CDROM_LOG;
#endif
static void static void
scsi_cdrom_log(const char *format, ...) scsi_cdrom_log(const char *format, ...)
{ {
#ifdef ENABLE_SCSI_CDROM_LOG
va_list ap; va_list ap;
if (scsi_cdrom_do_log) { if (scsi_cdrom_do_log) {
@@ -349,8 +345,10 @@ scsi_cdrom_log(const char *format, ...)
pclog_ex(format, ap); pclog_ex(format, ap);
va_end(ap); va_end(ap);
} }
#endif
} }
#else
#define scsi_cdrom_log(format, ...)
#endif
static void static void
@@ -379,8 +377,8 @@ scsi_cdrom_init(scsi_cdrom_t *dev)
if (!dev) if (!dev)
return; return;
/* Tell the scsi_cdrom_t struct what cdrom_drives element corresponds to it. */ /* Tell the scsi_cdrom_t struct what cdrom element corresponds to it. */
dev->drv = &(cdrom_drives[dev->id]); dev->drv = &(cdrom[dev->id]);
/* Do a reset (which will also rezero it). */ /* Do a reset (which will also rezero it). */
scsi_cdrom_reset(dev); scsi_cdrom_reset(dev);
@@ -542,7 +540,8 @@ scsi_cdrom_read_capacity(void *p, uint8_t *cdb, uint8_t *buffer, uint32_t *len)
scsi_cdrom_t *dev = (scsi_cdrom_t *) p; scsi_cdrom_t *dev = (scsi_cdrom_t *) p;
int size = 0; int size = 0;
size = dev->drv->handler->size(dev->id) - 1; /* IMPORTANT: What's returned is the last LBA block. */ if (dev->drv->ops && dev->drv->ops->size)
size = dev->drv->ops->size(dev->drv) - 1; /* IMPORTANT: What's returned is the last LBA block. */
memset(buffer, 0, 8); memset(buffer, 0, 8);
buffer[0] = (size >> 24) & 0xff; buffer[0] = (size >> 24) & 0xff;
buffer[1] = (size >> 16) & 0xff; buffer[1] = (size >> 16) & 0xff;
@@ -1084,7 +1083,12 @@ scsi_cdrom_read_data(scsi_cdrom_t *dev, int msf, int type, int flags, int32_t *l
int i = 0; int i = 0;
int temp_len = 0; int temp_len = 0;
cdsize = dev->drv->handler->size(dev->id); if (dev->drv->ops && dev->drv->ops->size)
cdsize = dev->drv->ops->size(dev->drv);
else {
scsi_cdrom_not_ready(dev);
return 0;
}
if (dev->sector_pos >= cdsize) { if (dev->sector_pos >= cdsize) {
scsi_cdrom_log("CD-ROM %i: Trying to read from beyond the end of disc (%i >= %i)\n", dev->id, scsi_cdrom_log("CD-ROM %i: Trying to read from beyond the end of disc (%i >= %i)\n", dev->id,
@@ -1104,8 +1108,13 @@ scsi_cdrom_read_data(scsi_cdrom_t *dev, int msf, int type, int flags, int32_t *l
*len = 0; *len = 0;
for (i = 0; i < dev->requested_blocks; i++) { for (i = 0; i < dev->requested_blocks; i++) {
ret = dev->drv->handler->readsector_raw(dev->id, cdbufferb + dev->data_pos, dev->sector_pos + i, if (dev->drv->ops && dev->drv->ops->readsector_raw)
msf, type, flags, &temp_len); ret = dev->drv->ops->readsector_raw(dev->drv, cdbufferb + dev->data_pos,
dev->sector_pos + i, msf, type, flags, &temp_len);
else {
scsi_cdrom_not_ready(dev);
return 0;
}
dev->data_pos += temp_len; dev->data_pos += temp_len;
dev->old_len += temp_len; dev->old_len += temp_len;
@@ -1173,11 +1182,16 @@ static int
scsi_cdrom_read_dvd_structure(scsi_cdrom_t *dev, int format, const uint8_t *packet, uint8_t *buf) scsi_cdrom_read_dvd_structure(scsi_cdrom_t *dev, int format, const uint8_t *packet, uint8_t *buf)
{ {
int layer = packet[6]; int layer = packet[6];
uint64_t total_sectors; uint64_t total_sectors = 0;
switch (format) { switch (format) {
case 0x00: /* Physical format information */ case 0x00: /* Physical format information */
total_sectors = (uint64_t) dev->drv->handler->size(dev->id); if (dev->drv->ops && dev->drv->ops->size)
total_sectors = (uint64_t) dev->drv->ops->size(dev->drv);
else {
scsi_cdrom_not_ready(dev);
return 0;
}
if (layer != 0) { if (layer != 0) {
scsi_cdrom_invalid_field(dev); scsi_cdrom_invalid_field(dev);
@@ -1325,17 +1339,23 @@ scsi_cdrom_pre_execution_check(scsi_cdrom_t *dev, uint8_t *cdb)
return 0; return 0;
} }
status = dev->drv->handler->status(dev->id); if (dev->drv->ops && dev->drv->ops->status)
status = dev->drv->ops->status(dev->drv);
else
status = CD_STATUS_EMPTY;
if ((status == CD_STATUS_PLAYING) || (status == CD_STATUS_PAUSED)) { if ((status == CD_STATUS_PLAYING) || (status == CD_STATUS_PAUSED)) {
ready = 1; ready = 1;
goto skip_ready_check; goto skip_ready_check;
} }
if (dev->drv->handler->medium_changed(dev->id)) if (dev->drv->ops && dev->drv->ops->medium_changed) {
scsi_cdrom_insert((void *) dev); if (dev->drv->ops->medium_changed(dev->drv))
scsi_cdrom_insert((void *) dev);
}
ready = dev->drv->handler->ready(dev->id); if (dev->drv->ops && dev->drv->ops->ready)
ready = dev->drv->ops->ready(dev->drv);
skip_ready_check: skip_ready_check:
/* If the drive is not ready, there is no reason to keep the /* If the drive is not ready, there is no reason to keep the
@@ -1461,10 +1481,13 @@ scsi_cdrom_request_sense_for_scsi(void *p, uint8_t *buffer, uint8_t alloc_length
scsi_cdrom_t *dev = (scsi_cdrom_t *) p; scsi_cdrom_t *dev = (scsi_cdrom_t *) p;
int ready = 0; int ready = 0;
if (dev->drv->handler->medium_changed(dev->id)) if (dev->drv->ops && dev->drv->ops->medium_changed) {
scsi_cdrom_insert((void *) dev); if (dev->drv->ops->medium_changed(dev->drv))
scsi_cdrom_insert((void *) dev);
}
ready = dev->drv->handler->ready(dev->id); if (dev->drv->ops && dev->drv->ops->ready)
ready = dev->drv->ops->ready(dev->drv);
if (!ready && dev->unit_attention) { if (!ready && dev->unit_attention) {
/* If the drive is not ready, there is no reason to keep the /* If the drive is not ready, there is no reason to keep the
@@ -1551,7 +1574,10 @@ scsi_cdrom_command(void *p, uint8_t *cdb)
memcpy(dev->current_cdb, cdb, 12); memcpy(dev->current_cdb, cdb, 12);
dev->drv->cd_status = dev->drv->handler->status(dev->id); if (dev->drv->ops && dev->drv->ops->status)
dev->drv->cd_status = dev->drv->ops->status(dev->drv);
else
dev->drv->cd_status = CD_STATUS_EMPTY;
if (cdb[0] != 0) { if (cdb[0] != 0) {
scsi_cdrom_log("CD-ROM %i: Command 0x%02X, Sense Key %02X, Asc %02X, Ascq %02X, Unit attention: %i\n", scsi_cdrom_log("CD-ROM %i: Command 0x%02X, Sense Key %02X, Asc %02X, Ascq %02X, Unit attention: %i\n",
@@ -1579,8 +1605,8 @@ scsi_cdrom_command(void *p, uint8_t *cdb)
break; break;
case GPCMD_REZERO_UNIT: case GPCMD_REZERO_UNIT:
if (dev->drv->handler->stop) if (dev->drv->ops->stop)
dev->drv->handler->stop(dev->id); dev->drv->ops->stop(dev->drv);
dev->sector_pos = dev->sector_len = 0; dev->sector_pos = dev->sector_len = 0;
dev->drv->seek_diff = dev->drv->seek_pos; dev->drv->seek_diff = dev->drv->seek_pos;
cdrom_seek(dev->drv, 0); cdrom_seek(dev->drv, 0);
@@ -1646,17 +1672,34 @@ scsi_cdrom_command(void *p, uint8_t *cdb)
if (toc_format == 0) if (toc_format == 0)
toc_format = (cdb[9] >> 6) & 3; toc_format = (cdb[9] >> 6) & 3;
if (!dev->drv->ops) {
scsi_cdrom_not_ready(dev);
return;
}
switch (toc_format) { switch (toc_format) {
case 0: /*Normal*/ case 0: /*Normal*/
len = dev->drv->handler->readtoc(dev->id, cdbufferb, cdb[6], msf, max_len, if (!dev->drv->ops->readtoc) {
scsi_cdrom_not_ready(dev);
return;
}
len = dev->drv->ops->readtoc(dev->drv, cdbufferb, cdb[6], msf, max_len,
0); 0);
break; break;
case 1: /*Multi session*/ case 1: /*Multi session*/
len = dev->drv->handler->readtoc_session(dev->id, cdbufferb, msf, max_len); if (!dev->drv->ops->readtoc_session) {
scsi_cdrom_not_ready(dev);
return;
}
len = dev->drv->ops->readtoc_session(dev->drv, cdbufferb, msf, max_len);
cdbufferb[0] = 0; cdbufferb[1] = 0xA; cdbufferb[0] = 0; cdbufferb[1] = 0xA;
break; break;
case 2: /*Raw*/ case 2: /*Raw*/
len = dev->drv->handler->readtoc_raw(dev->id, cdbufferb, max_len); if (!dev->drv->ops->readtoc_raw) {
scsi_cdrom_not_ready(dev);
return;
}
len = dev->drv->ops->readtoc_raw(dev->drv, cdbufferb, max_len);
break; break;
default: default:
scsi_cdrom_invalid_field(dev); scsi_cdrom_invalid_field(dev);
@@ -1826,7 +1869,10 @@ scsi_cdrom_command(void *p, uint8_t *cdb)
len = scsi_cdrom_mode_sense(dev, cdbufferb, 4, cdb[2], block_desc); len = scsi_cdrom_mode_sense(dev, cdbufferb, 4, cdb[2], block_desc);
len = MIN(len, alloc_length); len = MIN(len, alloc_length);
cdbufferb[0] = len - 1; cdbufferb[0] = len - 1;
cdbufferb[1] = dev->drv->handler->media_type_id(dev->id); if (dev->drv->ops && dev->drv->ops->media_type_id)
cdbufferb[1] = dev->drv->ops->media_type_id(dev->drv);
else
cdbufferb[1] = 0x70;
if (block_desc) if (block_desc)
cdbufferb[3] = 8; cdbufferb[3] = 8;
} else { } else {
@@ -1834,7 +1880,10 @@ scsi_cdrom_command(void *p, uint8_t *cdb)
len = MIN(len, alloc_length); len = MIN(len, alloc_length);
cdbufferb[0]=(len - 2) >> 8; cdbufferb[0]=(len - 2) >> 8;
cdbufferb[1]=(len - 2) & 255; cdbufferb[1]=(len - 2) & 255;
cdbufferb[2] = dev->drv->handler->media_type_id(dev->id); if (dev->drv->ops && dev->drv->ops->media_type_id)
cdbufferb[2] = dev->drv->ops->media_type_id(dev->drv);
else
cdbufferb[2] = 0x70;
if (block_desc) { if (block_desc) {
cdbufferb[6] = 0; cdbufferb[6] = 0;
cdbufferb[7] = 8; cdbufferb[7] = 8;
@@ -1892,8 +1941,9 @@ scsi_cdrom_command(void *p, uint8_t *cdb)
* the number of sectors from the media tells us which profile * the number of sectors from the media tells us which profile
* to use as current. 0 means there is no media * to use as current. 0 means there is no media
*/ */
if (dev->drv->handler->ready(dev->id)) { if (dev->drv->ops && dev->drv->ops->ready &&
len = dev->drv->handler->size(dev->id); dev->drv->ops->ready(dev->drv)) {
len = dev->drv->ops->size(dev->drv);
if (len > CD_MAX_SECTORS) { if (len > CD_MAX_SECTORS) {
b[6] = (MMC_PROFILE_DVD_ROM >> 8) & 0xff; b[6] = (MMC_PROFILE_DVD_ROM >> 8) & 0xff;
b[7] = MMC_PROFILE_DVD_ROM & 0xff; b[7] = MMC_PROFILE_DVD_ROM & 0xff;
@@ -2079,10 +2129,16 @@ scsi_cdrom_command(void *p, uint8_t *cdb)
cdbufferb[5] = (0 << 5) | (0 << 4) | (4 << 0); /* not damaged, primary copy, data track */ cdbufferb[5] = (0 << 5) | (0 << 4) | (4 << 0); /* not damaged, primary copy, data track */
cdbufferb[6] = (0 << 7) | (0 << 6) | (0 << 5) | (0 << 6) | (1 << 0); /* not reserved track, not blank, not packet writing, not fixed packet, data mode 1 */ cdbufferb[6] = (0 << 7) | (0 << 6) | (0 << 5) | (0 << 6) | (1 << 0); /* not reserved track, not blank, not packet writing, not fixed packet, data mode 1 */
cdbufferb[7] = (0 << 1) | (0 << 0); /* last recorded address not valid, next recordable address not valid */ cdbufferb[7] = (0 << 1) | (0 << 0); /* last recorded address not valid, next recordable address not valid */
cdbufferb[24] = (dev->drv->handler->size(dev->id) >> 24) & 0xff; /* track size */ if (dev->drv->ops && dev->drv->ops->size) {
cdbufferb[25] = (dev->drv->handler->size(dev->id) >> 16) & 0xff; /* track size */ cdbufferb[24] = (dev->drv->ops->size(dev->drv) >> 24) & 0xff; /* track size */
cdbufferb[26] = (dev->drv->handler->size(dev->id) >> 8) & 0xff; /* track size */ cdbufferb[25] = (dev->drv->ops->size(dev->drv) >> 16) & 0xff; /* track size */
cdbufferb[27] = dev->drv->handler->size(dev->id) & 0xff; /* track size */ cdbufferb[26] = (dev->drv->ops->size(dev->drv) >> 8) & 0xff; /* track size */
cdbufferb[27] = dev->drv->ops->size(dev->drv) & 0xff; /* track size */
} else {
scsi_cdrom_not_ready(dev);
scsi_cdrom_buf_free(dev);
return;
}
if (len > max_len) { if (len > max_len) {
len = max_len; len = max_len;
@@ -2131,8 +2187,8 @@ scsi_cdrom_command(void *p, uint8_t *cdb)
break; break;
} }
if (dev->drv->handler->playaudio) if (dev->drv->ops && dev->drv->ops->playaudio)
ret = dev->drv->handler->playaudio(dev->id, pos, len, msf); ret = dev->drv->ops->playaudio(dev->drv, pos, len, msf);
else else
ret = 0; ret = 0;
@@ -2181,7 +2237,13 @@ scsi_cdrom_command(void *p, uint8_t *cdb)
cdbufferb[pos++] = 0; cdbufferb[pos++] = 0; /*Subchannel length*/ cdbufferb[pos++] = 0; cdbufferb[pos++] = 0; /*Subchannel length*/
cdbufferb[pos++] = cdb[3] & 3; /*Format code*/ cdbufferb[pos++] = cdb[3] & 3; /*Format code*/
if (cdb[3] == 1) { if (cdb[3] == 1) {
cdbufferb[1] = dev->drv->handler->getcurrentsubchannel(dev->id, &cdbufferb[5], msf); if (dev->drv->ops && dev->drv->ops->getcurrentsubchannel)
cdbufferb[1] = dev->drv->ops->getcurrentsubchannel(dev->drv, &cdbufferb[5], msf);
else {
scsi_cdrom_not_ready(dev);
scsi_cdrom_buf_free(dev);
return;
}
switch(dev->drv->cd_status) { switch(dev->drv->cd_status) {
case CD_STATUS_PLAYING: case CD_STATUS_PLAYING:
cdbufferb[1] = 0x11; cdbufferb[1] = 0x11;
@@ -2216,7 +2278,13 @@ scsi_cdrom_command(void *p, uint8_t *cdb)
scsi_cdrom_buf_alloc(dev, alloc_length); scsi_cdrom_buf_alloc(dev, alloc_length);
len = dev->drv->handler->size(dev->id); if (dev->drv->ops && dev->drv->ops->size)
len = dev->drv->ops->size(dev->drv);
else {
scsi_cdrom_not_ready(dev);
scsi_cdrom_buf_free(dev);
return;
}
if ((cdb[7] < 0xc0) && (len <= CD_MAX_SECTORS)) { if ((cdb[7] < 0xc0) && (len <= CD_MAX_SECTORS)) {
scsi_cdrom_incompatible_format(dev); scsi_cdrom_incompatible_format(dev);
@@ -2249,15 +2317,16 @@ scsi_cdrom_command(void *p, uint8_t *cdb)
switch(cdb[4] & 3) { switch(cdb[4] & 3) {
case 0: /* Stop the disc. */ case 0: /* Stop the disc. */
if (dev->drv->handler->stop) if (dev->drv->ops && dev->drv->ops->stop)
dev->drv->handler->stop(dev->id); dev->drv->ops->stop(dev->drv);
break; break;
case 1: /* Start the disc and read the TOC. */ case 1: /* Start the disc and read the TOC. */
dev->drv->handler->medium_changed(dev->id); /* This causes a TOC reload. */ if (dev->drv->ops && dev->drv->ops->medium_changed)
dev->drv->ops->medium_changed(dev->drv); /* This causes a TOC reload. */
break; break;
case 2: /* Eject the disc if possible. */ case 2: /* Eject the disc if possible. */
if (dev->drv->handler->stop) if (dev->drv->ops && dev->drv->ops->stop)
dev->drv->handler->stop(dev->id); dev->drv->ops->stop(dev->drv);
cdrom_eject(dev->id); cdrom_eject(dev->id);
break; break;
case 3: /* Load the disc (close tray). */ case 3: /* Load the disc (close tray). */
@@ -2371,15 +2440,15 @@ atapi_out:
scsi_cdrom_set_phase(dev, SCSI_PHASE_STATUS); scsi_cdrom_set_phase(dev, SCSI_PHASE_STATUS);
if (cdb[8] & 1) { if (cdb[8] & 1) {
if (dev->drv->handler->resume) if (dev->drv->ops && dev->drv->ops->resume)
dev->drv->handler->resume(dev->id); dev->drv->ops->resume(dev->drv);
else { else {
scsi_cdrom_illegal_mode(dev); scsi_cdrom_illegal_mode(dev);
break; break;
} }
} else { } else {
if (dev->drv->handler->pause) if (dev->drv->ops && dev->drv->ops->pause)
dev->drv->handler->pause(dev->id); dev->drv->ops->pause(dev->drv);
else { else {
scsi_cdrom_illegal_mode(dev); scsi_cdrom_illegal_mode(dev);
break; break;
@@ -2423,8 +2492,8 @@ atapi_out:
case GPCMD_STOP_PLAY_SCAN: case GPCMD_STOP_PLAY_SCAN:
scsi_cdrom_set_phase(dev, SCSI_PHASE_STATUS); scsi_cdrom_set_phase(dev, SCSI_PHASE_STATUS);
if (dev->drv->handler->stop) if (dev->drv->ops && dev->drv->ops->stop)
dev->drv->handler->stop(dev->id); dev->drv->ops->stop(dev->drv);
else { else {
scsi_cdrom_illegal_mode(dev); scsi_cdrom_illegal_mode(dev);
break; break;
@@ -2630,7 +2699,9 @@ scsi_cdrom_irq_raise(scsi_cdrom_t *dev)
static int static int
scsi_cdrom_read_from_dma(scsi_cdrom_t *dev) scsi_cdrom_read_from_dma(scsi_cdrom_t *dev)
{ {
#ifdef ENABLE_SCSI_CDROM_LOG
int32_t *BufLen = &scsi_devices[dev->drv->scsi_device_id].buffer_length; int32_t *BufLen = &scsi_devices[dev->drv->scsi_device_id].buffer_length;
#endif
int ret = 0; int ret = 0;
if (dev->drv->bus_type == CDROM_BUS_SCSI) if (dev->drv->bus_type == CDROM_BUS_SCSI)
@@ -2700,7 +2771,9 @@ scsi_cdrom_write_to_scsi_dma(uint8_t scsi_id)
static int static int
scsi_cdrom_write_to_dma(scsi_cdrom_t *dev) scsi_cdrom_write_to_dma(scsi_cdrom_t *dev)
{ {
#ifdef ENABLE_SCSI_CDROM_LOG
int32_t *BufLen = &scsi_devices[dev->drv->scsi_device_id].buffer_length; int32_t *BufLen = &scsi_devices[dev->drv->scsi_device_id].buffer_length;
#endif
int ret = 0; int ret = 0;
if (dev->drv->bus_type == CDROM_BUS_SCSI) { if (dev->drv->bus_type == CDROM_BUS_SCSI) {
@@ -2930,8 +3003,8 @@ scsi_cdrom_stop(void *p)
{ {
scsi_cdrom_t *dev = (scsi_cdrom_t *) p; scsi_cdrom_t *dev = (scsi_cdrom_t *) p;
if (dev->drv->handler->stop) if (dev->drv->ops && dev->drv->ops->stop)
dev->drv->handler->stop(dev->id); dev->drv->ops->stop(dev->drv);
} }
@@ -2993,6 +3066,7 @@ static void
scsi_cdrom_identify(void *p, int ide_has_dma) scsi_cdrom_identify(void *p, int ide_has_dma)
{ {
ide_t *ide = (ide_t *) p; ide_t *ide = (ide_t *) p;
#if 0
scsi_cdrom_t *dev; scsi_cdrom_t *dev;
char device_identify[9] = { '8', '6', 'B', '_', 'C', 'D', '0', '0', 0 }; char device_identify[9] = { '8', '6', 'B', '_', 'C', 'D', '0', '0', 0 };
@@ -3000,6 +3074,7 @@ scsi_cdrom_identify(void *p, int ide_has_dma)
device_identify[7] = dev->id + 0x30; device_identify[7] = dev->id + 0x30;
scsi_cdrom_log("ATAPI Identify: %s\n", device_identify); scsi_cdrom_log("ATAPI Identify: %s\n", device_identify);
#endif
ide->buffer[0] = 0x8000 | (5<<8) | 0x80 | (2<<5); /* ATAPI device, CD-ROM drive, removable media, accelerated DRQ */ ide->buffer[0] = 0x8000 | (5<<8) | 0x80 | (2<<5); /* ATAPI device, CD-ROM drive, removable media, accelerated DRQ */
ide_padstr((char *) (ide->buffer + 10), "", 20); /* Serial Number */ ide_padstr((char *) (ide->buffer + 10), "", 20); /* Serial Number */
@@ -3023,7 +3098,7 @@ scsi_cdrom_identify(void *p, int ide_has_dma)
void void
scsi_cdrom_drive_reset(int c) scsi_cdrom_drive_reset(int c)
{ {
cdrom_drive_t *drv = &cdrom_drives[c]; cdrom_t *drv = &cdrom[c];
scsi_device_t *sd; scsi_device_t *sd;
ide_t *id; ide_t *id;
@@ -3063,7 +3138,7 @@ scsi_cdrom_drive_reset(int c)
sd->read_capacity = scsi_cdrom_read_capacity; sd->read_capacity = scsi_cdrom_read_capacity;
sd->type = SCSI_REMOVABLE_CDROM; sd->type = SCSI_REMOVABLE_CDROM;
scsi_cdrom_log("SCSI CD-ROM drive %i attached to SCSI ID %i\n", c, cdrom_drives[c].scsi_device_id); scsi_cdrom_log("SCSI CD-ROM drive %i attached to SCSI ID %i\n", c, cdrom[c].scsi_device_id);
} else if (drv->bus_type == CDROM_BUS_ATAPI) { } else if (drv->bus_type == CDROM_BUS_ATAPI) {
/* ATAPI CD-ROM, attach to the IDE bus. */ /* ATAPI CD-ROM, attach to the IDE bus. */
id = ide_drives[drv->ide_channel]; id = ide_drives[drv->ide_channel];
@@ -3086,6 +3161,6 @@ scsi_cdrom_drive_reset(int c)
ide_atapi_attach(id); ide_atapi_attach(id);
} }
scsi_cdrom_log("ATAPI CD-ROM drive %i attached to IDE channel %i\n", c, cdrom_drives[c].ide_channel); scsi_cdrom_log("ATAPI CD-ROM drive %i attached to IDE channel %i\n", c, cdrom[c].ide_channel);
} }
} }

View File

@@ -9,7 +9,7 @@
* Implementation of the CD-ROM drive with SCSI(-like) * Implementation of the CD-ROM drive with SCSI(-like)
* commands, for both ATAPI and SCSI usage. * commands, for both ATAPI and SCSI usage.
* *
* Version: @(#)scsi_cdrom.h 1.0.0 2018/10/09 * Version: @(#)scsi_cdrom.h 1.0.1 2018/10/17
* *
* Author: Miran Grca, <mgrca8@gmail.com> * Author: Miran Grca, <mgrca8@gmail.com>
* *
@@ -27,7 +27,7 @@ typedef struct {
/* Common block. */ /* Common block. */
mode_sense_pages_t ms_pages_saved; mode_sense_pages_t ms_pages_saved;
cdrom_drive_t *drv; cdrom_t *drv;
uint8_t *buffer, uint8_t *buffer,
atapi_cdb[16], atapi_cdb[16],

View File

@@ -8,7 +8,7 @@
* *
* Sound emulation core. * Sound emulation core.
* *
* Version: @(#)sound.c 1.0.21 2018/10/09 * Version: @(#)sound.c 1.0.22 2018/10/17
* *
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/> * Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com> * Miran Grca, <mgrca8@gmail.com>
@@ -110,13 +110,11 @@ static const SOUND_CARD sound_cards[] =
#ifdef ENABLE_SOUND_LOG #ifdef ENABLE_SOUND_LOG
int sound_do_log = ENABLE_SOUND_LOG; int sound_do_log = ENABLE_SOUND_LOG;
#endif
static void static void
sound_log(const char *fmt, ...) sound_log(const char *fmt, ...)
{ {
#ifdef ENABLE_SOUND_LOG
va_list ap; va_list ap;
if (sound_do_log) { if (sound_do_log) {
@@ -124,8 +122,10 @@ sound_log(const char *fmt, ...)
pclog_ex(fmt, ap); pclog_ex(fmt, ap);
va_end(ap); va_end(ap);
} }
#endif
} }
#else
#define sound_log(fmt, ...)
#endif
int sound_card_available(int card) int sound_card_available(int card)
@@ -218,27 +218,27 @@ static void sound_cd_thread(void *param)
for (i = 0; i < CDROM_NUM; i++) { for (i = 0; i < CDROM_NUM; i++) {
has_audio = 0; has_audio = 0;
if ((cdrom_drives[i].bus_type == CDROM_BUS_DISABLED) || !cdrom_drives[i].handler) if ((cdrom[i].bus_type == CDROM_BUS_DISABLED) || !cdrom[i].ops)
continue; continue;
if (cdrom_drives[i].handler->audio_callback) if (cdrom[i].ops->audio_callback)
{ {
r = cdrom_drives[i].handler->audio_callback(i, cd_buffer[i], CD_BUFLEN*2); r = cdrom[i].ops->audio_callback(&(cdrom[i]), cd_buffer[i], CD_BUFLEN*2);
has_audio = (cdrom_drives[i].bus_type && cdrom_drives[i].sound_on/* && r*/); has_audio = (cdrom[i].bus_type && cdrom[i].sound_on/* && r*/);
} else } else
continue; continue;
if (soundon && has_audio) { if (soundon && has_audio) {
if (cdrom_drives[i].get_volume) { if (cdrom[i].get_volume) {
audio_vol_l = cdrom_drives[i].get_volume(cdrom_drives[i].p, 0); audio_vol_l = cdrom[i].get_volume(cdrom[i].p, 0);
audio_vol_r = cdrom_drives[i].get_volume(cdrom_drives[i].p, 1); audio_vol_r = cdrom[i].get_volume(cdrom[i].p, 1);
} else { } else {
audio_vol_l = 255; audio_vol_l = 255;
audio_vol_r = 255; audio_vol_r = 255;
} }
if (cdrom_drives[i].get_channel) { if (cdrom[i].get_channel) {
channel_select[0] = cdrom_drives[i].get_channel(cdrom_drives[i].p, 0); channel_select[0] = cdrom[i].get_channel(cdrom[i].p, 0);
channel_select[1] = cdrom_drives[i].get_channel(cdrom_drives[i].p, 1); channel_select[1] = cdrom[i].get_channel(cdrom[i].p, 1);
} else { } else {
channel_select[0] = 1; channel_select[0] = 1;
channel_select[1] = 2; channel_select[1] = 2;
@@ -365,7 +365,7 @@ void sound_init(void)
for (i = 0; i < CDROM_NUM; i++) for (i = 0; i < CDROM_NUM; i++)
{ {
if (cdrom_drives[i].bus_type != CDROM_BUS_DISABLED) if (cdrom[i].bus_type != CDROM_BUS_DISABLED)
{ {
available_cdrom_drives++; available_cdrom_drives++;
} }
@@ -528,10 +528,10 @@ void sound_cd_thread_reset(void)
int available_cdrom_drives = 0; int available_cdrom_drives = 0;
for (i = 0; i < CDROM_NUM; i++) { for (i = 0; i < CDROM_NUM; i++) {
if (cdrom_drives[i].handler && cdrom_drives[i].handler->audio_stop) if (cdrom[i].ops && cdrom[i].ops->audio_stop)
cdrom_drives[i].handler->audio_stop(i); cdrom[i].ops->audio_stop(&(cdrom[i]));
if (cdrom_drives[i].bus_type != CDROM_BUS_DISABLED) if (cdrom[i].bus_type != CDROM_BUS_DISABLED)
available_cdrom_drives++; available_cdrom_drives++;
} }

View File

@@ -333,13 +333,13 @@ DLG_CFG_VIDEO DIALOG DISCARDABLE 97, 0, 267, 45
STYLE DS_CONTROL | WS_CHILD STYLE DS_CONTROL | WS_CHILD
FONT 9, "Segoe UI" FONT 9, "Segoe UI"
BEGIN BEGIN
LTEXT "Video:",IDT_1707,7,8,55,10 LTEXT "Video:",IDT_1707,7,8,48,10
COMBOBOX IDC_COMBO_VIDEO,71,7,140,120,CBS_DROPDOWNLIST | COMBOBOX IDC_COMBO_VIDEO,64,7,155,120,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "Configure",IDC_CONFIGURE_VID,214,7,46,12 PUSHBUTTON "Configure",IDC_CONFIGURE_VID,222,7,38,12
CONTROL "Voodoo Graphics",IDC_CHECK_VOODOO,"Button", CONTROL "Voodoo Graphics",IDC_CHECK_VOODOO,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,7,27,199,10 BS_AUTOCHECKBOX | WS_TABSTOP,7,27,199,10
PUSHBUTTON "Configure",IDC_BUTTON_VOODOO,214,26,46,12 PUSHBUTTON "Configure",IDC_BUTTON_VOODOO,222,26,38,12
END END
DLG_CFG_INPUT DIALOG DISCARDABLE 97, 0, 267, 65 DLG_CFG_INPUT DIALOG DISCARDABLE 97, 0, 267, 65
@@ -438,49 +438,49 @@ DLG_CFG_PERIPHERALS DIALOG DISCARDABLE 97, 0, 267, 200
STYLE DS_CONTROL | WS_CHILD STYLE DS_CONTROL | WS_CHILD
FONT 9, "Segoe UI" FONT 9, "Segoe UI"
BEGIN BEGIN
LTEXT "SCSI Controller:",IDT_1716,7,8,59,10 LTEXT "SCSI Controller:",IDT_1716,7,8,48,10
COMBOBOX IDC_COMBO_SCSI,71,7,140,120,CBS_DROPDOWNLIST | COMBOBOX IDC_COMBO_SCSI,64,7,155,120,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "Configure",IDC_CONFIGURE_SCSI,214,7,46,12 PUSHBUTTON "Configure",IDC_CONFIGURE_SCSI,222,7,38,12
LTEXT "HD Controller:",IDT_1717,7,26,61,10 LTEXT "HD Controller:",IDT_1717,7,26,48,10
COMBOBOX IDC_COMBO_HDC,71,25,140,120,CBS_DROPDOWNLIST | COMBOBOX IDC_COMBO_HDC,64,25,155,120,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "Configure",IDC_CONFIGURE_HDC,214,25,46,12 PUSHBUTTON "Configure",IDC_CONFIGURE_HDC,222,25,38,12
CONTROL "Tertiary IDE Controller",IDC_CHECK_IDE_TER,"Button", CONTROL "Tertiary IDE Controller",IDC_CHECK_IDE_TER,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,7,44,199,10 BS_AUTOCHECKBOX | WS_TABSTOP,7,44,199,10
PUSHBUTTON "Configure",IDC_BUTTON_IDE_TER,214,43,46,12 PUSHBUTTON "Configure",IDC_BUTTON_IDE_TER,222,43,38,12
CONTROL "Quaternary IDE Controller",IDC_CHECK_IDE_QUA,"Button", CONTROL "Quaternary IDE Controller",IDC_CHECK_IDE_QUA,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,7,62,199,10 BS_AUTOCHECKBOX | WS_TABSTOP,7,62,199,10
PUSHBUTTON "Configure",IDC_BUTTON_IDE_QUA,214,61,46,12 PUSHBUTTON "Configure",IDC_BUTTON_IDE_QUA,222,61,38,12
CONTROL "ISABugger device",IDC_CHECK_BUGGER,"Button", CONTROL "ISABugger device",IDC_CHECK_BUGGER,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,7,80,94,10 BS_AUTOCHECKBOX | WS_TABSTOP,7,80,94,10
LTEXT "ISA RTC",IDT_1767,7,99,61,10 LTEXT "ISA RTC",IDT_1767,7,99,48,10
COMBOBOX IDC_COMBO_ISARTC,71,98,140,120, COMBOBOX IDC_COMBO_ISARTC,64,98,155,120,
CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "Configure",IDC_CONFIGURE_ISARTC,214,98,46,12 PUSHBUTTON "Configure",IDC_CONFIGURE_ISARTC,222,98,38,12
GROUPBOX "ISA Memory Expansion",IDC_GROUP_ISAMEM,7,118,255,70 GROUPBOX "ISA Memory Expansion",IDC_GROUP_ISAMEM,7,118,255,70
LTEXT "#1:",IDT_1763,12,130,21,10 LTEXT "#1:",IDT_1763,12,130,21,10
COMBOBOX IDC_COMBO_ISAMEM_1,25,129,180,120, COMBOBOX IDC_COMBO_ISAMEM_1,25,129,190,120,
CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "Configure",IDC_CONFIGURE_ISAMEM_1,209,129,46,12 PUSHBUTTON "Configure",IDC_CONFIGURE_ISAMEM_1,217,129,38,12
LTEXT "#2:",IDT_1764,12,144,21,10 LTEXT "#2:",IDT_1764,12,144,21,10
COMBOBOX IDC_COMBO_ISAMEM_2,25,143,180,120, COMBOBOX IDC_COMBO_ISAMEM_2,25,143,190,120,
CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "Configure",IDC_CONFIGURE_ISAMEM_2,209,143,46,12 PUSHBUTTON "Configure",IDC_CONFIGURE_ISAMEM_2,217,143,38,12
LTEXT "#3:",IDT_1765,12,158,21,10 LTEXT "#3:",IDT_1765,12,158,21,10
COMBOBOX IDC_COMBO_ISAMEM_3,25,157,180,120, COMBOBOX IDC_COMBO_ISAMEM_3,25,157,190,120,
CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "Configure",IDC_CONFIGURE_ISAMEM_3,209,157,46,12 PUSHBUTTON "Configure",IDC_CONFIGURE_ISAMEM_3,217,157,38,12
LTEXT "#4:",IDT_1766,12,172,21,10 LTEXT "#4:",IDT_1766,12,172,21,10
COMBOBOX IDC_COMBO_ISAMEM_4,25,171,180,120, COMBOBOX IDC_COMBO_ISAMEM_4,25,171,190,120,
CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "Configure",IDC_CONFIGURE_ISAMEM_4,209,171,46,12 PUSHBUTTON "Configure",IDC_CONFIGURE_ISAMEM_4,217,171,38,12
END END
DLG_CFG_HARD_DISKS DIALOG DISCARDABLE 97, 0, 267, 154 DLG_CFG_HARD_DISKS DIALOG DISCARDABLE 97, 0, 267, 154

View File

@@ -8,7 +8,7 @@
# #
# Makefile for Win32 (MinGW32) environment. # Makefile for Win32 (MinGW32) environment.
# #
# Version: @(#)Makefile.mingw 1.0.129 2018/10/12 # Version: @(#)Makefile.mingw 1.0.130 2018/10/17
# #
# Authors: Miran Grca, <mgrca8@gmail.com> # Authors: Miran Grca, <mgrca8@gmail.com>
# Fred N. van Kempen, <decwiz@yahoo.com> # Fred N. van Kempen, <decwiz@yahoo.com>
@@ -471,7 +471,7 @@ HDDOBJ := hdd.o \
hdc_xtide.o hdc_ide.o hdc_xtide.o hdc_ide.o
CDROMOBJ := cdrom.o \ CDROMOBJ := cdrom.o \
cdrom_dosbox.o cdrom_image.o cdrom_null.o cdrom_dosbox.o cdrom_image.o
ZIPOBJ := zip.o ZIPOBJ := zip.o

View File

@@ -8,7 +8,7 @@
* *
* Handle the platform-side of CDROM drives. * Handle the platform-side of CDROM drives.
* *
* Version: @(#)win_cdrom.c 1.0.10 2018/10/09 * Version: @(#)win_cdrom.c 1.0.10 2018/10/17
* *
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/> * Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com> * Miran Grca, <mgrca8@gmail.com>
@@ -32,8 +32,6 @@
#include "../scsi/scsi_device.h" #include "../scsi/scsi_device.h"
#include "../cdrom/cdrom.h" #include "../cdrom/cdrom.h"
#include "../disk/zip.h" #include "../disk/zip.h"
#include "../cdrom/cdrom_image.h"
#include "../cdrom/cdrom_null.h"
#include "../scsi/scsi_disk.h" #include "../scsi/scsi_disk.h"
#include "../plat.h" #include "../plat.h"
#include "../ui.h" #include "../ui.h"
@@ -41,86 +39,24 @@
void void
cdrom_eject(uint8_t id) plat_cdrom_ui_update(uint8_t id, uint8_t reload)
{ {
cdrom_drive_t *drv = &cdrom_drives[id]; cdrom_t *drv = &cdrom[id];
cdrom_image_t *img = &cdrom_image[id];
if (drv->host_drive == 0) { if (drv->host_drive == 0) {
/* Switch from empty to empty. Do nothing. */ ui_sb_check_menu_item(SB_CDROM|id, IDM_CDROM_EMPTY | id, MF_CHECKED);
return; drv->host_drive = 0;
ui_sb_check_menu_item(SB_CDROM|id, IDM_CDROM_IMAGE | id, MF_UNCHECKED);
ui_sb_update_icon_state(SB_CDROM|id, 1);
} else {
ui_sb_check_menu_item(SB_CDROM|id, IDM_CDROM_EMPTY | id, MF_UNCHECKED);
drv->host_drive = 200;
ui_sb_check_menu_item(SB_CDROM|id, IDM_CDROM_IMAGE | id, MF_CHECKED);
ui_sb_update_icon_state(SB_CDROM|id, 0);
} }
if (img->prev_image_path) { ui_sb_enable_menu_item(SB_CDROM|id, IDM_CDROM_RELOAD | id, MF_BYCOMMAND | (reload ? MF_GRAYED : MF_ENABLED));
free(img->prev_image_path);
img->prev_image_path = NULL;
}
if (drv->host_drive == 200) {
img->prev_image_path = (wchar_t *) malloc(1024);
wcscpy(img->prev_image_path, img->image_path);
}
drv->prev_host_drive = drv->host_drive;
drv->handler->exit(id);
cdrom_close_handler(id);
memset(img->image_path, 0, 2048);
cdrom_null_open(id);
if (drv->insert) {
/* Signal disc change to the emulated machine. */
drv->insert(drv->p);
}
ui_sb_check_menu_item(SB_CDROM|id, IDM_CDROM_IMAGE | id, MF_UNCHECKED);
drv->host_drive=0;
ui_sb_check_menu_item(SB_CDROM|id, IDM_CDROM_EMPTY | id, MF_CHECKED);
ui_sb_update_icon_state(SB_CDROM|id, 1);
ui_sb_enable_menu_item(SB_CDROM|id, IDM_CDROM_RELOAD | id, MF_BYCOMMAND | MF_ENABLED);
ui_sb_update_tip(SB_CDROM|id); ui_sb_update_tip(SB_CDROM|id);
config_save();
}
void
cdrom_reload(uint8_t id)
{
cdrom_drive_t *drv = &cdrom_drives[id];
cdrom_image_t *img = &cdrom_image[id];
if ((drv->host_drive == drv->prev_host_drive) || !drv->prev_host_drive || drv->host_drive) {
/* Switch from empty to empty. Do nothing. */
return;
}
cdrom_close_handler(id);
memset(img->image_path, 0, 2048);
if (drv->prev_host_drive == 200) {
wcscpy(img->image_path, img->prev_image_path);
free(img->prev_image_path);
img->prev_image_path = NULL;
image_open(id, img->image_path);
if (drv->insert) {
/* Signal disc change to the emulated machine. */
drv->insert(drv->p);
}
if (wcslen(img->image_path) == 0) {
ui_sb_check_menu_item(SB_CDROM|id, IDM_CDROM_EMPTY | id, MF_CHECKED);
drv->host_drive = 0;
ui_sb_check_menu_item(SB_CDROM|id, IDM_CDROM_IMAGE | id, MF_UNCHECKED);
ui_sb_update_icon_state(SB_CDROM|id, 1);
} else {
ui_sb_check_menu_item(SB_CDROM|id, IDM_CDROM_EMPTY | id, MF_UNCHECKED);
drv->host_drive = 200;
ui_sb_check_menu_item(SB_CDROM|id, IDM_CDROM_IMAGE | id, MF_CHECKED);
ui_sb_update_icon_state(SB_CDROM|id, 0);
}
}
ui_sb_enable_menu_item(SB_CDROM|id, IDM_CDROM_RELOAD | id, MF_BYCOMMAND | MF_GRAYED);
ui_sb_update_tip(SB_CDROM|id);
config_save();
} }

View File

@@ -8,7 +8,7 @@
* *
* Windows 86Box Settings dialog handler. * Windows 86Box Settings dialog handler.
* *
* Version: @(#)win_settings.c 1.0.64 2018/10/08 * Version: @(#)win_settings.c 1.0.65 2018/10/17
* *
* Authors: Miran Grca, <mgrca8@gmail.com> * Authors: Miran Grca, <mgrca8@gmail.com>
* David Hrdlička, <hrdlickadavid@outlook.com> * David Hrdlička, <hrdlickadavid@outlook.com>
@@ -120,7 +120,7 @@ static int temp_fdd_turbo[FDD_NUM];
static int temp_fdd_check_bpb[FDD_NUM]; static int temp_fdd_check_bpb[FDD_NUM];
/* Other removable devices category */ /* Other removable devices category */
static cdrom_drive_t temp_cdrom_drives[CDROM_NUM]; static cdrom_t temp_cdrom[CDROM_NUM];
static zip_drive_t temp_zip_drives[ZIP_NUM]; static zip_drive_t temp_zip_drives[ZIP_NUM];
static HWND hwndParentDialog, hwndChildDialog; static HWND hwndParentDialog, hwndChildDialog;
@@ -281,12 +281,12 @@ win_settings_init(void)
} }
/* Other removable devices category */ /* Other removable devices category */
memcpy(temp_cdrom_drives, cdrom_drives, CDROM_NUM * sizeof(cdrom_drive_t)); memcpy(temp_cdrom, cdrom, CDROM_NUM * sizeof(cdrom_t));
for (i = 0; i < CDROM_NUM; i++) { for (i = 0; i < CDROM_NUM; i++) {
if (cdrom_drives[i].bus_type == CDROM_BUS_ATAPI) if (cdrom[i].bus_type == CDROM_BUS_ATAPI)
ide_tracking |= (2 << (cdrom_drives[i].ide_channel << 3)); ide_tracking |= (2 << (cdrom[i].ide_channel << 3));
else if (cdrom_drives[i].bus_type == CDROM_BUS_SCSI) else if (cdrom[i].bus_type == CDROM_BUS_SCSI)
scsi_tracking[cdrom_drives[i].scsi_device_id >> 3] |= (1 << ((cdrom_drives[i].scsi_device_id & 0x07) << 3)); scsi_tracking[cdrom[i].scsi_device_id >> 3] |= (1 << ((cdrom[i].scsi_device_id & 0x07) << 3));
} }
memcpy(temp_zip_drives, zip_drives, ZIP_NUM * sizeof(zip_drive_t)); memcpy(temp_zip_drives, zip_drives, ZIP_NUM * sizeof(zip_drive_t));
for (i = 0; i < ZIP_NUM; i++) { for (i = 0; i < ZIP_NUM; i++) {
@@ -372,7 +372,7 @@ win_settings_changed(void)
} }
/* Other removable devices category */ /* Other removable devices category */
i = i || memcmp(cdrom_drives, temp_cdrom_drives, CDROM_NUM * sizeof(cdrom_drive_t)); i = i || memcmp(cdrom, temp_cdrom, CDROM_NUM * sizeof(cdrom_t));
i = i || memcmp(zip_drives, temp_zip_drives, ZIP_NUM * sizeof(zip_drive_t)); i = i || memcmp(zip_drives, temp_zip_drives, ZIP_NUM * sizeof(zip_drive_t));
i = i || !!temp_deviceconfig; i = i || !!temp_deviceconfig;
@@ -482,7 +482,7 @@ win_settings_save(void)
} }
/* Removable devices category */ /* Removable devices category */
memcpy(cdrom_drives, temp_cdrom_drives, CDROM_NUM * sizeof(cdrom_drive_t)); memcpy(cdrom, temp_cdrom, CDROM_NUM * sizeof(cdrom_t));
memcpy(zip_drives, temp_zip_drives, ZIP_NUM * sizeof(zip_drive_t)); memcpy(zip_drives, temp_zip_drives, ZIP_NUM * sizeof(zip_drive_t));
/* Mark configuration as changed. */ /* Mark configuration as changed. */
@@ -3435,22 +3435,22 @@ win_settings_cdrom_drives_recalc_list(HWND hwndList)
lvI.stateMask = lvI.iSubItem = lvI.state = 0; lvI.stateMask = lvI.iSubItem = lvI.state = 0;
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
fsid = combo_id_to_format_string_id(temp_cdrom_drives[i].bus_type); fsid = combo_id_to_format_string_id(temp_cdrom[i].bus_type);
lvI.iSubItem = 0; lvI.iSubItem = 0;
switch (temp_cdrom_drives[i].bus_type) { switch (temp_cdrom[i].bus_type) {
case CDROM_BUS_DISABLED: case CDROM_BUS_DISABLED:
default: default:
lvI.pszText = plat_get_string(fsid); lvI.pszText = plat_get_string(fsid);
lvI.iImage = 0; lvI.iImage = 0;
break; break;
case CDROM_BUS_ATAPI: case CDROM_BUS_ATAPI:
wsprintf(szText, plat_get_string(fsid), temp_cdrom_drives[i].ide_channel >> 1, temp_cdrom_drives[i].ide_channel & 1); wsprintf(szText, plat_get_string(fsid), temp_cdrom[i].ide_channel >> 1, temp_cdrom[i].ide_channel & 1);
lvI.pszText = szText; lvI.pszText = szText;
lvI.iImage = 1; lvI.iImage = 1;
break; break;
case CDROM_BUS_SCSI: case CDROM_BUS_SCSI:
wsprintf(szText, plat_get_string(fsid), temp_cdrom_drives[i].scsi_device_id); wsprintf(szText, plat_get_string(fsid), temp_cdrom[i].scsi_device_id);
lvI.pszText = szText; lvI.pszText = szText;
lvI.iImage = 1; lvI.iImage = 1;
break; break;
@@ -3462,10 +3462,10 @@ win_settings_cdrom_drives_recalc_list(HWND hwndList)
return FALSE; return FALSE;
lvI.iSubItem = 1; lvI.iSubItem = 1;
if (temp_cdrom_drives[i].bus_type == CDROM_BUS_DISABLED) if (temp_cdrom[i].bus_type == CDROM_BUS_DISABLED)
lvI.pszText = plat_get_string(IDS_2112); lvI.pszText = plat_get_string(IDS_2112);
else { else {
wsprintf(szText, L"%ix", temp_cdrom_drives[i].speed); wsprintf(szText, L"%ix", temp_cdrom[i].speed);
lvI.pszText = szText; lvI.pszText = szText;
} }
lvI.iItem = i; lvI.iItem = i;
@@ -3698,21 +3698,21 @@ win_settings_cdrom_drives_update_item(HWND hwndList, int i)
lvI.iSubItem = 0; lvI.iSubItem = 0;
lvI.iItem = i; lvI.iItem = i;
fsid = combo_id_to_format_string_id(temp_cdrom_drives[i].bus_type); fsid = combo_id_to_format_string_id(temp_cdrom[i].bus_type);
switch (temp_cdrom_drives[i].bus_type) { switch (temp_cdrom[i].bus_type) {
case CDROM_BUS_DISABLED: case CDROM_BUS_DISABLED:
default: default:
lvI.pszText = plat_get_string(fsid); lvI.pszText = plat_get_string(fsid);
lvI.iImage = 0; lvI.iImage = 0;
break; break;
case CDROM_BUS_ATAPI: case CDROM_BUS_ATAPI:
wsprintf(szText, plat_get_string(fsid), temp_cdrom_drives[i].ide_channel >> 1, temp_cdrom_drives[i].ide_channel & 1); wsprintf(szText, plat_get_string(fsid), temp_cdrom[i].ide_channel >> 1, temp_cdrom[i].ide_channel & 1);
lvI.pszText = szText; lvI.pszText = szText;
lvI.iImage = 1; lvI.iImage = 1;
break; break;
case CDROM_BUS_SCSI: case CDROM_BUS_SCSI:
wsprintf(szText, plat_get_string(fsid), temp_cdrom_drives[i].scsi_device_id); wsprintf(szText, plat_get_string(fsid), temp_cdrom[i].scsi_device_id);
lvI.pszText = szText; lvI.pszText = szText;
lvI.iImage = 1; lvI.iImage = 1;
break; break;
@@ -3722,10 +3722,10 @@ win_settings_cdrom_drives_update_item(HWND hwndList, int i)
return; return;
lvI.iSubItem = 1; lvI.iSubItem = 1;
if (temp_cdrom_drives[i].bus_type == CDROM_BUS_DISABLED) if (temp_cdrom[i].bus_type == CDROM_BUS_DISABLED)
lvI.pszText = plat_get_string(IDS_2112); lvI.pszText = plat_get_string(IDS_2112);
else { else {
wsprintf(szText, L"%ix", temp_cdrom_drives[i].speed); wsprintf(szText, L"%ix", temp_cdrom[i].speed);
lvI.pszText = szText; lvI.pszText = szText;
} }
lvI.iItem = i; lvI.iItem = i;
@@ -3824,7 +3824,7 @@ static void cdrom_recalc_location_controls(HWND hdlg, int assign_id)
int i = 0; int i = 0;
HWND h; HWND h;
int bus = temp_cdrom_drives[lv1_current_sel].bus_type; int bus = temp_cdrom[lv1_current_sel].bus_type;
for (i = IDT_1741; i < (IDT_1742 + 1); i++) { for (i = IDT_1741; i < (IDT_1742 + 1); i++) {
h = GetDlgItem(hdlg, i); h = GetDlgItem(hdlg, i);
@@ -3847,7 +3847,7 @@ static void cdrom_recalc_location_controls(HWND hdlg, int assign_id)
} else { } else {
ShowWindow(h, SW_SHOW); ShowWindow(h, SW_SHOW);
EnableWindow(h, TRUE); EnableWindow(h, TRUE);
SendMessage(h, CB_SETCURSEL, temp_cdrom_drives[lv1_current_sel].speed - 1, 0); SendMessage(h, CB_SETCURSEL, temp_cdrom[lv1_current_sel].speed - 1, 0);
} }
h = GetDlgItem(hdlg, IDT_1758); h = GetDlgItem(hdlg, IDT_1758);
@@ -3866,12 +3866,12 @@ static void cdrom_recalc_location_controls(HWND hdlg, int assign_id)
EnableWindow(h, TRUE); EnableWindow(h, TRUE);
if (assign_id) if (assign_id)
temp_cdrom_drives[lv1_current_sel].ide_channel = next_free_ide_channel(); temp_cdrom[lv1_current_sel].ide_channel = next_free_ide_channel();
h = GetDlgItem(hdlg, IDC_COMBO_CD_CHANNEL_IDE); h = GetDlgItem(hdlg, IDC_COMBO_CD_CHANNEL_IDE);
ShowWindow(h, SW_SHOW); ShowWindow(h, SW_SHOW);
EnableWindow(h, TRUE); EnableWindow(h, TRUE);
SendMessage(h, CB_SETCURSEL, temp_cdrom_drives[lv1_current_sel].ide_channel, 0); SendMessage(h, CB_SETCURSEL, temp_cdrom[lv1_current_sel].ide_channel, 0);
break; break;
case CDROM_BUS_SCSI: /* SCSI */ case CDROM_BUS_SCSI: /* SCSI */
h = GetDlgItem(hdlg, IDT_1741); h = GetDlgItem(hdlg, IDT_1741);
@@ -3879,12 +3879,12 @@ static void cdrom_recalc_location_controls(HWND hdlg, int assign_id)
EnableWindow(h, TRUE); EnableWindow(h, TRUE);
if (assign_id) if (assign_id)
next_free_scsi_id((uint8_t *) &temp_cdrom_drives[lv1_current_sel].scsi_device_id); next_free_scsi_id((uint8_t *) &temp_cdrom[lv1_current_sel].scsi_device_id);
h = GetDlgItem(hdlg, IDC_COMBO_CD_ID); h = GetDlgItem(hdlg, IDC_COMBO_CD_ID);
ShowWindow(h, SW_SHOW); ShowWindow(h, SW_SHOW);
EnableWindow(h, TRUE); EnableWindow(h, TRUE);
SendMessage(h, CB_SETCURSEL, temp_cdrom_drives[lv1_current_sel].scsi_device_id, 0); SendMessage(h, CB_SETCURSEL, temp_cdrom[lv1_current_sel].scsi_device_id, 0);
break; break;
} }
} }
@@ -3987,20 +3987,20 @@ zip_recalc_location_controls(HWND hdlg, int assign_id)
static void static void
cdrom_track(uint8_t id) cdrom_track(uint8_t id)
{ {
if (temp_cdrom_drives[id].bus_type == CDROM_BUS_ATAPI) if (temp_cdrom[id].bus_type == CDROM_BUS_ATAPI)
ide_tracking |= (2 << (temp_cdrom_drives[id].ide_channel << 3)); ide_tracking |= (2 << (temp_cdrom[id].ide_channel << 3));
else if (temp_cdrom_drives[id].bus_type == CDROM_BUS_SCSI) else if (temp_cdrom[id].bus_type == CDROM_BUS_SCSI)
scsi_tracking[temp_cdrom_drives[id].scsi_device_id >> 3] |= (1 << (temp_cdrom_drives[id].scsi_device_id & 0x07)); scsi_tracking[temp_cdrom[id].scsi_device_id >> 3] |= (1 << (temp_cdrom[id].scsi_device_id & 0x07));
} }
static void static void
cdrom_untrack(uint8_t id) cdrom_untrack(uint8_t id)
{ {
if (temp_cdrom_drives[id].bus_type == CDROM_BUS_ATAPI) if (temp_cdrom[id].bus_type == CDROM_BUS_ATAPI)
ide_tracking &= ~(2 << (temp_cdrom_drives[id].ide_channel << 3)); ide_tracking &= ~(2 << (temp_cdrom[id].ide_channel << 3));
else if (temp_cdrom_drives[id].bus_type == CDROM_BUS_SCSI) else if (temp_cdrom[id].bus_type == CDROM_BUS_SCSI)
scsi_tracking[temp_cdrom_drives[id].scsi_device_id >> 3] &= ~(1 << (temp_cdrom_drives[id].scsi_device_id & 0x07)); scsi_tracking[temp_cdrom[id].scsi_device_id >> 3] &= ~(1 << (temp_cdrom[id].scsi_device_id & 0x07));
} }
@@ -4157,7 +4157,7 @@ win_settings_other_removable_devices_proc(HWND hdlg, UINT message, WPARAM wParam
h = GetDlgItem(hdlg, IDC_COMBO_CD_BUS); h = GetDlgItem(hdlg, IDC_COMBO_CD_BUS);
switch (temp_cdrom_drives[lv1_current_sel].bus_type) { switch (temp_cdrom[lv1_current_sel].bus_type) {
case CDROM_BUS_DISABLED: case CDROM_BUS_DISABLED:
default: default:
b = 0; b = 0;
@@ -4224,7 +4224,7 @@ win_settings_other_removable_devices_proc(HWND hdlg, UINT message, WPARAM wParam
h = GetDlgItem(hdlg, IDC_COMBO_CD_BUS); h = GetDlgItem(hdlg, IDC_COMBO_CD_BUS);
switch (temp_cdrom_drives[lv1_current_sel].bus_type) { switch (temp_cdrom[lv1_current_sel].bus_type) {
case CDROM_BUS_DISABLED: case CDROM_BUS_DISABLED:
default: default:
b = 0; b = 0;
@@ -4298,13 +4298,13 @@ win_settings_other_removable_devices_proc(HWND hdlg, UINT message, WPARAM wParam
b2 = CDROM_BUS_SCSI; b2 = CDROM_BUS_SCSI;
break; break;
} }
if (b2 == temp_cdrom_drives[lv1_current_sel].bus_type) if (b2 == temp_cdrom[lv1_current_sel].bus_type)
break; break;
cdrom_untrack(lv1_current_sel); cdrom_untrack(lv1_current_sel);
assign = (temp_cdrom_drives[lv1_current_sel].bus_type == b2) ? 0 : 1; assign = (temp_cdrom[lv1_current_sel].bus_type == b2) ? 0 : 1;
if (temp_cdrom_drives[lv1_current_sel].bus_type == CDROM_BUS_DISABLED) if (temp_cdrom[lv1_current_sel].bus_type == CDROM_BUS_DISABLED)
temp_cdrom_drives[lv1_current_sel].speed = 8; temp_cdrom[lv1_current_sel].speed = 8;
temp_cdrom_drives[lv1_current_sel].bus_type = b2; temp_cdrom[lv1_current_sel].bus_type = b2;
cdrom_recalc_location_controls(hdlg, assign); cdrom_recalc_location_controls(hdlg, assign);
cdrom_track(lv1_current_sel); cdrom_track(lv1_current_sel);
h = GetDlgItem(hdlg, IDC_LIST_CDROM_DRIVES); h = GetDlgItem(hdlg, IDC_LIST_CDROM_DRIVES);
@@ -4314,7 +4314,7 @@ win_settings_other_removable_devices_proc(HWND hdlg, UINT message, WPARAM wParam
case IDC_COMBO_CD_ID: case IDC_COMBO_CD_ID:
h = GetDlgItem(hdlg, IDC_COMBO_CD_ID); h = GetDlgItem(hdlg, IDC_COMBO_CD_ID);
cdrom_untrack(lv1_current_sel); cdrom_untrack(lv1_current_sel);
temp_cdrom_drives[lv1_current_sel].scsi_device_id = SendMessage(h, CB_GETCURSEL, 0, 0); temp_cdrom[lv1_current_sel].scsi_device_id = SendMessage(h, CB_GETCURSEL, 0, 0);
cdrom_track(lv1_current_sel); cdrom_track(lv1_current_sel);
h = GetDlgItem(hdlg, IDC_LIST_CDROM_DRIVES); h = GetDlgItem(hdlg, IDC_LIST_CDROM_DRIVES);
win_settings_cdrom_drives_update_item(h, lv1_current_sel); win_settings_cdrom_drives_update_item(h, lv1_current_sel);
@@ -4323,7 +4323,7 @@ win_settings_other_removable_devices_proc(HWND hdlg, UINT message, WPARAM wParam
case IDC_COMBO_CD_CHANNEL_IDE: case IDC_COMBO_CD_CHANNEL_IDE:
h = GetDlgItem(hdlg, IDC_COMBO_CD_CHANNEL_IDE); h = GetDlgItem(hdlg, IDC_COMBO_CD_CHANNEL_IDE);
cdrom_untrack(lv1_current_sel); cdrom_untrack(lv1_current_sel);
temp_cdrom_drives[lv1_current_sel].ide_channel = SendMessage(h, CB_GETCURSEL, 0, 0); temp_cdrom[lv1_current_sel].ide_channel = SendMessage(h, CB_GETCURSEL, 0, 0);
cdrom_track(lv1_current_sel); cdrom_track(lv1_current_sel);
h = GetDlgItem(hdlg, IDC_LIST_CDROM_DRIVES); h = GetDlgItem(hdlg, IDC_LIST_CDROM_DRIVES);
win_settings_cdrom_drives_update_item(h, lv1_current_sel); win_settings_cdrom_drives_update_item(h, lv1_current_sel);
@@ -4331,7 +4331,7 @@ win_settings_other_removable_devices_proc(HWND hdlg, UINT message, WPARAM wParam
case IDC_COMBO_CD_SPEED: case IDC_COMBO_CD_SPEED:
h = GetDlgItem(hdlg, IDC_COMBO_CD_SPEED); h = GetDlgItem(hdlg, IDC_COMBO_CD_SPEED);
temp_cdrom_drives[lv1_current_sel].speed = SendMessage(h, CB_GETCURSEL, 0, 0) + 1; temp_cdrom[lv1_current_sel].speed = SendMessage(h, CB_GETCURSEL, 0, 0) + 1;
h = GetDlgItem(hdlg, IDC_LIST_CDROM_DRIVES); h = GetDlgItem(hdlg, IDC_LIST_CDROM_DRIVES);
win_settings_cdrom_drives_update_item(h, lv1_current_sel); win_settings_cdrom_drives_update_item(h, lv1_current_sel);
break; break;

View File

@@ -8,7 +8,7 @@
* *
* Implement the application's Status Bar. * Implement the application's Status Bar.
* *
* Version: @(#)win_stbar.c 1.0.20 2018/10/09 * Version: @(#)win_stbar.c 1.0.21 2018/10/17
* *
* Authors: Miran Grca, <mgrca8@gmail.com> * Authors: Miran Grca, <mgrca8@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com> * Fred N. van Kempen, <decwiz@yahoo.com>
@@ -41,7 +41,6 @@
#include "../cdrom/cdrom.h" #include "../cdrom/cdrom.h"
#include "../disk/zip.h" #include "../disk/zip.h"
#include "../cdrom/cdrom_image.h" #include "../cdrom/cdrom_image.h"
#include "../cdrom/cdrom_null.h"
#include "../scsi/scsi_disk.h" #include "../scsi/scsi_disk.h"
#include "../network/network.h" #include "../network/network.h"
#include "../video/video.h" #include "../video/video.h"
@@ -153,13 +152,13 @@ StatusBarCreateCdromSubmenu(HMENU m, int id)
AppendMenu(m, MF_STRING, IDM_CDROM_IMAGE | id, AppendMenu(m, MF_STRING, IDM_CDROM_IMAGE | id,
plat_get_string(IDS_2089)); plat_get_string(IDS_2089));
if (! cdrom_drives[id].sound_on) if (! cdrom[id].sound_on)
CheckMenuItem(m, IDM_CDROM_MUTE | id, MF_CHECKED); CheckMenuItem(m, IDM_CDROM_MUTE | id, MF_CHECKED);
if (cdrom_drives[id].host_drive == 200) if (cdrom[id].host_drive == 200)
CheckMenuItem(m, IDM_CDROM_IMAGE | id, MF_CHECKED); CheckMenuItem(m, IDM_CDROM_IMAGE | id, MF_CHECKED);
else { else {
cdrom_drives[id].host_drive = 0; cdrom[id].host_drive = 0;
CheckMenuItem(m, IDM_CDROM_EMPTY | id, MF_CHECKED); CheckMenuItem(m, IDM_CDROM_EMPTY | id, MF_CHECKED);
} }
} }
@@ -269,16 +268,16 @@ StatusBarCreateCdromTip(int part)
WCHAR *szText; WCHAR *szText;
int id; int id;
int drive = sb_part_meanings[part] & 0xf; int drive = sb_part_meanings[part] & 0xf;
int bus = cdrom_drives[drive].bus_type; int bus = cdrom[drive].bus_type;
id = IDS_5377 + (bus - 1); id = IDS_5377 + (bus - 1);
szText = plat_get_string(id); szText = plat_get_string(id);
if (cdrom_drives[drive].host_drive == 200) { if (cdrom[drive].host_drive == 200) {
if (wcslen(cdrom_image[drive].image_path) == 0) if (wcslen(cdrom[drive].image_path) == 0)
_swprintf(tempTip, plat_get_string(IDS_5120), drive+1, szText, plat_get_string(IDS_2057)); _swprintf(tempTip, plat_get_string(IDS_5120), drive+1, szText, plat_get_string(IDS_2057));
else else
_swprintf(tempTip, plat_get_string(IDS_5120), drive+1, szText, cdrom_image[drive].image_path); _swprintf(tempTip, plat_get_string(IDS_5120), drive+1, szText, cdrom[drive].image_path);
} else } else
_swprintf(tempTip, plat_get_string(IDS_5120), drive+1, szText, plat_get_string(IDS_2057)); _swprintf(tempTip, plat_get_string(IDS_5120), drive+1, szText, plat_get_string(IDS_2057));
@@ -518,14 +517,14 @@ ui_sb_update_panes(void)
} }
for (i=0; i<CDROM_NUM; i++) { for (i=0; i<CDROM_NUM; i++) {
/* Could be Internal or External IDE.. */ /* Could be Internal or External IDE.. */
if ((cdrom_drives[i].bus_type == CDROM_BUS_ATAPI) && if ((cdrom[i].bus_type == CDROM_BUS_ATAPI) &&
!(hdint || !memcmp(hdc_name, "ide", 3))) !(hdint || !memcmp(hdc_name, "ide", 3)))
continue; continue;
if ((cdrom_drives[i].bus_type == CDROM_BUS_SCSI) && if ((cdrom[i].bus_type == CDROM_BUS_SCSI) &&
(scsi_card_current == 0)) (scsi_card_current == 0))
continue; continue;
if (cdrom_drives[i].bus_type != 0) if (cdrom[i].bus_type != 0)
sb_parts++; sb_parts++;
} }
for (i=0; i<ZIP_NUM; i++) { for (i=0; i<ZIP_NUM; i++) {
@@ -581,13 +580,13 @@ ui_sb_update_panes(void)
} }
for (i=0; i<CDROM_NUM; i++) { for (i=0; i<CDROM_NUM; i++) {
/* Could be Internal or External IDE.. */ /* Could be Internal or External IDE.. */
if ((cdrom_drives[i].bus_type == CDROM_BUS_ATAPI) && if ((cdrom[i].bus_type == CDROM_BUS_ATAPI) &&
!(hdint || !memcmp(hdc_name, "ide", 3))) { !(hdint || !memcmp(hdc_name, "ide", 3))) {
continue; continue;
} }
if ((cdrom_drives[i].bus_type == CDROM_BUS_SCSI) && (scsi_card_current == 0)) if ((cdrom[i].bus_type == CDROM_BUS_SCSI) && (scsi_card_current == 0))
continue; continue;
if (cdrom_drives[i].bus_type != 0) { if (cdrom[i].bus_type != 0) {
edge += SB_ICON_WIDTH; edge += SB_ICON_WIDTH;
iStatusWidths[sb_parts] = edge; iStatusWidths[sb_parts] = edge;
sb_part_meanings[sb_parts] = SB_CDROM | i; sb_part_meanings[sb_parts] = SB_CDROM | i;
@@ -681,8 +680,8 @@ ui_sb_update_panes(void)
case SB_CDROM: /* CD-ROM */ case SB_CDROM: /* CD-ROM */
id = sb_part_meanings[i] & 0xf; id = sb_part_meanings[i] & 0xf;
if (cdrom_drives[id].host_drive == 200) if (cdrom[id].host_drive == 200)
sb_part_icons[i] = (wcslen(cdrom_image[id].image_path) == 0) ? 128 : 0; sb_part_icons[i] = (wcslen(cdrom[id].image_path) == 0) ? 128 : 0;
else else
sb_part_icons[i] = 128; sb_part_icons[i] = 128;
sb_part_icons[i] |= 32; sb_part_icons[i] |= 32;
@@ -854,8 +853,8 @@ StatusBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
if ((part == 0xff) || (sb_menu_handles == NULL)) if ((part == 0xff) || (sb_menu_handles == NULL))
break; break;
cdrom_drives[id].sound_on ^= 1; cdrom[id].sound_on ^= 1;
CheckMenuItem(sb_menu_handles[part], IDM_CDROM_MUTE | id, cdrom_drives[id].sound_on ? MF_UNCHECKED : MF_CHECKED); CheckMenuItem(sb_menu_handles[part], IDM_CDROM_MUTE | id, cdrom[id].sound_on ? MF_UNCHECKED : MF_CHECKED);
config_save(); config_save();
sound_cd_thread_reset(); sound_cd_thread_reset();
break; break;
@@ -876,22 +875,23 @@ StatusBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
if ((part == 0xff) || (sb_menu_handles == NULL)) if ((part == 0xff) || (sb_menu_handles == NULL))
break; break;
if (!file_dlg_w_st(hwnd, IDS_2075, cdrom_image[id].image_path, 0)) { if (!file_dlg_w_st(hwnd, IDS_2075, cdrom[id].image_path, 0)) {
cdrom_drives[id].prev_host_drive = cdrom_drives[id].host_drive; cdrom[id].prev_host_drive = cdrom[id].host_drive;
wcscpy(temp_path, wopenfilestring); wcscpy(temp_path, wopenfilestring);
if (!cdrom_image[id].prev_image_path) if (!cdrom[id].prev_image_path)
cdrom_image[id].prev_image_path = (wchar_t *) malloc(1024); cdrom[id].prev_image_path = (wchar_t *) malloc(1024);
wcscpy(cdrom_image[id].prev_image_path, cdrom_image[id].image_path); wcscpy(cdrom[id].prev_image_path, cdrom[id].image_path);
cdrom_drives[id].handler->exit(id); if (cdrom[id].ops && cdrom[id].ops->exit)
cdrom_close_handler(id); cdrom[id].ops->exit(&(cdrom[id]));
memset(cdrom_image[id].image_path, 0, 2048); cdrom[id].ops = NULL;
image_open(id, temp_path); memset(cdrom[id].image_path, 0, 2048);
cdrom_image_open(&(cdrom[id]), temp_path);
/* Signal media change to the emulated machine. */ /* Signal media change to the emulated machine. */
if (cdrom_drives[id].insert) if (cdrom[id].insert)
cdrom_drives[id].insert(cdrom_drives[id].p); cdrom[id].insert(cdrom[id].p);
CheckMenuItem(sb_menu_handles[part], IDM_CDROM_EMPTY | id, MF_UNCHECKED); CheckMenuItem(sb_menu_handles[part], IDM_CDROM_EMPTY | id, MF_UNCHECKED);
cdrom_drives[id].host_drive = (wcslen(cdrom_image[id].image_path) == 0) ? 0 : 200; cdrom[id].host_drive = (wcslen(cdrom[id].image_path) == 0) ? 0 : 200;
if (cdrom_drives[id].host_drive == 200) { if (cdrom[id].host_drive == 200) {
CheckMenuItem(sb_menu_handles[part], IDM_CDROM_IMAGE | id, MF_CHECKED); CheckMenuItem(sb_menu_handles[part], IDM_CDROM_IMAGE | id, MF_CHECKED);
ui_sb_update_icon_state(SB_CDROM | id, 0); ui_sb_update_icon_state(SB_CDROM | id, 0);
} else { } else {