[comp.sys.apple] Apple IIgs SHR fade

daemon@bloom-beacon.MIT.EDU (Mr Background) (05/17/89)

From: mhamaoka@athena.mit.edu (Michael T Hamaoka)
Path: athena.mit.edu!mhamaoka

Hi,

   I was playing around a little with my IIgs and assembly
and was wondering if there is a way to fade a screen in (from
black to full screen) then back to black (with fading speed
control) from ProDOS 8.  Ideally, what I would like is a
program that I could run from BASIC.SYSTEM that would load a
$C1 type screen, fade it in, wait for a keypress and fade it
out.

   Could anyone give me hints or tell me where I could find
source code to try to learn how to do this?  I know 6502
assembly.  I just need to know where I could find methods to
load, display, and modify the palatte of an SHR screen without
actually being in GSOS.

   Thanks in advance.


  --> Mike Hamaoka
      (mhamaoka@athena.mit.edu)

farrier@Apple.COM (Cary Farrier) (05/17/89)

In article <11472@bloom-beacon.MIT.EDU> mhamaoka@athena.mit.edu (Michael T Hamaoka) writes:
> [stuff about fading a SHR screen deleted]

	You should probably get access to the Apple IIGS Hardware Reference 
	(This one *is* published by Addison Wesley, ISBN 0-201-17743-9), and
	start reading on page 84, Super Hi-Res graphics.  It will tell you
	all you need to know about how SHR mode operates.

	About the fading, try this algorithm to fade to black:

	for(loop = 0 to 15)
	{
		for (each color entry in the palette)
		{
			if(red_value - 1 > 0 )
				decrement the red value;
			if(green_value - 1 > 0 )
				decrement the green value;
			if(blue_value - 1 > 0 )
				decrement the blue value;
		}		
	}

	This loop will decrement the RGB values of each color register
	to zero, thus fading to black.  This is not the best algorithm,
	a better one would be one that would examine all the entries
	in the color palette and then figure out the amount to decrement
	each to produce an even fade simultaneously.

	To fade in, simply reverse the process, incrementing each
	RGB gun until it reaches it's maximum value for the color
	desired.

Cary Farrier

blochowi@cat28.CS.WISC.EDU (Jason Blochowiak) (05/18/89)

	Ugh! I hate that fade... I have some code (which I offered to the
person who originally asked) which will do a real nice fade. Are there enough
people out there interested to bother to post it to comp.binaries.apple2? I
don't care about people using my code, just so I can avoid seeing the color
distortion introduced by the simple fade. As might be obvious by now, this is
a pet peeve of mine.
 ------------------------------------------------------------------------------
		Jason Blochowiak (blochowi@garfield.cs.wisc.edu)
			"Not your average iconoclast..."
 ------------------------------------------------------------------------------

JWANKERL@UTCVM.BITNET ("Josef W. Wankerl") (05/19/89)

On Thu, 18 May 89 16:56:46 GMT Jason Blochowiak said:
>
>    Ugh! I hate that fade... I have some code (which I offered to the
>person who originally asked) which will do a real nice fade. Are there enough
>people out there interested to bother to post it to comp.binaries.apple2? I
>don't care about people using my code, just so I can avoid seeing the color
>distortion introduced by the simple fade. As might be obvious by now, this is
>a pet peeve of mine.
> ------------------------------------------------------------------------------
>        Jason Blochowiak (blochowi@garfield.cs.wisc.edu)
>            "Not your average iconoclast..."
> ------------------------------------------------------------------------------

Yes, I am indeed interested... but how about to Apple2-L since
I can't FTP.

-Gonzo

/**********************************************************************\
|*  Joe "Gonzo" Wankerl          |*|                                  *|
|*                               |*|   The views expressed here are   *|
|* BitNet =>  JWANKERL@UTCVM     |*|   not necessarily yours...       *|
|*                               |*|   ...but they should be.         *|
\**********************************************************************/

dseah@wpi.wpi.edu (David I Seah) (05/19/89)

In article <2808@puff.cs.wisc.edu> blochowi@cat28.CS.WISC.EDU (Jason Blochowiak) writes:
>	Ugh! I hate that fade... I have some code (which I offered to the
>person who originally asked) which will do a real nice fade. Are there enough
>people out there interested to bother to post it to comp.binaries.apple2? I
>don't care about people using my code, just so I can avoid seeing the color
>distortion introduced by the simple fade. As might be obvious by now, this is
>a pet peeve of mine.

I was wondering if that algorithm would cause color distortion myself.  Would
you have to lower each one of red,green, and blue color components
proportionally so that they all zeroed out at the same time?

In a word, please post it! :)

Dave Seah (dseah@wpi.wpi.edu)

blochowi@cat28.CS.WISC.EDU (Jason Blochowiak) (05/19/89)

In article <8905181632.aa12051@SMOKE.BRL.MIL> JWANKERL@UTCVM.BITNET ("Josef W. Wankerl") writes:
>> [I wrote]
>> How I offered my SHR fade code
>Yes, I am indeed interested... but how about to Apple2-L since I can't FTP.
	Ok, there were enough replies (not overwhelming, but it seems that the
number of letters I get is a certain proportion of actual interest), so I will
post to comp.binaries.apple2, which, as I understand it, gets cross-posted to
whatever else there is out there (it's a newsgroup, not an FTP site). What I
will post is the Orca //gs (or APW - I can't remember) assembly source, perhaps
with some code hacked on to it to load a pic & fade it in. Please remember,
though, that my last final for this semester was today, and I plan to go out
and seriously damage my brain RSN, so it might be a little while before it
gets posted, so be patient.
>-Gonzo
 ------------------------------------------------------------------------------
		Jason Blochowiak (blochowi@garfield.cs.wisc.edu)
			"Not your average iconoclast..."
 ------------------------------------------------------------------------------

brianw@microsoft.UUCP (Brian Willoughby) (05/22/89)

In article <2335@wpi.wpi.edu> dseah@wpi.wpi.edu (David I Seah) writes:
>I was wondering if that algorithm would cause color distortion myself.  Would
>you have to lower each one of red,green, and blue color components
>proportionally so that they all zeroed out at the same time?
>
>In a word, please post it! :)
>
>Dave Seah (dseah@wpi.wpi.edu)

Here is an idea for a fade algorithm that should be fairly simple:
Seems like you could look at the pallette color register that you want to
reduce, and then choose the component with the lowest value. Then
multiply each of the RGB components by a fraction which would effectively
decrement the smallest component. For example. if R=100, B=78 and G=90,
then multiply each component by 77/78. Of course, since I don't have a GS,
I can't predict how much rounding error would mess up this approach.

Perhaps someone could send me a II GS, and I could try it out?

Brian Willoughby                        ...!uw-beaver!microsoft!brianw
                or                      microsoft!brianw@uunet.UU.NET
                or just                 brianw@microsoft.UUCP

orcus@pro-lep.cts.com (Brian Greenstone) (05/23/89)

Network Comment: to #3818 by pnet01!crash!uunet.uu.net!microsoft!brianw

It seems like most of the suggestions for doing fades are more complicated
than they should be.  This is how I do my SHR fades:
1] Read each color value out of each palatte.
2] Break the color $0xyz into its three values x y & z
3] Decrement each value until it is 0.
4] Recombine each value back into the $0xyz format.
5] Put back into the palatte.
6] Loop until all colors have been done.
7] Loop 16 times to be sure that all colors have faded completely to black.

That's how I do it, and it works evenly and smoothly.