More serial cleanups

This commit is contained in:
Jasmine Iwanek
2022-07-28 16:50:49 -04:00
parent b1c2b2fef5
commit 8b33566187
8 changed files with 30 additions and 23 deletions

View File

@@ -157,7 +157,6 @@ int video_filter_method = 1; /* (C) video */
int video_vsync = 0; /* (C) video */
int video_framerate = -1; /* (C) video */
char video_shader[512] = { '\0' }; /* (C) video */
int serial_enabled[SERIAL_MAX] = {0,0}; /* (C) enable serial ports */
int bugger_enabled = 0; /* (C) enable ISAbugger */
int postcard_enabled = 0; /* (C) enable POST card */
int isamem_type[ISAMEM_MAX] = { 0,0,0,0 }; /* (C) enable ISA mem cards */

View File

@@ -45,6 +45,7 @@
#include <86box/isamem.h>
#include <86box/isartc.h>
#include <86box/lpt.h>
#include <86box/serial.h>
#include <86box/hdd.h>
#include <86box/hdc.h>
#include <86box/hdc_ide.h>
@@ -1178,7 +1179,7 @@ load_ports(void)
for (c = 0; c < SERIAL_MAX; c++) {
sprintf(temp, "serial%d_enabled", c + 1);
serial_enabled[c] = !!config_get_int(cat, temp, (c >= 2) ? 0 : 1);
com_ports[c].enabled = !!config_get_int(cat, temp, (c >= 2) ? 0 : 1);
/*
sprintf(temp, "serial%d_device", c + 1);
@@ -2163,10 +2164,10 @@ config_load(void)
time_sync = TIME_SYNC_ENABLED;
hdc_current = hdc_get_from_internal_name("none");
serial_enabled[0] = 1;
serial_enabled[1] = 1;
com_ports[0].enabled = 1;
com_ports[1].enabled = 1;
for (i = 2; i < SERIAL_MAX; i++)
serial_enabled[i] = 0;
com_ports[i].enabled = 0;
lpt_ports[0].enabled = 1;
@@ -2684,17 +2685,17 @@ save_ports(void)
for (c = 0; c < SERIAL_MAX; c++) {
sprintf(temp, "serial%d_enabled", c + 1);
if (((c < 2) && serial_enabled[c]) || ((c >= 2) && !serial_enabled[c]))
if (((c < 2) && com_ports[c].enabled) || ((c >= 2) && !com_ports[c].enabled))
config_delete_var(cat, temp);
else
config_set_int(cat, temp, serial_enabled[c]);
config_set_int(cat, temp, com_ports[c].enabled);
/*
/*
sprintf(temp, "serial%d_type", c + 1);
if (!serial_enabled[c])
if (!com_ports[c].enabled))
config_delete_var(cat, temp);
// else
// config_set_string(cat, temp, (char *) serial_type[c])
// else
// config_set_string(cat, temp, (char *) serial_type[c])
sprintf(temp, "serial%d_device", c + 1);
if (com_ports[c].device == 0)

View File

@@ -38,6 +38,8 @@
#include <86box/serial.h>
#include <86box/mouse.h>
serial_port_t com_ports[SERIAL_MAX];
enum {
SERIAL_INT_LSR = 1,
SERIAL_INT_RECEIVE = 2,
@@ -578,7 +580,7 @@ serial_remove(serial_t *dev)
if (dev == NULL)
return;
if (!serial_enabled[dev->inst])
if (!com_ports[dev->inst].enabled)
return;
if (!dev->base_address)
@@ -599,7 +601,7 @@ serial_setup(serial_t *dev, uint16_t addr, uint8_t irq)
if (dev == NULL)
return;
if (!serial_enabled[dev->inst])
if (!com_ports[dev->inst].enabled)
return;
if (dev->base_address != 0x0000)
serial_remove(dev);
@@ -650,7 +652,7 @@ serial_init(const device_t *info)
dev->inst = next_inst;
if (serial_enabled[next_inst]) {
if (com_ports[next_inst].enabled) {
serial_log("Adding serial port %i...\n", next_inst);
dev->type = info->local;
memset(&(serial_devices[next_inst]), 0, sizeof(serial_device_t));

View File

@@ -101,8 +101,7 @@ extern int vid_cga_contrast, /* (C) video */
video_framerate, /* (C) video */
gfxcard; /* (C) graphics/video card */
extern char video_shader[512]; /* (C) video */
extern int serial_enabled[], /* (C) enable serial ports */
bugger_enabled, /* (C) enable ISAbugger */
extern int bugger_enabled, /* (C) enable ISAbugger */
postcard_enabled, /* (C) enable POST card */
isamem_type[], /* (C) enable ISA mem cards */
isartc_type; /* (C) enable ISA RTC card */

View File

@@ -111,8 +111,6 @@ typedef struct {
# ifdef USE_SERIAL_DEVICES
char serial_devices[SERIAL_MAX][32]; /* Serial device names */
# endif
int serial_enabled[SERIAL_MAX], /* Serial ports 1, 2, 3, 4 enabled */
parallel_enabled[PARALLEL_MAX]; /* LPT1, LPT2, LPT3, LPT4 enabled */
/* Other peripherals category */
int fdc_type, /* Floppy disk controller type */

View File

@@ -74,6 +74,12 @@ typedef struct serial_device_s {
serial_t *serial;
} serial_device_t;
typedef struct {
uint8_t enabled;
} serial_port_t;
extern serial_port_t com_ports[SERIAL_MAX];
extern serial_t *serial_attach(int port,
void (*rcr_callback)(struct serial_s *serial, void *p),
void (*dev_write)(struct serial_s *serial, void *p, uint8_t data),

View File

@@ -26,6 +26,7 @@ extern "C" {
#include <86box/device.h>
#include <86box/machine.h>
#include <86box/lpt.h>
#include <86box/serial.h>
}
#include "qt_deviceconfig.hpp"
@@ -63,7 +64,7 @@ SettingsPorts::SettingsPorts(QWidget *parent) :
for (int i = 0; i < SERIAL_MAX; i++) {
auto* checkBox = findChild<QCheckBox*>(QString("checkBoxSerial%1").arg(i+1));
checkBox->setChecked(serial_enabled[i] > 0);
checkBox->setChecked(com_ports[i].enabled > 0);
}
}
@@ -82,7 +83,7 @@ void SettingsPorts::save() {
for (int i = 0; i < SERIAL_MAX; i++) {
auto* checkBox = findChild<QCheckBox*>(QString("checkBoxSerial%1").arg(i+1));
serial_enabled[i] = checkBox->isChecked() ? 1 : 0;
com_ports[i].enabled = checkBox->isChecked() ? 1 : 0;
}
}

View File

@@ -48,6 +48,7 @@
#include <86box/isartc.h>
#include <86box/lpt.h>
#include <86box/mouse.h>
#include <86box/serial.h>
#include <86box/scsi.h>
#include <86box/scsi_device.h>
#include <86box/cdrom.h>
@@ -352,7 +353,7 @@ win_settings_init(void)
temp_lpt[i] = lpt_ports[i].enabled;
}
for (i = 0; i < SERIAL_MAX; i++)
temp_serial[i] = serial_enabled[i];
temp_serial[i] = com_ports[i].enabled;
/* Storage devices category */
for (i = 0; i < SCSI_BUS_MAX; i++)
@@ -474,7 +475,7 @@ win_settings_changed(void)
i = i || (temp_lpt[j] != lpt_ports[j].enabled);
}
for (j = 0; j < SERIAL_MAX; j++)
i = i || (temp_serial[j] != serial_enabled[j]);
i = i || (temp_serial[j] != com_ports[j].enabled);
/* Storage devices category */
for (j = 0; j < SCSI_BUS_MAX; j++)
@@ -567,7 +568,7 @@ win_settings_save(void)
lpt_ports[i].enabled = temp_lpt[i];
}
for (i = 0; i < SERIAL_MAX; i++)
serial_enabled[i] = temp_serial[i];
com_ports[i].enabled = temp_serial[i];
/* Storage devices category */
for (i = 0; i < SCSI_BUS_MAX; i++)