/* 'Chase' engine
   Started by Chris Wilson 11/1/2000
*/

#include "global.h"
#include <islpsi.h>
#include <psitypes.h>

#include "bff_load.h"
#include "map_draw.h"

void chase_DrawFMA_World(FMA_WORLD *world)
{
#ifdef MAP_SCALE_ADJUST
	MATRIX temp;
#endif
	int i;
//	int removed_models;
	FMA_MESH_HEADER **mesh;
	mesh = ADD2POINTER(world,sizeof(FMA_WORLD));

#ifdef MAP_SCALE_ADJUST
	{
		temp = GsWSMATRIX;
		GsWSMATRIX.t[0] = GsWSMATRIX.t[0] << (MAP_SCALE_DEPTH_DOWN);
		GsWSMATRIX.t[1] = GsWSMATRIX.t[1] << (MAP_SCALE_DEPTH_DOWN);
		GsWSMATRIX.t[2] = GsWSMATRIX.t[2] << (MAP_SCALE_DEPTH_DOWN);
	}
#endif

//	printf("draw %d meshes\n",world->n_meshes);
//	removed_models=0;
	for(i = world->n_meshes; i != 0; i--, mesh++)
	{
// TBD - Do A clip-check on the mesh before calling
		MapDraw_SetMatrix(*mesh);

		if(MapDraw_ClipCheck(*mesh))
		{
#ifndef DREAMCAST
			MapDraw_DrawFMA_Mesh2(*mesh);
#endif
		}

//		else
//		{
//			removed_models++;
//		}

	}

// diagnostic message
//	if(removed_models)
//	{
//		printf("removed %d models\n",removed_models);
//	}

#ifdef MAP_SCALE_ADJUST
	{
		GsWSMATRIX = temp;

	}
#endif

}
