Let's suppose you have 16 frames, numbered from 1 to 16. Save them as 224 x 136 x 256colors bitmaps (.bmp).
Store them as overlay in the CSBgraphics.dat file, using the CSBgraphics.exe and it's "Import" button. Give them the indexes from 1 to 16.
code for the DSA:
Parameter A is used to store the first frame (in our case, A=1)
Parameter B is used to store the current frame
Code: Select all
0S0 = LB &1+ L16 &% SB L0 L50 L0 L0 LB LA &+ &OVERLAY L$ M1S*
0C0 = 1L0 L100 L0 L0 L1 &OVERLAY
0T0 = J
1T0 = 0J0
-------------------
Explanations:
State 0, line S0
Code: Select all
LB &1+ L16 &% SB L0 L50 L0 L0 LB LA &+ &OVERLAY L$ M1S*
This line is activated with a SET message. It shows the next frame and sends a SET message to itself.
This loads parameter B into the stack
It increases it's value by A.
It takes the mod 16 of it. In our case, when parameter B reaches 16, it is set to 0, nothing more.
It stores the new value to parameter B.
So, here are the possible values during these operations:
Code: Select all
LB -> 0<=B<=15
&1+ -> 1<=B<=16
mod 16 -> 0<=B<=15
Here we call the overlay function with the following parameters:
p1: 0 (unused)
p2: 50 (% of transparency)
p3: 0 (unused)
p4: 0 (unused)
p5: B+A (index of overlay). This is the overlay to show, stored in graphics.dat. We have to add A because the frames were indexed from 1 to 16, and B goes from 0 to 15. So A must be 1 in this case
(If our frames were numbered from 200 to 215, we had to add 200 to B, and A should be 200).
L$ stores the location of the DSA into the stack.
M1S* sends a SET message with delay 1 to the location stored in the stack (that is, the DSA location)
M means "send message"
1 means "delay 1"
S means SET message
* means "use the stack to know where to send the message"
-------------------
State 0, line C0
This line is activated with a CLOSE message. It clears the overlay and disable the DSA, by changing its state.
This store the value 0 to the stack, but notice the 1 at the beginning of the line.
Before any command, if there's a number, the DSA will be changed of state.
When all the code is done, the DSA, which was in state 0, will become in state 1.
Here we call the overlay function with the following parameters:
p1: 0 (unused)
p2: 100 (% of transparency). No matter which overlay it is, it will be invisible.
p3: 0 (unused)
p4: 0 (unused)
p5: 1 (index of overlay).
Since there can be only one overlay at a time, displaying an invisible overlay will clear any previous one.
So, if the DSA receives a CLOSE message, it will be changed to state 1. You can see that there is no code at line 1S0: the DSA will ignore the SET message it was sending to itself, and the overlay loop will be stopped this way.
-------------------
State 0, line T0
"J" means JS0. If the DSA receives a TOGGLE message in state 0, it will jump to line 0S0 and starts the loop.
-------------------
State 1, line T0
If the DSA receives a TOGGLE message in state 1, it will jump to line 0S0 and starts the loop.
But it will also be changed to state 0, enabling it, since there is code to respond to SET messages.
-------------------
Summary:
Set parameter A as the first frame number
Send a TOGGLE message to the DSA to start the overlay loop.
Send a CLOSE message to the DSA to stop the overlay loop.
The DSA cycles through the frames and show them each 1 tick.