/**********************************************************************

	Title :			Future Types Header File
	Filename :		ftypes.h
	Author :		Thomas Szirtes
	Revision :		1.0

	Notes :			Contains all base types and definitions for future
					city application

	Copyright :		(C) SEGA Europe 1998

  **********************************************************************/

#ifndef _FTYPES_H_INC
#define _FTYPES_H_INC


/*
 *		COMPILER SWITCHES	
 */
/*   Going to compile for set4 */
#define              USING_SET4

#ifdef USING_SET4
/*#define                              SOUND_ENABLE	*/
#endif


/*
 *		INCLUDES
 */

#ifdef USING_SET4
 #include        <shinobi.h>
#else
 #include        <ninja.h>
#endif


/*
 *	System Settings Definitions
 */
#define MAP_SIZE                        128
#define GRID_SIZE                       128
#define MAX_BUILDINGS		            18
#define MAX_INSTANCE				    512
#define PERIPHERAL_SCALE                100.f
#define BUILDING_ID_SMOKE               17
#define NO_SHIP_ID						0xff

/*
 *		MACROS
 */

#define ARGB(a,r,g,b)   (a<<24)|(r<<16)|(g<<8)|(b)
#define UV(v, u)        (((((long)(u))<<16)&0xffff0000)|((long)(v))& 0x0000ffff)
#define P2GRID(x)       (int)((x)/GRID_SIZE)
#define GRID2P(x)       ((x)*GRID_SIZE)


/*
 *		STRUCTURE DEFINITIONS
 */
typedef struct
{
	Sint16  move_backward_forward;
	Sint16  strafe_left_right;
	Sint16  strafe_up_down;

	Sint16  roll_left_right;
	Sint16  pitch_up_down;
	Sint16  yaw_left_right;

	Sint16  fire;
	Sint16  open;

	Bool    something_done;

} PERIPH_DATA;

typedef struct {
	Uint8   i;                                                      /* i axis grid position */
	Uint8   j;                                                      /* j axis grid position */
	Sint16  h;                                                      /* height */
} GRIDPOS;

#include        "collide.h"
#include        "particle.h"
#include        "lights.h"
#include        "ship.h"



/*--------- MAP DATA ITEM ----------*/

typedef struct
{
	Uint16  inst;                           /* instance number */
	Uint8   gnd;                            /* height of ground */
	Uint8   ship;                           /* ship index currently support 255 ships - can increase*/
} MAPITEM;


typedef struct
{
	Uint8                           id;                             /* building id */
	Uint8                           flag;
	Uint8                           i,j;                            /* grid coordinates */
	Uint16                          lbdlightinst;
	Uint16                          particleinst;
} BUILDING_INSTANCE;


/* FLAG BITS 
 *      0               DRAW FLAG r/w 
 *      1                
 *      2 
 *      3 
 *      4-5             ORIENTATION ro 
 *		6 
 *		7		        USED FLAG       ro 
 */

#define INST_FLAG_DRAWN                 0x01
#define INST_FLAG_USED                  0x80
#define INST_FLAG_ORIENT0               0x00
#define INST_FLAG_ORIENT1               0x10
#define INST_FLAG_ORIENT2               0x20
#define INST_FLAG_ORIENT3               0x30
#define INST_FLAG_ORIENT_MASK   (INST_FLAG_ORIENT0|INST_FLAG_ORIENT1|INST_FLAG_ORIENT2|INST_FLAG_ORIENT3)




/* Map Structure */
typedef struct
{
	Uint16  size_i;                         /* grid size in i axis */
	Uint16  size_j;                         /* grid size in j axis */
	MAPITEM map[MAP_SIZE][MAP_SIZE];
} MAP;


/* Display Information Table */
typedef struct {
	NJS_OBJECT                      *loobj;                 /* root object of building */
	NJS_TEXLIST                     *lotex;                 /* texture of building */
	NJS_OBJECT                      *lightobj;              /* optional object containing lights */
	LIGHTTEMPLATE                   *lighttemplate;         /* template for flashing lights */
	void                            *shadow;                /* shadowing info */
	COLLIDE_OBJ                     *collide;               /* collide template */
	PSYSTEM                         *particletemplate;      /* if any associated particles */
} BUILDING;


/*
 *		EXTERNAL DECLARATIONS - GLOBAL VARIABLES
 */
extern  MAP						map;
extern  BUILDING                buildings[];
extern  NJS_TEXLIST				misc_texlist;


#endif
