-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathGraphics.hpp
More file actions
226 lines (177 loc) · 6.72 KB
/
Copy pathGraphics.hpp
File metadata and controls
226 lines (177 loc) · 6.72 KB
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
/*
* Open Fodder
* ---------------
*
* Copyright (C) 2008-2026 Open Fodder
*
* 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 3 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
class cFodder;
struct sILBM_BMHD {
uint16 mWidth, mHeight;
uint16 mX, mY;
uint8 mPlanes;
uint8 mMask;
uint8 mCompression;
uint8 mReserved;
uint8 mTransparentColor;
uint8 mAspectX, mAspectY;
uint16 mPageWidth, mPageHeight;
sILBM_BMHD() {
mWidth = 0;
mHeight = 0;
mPlanes = 0;
}
uint16 ScreenSize() const {
return (mWidth * mHeight);
}
};
struct sImage {
tSharedBuffer mData;
cDimension mDimension;
cPalette mPalette[256];
uint8 mPlanes;
protected:
sILBM_BMHD mBMHD;
public:
sImage() {
mData = std::make_shared<std::vector<uint8>>();
mDimension = { 0,0 };
mPlanes = 0;
}
sILBM_BMHD* GetHeader() {
if (!mBMHD.mWidth || !mBMHD.mHeight) {
mBMHD.mWidth = mDimension.mWidth;
mBMHD.mHeight = mDimension.mHeight;
mBMHD.mPlanes = mPlanes;
}
return &mBMHD;
}
/*
* Load a Palette from a location in the loaded data
*/
void LoadPalette(size_t pFrom, const size_t pCount, const size_t pStartColorID = 0) {
auto Buffer = mData->data();
for (size_t ColorID = pStartColorID; ColorID < pStartColorID + pCount; ColorID++) {
// Get the next color values
mPalette[ColorID].mRed = *(Buffer + pFrom++);
mPalette[ColorID].mGreen = *(Buffer + pFrom++);
mPalette[ColorID].mBlue = *(Buffer + pFrom++);
}
}
/**
* Load a Palette from a buffer (BIG ENDIAN)
*/
void LoadPalette_Amiga( const uint8 *pFrom, const size_t pCount, const size_t pStartColorID = 0 ) {
uint16 color;
const size_t PaletteLimit = sizeof(mPalette) / sizeof(mPalette[0]);
if (pStartColorID >= PaletteLimit)
return;
const size_t ColorsToRead = std::min(pCount, PaletteLimit - pStartColorID);
for (size_t ColorID = pStartColorID; ColorID < pStartColorID + ColorsToRead; ColorID++) {
// Get the next color codes
color = readBEWord(pFrom);
pFrom += 2;
// Extract each color from the word
// X X X X R3 R2 R1 R0 G3 G2 G1 G0 B3 B2 B1 B0
mPalette[ColorID].mRed = ((color >> 8) & 0xF) << 2;
mPalette[ColorID].mGreen = ((color >> 4) & 0xF) << 2;
mPalette[ColorID].mBlue = ((color >> 0) & 0xF) << 2;
}
}
void CopyPalette( cPalette* pDestination, const size_t pCount, const size_t pStartColorID = 0) {
memcpy(pDestination, &mPalette[pStartColorID], sizeof(cPalette) * pCount);
}
};
class cGraphics {
public:
sImage mImageTemporary;
sImage mSpriteSheet_InGame1; // Army
sImage mSpriteSheet_InGame2; // Copt
sImage mSpriteSheet_RankFont;
sImage mImageHillBackground;
sImage mImageHillSprites;
sImage mImageRecruit;
sImage mImageService;
sImage mImagePStuff;
sImage mImageFonts;
sImage mImageMissionIntro;
cPalette mPalette[255];
protected:
cSurface* mSurface;
cSurface* mImageOriginal;
std::shared_ptr<cFodder> mFodder;
int32 Heli_VeryBack;
int32 Heli_Back;
int32 Heli_middle;
int32 Heli_Front;
int32 Heli_TextPos;
int32 Heli_TextPosBottom;
protected:
std::string EnsureExtension(const std::string& pFilename, const char* pExtension) const;
bool Sprite_OnScreen_ClipY(int16 pRowStrideBytes);
bool Sprite_OnScreen_ClipBottom();
void Sidebar_Copy_To_Surface_Common(int16 pStartY, cSurface* pSurface, bool pOffsetSource);
void Sidebar_Copy_ScreenBuffer_Common(uint16 pRow, int16 pRows, int16 pCopyToScreen, uint32*& pBuffer,
int pRowOffset, int pRowScale);
template <typename DrawFunc>
void Sidebar_Copy_Sprite_Loop(uint8* pSource, uint8* pDest, int16 pRows, int16 pColumnsHalf,
int16 pSourceSkip, int16 pDestSkip, DrawFunc pDraw) {
for (int16 dy = pRows; dy > 0; --dy) {
for (int16 dx = pColumnsHalf; dx > 0; --dx) {
pDraw(pSource, pDest);
}
pSource += pSourceSkip;
pDest += pDestSkip;
}
}
public:
cGraphics();
virtual ~cGraphics() { };
virtual uint8* GetSpriteData( uint16 pSegment ) = 0;
virtual void Mouse_DrawCursor() = 0;
virtual void Load_pStuff() = 0;
virtual void Load_Sprite_Font() = 0;
virtual void Load_Hill_Data() = 0;
virtual void Load_Service_Data() = 0;
virtual void Tile_Prepare_Gfx() = 0;
virtual sImage Decode_Image(const std::string& pFilename, const size_t pCount = 0, const size_t pPaletteOffset = 0, const size_t pStartIndex = 0) = 0;
virtual void Load_And_Draw_Image( const std::string &pFilename, unsigned int pColors, size_t pBackColor = 0) = 0;
virtual void HeliIntro_TickParallaxAndText();
virtual void Map_Tile_Draw(cSurface *pTarget, uint16 pTile, uint16 pX, uint16 pY, uint16 pOffset) = 0;
virtual void MapTiles_Draw() = 0;
virtual void Map_Load_Resources() = 0;
virtual void MapOverview_Render_Tiles( uint16 pTile, uint16 pDestX, uint16 pDestY ) = 0;
virtual void PaletteSetOverview() = 0;
virtual void PaletteSet(cSurface *pTarget = 0) = 0;
virtual void PaletteLoad( const uint8 *pBuffer, uint32 pColors, uint32 pColorID = 0 ) = 0;
virtual void Video_Draw_16(const uint8* RowPallete = 0) = 0;
virtual void Video_Draw_8(cSurface *pTarget = 0, const uint8* RowPallete = 0) = 0;
virtual void SetActiveSpriteSheet( eGFX_Types pSpriteType ) = 0;
virtual void SetImage( cSurface* pImage );
virtual void SetSurfaceOriginal(cSurface* pImage);
virtual void SetImageOriginal();
virtual bool Sprite_OnScreen_Check() = 0;
virtual void Sidebar_Copy_To_Surface( int16 pStartY = 0, cSurface *pSurface = 0 ) = 0;
virtual void Sidebar_Copy_Sprite_To_ScreenBufPtr( int16 pSpriteType, size_t pX, size_t pY ) = 0;
virtual void Sidebar_Copy_ScreenBuffer( uint16 pRow, int16 pRows, int16 pCopyToScreen, uint32*& pBuffer) = 0;
virtual void Recruit_Sprite_Draw( int16 pColumns, int16 pRows, int16 pData8, int16 pData10, int16 pData14, int16 pDataC, uint8* pGraphics ) = 0;
virtual void Briefing_Intro_Helicopter_Play( const bool pShowHelicopter, const eTileTypes pTileset, const std::string pTop, const std::string pBottom) = 0;
virtual void Mission_Intro_Load_Resources(const eTileTypes pTileset) = 0;
virtual void Mission_Intro_DrawHelicopter( uint16 pID ) = 0;
virtual void Recruit_Draw_Hill() = 0;
virtual void Recruit_Draw_HomeAway() = 0;
};