/*
   Copyright:  Apple Computer, Inc. 1993-5
   author: Mike Engber

   UpInSmoke v3
   
   This function erases an area using a poof sound and dissipating
   smoke and then forces that portion of the screen to be refreshed.
   It takes one argument, a bounds frame in global coordinates.

   You may incorporate this sample code into your applications without
   restriction.  This sample code has been provided "AS IS" and the
   responsibility for its operation is 100% yours.  You are not permitted to
   modify and redistribute the source as "DTS Sample Code." If you are going
   to re-distribute the source, we require that you make it clear in the
   source that the code was descended from Apple-provided sample code, but
   that you've made changes.

 */

func(smokeBounds)
begin

  local top  := smokeBounds.top;
  local left := smokeBounds.left;

  local bm1 := Clone(ROM_cloud1);
  local bm2 := Clone(ROM_cloud2);
  local bm3 := Clone(ROM_cloud3);
  
  //CopyBits draw bitmaps scaled to their bounds
  bm1.bounds := bm2.bounds := bm3.bounds := smokeBounds;
 
  //explained below
  local danQuayle := BuildContext({viewClass:clView,viewFlags:vFloating,viewBounds:smokeBounds});

  PlaySound(ROM_poof);

  GetRoot():CopyBits(bm1,left,top,modeMask);
  Sleep(2);
  GetRoot():CopyBits(bm1,left,top,modeBic);

  GetRoot():CopyBits(bm2,left,top,modeMask);
  Sleep(2);
  GetRoot():CopyBits(bm2,left,top,modeBic);

  GetRoot():CopyBits(bm3,left,top,modeMask);
  Sleep(1);
  GetRoot():CopyBits(bm3,left,top,modeBic);

  //force an update (ala InvalRect in the Mac ToolBox)
  danQuayle:Open();
  danQuayle:Close();
  
  //If you knew what view(s) to dirty you could just use :Dirty()
  // to force the update. This code is general purpose, so it
  // doesn't know (and GetRoot():Dirty is way slow)

end
