diff --git a/src/device/serial.c b/src/device/serial.c index 63f20cbee..38220485f 100644 --- a/src/device/serial.c +++ b/src/device/serial.c @@ -141,7 +141,7 @@ serial_update_ints(serial_t *dev) } } - serial_do_irq(dev, !(dev->iir & 0x01) && ((dev->mctrl & 8) || (dev->type == SERIAL_8250_PCJR))); + serial_do_irq(dev, !(dev->iir & 0x01) && ((dev->mctrl & 8) || ((dev->type == SERIAL_8250_PCJR_3F8) || (dev->type == SERIAL_8250_PCJR_2F8)))); } static void @@ -971,15 +971,20 @@ serial_init(const device_t *info) serial_setup(dev, COM4_ADDR, COM4_IRQ); else if (next_inst == 2) serial_setup(dev, COM3_ADDR, COM3_IRQ); - else if ((next_inst == 1) || (info->local == SERIAL_8250_PCJR)) + else if ((next_inst == 1) || (info->local == SERIAL_8250_PCJR_2F8)) serial_setup(dev, COM2_ADDR, COM2_IRQ); + // TODO +#if 0 + else if ((next_inst == 1) || (info->local == SERIAL_8250_PCJR_3F8)) + serial_setup(dev, COM1_ADDR, COM1_IRQ); +#endif else if (next_inst == 0) serial_setup(dev, COM1_ADDR, COM1_IRQ); /* Default to 1200,N,7. */ dev->dlab = 96; dev->fcr = 0x06; - if (info->local == SERIAL_8250_PCJR) + if ((info->local == SERIAL_8250_PCJR_3F8) || (info->local == SERIAL_8250_PCJR_2F8)) dev->clock_src = 1789500.0; else dev->clock_src = 1843200.0; @@ -1039,11 +1044,25 @@ const device_t ns8250_device = { .config = NULL }; -const device_t ns8250_pcjr_device = { - .name = "National Semiconductor 8250(-compatible) UART for PCjr", - .internal_name = "ns8250_pcjr", +const device_t ns8250_pcjr_3f8_device = { + .name = "National Semiconductor 8250(-compatible) UART for PCjr (0x3f8)", + .internal_name = "ns8250_pcjr_3f8", .flags = 0, - .local = SERIAL_8250_PCJR, + .local = SERIAL_8250_PCJR_3F8, + .init = serial_init, + .close = serial_close, + .reset = serial_reset, + .available = NULL, + .speed_changed = serial_speed_changed, + .force_redraw = NULL, + .config = NULL +}; + +const device_t ns8250_pcjr_2f8_device = { + .name = "National Semiconductor 8250(-compatible) UART for PCjr (0x2f8)", + .internal_name = "ns8250_pcjr_2f8", + .flags = 0, + .local = SERIAL_8250_PCJR_2F8, .init = serial_init, .close = serial_close, .reset = serial_reset, diff --git a/src/include/86box/m_pcjr.h b/src/include/86box/m_pcjr.h index f957252a6..f1a31954d 100644 --- a/src/include/86box/m_pcjr.h +++ b/src/include/86box/m_pcjr.h @@ -67,6 +67,7 @@ typedef struct pcjr_s { uint8_t pa; uint8_t pb; + uint8_t option_modem; uint8_t option_fdc; uint8_t option_ir; diff --git a/src/include/86box/serial.h b/src/include/86box/serial.h index 5231c491a..816672825 100644 --- a/src/include/86box/serial.h +++ b/src/include/86box/serial.h @@ -20,14 +20,15 @@ #ifndef EMU_SERIAL_H #define EMU_SERIAL_H -#define SERIAL_8250 0 -#define SERIAL_8250_PCJR 1 -#define SERIAL_16450 2 -#define SERIAL_16550 3 -#define SERIAL_16650 4 -#define SERIAL_16750 5 -#define SERIAL_16850 6 -#define SERIAL_16950 7 +#define SERIAL_8250 0 +#define SERIAL_8250_PCJR_3F8 1 +#define SERIAL_8250_PCJR_2F8 2 +#define SERIAL_16450 3 +#define SERIAL_16550 4 +#define SERIAL_16650 5 +#define SERIAL_16750 6 +#define SERIAL_16850 7 +#define SERIAL_16950 8 #define SERIAL_FIFO_SIZE 16 @@ -151,7 +152,8 @@ extern int serial_get_ri(serial_t *dev); extern uint8_t serial_get_shadow(serial_t *dev); extern const device_t ns8250_device; -extern const device_t ns8250_pcjr_device; +extern const device_t ns8250_pcjr_3f8_device; +extern const device_t ns8250_pcjr_2f8_device; extern const device_t ns16450_device; extern const device_t ns16550_device; extern const device_t ns16650_device; diff --git a/src/machine/m_pcjr.c b/src/machine/m_pcjr.c index 1b9e8a8f4..77a0ee392 100644 --- a/src/machine/m_pcjr.c +++ b/src/machine/m_pcjr.c @@ -653,7 +653,8 @@ kbd_read(uint16_t port, void *priv) case 0x62: ret = (pcjr->latched ? 1 : 0); - ret |= 0x02; /* Modem card not installed */ + if (!pcjr->option_modem) + ret |= 0x02; /* Modem card not installed */ if (!pcjr->option_fdc) ret |= 0x04; /* Diskette card not installed */ if (mem_size < 128) @@ -819,6 +820,17 @@ static const device_config_t pcjr_config[] = { .bios = { { 0 } } }, #if 0 + { + .name = "modem_slot", + .description = "Enable Serial Port in Modem Slot", + .type = CONFIG_BINARY, + .default_string = NULL, + .default_int = 0, + .file_filter = NULL, + .spinner = { 0 }, + .selection = { { 0 } }, + .bios = { { 0 } } + }, { .name = "ir_reciever", .description = "Enable IR Reciever", @@ -864,11 +876,16 @@ machine_pcjr_init(UNUSED(const machine_t *model)) pcjr = calloc(1, sizeof(pcjr_t)); - pcjr->option_fdc = 0; #if 0 - pcjr->option_ir = device_get_config_int("ir_reciever"); + pcjr->option_modem = device_get_config_int("modem_slot"); #else - pcjr->option_ir = 0; + pcjr->option_modem = 0; +#endif + pcjr->option_fdc = 0; +#if 0 + pcjr->option_ir = device_get_config_int("ir_reciever"); +#else + pcjr->option_ir = 0; #endif is_pcjr = 1; @@ -890,9 +907,13 @@ machine_pcjr_init(UNUSED(const machine_t *model)) keyboard_scan = 1; key_queue_start = key_queue_end = 0; io_sethandler(0x0060, 4, - kbd_read, NULL, NULL, kbd_write, NULL, NULL, pcjr); + kbd_read, NULL, NULL, + kbd_write, NULL, NULL, + pcjr); io_sethandler(0x00a0, 8, - kbd_read, NULL, NULL, kbd_write, NULL, NULL, pcjr); + kbd_read, NULL, NULL, + kbd_write, NULL, NULL, + pcjr); timer_add(&pcjr->send_delay_timer, kbd_poll, pcjr, 1); keyboard_set_table(scancode_pcjr); keyboard_send = kbd_adddata_ex; @@ -907,7 +928,13 @@ machine_pcjr_init(UNUSED(const machine_t *model)) pcjr->option_fdc = 1; } - device_add(&ns8250_pcjr_device); + if (!pcjr->option_modem) + device_add(&ns8250_pcjr_2f8_device); + else { + device_add(&ns8250_pcjr_3f8_device); + device_add(&ns8250_pcjr_2f8_device); + } + /* So that serial_standalone_init() won't do anything. */ serial_set_next_inst(SERIAL_MAX - 1);