Subject: [stella] Big Dig - update and musings From: Christopher Tumber <christophertumber@xxxxxxxxxx> Date: Sun, 13 Apr 2003 15:07:19 -0400 |
Just had a bit of a brainstorm so I'm making this post as much to "think out loud" and straighten things out in my head as anything... My girlfriend just looks at me like I'm talking gibberish (which I guess I am..) and the cat never gives a damn. Attached is the most recent Big Dig. It's about as far along as the original pre-rewrite version. - Blocks don't disappear when 3 or more come together - There's a roll/flicker problem depending upon the layout of the screen and for that reason if you run it on an emulator which autoselects NTSC/PAL you'll want to force NTSC (-c0 in z26) [A key routine needs to be optimised (or replaced - see below) and is spiking depending upon the layout of the screen] - No sound - Treasure don't respawn - Generation of new blocks is haphazzard - Probably all kinds of other stuff. But the reason for the post is one of the key routines. Which I may have just thought of a way to replace with something a lot quicker. Currently, every "game cycle" all blocks are checked to see if they can fall. This is done by checking to see if the block below is a different (non-empty) colour. If so, then that block is flagged as anchored and all blocks in its group (same colour & touching) are also flagged. In other words: Is space empty? YES- Next space Does space below have a different coloured block? YES - Flag this block and all blocks in this group (same coloure & touching) as anchored Goto Next Space However, this results in a lot of work. Currently the board is 8x10 so that's 80 tests each "game cycle". The first alternate idea is to only test blank spaces. There are usually a lot fewer of them, and they often have another blank space above them so they can quickly be discounted. So if there's a blank space, check the space above it. Find all blocks in the group above it and check if any of those are anchored. If not, mark all those blocks as ready to fall. In other words: Is space empty? NO -> Next space Is space above empty? YES -> Next space Find all blocks in same group as the block in the above space If none of these blocks have a different coloured block below them, mark all of them as falling. Those last two lines really need to be more explicitly stated. For my "fill" routine (as posted previously) I wound up using a seed fill in a diamond pattern. I realised I actually had quite a few bytes available to generate a list of blocks if I used the RAM allocated to my RAM routine since the RAM routine is regenerated every time I redraw the screen anyway (The score display also uses this area as scratch RAM as well so I should have realised this earlier). This gives me $26 bytes RAM to work with so I do have to be a little carefull about running out of RAM (probably by limiting the number of blocks of the same colour on screen at any time but that's really an issue that can be addressed later) Is block above the same colour? YES -> Flag this block and add this block to list Is block below the same colour? YES -> Flag this block and add this block to list is block below this block a different colour? YES -> this group is anchored - remove flag from blocks and exit routine Is block left the same colour? YES -> Flag this block and add this block to list is block below this block a different colour? YES -> this group is anchored - remove flag from blocks and exit routine Is block right the same colour? YES -> Flag add this block to list is block below this block a different colour? YES -> this group is anchored - remove flag from blocks and exit routine get next block from list - If list is finished then this group of blocks needs to fall. It also occurs to me that I could simplify things even more by only checking NEW blank spaces. However, keeping track of this becomes a problem. Each block is represented by 1 nybble. The high bit of each nybble is used as a flag to indicate various states (ie: Falling, part of a group, to be deleted). Keeping track of two different states would be a problem. Nononono! Wait, it is possible! Falling blocks always have a colour table value of %001 to $111. Empty blocks always have a value of %000. So in this case I can differentiate between the two: High bit clear - ignore this block High bit set & lower 3 bits all clear = New empty space High bit set & lower 3 bits NOT all clear - Falling group Yeh, yeh, yeh! Sweet, I am so glad we had this talk! Course it means some pretty serious rewriting, but what the hell, right? Chris...
Attachment:
BLOCK.BIN
Description: Binary data
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [stella] Star Fire: Warping!!!, Manuel Polik | Thread | Re: [stella] Big Dig - update and m, Ruffin Bailey |
Re: [stella] Star Fire: Warping!!!, Manuel Polik | Date | Re: [stella] Big Dig - update and m, Ruffin Bailey |
Month |