Jump to content
IGNORED

IntyBASIC and SCREEN with Color Stack Pattern?


First Spear

Recommended Posts

I created a ColorStack graphic area with two red shapes, one "hollow" and one solid. The stack is Black-Red-Black-Red. Then added some random "#" in places. Then used the SCREEN statement to plot a solid box on top of the "hollow" box.

 

When the solid box is added, the background color changes in random positions on the screen, apparently after every BACKTAB position after the new box plot, which is not what I want.

 

My understanding is that the stack needs to advance, but I don't understand what kind of rule I need to follow to make this happen so the rest of the screen is not upset when I add the new solid box.

 

post-31694-0-50735400-1550588764.gif

 

I have a larger program where I do a lot of graphic region changing using SCREEN, so I am looking for a good working pattern. I got a clue that adding an extra $2000 somewhere to the new image will help but am not sure about that.

 

Thanks.

 

 

Image with a grid to illustrate where things are:

post-31694-0-58057100-1550587207.jpg

 

Image:

post-31694-0-67538800-1550587177.jpg

 

Added solid image:

post-31694-0-20102700-1550587227.jpg

 

 

The Code:

 

 

INCLUDE "constants.bas"
MODE 0,0,2,0,2
Wait
DEFINE 0,6,ztk0_bitmaps_0
Wait

WorkIt:
For #waitMe=0 to 65 : Wait : Next #waitMe
CLS
SCREEN ztk0_cards
For #waitMe=0 to 59 : Wait : Next #waitMe
Wait
For #showMe = 0 to 5
#theSpot = Random(239)
Print At #theSpot Color CS_WHITE , "#"
Next #showMe
For #waitMe=0 to 65 : Wait : Next #waitMe
DEFINE 20,2,ztk1_bitmaps_0
Wait
SCREEN ztk1_cards,0,40,6,4,6
For #waitMe=0 to 265 : Wait : Next #waitMe
Goto WorkIt

' 6 bitmaps
ztk0_bitmaps_0:
BITMAP "11111111"
BITMAP "11111111"
BITMAP "11111111"
BITMAP "11111111"
BITMAP "11111111"
BITMAP "11111111"
BITMAP "11111111"
BITMAP "11111111"

BITMAP "00000000"
BITMAP "00000000"
BITMAP "00000000"
BITMAP "00000000"
BITMAP "00000000"
BITMAP "11111111"
BITMAP "11111111"
BITMAP "00000000"

BITMAP "00000000"
BITMAP "00000000"
BITMAP "00000000"
BITMAP "00000000"
BITMAP "00000000"
BITMAP "11111111"
BITMAP "11111111"
BITMAP "00000011"

BITMAP "00000011"
BITMAP "00000011"
BITMAP "00000011"
BITMAP "00000011"
BITMAP "00000011"
BITMAP "00000011"
BITMAP "00000011"
BITMAP "00000011"

BITMAP "00000000"
BITMAP "00000000"
BITMAP "00000000"
BITMAP "11111111"
BITMAP "11111111"
BITMAP "00000000"
BITMAP "00000000"
BITMAP "00000000"

BITMAP "00000011"
BITMAP "00000011"
BITMAP "00000011"
BITMAP "11111111"
BITMAP "11111111"
BITMAP "00000000"
BITMAP "00000000"
BITMAP "00000000"


REM 20x12 cards
ztk0_cards:
DATA $0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800
DATA $0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800
DATA $080A,$080A,$080A,$080A,$080A,$0812,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800
DATA $0800,$0800,$0800,$0800,$0800,$081A,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800
DATA $0800,$0800,$0800,$0800,$0800,$081A,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800
DATA $0822,$0822,$0822,$0822,$0822,$082A,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800
DATA $0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800
DATA $0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$2000,$0802,$0802
DATA $2000,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$2000,$0802,$0802
DATA $2000,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$2000,$0802,$0802
DATA $2000,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800
DATA $0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800,$0800


ztk1_bitmaps_0:
BITMAP "00000000"
BITMAP "00000000"
BITMAP "00000000"
BITMAP "00000000"
BITMAP "00000000"
BITMAP "11111111"
BITMAP "11111111"
BITMAP "11111111"

BITMAP "11111111"
BITMAP "11111111"
BITMAP "11111111"
BITMAP "11111111"
BITMAP "11111111"
BITMAP "11111111"
BITMAP "11111111"
BITMAP "11111111"


REM 6x4 cards
ztk1_cards:
DATA $08A2,$08A2,$08A2,$08A2,$08A2,$08A2
DATA $2000,$08AA,$08AA,$08AA,$08AA,$08AA
DATA $08AA,$08AA,$08AA,$08AA,$08AA,$08AA
DATA $08A0,$08A0,$08A0,$08A0,$08A0,$08A0

 

 

 

