Scan line blues

Discussion about Rocks'n'Diamonds, Boulder Dash, Supaplex, Emerald Mine and any other BD hybrid.

Moderators: Flumminator, Zomis

Post Reply
User avatar
Alan
Posts: 661
Joined: Fri Jun 18, 2004 7:48 pm

Scan line blues

Post by Alan »

Zomis I'm not sure where to put this? This isn't a bug report, or a new idea (OK it is a bit), so I suppose I'm asking for help... but I'm also outlining a fundamental CE rule which all "CE heads" should be aware of ;-) (it might explain why things work one direction but not the other)

I was working on a nice little puzzle/rubik/tetris type game and have hit a brick wall ....the scan line!

I'm guessing (correct me if I'm wrong Holger) that the screen is drawn and each CE is processed using a Left-Right Top-Bottom scan line?
The problem I'm having is CEs getting ignored/wiped and always if it's going with the scan line, right or down. (swimming against the tide works, surfing to the beach doesn't ;-) )


Say we have CE1

It is moved by pressing it (not actual movement just replacement), here's its change pages for pressing it up,down,left and right:-

up




down




left




right




As you can see this wipes and recreates itself one step ahead, and as soon as you press one of these all it's neighbours move as well.

The problem is, it works going against the scan line (left or up), but fails when it's going with it (right or down).

Say I have a line of CE1s

I push left:-





You get:-





Since the scan line is left-right the far left is processed first. It moves left and leaves a space like this:-





...until the whole line has moved (in one draw cycle), OK so far so good.



Now the problem is, moving right:-





This gives you:-





Again, since the scan line is L-R, the first CE to be effected is the one by the player. This is wiped and reconstructed to the right, then the scan line moves right (to the newly made CE), which is then wiped. Gives the effect of a dotted line.

I have tried every possible way under the sun to try and trick the scan line and move them all right in one (or two) screen draw cycles.

Having the element wait until a free space is on the right works, but that means you can only move elements on the end of a line once per screen draw, all the rest have to wait for the next cycle, the longer the line the more waiting they do (and the more errors can occur). So if you push a line of 20 CE1s, it will take 20 screen draw cycles to move the whole thing.... which is slooooooow!


Other methods where to construct secondary movers, like:-

change page right:




Using to check/add/delete neighbours using timers, it either works the same as the simple method, or came crashing down like a horribly complected house of cards. :-\

I had all these problems with snakebite, but what I'm doing now is a bit more technical.
I have ran into this kind of problem lots of times (since day one I suppose) and have either settled or abandoned the idea/game.

Anyone got any ideas?


Holger: How hard would it be to reprogram the screen draw routine so it could not only draw the screen L-R and T-B, but also R-L as well as B-T (8 combinations in all )
You could then add an option to override the next scan with the draw direction of your choice!

So if I moved a vertical line of CE1s down and set the "scan line mode" to B-T and L-R (which starts drawing the screen at the bottom first)
Now all elements at the bottom of a line will be effected first, and all of them would move down correctly (the scan line mode could go back to it's default after a force call)

This would end all block movement limitations (all of snakebite works like that), plus it would have a 1001 uses.
Zomis
Posts: 1502
Joined: Mon Jun 21, 2004 1:27 pm
Location: Sweden
Contact:

Re: Scan line blues

Post by Zomis »

Alan wrote:Zomis I'm not sure where to put this? This isn't a bug report, or a new idea (OK it is a bit), so I suppose I'm asking for help... but I'm also outlining a fundamental CE rule which all "CE heads" should be aware of ;-) (it might explain why things work one direction but not the other)
Heh... after reading the post I'm also unsure ;) But General Discussion is probably the best place to put it in, considering this is about a very general issue... I believe there's not a single level which isn't using Scanning of lines... (since even the smallest - 3x3 level - is created using the left-right, top-bottom method).

And indeed, it's not a very easy problem at all.
I just come up with an idea that could solve it, but I'm absolutely not sure... I have to test this (I just hope I can remember the idea...:P)

However, my guess (without looking much at the source code) is that giving an option of which way to scan the lines would be a very huge project, since Scanning of lines probably affects nearly every single thing in the game...
User avatar
Alan
Posts: 661
Joined: Fri Jun 18, 2004 7:48 pm

Post by Alan »

However, my guess (without looking much at the source code) is that giving an option of which way to scan the lines would be a very huge project, since Scanning of lines probably affects nearly every single thing in the game...
Yep, that is my concern also.......would it effect other elements though?
It would definitely effect other custom elements, but would it change how a firefly moves? Or more importantly how objects with gravity move?

hummmm.
Zomis
Posts: 1502
Joined: Mon Jun 21, 2004 1:27 pm
Location: Sweden
Contact:

Post by Zomis »

HALLELUJAH! :D
I solved this problem using 3 CEs! (at least for the "right" direction...)

Now why is that damn archive down... :twisted: ZOMIS! FIX IT!! :evil: uumm... wait a second... I'm Zomis... ah... yes... Linux Shellbot hit the system... :roll: I hope it will be up again in the beginning of next week though..

Anyways, I describe how I did here:
CE1 has (so far, considering only 1 direction is implemented) 3 change pages:
Page 1 - Change to CE3 when pressed by player at left side
Page 2 - Change to extended target when touching CE2. Extended target is:



( = CE2)
Page 3 - Change to same extended target as page 2, when touching CE3.

CE2 has only 1 change page: Change to CE1 when delay 0 frames.
CE3, also only 1 change page: Change to empty space when delay 0 frames.

Try it!

The only thing I've found out so far that's not good is that you can push these elements up to a wall and they'll disappear... but I've been thinking about using "replace all or nothing" to prevent this somehow..

Now we're approaching "chainable / pullable CEs" I think... interesting. Maybe this is the technique to use :)
User avatar
Alan
Posts: 661
Joined: Fri Jun 18, 2004 7:48 pm

Post by Alan »

You know, as I was implementing your idea, it started to look very familiar! :-( I have done something like this (but a bit different)

Dang it!

The problem is, if the line is an even amount of CEs then it works ok, but if it's an odd number like a row of 9, the first (or is it last) CE is killed!

It's this odd/even thing that can trick you into thinking you got it nailed if your test shapes are all even :-( (which it did with me the 1st time)
Zomis
Posts: 1502
Joined: Mon Jun 21, 2004 1:27 pm
Location: Sweden
Contact:

Post by Zomis »

Alan wrote:The problem is, if the line is an even amount of CEs then it works ok, but if it's an odd number like a row of 9, the first (or is it last) CE is killed!
Hmmm...? I haven't experienced this... neither with the old nor the new idea...
Could you describe it further or show an example level?
User avatar
Alan
Posts: 661
Joined: Fri Jun 18, 2004 7:48 pm

Post by Alan »

Hmmm...? I haven't experienced this... neither with the old nor the new idea...
Maybe I translated it wrong, or maybe the "move all neighbours" action is interfering with is somehow. I'll have another go and do it separately......
User avatar
Alan
Posts: 661
Joined: Fri Jun 18, 2004 7:48 pm

Post by Alan »

Ok here it is:

http://www.ambience.2restinpeace.com/001.level

A totaly empty level with only your example, and it still kills the ends of the line on odd shapes......

I also tried this in different RnD versions just in case (I'm still using 3.1.1), and it does the same. :-( If this works for you, then I haven't a clue why!
Zomis
Posts: 1502
Joined: Mon Jun 21, 2004 1:27 pm
Location: Sweden
Contact:

Post by Zomis »

I discovered it.
On change page 2 and 3 of your CE1, both elements in the change target should be CE2. Not one CE1 and one CE2 as it is now..
Hope that works better for you.

Btw: I use replace when empty and not replace when destructible, but well... that doesn't seem to matter much as long as all elements are the same type and you don't smash them against a wall or so :)
User avatar
Alan
Posts: 661
Joined: Fri Jun 18, 2004 7:48 pm

Post by Alan »

Yes! :D :D :D

Thank you Zomis!

So I did misread it! :oops: I think from now on, if the example CE is in range of 0-9 then we should use - ;-) ;-)

