Files
86Box/src/device.c
OBattler f6ef1f833c Vastly overhauled the UI, there's now a completely new Settings dialog as well as a status bar with disk activity icons and removable drive menus;
Thoroughly clean up the code to vastly reduce the number of compiler warnings and found and fixed several bugs in the process;
Applied all mainline PCem commits;
Added SCSI hard disk emulation;
Commented out all unfinished machines and graphics cards;
Added the AOpen AP53 and ASUS P/I-P55T2 machines as well as another Tyan 440FX machine, all three with AMI WinBIOS (patch from TheCollector1995);
Added the Diamond Stealth 3D 3000 (S3 ViRGE/VX) graphics card (patch from TheCollector1995);
Added the PS/2 XT IDE (AccuLogic) HDD Controller (patch from TheCollector1995);
Added Microsoft/Logitech Bus Mouse emulation (patch from waltje);
Overhauled the makefiles (patch from waltje);
Added the Adaptec AHA-1542CF SCSI controller (patch from waltje);
Added preliminary (but still unfinished) Adaptec AHA-154x SCSI controller BIOS support (patch from waltje);
Added an ISABugger debugging device (patch from waltje);
Added sanity checks to the Direct3D code.
2017-05-05 01:49:42 +02:00

186 lines
4.2 KiB
C

#include "ibm.h"
#include "config.h"
#include "cpu.h"
#include "device.h"
#include "model.h"
#include "sound.h"
static void *device_priv[256];
static device_t *devices[256];
static device_t *current_device;
void device_init()
{
memset(devices, 0, sizeof(devices));
}
void device_add(device_t *d)
{
int c = 0;
void *priv = NULL;
while (devices[c] != NULL && c < 256)
c++;
if (c >= 256)
fatal("device_add : too many devices\n");
current_device = d;
if (d->init != NULL)
{
priv = d->init();
if (priv == NULL)
fatal("device_add : device init failed\n");
}
devices[c] = d;
device_priv[c] = priv;
}
void device_close_all()
{
int c;
for (c = 0; c < 256; c++)
{
if (devices[c] != NULL)
{
if (devices[c]->close != NULL)
devices[c]->close(device_priv[c]);
devices[c] = device_priv[c] = NULL;
}
}
}
int device_available(device_t *d)
{
#ifdef RELEASE_BUILD
if (d->flags & DEVICE_NOT_WORKING)
return 0;
#endif
if (d->available)
return d->available();
return 1;
}
void device_speed_changed()
{
int c;
for (c = 0; c < 256; c++)
{
if (devices[c] != NULL)
{
if (devices[c]->speed_changed != NULL)
{
devices[c]->speed_changed(device_priv[c]);
}
}
}
sound_speed_changed();
}
void device_force_redraw()
{
int c;
for (c = 0; c < 256; c++)
{
if (devices[c] != NULL)
{
if (devices[c]->force_redraw != NULL)
{
devices[c]->force_redraw(device_priv[c]);
}
}
}
}
char *device_add_status_info(char *s, int max_len)
{
int c;
for (c = 0; c < 256; c++)
{
if (devices[c] != NULL)
{
if (devices[c]->add_status_info != NULL)
devices[c]->add_status_info(s, max_len, device_priv[c]);
}
}
return NULL;
}
int device_get_config_int(char *s)
{
device_config_t *config = current_device->config;
while (config->type != -1)
{
if (!strcmp(s, config->name))
return config_get_int(current_device->name, s, config->default_int);
config++;
}
return 0;
}
char *device_get_config_string(char *s)
{
device_config_t *config = current_device->config;
while (config->type != -1)
{
if (!strcmp(s, config->name))
return config_get_string(current_device->name, s, config->default_string);
config++;
}
return NULL;
}
int model_get_config_int(char *s)
{
device_t *device = model_getdevice(model);
device_config_t *config;
if (!device)
return 0;
config = device->config;
while (config->type != -1)
{
if (!strcmp(s, config->name))
return config_get_int(device->name, s, config->default_int);
config++;
}
return 0;
}
char *model_get_config_string(char *s)
{
device_t *device = model_getdevice(model);
device_config_t *config;
if (!device)
return 0;
config = device->config;
while (config->type != -1)
{
if (!strcmp(s, config->name))
return config_get_string(device->name, s, config->default_string);
config++;
}
return NULL;
}