Link to comment
Share on other sites

The Color Stack "Advance Flag" will advance the stack to the next color and use it to paint the background of all subsequent cards, starting from the one where the flag is set, until the end of the BACKTAB or the next card that has the flag set.

 

This means that if you want to paint a rectangular block with an alternate background color, you need to set the "Advance flag" on the leftmost card of each row, and set it again on the right most.

 

Remember, the Color Stack "paints" cards from top to bottom, left to right, in order of card address.

 

You set the flag by adding $2000 to the BACKTAB word. At a glance, it looks to me that you are setting the "Advance Flag" once at the top left of the rectangle. The end result is that all cards to the right and below of that point will be painted with the new background color.

 

The reason you see the red color at "random" places, is because you have you are using a black foreground color to "cover" the other cards.

 

Here's a brief explanation of the color stack I wrote in another thread:

Imagine an array of four colours. Now consider an imaginary cursor moving across the background, from the top-left corner, all the way to the right edge, then over to the next row, and so on. As the cursor moves, it will "paint" the background of the card using the first colour in the array. It will continue painting cards the same colour until it finds a card that has the "Advance" bit set, at which point, it will start using the next colour in the array.

Now, the cursor is painting the rest of the background, row by row, with the second colour of the array until it finds another card with the "Advance" bit, which will cause it to switch to the third colour in the array. And on it goes advancing the background colour array (the "Color Stack") every time it finds a card with the "Advance" bit on. If it reaches the fourth colour, it will cycle back to the first again.

 

I hope this helps.

 

-dZ.

  • Like 1
Link to comment
Share on other sites

Aha.... Before and after... There was this joker First Spear that asked a question you answered at http://atariage.com/forums/topic/277143-intybasic-place-different-color-stack-images/?p=4000503, makes more sense now.

 

So painting a solid red box of solid tiles from tiles 40-45,60-65,80-85,100-105 means advancing the stack at tiles 39,59,79,99 and again at 45,65,85,105.

Is there a smart way code the stack advance instruction so all of the SCREEN'd graphics don't need modification?

 

Thanks.

 

 

The Color Stack "Advance Flag" will advance the stack to the next color and use it to paint the background of all subsequent cards, starting from the one where the flag is set, until the end of the BACKTAB or the next card that has the flag set.

 

This means that if you want to paint a rectangular block with an alternate background color, you need to set the "Advance flag" on the leftmost card of each row, and set it again on the right most.

 

Remember, the Color Stack "paints" cards from top to bottom, left to right, in order of card address.

 

You set the flag by adding $2000 to the BACKTAB word. At a glance, it looks to me that you are setting the "Advance Flag" once at the top left of the rectangle. The end result is that all cards to the right and below of that point will be painted with the new background color.

 

The reason you see the red color at "random" places, is because you have you are using a black foreground color to "cover" the other cards.

 

Here's a brief explanation of the color stack I wrote in another thread:

 

I hope this helps.

 

-dZ.

 

Link to comment
Share on other sites

Aha.... Before and after... There was this joker First Spear that asked a question you answered at http://atariage.com/forums/topic/277143-intybasic-place-different-color-stack-images/?p=4000503, makes more sense now.

 

LOL! You know, I looked up that post to provide the link, but didn't notice it was a reply to you. :P

 

So painting a solid red box of solid tiles from tiles 40-45,60-65,80-85,100-105 means advancing the stack at tiles 39,59,79,99 and again at 45,65,85,105.

 

Er ... actually, you need to advance the flag on the card where the rectangle starts and on the card after. That is, at 40 and 46, 60 and 66, 80 and 86, and 100 and 106.

 

The flag says "change color on this card," so that very same card will use the new color. That's why you set the flag on the first card you want to use the new color, and when you're done, on the first card you want to use the next color.

 

Does that make sense?

 

So painting a solid red box of solid tiles from tiles 40-45,60-65,80-85,100-105 means advancing the stack at tiles 39,59,79,99 and again at 45,65,85,105.

Is there a smart way code the stack advance instruction so all of the SCREEN'd graphics don't need modification?

 

Thanks.

 

Well, you don't need to paint the cards in the middle. SCREEN is not really conducive to that. Perhaps you should just POKE the cards on the edge columns. *shrug*

 

-dZ.

  • Like 1
Link to comment
Share on other sites

I'll be honest, as much as I love the Color Stack for its flexibility, it is really a weird mode. Nobody has yet come up with a high-level intuitive model to use that could make something like SCREEN utilize it automatically. The closest I have in my own framework is to treat the "advance flag" as part of the color information of a card, rather than something separate.

 

In my own mental model, I think of the Color Stack background colors as "flood fill." That is, when I set the advance flag on a card, it will start painting all cards to the right and below, in sequence, until the flood is contained by another advance flag.

 

-dZ.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...