Right.....now the tricky part, implementing it. I may even start from scratch!


*EDIT*

Found a problem, but fixed it ;-)

If the shape is a single CE on its own, it gets wiped leaving nothing (try it), but by changing the change page of CE3 to:-






With "replace when empty", instead of the normal turn to space after delay 0, this seems to fix it......


*EDIT2*

Found another problem :roll: and managed to fix it.
You won't see any difference in your example, but in change page 2 of CE 1, it's better to have:-






instead of CE2 + CE2, this prevents shapes like horse shoes, filling in the gap! ....... to be honest, I solved this problem with a fluke!
User avatar
Holger
Site Admin
Posts: 4081
Joined: Fri Jun 18, 2004 4:13 pm
Location: Germany
Contact:

Post by Holger »

OK, I just see that I managed to be exactly too late (as you two have just solved that problem)... ;-)

But as I thought the main problem to be interesting, here are some bits anyway (replying to Alan's initial post):

> I'm guessing (correct me if I'm wrong Holger) that the screen is drawn
> and each CE is processed using a Left-Right Top-Bottom scan line?

Yep, that's right.

> The problem is, it works going against the scan line (left or up), but fails
> when it's going with it (right or down).

Yes, that's a typical problem with these kinds of engines... This cannot really be fixed.

> Holger: How hard would it be to reprogram the screen draw routine so it
> could not only draw the screen L-R and T-B, but also R-L as well as B-T (8
> combinations in all )

