30 lines
1 KiB
Python
30 lines
1 KiB
Python
"""Commodore PET / CBM monochrome display.
|
|
|
|
The PET has no bitmap or colour -- a 40- or 80-column text screen of a fixed
|
|
character ROM on a monochrome (green P1 phosphor) monitor. Images are rendered
|
|
with the PETSCII 2x2 quadrant-block graphics characters, giving an effective
|
|
80x50 (40-col) or 160x50 (80-col) one-bit pixel grid.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import numpy as np
|
|
|
|
from ..palette import srgb_to_lab
|
|
|
|
# 0 = background (dark), 1 = foreground (lit phosphor). Green to match the
|
|
# classic PET monitor; the signal is one bit, so only luminance matters.
|
|
PALETTE = np.array([(0, 0, 0), (0x40, 0xE0, 0x40)], dtype=np.float64)
|
|
|
|
|
|
def get_palette() -> np.ndarray:
|
|
return PALETTE
|
|
|
|
|
|
def palette_lab() -> np.ndarray:
|
|
return srgb_to_lab(PALETTE)
|
|
|
|
|
|
# screen (poke) code for each 2x2 quadrant pattern, bits TL<<3|TR<<2|BL<<1|BR.
|
|
# Derived from the PET character ROM: 8 blocks exist directly, the other 8 are
|
|
# their reverse-video forms (screen code | $80).
|
|
QUAD = [32, 108, 123, 98, 124, 225, 255, 254, 126, 127, 97, 252, 226, 251, 236, 160]
|