1
0
mirror of https://github.com/TomHarte/CLK.git synced 2026-04-20 10:17:05 +00:00

Attempts retroactively to enforce the rule that 8-bit index modes => no top byte.

(Rather than a preserved but ignored top byte)
This commit is contained in:
Thomas Harte
2020-11-02 18:55:28 -05:00
parent 53f60f7c87
commit 0178aaee2b
3 changed files with 146 additions and 35 deletions
@@ -1097,7 +1097,6 @@ void ProcessorStorage::set_emulation_mode(bool enabled) {
if(enabled) {
set_m_x_flags(true, true);
registers_.x.halves.high = registers_.y.halves.high = 0;
registers_.e_masks[0] = 0xff00;
registers_.e_masks[1] = 0x00ff;
} else {
@@ -1109,17 +1108,24 @@ void ProcessorStorage::set_emulation_mode(bool enabled) {
}
void ProcessorStorage::set_m_x_flags(bool m, bool x) {
// true/1 => 8bit for both flags.
registers_.mx_flags[0] = m;
registers_.mx_flags[1] = x;
// Reset the top byte of x and y if _exiting_ 8-bit mode.
// TODO: rationalise this sort of logic, both here and
// with regards to the stack pointer.
if(!x && registers_.mx_flags[1]) {
registers_.x.halves.high = registers_.y.halves.high = 0;
}
registers_.x_masks[0] = x ? 0xff00 : 0x0000;
registers_.x_masks[1] = x ? 0x00ff : 0xffff;
registers_.x_shift = x ? 0 : 8;
registers_.m_masks[0] = m ? 0xff00 : 0x0000;
registers_.m_masks[1] = m ? 0x00ff : 0xffff;
registers_.m_shift = m ? 0 : 8;
registers_.x_masks[0] = x ? 0xff00 : 0x0000;
registers_.x_masks[1] = x ? 0x00ff : 0xffff;
registers_.x_shift = x ? 0 : 8;
// true/1 => 8bit for both flags.
registers_.mx_flags[0] = m;
registers_.mx_flags[1] = x;
}
uint8_t ProcessorStorage::get_flags() const {