From be16ee33ba528678d33f847e7ee9d1d83d764ef2 Mon Sep 17 00:00:00 2001 From: OBattler Date: Sat, 2 Sep 2017 15:46:21 +0200 Subject: [PATCH] The model structure now uses a pointer to a function that returns the pointer to the device structure, rather than a pointer to the device structure directly. --- src/model.c | 19 +++++++++++++------ src/model.h | 2 +- src/video/vid_pcjr.c | 7 ++++++- src/video/vid_pcjr.h | 3 ++- src/video/vid_tandy.c | 14 ++++++++++++-- src/video/vid_tandy.h | 4 ++-- 6 files changed, 36 insertions(+), 13 deletions(-) diff --git a/src/model.c b/src/model.c index 4aedc0c05..2185e2b4c 100644 --- a/src/model.c +++ b/src/model.c @@ -155,14 +155,14 @@ MODEL models[] = {"[8088] Compaq Portable", ROM_PORTABLE, "portable", {{"", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, 0, 128, 640, 128, 0, xt_init, NULL }, {"[8088] DTK XT clone", ROM_DTKXT, "dtk", {{"", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, 0, 64, 640, 64, 0, xt_init, NULL }, {"[8088] IBM PC", ROM_IBMPC, "ibmpc", {{"", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, 0, 64, 640, 32, 0, xt_init, NULL }, - {"[8088] IBM PCjr", ROM_IBMPCJR, "ibmpcjr", {{"", cpus_pcjr}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 1, 0, 128, 640, 128, 0, pcjr_init, &pcjr_device }, + {"[8088] IBM PCjr", ROM_IBMPCJR, "ibmpcjr", {{"", cpus_pcjr}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 1, 0, 128, 640, 128, 0, pcjr_init, pcjr_get_device }, {"[8088] IBM XT", ROM_IBMXT, "ibmxt", {{"", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, 0, 64, 640, 64, 0, xt_init, NULL }, {"[8088] Generic XT clone", ROM_GENXT, "genxt", {{"", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, 0, 64, 640, 64, 0, xt_init, NULL }, {"[8088] Juko XT clone", ROM_JUKOPC, "jukopc", {{"", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, 0, 64, 640, 64, 0, xt_init, NULL }, {"[8088] Phoenix XT clone", ROM_PXXT, "pxxt", {{"", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, 0, 64, 640, 64, 0, xt_init, NULL }, {"[8088] Schneider EuroPC", ROM_EUROPC, "europc", {{"", cpus_europc}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, 0, 512, 640, 128, 0, europc_init, NULL }, - {"[8088] Tandy 1000", ROM_TANDY, "tandy", {{"", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 1, 0, 128, 640, 128, 0, tandy1k_init, &tandy1000_device }, - {"[8088] Tandy 1000 HX", ROM_TANDY1000HX, "tandy1000hx", {{"", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 1, 0, 256, 640, 128, 0, tandy1k_init, &tandy1000hx_device }, + {"[8088] Tandy 1000", ROM_TANDY, "tandy", {{"", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 1, 0, 128, 640, 128, 0, tandy1k_init, tandy1000_get_device }, + {"[8088] Tandy 1000 HX", ROM_TANDY1000HX, "tandy1000hx", {{"", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 1, 0, 256, 640, 128, 0, tandy1k_init, tandy1000hx_get_device }, {"[8088] VTech Laser Turbo XT", ROM_LTXT, "ltxt", {{"", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, 0, 64, 1152, 64, 0, xt_laserxt_init, NULL }, {"[8088] VTech Laser XT3", ROM_LXT3, "lxt3", {{"", cpus_8088}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, 0, 64, 1152, 64, 0, xt_laserxt_init, NULL }, @@ -287,7 +287,14 @@ char *model_getname(void) device_t *model_getdevice(int model) { - return models[model].device; + if (models[model].get_device) + { + return models[model].get_device(); + } + else + { + return NULL; + } } @@ -1108,6 +1115,6 @@ void model_init(void) models[model].init(); - if (models[model].device) - device_add(models[model].device); + if (models[model].get_device) + device_add(models[model].get_device()); } diff --git a/src/model.h b/src/model.h index c25d19850..50c5d2177 100644 --- a/src/model.h +++ b/src/model.h @@ -46,7 +46,7 @@ typedef struct { int ram_granularity; int nvrmask; void (*init)(void); - device_t *device; + device_t *(*get_device)(void); } MODEL; diff --git a/src/video/vid_pcjr.c b/src/video/vid_pcjr.c index 0557967d9..5ccc09080 100644 --- a/src/video/vid_pcjr.c +++ b/src/video/vid_pcjr.c @@ -579,7 +579,7 @@ static device_config_t pcjr_config[] = /*This isn't really a device as such - more of a convenient way to hook in the config information*/ -device_t pcjr_device = +static device_t pcjr_device = { "IBM PCjr", 0, @@ -591,3 +591,8 @@ device_t pcjr_device = NULL, pcjr_config }; + +device_t *pcjr_get_device(void) +{ + return &pcjr_device; +} diff --git a/src/video/vid_pcjr.h b/src/video/vid_pcjr.h index 6bb47bc07..0228dde3b 100644 --- a/src/video/vid_pcjr.h +++ b/src/video/vid_pcjr.h @@ -1,2 +1,3 @@ extern device_t pcjr_video_device; -extern device_t pcjr_device; + +device_t *pcjr_get_device(void); diff --git a/src/video/vid_tandy.c b/src/video/vid_tandy.c index d6151e44e..fca4a73f0 100644 --- a/src/video/vid_tandy.c +++ b/src/video/vid_tandy.c @@ -655,7 +655,7 @@ static device_config_t tandy_config[] = /*These aren't really devices as such - more of a convenient way to hook in the config information*/ -device_t tandy1000_device = +static device_t tandy1000_device = { "Tandy 1000", 0, @@ -667,7 +667,7 @@ device_t tandy1000_device = NULL, tandy_config }; -device_t tandy1000hx_device = +static device_t tandy1000hx_device = { "Tandy 1000HX", 0, @@ -679,3 +679,13 @@ device_t tandy1000hx_device = NULL, tandy_config }; + +device_t *tandy1000_get_device(void) +{ + return &tandy1000_device; +} + +device_t *tandy1000hx_get_device(void) +{ + return &tandy1000hx_device; +} diff --git a/src/video/vid_tandy.h b/src/video/vid_tandy.h index 524ad023f..9e5e190b8 100644 --- a/src/video/vid_tandy.h +++ b/src/video/vid_tandy.h @@ -1,4 +1,4 @@ extern device_t tandy_device; -extern device_t tandy1000_device; -extern device_t tandy1000hx_device; +device_t *tandy1000_get_device(void); +device_t *tandy1000hx_get_device(void);