Module background

Module background 

Source
Expand description

The background layer: one line of 9-bit pixels from the BAT and the character generator (vdc/background.py).

[hw: pcetech 5.2; mfr: Hudson HuC6270 manual] Tiles are 8x8, 4 bits per pixel, planar: 16 words per tile, word y holds bitplanes 0 (low byte) and 1 (high byte) of line y, word y + 8 bitplanes 2 and 3. The BAT starts at VRAM word 0, one word per tile ppppnnnnnnnnnnnn: palette and name, no flips and no priority. Only names 0-2047 exist in 64 KiB of VRAM; the rest read as 0 here (U23).

The line is drawn in one go when the display width begins, from the scroll registers latched a few dots earlier, as Mednafen does (tier 5, U3); a VRAM change during the line shows on the next one.

Differences forced by Rust: none in behaviour. The reference’s per-instance decode cache (a dict that only saves PyPy time) is not carried over; the eight pixels are decoded each time (the fork: from a table, a bitplane byte at a time, into the row itself).

Constants§

BAT_HEIGHTS
BAT_SHIFTS
BAT_WIDTHS

Functions§

row
width pixels, each palette << 4 | colour; colour 0 is transparent.
row_into
row, drawn into out (its length is the width).