Re: SCI1.1 Picture transition speeds?

Also, looking at this a bit more... I am pretty sure that the while loop in the fadeCode can be removed. It is in the doit method, but after the palette intensity has been changed. I would assume that this was intended to build in a bit more delay for a slower fade, but because of where it is, it is accomplishing nothing. I have done a bit of editing so that the while loop now does what I think it was supposed to be doing from the beginning

So First, I renamed the local variables per Phil's suggestion as well as included a new one which is going to be our delay time. The larger it is set, the slower the fade occurs.

Code: [Select]
(local
fCurrent
fTarget
fIncrement
fCallBack
fDelay
)

Then we have our fadeCode of Code instance.

Code: [Select]
(instance FadeCode of Code
(properties)
    (method (init param1 param2 param3 param4)
        = fCallBack 0
        = fDelay 10
        (if (>= paramTotal 1)
            = fIncrement param1
            (if (>= paramTotal 2)
                = fTarget param2
                (if (>= paramTotal 3)
                    = fCallBack param3
                    (if (>= paramTotal 4)
                    = fDelay param4
                    )
                )
            )
        )
        (send gTheDoits:add(self))
    )
    (method (doit)
    (var temp0)
       (while (< temp0 fDelay)
       ++temp0
       )   
       (if(== temp0 fDelay)
          (if (<> fCurrent fIncrement)
            = fCurrent (+ fCurrent (* 1 fTarget))
            Palette(palSET_INTENSITY 0 255 fCurrent)
            = temp0 0
          )
          (else
            (send gTheDoits:delete(self))
            (if (fCallBack and IsObject(fCallBack))
                (send fCallBack:cue())
                = fCallBack 0
            )
          )
   )// end if temp = fDelay
    )
)

To make use of it, heres an example of fading in and out.

Code: [Select]
//FadeIn
(FadeCode:init(100 1 self 10000))// fTarget   fIncrement   fCallBack   fDelay

//FadeOut
(FadeCode:init(0 -1 self 100)) // fTarget   fIncrement   fCallBack   fDelay

And there you go, a variable speed fading screen