From abacd105b2ac1c4c92247e195f7ff6a76563875e Mon Sep 17 00:00:00 2001 From: OBattler Date: Wed, 29 Dec 2021 18:00:01 +0100 Subject: [PATCH] OPTi 49x scratch register writes no longer write out of the array's bounds. --- src/chipset/opti495.c | 4 ++-- src/chipset/opti499.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/chipset/opti495.c b/src/chipset/opti495.c index 5d2313ef9..cdde85300 100644 --- a/src/chipset/opti495.c +++ b/src/chipset/opti495.c @@ -152,7 +152,7 @@ opti495_write(uint16_t addr, uint8_t val, void *priv) case 0xe1: case 0xe2: - dev->scratch[addr] = val; + dev->scratch[~addr & 0x01] = val; break; } } @@ -176,7 +176,7 @@ opti495_read(uint16_t addr, void *priv) break; case 0xe1: case 0xe2: - ret = dev->scratch[addr]; + ret = dev->scratch[~addr & 0x01]; break; } diff --git a/src/chipset/opti499.c b/src/chipset/opti499.c index 87bc39c8d..1768908a4 100644 --- a/src/chipset/opti499.c +++ b/src/chipset/opti499.c @@ -162,7 +162,7 @@ opti499_write(uint16_t addr, uint8_t val, void *priv) break; case 0xe1: case 0xe2: - dev->scratch[addr] = val; + dev->scratch[~addr & 0x01] = val; break; } } @@ -189,7 +189,7 @@ opti499_read(uint16_t addr, void *priv) break; case 0xe1: case 0xe2: - ret = dev->scratch[addr]; + ret = dev->scratch[~addr & 0x01]; break; }