Auto animation: Difference between revisions
mNo edit summary |
m (Sections, note about animation counter being read-only) |
||
(8 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
[[File:Autoanim.gif|frame| | [[File:Autoanim.gif|frame|2bit (4 tiles) example from [[Mutation Nation]].]] | ||
Some information from Charles MacDonald. | |||
Auto-animation is a | Auto-animation is a special feature of the video controller allowing animation of simple loops with no CPU usage. It is enabled via [[sprites|sprite]] tile attributes bits. | ||
==Usage== | |||
The auto-animation speed is a global setting, which is set in the highest 8 bits of {{Reg|REG_LSPCMODE}}. A value of n will tick the animation every n+1 frames. | |||
When auto-animation is | When setting the auto-animation speed, the new value is only taken into account the next time the timer underflows (reloads), not immediately after the write. | ||
Bit 3 of REG_LSPCMODE stalls animation when set. The animation counter is '''read only''', from the lower 3 bits of REG_LSPCMODE. | |||
Auto-animation is enabled per-tile via 2 bits in the odd bytes of [[Sprites|SCB1]]: | |||
{{16BitRegister|[[Palettes|Palette]]|8|Tile number MSBs|4|'''3-bit auto-anim'''|1|'''2-bit auto-anim'''|1|Vertical flip|1|Horizontal flip|1}} | |||
Depending on the animation period (4 or 8 frames), the tile number specified in [[Sprites|SCB1]] has the lower 2 or 3 bits replaced with those of the animation counter. | Effects: | ||
{|class="wikitable" | |||
!Bit 3||Bit 2||Effect | |||
|- | |||
|0||0||No auto-animation for this tile. Tile shown is the tile number. | |||
|- | |||
|0||1||Auto-animation over 4 tiles. | |||
|- | |||
|1||0||Auto-animation over 8 tiles. | |||
|- | |||
|1||1||Auto-animation over 8 tiles (bit 2 is ignored). | |||
|} | |||
Depending on the animation period (4 or 8 frames), the tile number specified in [[Sprites|SCB1]] has the lower 2 or 3 bits '''replaced''' with those of the animation counter. | |||
Note that the bits are '''replaced''', not added. Therefore, the tiles must be carefully aligned to the right positions in the [[C ROM]]s. | |||
==Operation== | |||
An internal 8-bit timer is ticked each frame. When it underflows, two things happen: | |||
* The timer is reloaded with the last value written to it, which comes from the 8 highest bits of REG_LSPCMODE. | |||
* An internal 3-bit animation counter is incremented. | |||
When auto-animation is disabled (bit 3 of REG_LSPCMODE set), the timer and animation counter continue to function. However, '''all''' tiles are shown as if their animation mode select bits were reset (so the tile number specified is the tile shown). | |||
[[Category:Video system]] | [[Category:Video system]] |
Latest revision as of 01:52, 27 February 2018
Some information from Charles MacDonald.
Auto-animation is a special feature of the video controller allowing animation of simple loops with no CPU usage. It is enabled via sprite tile attributes bits.
Usage
The auto-animation speed is a global setting, which is set in the highest 8 bits of REG_LSPCMODE. A value of n will tick the animation every n+1 frames.
When setting the auto-animation speed, the new value is only taken into account the next time the timer underflows (reloads), not immediately after the write.
Bit 3 of REG_LSPCMODE stalls animation when set. The animation counter is read only, from the lower 3 bits of REG_LSPCMODE.
Auto-animation is enabled per-tile via 2 bits in the odd bytes of SCB1:
Bit | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
Def | Palette | Tile number MSBs | 3-bit auto-anim | 2-bit auto-anim | Vertical flip | Horizontal flip |
Effects:
Bit 3 | Bit 2 | Effect |
---|---|---|
0 | 0 | No auto-animation for this tile. Tile shown is the tile number. |
0 | 1 | Auto-animation over 4 tiles. |
1 | 0 | Auto-animation over 8 tiles. |
1 | 1 | Auto-animation over 8 tiles (bit 2 is ignored). |
Depending on the animation period (4 or 8 frames), the tile number specified in SCB1 has the lower 2 or 3 bits replaced with those of the animation counter.
Note that the bits are replaced, not added. Therefore, the tiles must be carefully aligned to the right positions in the C ROMs.
Operation
An internal 8-bit timer is ticked each frame. When it underflows, two things happen:
- The timer is reloaded with the last value written to it, which comes from the 8 highest bits of REG_LSPCMODE.
- An internal 3-bit animation counter is incremented.
When auto-animation is disabled (bit 3 of REG_LSPCMODE set), the timer and animation counter continue to function. However, all tiles are shown as if their animation mode select bits were reset (so the tile number specified is the tile shown).