[Coco] Re: Coco Digest, Vol 17, Issue 53

Andrew keeper63 at cox.net
Wed Feb 23 12:03:59 EST 2005


> Message: 1
> Date: Wed, 23 Feb 2005 08:06:32 +1100
> From: Mark McDougall <msmcdoug at optushome.com.au>
> Subject: Re: [Coco] help with drawing
> To: CoCoList for Color Computer Enthusiasts <coco at maltedmedia.com>
> Message-ID: <421B9ED8.4070401 at optushome.com.au>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> 
> Andrew wrote:
> 
> 
>>Something that I have been trying to do on occasion is HGET/HPUT sprite 
>>masking - but it is like the boolean operators don't work correctly for 
>>the mask. I should be able to make a black and white mask of the sprite,
>> lay the mask down with HPUT via an AND, then lay the sprite down via an
>> OR - but it has yet to never work - anybody know what I am doing wrong,
>> or what I am wrongly assumming?
> 
> 
> What are the symptoms?

To be honest, it has been a while since I last played with it - but 
basically, what I was trying was something akin to the following 
(forgive me if this isn't proper code - like I said, its been a while):

10 HBUFF 1, 200: HBUFF 2, 200
20 HSCREEN 2: HCLS 0: PALETTE RGB
30 REM DRAW SPRITE
40 HCIRCLE(10, 10), 5, 4
50 HPAINT(10, 10), 4, 4
60 HGET(0, 0)-(20, 20), 1
70 HCLS 0
80 REM DRAW SPRITE MASK
100 HLINE(0, 0)-(20, 20), 15, BF
110 HCIRCLE(10, 10), 5, 0
120 HPAINT(10, 10), 0, 0
130 HGET(0, 0)-(20, 20), 2
140 HCLS 0
150 REM DRAW TEST BACKGROUND OF LINES
160 FOR X = 0 TO 319 STEP 5
170 HLINE(X, 0)-(X, 199), 7
180 NEXT X
190 REM USE MASK TO "PUNCH" HOLE IN BACKGROUND VIA BITWISE "AND"
200 HPUT(115, 100), 1, AND
210 REM PLACE SPRITE OVER HOLE USING BITWISE "OR"
220 HPUT(115, 100), 2, OR
230 GOTO 230

The "AND"ing of the mask with the background should punch a hole by 
ANDing white (0xF) with any background color, leaving the background 
color values (ie, 0xF AND 0x? = 0x?), and black (0x0 - the hole) with 
the background, making any background color value black (ie, 0x0 AND 0x? 
= 0x0).

Then, "OR"ing the sprite should seamlessly overlay the sprite into the 
image, so you don't have the "black" border around the sprite. However, 
it doesn't work (I can't remember what happens, but it isn't what is 
expected).

Actually, the above code probably doesn't work as expected anyhow - it 
has been so long since I have really coded graphics in SECB that the 
above is likely broken. I am just looking for a working example of a 
real sprite routine in SECB, something I have never seen on a CoCo.

Of course, this is only half of the problem to a real game - you still 
need to be able to do this on a background (hidden) screen, then flip it 
forward to the visible screen so that flicker is avoided, but you get 
the idea...

Andrew



More information about the Coco mailing list