BBS: Inland Empire Archive Date: 03-01-93 (00:42) Number: 389 From: MARK BUTLER Refer#: NONE To: MARK HARRIS Recvd: NO Subj: Transparent window shadow Conf: (2) Quik_Bas
Once upon a time Mark Harris uttered these sage words to Mark Butler:
MB> Exactly what troubles are you having with the transparent shadowing?
MH> The problem I'm facing is major ignorance. I don't
MH> understand what the POKEing is doing, exactly. And,
MH> really, it's not just the shadow; I want to restore
MH> everything behind the window, as well, to give it a smooth,
MH> sharp, professional look. To be honest, I haven't done
MH> much with it; let me play with it some more, and when I
MH> have more specific questions, I'll write to you and ask.
Ok, let's look at the shadow code...
SUB Shadow (Uprow, Ltcol, Lorow, Rtcol) STATIC
'First we'll want to get the correct text mode video segment
'which will be &HB800 if we're using CGA and up. If it's monochrome
'the segment would be &HB000 but there isn't a lot of point for a
'shadow on a monchrome monitor so if it is we'll just duck back out
'of the sub
DEF SEG = &H40
equip = PEEK(&H10)
IF (equip AND 48) = 48 THEN
EXIT SUB
ELSE
DEF SEG = &HB800
END IF
'*********************************************************
'****** find out what the screen attribute **************
'****** already is (underneath the box) ******************
'*********************************************************
'Now here we're using the screen function to get the color
'atrributes right off the screen for the areas we want to recolor to
'look like a shadow. This bit of code finds out if the character
'displayed at the location is a hi-color and changes it to the lower
'(non-hi) color. If you wanted to keep this simple you could skip all
'this and merely set attr%=8 which will give you a shadow that is
'in COLOR 8, 0 no matter what used to be there. This is just a bit
'fancier as it allows for different shadow colors.
attr = SCREEN(Lorow + 1, Rtcol + 1, -1) ' Obtain the color attribute
attr = attr AND 15 ' Calculate forground color.
attr = attr - 8 ' Remove bright from the color
IF attr < 1 THEN attr = 8 ' In case color wasn't bright
'*********************************************************
'****** use the given box dimensions to POKE a ***********
'****** "shadow" on the right side and bottom edge *******
'*********************************************************
'Now this part of the code uses a formula that John Strong (author of
'the EZWindow library) taught me to get a particular screen offset...
' offset=(row-1)*160+(Col-1)*2+1
'..(we've already set the segment above) and we just POKE a new color
'attribute at that location. The way I've set it up below these
'locations will be along the right edge and bottom of our window.
FOR row = Uprow + 1 TO Lorow + 1 '***** right edge locations. ***
FOR Col = Rtcol + 1 TO Rtcol + 2 '***** make it 2 chars wide. ***
offset = (row - 1) * 160 + (Col - 1) * 2 + 1
POKE offset, attr '<---we POKE the new color attr right here
NEXT
NEXT
row = Lorow + 1 '***** now POKE along the ******
FOR Col = Ltcol + 2 TO Rtcol + 2 '***** bottom edge *************
offset = (row - 1) * 160 + (Col - 1) * 2 + 1
POKE offset, attr '<---we POKE the new color attr here also
NEXT
DEF SEG '*** we're all done so we can return to BASIC's default seg
END SUB
Now to restore the screen to it's original state what you want to do is
to save the screen to an array that has been dimensioned large enough to
hold all elements of the text mode screen. Then when you want to cause
your window to "vanish" you move the contents of that array back to the
video segment again. I don't recall now if I provided for that in the
code you are playing with but I know I included "SaveScrn" and "RestScrn"
subs in the pulldown code I posted a little while back here. Take a look
at that code if you want to pop your windows on and off the screen with
a professional looking 'vanishing act' :-)
MH> On another topic, I posted a msg to a certain moderator
MH> after you did and also "areafixed" it....
Well, I don't feel very good about discussing that topic here even
though the person you mentioned rags on this conference quite often. I
have come to see that returning evil for evil is not quite right. It
really doesn't make anything better as Zack wisely pointed out to me the
other day regarding my strong distaste for the person who attempted to
hijack both of these conferences. When it comes down to it an echo is
the _property_ of it's moderator by Fido definition. And as such the
moderator has absolute license to run his/her conference in any manner
that suits their taste. So that means that the person in question was
technically correct in stating that his echo's participants are strictly
limited to only the "rights" that you and I chose to excercise with
regard to his conference (taking a hike that is).
Besides, I like it much better over here anyway. <grin>
תש [-M-H-B-] שת
--- timEd/B7 * Computer possessed? Use DEVICE = EXOR.SYS
* Origin: MotherShip Portholes, Portland OR (1:105/330.5)

Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET