Editing Wikifang:Network Translation Patchsite/SpriteManager
Jump to navigation
Jump to search
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
Bugsite's metasprite system is a scriptable SpriteManager which manages the movement of objects on a playfield. These objects need to be managed as a collection of hardware sprites (on systems which support them). In GB retroprogramming parlance these collections of sprites are called metasprites. SpriteManager is Bugsite's implementation of a metasprite system. | Bugsite's metasprite system is a scriptable SpriteManager which manages the movement of objects on a playfield. These objects need to be managed as a collection of hardware sprites (on systems which support them). In GB retroprogramming parlance these collections of sprites are called metasprites. SpriteManager is Bugsite's implementation of a metasprite system. | ||
== Metasprite Data Structure == | == Metasprite Data Structure == | ||
Line 34: | Line 16: | ||
Bit 1: Metasprite is active, meaning the user is expected to be able to see it. Sprites are usually activated and deactivated by a per-frame clip test; however, sprites can also manually deactivate themselves. Deactivated sprites are processed normally, but they do not create visible hardware sprites on screen. | Bit 1: Metasprite is active, meaning the user is expected to be able to see it. Sprites are usually activated and deactivated by a per-frame clip test; however, sprites can also manually deactivate themselves. Deactivated sprites are processed normally, but they do not create visible hardware sprites on screen. | ||
Bit 2: Metasprite is | Bit 2: Metasprite is running an animation. New animations won't be queued, and idle loop scripts won't run, until the animation completes. Stationary animations do not set this flag and are always interruptible animations. | ||
Bit 3: Metasprite | Bit 3: Metasprite has been locked to it's stationary animation. | ||
Bit 4: Metasprite | Bit 4: Metasprite has been locked to it's stationary animation. For some reason, there are two bits with the same effect. It is unknown if one bit has different semantics from the other. | ||
For some reason, there are two bits with the same effect | |||
|- | |- | ||
| SpriteY || +$01 || Y coordinate of sprite (16bit) | | SpriteY || +$01 || Y coordinate of sprite (16bit) | ||
Line 50: | Line 30: | ||
| AnimAllowed || +$07 || Must be non-zero for animations to run on this sprite. | | AnimAllowed || +$07 || Must be non-zero for animations to run on this sprite. | ||
|- | |- | ||
| | | FileIndex || +$08 || Offset from the base files for stationary and moving animations. | ||
The file index appears to be restricted to the following common indices; BugVM instructions that directly set FileIndex will wrap any further values to zero. | |||
{| class="wikitable" | |||
|+ Common indices | |||
|- | |||
! Direction !! FileIndex | |||
|- | |||
| Right / East || 0 | |||
|- | |||
| Left / West || 1 | |||
|- | |||
| Up / North || 2 | |||
|- | |||
| Down / South || 3 | |||
|} | |||
|- | |- | ||
| FileAnimStationary || +$09 || BugFS file ID containing an animation script to be used for the stationary animation. | | FileAnimStationary || +$09 || BugFS file ID containing an animation script to be used for the stationary animation. | ||
Line 60: | Line 53: | ||
| FileAnimMoving || +$0B || BugFS file ID containing an animation script to be used for walk cycles and other sprite-moving animations. | | FileAnimMoving || +$0B || BugFS file ID containing an animation script to be used for walk cycles and other sprite-moving animations. | ||
|- | |- | ||
| | | IdleRepeat || +$0D || How many idle frames to continue executing the current IdleInstr. | ||
|- | |- | ||
| | | IdleInstr || +$0E || The current IdleInstr being executed. | ||
''See "Idle Loop Instructions".'' | |||
''See " | |||
|- | |- | ||
| | | IdlePC || +$0F || Pointer to the next idle loop instruction to execute. | ||
|- | |- | ||
| | | IdleScript || +$11 || Pointer to the start point of the current idle loop. | ||
|- | |- | ||
| || +$13 to +$1F || Presumed empty | | || +$13 to +$1F || Presumed empty | ||
Line 80: | Line 72: | ||
! Field !! Offset !! | ! Field !! Offset !! | ||
|- | |- | ||
| | | || +$00 || Purpose unknown. Zeroed upon initialization. | ||
|- | |- | ||
| Delay || +$01 || Amount of frames to wait until next frame of animation. | | Delay || +$01 || Amount of frames to wait until next frame of animation. | ||
Line 91: | Line 83: | ||
|- | |- | ||
| AnimPC || +$07 || Pointer to the next animation instruction to execute. | | AnimPC || +$07 || Pointer to the next animation instruction to execute. | ||
|- | |- | ||
| SpriteIndex || +$09 || Index of the metasprite slot that this animation serves. | | SpriteIndex || +$09 || Index of the metasprite slot that this animation serves. | ||
Line 108: | Line 98: | ||
Yes, Bugsite has ''two of them''. | Yes, Bugsite has ''two of them''. | ||
=== | === Idle Loop Instructions === | ||
Idle loops are small lists of instructions that dictate how a non-player-controlled sprite, such as an NPC, will move across the screen. Each instruction is preceded by a repeat count; each instruction will execute that many times before moving to the next idle loop. A maximum of one idle instruction will execute per frame, and idle instructions wait for animations to finish before proceeding. Idle loop opcodes do not have operands, and only one flow control instruction. | |||
Setting a repeat value of 0 causes the loop to stop executing instructions. The current instruction will still execute | Setting a repeat value of 0 causes the loop to stop executing instructions. The current instruction will still execute. | ||
{| class='wikitable' | {| class='wikitable' | ||
Line 119: | Line 109: | ||
| ENOP $nn || $00-$4F || N/A || Treated as effective NOP by the script interpreter. | | ENOP $nn || $00-$4F || N/A || Treated as effective NOP by the script interpreter. | ||
|- | |- | ||
| | | INOP $50 || $50 || $33F7 || NOP | ||
|- | |- | ||
| | | INOP $51 || $51 || $33FA || NOP | ||
|- | |- | ||
| | | INOP $52 || $52 || $33FD || NOP | ||
|- | |- | ||
| | | IDOWN || $53 || $341F || Run the sprite's move-down animation. | ||
|- | |- | ||
| | | IUP || $54 || $3436 || Run the sprite's move-up animation. | ||
|- | |- | ||
| | | ILEFT || $55 || $344D || Run the sprite's move-left animation. | ||
|- | |- | ||
| | | IRIGHT || $56 || $3464 || Run the sprite's move-right animation. | ||
|- | |- | ||
| | | INOP $57 || $57 || $347B || NOP | ||
|- | |- | ||
| | | IWAIT || $58 || $3400 || Run the stationary animation for the sprite's current direction a random number of times, from $0 to $20. | ||
The repeat value of this instruction is ignored. | The repeat value of this instruction is ignored. | ||
|- | |- | ||
| | | ISTOP || $59 || $341C || Run the stationary animation for the sprite's current direction. | ||
|- | |- | ||
| EFGAME $nn || $60-$EF || N/A || Invalid opcodes, will likely crash game. | | EFGAME $nn || $60-$EF || N/A || Invalid opcodes, will likely crash game. | ||
|- | |- | ||
| | | IHALT || $F0 || $33C0 || Reset the idle loop back to IdleScript. | ||
The repeat value of this instruction is always treated as 0 (e.g. halt). | The repeat value of this instruction is always treated as 0 (e.g. halt). | ||
|- | |- | ||
| | | IRESET || $F1 || $33E2 || Reset the idle loop back to IdleScript. | ||
|- | |- | ||
| EFGAME $nn || $F2-$FF || N/A || Invalid opcodes, will likely crash game. | | EFGAME $nn || $F2-$FF || N/A || Invalid opcodes, will likely crash game. | ||
|} | |} | ||
''Please keep in mind that directional commands such as | ''Please keep in mind that directional commands such as IDOWN, IUP, ILEFT, and IRIGHT do not actually move the sprite.'' Instead, they queue the animation script associated with that direction. The animation script itself moves the sprite; it's only by convention that, e.g. IDOWN always executes a script that moves the sprite down two tiles. Furthermore, script execution is predicated upon the target tiles being free; if they are occupied, then the idle script will halt until that slot becomes free. This has the following consequences: | ||
* The movement path specified by the | * The movement path specified by the idle script will be followed exactly. | ||
* Sprites can get 'stuck' on stationary walls, or even each other. | * Sprites can get 'stuck' on stationary walls, or even each other. | ||
* NPCs will 'box in' players, never moving until the player moves out of their way, as the player is just another sprite. | * NPCs will 'box in' players, never moving until the player moves out of their way, as the player is just another sprite. | ||
=== Animation Script Instructions === | === Animation Script Instructions === | ||
This scripting engine does the actual job of specifying how a sprite will animate from frame to frame when moving across the screen | This scripting engine does the actual job of specifying how a sprite will animate from frame to frame when moving across the screen. | ||
== Move Permissions == | == Move Permissions == |