Overlay help needed!

Discuss Chaos Strikes Back for Windows and Linux, an unofficial port of Chaos Strikes Back to PC by Paul Stevens, as well as CSBuild, an associated dungeon editor.

Moderator: Zyx

Forum rules
Please read the Forum rules and policies before posting.
Post Reply
User avatar
PaulH
Ghastly gastropod
Posts: 3763
Joined: Wed Aug 07, 2002 10:27 pm
Location: Level 6

Overlay help needed!

Post by PaulH »

I would like to make an overlay, sort of a red version (red hue, or fiery type thing) of the watery one that was posted by Paul/Zyx in the Demo that works when entereing just one level, but switches of when leaving. I dunno what to do! I have had a play with the Demo and am stumped.

Any help would be appreciated. And would have to be in absolute beginners terms!
Never underestimate the predictability of stupidity
User avatar
Zyx
DSA Master
Posts: 2592
Joined: Mon Jun 05, 2000 1:53 pm
Location: in the mind
Contact:

Post by Zyx »

I'll post a DSA example here later.
User avatar
PaulH
Ghastly gastropod
Posts: 3763
Joined: Wed Aug 07, 2002 10:27 pm
Location: Level 6

Post by PaulH »

Thankyou!!!
User avatar
Zyx
DSA Master
Posts: 2592
Joined: Mon Jun 05, 2000 1:53 pm
Location: in the mind
Contact:

Post by Zyx »

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.

Code: Select all

LB LA &+ L16 &% SB
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

Code: Select all

L0 L50 L0 L0 LB LA &+ &OVERLAY
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).

Code: Select all

L$ M1S*
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

Code: Select all

1L0 L100 L0 L0 L1 &OVERLAY
This line is activated with a CLOSE message. It clears the overlay and disable the DSA, by changing its state.

Code: Select all

1L0
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.

Code: Select all

L0 L100 L0 L0 L1 &OVERLAY
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

Code: Select all

J
"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

Code: Select all

0J0
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.
Last edited by Zyx on Thu May 19, 2005 2:59 am, edited 2 times in total.
User avatar
PaulH
Ghastly gastropod
Posts: 3763
Joined: Wed Aug 07, 2002 10:27 pm
Location: Level 6

Post by PaulH »

We may just about have lift off! Great explanation, even for my tired eyes.

But... (there always is one LOL!), I get an error message when stepping on the pad to activate the DSA. Its says 'overlay not included in csbgraphics.dat'. Have have imported the bitmaps as specified.
User avatar
Paul Stevens
CSBwin Guru
Posts: 4318
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

Again, I would like to point out the TimerTrace function
in the Misc menu. Turn it on. Then, in the trace file you
will see each step of your dsa and the parameters that
are being passed to the &OVERLAY function. So that
you can see if they are correct. If there are problems
you can quote this trace and we can help you figure out
what went wrong.
User avatar
PaulH
Ghastly gastropod
Posts: 3763
Joined: Wed Aug 07, 2002 10:27 pm
Location: Level 6

Post by PaulH »

OK, I shall take a look at this, but it seems the import went awry. The CSBgraphics file is very small (only 2k) compared to the 180kb of data I imported. I am using v3.5.

Thankyou for your help I am determined now to enter the world of DSA!
User avatar
Paul Stevens
CSBwin Guru
Posts: 4318
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

If the DSA receives a TOGGLE message <in state 0>, it will execute line 0C0 and starts the loop.
f the DSA receives a TOGGLE message in state 1, it will execute line 0C0 and starts the loop.
I don't understand either of these statements.

A TOGGLE in state 0 will cause 0S0 to execute (Not 0C0 as
you say).

A TOGGLE in state 1 will do nothing except change the
state to 0 for the next message that arrives. It JUMPS to
S0 in state 1 which is empty.

What am I missing? You have used these things hundreds of
times as many tmes as I have used them so you are probably
right.....but if you are right it seems like a bug in CSBwin, to me.
User avatar
PaulH
Ghastly gastropod
Posts: 3763
Joined: Wed Aug 07, 2002 10:27 pm
Location: Level 6

Post by PaulH »

Apologies, the import is functioning correctly, it is me who isn't.

I shall take this back up tomorrow and will report on progress.
User avatar
Zyx
DSA Master
Posts: 2592
Joined: Mon Jun 05, 2000 1:53 pm
Location: in the mind
Contact:

