# SPDX-License-Identifier: MIT """The access bits of a bus callback, and the GBA's view of them. Every ``read`` and ``write`` callback carries a set of these bits: ``SEQ`` (the SEQ pin: an S cycle, the address follows the previous one), ``CODE`` (nOPC low: an opcode fetch) and ``LOCK`` (the LOCK pin: SWP's read and write, TRM table 6-14). The core reports the TRM's cycle types. """ SEQ = 1 CODE = 2 LOCK = 8 def gba_access(access: int, after_idle: bool) -> int: """The access bits as the GBA's memory times them: an access that follows an internal (or coprocessor) cycle is non-sequential. The TRM merges an I cycle with a following S cycle (merged IS, TRM 3.3.4), so the core reports SEQ there; the GBA's wait-state logic times that access as N (C1, user decision 1: the mGBA suite's hardware-captured timing tests pass only so; GBATEK "GBA Memory Map", wait states). A board passes every access through this with whether an I or C cycle came just before it. """ return access & ~SEQ if after_idle else access