Module sprites

Module sprites 

Source
Expand description

Sprites: the line scan of the sprite attribute table, and the drawing of the line’s sprites (vdc/sprites.py).

[hw: pcetech 5.3; mfr: Hudson HuC6270 manual] The 64-entry table (SAT, filled only by the VRAM -> SAT DMA) holds, per sprite: Y (10 bits, the first visible line is 64), X (10 bits, 32 is the display’s left edge), pattern (bits 10-1; bit 0 is the CG bit), and flags: palette (3-0), priority (7), width 16/32 (8), flip X (11), height 16/32/64 (13-12), flip Y (15). A pattern is 16 x 16 pixels = 64 words, four planes of 16 words. Larger sprites use neighbouring patterns: width 32 clears pattern bit 0, height 32 clears bit 1, height 64 clears bits 2 and 1; flips act on the whole sprite.

Per line the scan finds the sprites that cover the next line, in table order, up to 16 pattern entries (a 32-wide sprite is two entries); a 17th needed entry sets the overflow flag and ends the scan. The first opaque pixel in buffer order wins; a pixel is in front of the background if its priority bit is set or the background pixel is transparent; sprite 0 colliding with another sprite’s opaque pixel sets the collision flag. When MWR’s sprite access width is 1 the pattern is two bitplanes, picked by the CG bit (SP0/SP1 or SP2/SP3).

Provisional (U3, tier 5): that the scan reads the pattern words when it finds the sprite (the line before it is drawn), as Mednafen does; the narrow-display budget below is Mesen2’s.

Structs§

Entry

Constants§

CLOCKS_PER_SPRITE
[mfr: SM table; emu: Mesen2] dots of fetch time per entry
HEIGHTS
HEIGHT_MASKS
SPRITE_LIMIT

Functions§

draw
Draw the entries over row (the line’s 9-bit pixels; the display starts at index first).
scan
The entries of sprites covering line (counted from the first display line), and whether a 17th entry was needed (overflow).
scan_into
scan into a list the caller keeps (emptied first); returns the overflow.