I have just tried it -- in fact it's quite easy. :-)

> You could then add an option to override the next scan with the draw
> direction of your choice!

Yes! I've just added another section to the "CE actions" selectbox named "[engine actions]" and an entry named "set scan mode" with the two possible values "normal" and "reverse". Works as expected! :-)

> Yep, that is my concern also.......would it effect other elements though?

Probably yes. Haven't tested this too deeply...

> It would definitely effect other custom elements, but would it change how
> a firefly moves?

Just checked this. Apparently it does not really affect the firefly movement, for example, but it "disturbes" its movement when you switch the scan mode while a row of fireflies is moving.

> Or more importantly how objects with gravity move?

That was also my first thought. On the first look, everything works OK (falling rocks, smashing a bomb or the player). But I'm sure that there are some things not yet discovered that would be affected in an unexpected way...

Although I'm not sure if this CE action is a good thing for the next stable release, I'll put it into the next pre-release, so you can have a look at it. (Even if it's not needed anymore now with Zomis' solution to your problem.)
Zomis
Posts: 1502
Joined: Mon Jun 21, 2004 1:27 pm
Location: Sweden
Contact:

Post by Zomis »

Well Holger, you never stop suprising us :D
I'm amazed about how fast you implemented this :shock:
And that it, apparently, was easy to do :shock:
But anyways, I solved it first :lol: (just kidding...).

And Alan, I see you solved those problems you ran into very nicely.
I'm looking forward to a couple of levels using this technique ;) I can just imagine what kind of puzzles would be possible...
Last edited by Zomis on Fri Jan 06, 2006 8:33 pm, edited 1 time in total.
User avatar
Alan
Posts: 661
Joined: Fri Jun 18, 2004 7:48 pm

Post by Alan »

Hehe! Took the words out of my mouth there Zomis!

Great work Holger! :D :D :D

So reverse is R-L and B-T ? You don't need these seperate, like horizontal reverse and/or vertical? Cool!

About the firefly, Are you changing the drawmode whilst it's drawing? Wouldn't it be better for the command to change the next draw loop, when the current one has finished?
User avatar
Holger
Site Admin
Posts: 4081
Joined: Fri Jun 18, 2004 4:13 pm
Location: Germany
Contact:

Post by Holger »

(Besides a lot other posts, I missed these two last posts. I don't know why...)

> And that it, apparently, was easy to do

Only a few lines of code, and a C macro to replace all playfield scan "for()" loops... :-)

Adding it as a CE option (I mean, adding it to the selectbox) was the main part of the work... ;-)

Indeed I had some more time around xmas and new years eve than usual (despite some heavy parties around these days... ;-) ).

Unfortunately, I have to work again, and therefore have less time again, so don't expect me running in god mode all the time... =;-) ;-) ;-)

> About the firefly, Are you changing the drawmode whilst it's drawing?

No, I mark it for changing for the next full playfield scan cycle.

> Wouldn't it be better for the command to change the next draw loop,
> when the current one has finished?

Yep, that's exactly how it works now. :-)

It's just that I'm not totally sure which parts of the game engine might be affected by the reverse scanning. I did expect a lot of problems (like with falling elements or gravity), but so far everything I tested seems to be OK.
(I'm sure Darkon will find nasty bugs sooner or later... ;-) )
Post Reply