Post by Zyx »

You pointed out several mistakes, Paul S. I fixed them, thank you.
I should try this DSA code before posting!
User avatar
Paul Stevens
CSBwin Guru
Posts: 4318
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

If I were to produce a generic Overlay DSA
it would look like this: (Details removed so
that even Cows can understand! :wink:

http://www.dianneandpaul.net/CSBwin/doc ... layDSA.png

Edit.......
P.S. Anyone see how this can fail? It needs a bit
of tweeking in the details.
User avatar
PaulH
Ghastly gastropod
Posts: 3763
Joined: Wed Aug 07, 2002 10:27 pm
Location: Level 6

Post by PaulH »

It works! I have 'Sprach Zarathustra' (2001 - A Space Odyssey) playing in my mind...

Thankyou once again.
User avatar
PaulH
Ghastly gastropod
Posts: 3763
Joined: Wed Aug 07, 2002 10:27 pm
Location: Level 6

Post by PaulH »

I have successfully set one of my levels 'onfire', and turned another into a psychedelic light show. I am using just 4 frames for the 'animation' which gives a nice result.

So easy to make mistakes though... like saving as 24bit bitmap instead of 256 colours and wondering what the resultant garbage was... or forgetting to replace the 'A' in the DSA with the correct number. Also have to be careful switching the overlay on and off between levels as it remains 'on' if you fall down a pit for example. But really cool.

I have also realised that I can make a 'endgame' sequence animation if I fiddle with the transparancies (though a short animation). Question: what happens if you trigger another Overlay when one is in progress?
User avatar
Paul Stevens
CSBwin Guru
Posts: 4318
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

what happens if you trigger another Overlay when one is in progress?
Hopefully, the new will take effect and the old will go away.
remains 'on' if you fall down a pit for example
Your DSA can check the party's level if it wishes.
User avatar
Adamo
Italodance spammer
Posts: 1534
Joined: Fri Apr 22, 2005 11:59 am
Location: Poland
Contact:

Post by Adamo »

ok, even though I`m a totally DSA dumb, after millions of trials and errors I`ve mixed Paul`s and Zyx`s DSA overlays. This is if anyone has any doubts.

Code: Select all

0S0: LB &1+ L16 &% SB L0 L50 L0 L0 LB &1+ &OVERLAY M1S
0C0: 1L0 L100 L0 L0 L1 &OVERLAY
0T0: J
1T0: 0J0
An overlay moves all the time, like in Paul`s example, and is turnonable (by toggle message) and turnoffable (by clear message) like in Zyx`s DSA (when DSA A and B parameters are set to the DSA itself).
I did it, because I had a little problem with Zyx DSA: it worked allright, but an overlay wasn`t moving at "real" time: it was moving one frame each time, when a DSA got a "toggle" message: 0S0 lines in Paul`s "overlay demo" and Zyx`s example are bit different, so I`ve mixed Paul`s 0S0 line with Zyx`s 0C0, 0T0 and 1T0 lines. It works!
To be honest, I don`t understand this stuff at all !
Spoiler
(\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/)
Spoiler
(@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@)
Spoiler
(>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<)
User avatar
beowuuf
Archmastiff
Posts: 20687
Joined: Sat Sep 16, 2000 2:00 pm
Location: Basingstoke, UK

Post by beowuuf »

Line zero is adding 1 to the parameter B used as the location number (in the CSBgraphics.dat) for the overlay - the L16 &% is simply a divide by 16, and give me back only the remainder, then set parameter B with this value. So you will always get 0 - 15 as your B parameter value (if the answer LB was incremented to 16, the remaineder of the division is 0 and you start again)

After generating the overlay, the DSA targets the parameter in A with a set message - I assume itself (you could have used L$ M1S* to save parameters)

C0 is simply caling up a fully transparent overlay - which clears the screen effectively. It also toggles the state to state 1 (the very first number in the line changes state after the code is excecuted), to ensure that your last set message doens't retrigger the overlay code in state 0.

You cannot set the DSA again without giving it a toggle message to set it back to state 0, which will start the DSA up again (as you are jumping to line S by default).

I assume line 0T0 is there simply to make sure a toggle message always starts the DSA overlay, and I would therefore assume that you use toggle to start the DSA and clear to stop it alone.
Post Reply

Return to “Chaos Strikes Back for Windows & Linux (CSBWin) / CSBuild”