From 27c8bdd57e0bace39fb2c48db98799987b85e536 Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Sun, 30 Jun 2024 22:18:15 -0400 Subject: [PATCH] Less dummy devices --- src/device.c | 28 ++++++++++++++++++++++ src/device/isamem.c | 16 +------------ src/device/isartc.c | 26 +++++---------------- src/disk/hdc.c | 32 ++----------------------- src/floppy/fdc.c | 46 +++++++----------------------------- src/include/86box/device.h | 3 +++ src/network/network.c | 32 ++----------------------- src/scsi/scsi.c | 16 +------------ src/sound/midi.c | 48 ++++++++------------------------------ src/sound/sound.c | 32 ++----------------------- src/video/vid_table.c | 31 ++---------------------- 11 files changed, 66 insertions(+), 244 deletions(-) diff --git a/src/device.c b/src/device.c index be39847e6..cf0764946 100644 --- a/src/device.c +++ b/src/device.c @@ -843,3 +843,31 @@ device_context_get_device(void) { return device_current.dev; } + +const device_t device_none = { + .name = "None", + .internal_name = "none", + .flags = 0, + .local = 0, + .init = NULL, + .close = NULL, + .reset = NULL, + { .available = NULL }, + .speed_changed = NULL, + .force_redraw = NULL, + .config = NULL +}; + +const device_t device_internal = { + .name = "Internal", + .internal_name = "internal", + .flags = 0, + .local = 0, + .init = NULL, + .close = NULL, + .reset = NULL, + { .available = NULL }, + .speed_changed = NULL, + .force_redraw = NULL, + .config = NULL +}; diff --git a/src/device/isamem.c b/src/device/isamem.c index 278bc49a5..d6fa04a64 100644 --- a/src/device/isamem.c +++ b/src/device/isamem.c @@ -2040,25 +2040,11 @@ static const device_t iab_device = { }; #endif -static const device_t isa_none_device = { - .name = "None", - .internal_name = "none", - .flags = 0, - .local = 0, - .init = NULL, - .close = NULL, - .reset = NULL, - { .available = NULL }, - .speed_changed = NULL, - .force_redraw = NULL, - .config = NULL -}; - static const struct { const device_t *dev; } boards[] = { // clang-format off - { &isa_none_device }, + { &device_none }, // XT Ram Expansion Cards { &ibmxt_32k_device }, { &ibmxt_64k_device }, diff --git a/src/device/isartc.c b/src/device/isartc.c index fea108426..7721d9885 100644 --- a/src/device/isartc.c +++ b/src/device/isartc.c @@ -752,30 +752,16 @@ const device_t vendex_xt_rtc_onboard_device = { .config = NULL }; -static const device_t isartc_none_device = { - .name = "None", - .internal_name = "none", - .flags = 0, - .local = 0, - .init = NULL, - .close = NULL, - .reset = NULL, - { .available = NULL }, - .speed_changed = NULL, - .force_redraw = NULL, - .config = NULL -}; - static const struct { const device_t *dev; } boards[] = { // clang-format off - { &isartc_none_device }, - { &ev170_device }, - { &pii147_device }, - { &p5pak_device }, - { &a6pak_device }, - { NULL }, + { &device_none }, + { &ev170_device }, + { &pii147_device }, + { &p5pak_device }, + { &a6pak_device }, + { NULL }, // clang-format on }; diff --git a/src/disk/hdc.c b/src/disk/hdc.c index bb7adcd67..ee25e8574 100644 --- a/src/disk/hdc.c +++ b/src/disk/hdc.c @@ -50,40 +50,12 @@ hdc_log(const char *fmt, ...) # define hdc_log(fmt, ...) #endif -static const device_t hdc_none_device = { - .name = "None", - .internal_name = "none", - .flags = 0, - .local = 0, - .init = NULL, - .close = NULL, - .reset = NULL, - { .available = NULL }, - .speed_changed = NULL, - .force_redraw = NULL, - .config = NULL -}; - -static const device_t hdc_internal_device = { - .name = "Internal", - .internal_name = "internal", - .flags = 0, - .local = 0, - .init = NULL, - .close = NULL, - .reset = NULL, - { .available = NULL }, - .speed_changed = NULL, - .force_redraw = NULL, - .config = NULL -}; - static const struct { const device_t *device; } controllers[] = { // clang-format off - { &hdc_none_device }, - { &hdc_internal_device }, + { &device_none }, + { &device_internal }, { &st506_xt_xebec_device }, { &st506_xt_wdxt_gen_device }, { &st506_xt_dtc5150x_device }, diff --git a/src/floppy/fdc.c b/src/floppy/fdc.c index 49171ae30..7c7549ed7 100644 --- a/src/floppy/fdc.c +++ b/src/floppy/fdc.c @@ -97,49 +97,21 @@ fdc_log(const char *fmt, ...) # define fdc_log(fmt, ...) #endif -const device_t fdc_none_device = { - .name = "None", - .internal_name = "none", - .flags = 0, - .local = 0, - .init = NULL, - .close = NULL, - .reset = NULL, - { .available = NULL }, - .speed_changed = NULL, - .force_redraw = NULL, - .config = NULL -}; - -const device_t fdc_internal_device = { - .name = "Internal", - .internal_name = "internal", - .flags = 0, - .local = 0, - .init = NULL, - .close = NULL, - .reset = NULL, - { .available = NULL }, - .speed_changed = NULL, - .force_redraw = NULL, - .config = NULL -}; - typedef const struct { const device_t *device; } fdc_cards_t; static fdc_cards_t fdc_cards[] = { // clang-format off - { &fdc_none_device }, - { &fdc_internal_device }, - { &fdc_xt_device }, - { &fdc_at_device }, - { &fdc_b215_device }, - { &fdc_pii151b_device }, - { &fdc_pii158b_device }, - { &fdc_monster_device }, - { NULL } + { &device_none }, + { &device_internal }, + { &fdc_xt_device }, + { &fdc_at_device }, + { &fdc_b215_device }, + { &fdc_pii151b_device }, + { &fdc_pii158b_device }, + { &fdc_monster_device }, + { NULL } // clang-format on }; diff --git a/src/include/86box/device.h b/src/include/86box/device.h index 30ce1c093..1a2a6fd8b 100644 --- a/src/include/86box/device.h +++ b/src/include/86box/device.h @@ -244,6 +244,9 @@ extern const char *device_get_internal_name(const device_t *dev); extern int machine_get_config_int(char *s); extern char *machine_get_config_string(char *s); +extern const device_t device_none; +extern const device_t device_internal; + #ifdef __cplusplus } #endif diff --git a/src/network/network.c b/src/network/network.c index 10f81b938..c972e80da 100644 --- a/src/network/network.c +++ b/src/network/network.c @@ -77,37 +77,9 @@ # include #endif -static const device_t net_none_device = { - .name = "None", - .internal_name = "none", - .flags = 0, - .local = NET_TYPE_NONE, - .init = NULL, - .close = NULL, - .reset = NULL, - { .available = NULL }, - .speed_changed = NULL, - .force_redraw = NULL, - .config = NULL -}; - -static const device_t net_internal_device = { - .name = "Internal", - .internal_name = "internal", - .flags = 0, - .local = NET_TYPE_NONE, - .init = NULL, - .close = NULL, - .reset = NULL, - { .available = NULL }, - .speed_changed = NULL, - .force_redraw = NULL, - .config = NULL -}; - static const device_t *net_cards[] = { - &net_none_device, - &net_internal_device, + &device_none, + &device_internal, &threec501_device, &threec503_device, &pcnet_am79c960_device, diff --git a/src/scsi/scsi.c b/src/scsi/scsi.c index 23c3e65f3..591ef2aa3 100644 --- a/src/scsi/scsi.c +++ b/src/scsi/scsi.c @@ -47,27 +47,13 @@ double scsi_bus_speed[SCSI_BUS_MAX] = { 0.0, 0.0, 0.0, 0.0 }; static uint8_t next_scsi_bus = 0; -static const device_t scsi_none_device = { - .name = "None", - .internal_name = "none", - .flags = 0, - .local = 0, - .init = NULL, - .close = NULL, - .reset = NULL, - { .available = NULL }, - .speed_changed = NULL, - .force_redraw = NULL, - .config = NULL -}; - typedef const struct { const device_t *device; } SCSI_CARD; static SCSI_CARD scsi_cards[] = { // clang-format off - { &scsi_none_device, }, + { &device_none, }, { &aha154xa_device, }, { &aha154xb_device, }, { &aha154xc_device, }, diff --git a/src/sound/midi.c b/src/sound/midi.c index bb107acbf..18fad1886 100644 --- a/src/sound/midi.c +++ b/src/sound/midi.c @@ -71,59 +71,31 @@ typedef struct const device_t *device; } MIDI_OUT_DEVICE, MIDI_IN_DEVICE; -static const device_t midi_out_none_device = { - .name = "None", - .internal_name = "none", - .flags = 0, - .local = 0, - .init = NULL, - .close = NULL, - .reset = NULL, - { .available = NULL }, - .speed_changed = NULL, - .force_redraw = NULL, - .config = NULL -}; - static const MIDI_OUT_DEVICE devices[] = { // clang-format off - { &midi_out_none_device }, + { &device_none }, #ifdef USE_FLUIDSYNTH - { &fluidsynth_device }, + { &fluidsynth_device }, #endif #ifdef USE_MUNT - { &mt32_old_device }, - { &mt32_new_device }, - { &cm32l_device }, - { &cm32ln_device }, + { &mt32_old_device }, + { &mt32_new_device }, + { &cm32l_device }, + { &cm32ln_device }, #endif #ifdef USE_RTMIDI - { &rtmidi_output_device }, + { &rtmidi_output_device }, #endif #if defined(DEV_BRANCH) && defined(USE_OPL4ML) - { &opl4_midi_device }, + { &opl4_midi_device }, #endif - { NULL } + { NULL } // clang-format on }; -static const device_t midi_in_none_device = { - .name = "None", - .internal_name = "none", - .flags = 0, - .local = 0, - .init = NULL, - .close = NULL, - .reset = NULL, - { .available = NULL }, - .speed_changed = NULL, - .force_redraw = NULL, - .config = NULL -}; - static const MIDI_IN_DEVICE midi_in_devices[] = { // clang-format off - { &midi_in_none_device }, + { &device_none }, #ifdef USE_RTMIDI { &rtmidi_input_device }, #endif diff --git a/src/sound/sound.c b/src/sound/sound.c index 794e21359..4820c45f9 100644 --- a/src/sound/sound.c +++ b/src/sound/sound.c @@ -96,38 +96,10 @@ static void *filter_cd_audio_p = NULL; void (*filter_pc_speaker)(int channel, double *buffer, void *priv) = NULL; void *filter_pc_speaker_p = NULL; -static const device_t sound_none_device = { - .name = "None", - .internal_name = "none", - .flags = 0, - .local = 0, - .init = NULL, - .close = NULL, - .reset = NULL, - { .available = NULL }, - .speed_changed = NULL, - .force_redraw = NULL, - .config = NULL -}; - -static const device_t sound_internal_device = { - .name = "Internal", - .internal_name = "internal", - .flags = 0, - .local = 0, - .init = NULL, - .close = NULL, - .reset = NULL, - { .available = NULL }, - .speed_changed = NULL, - .force_redraw = NULL, - .config = NULL -}; - static const SOUND_CARD sound_cards[] = { // clang-format off - { &sound_none_device }, - { &sound_internal_device }, + { &device_none }, + { &device_internal }, { &acermagic_s20_device }, { &mirosound_pcm10_device }, { &adlib_device }, diff --git a/src/video/vid_table.c b/src/video/vid_table.c index c99a41544..bcc7d5de8 100644 --- a/src/video/vid_table.c +++ b/src/video/vid_table.c @@ -47,38 +47,11 @@ static video_timings_t timing_default = { .type = VIDEO_ISA, .write_b = 8, .writ static int was_reset = 0; -static const device_t vid_none_device = { - .name = "None", - .internal_name = "none", - .flags = 0, - .local = 0, - .init = NULL, - .close = NULL, - .reset = NULL, - { .available = NULL }, - .speed_changed = NULL, - .force_redraw = NULL, - .config = NULL -}; -static const device_t vid_internal_device = { - .name = "Internal", - .internal_name = "internal", - .flags = 0, - .local = 0, - .init = NULL, - .close = NULL, - .reset = NULL, - { .available = NULL }, - .speed_changed = NULL, - .force_redraw = NULL, - .config = NULL -}; - static const VIDEO_CARD video_cards[] = { // clang-format off - { &vid_none_device }, - { &vid_internal_device }, + { &device_none }, + { &device_internal }, { &atiega800p_device }, { &mach8_vga_isa_device, VIDEO_FLAG_TYPE_8514 }, { &mach32_isa_device, VIDEO_FLAG_TYPE_8514 },