Difference between revisions of "Sprites"
(Created page with "= Sprites = Sprites are 16x16 independently moving images. Each can use up to 256 colors, independently selected from a palette. To enable sprites, bit 0 of {{NextRegNo|$21}...") |
|||
Line 9: | Line 9: | ||
To upload a pattern, write the pattern number to {{PortNo|$303B}}. Then write the pattern, byte by byte in reading order, to {{PortNo|$xx5B}}. The pattern must be exactly 256 bytes long, filling the 16x16 available area. Each byte is the index into the palette of the color of that pixel. The default palette simply maps the indexes 0-255 to colors 0-255 which are decoded as in [[Enhanced ULA|ULAPlus]], except that %11100011 (pink) is treated as transparent. Sprites smaller that 16x16 thus must pad the extra space with the transparent color. After 256 bytes are written, continuing to write will write to the ''next'' pattern number, and so on. | To upload a pattern, write the pattern number to {{PortNo|$303B}}. Then write the pattern, byte by byte in reading order, to {{PortNo|$xx5B}}. The pattern must be exactly 256 bytes long, filling the 16x16 available area. Each byte is the index into the palette of the color of that pixel. The default palette simply maps the indexes 0-255 to colors 0-255 which are decoded as in [[Enhanced ULA|ULAPlus]], except that %11100011 (pink) is treated as transparent. Sprites smaller that 16x16 thus must pad the extra space with the transparent color. After 256 bytes are written, continuing to write will write to the ''next'' pattern number, and so on. | ||
− | + | To display and move sprites, write the sprite number to {{PortNo|$303B}}, then control the sprite by writing a 4 byte packet to {{PortNo|$xx57}} to which 4 byte packets are set. This sets the position of the sprite, which pattern it displays, and what effects are applied. Full details of the packet contents are given on the page for that port. | |
+ | |||
+ | You can overwrite the standard palette by sending any value to {{PortNo|$303B}} then sending 256 color values, in [[Enhanced ULA|ULAPlus]] format, to {{PortNo|$xx53}}. Since 256 indices are supported this is not necessary to be able to access every color, but re-ordering the colors will allow the sprite palette offset option at {{PortNo|$xx57}} to create effects. |
Revision as of 17:17, 18 August 2017
Sprites
Sprites are 16x16 independently moving images. Each can use up to 256 colors, independently selected from a palette.
To enable sprites, bit 0 of ($21) must be set. If bit 1 is set also, sprites are permitted to cross the border.
The Next supports up to 64 sprites on screen at a time. It also supports 64 "patterns" (bitmap images used for sprites). These can be independent - for example, you could have several sprites with the same pattern.
To upload a pattern, write the pattern number to Sprite Status/Slot Select ($303B / 12347). Then write the pattern, byte by byte in reading order, to Sprite Pattern Upload ($xx5B / 91). The pattern must be exactly 256 bytes long, filling the 16x16 available area. Each byte is the index into the palette of the color of that pixel. The default palette simply maps the indexes 0-255 to colors 0-255 which are decoded as in ULAPlus, except that %11100011 (pink) is treated as transparent. Sprites smaller that 16x16 thus must pad the extra space with the transparent color. After 256 bytes are written, continuing to write will write to the next pattern number, and so on.
To display and move sprites, write the sprite number to Sprite Status/Slot Select ($303B / 12347), then control the sprite by writing a 4 byte packet to Sprite Attribute Upload ($xx57 / 87) to which 4 byte packets are set. This sets the position of the sprite, which pattern it displays, and what effects are applied. Full details of the packet contents are given on the page for that port.
You can overwrite the standard palette by sending any value to Sprite Status/Slot Select ($303B / 12347) then sending 256 color values, in ULAPlus format, to ($xx53). Since 256 indices are supported this is not necessary to be able to access every color, but re-ordering the colors will allow the sprite palette offset option at Sprite Attribute Upload ($xx57 / 87) to create effects.