Added per-model configuration.
Removed global cga_comp setting in the process.
This commit is contained in:
parent
f311c9e17f
commit
4324223f54
14 changed files with 263 additions and 72 deletions
56
src/device.c
56
src/device.c
|
|
@ -1,6 +1,8 @@
|
|||
#include "ibm.h"
|
||||
#include "config.h"
|
||||
#include "cpu.h"
|
||||
#include "device.h"
|
||||
#include "model.h"
|
||||
#include "sound.h"
|
||||
|
||||
static void *device_priv[256];
|
||||
|
|
@ -16,7 +18,7 @@ void device_init()
|
|||
void device_add(device_t *d)
|
||||
{
|
||||
int c = 0;
|
||||
void *priv;
|
||||
void *priv = NULL;
|
||||
|
||||
while (devices[c] != NULL && c < 256)
|
||||
c++;
|
||||
|
|
@ -26,9 +28,12 @@ void device_add(device_t *d)
|
|||
|
||||
current_device = d;
|
||||
|
||||
priv = d->init();
|
||||
if (priv == NULL)
|
||||
fatal("device_add : device init failed\n");
|
||||
if (d->init != NULL)
|
||||
{
|
||||
priv = d->init();
|
||||
if (priv == NULL)
|
||||
fatal("device_add : device init failed\n");
|
||||
}
|
||||
|
||||
devices[c] = d;
|
||||
device_priv[c] = priv;
|
||||
|
|
@ -42,7 +47,8 @@ void device_close_all()
|
|||
{
|
||||
if (devices[c] != NULL)
|
||||
{
|
||||
devices[c]->close(device_priv[c]);
|
||||
if (devices[c]->close != NULL)
|
||||
devices[c]->close(device_priv[c]);
|
||||
devices[c] = device_priv[c] = NULL;
|
||||
}
|
||||
}
|
||||
|
|
@ -135,3 +141,43 @@ char *device_get_config_string(char *s)
|
|||
}
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue