1 /* ResidualVM - A 3D game interpreter
2  *
3  * ResidualVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the AUTHORS
5  * file distributed with this source distribution.
6  *
7  * Additional copyright for this file:
8  * Copyright (C) 1999-2000 Revolution Software Ltd.
9  * This code is based on source code created by Revolution Software,
10  * used with permission.
11  *
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License
14  * as published by the Free Software Foundation; either version 2
15  * of the License, or (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25  *
26  */
27 
28 #ifndef ICB_GRAPIC_PRIMS
29 #define ICB_GRAPIC_PRIMS
30 
31 #include "engines/icb/common/px_bitmap.h"
32 #include "engines/icb/common/px_types.h"
33 #include "engines/icb/p4_generic.h"
34 
35 namespace ICB {
36 
37 typedef float PXreal;
38 typedef float PXfloat;
39 typedef double PXdouble;
40 
41 typedef struct {
42 	uint32 x1;
43 	uint32 z1;
44 	uint32 x2;
45 	uint32 z2;
46 } _line;
47 
48 typedef struct {
49 	PXreal x;
50 	PXreal z;
51 } _point;
52 
53 // used in extrapolate line
54 typedef struct {
55 	PXdouble x;
56 	PXdouble z;
57 } _fpoint;
58 
59 typedef struct {
60 	PXdouble x;
61 	PXdouble z;
62 } _float_point;
63 
64 // Might seem silly to create yet another rectangle structure, but this one is needed to help the PSX and the PC
65 // share some of the Remora and inventory code.
66 typedef struct {
67 	int32 nX, nY;
68 	uint32 nWidth, nHeight;
69 } _PxBitmapRect;
70 
71 typedef LRECT DXrect;
72 
73 int32 twabs(int32 val);
74 
75 void Draw_horizontal_line(int32 xx, int32 yy, uint32 len, _rgb *pen, uint8 *ad, uint32 pitch);
76 void Draw_vertical_line(int32 xx, int32 yy, uint32 len, _rgb *pen, uint8 *ad, uint32 pitch);
77 void Fill_rect(int32 x, int32 y, int32 x2, int32 y2, uint32 pen, int32 z = 0);
78 void General_draw_line_24_32(int16 x0, int16 y0, int16 x1, int16 y1, _rgb *colour, uint8 *myScreenBuffer, uint32 pitch, int32 surface_width = SCREEN_WIDTH,
79 							 int32 surface_height = SCREEN_DEPTH);
80 
81 void General_poly_draw_24_32(_point *pVerts, int32 nNumVerts, _rgb sColour, bool8 bFill, uint8 *pSurface, int32 nPitch, int32 nSurfaceWidth, int32 nSurfaceHeight);
82 
83 // This draws a sprite to a surface, using the x, y found in the sprite itself.
84 void SpriteFrameDraw(uint8 *pSurfaceBitmap, uint32 nPitch, uint32 nSurfaceWidth, uint32 nSurfaceHeight, _pxBitmap *pBitmap, uint32 nFrameNumber, uint32 *nTransparencyRef,
85 					 uint8 nOpacity);
86 
87 // This draws a sprite to a surface, using a supplied x, y, so the sprite can be moved on the surface.
88 void SpriteXYFrameDraw(uint8 *pSurfaceBitmap, uint32 nPitch, uint32 nSurfaceWidth, uint32 nSurfaceHeight, _pxBitmap *pBitmap, int32 nX, int32 nY, uint32 nFrameNumber,
89 					   bool8 bCentre, uint32 *nTransparencyRef, uint8 nOpacity);
90 
91 // These all make LRECTs (needed by Direct-X) from various sources.
92 LRECT ConvertPxBitmapRectToRECT(const _PxBitmapRect &sBitmapRect);
93 
94 // Additive gouraud line .... what else ?
95 void AdditiveGouraudLine(int16 x0, int16 y0, _rgb c0, int16 x1, int16 y1, _rgb c1, uint32 surface_id);
96 void BlendedLine(int32 x0, int32 y0, int32 x1, int32 y1, _rgb c, uint32 surface_id);
97 void BlendedLine(int32 x0, int32 y0, int32 x1, int32 y1, _rgb c, int32 surface_width, int32 surface_height, uint32 pitch, uint8 *surface);
98 
99 DXrect MakeRECTFromSpriteSizes(int32 nX, int32 nY, uint32 nWidth, uint32 nHeight);
100 
101 } // End of namespace ICB
102 
103 #endif // #ifndef _GRAPIC_PRIMS
104