KBC P1 readout fixes.

This commit is contained in:
OBattler
2025-08-23 16:45:06 +02:00
parent d333ea8b4f
commit fbe69ab218
3 changed files with 10 additions and 18 deletions

View File

@@ -2269,7 +2269,9 @@ read_p1(atkbc_t *dev)
Compaq: Reserved; Compaq: Reserved;
NCR: DMA mode. NCR: DMA mode.
*/ */
uint8_t ret = machine_get_p1(dev->p1); uint8_t ret = machine_get_p1(dev->p1) | (dev->p1 & 0x03);
dev->p1 = ((dev->p1 + 1) & 0x03) | (dev->p1 & 0xfc);
return ret; return ret;
} }
@@ -2367,14 +2369,7 @@ kbc_at_process_cmd(void *priv)
if (machine_has_flags_ex(MACHINE_PS2_KBC)) { if (machine_has_flags_ex(MACHINE_PS2_KBC)) {
if (dev->state != STATE_RESET) { if (dev->state != STATE_RESET) {
kbc_at_log("ATkbc: self-test reinitialization\n"); kbc_at_log("ATkbc: self-test reinitialization\n");
/* dev->p1 |= 0xff;
Yes, the firmware has an OR, but we need to make sure
to keep any forcibly lowered bytes lowered.
TODO: Proper P1 implementation, with OR and AND flags
in the machine table.
*/
dev->p1 = dev->p1 & 0xff;
write_p2(dev, 0x4b); write_p2(dev, 0x4b);
if (dev->irq[1] != 0xffff) if (dev->irq[1] != 0xffff)
picintc(1 << dev->irq[1]); picintc(1 << dev->irq[1]);
@@ -2394,14 +2389,7 @@ kbc_at_process_cmd(void *priv)
} else { } else {
if (dev->state != STATE_RESET) { if (dev->state != STATE_RESET) {
kbc_at_log("ATkbc: self-test reinitialization\n"); kbc_at_log("ATkbc: self-test reinitialization\n");
/* dev->p1 |= 0xff;
Yes, the firmware has an OR, but we need to make sure
to keep any forcibly lowered bytes lowered.
TODO: Proper P1 implementation, with OR and AND flags
in the machine table.
*/
dev->p1 = dev->p1 & 0xff;
write_p2(dev, 0xcf); write_p2(dev, 0xcf);
if (dev->irq[0] != 0xffff) if (dev->irq[0] != 0xffff)
picintclevel(1 << dev->irq[0], &dev->irq_state); picintclevel(1 << dev->irq[0], &dev->irq_state);

View File

@@ -140,6 +140,7 @@ machine_init(void)
{ {
bios_only = 0; bios_only = 0;
machine_set_p1_default(machines[machine].kbc_p1);
machine_set_ps2(); machine_set_ps2();
(void) machine_init_ex(machine); (void) machine_init_ex(machine);

View File

@@ -19831,7 +19831,8 @@ machine_generic_p1_handler(void)
uint8_t uint8_t
machine_get_p1(uint8_t kbc_p1) machine_get_p1(uint8_t kbc_p1)
{ {
uint8_t ret = 0xff; uint8_t low_bits = ((machine_p1 >> 8) + 1) & 0x03;
uint8_t ret = 0xff;
if (machines[machine].p1_handler) if (machines[machine].p1_handler)
ret = machines[machine].p1_handler(); ret = machines[machine].p1_handler();
@@ -19844,6 +19845,8 @@ machine_get_p1(uint8_t kbc_p1)
ret &= kbc_p1; ret &= kbc_p1;
machine_p1 = (machine_p1 & 0xfffffcff) | (low_bits << 8);
return ret; return ret;
} }