/***************************************************************************
 *
 *   NAME 
 *      LoadIFF -- call an IFF single frame from disk
 *
 *   SYNOPSIS
 *      LoadIFF( frame, bitmap, viewport );
 * 
 *      WORD frame;
 *      struct BitMap *bitmap;
 *      struct ViewPort *viewport;
 *
 *   DESCRIPTION
 *      To recall an animation HAM screen that has been saved to disk
 *      under a subdirectory created with the name of the choreography,
 *      this program calls each file with a name that is the number of
 *      the frame.
 *
 *       copyright (c) 1987 Martin D. Hash
 *
 *   LAST EDITED
 *      Martin Hash			11 Aug 1987
 *
 *   EDIT HISTORY
 *      19 Dec 1986  MH  Created.
 *      21 Mar 1987      Converted to real-time audition.
 *
 **********************************************************************/

#include <exec/types.h>
#include <intuition/intuition.h>
#include <libraries/dos.h>
#include <libraries/dosextens.h>
#include "df1:ilbm.h"
#include "df1:FileCons.h"

/* EXTERNAL VARIABLES */

extern char animpathname[];

/* EXTERNAL FUNCTIONS */

struct FileLock *Lock();
BOOL UserRequest();

/* FUNCTION */

void LoadIFF( frame, bitmap, viewport )

WORD frame;
struct BitMap *bitmap;
struct ViewPort *viewport;
{
   /* LOCAL VARIABLES */

   BPTR file;
   struct FileLock *lock;
   char name[STRINGSIZE],
        text[MAXNUMBERTEXT];

   /* FUNCTION */

   strcpy( name, animpathname );
   stci_d( text, (int)frame, sizeof(text));
   strcat( name, text );

   if ((lock = Lock( name, ACCESS_READ )) != 0) {
      file = Open( name, MODE_OLDFILE );
      UnLock( lock );

      ReadPicture( file, bitmap, viewport );

      Close( file );
   }
}
