diff --git a/src/emu/sound/ay8910.c b/src/emu/sound/ay8910.c index 6831a49b7fc..71ba0dc161f 100644 --- a/src/emu/sound/ay8910.c +++ b/src/emu/sound/ay8910.c @@ -868,6 +868,7 @@ void ay8910_write_ym(void *chip, int addr, int data) int ay8910_read_ym(void *chip) { ay8910_context *psg = (ay8910_context *)chip; + device_type chip_type = psg->device->type(); int r = psg->register_latch; if (r > 15) return 0; @@ -898,7 +899,21 @@ int ay8910_read_ym(void *chip) logerror("%s: warning - read 8910 '%s' Port B\n",cpuexec_describe_context(psg->device->machine),psg->device->tag()); break; } - return psg->regs[r]; + + /* Depending on chip type, unused bits in registers may or may not be accessible. + Untested chips are assumed to regard them as 'ram' + Tested and confirmed on hardware: + - AY-3-8910: inaccessible bits (see masks below) read back as 0 + - YM2149: no anomaly + */ + if (chip_type == AY8910) { + const UINT8 mask[0x10]={ + 0xff,0x0f,0xff,0x0f,0xff,0x0f,0x1f,0xff,0x1f,0x1f,0x1f,0xff,0xff,0x0f,0xff,0xff + }; + + return psg->regs[r] & mask[r]; + } + else return psg->regs[r]; } /*************************************