1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-23 03:32:32 +00:00

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.

This commit is contained in:
Thomas Harte 2017-08-16 09:29:48 -04:00
parent 1a831bcf9b
commit cc9d23f23b

View File

@ -218,17 +218,16 @@ void AY38910::set_register_value(uint8_t value) {
} }
uint8_t AY38910::get_register_value() { uint8_t AY38910::get_register_value() {
// This table ensures that bits that aren't defined within the AY are returned as 1s // This table ensures that bits that aren't defined within the AY are returned as 0s
// when read. I can't find documentation on this and don't have a machine to test, so // when read, conforming to CPC-sourced unit tests.
// this is provisionally a guess. TODO: investigate.
const uint8_t register_masks[16] = { const uint8_t register_masks[16] = {
0x00, 0xf0, 0x00, 0xf0, 0x00, 0xf0, 0xe0, 0x00, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0x1f, 0xff,
0xe0, 0xe0, 0xe0, 0x00, 0x00, 0xf0, 0x00, 0x00 0x1f, 0x1f, 0x1f, 0xff, 0xff, 0x0f, 0xff, 0xff
}; };
if(selected_register_ > 15) return 0xff; if(selected_register_ > 15) return 0xff;
switch(selected_register_) { 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 14: return (registers_[0x7] & 0x40) ? registers_[14] : port_inputs_[0];
case 15: return (registers_[0x7] & 0x80) ? registers_[15] : port_inputs_[1]; case 15: return (registers_[0x7] & 0x80) ? registers_[15] : port_inputs_[1];
} }