graphics.h 9.13 KB
/********************************************************************************
	graphics.h: NINTENDO64 DD Disk Drive IPL4 header.

	December 25, 1986
 ********************************************************************************/

#ifndef GRAPHICS_H
#define	GRAPHICS_H

#include "mathfunc.h"


typedef	char *	MemPtr;
typedef Gfx	*	GfxPtr;
typedef Mtx *	MtxPtr;

#define	RGBA16(r,g,b,a)		(((r)<<11) | ((g)<< 6) | ((b)<<1) | (a))

/********************************************************************************/
/*																				*/
/*																				*/
/*	N-Cube control record														*/
/*																				*/
/*																				*/
/********************************************************************************/

typedef struct {
		short		type;				/* drawing type							*/
		short		flag;				/* flag									*/
		ushort *	texture1;			/* number of texture 1 					*/
		ushort *	texture2;			/* number of texture 2					*/
		FVector		scaling;			/* shape scale (x,y,z)					*/
		FVector		position;			/* shape position (x,y,z)				*/
		FVector		velocity;			/* shape moving velocity (x,y,z)		*/
		SVector		angle;				/* shape angle (x,y,z)					*/
		SVector		angvelo;			/* shape angle velocity (x,y,z)			*/
		RGBAColor	color;				/* effect color (r,g,b,a)				*/
} CtrlNCube;

#define	NCUBE_TYPE_COLOR			0
#define	NCUBE_TYPE_COLCOMBINE		1
#define	NCUBE_TYPE_TXTCOMBINE		2
#define	NCUBE_TYPE_TXTOVERLAP		3
#define	NCUBE_TYPE_BUMPMAP			4

#define	NCUBE_FLAG_NORMAL		(1<<0)
#define	NCUBE_FLAG_MIRROR		(1<<1)

#define	NCUBE_DRAW_NORMAL		0
#define	NCUBE_DRAW_MIRROR		1

extern void DisplayNCube(CtrlNCube *ncube);


/********************************************************************************/
/*																				*/
/*																				*/
/*	Leaf control record															*/
/*																				*/
/*																				*/
/********************************************************************************/

typedef struct {
	short		flag;					/* flag									*/
	short		shake;					/* shake parameter						*/
	SVector		angle;					/* leaf angle (x,y,z)					*/
	SVector		angvelo;				/* leaf angle velocity					*/

	FVector		position;				/* leaf position (x,y,z)				*/
	FVector		scaling;				/* leaf scale (x,y,z)					*/
	float		moving;					/* leaf moving speed					*/
	float		falling;				/* leaf falling speed					*/
} CtrlLeaf;

#define	LEAF_DRAW_NORMAL	0
#define	LEAF_DRAW_MIRROR	1

extern void InitLeaf(void);
extern void DrawLeaf(void);
extern void MakeLeaf(FVector *position);
extern void BlowLeaf(FVector *center);


/********************************************************************************/
/*																				*/
/*																				*/
/*	Skeleton shape control records												*/
/*																				*/
/*																				*/
/********************************************************************************/

#define	HMS_ANIM_NORMAL			(1<<0)
#define	HMS_ANIM_ONETIME		(1<<1)

typedef struct AnimeData {
	short		attr;					/* attribute							*/
	short		waist;					/* height base							*/
	short		start;					/* start frame number					*/
	short		loop;					/* loop frame number					*/
	short		nframes;				/* number of frames						*/
	short		njoints;				/* number of joiunts					*/
	short *		param;					/* pointer to the parameters			*/
	short *		table;					/* pointer to the animation 			*/
} AnimeData;

typedef struct AnimeCtrl {
	short		code;					/* animation ID							*/
	ushort		ctrl;					/* animation control flags				*/
	AnimeData *	anime;					/* pointer to the animation data		*/
	long		frame;					/* frame counter						*/
	long		speed;					/* animation speed						*/
} AnimeCtrl;

typedef struct AnimePlay {
	short	 status;					/* skeleton animation status			*/
	short	 frame;						/* skeleton animation frame				*/
	float	 scale;						/* animation scale						*/
	short	*table;						/* pointer to the animation table		*/
	short	*param;						/* pointer to the animation parameter	*/
} AnimePlay;

typedef struct HmsDynamic {
	ulong		flags;					/* flags								*/
	short		angle;					/* object rotation angle				*/
	short		angvelo;				/* angle velocity						*/
	float		scale;					/* scaling								*/
	float		speed;					/* object speed							*/
	float		accele;					/* accele								*/
	float		jumping;				/* jumping speed						*/
	float		ground;					/* ground height						*/
	FVector		position;				/* object position						*/
	AnimeCtrl	animation;				/* information for the skeleton anime	*/
} CtrlShape;

