File: new_video.h

package info (click to toggle)
ale-clone 1.15pre16.3-1
  • links: PTS
  • area: contrib
  • in suites: potato
  • size: 2,432 kB
  • ctags: 3,217
  • sloc: ansic: 37,483; sh: 1,105; makefile: 343
file content (127 lines) | stat: -rw-r--r-- 3,641 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
**	A clone of a famous game.
*/
/**@name video.h	-	The video headerfile. */
/*
**	(c) Copyright 1999 by Lutz Sammer
**
**	$Id: new_video.h,v 1.5 1999/12/10 01:33:46 root Exp $
*/

#ifndef __NEW_VIDEO_H__
#define __NEW_VIDEO_H__

//@{

// Little note: this should become the new video headerfile

/*----------------------------------------------------------------------------
--	Includes
----------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------
--	Declarations
----------------------------------------------------------------------------*/

#if 0
Note:	This new graphic object should generalize all the different objects
	currently used in ALE Clone, Graphic Image, Sprite, RLESprite.
	Also should generalize the handling of different hardwares.
	(8bit,16bit,...)
#endif

/**
**	General graphic object typedef. (forward)
*/
typedef struct __graphic__ Graphic;

/**
**	General graphic object type.
*/
typedef struct __graphic_type__ {
	/**
	**	Draw the object.
	**
	**	@param o	pointer to object
	**	@param f	number of frame (object index)
	**	@param x	x coordinate on the screen
	**	@param y	y coordinate on the screen
	*/
    void (*Draw)	(Graphic* o,unsigned f,unsigned x,unsigned y);
    void (*DrawX)	(Graphic* o,unsigned f,unsigned x,unsigned y);
    void (*DrawClip)	(Graphic* o,unsigned f,unsigned x,unsigned y);
    void (*DrawClipX)	(Graphic* o,unsigned f,unsigned x,unsigned y);
	/**
	**	Draw part of the object.
	**
	**	@param o	pointer to object
	**	@param gx	X offset into object
	**	@param gy	Y offset into object
	**	@param w	width to display
	**	@param h	height to display
	**	@param x	x coordinate on the screen
	**	@param y	y coordinate on the screen
	*/
    void (*DrawSub)	(Graphic* o,unsigned gx,unsigned gy
			,unsigned w,unsigned h,unsigned x,unsigned y);
    void (*DrawSubX)	(Graphic* o,unsigned gx,unsigned gy
			,unsigned w,unsigned h,unsigned x,unsigned y);
    void (*DrawSubClip)	(Graphic* o,unsigned gx,unsigned gy
			,unsigned w,unsigned h,unsigned x,unsigned y);
    void (*DrawSubClipX)(Graphic* o,unsigned gx,unsigned gy
			,unsigned w,unsigned h,unsigned x,unsigned y);

    void (*Free)	(Graphic* o);
} GraphicType;

/**
**	General graphic object
*/
struct __graphic__ {
    GraphicType*	Type;		/// object type dependend
    unsigned		Width;		/// Width of the object
    unsigned		Height;		/// Height of the object
    unsigned		NumFrames;	/// Number of frames
    void*		Frames;		/// Frames of the object
};

/*----------------------------------------------------------------------------
--	Variables
----------------------------------------------------------------------------*/

/**
**	Wanted videomode, fullscreen or windowed.
*/
extern int VideoFullScreen;

/*----------------------------------------------------------------------------
--	Macros
----------------------------------------------------------------------------*/

/**
**	Draw a graphic object.
*/
#define VideoDraw(o,f,x,y) \
    ((o)->Type->Draw)(o,(f),(x),(y))

/*----------------------------------------------------------------------------
--	Functions
----------------------------------------------------------------------------*/

extern void InitVideo(void);		/// initialize the video part

    ///	Load graphic from PNG file.
extern Graphic* LoadGraphicPNG(const char* name);

    /// Make graphic
extern Graphic* MakeGraphic(unsigned d,unsigned w,unsigned h,void* p);

    /// Load graphic
extern Graphic* LoadGraphic(const char* file);

    /// Init graphic
extern void InitGraphic(void);

//@}

#endif	// !__NEW_VIDEO_H__