Auto animation: Difference between revisions

From NeoGeo Development Wiki
Jump to navigation Jump to search
mNo edit summary
m (Note about timer reload)
Line 1: Line 1:
[[File:Autoanim.gif|frame|2bit (4 tiles) example from [[Mutation Nation]]]]
[[File:Autoanim.gif|frame|2bit (4 tiles) example from [[Mutation Nation]].]]


(Information from [[Charles MacDonald]])
Some information from Charles MacDonald.


Auto-animation is a tile attribute for [[sprites]] and a special feature of the GPU used to animate loops without CPU usage.
Auto-animation is a tile attribute for [[sprites]] and a special feature of the video controller, used to animate simple loops with no CPU usage.


An internal write-only 8bit counter is automatically decremented each frame. When it underflows, it is reloaded with the last value written to it, which comes from the 8 highest bits of {{Reg|REG_LSPCMODE}}. This sets the speed of the animation.
An internal 8-bit timer is ticked each frame. When it underflows, two things happen:


Each time that counter underflows, another internal 3bit counter is incremented. Those 3 bits can only be read in bits 2~0 of REG_LSPCMODE.
* The timer is reloaded with the last value written to it, which comes from the 8 highest bits of {{Reg|REG_LSPCMODE}}. This sets the speed of the animation.
* An internal 3bit counter is incremented. Those 3 bits can only be read in bits 2~0 of REG_LSPCMODE.


When auto-animation is disabled (bit 3 of REG_LSPCMODE set), the frame counter and animation counter continue to function. However, tiles are shown as if their animation mode select bits were reset (so the tile number specified is the tile shown).
When setting the auto-animation speed via REG_LSPCMODE, the new value is only taken into account the next time the timer underflows (reloads), not immediately after the write.
 
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).


These bits can be set in each tile's attribute word (odd bytes of [[Sprites|SCB1]]):
These bits can be set in each tile's attribute word (odd bytes of [[Sprites|SCB1]]):
{{16BitRegister|[[Palettes|Palette]]|8|Tile number MSBs|4|'''3bit auto-anim'''|1|'''2bit auto-anim'''|1|Vertical flip|1|Horizontal flip|1}}
{{16BitRegister|[[Palettes|Palette]]|8|Tile number MSBs|4|'''3-bit auto-anim'''|1|'''2-bit auto-anim'''|1|Vertical flip|1|Horizontal flip|1}}
 
Effects:


Bit 3 has priority.
{|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.
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 consecutive tiles used for animation must be aligned on 4 or 8.
Note that the bits are '''replaced''', not added. Therefore, the tiles must be carefully aligned to the right positions in the [[C ROM]]s.


[[Category:Video system]]
[[Category:Video system]]

Revision as of 15:53, 19 February 2018

2bit (4 tiles) example from Mutation Nation.

Some information from Charles MacDonald.

Auto-animation is a tile attribute for sprites and a special feature of the video controller, used to animate simple loops with no CPU usage.

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. This sets the speed of the animation.
  • An internal 3bit counter is incremented. Those 3 bits can only be read in bits 2~0 of REG_LSPCMODE.

When setting the auto-animation speed via REG_LSPCMODE, the new value is only taken into account the next time the timer underflows (reloads), not immediately after the write.

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).

These bits can be set in each tile's attribute word (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 MSBs3-bit auto-anim2-bit auto-animVertical flipHorizontal 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.