Board index » delphi » Combining the contents of arrays

Combining the contents of arrays

I hope the subject isn't misleading, I couldn't word it in that short of
space.   This is my problem.  I want to use a mouse cursor in my program
(game) but I can't easily since the unit I'm using (ANIVGA) uses a
tweaked VGA mode with 4 pages, and when I try any conventional mouse
cursors (built-in), it goes nuts.  So I decided I would make a cursor and
just "put" it wherver it's supposed to be on the screen.

Here's my problem.  The cursor has "black" spots and I can'tfigure out
how to put it so that the black spots are invisible (transparent).  This
is what I want to do.  I want to get an area the size of the cursor (box)
and, with the cursor, take the respective pixels in the area which I
"got" and fill in the black of the cursor.  In case you still aren'ty
following me, I'll give a visual aid.  

Let's say we have two arrays--    0000000000000004030070888807006543
                      and         7777777777777777777777777777777777
          What I would want is    7777777777777774737777888877776543

See how the 7s are visible through the 0s?  Strange example, I know.  But
that's what I want.  I tried fiddling around with the mem command but I
got scared and ran away (I'm not really using arrays, just blocks of
memory.  Were is arrays it would be a HELL of a lot easier. Although I
could try moving it from the normal memory to an array, but I'm not sure
how I'd go around doing that)

Any help wuld be appreciated.  Oh and swap procedures, those would be
nice to.  I haven't checked the swag files available on the big ftp
sites.  Would there be swap procedures/fns in there?  Assembler of
course, I could write my own in pascal if I wanted to, but I doubt they
would be as fast. Would they?  Oh yeah I almost forgot I'm using TP7.

--
                                                            ___    ______
************************************************************\  \**/  _   \***
   Jean-Paul Deveaux        aa...@ccn.cs.dal.ca            __\  \_\__\_\  \
==========================================================/  _\  \________/==
            "French toast, please."                       \  \_\  \ \  \
***********************************************************\______/**\__\****

 

Re:Combining the contents of arrays


Quote
Jean-Paul Deveaux wrote:

[snip]
Quote

> Let's say we have two arrays--    0000000000000004030070888807006543
>                       and         7777777777777777777777777777777777
>           What I would want is    7777777777777774737777888877776543

[snip]

If I'm understanding you rightly...
One method freqently used (although it doesn't give the exact result
you want) is to bitwise XOR the background and the mask (in this case your
pointer).  When the mask is moved repeat the XOR and the background
returns to it's original colour.  This also means the pointer will change
colours as it moves over different coloured areas, which looks pretty
cool.

So what you'd gett in your example is:
        array 1 - 0000000000000004030070888807006543  (the background)
        array 2 - 7777777777777777777777777777777777  (the mask or mouse pointer)
        result  - 7777777777777773747707FFFF70771234  (i.e., array1 XOR array2)

And to get back to the original background colours (i.e., when
your mouse cursor moves) you simply do result XOR array2:
        array 2 - 7777777777777777777777777777777777  (the mask or mouse pointer)
        result  - 7777777777777773747707FFFF70771234  (i.e., array1 XOR array2)
        result2 - 0000000000000004030070888807006543  (the original background)

Hope that helps.  Drop me a line if you need more info.

ChrisR:

Other Threads