aboutsummaryrefslogtreecommitdiff
path: root/awe/video.h
blob: e6a5d5ea9f22c422403aab11f3a4b6544fb2251d (plain)
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
/* AWE - Another World Engine
 * Copyright (C) 2004 Gregory Montoir
 * Copyright (C) 2004 The ScummVM project
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

#ifndef __VIDEO_H__
#define __VIDEO_H__

#include "stdafx.h"

#include "intern.h"

namespace Awe {

struct StrEntry {
	uint16 id;
	const char *str;
};

struct Polygon {
	enum {
		MAX_POINTS = 50
	};

	uint16 bbw, bbh;
	uint8 numPoints;
	Point points[MAX_POINTS];

	void init(const uint8 *p, uint16 zoom);
};

struct Resource;
struct Serializer;
struct SystemStub;

struct Video {
	typedef void (Video::*drawLine)(int16 x1, int16 x2, uint8 col);

	enum {
		VID_PAGE_SIZE  = 320 * 200 / 2
	};

	static const uint8 _font[];
	static const StrEntry _stringsTableEng[];
	static const StrEntry _stringsTableDemo[];

	Resource *_res;
	SystemStub *_stub;

	uint8 _newPal, _curPal;
	uint8 *_pagePtrs[4];
	uint8 *_curPagePtr1, *_curPagePtr2, *_curPagePtr3;
	Polygon _pg;
	int16 _hliney;
	uint16 _interpTable[0x400];
	Ptr _pData;
	uint8 *_dataBuf;

	Video(Resource *res, SystemStub *stub);
	void init();

	void setDataBuffer(uint8 *dataBuf, uint16 offset);
	void drawShape(uint8 color, uint16 zoom, const Point &pt);
	void fillPolygon(uint16 color, uint16 zoom, const Point &pt);
	void drawShapeParts(uint16 zoom, const Point &pt);
	int32 calcStep(const Point &p1, const Point &p2, uint16 &dy);

	void drawString(uint8 color, uint16 x, uint16 y, uint16 strId);
	void drawChar(uint8 c, uint16 x, uint16 y, uint8 color, uint8 *buf);
	void drawPoint(uint8 color, int16 x, int16 y);
	void drawLineT(int16 x1, int16 x2, uint8 color);
	void drawLineN(int16 x1, int16 x2, uint8 color);
	void drawLineP(int16 x1, int16 x2, uint8 color);
	uint8 *getPagePtr(uint8 page);
	void changePagePtr1(uint8 page);
	void fillPage(uint8 page, uint8 color);
	void copyPage(uint8 src, uint8 dst, int16 vscroll);
	void copyPagePtr(const uint8 *src);
	uint8 *allocPage();
	void changePal(uint8 pal);
	void updateDisplay(uint8 page);
	
	void saveOrLoad(Serializer &ser);
};

}

#endif