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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
/* ScummVM - Scumm Interpreter
* Copyright (C) 2004-2005 The ScummVM project
*
* The ReInherit Engine is (C)2000-2003 by Daniel Balsom.
*
* 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.
*
* $Header$
*
*/
// Isometric level module - private header
#ifndef SAGA_ISOMAP_H_
#define SAGA_ISOMAP_H_
namespace Saga {
#define SAGA_ISOTILEDATA_LEN 8
#define SAGA_ISOTILE_WIDTH 32
#define SAGA_ISOTILE_BASEHEIGHT 15
#define SAGA_TILE_NOMINAL_H 16
#define SAGA_MAX_TILE_H 64
#define SAGA_TILEPLATFORMDATA_LEN 136
#define SAGA_PLATFORM_W 8
#define SAGA_MAX_PLATFORM_H 16
#define SAGA_TILEMAP_LEN 514
#define SAGA_TILEMAP_W 16
#define SAGA_TILEMAP_H 16
#define SAGA_METATILEDATA_LEN 36
#define SAGA_MULTI_TILE (1 << 15)
enum TileMapEdgeType {
kEdgeTypeBlack = 0,
kEdgeTypeFill0 = 1,
kEdgeTypeFill1 = 2,
kEdgeTypeRpt = 3,
kEdgeTypeWrap = 4
};
struct IsoTileData {
byte height;
int8 attributes;
size_t offset;
uint16 terrainMask;
byte FGBGAttr;
};
struct TilePlatformData {
int16 metaTile;
int16 height;
int16 highestPixel;
byte vBits;
byte uBits;
int16 tiles[SAGA_PLATFORM_W][SAGA_PLATFORM_W];
};
struct TileMapData {
byte edgeType;
int16 tilePlatforms[SAGA_TILEMAP_W][SAGA_TILEMAP_H];
};
struct MetaTileData {
uint16 highestPlatform;
uint16 highestPixel;
int16 stack[SAGA_MAX_PLATFORM_H];
};
struct MultiTileEntryData {
int16 offset;
byte u;
byte v;
byte h;
byte uSize;
byte vSize;
byte numStates;
byte currentState;
};
class IsoMap {
public:
IsoMap(SagaEngine *vm);
~IsoMap() {
freeMem();
}
void loadImages(const byte * resourcePointer, size_t resourceLength);
void loadMap(const byte * resourcePointer, size_t resourceLength);
void loadPlatforms(const byte * resourcePointer, size_t resourceLength);
void loadMetaTiles(const byte * resourcePointer, size_t resourceLength);
void loadMulti(const byte * resourcePointer, size_t resourceLength);
void freeMem();
int draw(SURFACE *ds);
private:
void drawTiles(SURFACE *ds);
void drawMetaTile(SURFACE *ds, uint16 metaTileIndex, int16 x, int16 y, int16 absU, int16 absV);
void drawPlatform(SURFACE *ds, uint16 platformIndex, int16 x, int16 y, int16 absU, int16 absV, int16 absH);
void setTileClip(int16 left, int16 right, int16 top, int16 bottom) {
_tileClipLeft = left;
_tileClipRight = right;
_tileClipTop = top;
_tileClipBottom = bottom;
}
void drawTile(SURFACE *ds, uint16 tileIndex, const Point &point);
//int drawMetaTile(SURFACE *ds, uint16 platformNumber, const Point &point);
//int drawMetamap(SURFACE *dst_s, int map_x, int map_y);
byte *_tileData;
size_t _tileDataLength;
uint16 _tilesCount;
IsoTileData *_tilesTable;
uint16 _tilePlatformsCount;
TilePlatformData *_tilePlatformList;
uint16 _metaTilesCount;
MetaTileData *_metaTileList;
uint16 _multiCount;
MultiTileEntryData *_multiTable;
TileMapData _tileMap;
Point _tileScroll;
Point _viewScroll;
int16 _tileClipLeft, _tileClipRight, _tileClipTop, _tileClipBottom;
SagaEngine *_vm;
};
} // End of namespace Saga
#endif
|