From 927a45c0e74952e68d9983d17e18bb05078ed904 Mon Sep 17 00:00:00 2001 From: SNB Date: Sun, 22 Jan 2023 16:25:18 +0100 Subject: [PATCH] added two WIV registers CR3 and CR4, implemented flag CRE in bit#0 of CR3 --- vice/src/viciisc/vicii-mem.c | 46 ++++++++++++++++++++++++++++++----- vice/src/viciisc/viciitypes.h | 3 +++ 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/vice/src/viciisc/vicii-mem.c b/vice/src/viciisc/vicii-mem.c index d30f5438cf9..4646ac7ebe9 100644 --- a/vice/src/viciisc/vicii-mem.c +++ b/vice/src/viciisc/vicii-mem.c @@ -143,7 +143,7 @@ inline static void update_raster_line(void) inline static void d011_store(uint8_t value) { - VICII_DEBUG_REGISTER(("Control register: $%02X", value)); + VICII_DEBUG_REGISTER(("Control register 1: $%02X", value)); VICII_DEBUG_REGISTER(("$D011 tricks at cycle %d, line $%04X, " "value $%02X", vicii.raster_cycle, vicii.raster_line, value)); @@ -167,6 +167,20 @@ inline static void d012_store(uint8_t value) update_raster_line(); } +inline static void d013_store(const uint8_t value) +{ + VICII_DEBUG_REGISTER(("WIV Control register 3: $%02X", value)); + + vicii.regs[0x13] = value; +} + +inline static void d014_store(const uint8_t value) +{ + VICII_DEBUG_REGISTER(("WIV Control register 4: $%02X", value)); + + vicii.regs[0x14] = value; +} + inline static void d015_store(const uint8_t value) { vicii.regs[0x15] = value; @@ -174,7 +188,7 @@ inline static void d015_store(const uint8_t value) inline static void d016_store(const uint8_t value) { - VICII_DEBUG_REGISTER(("Control register: $%02X", value)); + VICII_DEBUG_REGISTER(("Control register 2: $%02X", value)); vicii.regs[0x16] = value; } @@ -375,8 +389,16 @@ void vicii_store(uint16_t addr, uint8_t value) d012_store(value); break; - case 0x13: /* $D013: Light Pen X */ - case 0x14: /* $D014: Light Pen Y */ + case 0x13: /* $D013: VIC-II WIV Control Register 3 */ + if (IS_WIV) { + d013_store(value); + } + break; + + case 0x14: /* $D014: VIC-II WIV Control Register 4 */ + if (IS_WIV) { + d014_store(value); + } break; case 0x15: /* $D015: Sprite Enable */ @@ -607,12 +629,24 @@ uint8_t vicii_read(uint16_t addr) value = d01112_read(addr); break; - case 0x13: /* $D013: Light Pen X */ + case 0x13: /* $D013: Light Pen X or VIC-II WIV Control Register 3 */ + if (IS_WIV && WIV_CRE) { + VICII_DEBUG_REGISTER(("WIV Control Register 3: $%02X", vic.regs[addr])); + value = vicii.regs[addr]; + break; + } + VICII_DEBUG_REGISTER(("Light pen X: %d", vicii.light_pen.x)); value = vicii.light_pen.x; break; - case 0x14: /* $D014: Light Pen Y */ + case 0x14: /* $D014: Light Pen Y or VIC-II WIV Control Register 4 */ + if (IS_WIV && WIV_CRE) { + VICII_DEBUG_REGISTER(("WIV Control Register 4: $%02X", vic.regs[addr])); + value = vicii.regs[addr]; + break; + } + VICII_DEBUG_REGISTER(("Light pen Y: %d", vicii.light_pen.y)); value = vicii.light_pen.y; break; diff --git a/vice/src/viciisc/viciitypes.h b/vice/src/viciisc/viciitypes.h index ad70c4a857c..332f4ffaaec 100644 --- a/vice/src/viciisc/viciitypes.h +++ b/vice/src/viciisc/viciitypes.h @@ -62,6 +62,9 @@ /* just a dummy for the vicii-draw.c wrapper */ #define VICII_DUMMY_MODE (0) +/* VIC-II WIF flags */ +#define WIV_CRE (vicii.regs[0x13] & 0x01) /* Control Registers Enable: reads to $13 and $14 give control registers instead of light pen position */ + /* VIC-II structures. This is meant to be used by VIC-II modules *exclusively*! */