From 7d833829e31882a21798ae6d104132db8f69bc01 Mon Sep 17 00:00:00 2001 From: EkeEke Date: Mon, 10 Dec 2012 20:26:53 +0100 Subject: [PATCH] [SCD] fixed access to read-only registers on MD side (Batman Returns) --- source/cd_hw/scd.c | 6 +++--- source/mem68k.c | 27 +++++++++------------------ 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/source/cd_hw/scd.c b/source/cd_hw/scd.c index 591babf..c8b6574 100644 --- a/source/cd_hw/scd.c +++ b/source/cd_hw/scd.c @@ -180,7 +180,7 @@ static void bram_write_word(unsigned int address, unsigned int data) /* PCM chip & Gate-Array area */ /*--------------------------------------------------------------------------*/ -INLINE void s68k_poll_detect(reg) +static void s68k_poll_detect(reg) { /* detect SUB-CPU register polling */ if (s68k.poll.detected == (1 << reg)) @@ -210,7 +210,7 @@ INLINE void s68k_poll_detect(reg) s68k.poll.pc = s68k.pc; } -INLINE void s68k_poll_sync(reg) +static void s68k_poll_sync(reg) { /* relative MAIN-CPU cycle counter */ unsigned int cycles = (s68k.cycles * MCYCLES_PER_LINE) / SCYCLES_PER_LINE; @@ -663,7 +663,7 @@ static void scd_write_byte(unsigned int address, unsigned int data) } /* update PM0-1 & MODE bits */ - scd.regs[0x02 >> 1].byte.l = (scd.regs[0x01].byte.l & ~0x1c) | (data & 0x1c); + scd.regs[0x02 >> 1].byte.l = (scd.regs[0x02 >> 1].byte.l & ~0x1c) | (data & 0x1c); return; } diff --git a/source/mem68k.c b/source/mem68k.c index 90bdc62..499cceb 100644 --- a/source/mem68k.c +++ b/source/mem68k.c @@ -223,7 +223,7 @@ void z80_write_word(unsigned int address, unsigned int data) /* I/O Control */ /*--------------------------------------------------------------------------*/ -INLINE void m68k_poll_detect(reg) +static void m68k_poll_detect(reg) { /* detect MAIN-CPU register polling */ if (m68k.poll.detected == (1 << reg)) @@ -253,7 +253,7 @@ INLINE void m68k_poll_detect(reg) m68k.poll.pc = m68k.pc; } -INLINE void m68k_poll_sync(reg) +static void m68k_poll_sync(reg) { /* relative SUB-CPU cycle counter */ unsigned int cycles = (m68k.cycles * SCYCLES_PER_LINE) / MCYCLES_PER_LINE; @@ -711,14 +711,10 @@ void ctrl_io_write_byte(unsigned int address, unsigned int data) default: { - /* default registers */ - if (address < 0xa12020) + /* MAIN-CPU communication words */ + if ((address & 0x30) == 0x10) { - /* MAIN-CPU communication words */ - if (address >= 0xa12010) - { - m68k_poll_sync(address & 0x1e); - } + m68k_poll_sync(address & 0x1e); /* register LSB */ if (address & 1) @@ -731,7 +727,7 @@ void ctrl_io_write_byte(unsigned int address, unsigned int data) scd.regs[(address >> 1) & 0xff].byte.h = data; return; } - + /* invalid address */ m68k_unused_8_w(address, data); return; @@ -930,15 +926,10 @@ void ctrl_io_write_word(unsigned int address, unsigned int data) default: { - if (address < 0xa12020) + /* MAIN-CPU communication words */ + if ((address & 0x30) == 0x10) { - /* MAIN-CPU communication words */ - if (address >= 0xa12010) - { - m68k_poll_sync(address & 0x1e); - } - - /* default registers */ + m68k_poll_sync(address & 0x1e); scd.regs[(address >> 1) & 0xff].w = data; return; }