From 30017ea58bdcb4f5e4f8ff276b07a38c91bb310d Mon Sep 17 00:00:00 2001 From: SarahW Date: Sat, 9 Dec 2017 22:10:43 +0000 Subject: [PATCH] Fix LPT port accesses on Amstrad machines - Amstrad machines work again. --- src/amstrad.c | 21 ++++++++++++++++----- src/lpt.h | 3 +++ src/model.c | 1 + 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/amstrad.c b/src/amstrad.c index b5502c1..ca2861a 100644 --- a/src/amstrad.c +++ b/src/amstrad.c @@ -11,15 +11,20 @@ static uint8_t amstrad_dead; uint8_t amstrad_read(uint16_t port, void *priv) { + uint8_t temp; + pclog("amstrad_read : %04X\n",port); switch (port) { + case 0x378: + return lpt1_read(port, NULL); case 0x379: - return 7; + return lpt1_read(port, NULL) | 7; case 0x37a: - if (romset == ROM_PC1512) return 0x20; - if (romset == ROM_PC200) return 0x80; - return 0; + temp = lpt1_read(port, NULL) & 0x1f; + if (romset == ROM_PC1512) return temp | 0x20; + if (romset == ROM_PC200) return temp | 0x80; + return temp; case 0xdead: return amstrad_dead; } @@ -30,6 +35,12 @@ void amstrad_write(uint16_t port, uint8_t val, void *priv) { switch (port) { + case 0x378: + case 0x379: + case 0x37a: + lpt1_write(port, val, NULL); + break; + case 0xdead: amstrad_dead = val; break; @@ -108,6 +119,6 @@ void amstrad_init() io_sethandler(0x0078, 0x0001, amstrad_mouse_read, NULL, NULL, amstrad_mouse_write, NULL, NULL, NULL); io_sethandler(0x007a, 0x0001, amstrad_mouse_read, NULL, NULL, amstrad_mouse_write, NULL, NULL, NULL); - io_sethandler(0x0379, 0x0002, amstrad_read, NULL, NULL, NULL, NULL, NULL, NULL); + io_sethandler(0x0378, 0x0003, amstrad_read, NULL, NULL, amstrad_write, NULL, NULL, NULL); io_sethandler(0xdead, 0x0001, amstrad_read, NULL, NULL, amstrad_write, NULL, NULL, NULL); } diff --git a/src/lpt.h b/src/lpt.h index 7d12593..117524a 100644 --- a/src/lpt.h +++ b/src/lpt.h @@ -5,6 +5,9 @@ extern void lpt2_init(uint16_t port); extern void lpt2_remove(); extern void lpt2_remove_ams(); +void lpt1_write(uint16_t port, uint8_t val, void *priv); +uint8_t lpt1_read(uint16_t port, void *priv); + void lpt1_device_init(); void lpt1_device_close(); diff --git a/src/model.c b/src/model.c index 805e0f0..e76a34c 100644 --- a/src/model.c +++ b/src/model.c @@ -282,6 +282,7 @@ void ams_init() AMSTRAD = 1; common_init(); mem_add_bios(); + lpt1_remove(); amstrad_init(); keyboard_amstrad_init(); nvr_init();