//
// Project UnReality: The First Nintendo 64 Emulator
// Copyright (C) 1997-1998, Cold Fusion Entertainment
// All rights reserved
//
// This source code is unpublished propietary information of Cold Fusion Entertainment.  No portion of this software
// may be disclosed to any third party or copied or duplicated in any form, in whole or in part, without the prior
// written consent of Cold Fusion Entertainment.
// 

//
// $Log: LFE.CPP $
// Revision 1.1  1998/03/08 19:09:51  unknown
// Initial revision
//

static char *rcsid = "$Id: LFE.CPP 1.1 1998/03/08 19:09:51 unknown Exp $";

//---------------------------------------------------------------------------------------------------------------------

#include <types.h>
#define NO_EXTERN_LFE
#include "lfe.h"
#include "lfe_data.h"

ulong osViSwapBuffer_addr;

int LFE_Scan(uchar *buf, ushort *data, ulong data_size, ulong buf_size)
{
	uchar *sptr;
	ushort *dptr;
	uint s;

	sptr = buf;
	dptr = data;

	for (s = 0; s < buf_size; s++)
	{
		if (*dptr == 0x0100)
		{
			dptr++;
		}
		else
		{
			if (buf[s] == (uchar)(*dptr))
			{
				dptr++;
				if ((dptr - data) >= data_size)
					return (s - data_size) + 1;
			}
			else
			{
				dptr = data;
			}
		}
	}

	return -1;
}
