[comp.sys.mac.programmer] Fading the screen to black

Eric.J.Baumgartner@dartmouth.edu (Eric J. Baumgartner) (02/20/91)

Both the Fadeaway module of AfterDark and the shareware screen saver
Dimmer work by gradually fading the screen (more impressive on a color
screen) to black.  I thought this was kind of cool, until I tried it
with a RasterOps 364 in 24-bit mode running live video.  EVERYTHING
fades away, 24-bit color AND the running video!  Now I think this is a
very cool thing.

Anyone know how to do it?  My skills at reading assembly in Macsbug are
limited.  Does it just happen that modifying an 8-bit palette or clut
(the way I thought these guys worked) also works on a 24-bit monitor,
or do you have to fiddle with the gamma table of the video card...

Advice, source, comments accepted.  Send email and I'll summarize if
there's interest.

Eric Baumgartner                      Internet:  ebaum@dartmouth.edu
Interactive Media Lab                 Applelink: DARTMED
Dartmouth Medical School              -- This space for rent. -- 

lemke@radius.com (Steve Lemke) (02/27/91)

Eric.J.Baumgartner@dartmouth.edu (Eric J. Baumgartner) writes:

>Both the Fadeaway module of AfterDark and the shareware screen saver
>Dimmer work by gradually fading the screen (more impressive on a color
>screen) to black.  I thought this was kind of cool, until I tried it
>with a RasterOps 364 in 24-bit mode running live video.  EVERYTHING
>fades away, 24-bit color AND the running video!  Now I think this is a
>very cool thing.

Our Pivot Display does the same thing when you pivot the display from
portrait to landscape or vice versa - it fades out, redraws everything,
and fades back in again.

>Anyone know how to do it?  My skills at reading assembly in Macsbug are
>limited.

I don't think it would be too pleasant to try to figure it out in assembly.
I've seen the source for how we do it (in the video driver, which lives in
ROM on the display board), and, while the concept is fairly simple, it's
not necessarily a trivial task.

>Does it just happen that modifying an 8-bit palette or clut
>(the way I thought these guys worked) also works on a 24-bit monitor,
>or do you have to fiddle with the gamma table of the video card...

I'm not sure how it works for 24-bit, but I can tell say for the lesser
modes it's pretty straight forward, and I can imagine that the same code
would work for 4-bit as for 8-bit or 24-bit.

One thing to ask, however, just to protect myself from the User Interface
Police, is this:  Why do you want to do this?  Keep in mind that you should
have a good reason for fading the screen out on someone...  That said, let's
figure out how it's done:

Basically, you have three color lookup tables, one for each color (though
in grayscale, all three tables are the same).  Well, each table has 8-bits
of lookup information in it, and for your first increment of fade out, you
go through all three tables, decreasing each value in the table by some
constant.  Once this is done, you've faded some percent (your constant/255).
So, you increment your constant, and repeat (go through all three tables
again, decreasing each value by the now larger constant).  This assume that
each time you are reading a copy of the original table.  If you're reading
the existing table, it's not necessary to increment the constant.  Anyway,
repeat until your constant is 256, which essentially says that each value in
the lookup table points to black.

>Advice, source, comments accepted.  Send email and I'll summarize if
>there's interest.

Sorry I can't share source code with you, but Radius wouldn't appreciate it...

Have fun...

--Steve
-- 
----- Steve Lemke, KC6QDT - Software Engineering, Radius Inc., San Jose -----
----- Reply to: lemke@radius.com -- U.C. Santa Barbara ECE Class of '89 -----
----- "I'm not a UNIX wizard, but I play the Postmaster at radius.com." -----