diff --git a/Processors/Z80/Implementation/Z80Implementation.hpp b/Processors/Z80/Implementation/Z80Implementation.hpp index 517cc57ea..c9c0a58aa 100644 --- a/Processors/Z80/Implementation/Z80Implementation.hpp +++ b/Processors/Z80/Implementation/Z80Implementation.hpp @@ -805,9 +805,19 @@ template < class T, subtract_flag_ = half_carry_result_ = 0; sign_result_ = zero_result_ = bit53_result_ = *static_cast(operation->source); set_parity(sign_result_); - set_did_compute_flags(); // deliberate fallthrough - case MicroOp::SetOutFlags: + set_did_compute_flags(); + if(operation_ == 0xdb) { + // IN A, (n) + memptr_.full = bc_.full + 1; + } else { + // IN r, (C) + // TODO: this surely isn't right? + ++memptr_.full; + } + break; + + case MicroOp::SetOutFlags: memptr_.full = bc_.full + 1; break; diff --git a/Processors/Z80/Implementation/Z80Storage.cpp b/Processors/Z80/Implementation/Z80Storage.cpp index 841eb626b..37cb8db9a 100644 --- a/Processors/Z80/Implementation/Z80Storage.cpp +++ b/Processors/Z80/Implementation/Z80Storage.cpp @@ -244,7 +244,7 @@ void ProcessorStorage::install_default_instruction_set() { } void ProcessorStorage::assemble_ed_page(InstructionPage &target) { -#define IN_C(r) StdInstr(Input(bc_, r), {MicroOp::SetInFlags, &r}) +#define IN_C(r) StdInstr({MicroOp::Move16, &bc_.full, &memptr_.full}, Input(bc_, r), {MicroOp::SetInFlags, &r}) #define OUT_C(r) StdInstr(Output(bc_, r), {MicroOp::SetOutFlags, &r}) #define IN_OUT(r) IN_C(r), OUT_C(r)