MassCommit(tm) to fix the MCA ESDI driver, clean up all RLL-ESDI stuff, rename HDD-related files, and another version of the AHA-1640, which now works. Not done yet, but getting close!
This commit is contained in:
88
src/device.c
88
src/device.c
@@ -9,12 +9,12 @@
|
||||
* Implementation of the generic device interface to handle
|
||||
* all devices attached to the emulator.
|
||||
*
|
||||
* Version: @(#)device.c 1.0.1 2017/06/03
|
||||
* Version: @(#)device.c 1.0.2 2017/08/24
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
* Copyright 2008-2016 Sarah Walker.
|
||||
* Copyright 2016-2017 Miran Grca.
|
||||
* Copyright 2016,2017 Miran Grca.
|
||||
*/
|
||||
#include "ibm.h"
|
||||
#include "CPU/cpu.h"
|
||||
@@ -24,30 +24,34 @@
|
||||
#include "SOUND/sound.h"
|
||||
|
||||
|
||||
static void *device_priv[256];
|
||||
static device_t *devices[256];
|
||||
#define DEVICE_MAX 256 /* max # of devices */
|
||||
|
||||
|
||||
static void *device_priv[DEVICE_MAX];
|
||||
static device_t *devices[DEVICE_MAX];
|
||||
static device_t *current_device;
|
||||
|
||||
|
||||
void device_init(void)
|
||||
{
|
||||
memset(devices, 0, sizeof(devices));
|
||||
memset(devices, 0x00, sizeof(devices));
|
||||
}
|
||||
|
||||
|
||||
void device_add(device_t *d)
|
||||
{
|
||||
int c = 0;
|
||||
void *priv = NULL;
|
||||
int c = 0;
|
||||
void *priv = NULL;
|
||||
|
||||
while (devices[c] != NULL && c < 256)
|
||||
while (devices[c] != NULL && c < 256)
|
||||
c++;
|
||||
|
||||
if (c >= 256)
|
||||
if (c >= DEVICE_MAX)
|
||||
fatal("device_add : too many devices\n");
|
||||
|
||||
current_device = d;
|
||||
current_device = d;
|
||||
|
||||
if (d->init != NULL)
|
||||
if (d->init != NULL)
|
||||
{
|
||||
priv = d->init();
|
||||
if (priv == NULL)
|
||||
@@ -58,11 +62,12 @@ void device_add(device_t *d)
|
||||
device_priv[c] = priv;
|
||||
}
|
||||
|
||||
void device_close_all()
|
||||
|
||||
void device_close_all(void)
|
||||
{
|
||||
int c;
|
||||
|
||||
for (c = 0; c < 256; c++)
|
||||
|
||||
for (c=0; c<DEVICE_MAX; c++)
|
||||
{
|
||||
if (devices[c] != NULL)
|
||||
{
|
||||
@@ -73,11 +78,12 @@ void device_close_all()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void *device_get_priv(device_t *d)
|
||||
{
|
||||
int c;
|
||||
|
||||
for (c = 0; c < 256; c++)
|
||||
for (c=0; c<DEVICE_MAX; c++)
|
||||
{
|
||||
if (devices[c] != NULL)
|
||||
{
|
||||
@@ -89,6 +95,7 @@ void *device_get_priv(device_t *d)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
int device_available(device_t *d)
|
||||
{
|
||||
#ifdef RELEASE_BUILD
|
||||
@@ -101,11 +108,12 @@ int device_available(device_t *d)
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void device_speed_changed(void)
|
||||
{
|
||||
int c;
|
||||
|
||||
for (c = 0; c < 256; c++)
|
||||
for (c=0; c<DEVICE_MAX; c++)
|
||||
{
|
||||
if (devices[c] != NULL)
|
||||
{
|
||||
@@ -119,11 +127,12 @@ void device_speed_changed(void)
|
||||
sound_speed_changed();
|
||||
}
|
||||
|
||||
|
||||
void device_force_redraw(void)
|
||||
{
|
||||
int c;
|
||||
|
||||
for (c = 0; c < 256; c++)
|
||||
for (c=0; c<DEVICE_MAX; c++)
|
||||
{
|
||||
if (devices[c] != NULL)
|
||||
{
|
||||
@@ -135,11 +144,12 @@ void device_force_redraw(void)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
char *device_add_status_info(char *s, int max_len)
|
||||
{
|
||||
int c;
|
||||
|
||||
for (c = 0; c < 256; c++)
|
||||
for (c=0; c<DEVICE_MAX; c++)
|
||||
{
|
||||
if (devices[c] != NULL)
|
||||
{
|
||||
@@ -151,11 +161,12 @@ char *device_add_status_info(char *s, int max_len)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
int device_get_config_int(char *s)
|
||||
{
|
||||
device_config_t *config = current_device->config;
|
||||
|
||||
while (config->type != -1)
|
||||
while (config && config->type != -1)
|
||||
{
|
||||
if (!strcmp(s, config->name))
|
||||
return config_get_int(current_device->name, s, config->default_int);
|
||||
@@ -165,11 +176,12 @@ int device_get_config_int(char *s)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int device_get_config_int_ex(char *s, int default_int)
|
||||
{
|
||||
device_config_t *config = current_device->config;
|
||||
|
||||
while (config->type != -1)
|
||||
while (config && config->type != -1)
|
||||
{
|
||||
if (!strcmp(s, config->name))
|
||||
return config_get_int(current_device->name, s, default_int);
|
||||
@@ -179,11 +191,12 @@ int device_get_config_int_ex(char *s, int default_int)
|
||||
return default_int;
|
||||
}
|
||||
|
||||
|
||||
int device_get_config_hex16(char *s)
|
||||
{
|
||||
device_config_t *config = current_device->config;
|
||||
|
||||
while (config->type != -1)
|
||||
|
||||
while (config && config->type != -1)
|
||||
{
|
||||
if (!strcmp(s, config->name))
|
||||
return config_get_hex16(current_device->name, s, config->default_int);
|
||||
@@ -193,11 +206,12 @@ int device_get_config_hex16(char *s)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int device_get_config_hex20(char *s)
|
||||
{
|
||||
device_config_t *config = current_device->config;
|
||||
|
||||
while (config->type != -1)
|
||||
while (config && config->type != -1)
|
||||
{
|
||||
if (!strcmp(s, config->name))
|
||||
return config_get_hex20(current_device->name, s, config->default_int);
|
||||
@@ -207,11 +221,12 @@ int device_get_config_hex20(char *s)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int device_get_config_mac(char *s, int default_int)
|
||||
{
|
||||
device_config_t *config = current_device->config;
|
||||
|
||||
while (config->type != -1)
|
||||
while (config && config->type != -1)
|
||||
{
|
||||
if (!strcmp(s, config->name))
|
||||
return config_get_mac(current_device->name, s, default_int);
|
||||
@@ -221,11 +236,12 @@ int device_get_config_mac(char *s, int default_int)
|
||||
return default_int;
|
||||
}
|
||||
|
||||
|
||||
void device_set_config_int(char *s, int val)
|
||||
{
|
||||
device_config_t *config = current_device->config;
|
||||
|
||||
while (config->type != -1)
|
||||
while (config && config->type != -1)
|
||||
{
|
||||
if (!strcmp(s, config->name))
|
||||
{
|
||||
@@ -235,14 +251,14 @@ void device_set_config_int(char *s, int val)
|
||||
|
||||
config++;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void device_set_config_hex16(char *s, int val)
|
||||
{
|
||||
device_config_t *config = current_device->config;
|
||||
|
||||
while (config->type != -1)
|
||||
while (config && config->type != -1)
|
||||
{
|
||||
if (!strcmp(s, config->name))
|
||||
{
|
||||
@@ -252,14 +268,14 @@ void device_set_config_hex16(char *s, int val)
|
||||
|
||||
config++;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void device_set_config_hex20(char *s, int val)
|
||||
{
|
||||
device_config_t *config = current_device->config;
|
||||
|
||||
while (config->type != -1)
|
||||
while (config && config->type != -1)
|
||||
{
|
||||
if (!strcmp(s, config->name))
|
||||
{
|
||||
@@ -269,14 +285,14 @@ void device_set_config_hex20(char *s, int val)
|
||||
|
||||
config++;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void device_set_config_mac(char *s, int val)
|
||||
{
|
||||
device_config_t *config = current_device->config;
|
||||
|
||||
while (config->type != -1)
|
||||
while (config && config->type != -1)
|
||||
{
|
||||
if (!strcmp(s, config->name))
|
||||
{
|
||||
@@ -286,14 +302,14 @@ void device_set_config_mac(char *s, int val)
|
||||
|
||||
config++;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
char *device_get_config_string(char *s)
|
||||
{
|
||||
device_config_t *config = current_device->config;
|
||||
|
||||
while (config->type != -1)
|
||||
while (config && config->type != -1)
|
||||
{
|
||||
if (!strcmp(s, config->name))
|
||||
return config_get_string(current_device->name, s, config->default_string);
|
||||
@@ -303,6 +319,7 @@ char *device_get_config_string(char *s)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
int model_get_config_int(char *s)
|
||||
{
|
||||
device_t *device = model_getdevice(model);
|
||||
@@ -313,7 +330,7 @@ int model_get_config_int(char *s)
|
||||
|
||||
config = device->config;
|
||||
|
||||
while (config->type != -1)
|
||||
while (config && config->type != -1)
|
||||
{
|
||||
if (!strcmp(s, config->name))
|
||||
return config_get_int(device->name, s, config->default_int);
|
||||
@@ -323,6 +340,7 @@ int model_get_config_int(char *s)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
char *model_get_config_string(char *s)
|
||||
{
|
||||
device_t *device = model_getdevice(model);
|
||||
@@ -333,7 +351,7 @@ char *model_get_config_string(char *s)
|
||||
|
||||
config = device->config;
|
||||
|
||||
while (config->type != -1)
|
||||
while (config && config->type != -1)
|
||||
{
|
||||
if (!strcmp(s, config->name))
|
||||
return config_get_string(device->name, s, config->default_string);
|
||||
|
||||
Reference in New Issue
Block a user