typedef void (*Skeleton)(short flags);

#define	SHAPE_DRAW_NORMAL		0
#define	SHAPE_DRAW_MIRROR		1

#define	SHAPE_FLAG_OPENHAND		0x4000
#define	SHAPE_FLAG_ENABLE		0x8000


extern void  MarioSkeleton(short flags);

extern int   SetAnimation(CtrlShape *shape, short id, AnimeData *anime, long speed);
extern void  DrawSkeleton(CtrlShape *shape, Skeleton skeleton, int mirror);


/********************************************************************************/
/*																				*/
/*																				*/
/*	Mario sequence records														*/
/*																				*/
/*																				*/
/********************************************************************************/

#define	SEQ_FLAG_JUMPING		0x0001
#define	SEQ_FLAG_SETHEIGHT		0x0002
#define	SEQ_FLAG_MAKELEAF		0x0004
#define	SEQ_FLAG_BLOWLEAF		0x0008
#define	SEQ_FLAG_ROTATION		0x0010

#define	SEQ_FLAG_OPENHAND		SHAPE_FLAG_OPENHAND
#define	SEQ_FLAG_ENABLE			SHAPE_FLAG_ENABLE


typedef struct {
	uchar	counter;
	uchar	nframes;
	short	angle;
	float	posx1, posz1;
	float	posx2, posz2;
	float	posx3, posz3;
	float	posx4, posz4;
} Curve;

extern void InitializeMario(void);
extern int	DisplayMario(int event);


/********************************************************************************/
/*																				*/
/*																				*/
/*	Fader control record														*/
/*																				*/
/*																				*/
/********************************************************************************/

typedef struct {
		ushort		flag;				/* fader flag							*/
		uchar		counter;			/* fade counter							*/
		uchar		nframes;			/* number of frames 					*/
		RGBAColor	color;				/* fade color (r,g,b)					*/
} CtrlFader;

#define	FADER_FLAG_INACTIVE		0
#define	FADER_FLAG_FADEIN		1
#define	FADER_FLAG_FADEOUT		2


/********************************************************************************/
/*																				*/
/*																				*/
/*	Wave record																	*/
/*																				*/
/*																				*/
/********************************************************************************/

typedef struct Point {
	short	px;
	short	pz;
	short	py;
	short	ct;
	float	nx;
	float	ny;
	float	nz;
} WaveVertex;

extern void	InitializeWater(void);
extern void	DisplayWater(void);


/********************************************************************************/
/*																				*/
/*																				*/
/*	Bump mapping routines														*/
/*																				*/
/*																				*/
/********************************************************************************/

extern void InitBumpNCube(void);


extern void *NewBumpMap(int tw, int th, float nx, float ny, float nz,
					float a, float d, float s, float h, float sh, void *p);

extern void *UpdateBumpMap(void *p, float *l, float *m, float *vm);

extern void *malloc(long size);


/********************************************************************************/
/*																				*/
/*																				*/
/*	Message drawing routines													*/
/*																				*/
/*																				*/
/********************************************************************************/

typedef struct {
	char	cursor;		/* cursor position			*/
	char	blink;		/* cursor blinking counter	*/
	char	year;		/* year   96 - 120			*/
	char	month;		/* month   1 - 12			*/
	char	day;		/* day     1 - 31			*/
	char	week;		/* week    0 -  6			*/
	char	hour;		/* hour    0 - 23			*/
	char	minute;		/* minute  0 - 59			*/
} ClockInfo;

extern void DrawClockSetting(ClockInfo *clock);
extern void DrawClock(int posx, int posy, short month, short day, short week, short hour, short minute, short second, short alpha);


/********************************************************************************/
/*																				*/
/*																				*/
/*	Other function prototypes													*/
/*																				*/
/*																				*/
/********************************************************************************/

extern	int LeoGetKAdr(int sjis);
extern	int LeoGetAAdr(int code, int *dx, int *dy, int *cy);

extern void	 DisplayNintendoLogo(int alpha);
extern void	 DisplayInsertDisk(int active);
extern int   SetClock(void);
extern void	 InitClock(void);
extern void	 DisplayClock(int alpha);


/********************************************************************************/
/*																				*/
/*																				*/
/*	Global variables															*/
/*																				*/
/*																				*/
/********************************************************************************/

extern GfxPtr	 graphicp;			/* graphics diskplay list pointer			*/
extern AffineMtx cameraMatrix;

extern OSContStatus	contStatus[MAXCONTROLLERS];	/* controller status			*/
extern OSContPad	contRdData[MAXCONTROLLERS];	/* controller data				*/
extern uchar		contConnection;				/* controller connection		*/

#endif