[futurebasic] Re: [FB] gWorld #s-small bytes (bit manipulation)

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : April 2001 : Group Archive : Group : All Groups

From: "Peter Dempsey" <theviron@...>
Date: Mon, 16 Apr 2001 11:30:08 -0500
Well, it took me a while 2 respond 4 a # o (boring) reasons...
(sorry.... wanted to weed out as many stupid questions as possible, then 
gave up as thats impossible for me ;)

Switching 2 8 bit is a pain
While looking through the plethora of examples u mentioned, I realized 
another problem (undoubtebly everyone else thought it too obvious to 
mention... shows my lack of smartness ;-)

32 bit gworlds conviently have everything as exactly one byte... rgb & m.  
(32/4 = 8 wee)

However, 8/4 = 2 bits, so I need to cut that byte down (a pixel a byte... 
eek).  I found the bit section in the toolbox (bittst, bitclr, and bitset).  
However, I can't get em 2 work.

I tried this: r1 (red part) = FN BITTST(pixel1,0) + FN BITTST(pixel1,0) + FN 
BITTST(pixel1,1)

This should translate the two bits into a number, right? (I'd say stop me if 
I'm wrong, but I'm afraid it'll be a little late...)

But this didn't work, so I tried a much longer method (I figured that maybe 
BITTST returned something odd for its true/false values...):
long if fn bittst(pixel1,0)
long if fn bittst(pixel1,1)
r1 = 3
xelse
r1 = 2
end if
xelse
long if fn bittst(pixel1,1)
r1 = 1
xelse
r1 = 0
end if
end if

But still, this did not work.  It treated every part as both not 0 (black) 
and not the same (gray-white).  Also, when I tried color shade it ((r1/4) * 
(gTeamColors(team).r/16384)) and place that number (using partners of bitclr 
&/or bitset) it wouldn't place anything.

So, anybody know how to pick apart a byte?  I'm obviously doing something 
wrong...

Thanks 2 all
pd

*btw, if I am right (or even if I am wrong) then below might be important... 
I can't figure out if I have the rowbytes right, but I think I do

>From: Robert Covington <artlythere@...>
>Reply-To: futurebasic@...
>To: futurebasic@...
>Subject: Re: [FB] gWorld #s
>Date: Sat, 14 Apr 2001 23:59:56 -0500
>
>
><snips>
> >I think this line is the culprit:
> >myRowBytes1 = pmHandle1..RowBytes AND 0x3FFF
>
> >I would guess that 0x3FF (3 15 15 15, right?) needs to be changed to
> >something else for 8 bit...
>
>I just did a search through all the FB 3 Examples...seems there are 19
>different ways used to get rowbytes.  There is the
>theworld.portbits.rowbytes, the mask approach above, so many others.

I looked through a few (and almost understood em! ;-)
I tried the gWorld.portbits.rowbytes shown above.
The pictures vanished.
I tried a number I found in one example (like &73FFE or something)
The pictures vanished.
So, might some1 happen 2 know if I am supposed to use a different number 4 
different color depths of gWorlds?
>
> >One other possible spot of error (which I think I guess-corrected 
>rightly):
> >
> >Pixel1 = baseAddr1 + (yy * myRowBytes1) + (xx)
> >
> >Originally, it was:
> >Pixel1 = baseAddr1 + (yy * myRowBytes1) + (xx * 4)
>
><snip>
>
>I mentioned that to you a while back I think. :)

No doubt... My sense of time is very distorted... prolly went in one ea.. 
eye ...

neway, thnks 4 tellin me then & reasurin' me now
>
> >If you are really curious, or think I'm just a blundering newbie (true
> >true...) then here's the full [faulty] function: (I checked  a normal
> >drawing routine and it worked fine)
> >
> >//100% inspired & 99% written by Covington
>
>I don't think I can (would?) claim 99% of that...50% maybe.
but you could & should! ;-)
>
>I only know enough to be dangerous, and I spout what little I know like a
>flamethrower. ;)
>rc
Burn baby burn!

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com