The PCjr now correctly supports 64 kB of RAM, also other fixes and added support to PCjr ports 11h and 12h to the POST card (it now supports up to 4 different ports in the range).
This commit is contained in:
@@ -29,10 +29,14 @@
|
||||
#include <86box/postcard.h>
|
||||
#include "cpu.h"
|
||||
|
||||
#define POSTCARDS_NUM 4
|
||||
#define POSTCARD_MASK (POSTCARDS_NUM - 1)
|
||||
|
||||
static uint16_t postcard_port;
|
||||
static uint8_t postcard_written;
|
||||
static uint8_t postcard_code;
|
||||
static uint8_t postcard_prev_code;
|
||||
static uint8_t postcard_written[POSTCARDS_NUM];
|
||||
static uint8_t postcard_ports_num = 1;
|
||||
static uint8_t postcard_codes[POSTCARDS_NUM];
|
||||
static uint8_t postcard_prev_codes[POSTCARDS_NUM];
|
||||
#define UISTR_LEN 13
|
||||
static char postcard_str[UISTR_LEN]; /* UI output string */
|
||||
|
||||
@@ -61,12 +65,46 @@ int postcard_do_log = 0;
|
||||
static void
|
||||
postcard_setui(void)
|
||||
{
|
||||
if (!postcard_written)
|
||||
sprintf(postcard_str, "POST: -- --");
|
||||
else if (postcard_written == 1)
|
||||
sprintf(postcard_str, "POST: %02X --", postcard_code);
|
||||
else
|
||||
sprintf(postcard_str, "POST: %02X %02X", postcard_code, postcard_prev_code);
|
||||
if (postcard_ports_num > 1) {
|
||||
char ps[2][POSTCARDS_NUM][64] = { { 0 },
|
||||
{ 0 } };
|
||||
for (uint8_t i = 0; i < POSTCARDS_NUM; i++) {
|
||||
if (!postcard_written[i]) {
|
||||
sprintf(ps[0][i], "--");
|
||||
sprintf(ps[1][i], "--");
|
||||
} else if (postcard_written[i] == 1) {
|
||||
sprintf(ps[0][i], "%02X", postcard_codes[i]);
|
||||
sprintf(ps[1][i], "--");
|
||||
} else {
|
||||
sprintf(ps[0][i], "%02X", postcard_codes[i]);
|
||||
sprintf(ps[1][i], "%02X", postcard_prev_codes[i]);
|
||||
}
|
||||
}
|
||||
|
||||
switch (postcard_ports_num) {
|
||||
default:
|
||||
case 2:
|
||||
sprintf(postcard_str, "POST: %s%s %s%s",
|
||||
ps[0][0], ps[0][1], ps[1][0], ps[1][1]);
|
||||
break;
|
||||
case 3:
|
||||
sprintf(postcard_str, "POST: %s/%s%s %s/%s%s",
|
||||
ps[0][0], ps[0][1], ps[0][2], ps[1][0], ps[1][1], ps[1][2]);
|
||||
break;
|
||||
case 4:
|
||||
sprintf(postcard_str, "POST: %s%s/%s%s %s%s/%s%s",
|
||||
ps[0][0], ps[0][1], ps[0][2], ps[0][3],
|
||||
ps[1][0], ps[1][1], ps[1][2], ps[1][3]);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (!postcard_written[0])
|
||||
sprintf(postcard_str, "POST: -- --");
|
||||
else if (postcard_written[0] == 1)
|
||||
sprintf(postcard_str, "POST: %02X --", postcard_codes[0]);
|
||||
else
|
||||
sprintf(postcard_str, "POST: %02X %02X", postcard_codes[0], postcard_prev_codes[0]);
|
||||
}
|
||||
|
||||
ui_sb_bugui(postcard_str);
|
||||
|
||||
@@ -79,22 +117,27 @@ postcard_setui(void)
|
||||
static void
|
||||
postcard_reset(void)
|
||||
{
|
||||
postcard_written = 0;
|
||||
postcard_code = postcard_prev_code = 0x00;
|
||||
memset(postcard_written, 0x00, POSTCARDS_NUM * sizeof(uint8_t));
|
||||
|
||||
memset(postcard_codes, 0x00, POSTCARDS_NUM * sizeof(uint8_t));
|
||||
memset(postcard_prev_codes, 0x00, POSTCARDS_NUM * sizeof(uint8_t));
|
||||
|
||||
postcard_setui();
|
||||
}
|
||||
|
||||
static void
|
||||
postcard_write(UNUSED(uint16_t port), uint8_t val, UNUSED(void *priv))
|
||||
postcard_write(uint16_t port, uint8_t val, UNUSED(void *priv))
|
||||
{
|
||||
if (postcard_written && (val == postcard_code))
|
||||
uint8_t matches = 0;
|
||||
|
||||
if (postcard_written[port & POSTCARD_MASK] &&
|
||||
(val == postcard_codes[port & POSTCARD_MASK]))
|
||||
return;
|
||||
|
||||
postcard_prev_code = postcard_code;
|
||||
postcard_code = val;
|
||||
if (postcard_written < 2)
|
||||
postcard_written++;
|
||||
postcard_prev_codes[port & POSTCARD_MASK] = postcard_codes[port & POSTCARD_MASK];
|
||||
postcard_codes[port & POSTCARD_MASK] = val;
|
||||
if (postcard_written[port & POSTCARD_MASK] < 2)
|
||||
postcard_written[port & POSTCARD_MASK]++;
|
||||
|
||||
postcard_setui();
|
||||
}
|
||||
@@ -102,7 +145,7 @@ postcard_write(UNUSED(uint16_t port), uint8_t val, UNUSED(void *priv))
|
||||
static void *
|
||||
postcard_init(UNUSED(const device_t *info))
|
||||
{
|
||||
postcard_reset();
|
||||
postcard_ports_num = 1;
|
||||
|
||||
if (machine_has_bus(machine, MACHINE_BUS_MCA))
|
||||
postcard_port = 0x680; /* MCA machines */
|
||||
@@ -110,16 +153,21 @@ postcard_init(UNUSED(const device_t *info))
|
||||
postcard_port = 0x190; /* ISA PS/2 machines */
|
||||
else if (strstr(machines[machine].name, " IBM XT "))
|
||||
postcard_port = 0x60; /* IBM XT */
|
||||
else if (strstr(machines[machine].name, " IBM PCjr"))
|
||||
else if (strstr(machines[machine].name, " IBM PCjr")) {
|
||||
postcard_port = 0x10; /* IBM PCjr */
|
||||
else if (strstr(machines[machine].name, " Compaq ") && !machine_has_bus(machine, MACHINE_BUS_PCI))
|
||||
postcard_ports_num = 3; /* IBM PCjr error ports 11h and 12h */
|
||||
} else if (strstr(machines[machine].name, " Compaq ") && !machine_has_bus(machine, MACHINE_BUS_PCI))
|
||||
postcard_port = 0x84; /* ISA Compaq machines */
|
||||
else if (strstr(machines[machine].name, "Olivetti"))
|
||||
postcard_port = 0x378; /* Olivetti machines */
|
||||
else
|
||||
postcard_port = 0x80; /* AT and clone machines */
|
||||
postcard_log("POST card initializing on port %04Xh\n", postcard_port);
|
||||
|
||||
postcard_reset();
|
||||
|
||||
if (postcard_port)
|
||||
io_sethandler(postcard_port, 1,
|
||||
io_sethandler(postcard_port, postcard_ports_num,
|
||||
NULL, NULL, NULL, postcard_write, NULL, NULL, NULL);
|
||||
|
||||
return postcard_write;
|
||||
@@ -129,7 +177,7 @@ static void
|
||||
postcard_close(UNUSED(void *priv))
|
||||
{
|
||||
if (postcard_port)
|
||||
io_removehandler(postcard_port, 1,
|
||||
io_removehandler(postcard_port, postcard_ports_num,
|
||||
NULL, NULL, NULL, postcard_write, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user