#: The horizontal-blank part of a pattern-mode line, dots 256-340, as read from [1978] #: (rows DDYY-XXYY for V H N T, NNYY-RRYY for P1 P2, AAYY for the first eight vertical #: checks, HCPB for the CPU). Drawing counts 466-510 are dots 296-340. _HBLANK = { 256: (CPU, 0), 258: (CPU, 0), 260: (SPRITE_V, 0), 262: (SPRITE_H, 0), 264: (SPRITE_N, 0), 266: (SPRITE_T, 0), 268: (SPRITE_P1, 0), 270: (SPRITE_P2, 0), 272: (SPRITE_V, 1), 274: (SPRITE_H, 1), 276: (SPRITE_N, 1), 278: (SPRITE_T, 1), 280: (SPRITE_P1, 1), 282: (SPRITE_P2, 1), 284: (SPRITE_V, 2), 286: (SPRITE_H, 2), 288: (CPU, 0), 290: (CPU, 0), 292: (CPU, 0), 294: (CPU, 0), 296: (CPU, 0), # 288-294, count 466 298: (SPRITE_N, 2), 300: (SPRITE_T, 2), 302: (SPRITE_P1, 2), 304: (SPRITE_P2, 2), 306: (SPRITE_V, 3), 308: (SPRITE_H, 3), 310: (SPRITE_N, 3), 312: (SPRITE_T, 3), 314: (SPRITE_P1, 3), 316: (SPRITE_P2, 3), 318: (CPU, 0), 320: (CPU, 0), 322: (CPU, 0), 324: (CPU, 0), # counts 488-494 **{326 + 2 * i: (SPRITE_Y, i) for i in range(8)}, # counts 496-510: sprites 0-7 } # fmt: skip #: Slots 163-170 (dots 326-340): the first eight vertical checks, which belong to the #: evaluation for two lines on (they precede the next line's 24 checks). EARLY_Y_SLOTS = range(163, 171) def _pattern_mode_line(colour_fetch: bool) -> tuple[tuple[int, int], ...]: """The pattern-mode line; ``colour_fetch=False`` gives colour slots to the CPU. [1978] "PATTERN PLANE": in each 8-pixel group g at dot 8g, name at +0, colour at +4, pattern at +6, and at +2 either the CPU (groups 0, 4, 8, ...: "CPU" row at count 2, repeat 8 times of 32 counts) or a sprite vertical check ("VERT ATT. ADDRESS SELECT" at counts 10, 18, 26 of each 32). The 24 checks in the active area are sprites 8-31. The drawing has no Multicolor row; see ``MULTICOLOR_LINE`` (docs/schedule.md). """ slots: list[tuple[int, int]] = [] sprite = 8 for g in range(32): slots.append((NAME, g)) if g % 4 == 0: slots.append((CPU, 0)) else: slots.append((SPRITE_Y, sprite)) sprite += 1 slots.append((COLOUR, g) if colour_fetch else (CPU, 0)) slots.append((PATTERN, g)) for dot in range(256, 342, 2): slots.append(_HBLANK[dot]) return tuple(slots) def _text_line() -> tuple[tuple[int, int], ...]: """Text mode [1978] "TEXT MODE": per 6-pixel character, name at +0, CPU at +2, pattern at +4, 40 characters from dot 6 (the text area is 6 pixels to the right of the pattern modes' [TI table 3-3]); every other slot of the line is a CPU window (no sprites, no refresh on display lines).""" slots: list[tuple[int, int]] = [(CPU, 0)] * 3 # dots 0, 2, 4 for k in range(40): slots += [(TEXT_NAME, k), (CPU, 0), (TEXT_PATTERN, k)] while len(slots) < SLOTS_PER_LINE: slots.append((CPU, 0)) return tuple(slots) def _refresh_line() -> tuple[tuple[int, int], ...]: """[1978] "REFRESH MODE": refresh and CPU alternate through the first 128 slots (dots 0-255), then CPU windows only through the horizontal blank. Used on lines outside the active display and on every line while BLANK = 0 [TI 2.1.5].""" slots: list[tuple[int, int]] = [] for s in range(SLOTS_PER_LINE): slots.append((REFRESH, 0) if s < 128 and s % 2 == 0 else (CPU, 0)) return tuple(slots) def _with_early_checks(line: tuple, checks: bool) -> tuple[tuple[int, int], ...]: """Slots 163-170 as vertical checks (the next line is a sprite line) or CPU windows.""" out = list(line) for i, s in enumerate(EARLY_Y_SLOTS): out[s] = (SPRITE_Y, i) if checks else (CPU, 0) return tuple(out) GRAPHICS_LINE = _pattern_mode_line(colour_fetch=True) #: Multicolor uses the Graphics schedule: its colour slots are not CPU windows (C9). #: VATT on 21 TI-part MSX1 entries (tier 3) lands the same fraction of fast writes in #: Multicolor as in Graphics I and II at every period, which a Multicolor line with 51 #: windows cannot do (docs/results.md, rung 4). The colour slot's fetch has no use in #: Multicolor; the core makes it and ignores the byte. MULTICOLOR_LINE = GRAPHICS_LINE #: TI 2.1.5's "at least once out of every four memory cycles" read as colour slots given #: to the CPU (openMSX's ``slotsMsx1Gfx3``): kept for the detector comparison only. MULTICOLOR_ONE_IN_FOUR = _pattern_mode_line(colour_fetch=False) TEXT_LINE = _text_line() REFRESH_LINE = _refresh_line()