'FADER by Stephan van Loendersloot 'Program is Public Domain. Use it! ' 'Written on 22-Jan-1995 at 03:10:05 ' 'PowerBASIC Update by Thomas Gohel on 29-Jan-1996 ' DECLARE SUB FadeIn (PBDelay!) DECLARE SUB FadeOut (PBDelay!) DIM Red(256) AS SHARED INTEGER DIM Green(256) AS SHARED INTEGER DIM Blue(256) AS SHARED INTEGER FILES "*.*" FadeOut (0) FadeIn (0) SUB FadeIn (PBDelay!) SHARED Red%() SHARED Green%() SHARED Blue%() FOR PalCol% = 0 TO 63 ' Maximum intensity can be 63 ' So we only have to loop 64 times FOR Col% = 0 TO 255 ' Do all colors OUT &H3C7, Col% ' Tell VGA port we'd like to read ' color Col% R% = INP(&H3C9) ' Read Red value G% = INP(&H3C9) ' Read Green value B% = INP(&H3C9) ' Read Blue value R% = R% + 1 ' Increase Red value G% = G% + 1 ' Increase Green value B% = B% + 1 ' Increase Blue value '*** Now check if the Red, Green and Blue values have reached *** '*** their original state. If they have passed it, then give *** '*** them their original state. *** IF R% > Red%(Col%) THEN R% = Red%(Col%) IF G% > Green%(Col%) THEN G% = Green%(Col%) IF B% > Blue%(Col%) THEN B% = Blue%(Col%) OUT &H3C8, Col% ' Tell VGA port we'd like to write ' color Col% OUT (&H3C9), R% ' Write Red value OUT (&H3C9), G% ' Write Green value OUT (&H3C9), B% ' Write Blue value NEXT Col% ' *** Here's the delay procedure for slower fades *** ' Begin! = TIMER DO: Elapsed! = TIMER - Begin! LOOP WHILE Elapsed < PBDelay! NEXT PalCol% END SUB SUB FadeOut (PBDelay!) SHARED Red%() SHARED Green%() SHARED Blue%() ' *** Store original values first *** ' FOR a% = 0 TO 255 ' Read all colors OUT &H3C7, a% ' Tell VGA port we'd like to read ' color a% Red%(a%) = INP(&H3C9) ' Read Red value Green%(a%) = INP(&H3C9) ' Read Green value Blue%(a%) = INP(&H3C9) ' Read Blue value NEXT a% ' *** And...start fading now! *** ' FOR PalCol% = 0 TO 63 ' Maximum intensity can be 63 ' So we only have to loop 64 times FOR Col% = 0 TO 255 ' Do all colors OUT &H3C7, Col% ' Tell VGA port we'd like to read ' color Col% R% = INP(&H3C9) ' Read Red G% = INP(&H3C9) ' Read Green B% = INP(&H3C9) ' Read Blue R% = R% - 1 ' Decrease Red value G% = G% - 1 ' Decrease Green value B% = B% - 1 ' Decrease Blue value IF R% < 0 THEN R% = 0 ' If Red is below 0 then make it 0 IF G% < 0 THEN G% = 0 ' If Green is below 0 then make it 0 IF B% < 0 THEN B% = 0 ' If Blue is below 0 then make it 0 OUT &H3C8, Col% ' Tell VGA port we'd like to write ' color Col% OUT &H3C9, R% ' Write Red value OUT &H3C9, G% ' Write Green value OUT &H3C9, B% ' Write Blue value NEXT Col% ' *** Here's the delay procedure for slower fades *** ' Begin! = TIMER DO: Elapsed! = TIMER - Begin! LOOP WHILE Elapsed < PBDelay! NEXT PalCol% END SUB