From cc9d23f23be1860e89f0cd35ae64858f2dfb0b35 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Wed, 16 Aug 2017 09:29:48 -0400 Subject: [PATCH] Inverted meaning of register_masks, as it's a bit weird that the mask is inverted immediately upon usage. It's a left-over from thinking the unused bits should be 1s; unit tests reveal they should be 0s. Comment updated appropriately. --- Components/AY38910/AY38910.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Components/AY38910/AY38910.cpp b/Components/AY38910/AY38910.cpp index c5bd09491..a888eecc9 100644 --- a/Components/AY38910/AY38910.cpp +++ b/Components/AY38910/AY38910.cpp @@ -218,17 +218,16 @@ void AY38910::set_register_value(uint8_t value) { } uint8_t AY38910::get_register_value() { - // This table ensures that bits that aren't defined within the AY are returned as 1s - // when read. I can't find documentation on this and don't have a machine to test, so - // this is provisionally a guess. TODO: investigate. + // This table ensures that bits that aren't defined within the AY are returned as 0s + // when read, conforming to CPC-sourced unit tests. const uint8_t register_masks[16] = { - 0x00, 0xf0, 0x00, 0xf0, 0x00, 0xf0, 0xe0, 0x00, - 0xe0, 0xe0, 0xe0, 0x00, 0x00, 0xf0, 0x00, 0x00 + 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0x1f, 0xff, + 0x1f, 0x1f, 0x1f, 0xff, 0xff, 0x0f, 0xff, 0xff }; if(selected_register_ > 15) return 0xff; switch(selected_register_) { - default: return registers_[selected_register_] & ~register_masks[selected_register_]; + default: return registers_[selected_register_] & register_masks[selected_register_]; case 14: return (registers_[0x7] & 0x40) ? registers_[14] : port_inputs_[0]; case 15: return (registers_[0x7] & 0x80) ? registers_[15] : port_inputs_[1]; }