[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stratagus-CVS] stratagus/src/map map.c map_draw.c map_fog.c mi...
From: |
address@hidden |
Subject: |
[Stratagus-CVS] stratagus/src/map map.c map_draw.c map_fog.c mi... |
Date: |
15 Jan 2004 13:06:24 +1100 |
CVSROOT: /home/strat
Module name: stratagus
Changes by: <address@hidden> 04/01/15 13:06:23
Modified files:
src/map : map.c map_draw.c map_fog.c minimap.c tileset.c
Log message:
USE_SDL_SURFACE is default
Patches:
Index: stratagus/src/map/map.c
diff -u stratagus/src/map/map.c:1.72 stratagus/src/map/map.c:1.73
--- stratagus/src/map/map.c:1.72 Thu Jan 15 09:31:05 2004
+++ stratagus/src/map/map.c Thu Jan 15 13:06:21 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: map.c,v 1.72 2004/01/14 22:31:05 nobody_ Exp $
+// $Id: map.c,v 1.73 2004/01/15 02:06:21 jsalmon3 Exp $
//@{
@@ -646,11 +646,6 @@
{
free(TheMap.Fields);
free(TheMap.TerrainName);
-#ifndef USE_SDL_SURFACE
-// FIXME: merge
- free(TheMap.TileData);
- free(TheMap.Tiles);
-#endif
free(TheMap.Visible[0]);
// Tileset freeed by Tileset?
Index: stratagus/src/map/map_draw.c
diff -u stratagus/src/map/map_draw.c:1.59 stratagus/src/map/map_draw.c:1.60
--- stratagus/src/map/map_draw.c:1.59 Thu Jan 15 10:44:00 2004
+++ stratagus/src/map/map_draw.c Thu Jan 15 13:06:21 2004
@@ -29,7 +29,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: map_draw.c,v 1.59 2004/01/14 23:44:00 jsalmon3 Exp $
+// $Id: map_draw.c,v 1.60 2004/01/15 02:06:21 jsalmon3 Exp $
//@{
@@ -161,24 +161,6 @@
*/
local unsigned int PixelsHigh[256];
-/**
-** Fast draw tile function pointer.
-**
-** Draws tiles display and video mode independ
-*/
-#ifndef USE_SDL_SURFACE
-global void (*VideoDrawTile)(const GraphicData*, int, int);
-#endif
-
-/**
-** Fast draw tile function pointer with cache support.
-**
-** Draws tiles display and video mode independ
-*/
-#ifndef USE_SDL_SURFACE
-global void (*MapDrawTile)(int, int, int);
-#endif
-
#ifdef NEW_DECODRAW
/**
** Decoration as registered for decoration mechanism to draw map
tiles
@@ -260,7 +242,6 @@
-- Draw tile
----------------------------------------------------------------------------*/
-#ifdef USE_SDL_SURFACE
/**
** Fast draw tile.
**
@@ -292,76 +273,147 @@
SDL_BlitSurface(TheMap.TileGraphic->Surface, &srect,
TheScreen, &drect);
}
-#else
+
+#ifdef NEW_DECODRAW
/**
-** Fast draw 16x16 tile for 8 bpp video modes.
+** Draw TileSizeX x TileSizeY clipped for XX bpp video modes.
+** (needed for decoration mechanism, which wants to draw tile
partly)
+** FIXME: this separate function is only needed for compatibility
with
+** variable VideoDrawTile, can be replaced by
MapDrawXXTileClip
**
** @param data pointer to tile graphic data
** @param x X position into video memory
** @param y Y position into video memory
+*/
+local void VideoDrawXXTileClip(const unsigned char* data, int x, int y)
+{
+#if GRID==1
+ VideoDrawRawClip((VMemType*)TheMap.TileData->Pixels,
+ data, x, y, TileSizeX, TileSizeY-1);
+ VideoDrawLineClip(ColorBlack, x + TileSizeX-1, y,
+ x + TileSizeX-1, y + TileSizeY);
+ VideoDrawLineClip(ColorBlack, x, y + TileSizeY-1,
+ x + TileSizeX, y + TileSizeY - 1);
+#else
+ VideoDrawRawClip((VMemType*)TheMap.TileData->Pixels,
+ data, x, y, TileSizeX, TileSizeY);
+#endif
+}
+
+/**
+** Draw TileSizeX x TileSizeY clipped for XX bpp video modes.
+** (needed for decoration mechanism, which wants to draw tile
partly)
+**
+** @param tile Tile number to draw.
+** @param x X position into video memory
+** @param y Y position into video memory
+*/
+local void MapDrawXXTileClip(int tile, int x, int y)
+{
+ VideoDrawXXTileClip(TheMap.Tiles[tile], x, y);
+}
+#endif
+
+/*----------------------------------------------------------------------------
+-- Draw tile with zoom
+----------------------------------------------------------------------------*/
+
+// FIXME: write this
+
+/*----------------------------------------------------------------------------
+-- Cache
+----------------------------------------------------------------------------*/
+
+#ifdef USE_TILECACHE // {
+
+/**
+** Draw 16x16 tile for 8 bpp video modes into cache and video
memory.
+**
+** @param graphic Graphic structure for the tile
+** @param cache Cache to fill with tile
+** @param x X position into video memory
+** @param y Y position into video memory
**
** @note This is a hot spot in the program.
-** (50% cpu time was needed for this, now only 32%)
**
** @see GRID
*/
-global void VideoDraw8Tile16(const unsigned char* data, int x, int y)
+local void FillCache8AndDraw16(const unsigned char* data, VMemType8* cache,
+ int x, int y)
{
const unsigned char* sp;
const unsigned char* ep;
+ int va;
VMemType8* dp;
- int da;
+ VMemType8* vp;
sp = data;
ep = sp + TileSizeY * TileSizeX - GRID_SUB;
- da = VideoWidth;
- dp = VideoMemory8 + x + y * VideoWidth;
+ dp = cache;
+ va = VideoWidth;
+ vp = VideoMemory8 + x + y * VideoWidth;
+
+#ifdef DEBUG
+ if (((long)sp) & 1) {
+ DebugLevel0("Not aligned memory\n");
+ }
+ if (((long)dp) & 3) {
+ DebugLevel0("Not aligned memory\n");
+ }
+ if (((long)vp) & 3) {
+ DebugLevel0("Not aligned video memory\n");
+ }
+#endif
while (sp < ep) { // loop
unrolled
#undef UNROLL2
/// basic unroll code
-#define UNROLL2(x) \
- dp[x + 0] = ((VMemType8*)TheMap.TileData->Pixels)[sp[x + 0]]; \
- dp[x + 1] = ((VMemType8*)TheMap.TileData->Pixels)[sp[x + 1]]
+#define UNROLL2(x) \
+ vp[x + 0] = dp[x + 0] =
((VMemType8*)TheMap.TileData->Pixels)[sp[x + 0]]; \
+ vp[x + 0] = dp[x + 1] =
((VMemType8*)TheMap.TileData->Pixels)[sp[x + 1]]
UNROLL16(0);
#if GRID == 1
- dp[15] = ((VMemType8*)TheMap.TileData->Pixels)[0];
+ vp[15] = dp[15] = ((VMemType8*)TheMap.TileData->Pixels)[0];
#endif
+ vp += va;
sp += TileSizeX;
- dp += da;
+ dp += TileSizeX;
}
#if GRID == 1
- for (da = TileSizeX; da--;) { // with grid no need to be fast
- dp[da] = ((VMemType8*)TheMap.TileData->Pixels)[0];
+ for (va = TileSizeX; va--;) { // no need to be fast with grid
+ vp[va] = dp[va] = ((VMemType8*)TheMap.TileData->Pixels)[0];
}
#endif
}
/**
-** Fast draw 16x16 tile for 16 bpp video modes.
+** Draw 16x16 tile for 16 bpp video modes into cache and video
memory.
**
-** @param data pointer to tile graphic data
+** @param graphic Graphic structure for the tile
+** @param cache Cache to fill with tile
** @param x X position into video memory
** @param y Y position into video memory
**
** @note This is a hot spot in the program.
-** (50% cpu time was needed for this, now only 32%)
**
** @see GRID
*/
-global void VideoDraw16Tile16(const unsigned char* data, int x, int y)
+local void FillCache16AndDraw16(const unsigned char* data, VMemType16* cache,
+ int x, int y)
{
const unsigned char* sp;
const unsigned char* ep;
+ int va;
VMemType16* dp;
- int da;
+ VMemType16* vp;
sp = data;
ep = sp + TileSizeY * TileSizeX - GRID_SUB;
- da = VideoWidth;
- dp = VideoMemory16 + x + y * VideoWidth;
+ dp = cache;
+ va = VideoWidth;
+ vp = VideoMemory16 + x + y * VideoWidth;
#ifdef DEBUG
if (((long)sp) & 1) {
@@ -370,52 +422,60 @@
if (((long)dp) & 3) {
DebugLevel0("Not aligned memory\n");
}
+ if (((long)vp) & 3) {
+ DebugLevel0("Not aligned video memory\n");
+ }
#endif
while (sp < ep) { // loop
unrolled
#undef UNROLL2
/// basic unroll code
-#define UNROLL2(x) \
- *(unsigned int*)(dp + x + 0) = PixelsLow[sp[x + 0]] |
PixelsHigh[sp[x + 1]]
+#define UNROLL2(x) \
+ *(unsigned int*)(vp + x + 0) = *(unsigned int*)(dp + x + 0) = \
+ PixelsLow[sp[x + 0]] | PixelsHigh[sp[x + 1]]
UNROLL16(0);
#if GRID == 1
- dp[15] = Pixels16[0];
+ vp[15] = dp[15] = Pixels[0];
#endif
+ vp += va;
sp += TileSizeX;
- dp += da;
+ dp += TileSizeX;
}
#if GRID == 1
- for (da = TileSizeX; da--;) { // with grid no need to be fast
- dp[da] = Pixels16[0];
+ for (va = TileSizeX; va--;) { // no need to be fast with grid
+ vp[va] = dp[va] = Pixels[0];
}
#endif
}
/**
-** Fast draw 16x16 tile for 24 bpp video modes.
+** Draw 16x16 tile for 24 bpp video modes into cache and video
memory.
**
-** @param data pointer to tile graphic data
+** @param graphic Graphic structure for the tile
+** @param cache Cache to fill with tile
** @param x X position into video memory
** @param y Y position into video memory
**
** @note This is a hot spot in the program.
-** (50% cpu time was needed for this, now only 32%)
**
** @see GRID
*/
-global void VideoDraw24Tile16(const unsigned char* data, int x, int y)
+local void FillCache24AndDraw16(const unsigned char* data, VMemType24* cache,
+ int x, int y)
{
const unsigned char* sp;
const unsigned char* ep;
+ int va;
VMemType24* dp;
- int da;
+ VMemType24* vp;
sp = data;
ep = sp + TileSizeY * TileSizeX - GRID_SUB;
- da = VideoWidth;
- dp = VideoMemory24 + x + y * VideoWidth;
+ dp = cache;
+ va = VideoWidth;
+ vp = VideoMemory24 + x + y * VideoWidth;
#ifdef DEBUG
if (((long)sp) & 1) {
@@ -424,145 +484,184 @@
if (((long)dp) & 3) {
DebugLevel0("Not aligned memory\n");
}
+ if (((long)vp) & 3) {
+ DebugLevel0("Not aligned video memory\n");
+ }
#endif
while (sp < ep) { // loop
unrolled
#undef UNROLL2
/// basic unroll code
-#define UNROLL2(x) \
- dp[x + 0] = ((VMemType24*)TheMap.TileData->Pixels)[sp[x + 0]];
\
- dp[x + 1] = ((VMemType24*)TheMap.TileData->Pixels)[sp[x + 1]]
+#define UNROLL2(x) \
+ vp[x + 0] = dp[x + 0] =
((VMemType24*)TheMap.TileData->Pixels)[sp[x + 0]]; \
+ vp[x + 0] = dp[x + 1] =
((VMemType24*)TheMap.TileData->Pixels)[sp[x + 1]]
UNROLL16(0);
-#if GRID==1
- dp[15] = Pixels24[0];
+#if GRID == 1
+ vp[15] = dp[15] = ((VMemType24*)TheMap.TileData->Pixels)[0];
#endif
+ vp += va;
sp += TileSizeX;
- dp += da;
+ dp += TileSizeX;
}
#if GRID == 1
- for (da = TileSizeX; da--;) { // with grid no need to be fast
- dp[da] = Pixels24[0];
+ for (va = TileSizeX; va--;) { // no need to be fast with grid
+ vp[va] = dp[va] = ((VMemType24*)TheMap.TileData->Pixels)[0];
}
#endif
}
/**
-** Fast draw 16x16 tile for 32 bpp video modes.
+** Draw 16x16 tile for 32 bpp video modes into cache and video
memory.
**
-** @param data pointer to tile graphic data
+** @param graphic Graphic structure for the tile
+** @param cache Cache to fill with tile
** @param x X position into video memory
** @param y Y position into video memory
**
** @note This is a hot spot in the program.
-** (50% cpu time was needed for this, now only 32%)
**
** @see GRID
*/
-global void VideoDraw32Tile16(const unsigned char* data, int x, int y)
+local void FillCache32AndDraw16(const unsigned char* data, VMemType32* cache,
+ int x, int y)
{
const unsigned char* sp;
const unsigned char* ep;
+ int va;
VMemType32* dp;
- int da;
+ VMemType32* vp;
sp = data;
ep = sp + TileSizeY * TileSizeX - GRID_SUB;
- da = VideoWidth;
- dp = VideoMemory32 + x + y * VideoWidth;
+ dp = cache;
+ va = VideoWidth;
+ vp = VideoMemory32 + x + y * VideoWidth;
+
+#ifdef DEBUG
+ if (((long)sp) & 1) {
+ DebugLevel0("Not aligned memory\n");
+ }
+ if (((long)dp) & 3) {
+ DebugLevel0("Not aligned memory\n");
+ }
+ if (((long)vp) & 3) {
+ DebugLevel0("Not aligned video memory\n");
+ }
+#endif
while (sp < ep) { // loop
unrolled
#undef UNROLL2
/// basic unroll code
-#define UNROLL2(x) \
- dp[x + 0] = ((VMemType32*)TheMap.TileData->Pixels)[sp[x + 0]];
\
- dp[x + 1] = ((VMemType32*)TheMap.TileData->Pixels)[sp[x + 1]]
+#define UNROLL2(x) \
+ vp[x + 0] = dp[x + 0] =
((VMemType32*)TheMap.TileData->Pixels)[sp[x + 0]]; \
+ vp[x + 0] = dp[x + 1] =
((VMemType32*)TheMap.TileData->Pixels)[sp[x + 1]]
UNROLL16(0);
#if GRID == 1
- dp[15] = ((VMemType32*)TheMap.TileData->Pixels)[0];
+ vp[15] = dp[15] = ((VMemType32*)TheMap.TileData->Pixels)[0];
#endif
+ vp += va;
sp += TileSizeX;
- dp += da;
+ dp += TileSizeX;
}
#if GRID == 1
- for (da = TileSizeX; da--;) { // with grid no need to be fast
- dp[da] = ((VMemType32*)TheMap.TileData->Pixels)[0];
+ for (va = TileSizeX; va--;) { // no need to be fast with grid
+ vp[va] = dp[va] = ((VMemType32*)TheMap.TileData->Pixels)[0];
}
#endif
}
/**
-** Fast draw 32x32 tile for 8 bpp video modes.
+** Draw 32x32 tile for 8 bpp video modes into cache and video
memory.
**
-** @param data pointer to tile graphic data
+** @param graphic Graphic structure for the tile
+** @param cache Cache to fill with tile
** @param x X position into video memory
** @param y Y position into video memory
**
** @note This is a hot spot in the program.
-** (50% cpu time was needed for this, now only 32%)
**
** @see GRID
*/
-global void VideoDraw8Tile32(const unsigned char* data, int x, int y)
+local void FillCache8AndDraw32(const unsigned char* data, VMemType8* cache,
+ int x, int y)
{
const unsigned char* sp;
const unsigned char* ep;
+ int va;
VMemType8* dp;
- int da;
+ VMemType8* vp;
sp = data;
ep = sp + TileSizeY * TileSizeX - GRID_SUB;
- da = VideoWidth;
- dp = VideoMemory8 + x + y * VideoWidth;
+ dp = cache;
+ va = VideoWidth;
+ vp = VideoMemory8 + x + y * VideoWidth;
+
+#ifdef DEBUG
+ if (((long)sp) & 1) {
+ DebugLevel0("Not aligned memory\n");
+ }
+ if (((long)dp) & 3) {
+ DebugLevel0("Not aligned memory\n");
+ }
+ if (((long)vp) & 3) {
+ DebugLevel0("Not aligned video memory\n");
+ }
+#endif
while (sp < ep) { // loop
unrolled
#undef UNROLL2
/// basic unroll code
-#define UNROLL2(x) \
- dp[x + 0] = ((VMemType8*)TheMap.TileData->Pixels)[sp[x + 0]]; \
- dp[x + 1] = ((VMemType8*)TheMap.TileData->Pixels)[sp[x + 1]]
+#define UNROLL2(x) \
+ vp[x + 0] = dp[x + 0] =
((VMemType8*)TheMap.TileData->Pixels)[sp[x + 0]]; \
+ vp[x + 0] = dp[x + 1] =
((VMemType8*)TheMap.TileData->Pixels)[sp[x + 1]]
UNROLL32(0);
#if GRID == 1
- dp[31] = ((VMemType8*)TheMap.TileData->Pixels)[0];
+ vp[31] = dp[31] = ((VMemType8*)TheMap.TileData->Pixels)[0];
#endif
+ vp += va;
sp += TileSizeX;
- dp += da;
+ dp += TileSizeX;
}
#if GRID == 1
- for (da = TileSizeX; da--;) { // with grid no need to be fast
- dp[da] = ((VMemType8*)TheMap.TileData->Pixels)[0];
+ for (va = TileSizeX; va--;) { // no need to be fast with grid
+ vp[va] = dp[va] = ((VMemType8*)TheMap.TileData->Pixels)[0];
}
#endif
}
/**
-** Fast draw 32x32 tile for 16 bpp video modes.
+** Draw 32x32 tile for 16 bpp video modes into cache and video
memory.
**
-** @param data pointer to tile graphic data
+** @param graphic Graphic structure for the tile
+** @param cache Cache to fill with tile
** @param x X position into video memory
** @param y Y position into video memory
**
** @note This is a hot spot in the program.
-** (50% cpu time was needed for this, now only 32%)
**
** @see GRID
*/
-global void VideoDraw16Tile32(const unsigned char* data, int x, int y)
+local void FillCache16AndDraw32(const unsigned char* data, VMemType16* cache,
+ int x, int y)
{
const unsigned char* sp;
const unsigned char* ep;
+ int va;
VMemType16* dp;
- int da;
+ VMemType16* vp;
sp = data;
ep = sp + TileSizeY * TileSizeX - GRID_SUB;
- da = VideoWidth;
- dp = VideoMemory16 + x + y * VideoWidth;
+ dp = cache;
+ va = VideoWidth;
+ vp = VideoMemory16 + x + y * VideoWidth;
#ifdef DEBUG
if (((long)sp) & 1) {
@@ -571,247 +670,36 @@
if (((long)dp) & 3) {
DebugLevel0("Not aligned memory\n");
}
+ if (((long)vp) & 3) {
+ DebugLevel0("Not aligned video memory\n");
+ }
#endif
while (sp < ep) { // loop
unrolled
#undef UNROLL2
/// basic unroll code
-#define UNROLL2(x) \
- *(unsigned int*)(dp + x + 0) = PixelsLow[sp[x + 0]] |
PixelsHigh[sp[x + 1]]
+#define UNROLL2(x) \
+ *(unsigned int*)(vp + x + 0) = *(unsigned int*)(dp + x + 0)
= \
+ PixelsLow[sp[x + 0]] | PixelsHigh[sp[x + 1]]
UNROLL32(0);
#if GRID == 1
- dp[31] = Pixels16[0];
+ vp[31] = dp[31] = Pixels[0];
#endif
- sp += TileSizeX;
- dp += da;
- }
-
-#if GRID == 1
- for (da = TileSizeX; da--;) { // with grid no need to be fast
- dp[da] = Pixels16[0];
- }
-#endif
-}
-
-/**
-** Fast draw 32x32 tile for 24 bpp video modes.
-**
-** @param data pointer to tile graphic data
-** @param x X position into video memory
-** @param y Y position into video memory
-**
-** @note This is a hot spot in the program.
-** (50% cpu time was needed for this, now only 32%)
-**
-** @see GRID
-*/
-global void VideoDraw24Tile32(const unsigned char* data, int x, int y)
-{
- const unsigned char* sp;
- const unsigned char* ep;
- VMemType24* dp;
- int da;
-
- sp = data;
- ep = sp + TileSizeY * TileSizeX - GRID_SUB;
- da = VideoWidth;
- dp = VideoMemory24 + x + y * VideoWidth;
-
-#ifdef DEBUG
- if (((long)sp) & 1) {
- DebugLevel0("Not aligned memory\n");
- }
- if (((long)dp) & 3) {
- DebugLevel0("Not aligned memory\n");
- }
-#endif
-
- while (sp < ep) { // loop
unrolled
-#undef UNROLL2
- /// basic unroll code
-#define UNROLL2(x) \
- dp[x + 0] = ((VMemType24*)TheMap.TileData->Pixels)[sp[x + 0]];
\
- dp[x + 1] = ((VMemType24*)TheMap.TileData->Pixels)[sp[x + 1]]
-
- UNROLL32(0);
-#if GRID == 1
- dp[31] = Pixels24[0];
-#endif
- sp += TileSizeX;
- dp += da;
- }
-
-#if GRID == 1
- for (da = TileSizeX; da--;) { // with grid no need to be fast
- dp[da] = Pixels24[0];
- }
-#endif
-}
-
-/**
-** Fast draw 32x32 tile for 32 bpp video modes.
-**
-** @param data pointer to tile graphic data
-** @param x X position into video memory
-** @param y Y position into video memory
-**
-** @note This is a hot spot in the program.
-** (50% cpu time was needed for this, now only 32%)
-**
-** @see GRID
-*/
-global void VideoDraw32Tile32(const unsigned char* data, int x, int y)
-{
- const unsigned char* sp;
- const unsigned char* ep;
- VMemType32* dp;
- int da;
-
- sp = data;
- ep = sp + TileSizeY * TileSizeX - GRID_SUB;
- da = VideoWidth;
- dp = VideoMemory32 + x + y * VideoWidth;
-
- while (sp < ep) { // loop
unrolled
-#undef UNROLL2
- /// basic unroll code
-#define UNROLL2(x) \
- dp[x + 0] = ((VMemType32*)TheMap.TileData->Pixels)[sp[x + 0]];
\
- dp[x + 1] = ((VMemType32*)TheMap.TileData->Pixels)[sp[x + 1]]
-
- UNROLL32(0);
-#if GRID == 1
- dp[31] = ((VMemType32*)TheMap.TileData->Pixels)[0];
-#endif
- sp += TileSizeX;
- dp += da;
- }
-
-#if GRID == 1
- for (da = TileSizeX; da--;) { // with grid no need to be fast
- dp[da] = ((VMemType32*)TheMap.TileData->Pixels)[0];
- }
-#endif
-}
-#endif // ifdef USE_SDL_SURFACE
-
-#ifdef NEW_DECODRAW
-/**
-** Draw TileSizeX x TileSizeY clipped for XX bpp video modes.
-** (needed for decoration mechanism, which wants to draw tile
partly)
-** FIXME: this separate function is only needed for compatibility
with
-** variable VideoDrawTile, can be replaced by
MapDrawXXTileClip
-**
-** @param data pointer to tile graphic data
-** @param x X position into video memory
-** @param y Y position into video memory
-*/
-local void VideoDrawXXTileClip(const unsigned char* data, int x, int y)
-{
-#if GRID==1
- VideoDrawRawClip((VMemType*)TheMap.TileData->Pixels,
- data, x, y, TileSizeX, TileSizeY-1);
- VideoDrawLineClip(ColorBlack, x + TileSizeX-1, y,
- x + TileSizeX-1, y + TileSizeY);
- VideoDrawLineClip(ColorBlack, x, y + TileSizeY-1,
- x + TileSizeX, y + TileSizeY - 1);
-#else
- VideoDrawRawClip((VMemType*)TheMap.TileData->Pixels,
- data, x, y, TileSizeX, TileSizeY);
-#endif
-}
-
-/**
-** Draw TileSizeX x TileSizeY clipped for XX bpp video modes.
-** (needed for decoration mechanism, which wants to draw tile
partly)
-**
-** @param tile Tile number to draw.
-** @param x X position into video memory
-** @param y Y position into video memory
-*/
-local void MapDrawXXTileClip(int tile, int x, int y)
-{
- VideoDrawXXTileClip(TheMap.Tiles[tile], x, y);
-}
-#endif
-
-/*----------------------------------------------------------------------------
--- Draw tile with zoom
-----------------------------------------------------------------------------*/
-
-// FIXME: write this
-
-/*----------------------------------------------------------------------------
--- Cache
-----------------------------------------------------------------------------*/
-
-#ifdef USE_TILECACHE // {
-
-/**
-** Draw 16x16 tile for 8 bpp video modes into cache and video
memory.
-**
-** @param graphic Graphic structure for the tile
-** @param cache Cache to fill with tile
-** @param x X position into video memory
-** @param y Y position into video memory
-**
-** @note This is a hot spot in the program.
-**
-** @see GRID
-*/
-local void FillCache8AndDraw16(const unsigned char* data, VMemType8* cache,
- int x, int y)
-{
- const unsigned char* sp;
- const unsigned char* ep;
- int va;
- VMemType8* dp;
- VMemType8* vp;
-
- sp = data;
- ep = sp + TileSizeY * TileSizeX - GRID_SUB;
- dp = cache;
- va = VideoWidth;
- vp = VideoMemory8 + x + y * VideoWidth;
-
-#ifdef DEBUG
- if (((long)sp) & 1) {
- DebugLevel0("Not aligned memory\n");
- }
- if (((long)dp) & 3) {
- DebugLevel0("Not aligned memory\n");
- }
- if (((long)vp) & 3) {
- DebugLevel0("Not aligned video memory\n");
- }
-#endif
-
- while (sp < ep) { // loop
unrolled
-#undef UNROLL2
- /// basic unroll code
-#define UNROLL2(x) \
- vp[x + 0] = dp[x + 0] =
((VMemType8*)TheMap.TileData->Pixels)[sp[x + 0]]; \
- vp[x + 0] = dp[x + 1] =
((VMemType8*)TheMap.TileData->Pixels)[sp[x + 1]]
-
- UNROLL16(0);
-#if GRID == 1
- vp[15] = dp[15] = ((VMemType8*)TheMap.TileData->Pixels)[0];
-#endif
- vp += va;
+ vp += va;
sp += TileSizeX;
dp += TileSizeX;
}
#if GRID == 1
for (va = TileSizeX; va--;) { // no need to be fast with grid
- vp[va] = dp[va] = ((VMemType8*)TheMap.TileData->Pixels)[0];
+ vp[va] = dp[va] = Pixels[0];
}
#endif
}
/**
-** Draw 16x16 tile for 16 bpp video modes into cache and video
memory.
+** Draw 32x32 tile for 24 bpp video modes into cache and video
memory.
**
** @param graphic Graphic structure for the tile
** @param cache Cache to fill with tile
@@ -822,20 +710,20 @@
**
** @see GRID
*/
-local void FillCache16AndDraw16(const unsigned char* data, VMemType16* cache,
+local void FillCache24AndDraw32(const unsigned char* data, VMemType24* cache,
int x, int y)
{
const unsigned char* sp;
const unsigned char* ep;
int va;
- VMemType16* dp;
- VMemType16* vp;
+ VMemType24* dp;
+ VMemType24* vp;
sp = data;
ep = sp + TileSizeY * TileSizeX - GRID_SUB;
dp = cache;
va = VideoWidth;
- vp = VideoMemory16 + x + y * VideoWidth;
+ vp = VideoMemory24 + x + y * VideoWidth;
#ifdef DEBUG
if (((long)sp) & 1) {
@@ -853,12 +741,12 @@
#undef UNROLL2
/// basic unroll code
#define UNROLL2(x) \
- *(unsigned int*)(vp + x + 0) = *(unsigned int*)(dp + x + 0) = \
- PixelsLow[sp[x + 0]] | PixelsHigh[sp[x + 1]]
+ vp[x + 0] = dp[x + 0] =
((VMemType24*)TheMap.TileData->Pixels)[sp[x + 0]]; \
+ vp[x + 0] = dp[x + 1] =
((VMemType24*)TheMap.TileData->Pixels)[sp[x + 1]]
- UNROLL16(0);
+ UNROLL32(0);
#if GRID == 1
- vp[15] = dp[15] = Pixels[0];
+ vp[31] = dp[31] = ((VMemType24*)TheMap.TileData->Pixels)[0];
#endif
vp += va;
sp += TileSizeX;
@@ -867,13 +755,13 @@
#if GRID == 1
for (va = TileSizeX; va--;) { // no need to be fast with grid
- vp[va] = dp[va] = Pixels[0];
+ vp[va] = dp[va] = ((VMemType24*)TheMap.TileData->Pixels)[0];
}
#endif
}
/**
-** Draw 16x16 tile for 24 bpp video modes into cache and video
memory.
+** Draw 32x32 tile for 32 bpp video modes into cache and video
memory.
**
** @param graphic Graphic structure for the tile
** @param cache Cache to fill with tile
@@ -884,20 +772,20 @@
**
** @see GRID
*/
-local void FillCache24AndDraw16(const unsigned char* data, VMemType24* cache,
+local void FillCache32AndDraw32(const unsigned char* data, VMemType32* cache,
int x, int y)
{
const unsigned char* sp;
const unsigned char* ep;
int va;
- VMemType24* dp;
- VMemType24* vp;
+ VMemType32* dp;
+ VMemType32* vp;
sp = data;
ep = sp + TileSizeY * TileSizeX - GRID_SUB;
dp = cache;
va = VideoWidth;
- vp = VideoMemory24 + x + y * VideoWidth;
+ vp = VideoMemory32 + x + y * VideoWidth;
#ifdef DEBUG
if (((long)sp) & 1) {
@@ -915,986 +803,29 @@
#undef UNROLL2
/// basic unroll code
#define UNROLL2(x) \
- vp[x + 0] = dp[x + 0] =
((VMemType24*)TheMap.TileData->Pixels)[sp[x + 0]]; \
- vp[x + 0] = dp[x + 1] =
((VMemType24*)TheMap.TileData->Pixels)[sp[x + 1]]
+ vp[x + 0] = dp[x + 0] =
((VMemType32*)TheMap.TileData->Pixels)[sp[x + 0]]; \
+ vp[x + 0] = dp[x + 1] =
((VMemType32*)TheMap.TileData->Pixels)[sp[x + 1]]
- UNROLL16(0);
+ UNROLL32(0);
#if GRID == 1
- vp[15] = dp[15] = ((VMemType24*)TheMap.TileData->Pixels)[0];
+ vp[31] = dp[31] = ((VMemType32*)TheMap.TileData->Pixels)[0];
#endif
vp += va;
sp += TileSizeX;
dp += TileSizeX;
}
-#if GRID == 1
- for (va = TileSizeX; va--;) { // no need to be fast with grid
- vp[va] = dp[va] = ((VMemType24*)TheMap.TileData->Pixels)[0];
- }
-#endif
-}
-
-/**
-** Draw 16x16 tile for 32 bpp video modes into cache and video
memory.
-**
-** @param graphic Graphic structure for the tile
-** @param cache Cache to fill with tile
-** @param x X position into video memory
-** @param y Y position into video memory
-**
-** @note This is a hot spot in the program.
-**
-** @see GRID
-*/
-local void FillCache32AndDraw16(const unsigned char* data, VMemType32* cache,
- int x, int y)
-{
- const unsigned char* sp;
- const unsigned char* ep;
- int va;
- VMemType32* dp;
- VMemType32* vp;
-
- sp = data;
- ep = sp + TileSizeY * TileSizeX - GRID_SUB;
- dp = cache;
- va = VideoWidth;
- vp = VideoMemory32 + x + y * VideoWidth;
-
-#ifdef DEBUG
- if (((long)sp) & 1) {
- DebugLevel0("Not aligned memory\n");
- }
- if (((long)dp) & 3) {
- DebugLevel0("Not aligned memory\n");
- }
- if (((long)vp) & 3) {
- DebugLevel0("Not aligned video memory\n");
- }
-#endif
-
- while (sp < ep) { // loop
unrolled
-#undef UNROLL2
- /// basic unroll code
-#define UNROLL2(x) \
- vp[x + 0] = dp[x + 0] =
((VMemType32*)TheMap.TileData->Pixels)[sp[x + 0]]; \
- vp[x + 0] = dp[x + 1] =
((VMemType32*)TheMap.TileData->Pixels)[sp[x + 1]]
-
- UNROLL16(0);
-#if GRID == 1
- vp[15] = dp[15] = ((VMemType32*)TheMap.TileData->Pixels)[0];
-#endif
- vp += va;
- sp += TileSizeX;
- dp += TileSizeX;
- }
-
-#if GRID == 1
- for (va = TileSizeX; va--;) { // no need to be fast with grid
- vp[va] = dp[va] = ((VMemType32*)TheMap.TileData->Pixels)[0];
- }
-#endif
-}
-
-/**
-** Draw 32x32 tile for 8 bpp video modes into cache and video
memory.
-**
-** @param graphic Graphic structure for the tile
-** @param cache Cache to fill with tile
-** @param x X position into video memory
-** @param y Y position into video memory
-**
-** @note This is a hot spot in the program.
-**
-** @see GRID
-*/
-local void FillCache8AndDraw32(const unsigned char* data, VMemType8* cache,
- int x, int y)
-{
- const unsigned char* sp;
- const unsigned char* ep;
- int va;
- VMemType8* dp;
- VMemType8* vp;
-
- sp = data;
- ep = sp + TileSizeY * TileSizeX - GRID_SUB;
- dp = cache;
- va = VideoWidth;
- vp = VideoMemory8 + x + y * VideoWidth;
-
-#ifdef DEBUG
- if (((long)sp) & 1) {
- DebugLevel0("Not aligned memory\n");
- }
- if (((long)dp) & 3) {
- DebugLevel0("Not aligned memory\n");
- }
- if (((long)vp) & 3) {
- DebugLevel0("Not aligned video memory\n");
- }
-#endif
-
- while (sp < ep) { // loop
unrolled
-#undef UNROLL2
- /// basic unroll code
-#define UNROLL2(x) \
- vp[x + 0] = dp[x + 0] =
((VMemType8*)TheMap.TileData->Pixels)[sp[x + 0]]; \
- vp[x + 0] = dp[x + 1] =
((VMemType8*)TheMap.TileData->Pixels)[sp[x + 1]]
-
- UNROLL32(0);
-#if GRID == 1
- vp[31] = dp[31] = ((VMemType8*)TheMap.TileData->Pixels)[0];
-#endif
- vp += va;
- sp += TileSizeX;
- dp += TileSizeX;
- }
-
-#if GRID == 1
- for (va = TileSizeX; va--;) { // no need to be fast with grid
- vp[va] = dp[va] = ((VMemType8*)TheMap.TileData->Pixels)[0];
- }
-#endif
-}
-
-/**
-** Draw 32x32 tile for 16 bpp video modes into cache and video
memory.
-**
-** @param graphic Graphic structure for the tile
-** @param cache Cache to fill with tile
-** @param x X position into video memory
-** @param y Y position into video memory
-**
-** @note This is a hot spot in the program.
-**
-** @see GRID
-*/
-local void FillCache16AndDraw32(const unsigned char* data, VMemType16* cache,
- int x, int y)
-{
- const unsigned char* sp;
- const unsigned char* ep;
- int va;
- VMemType16* dp;
- VMemType16* vp;
-
- sp = data;
- ep = sp + TileSizeY * TileSizeX - GRID_SUB;
- dp = cache;
- va = VideoWidth;
- vp = VideoMemory16 + x + y * VideoWidth;
-
-#ifdef DEBUG
- if (((long)sp) & 1) {
- DebugLevel0("Not aligned memory\n");
- }
- if (((long)dp) & 3) {
- DebugLevel0("Not aligned memory\n");
- }
- if (((long)vp) & 3) {
- DebugLevel0("Not aligned video memory\n");
- }
-#endif
-
- while (sp < ep) { // loop
unrolled
-#undef UNROLL2
- /// basic unroll code
-#define UNROLL2(x) \
- *(unsigned int*)(vp + x + 0) = *(unsigned int*)(dp + x + 0)
= \
- PixelsLow[sp[x + 0]] | PixelsHigh[sp[x + 1]]
-
- UNROLL32(0);
-#if GRID == 1
- vp[31] = dp[31] = Pixels[0];
-#endif
- vp += va;
- sp += TileSizeX;
- dp += TileSizeX;
- }
-
-#if GRID == 1
- for (va = TileSizeX; va--;) { // no need to be fast with grid
- vp[va] = dp[va] = Pixels[0];
- }
-#endif
-}
-
-/**
-** Draw 32x32 tile for 24 bpp video modes into cache and video
memory.
-**
-** @param graphic Graphic structure for the tile
-** @param cache Cache to fill with tile
-** @param x X position into video memory
-** @param y Y position into video memory
-**
-** @note This is a hot spot in the program.
-**
-** @see GRID
-*/
-local void FillCache24AndDraw32(const unsigned char* data, VMemType24* cache,
- int x, int y)
-{
- const unsigned char* sp;
- const unsigned char* ep;
- int va;
- VMemType24* dp;
- VMemType24* vp;
-
- sp = data;
- ep = sp + TileSizeY * TileSizeX - GRID_SUB;
- dp = cache;
- va = VideoWidth;
- vp = VideoMemory24 + x + y * VideoWidth;
-
-#ifdef DEBUG
- if (((long)sp) & 1) {
- DebugLevel0("Not aligned memory\n");
- }
- if (((long)dp) & 3) {
- DebugLevel0("Not aligned memory\n");
- }
- if (((long)vp) & 3) {
- DebugLevel0("Not aligned video memory\n");
- }
-#endif
-
- while (sp < ep) { // loop
unrolled
-#undef UNROLL2
- /// basic unroll code
-#define UNROLL2(x) \
- vp[x + 0] = dp[x + 0] =
((VMemType24*)TheMap.TileData->Pixels)[sp[x + 0]]; \
- vp[x + 0] = dp[x + 1] =
((VMemType24*)TheMap.TileData->Pixels)[sp[x + 1]]
-
- UNROLL32(0);
-#if GRID == 1
- vp[31] = dp[31] = ((VMemType24*)TheMap.TileData->Pixels)[0];
-#endif
- vp += va;
- sp += TileSizeX;
- dp += TileSizeX;
- }
-
-#if GRID == 1
- for (va = TileSizeX; va--;) { // no need to be fast with grid
- vp[va] = dp[va] = ((VMemType24*)TheMap.TileData->Pixels)[0];
- }
-#endif
-}
-
-/**
-** Draw 32x32 tile for 32 bpp video modes into cache and video
memory.
-**
-** @param graphic Graphic structure for the tile
-** @param cache Cache to fill with tile
-** @param x X position into video memory
-** @param y Y position into video memory
-**
-** @note This is a hot spot in the program.
-**
-** @see GRID
-*/
-local void FillCache32AndDraw32(const unsigned char* data, VMemType32* cache,
- int x, int y)
-{
- const unsigned char* sp;
- const unsigned char* ep;
- int va;
- VMemType32* dp;
- VMemType32* vp;
-
- sp = data;
- ep = sp + TileSizeY * TileSizeX - GRID_SUB;
- dp = cache;
- va = VideoWidth;
- vp = VideoMemory32 + x + y * VideoWidth;
-
-#ifdef DEBUG
- if (((long)sp) & 1) {
- DebugLevel0("Not aligned memory\n");
- }
- if (((long)dp) & 3) {
- DebugLevel0("Not aligned memory\n");
- }
- if (((long)vp) & 3) {
- DebugLevel0("Not aligned video memory\n");
- }
-#endif
-
- while (sp < ep) { // loop
unrolled
-#undef UNROLL2
- /// basic unroll code
-#define UNROLL2(x) \
- vp[x + 0] = dp[x + 0] =
((VMemType32*)TheMap.TileData->Pixels)[sp[x + 0]]; \
- vp[x + 0] = dp[x + 1] =
((VMemType32*)TheMap.TileData->Pixels)[sp[x + 1]]
-
- UNROLL32(0);
-#if GRID == 1
- vp[31] = dp[31] = ((VMemType32*)TheMap.TileData->Pixels)[0];
-#endif
- vp += va;
- sp += TileSizeX;
- dp += TileSizeX;
- }
-
-#if GRID == 1
- for (va = TileSizeX; va--;) { // no need to be fast with grid
- vp[va] = dp[va] = ((VMemType32*)TheMap.TileData->Pixels)[0];
- }
-#endif
-}
-
-// ---------------------------------------------------------------------------
-
-/**
-** Fast draw 16x16 tile from cache for 8bpp.
-**
-** @param graphic Pointer to cached tile graphic
-** @param x X position into video memory
-** @param y Y position into video memory
-**
-** @see GRID
-*/
-local void VideoDraw8Tile16FromCache(const VMemType8* graphic, int x, int y)
-{
- const VMemType8* sp;
- const VMemType8* ep;
- VMemType8* dp;
- int da;
-
- sp = graphic;
- ep = sp + TileSizeY * TileSizeX;
- da = VideoWidth;
- dp = VideoMemory8 + x + y * VideoWidth;
-
-#ifdef DEBUG
- if (((long)dp) & 3) {
- DebugLevel0("Not aligned memory\n");
- }
- if (((long)sp) & 3) {
- DebugLevel0("Not aligned memory\n");
- }
-#endif
-
- while (sp < ep) { // loop
unrolled
-#undef UNROLL2
- /// basic unroll code
-#define UNROLL2(x) \
- *(unsigned long*)(dp + x) = *(unsigned long*)(sp + x)
-
- UNROLL8(0);
- sp += TileSizeX;
- dp += da;
- }
-}
-
-/**
-** Fast draw 16x16 tile from cache for 16bpp.
-**
-** @param graphic Pointer to cached tile graphic
-** @param x X position into video memory
-** @param y Y position into video memory
-**
-** @see GRID
-*/
-local void VideoDraw16Tile16FromCache(const VMemType16* graphic, int x, int y)
-{
- const VMemType16* sp;
- const VMemType16* ep;
- VMemType16* dp;
- int da;
-
- sp = graphic;
- ep = sp + TileSizeY * TileSizeX;
- da = VideoWidth;
- dp = VideoMemory16 + x + y * VideoWidth;
-
-#ifdef DEBUG
- if (((long)dp) & 3) {
- DebugLevel0("Not aligned memory\n");
- }
- if (((long)sp) & 3) {
- DebugLevel0("Not aligned memory\n");
- }
-#endif
-
- while (sp < ep) { // loop
unrolled
-#undef UNROLL2
- /// basic unroll code
-#define UNROLL2(x) \
- *(unsigned long*)(dp + x) = *(unsigned long*)(sp + x)
-
- UNROLL16(0);
- sp += TileSizeX;
- dp += da;
- }
-}
-
-/**
-** Fast draw 16x16 tile from cache for 24bpp.
-**
-** @param graphic Pointer to cached tile graphic
-** @param x X position into video memory
-** @param y Y position into video memory
-**
-** @see GRID
-*/
-local void VideoDraw24Tile16FromCache(const VMemType24* graphic, int x, int y)
-{
- const VMemType24* sp;
- const VMemType24* ep;
- VMemType24* dp;
- int da;
-
- sp = graphic;
- ep = sp + TileSizeY * TileSizeX;
- da = VideoWidth;
- dp = VideoMemory24 + x + y * VideoWidth;
-
-#ifdef DEBUG
- if (((long)dp) & 3) {
- DebugLevel0("Not aligned memory\n");
- }
- if (((long)sp) & 3) {
- DebugLevel0("Not aligned memory\n");
- }
-#endif
-
- while (sp < ep) { // loop
unrolled
-#undef UNROLL2
- /// basic unroll code
-#define UNROLL2(x) \
- *(unsigned long*)(dp + x * 2 + 0) = *(unsigned long*)(sp + x *
2 + 0); \
- *(unsigned long*)(dp + x * 2 + 1) = *(unsigned long*)(sp + x *
2 + 1)
-
- UNROLL12(0);
- sp += TileSizeX;
- dp += da;
- }
-}
-
-/**
-** Fast draw 16x16 tile from cache.
-**
-** @param graphic Pointer to cached tile graphic
-** @param x X position into video memory
-** @param y Y position into video memory
-**
-** @see GRID
-*/
-local void VideoDraw32Tile16FromCache(const VMemType32* graphic, int x, int y)
-{
- const VMemType32* sp;
- const VMemType32* ep;
- VMemType32* dp;
- int da;
-
- sp = graphic;
- ep = sp + TileSizeY * TileSizeX;
- da = VideoWidth;
- dp = VideoMemory32 + x + y * VideoWidth;
-
-#ifdef DEBUG
- if (((long)dp) & 3) {
- DebugLevel0("Not aligned memory\n");
- }
- if (((long)sp) & 3) {
- DebugLevel0("Not aligned memory\n");
- }
-#endif
-
- while (sp < ep) { // loop
unrolled
-#undef UNROLL2
- /// basic unroll code
-#define UNROLL2(x) \
- *(unsigned long*)(dp + x * 2 + 0) = *(unsigned long*)(sp + x *
2 + 0); \
- *(unsigned long*)(dp + x * 2 + 1) = *(unsigned long*)(sp + x *
2 + 1)
-
- UNROLL16(0);
- sp += TileSizeX;
- dp += da;
- }
-}
-
-/**
-** Fast draw 32x32 tile from cache for 8bpp.
-**
-** @param graphic Pointer to cached tile graphic
-** @param x X position into video memory
-** @param y Y position into video memory
-**
-** @see GRID
-*/
-local void VideoDraw8Tile32FromCache(const VMemType8* graphic, int x, int y)
-{
- const VMemType8* sp;
- const VMemType8* ep;
- VMemType8* dp;
- int da;
-
- sp = graphic;
- ep = sp + TileSizeY * TileSizeX;
- da = VideoWidth;
- dp = VideoMemory8 + x + y * VideoWidth;
-
-#ifdef DEBUG
- if (((long)dp) & 3) {
- DebugLevel0("Not aligned memory\n");
- }
- if (((long)sp) & 3) {
- DebugLevel0("Not aligned memory\n");
- }
-#endif
-
- while (sp < ep) { // loop
unrolled
-#undef UNROLL2
- /// basic unroll code
-#define UNROLL2(x) \
- *(unsigned long*)(dp + x) = *(unsigned long*)(sp + x)
-
- UNROLL16(0);
- sp += TileSizeX;
- dp += da;
- }
-}
-
-/**
-** Fast draw 32x32 tile from cache for 16bpp.
-**
-** @param graphic Pointer to cached tile graphic
-** @param x X position into video memory
-** @param y Y position into video memory
-**
-** @see GRID
-*/
-local void VideoDraw16Tile32FromCache(const VMemType16* graphic, int x, int y)
-{
- const VMemType16* sp;
- const VMemType16* ep;
- VMemType16* dp;
- int da;
-
- sp = graphic;
- ep = sp + TileSizeY * TileSizeX;
- da = VideoWidth;
- dp = VideoMemory16 + x + y * VideoWidth;
-
-#ifdef DEBUG
- if (((long)dp) & 3) {
- DebugLevel0("Not aligned memory\n");
- }
- if (((long)sp) & 3) {
- DebugLevel0("Not aligned memory\n");
- }
-#endif
-
- while (sp < ep) { // loop
unrolled
-#undef UNROLL2
- /// basic unroll code
-#define UNROLL2(x) \
- *(unsigned long*)(dp + x) = *(unsigned long*)(sp + x)
-
- UNROLL32(0);
- sp += TileSizeX;
- dp += da;
- }
-}
-
-/**
-** Fast draw 32x32 tile from cache for 24bpp.
-**
-** @param graphic Pointer to cached tile graphic
-** @param x X position into video memory
-** @param y Y position into video memory
-**
-** @see GRID
-*/
-local void VideoDraw24Tile32FromCache(const VMemType24* graphic, int x, int y)
-{
- const VMemType24* sp;
- const VMemType24* ep;
- VMemType24* dp;
- int da;
-
- sp = graphic;
- ep = sp + TileSizeY * TileSizeX;
- da = VideoWidth;
- dp = VideoMemory24 + x + y * VideoWidth;
-
-#ifdef DEBUG
- if (((long)dp) & 3) {
- DebugLevel0("Not aligned memory\n");
- }
- if (((long)sp) & 3) {
- DebugLevel0("Not aligned memory\n");
- }
-#endif
-
- while (sp < ep) { // loop
unrolled
-#undef UNROLL2
- /// basic unroll code
-#define UNROLL2(x) \
- *(unsigned long*)(dp + x * 2 + 0) = *(unsigned long*)(sp + x *
2 + 0); \
- *(unsigned long*)(dp + x * 2 + 1) = *(unsigned long*)(sp + x *
2 + 1)
-
- UNROLL24(0);
- sp += TileSizeX;
- dp += da;
- }
-}
-
-/**
-** Fast draw 32x32 tile from cache.
-**
-** @param graphic Pointer to cached tile graphic
-** @param x X position into video memory
-** @param y Y position into video memory
-**
-** @see GRID
-*/
-local void VideoDraw32Tile32FromCache(const VMemType32* graphic, int x, int y)
-{
- const VMemType32* sp;
- const VMemType32* ep;
- VMemType32* dp;
- int da;
-
- sp = graphic;
- ep = sp + TileSizeY * TileSizeX;
- da = VideoWidth;
- dp = VideoMemory32 + x + y * VideoWidth;
-
-#ifdef DEBUG
- if (((long)dp) & 3) {
- DebugLevel0("Not aligned memory\n");
- }
- if (((long)sp) & 3) {
- DebugLevel0("Not aligned memory\n");
- }
-#endif
-
- while (sp < ep) { // loop
unrolled
-#undef UNROLL2
- /// basic unroll code
-#define UNROLL2(x) \
- *(unsigned long*)(dp + x * 2 + 0) = *(unsigned long*)(sp + x *
2 + 0); \
- *(unsigned long*)(dp + x * 2 + 1) = *(unsigned long*)(sp + x *
2 + 1)
-
- UNROLL32(0);
- sp += TileSizeX;
- dp += da;
- }
-}
-
-// ---------------------------------------------------------------------------
-
-/**
-** Draw 16x16 tile for 8 bpp video modes with cache support.
-**
-** @param tile Tile number to draw.
-** @param x X position into video memory
-** @param y Y position into video memory
-*/
-local void MapDraw8Tile16(int tile, int x, int y)
-{
- TileCache* cache;
-
- if (!(cache = TileCached[tile])) {
- //
- // Not cached
- //
- if (TileCacheSize) { // enough cache
buffers?
- --TileCacheSize;
- cache = malloc(sizeof(TileCache) - sizeof(unsigned
char) +
- TileSizeX * TileSizeY * sizeof(VMemType16));
- } else {
- cache = (void*)TileCacheLRU->last;
- if (cache->Tile) {
- TileCached[cache->Tile] = NULL; // now
not cached
- }
- dl_remove_last(TileCacheLRU);
- DebugLevel3("EMPTY CACHE\n");
- }
- TileCached[tile] = cache;
- cache->Tile = tile;
- dl_insert_first(TileCacheLRU, &cache->DlNode);
-
- FillCache8AndDraw16(TheMap.Tiles[tile], (void*)&cache->Buffer,
x, y);
- } else {
- VideoDraw8Tile16FromCache((void*)&cache->Buffer, x, y);
- }
-}
-
-/**
-** Draw 16x16 tile for 16 bpp video modes with cache support.
-**
-** @param tile Tile number to draw.
-** @param x X position into video memory
-** @param y Y position into video memory
-*/
-local void MapDraw16Tile16(int tile, int x, int y)
-{
- TileCache* cache;
-
- if (!(cache = TileCached[tile])) {
- //
- // Not cached
- //
- if (TileCacheSize) { // enough cache
buffers?
- --TileCacheSize;
- cache = malloc(sizeof(TileCache) - sizeof(unsigned
char) +
- TileSizeX * TileSizeY * sizeof(VMemType16));
- } else {
- cache = (void*)TileCacheLRU->last;
- if (cache->Tile) {
- TileCached[cache->Tile] = NULL; // now
not cached
- }
- dl_remove_last(TileCacheLRU);
- DebugLevel3("EMPTY CACHE\n");
- }
- TileCached[tile] = cache;
- cache->Tile = tile;
- dl_insert_first(TileCacheLRU, &cache->DlNode);
-
- FillCache16AndDraw16(TheMap.Tiles[tile], (void*)&cache->Buffer,
x, y);
- } else {
- VideoDraw16Tile16FromCache((void*)&cache->Buffer, x, y);
- }
-}
-
-/**
-** Draw 16x16 tile for 24 bpp video modes with cache support.
-**
-** @param tile Tile number to draw.
-** @param x X position into video memory
-** @param y Y position into video memory
-*/
-local void MapDraw24Tile16(int tile, int x, int y)
-{
- TileCache* cache;
-
- if (!(cache = TileCached[tile])) {
- //
- // Not cached
- //
- if (TileCacheSize) { // enough cache
buffers?
- --TileCacheSize;
- cache = malloc(sizeof(TileCache) - sizeof(unsigned
char) +
- TileSizeX * TileSizeY * sizeof(VMemType24));
- } else {
- cache = (void*)TileCacheLRU->last;
- if (cache->Tile) {
- TileCached[cache->Tile] = NULL; // now
not cached
- }
- dl_remove_last(TileCacheLRU);
- DebugLevel3("EMPTY CACHE\n");
- }
- TileCached[tile] = cache;
- cache->Tile = tile;
- dl_insert_first(TileCacheLRU, &cache->DlNode);
-
- FillCache24AndDraw16(TheMap.Tiles[tile], (void*)&cache->Buffer,
x, y);
- } else {
- VideoDraw24Tile16FromCache((void*)&cache->Buffer, x, y);
- }
-}
-
-/**
-** Draw 16x16 tile for 32 bpp video modes with cache support.
-**
-** @param tile Tile number to draw.
-** @param x X position into video memory
-** @param y Y position into video memory
-*/
-local void MapDraw32Tile16(int tile, int x, int y)
-{
- TileCache* cache;
-
- if (!(cache = TileCached[tile])) {
- //
- // Not cached
- //
- if (TileCacheSize) { // enough cache
buffers?
- --TileCacheSize;
- cache = malloc(sizeof(TileCache) - sizeof(unsigned
char) +
- TileSizeX * TileSizeY * sizeof(VMemType32));
- } else {
- cache = (void*)TileCacheLRU->last;
- if (cache->Tile) {
- TileCached[cache->Tile] = NULL; // now
not cached
- }
- dl_remove_last(TileCacheLRU);
- DebugLevel3("EMPTY CACHE\n");
- }
- TileCached[tile] = cache;
- cache->Tile = tile;
- dl_insert_first(TileCacheLRU, &cache->DlNode);
-
- FillCache32AndDraw16(TheMap.Tiles[tile], (void*)&cache->Buffer,
x, y);
- } else {
- VideoDraw32Tile16FromCache((void*)&cache->Buffer, x, y);
- }
-}
-
-/**
-** Draw 32x32 tile for 8 bpp video modes with cache support.
-**
-** @param tile Tile number to draw.
-** @param x X position into video memory
-** @param y Y position into video memory
-*/
-local void MapDraw8Tile32(int tile, int x, int y)
-{
- TileCache* cache;
-
- if (!(cache = TileCached[tile])) {
- //
- // Not cached
- //
- if (TileCacheSize) { // enough cache
buffers?
- --TileCacheSize;
- cache = malloc(sizeof(TileCache) - sizeof(unsigned
char) +
- TileSizeX * TileSizeY * sizeof(VMemType16));
- } else {
- cache = (void*)TileCacheLRU->last;
- if (cache->Tile) {
- TileCached[cache->Tile] = NULL; // now
not cached
- }
- dl_remove_last(TileCacheLRU);
- DebugLevel3("EMPTY CACHE\n");
- }
- TileCached[tile] = cache;
- cache->Tile = tile;
- dl_insert_first(TileCacheLRU, &cache->DlNode);
-
- FillCache8AndDraw32(TheMap.Tiles[tile], (void*)&cache->Buffer,
x, y);
- } else {
- VideoDraw8Tile32FromCache((void*)&cache->Buffer, x, y);
- }
-}
-
-/**
-** Draw 32x32 tile for 16 bpp video modes with cache support.
-**
-** @param tile Tile number to draw.
-** @param x X position into video memory
-** @param y Y position into video memory
-*/
-local void MapDraw16Tile32(int tile, int x, int y)
-{
- TileCache* cache;
-
- if (!(cache = TileCached[tile])) {
- //
- // Not cached
- //
- if (TileCacheSize) { // enough cache
buffers?
- --TileCacheSize;
- cache = malloc(sizeof(TileCache) - sizeof(unsigned
char) +
- TileSizeX * TileSizeY * sizeof(VMemType16));
- } else {
- cache = (void*)TileCacheLRU->last;
- if (cache->Tile) {
- TileCached[cache->Tile] = NULL; // now
not cached
- }
- dl_remove_last(TileCacheLRU);
- DebugLevel3("EMPTY CACHE\n");
- }
- TileCached[tile] = cache;
- cache->Tile = tile;
- dl_insert_first(TileCacheLRU, &cache->DlNode);
-
- FillCache16AndDraw32(TheMap.Tiles[tile], (void*)&cache->Buffer,
x, y);
- } else {
- VideoDraw16Tile32FromCache((void*)&cache->Buffer, x, y);
- }
-}
-
-/**
-** Draw 32x32 tile for 24 bpp video modes with cache support.
-**
-** @param tile Tile number to draw.
-** @param x X position into video memory
-** @param y Y position into video memory
-*/
-local void MapDraw24Tile32(int tile, int x, int y)
-{
- TileCache* cache;
-
- if (!(cache = TileCached[tile])) {
- //
- // Not cached
- //
- if (TileCacheSize) { // enough cache
buffers?
- --TileCacheSize;
- cache = malloc(sizeof(TileCache) - sizeof(unsigned
char) +
- TileSizeX * TileSizeY * sizeof(VMemType24));
- } else {
- cache = (void*)TileCacheLRU->last;
- if (cache->Tile) {
- TileCached[cache->Tile] = NULL; // now
not cached
- }
- dl_remove_last(TileCacheLRU);
- DebugLevel3("EMPTY CACHE\n");
- }
- TileCached[tile] = cache;
- cache->Tile = tile;
- dl_insert_first(TileCacheLRU, &cache->DlNode);
-
- FillCache24AndDraw32(TheMap.Tiles[tile], (void*)&cache->Buffer,
x, y);
- } else {
- VideoDraw24Tile32FromCache((void*)&cache->Buffer, x, y);
- }
-}
-
-/**
-** Draw 32x32 tile for 32 bpp video modes with cache support.
-**
-** @param tile Tile number to draw.
-** @param x X position into video memory
-** @param y Y position into video memory
-*/
-local void MapDraw32Tile32(int tile, int x, int y)
-{
- TileCache* cache;
-
- if (!(cache = TileCached[tile])) {
- //
- // Not cached
- //
- if (TileCacheSize) { // enough cache
buffers?
- --TileCacheSize;
- cache = malloc(sizeof(TileCache) - sizeof(unsigned
char) +
- TileSizeX * TileSizeY * sizeof(VMemType32));
- } else {
- cache = (void*)TileCacheLRU->last;
- if (cache->Tile) {
- TileCached[cache->Tile] = NULL; // now
not cached
- }
- dl_remove_last(TileCacheLRU);
- DebugLevel3("EMPTY CACHE\n");
- }
- TileCached[tile] = cache;
- cache->Tile = tile;
- dl_insert_first(TileCacheLRU, &cache->DlNode);
-
- FillCache32AndDraw32(TheMap.Tiles[tile], (void*)&cache->Buffer,
x, y);
- } else {
- VideoDraw32Tile32FromCache((void*)&cache->Buffer, x, y);
- }
-}
-
-#endif // } USE_TILECACHE
-
-/*----------------------------------------------------------------------------
--- Smart Cache
-----------------------------------------------------------------------------*/
+#if GRID == 1
+ for (va = TileSizeX; va--;) { // no need to be fast with grid
+ vp[va] = dp[va] = ((VMemType32*)TheMap.TileData->Pixels)[0];
+ }
+#endif
+}
-#ifdef USE_SMART_TILECACHE // {
+// ---------------------------------------------------------------------------
-#ifndef USE_SDL_SURFACE
/**
-** Fast draw 16x16 tile for 8 bpp from cache.
+** Fast draw 16x16 tile from cache for 8bpp.
**
** @param graphic Pointer to cached tile graphic
** @param x X position into video memory
@@ -1902,7 +833,7 @@
**
** @see GRID
*/
-local void VideoDraw8Tile16Cached(const VMemType8* graphic, int x, int y)
+local void VideoDraw8Tile16FromCache(const VMemType8* graphic, int x, int y)
{
const VMemType8* sp;
const VMemType8* ep;
@@ -1910,29 +841,33 @@
int da;
sp = graphic;
+ ep = sp + TileSizeY * TileSizeX;
da = VideoWidth;
- ep = sp + TileSizeX + TileSizeY * da;
- dp = VideoMemory8 + x + y * da;
+ dp = VideoMemory8 + x + y * VideoWidth;
+
+#ifdef DEBUG
+ if (((long)dp) & 3) {
+ DebugLevel0("Not aligned memory\n");
+ }
+ if (((long)sp) & 3) {
+ DebugLevel0("Not aligned memory\n");
+ }
+#endif
while (sp < ep) { // loop
unrolled
#undef UNROLL2
/// basic unroll code
#define UNROLL2(x) \
- ((unsigned long*)dp)[x + 0] = ((unsigned long*)sp)[x + 0]; \
- ((unsigned long*)dp)[x + 1] = ((unsigned long*)sp)[x + 1]
-
- UNROLL4(0);
- sp += da;
- dp += da;
+ *(unsigned long*)(dp + x) = *(unsigned long*)(sp + x)
- UNROLL4(0);
- sp += da;
+ UNROLL8(0);
+ sp += TileSizeX;
dp += da;
}
}
/**
-** Fast draw 16x16 tile for 16 bpp from cache.
+** Fast draw 16x16 tile from cache for 16bpp.
**
** @param graphic Pointer to cached tile graphic
** @param x X position into video memory
@@ -1940,7 +875,7 @@
**
** @see GRID
*/
-local void VideoDraw16Tile16Cached(const VMemType16* graphic, int x, int y)
+local void VideoDraw16Tile16FromCache(const VMemType16* graphic, int x, int y)
{
const VMemType16* sp;
const VMemType16* ep;
@@ -1948,9 +883,18 @@
int da;
sp = graphic;
+ ep = sp + TileSizeY * TileSizeX;
da = VideoWidth;
- ep = sp+TileSizeY * da;
- dp = VideoMemory16 + x + y * da;
+ dp = VideoMemory16 + x + y * VideoWidth;
+
+#ifdef DEBUG
+ if (((long)dp) & 3) {
+ DebugLevel0("Not aligned memory\n");
+ }
+ if (((long)sp) & 3) {
+ DebugLevel0("Not aligned memory\n");
+ }
+#endif
while (sp < ep) { // loop
unrolled
#undef UNROLL2
@@ -1959,17 +903,13 @@
*(unsigned long*)(dp + x) = *(unsigned long*)(sp + x)
UNROLL16(0);
- sp += da;
- dp += da;
-
- UNROLL16(0);
- sp += da;
+ sp += TileSizeX;
dp += da;
}
}
/**
-** Fast draw 16x16 tile for 24 bpp from cache.
+** Fast draw 16x16 tile from cache for 24bpp.
**
** @param graphic Pointer to cached tile graphic
** @param x X position into video memory
@@ -1977,7 +917,7 @@
**
** @see GRID
*/
-local void VideoDraw24Tile16Cached(const VMemType24* graphic, int x, int y)
+local void VideoDraw24Tile16FromCache(const VMemType24* graphic, int x, int y)
{
const VMemType24* sp;
const VMemType24* ep;
@@ -1985,29 +925,34 @@
int da;
sp = graphic;
+ ep = sp + TileSizeY * TileSizeX;
da = VideoWidth;
- ep = sp + TileSizeX + TileSizeY * da;
- dp = VideoMemory24 + x + y * da;
+ dp = VideoMemory24 + x + y * VideoWidth;
+
+#ifdef DEBUG
+ if (((long)dp) & 3) {
+ DebugLevel0("Not aligned memory\n");
+ }
+ if (((long)sp) & 3) {
+ DebugLevel0("Not aligned memory\n");
+ }
+#endif
while (sp < ep) { // loop
unrolled
#undef UNROLL2
/// basic unroll code
#define UNROLL2(x) \
- *((unsigned long*)dp + x + 0) = *((unsigned long*)sp + x + 0);
\
- *((unsigned long*)dp + x + 1) = *((unsigned long*)sp + x + 1)
-
- UNROLL12(0);
- sp += da;
- dp += da;
+ *(unsigned long*)(dp + x * 2 + 0) = *(unsigned long*)(sp + x *
2 + 0); \
+ *(unsigned long*)(dp + x * 2 + 1) = *(unsigned long*)(sp + x *
2 + 1)
UNROLL12(0);
- sp += da;
+ sp += TileSizeX;
dp += da;
}
}
/**
-** Fast draw 16x16 tile for 32 bpp from cache.
+** Fast draw 16x16 tile from cache.
**
** @param graphic Pointer to cached tile graphic
** @param x X position into video memory
@@ -2015,7 +960,7 @@
**
** @see GRID
*/
-local void VideoDraw32Tile16Cached(const VMemType32* graphic, int x, int y)
+local void VideoDraw32Tile16FromCache(const VMemType32* graphic, int x, int y)
{
const VMemType32* sp;
const VMemType32* ep;
@@ -2023,29 +968,34 @@
int da;
sp = graphic;
+ ep = sp + TileSizeY * TileSizeX;
da = VideoWidth;
- ep = sp + TileSizeX + TileSizeY * da;
- dp = VideoMemory32+x + y * da;
+ dp = VideoMemory32 + x + y * VideoWidth;
+
+#ifdef DEBUG
+ if (((long)dp) & 3) {
+ DebugLevel0("Not aligned memory\n");
+ }
+ if (((long)sp) & 3) {
+ DebugLevel0("Not aligned memory\n");
+ }
+#endif
while (sp < ep) { // loop
unrolled
#undef UNROLL2
/// basic unroll code
#define UNROLL2(x) \
- *(dp + x * 2 + 0) = *(sp + x * 2 + 0); \
- *(dp + x * 2 + 1) = *(sp + x * 2 + 1)
-
- UNROLL16(0);
- sp += da;
- dp += da;
+ *(unsigned long*)(dp + x * 2 + 0) = *(unsigned long*)(sp + x *
2 + 0); \
+ *(unsigned long*)(dp + x * 2 + 1) = *(unsigned long*)(sp + x *
2 + 1)
UNROLL16(0);
- sp += da;
+ sp += TileSizeX;
dp += da;
}
}
/**
-** Fast draw 32x32 tile for 8 bpp from cache.
+** Fast draw 32x32 tile from cache for 8bpp.
**
** @param graphic Pointer to cached tile graphic
** @param x X position into video memory
@@ -2053,7 +1003,7 @@
**
** @see GRID
*/
-local void VideoDraw8Tile32Cached(const VMemType8* graphic, int x, int y)
+local void VideoDraw8Tile32FromCache(const VMemType8* graphic, int x, int y)
{
const VMemType8* sp;
const VMemType8* ep;
@@ -2061,29 +1011,33 @@
int da;
sp = graphic;
+ ep = sp + TileSizeY * TileSizeX;
da = VideoWidth;
- ep = sp + TileSizeX + TileSizeY * da;
- dp = VideoMemory8 + x + y * da;
+ dp = VideoMemory8 + x + y * VideoWidth;
+
+#ifdef DEBUG
+ if (((long)dp) & 3) {
+ DebugLevel0("Not aligned memory\n");
+ }
+ if (((long)sp) & 3) {
+ DebugLevel0("Not aligned memory\n");
+ }
+#endif
while (sp < ep) { // loop
unrolled
#undef UNROLL2
/// basic unroll code
#define UNROLL2(x) \
- ((unsigned long*)dp)[x + 0] = ((unsigned long*)sp)[x + 0]; \
- ((unsigned long*)dp)[x + 1] = ((unsigned long*)sp)[x + 1]
-
- UNROLL8(0);
- sp += da;
- dp += da;
+ *(unsigned long*)(dp + x) = *(unsigned long*)(sp + x)
- UNROLL8(0);
- sp += da;
+ UNROLL16(0);
+ sp += TileSizeX;
dp += da;
}
}
/**
-** Fast draw 32x32 tile for 16 bpp from cache.
+** Fast draw 32x32 tile from cache for 16bpp.
**
** @param graphic Pointer to cached tile graphic
** @param x X position into video memory
@@ -2091,7 +1045,7 @@
**
** @see GRID
*/
-local void VideoDraw16Tile32Cached(const VMemType16* graphic, int x, int y)
+local void VideoDraw16Tile32FromCache(const VMemType16* graphic, int x, int y)
{
const VMemType16* sp;
const VMemType16* ep;
@@ -2099,9 +1053,18 @@
int da;
sp = graphic;
+ ep = sp + TileSizeY * TileSizeX;
da = VideoWidth;
- ep = sp + TileSizeY * da;
- dp = VideoMemory16 + x + y * da;
+ dp = VideoMemory16 + x + y * VideoWidth;
+
+#ifdef DEBUG
+ if (((long)dp) & 3) {
+ DebugLevel0("Not aligned memory\n");
+ }
+ if (((long)sp) & 3) {
+ DebugLevel0("Not aligned memory\n");
+ }
+#endif
while (sp < ep) { // loop
unrolled
#undef UNROLL2
@@ -2110,17 +1073,13 @@
*(unsigned long*)(dp + x) = *(unsigned long*)(sp + x)
UNROLL32(0);
- sp += da;
- dp += da;
-
- UNROLL32(0);
- sp += da;
+ sp += TileSizeX;
dp += da;
}
}
/**
-** Fast draw 32x32 tile for 24 bpp from cache.
+** Fast draw 32x32 tile from cache for 24bpp.
**
** @param graphic Pointer to cached tile graphic
** @param x X position into video memory
@@ -2128,7 +1087,7 @@
**
** @see GRID
*/
-local void VideoDraw24Tile32Cached(const VMemType24* graphic, int x, int y)
+local void VideoDraw24Tile32FromCache(const VMemType24* graphic, int x, int y)
{
const VMemType24* sp;
const VMemType24* ep;
@@ -2136,29 +1095,34 @@
int da;
sp = graphic;
+ ep = sp + TileSizeY * TileSizeX;
da = VideoWidth;
- ep = sp + TileSizeX + TileSizeY * da;
- dp = VideoMemory24 + x + y * da;
+ dp = VideoMemory24 + x + y * VideoWidth;
+
+#ifdef DEBUG
+ if (((long)dp) & 3) {
+ DebugLevel0("Not aligned memory\n");
+ }
+ if (((long)sp) & 3) {
+ DebugLevel0("Not aligned memory\n");
+ }
+#endif
while (sp < ep) { // loop
unrolled
#undef UNROLL2
/// basic unroll code
#define UNROLL2(x) \
- *((unsigned long*)dp + x + 0) = *((unsigned long*)sp + x + 0);
\
- *((unsigned long*)dp + x + 1) = *((unsigned long*)sp + x + 1)
-
- UNROLL24(0);
- sp += da;
- dp += da;
+ *(unsigned long*)(dp + x * 2 + 0) = *(unsigned long*)(sp + x *
2 + 0); \
+ *(unsigned long*)(dp + x * 2 + 1) = *(unsigned long*)(sp + x *
2 + 1)
UNROLL24(0);
- sp += da;
+ sp += TileSizeX;
dp += da;
}
}
/**
-** Fast draw 32x32 tile for 32 bpp from cache.
+** Fast draw 32x32 tile from cache.
**
** @param graphic Pointer to cached tile graphic
** @param x X position into video memory
@@ -2166,7 +1130,7 @@
**
** @see GRID
*/
-local void VideoDraw32Tile32Cached(const VMemType32* graphic, int x, int y)
+local void VideoDraw32Tile32FromCache(const VMemType32* graphic, int x, int y)
{
const VMemType32* sp;
const VMemType32* ep;
@@ -2174,117 +1138,105 @@
int da;
sp = graphic;
+ ep = sp + TileSizeY * TileSizeX;
da = VideoWidth;
- ep = sp + TileSizeX + TileSizeY * da;
- dp = VideoMemory32 + x + y * da;
+ dp = VideoMemory32 + x + y * VideoWidth;
+
+#ifdef DEBUG
+ if (((long)dp) & 3) {
+ DebugLevel0("Not aligned memory\n");
+ }
+ if (((long)sp) & 3) {
+ DebugLevel0("Not aligned memory\n");
+ }
+#endif
while (sp < ep) { // loop
unrolled
#undef UNROLL2
/// basic unroll code
#define UNROLL2(x) \
- *(dp + x * 2 + 0) = *(sp + x * 2 + 0); \
- *(dp + x * 2 + 1) = *(sp + x * 2 + 1)
-
- UNROLL32(0);
- sp += da;
- dp += da;
+ *(unsigned long*)(dp + x * 2 + 0) = *(unsigned long*)(sp + x *
2 + 0); \
+ *(unsigned long*)(dp + x * 2 + 1) = *(unsigned long*)(sp + x *
2 + 1)
UNROLL32(0);
- sp += da;
+ sp += TileSizeX;
dp += da;
}
}
-#endif // ifndef USE_SDL_SURFACE
// ---------------------------------------------------------------------------
/**
-** Draw tile.
+** Draw 16x16 tile for 8 bpp video modes with cache support.
**
** @param tile Tile number to draw.
** @param x X position into video memory
** @param y Y position into video memory
*/
-#ifdef USE_SDL_SURFACE
-#ifndef USE_OPENGL
-global void MapDrawTile(int tile, int x, int y)
-{
- VideoDrawTile(tile, x, y);
-}
-#else
-global void MapDrawTile(int tile, int x, int y)
+local void MapDraw8Tile16(int tile, int x, int y)
{
- GLint sx;
- GLint ex;
- GLint sy;
- GLint ey;
- GLfloat stx;
- GLfloat etx;
- GLfloat sty;
- GLfloat ety;
- Graphic *g;
- int t;
-
- g = TheMap.TileGraphic;
- sx = x;
- ex = sx + TileSizeX;
- ey = VideoHeight - y;
- sy = ey - TileSizeY;
+ TileCache* cache;
- t = tile % (g->Width / TileSizeX);
- stx=(GLfloat)t * TileSizeX / g->Width * g->TextureWidth;
- etx=(GLfloat)(t * TileSizeX + TileSizeX) / g->Width * g->TextureWidth;
- t = tile / (g->Width / TileSizeX);
- sty=(GLfloat)t * TileSizeY / g->Height * g->TextureHeight;
- ety=(GLfloat)(t * TileSizeY + TileSizeY) / g->Height * g->TextureHeight;
+ if (!(cache = TileCached[tile])) {
+ //
+ // Not cached
+ //
+ if (TileCacheSize) { // enough cache
buffers?
+ --TileCacheSize;
+ cache = malloc(sizeof(TileCache) - sizeof(unsigned
char) +
+ TileSizeX * TileSizeY * sizeof(VMemType16));
+ } else {
+ cache = (void*)TileCacheLRU->last;
+ if (cache->Tile) {
+ TileCached[cache->Tile] = NULL; // now
not cached
+ }
+ dl_remove_last(TileCacheLRU);
+ DebugLevel3("EMPTY CACHE\n");
+ }
+ TileCached[tile] = cache;
+ cache->Tile = tile;
+ dl_insert_first(TileCacheLRU, &cache->DlNode);
- glBindTexture(GL_TEXTURE_2D, g->TextureNames[0]);
- glBegin(GL_QUADS);
- glTexCoord2f(stx, 1.0f - ety);
- glVertex2i(sx, sy);
- glTexCoord2f(stx, 1.0f - sty);
- glVertex2i(sx, ey);
- glTexCoord2f(etx, 1.0f - sty);
- glVertex2i(ex, ey);
- glTexCoord2f(etx, 1.0f - ety);
- glVertex2i(ex, sy);
- glEnd();
+ FillCache8AndDraw16(TheMap.Tiles[tile], (void*)&cache->Buffer,
x, y);
+ } else {
+ VideoDraw8Tile16FromCache((void*)&cache->Buffer, x, y);
+ }
}
-#endif
-
-#else
/**
-** Draw 16x16 tile for 8 bpp video modes with cache support.
+** Draw 16x16 tile for 16 bpp video modes with cache support.
**
** @param tile Tile number to draw.
** @param x X position into video memory
** @param y Y position into video memory
*/
-local void MapDraw8Tile16(int tile, int x, int y)
+local void MapDraw16Tile16(int tile, int x, int y)
{
- if (TileCached[tile]) {
- VideoDraw8Tile16Cached(TileCached[tile], x, y);
- } else {
- VideoDraw8Tile16(TheMap.Tiles[tile], x, y);
- TileCached[tile] = VideoMemory8 + x + y * VideoWidth;
- }
-}
+ TileCache* cache;
+
+ if (!(cache = TileCached[tile])) {
+ //
+ // Not cached
+ //
+ if (TileCacheSize) { // enough cache
buffers?
+ --TileCacheSize;
+ cache = malloc(sizeof(TileCache) - sizeof(unsigned
char) +
+ TileSizeX * TileSizeY * sizeof(VMemType16));
+ } else {
+ cache = (void*)TileCacheLRU->last;
+ if (cache->Tile) {
+ TileCached[cache->Tile] = NULL; // now
not cached
+ }
+ dl_remove_last(TileCacheLRU);
+ DebugLevel3("EMPTY CACHE\n");
+ }
+ TileCached[tile] = cache;
+ cache->Tile = tile;
+ dl_insert_first(TileCacheLRU, &cache->DlNode);
-/**
-** Draw 16x16 tile for 16 bpp video modes with cache support.
-**
-** @param tile Tile number to draw.
-** @param x X position into video memory
-** @param y Y position into video memory
-*/
-local void MapDraw16Tile16(int tile, int x, int y)
-{
- if (TileCached[tile]) {
- VideoDraw16Tile16Cached(TileCached[tile], x, y);
+ FillCache16AndDraw16(TheMap.Tiles[tile], (void*)&cache->Buffer,
x, y);
} else {
- VideoDraw16Tile16(TheMap.Tiles[tile], x, y);
- TileCached[tile] = VideoMemory16 + x + y * VideoWidth;
+ VideoDraw16Tile16FromCache((void*)&cache->Buffer, x, y);
}
}
@@ -2297,11 +1249,31 @@
*/
local void MapDraw24Tile16(int tile, int x, int y)
{
- if (TileCached[tile]) {
- VideoDraw24Tile16Cached(TileCached[tile], x, y);
+ TileCache* cache;
+
+ if (!(cache = TileCached[tile])) {
+ //
+ // Not cached
+ //
+ if (TileCacheSize) { // enough cache
buffers?
+ --TileCacheSize;
+ cache = malloc(sizeof(TileCache) - sizeof(unsigned
char) +
+ TileSizeX * TileSizeY * sizeof(VMemType24));
+ } else {
+ cache = (void*)TileCacheLRU->last;
+ if (cache->Tile) {
+ TileCached[cache->Tile] = NULL; // now
not cached
+ }
+ dl_remove_last(TileCacheLRU);
+ DebugLevel3("EMPTY CACHE\n");
+ }
+ TileCached[tile] = cache;
+ cache->Tile = tile;
+ dl_insert_first(TileCacheLRU, &cache->DlNode);
+
+ FillCache24AndDraw16(TheMap.Tiles[tile], (void*)&cache->Buffer,
x, y);
} else {
- VideoDraw24Tile16(TheMap.Tiles[tile], x, y);
- TileCached[tile] = VideoMemory24 + x + y * VideoWidth;
+ VideoDraw24Tile16FromCache((void*)&cache->Buffer, x, y);
}
}
@@ -2314,12 +1286,31 @@
*/
local void MapDraw32Tile16(int tile, int x, int y)
{
- // FIXME: (johns) Why turned off?
- if (0 && TileCached[tile]) {
- VideoDraw32Tile16Cached(TileCached[tile], x, y);
+ TileCache* cache;
+
+ if (!(cache = TileCached[tile])) {
+ //
+ // Not cached
+ //
+ if (TileCacheSize) { // enough cache
buffers?
+ --TileCacheSize;
+ cache = malloc(sizeof(TileCache) - sizeof(unsigned
char) +
+ TileSizeX * TileSizeY * sizeof(VMemType32));
+ } else {
+ cache = (void*)TileCacheLRU->last;
+ if (cache->Tile) {
+ TileCached[cache->Tile] = NULL; // now
not cached
+ }
+ dl_remove_last(TileCacheLRU);
+ DebugLevel3("EMPTY CACHE\n");
+ }
+ TileCached[tile] = cache;
+ cache->Tile = tile;
+ dl_insert_first(TileCacheLRU, &cache->DlNode);
+
+ FillCache32AndDraw16(TheMap.Tiles[tile], (void*)&cache->Buffer,
x, y);
} else {
- VideoDraw32Tile16(TheMap.Tiles[tile], x, y);
- TileCached[tile] = VideoMemory32 + x + y * VideoWidth;
+ VideoDraw32Tile16FromCache((void*)&cache->Buffer, x, y);
}
}
@@ -2332,11 +1323,31 @@
*/
local void MapDraw8Tile32(int tile, int x, int y)
{
- if (TileCached[tile]) {
- VideoDraw8Tile32Cached(TileCached[tile], x, y);
+ TileCache* cache;
+
+ if (!(cache = TileCached[tile])) {
+ //
+ // Not cached
+ //
+ if (TileCacheSize) { // enough cache
buffers?
+ --TileCacheSize;
+ cache = malloc(sizeof(TileCache) - sizeof(unsigned
char) +
+ TileSizeX * TileSizeY * sizeof(VMemType16));
+ } else {
+ cache = (void*)TileCacheLRU->last;
+ if (cache->Tile) {
+ TileCached[cache->Tile] = NULL; // now
not cached
+ }
+ dl_remove_last(TileCacheLRU);
+ DebugLevel3("EMPTY CACHE\n");
+ }
+ TileCached[tile] = cache;
+ cache->Tile = tile;
+ dl_insert_first(TileCacheLRU, &cache->DlNode);
+
+ FillCache8AndDraw32(TheMap.Tiles[tile], (void*)&cache->Buffer,
x, y);
} else {
- VideoDraw8Tile32(TheMap.Tiles[tile], x, y);
- TileCached[tile] = VideoMemory8 + x + y * VideoWidth;
+ VideoDraw8Tile32FromCache((void*)&cache->Buffer, x, y);
}
}
@@ -2349,11 +1360,31 @@
*/
local void MapDraw16Tile32(int tile, int x, int y)
{
- if (TileCached[tile]) {
- VideoDraw16Tile32Cached(TileCached[tile], x, y);
+ TileCache* cache;
+
+ if (!(cache = TileCached[tile])) {
+ //
+ // Not cached
+ //
+ if (TileCacheSize) { // enough cache
buffers?
+ --TileCacheSize;
+ cache = malloc(sizeof(TileCache) - sizeof(unsigned
char) +
+ TileSizeX * TileSizeY * sizeof(VMemType16));
+ } else {
+ cache = (void*)TileCacheLRU->last;
+ if (cache->Tile) {
+ TileCached[cache->Tile] = NULL; // now
not cached
+ }
+ dl_remove_last(TileCacheLRU);
+ DebugLevel3("EMPTY CACHE\n");
+ }
+ TileCached[tile] = cache;
+ cache->Tile = tile;
+ dl_insert_first(TileCacheLRU, &cache->DlNode);
+
+ FillCache16AndDraw32(TheMap.Tiles[tile], (void*)&cache->Buffer,
x, y);
} else {
- VideoDraw16Tile32(TheMap.Tiles[tile], x, y);
- TileCached[tile] = VideoMemory16 + x + y * VideoWidth;
+ VideoDraw16Tile32FromCache((void*)&cache->Buffer, x, y);
}
}
@@ -2366,11 +1397,31 @@
*/
local void MapDraw24Tile32(int tile, int x, int y)
{
- if (TileCached[tile]) {
- VideoDraw24Tile32Cached(TileCached[tile], x, y);
+ TileCache* cache;
+
+ if (!(cache = TileCached[tile])) {
+ //
+ // Not cached
+ //
+ if (TileCacheSize) { // enough cache
buffers?
+ --TileCacheSize;
+ cache = malloc(sizeof(TileCache) - sizeof(unsigned
char) +
+ TileSizeX * TileSizeY * sizeof(VMemType24));
+ } else {
+ cache = (void*)TileCacheLRU->last;
+ if (cache->Tile) {
+ TileCached[cache->Tile] = NULL; // now
not cached
+ }
+ dl_remove_last(TileCacheLRU);
+ DebugLevel3("EMPTY CACHE\n");
+ }
+ TileCached[tile] = cache;
+ cache->Tile = tile;
+ dl_insert_first(TileCacheLRU, &cache->DlNode);
+
+ FillCache24AndDraw32(TheMap.Tiles[tile], (void*)&cache->Buffer,
x, y);
} else {
- VideoDraw24Tile32(TheMap.Tiles[tile], x, y);
- TileCached[tile] = VideoMemory24 + x + y * VideoWidth;
+ VideoDraw24Tile32FromCache((void*)&cache->Buffer, x, y);
}
}
@@ -2383,14 +1434,93 @@
*/
local void MapDraw32Tile32(int tile, int x, int y)
{
- // FIXME: (johns) Why turned off?
- if (0 && TileCached[tile]) {
- VideoDraw32Tile32Cached(TileCached[tile], x, y);
+ TileCache* cache;
+
+ if (!(cache = TileCached[tile])) {
+ //
+ // Not cached
+ //
+ if (TileCacheSize) { // enough cache
buffers?
+ --TileCacheSize;
+ cache = malloc(sizeof(TileCache) - sizeof(unsigned
char) +
+ TileSizeX * TileSizeY * sizeof(VMemType32));
+ } else {
+ cache = (void*)TileCacheLRU->last;
+ if (cache->Tile) {
+ TileCached[cache->Tile] = NULL; // now
not cached
+ }
+ dl_remove_last(TileCacheLRU);
+ DebugLevel3("EMPTY CACHE\n");
+ }
+ TileCached[tile] = cache;
+ cache->Tile = tile;
+ dl_insert_first(TileCacheLRU, &cache->DlNode);
+
+ FillCache32AndDraw32(TheMap.Tiles[tile], (void*)&cache->Buffer,
x, y);
} else {
- VideoDraw32Tile32(TheMap.Tiles[tile], x, y);
- TileCached[tile] = VideoMemory32 + x + y * VideoWidth;
+ VideoDraw32Tile32FromCache((void*)&cache->Buffer, x, y);
}
}
+
+#endif // } USE_TILECACHE
+
+/*----------------------------------------------------------------------------
+-- Smart Cache
+----------------------------------------------------------------------------*/
+
+#ifdef USE_SMART_TILECACHE // {
+
+/**
+** Draw tile.
+**
+** @param tile Tile number to draw.
+** @param x X position into video memory
+** @param y Y position into video memory
+*/
+#ifndef USE_OPENGL
+global void MapDrawTile(int tile, int x, int y)
+{
+ VideoDrawTile(tile, x, y);
+}
+#else
+global void MapDrawTile(int tile, int x, int y)
+{
+ GLint sx;
+ GLint ex;
+ GLint sy;
+ GLint ey;
+ GLfloat stx;
+ GLfloat etx;
+ GLfloat sty;
+ GLfloat ety;
+ Graphic *g;
+ int t;
+
+ g = TheMap.TileGraphic;
+ sx = x;
+ ex = sx + TileSizeX;
+ ey = VideoHeight - y;
+ sy = ey - TileSizeY;
+
+ t = tile % (g->Width / TileSizeX);
+ stx=(GLfloat)t * TileSizeX / g->Width * g->TextureWidth;
+ etx=(GLfloat)(t * TileSizeX + TileSizeX) / g->Width * g->TextureWidth;
+ t = tile / (g->Width / TileSizeX);
+ sty=(GLfloat)t * TileSizeY / g->Height * g->TextureHeight;
+ ety=(GLfloat)(t * TileSizeY + TileSizeY) / g->Height * g->TextureHeight;
+
+ glBindTexture(GL_TEXTURE_2D, g->TextureNames[0]);
+ glBegin(GL_QUADS);
+ glTexCoord2f(stx, 1.0f - ety);
+ glVertex2i(sx, sy);
+ glTexCoord2f(stx, 1.0f - sty);
+ glVertex2i(sx, ey);
+ glTexCoord2f(etx, 1.0f - sty);
+ glVertex2i(ex, ey);
+ glTexCoord2f(etx, 1.0f - ety);
+ glVertex2i(ex, sy);
+ glEnd();
+}
#endif
#endif // } USE_SMART_TILECACHE
@@ -2503,44 +1633,6 @@
-- Global functions
----------------------------------------------------------------------------*/
-#ifndef USE_SDL_SURFACE
-/**
-** Called if color cycled.
-** Must mark color cycled tiles as dirty.
-*/
-global void MapColorCycle(void)
-{
- int i;
-
-#ifdef USE_TILECACHE
- TileCache* cache;
-
- // FIXME: the easy version just remove color cycling tiles from cache.
- for (i = 0; i < TheMap.TileCount; ++i) {
- if (TheMap.Tileset->TileTypeTable[i] == TileTypeWater) {
- if ((cache = TileCached[i])) {
- DebugLevel3("Flush\n");
- dl_remove(&cache->DlNode);
- dl_insert_last(TileCacheLRU, &cache->DlNode);
- cache->Tile = 0;
- TileCached[i] = NULL;
- }
- }
- }
-#endif
-
- if (VideoBpp == 15 || VideoBpp == 16) {
- //
- // Convert 16 bit pixel table into two 32 bit
tables.
- //
- for (i = 0; i < 256; ++i) {
- PixelsLow[i] =
((VMemType16*)TheMap.TileData->Pixels)[i] & 0xFFFF;
- PixelsHigh[i] =
(((VMemType16*)TheMap.TileData->Pixels)[i] & 0xFFFF) << 16;
- }
- }
-}
-#endif
-
/**
** Mark position inside viewport be drawn for next display update.
**
@@ -2897,10 +1989,6 @@
*/
global void InitMap(void)
{
-#ifndef USE_SDL_SURFACE
- MapColorCycle();
-#endif
-
#ifdef NEW_DECODRAW
// StephanR: Using the decoration mechanism we need to support drawing
tiles
// clipped, as by only updating a small part of the tile, we don't have
to
@@ -2920,80 +2008,6 @@
// TheUI.SelectedViewport->EndX - TheUI.SelectedViewport->X + 1,
// TheUI.SelectedViewport->EndY - TheUI.SelectedViewport->Y + 1);
DebugCheck(!MapDecoration);
-
-#else
-#ifndef USE_SDL_SURFACE
- if (TileSizeX == 16 && TileSizeY == 16) {
- switch (VideoBpp) {
- case 8:
- VideoDrawTile = VideoDraw8Tile16;
- MapDrawTile = MapDraw8Tile16;
- break;
- case 15:
- case 16:
- VideoDrawTile = VideoDraw16Tile16;
- MapDrawTile = MapDraw16Tile16;
- break;
- case 24:
- VideoDrawTile = VideoDraw24Tile16;
- MapDrawTile = MapDraw24Tile16;
- break;
-
- case 32:
- VideoDrawTile = VideoDraw32Tile16;
- MapDrawTile = MapDraw32Tile16;
- break;
-
- default:
- DebugLevel0Fn("Depth unsupported\n");
- break;
- }
- } else if (TileSizeX == 32 && TileSizeY == 32) {
- switch (VideoBpp) {
- case 8:
- VideoDrawTile = VideoDraw8Tile32;
-#if !defined(USE_TILECACHE) && !defined(USE_SMART_TILECACHE)
- MapDrawTile = MapDraw8Tile32;
-#else
- MapDrawTile = MapDraw8Tile32;
-#endif
- break;
- case 15:
- case 16:
- VideoDrawTile = VideoDraw16Tile32;
-#if !defined(USE_TILECACHE) && !defined(USE_SMART_TILECACHE)
- MapDrawTile = MapDraw16Tile32;
-#else
- MapDrawTile = MapDraw16Tile32;
-#endif
- break;
- case 24:
- VideoDrawTile = VideoDraw24Tile32;
-#if !defined(USE_TILECACHE) && !defined(USE_SMART_TILECACHE)
- MapDrawTile = MapDraw24Tile32;
-#else
- MapDrawTile = MapDraw24Tile32;
-#endif
- break;
-
- case 32:
- VideoDrawTile = VideoDraw32Tile32;
-#if !defined(USE_TILECACHE) && !defined(USE_SMART_TILECACHE)
- MapDrawTile = MapDraw32Tile32;
-#else
- MapDrawTile = MapDraw32Tile32;
-#endif
- break;
-
- default:
- DebugLevel0Fn("Depth unsupported\n");
- break;
- }
- } else {
- printf("Tile size not supported: (%dx%d)\n", TileSizeX,
TileSizeY);
- exit(1);
- }
-#endif // ifdef USE_SDL_SURFACE
#endif // NEW_DECODRAW
}
Index: stratagus/src/map/map_fog.c
diff -u stratagus/src/map/map_fog.c:1.141 stratagus/src/map/map_fog.c:1.142
--- stratagus/src/map/map_fog.c:1.141 Thu Jan 15 10:44:01 2004
+++ stratagus/src/map/map_fog.c Thu Jan 15 13:06:22 2004
@@ -27,7 +27,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: map_fog.c,v 1.141 2004/01/14 23:44:01 jsalmon3 Exp $
+// $Id: map_fog.c,v 1.142 2004/01/15 02:06:22 jsalmon3 Exp $
//@{
@@ -121,27 +121,22 @@
local unsigned char* VisibleTable;
-#ifdef USE_SDL_SURFACE
local SDL_Surface* OnlyFogSurface;
-local void (*VideoDrawUnexplored)(const int, int, int);
-local void (*VideoDrawFog)(const int, int, int);
-local void (*VideoDrawOnlyFog)(int, int);
-#else
+
/**
** Draw unexplored area function pointer. (display and video mode
independ)
*/
-local void (*VideoDrawUnexplored)(const GraphicData*, int, int);
+local void (*VideoDrawUnexplored)(const int, int, int);
/**
** Draw fog of war function pointer. (display and video mode
independ)
*/
-local void (*VideoDrawFog)(const GraphicData*, int, int);
+local void (*VideoDrawFog)(const int, int, int);
/**
** Draw only fog of war function pointer. (display and video mode
independ)
*/
-local void (*VideoDrawOnlyFog)(const GraphicData*, int x, int y);
-#endif
+local void (*VideoDrawOnlyFog)(int, int);
/*----------------------------------------------------------------------------
-- Functions
@@ -485,8 +480,7 @@
-- Draw fog solid
----------------------------------------------------------------------------*/
-#ifdef USE_SDL_SURFACE
-
+#ifndef USE_OPENGL
/**
** Fast draw solid fog of war 16x16 tile for 8 bpp video modes.
**
@@ -547,1000 +541,6 @@
#else
-// Routines for 8 bit displays .. --------------------------------------------
-
-/**
-** Fast draw solid fog of war 16x16 tile for 8 bpp video modes.
-**
-** @param data pointer to tile graphic data.
-** @param x X position into video memory.
-** @param y Y position into video memory.
-*/
-global void VideoDraw8Fog16Solid(const GraphicData* data, int x, int y)
-{
- const unsigned char* sp;
- const unsigned char* gp;
- VMemType8* dp;
- int da;
-
- sp = data;
- gp = sp + TileSizeY * TileSizeX;
- dp = VideoMemory8 + x + y * VideoWidth;
- da = VideoWidth;
-
- while (sp < gp) {
-#undef UNROLL1
-#define UNROLL1(x) \
- if (COLOR_FOG_P(sp[x])) { \
- dp[x] =
((VMemType8*)TheMap.TileData->Pixels)[COLOR_FOG]; \
- }
-
-#undef UNROLL2
-#define UNROLL2(x) \
- UNROLL1(x + 0);
-
- UNROLL16(0);
-
- sp += TileSizeX;
- dp += da;
-
-#undef UNROLL2
-#define UNROLL2(x) \
- UNROLL1(x + 1);
-
- UNROLL16(0);
-
- sp += TileSizeX;
- dp += da;
- }
-}
-
-/**
-** Fast draw solid 100% fog of war 16x16 tile for 8 bpp video
modes.
-**
-** 100% fog of war -- i.e. raster 10101.
-**
01010 etc...
-**
-** @param data pointer to tile graphic data.
-** @param x X position into video memory
-** @param y Y position into video memory
-*/
-global void VideoDraw8OnlyFog16Solid(const GraphicData* data
__attribute__((unused)),
- int x, int y)
-{
- const VMemType8* gp;
- VMemType8* dp;
- int da;
-
- dp = VideoMemory8 + x + y * VideoWidth;
- gp = dp + VideoWidth * TileSizeX;
- da = VideoWidth;
- while (dp < gp) {
-#undef UNROLL2
-#define UNROLL2(x) \
- dp[x + 0] = ((VMemType8*)TheMap.TileData->Pixels)[COLOR_FOG];
- UNROLL16(0);
- dp += da;
-
-#undef UNROLL2
-#define UNROLL2(x) \
- dp[x + 1] = ((VMemType8*)TheMap.TileData->Pixels)[COLOR_FOG];
- UNROLL16(0);
- dp += da;
- }
-}
-
-/**
-** Fast draw solid unexplored 16x16 tile for 8 bpp video modes.
-**
-** @param data pointer to tile graphic data
-** @param x X position into video memory
-** @param y Y position into video memory
-*/
-global void VideoDraw8Unexplored16Solid(const GraphicData* data, int x, int y)
-{
- const unsigned char* sp;
- const unsigned char* gp;
- VMemType8* dp;
- int da;
-
- sp = data;
- gp = sp + TileSizeY * TileSizeX;
- dp = VideoMemory8 + x + y * VideoWidth;
- da = VideoWidth;
-
- while (sp < gp) {
-#undef UNROLL1
-#define UNROLL1(x) \
- if (COLOR_FOG_P(sp[x])) { \
- dp[x] =
((VMemType8*)TheMap.TileData->Pixels)[COLOR_FOG]; \
- }
-
-#undef UNROLL2
-#define UNROLL2(x) \
- UNROLL1(x + 0); \
- UNROLL1(x + 1);
-
- UNROLL16(0);
- sp += TileSizeX;
- dp += da;
-
- UNROLL16(0);
- sp += TileSizeX;
- dp += da;
-
- }
-}
-
-/**
-** Fast draw solid fog of war 32x32 tile for 8 bpp video modes.
-**
-** @param data pointer to tile graphic data.
-** @param x X position into video memory.
-** @param y Y position into video memory.
-*/
-global void VideoDraw8Fog32Solid(const GraphicData* data, int x, int y)
-{
- const unsigned char* sp;
- const unsigned char* gp;
- VMemType8* dp;
- int da;
-
- sp = data;
- gp = sp + TileSizeY * TileSizeX;
- dp = VideoMemory8 + x + y * VideoWidth;
- da = VideoWidth;
-
- while (sp < gp) {
-#undef UNROLL1
-#define UNROLL1(x) \
- if (COLOR_FOG_P(sp[x])) { \
- dp[x] =
((VMemType8*)TheMap.TileData->Pixels)[COLOR_FOG]; \
- }
-
-#undef UNROLL2
-#define UNROLL2(x) \
- UNROLL1(x + 0);
-
- UNROLL32(0);
-
- sp += TileSizeX;
- dp += da;
-
-#undef UNROLL2
-#define UNROLL2(x) \
- UNROLL1(x + 1);
-
- UNROLL32(0);
-
- sp += TileSizeX;
- dp += da;
- }
-}
-
-/**
-** Fast draw solid 100% fog of war 32x32 tile for 8 bpp video
modes.
-**
-** 100% fog of war -- i.e. raster 10101.
-**
01010 etc...
-**
-** @param data pointer to tile graphic data.
-** @param x X position into video memory
-** @param y Y position into video memory
-*/
-global void VideoDraw8OnlyFog32Solid(const GraphicData* data
__attribute__((unused)),
- int x, int y)
-{
- const VMemType8* gp;
- VMemType8* dp;
- int da;
-
- dp = VideoMemory8 + x + y * VideoWidth;
- gp = dp + VideoWidth * TileSizeX;
- da = VideoWidth;
- while (dp < gp) {
-#undef UNROLL2
-#define UNROLL2(x) \
- dp[x + 0] = ((VMemType8*)TheMap.TileData->Pixels)[COLOR_FOG];
- UNROLL32(0);
- dp += da;
-
-#undef UNROLL2
-#define UNROLL2(x) \
- dp[x + 1] = ((VMemType8*)TheMap.TileData->Pixels)[COLOR_FOG];
- UNROLL32(0);
- dp += da;
- }
-}
-
-/**
-** Fast draw solid unexplored 32x32 tile for 8 bpp video modes.
-**
-** @param data pointer to tile graphic data
-** @param x X position into video memory
-** @param y Y position into video memory
-*/
-global void VideoDraw8Unexplored32Solid(const GraphicData* data, int x, int y)
-{
- const unsigned char* sp;
- const unsigned char* gp;
- VMemType8* dp;
- int da;
-
- sp = data;
- gp = sp + TileSizeY * TileSizeX;
- dp = VideoMemory8 + x + y * VideoWidth;
- da = VideoWidth;
-
- while (sp < gp) {
-#undef UNROLL1
-#define UNROLL1(x) \
- if (COLOR_FOG_P(sp[x])) { \
- dp[x] =
((VMemType8*)TheMap.TileData->Pixels)[COLOR_FOG]; \
- }
-
-#undef UNROLL2
-#define UNROLL2(x) \
- UNROLL1(x + 0); \
- UNROLL1(x + 1);
-
- UNROLL32(0);
- sp += TileSizeX;
- dp += da;
-
- UNROLL32(0);
- sp += TileSizeX;
- dp += da;
-
- }
-}
-
-// Routines for 16 bit displays .. -------------------------------------------
-
-/**
-** Fast draw solid fog of war 16x16 tile for 16 bpp video modes.
-**
-** @param data pointer to tile graphic data.
-** @param x X position into video memory.
-** @param y Y position into video memory.
-*/
-global void VideoDraw16Fog16Solid(const GraphicData* data, int x, int y)
-{
- const unsigned char* sp;
- const unsigned char* gp;
- VMemType16* dp;
- int da;
-
- sp = data;
- gp = sp + TileSizeY * TileSizeX;
- dp = VideoMemory16 + x + y * VideoWidth;
- da = VideoWidth;
-
- while (sp < gp) {
-#undef UNROLL1
-#define UNROLL1(x) \
- if (COLOR_FOG_P(sp[x])) { \
- dp[x] =
((VMemType16*)TheMap.TileData->Pixels)[COLOR_FOG]; \
- }
-
-#undef UNROLL2
-#define UNROLL2(x) \
- UNROLL1(x + 0);
-
- UNROLL16(0);
-
- sp += TileSizeX;
- dp += da;
-
-#undef UNROLL2
-#define UNROLL2(x) \
- UNROLL1(x + 1);
-
- UNROLL16(0);
-
- sp += TileSizeX;
- dp += da;
- }
-}
-
-/**
-** Fast draw solid 100% fog of war 16x16 tile for 16 bpp video
modes.
-**
-** 100% fog of war -- i.e. raster 10101.
-**
01010 etc...
-**
-** @param data pointer to tile graphic data.
-** @param x X position into video memory
-** @param y Y position into video memory
-*/
-global void VideoDraw16OnlyFog16Solid(const GraphicData* data
__attribute__((unused)),
- int x, int y)
-{
- const VMemType16* gp;
- VMemType16* dp;
- int da;
-
- dp = VideoMemory16 + x + y * VideoWidth;
- gp = dp + VideoWidth * TileSizeX;
- da = VideoWidth;
- while (dp < gp) {
-#undef UNROLL2
-#define UNROLL2(x) \
- dp[x + 0] = ((VMemType16*)TheMap.TileData->Pixels)[COLOR_FOG];
- UNROLL16(0);
- dp += da;
-
-#undef UNROLL2
-#define UNROLL2(x) \
- dp[x + 1] = ((VMemType16*)TheMap.TileData->Pixels)[COLOR_FOG];
- UNROLL16(0);
- dp += da;
- }
-}
-
-/**
-** Fast draw solid unexplored 16x16 tile for 16 bpp video modes.
-**
-** @param data pointer to tile graphic data
-** @param x X position into video memory
-** @param y Y position into video memory
-*/
-global void VideoDraw16Unexplored16Solid(const GraphicData* data, int x, int y)
-{
- const unsigned char* sp;
- const unsigned char* gp;
- VMemType16* dp;
- int da;
-
- sp = data;
- gp = sp + TileSizeY * TileSizeX;
- dp = VideoMemory16 + x + y * VideoWidth;
- da = VideoWidth;
-
- while (sp < gp) {
-#undef UNROLL1
-#define UNROLL1(x) \
- if (COLOR_FOG_P(sp[x])) { \
- dp[x] =
((VMemType16*)TheMap.TileData->Pixels)[COLOR_FOG]; \
- }
-
-#undef UNROLL2
-#define UNROLL2(x) \
- UNROLL1(x + 0); \
- UNROLL1(x + 1);
-
- UNROLL16(0);
- sp += TileSizeX;
- dp += da;
-
- UNROLL16(0);
- sp += TileSizeX;
- dp += da;
- }
-}
-
-/**
-** Fast draw solid fog of war 32x32 tile for 16 bpp video modes.
-**
-** @param data pointer to tile graphic data.
-** @param x X position into video memory.
-** @param y Y position into video memory.
-*/
-global void VideoDraw16Fog32Solid(const GraphicData* data, int x, int y)
-{
- const unsigned char* sp;
- const unsigned char* gp;
- VMemType16* dp;
- int da;
-
- sp = data;
- gp = sp + TileSizeY * TileSizeX;
- dp = VideoMemory16 + x + y * VideoWidth;
- da = VideoWidth;
-
- while (sp < gp) {
-#undef UNROLL1
-#define UNROLL1(x) \
- if (COLOR_FOG_P(sp[x])) { \
- dp[x] =
((VMemType16*)TheMap.TileData->Pixels)[COLOR_FOG]; \
- }
-
-#undef UNROLL2
-#define UNROLL2(x) \
- UNROLL1(x + 0);
-
- UNROLL32(0);
-
- sp += TileSizeX;
- dp += da;
-
-#undef UNROLL2
-#define UNROLL2(x) \
- UNROLL1(x + 1);
-
- UNROLL32(0);
-
- sp += TileSizeX;
- dp += da;
- }
-}
-
-/**
-** Fast draw solid 100% fog of war 32x32 tile for 16 bpp video
modes.
-**
-** 100% fog of war -- i.e. raster 10101.
-**
01010 etc...
-**
-** @param data pointer to tile graphic data.
-** @param x X position into video memory
-** @param y Y position into video memory
-*/
-global void VideoDraw16OnlyFog32Solid(const GraphicData* data
__attribute__((unused)),
- int x, int y)
-{
- const VMemType16* gp;
- VMemType16* dp;
- int da;
-
- dp = VideoMemory16 + x + y * VideoWidth;
- gp = dp + VideoWidth * TileSizeX;
- da = VideoWidth;
- while (dp < gp) {
-#undef UNROLL2
-#define UNROLL2(x) \
- dp[x + 0] = ((VMemType16*)TheMap.TileData->Pixels)[COLOR_FOG];
- UNROLL32(0);
- dp += da;
-
-#undef UNROLL2
-#define UNROLL2(x) \
- dp[x + 1] = ((VMemType16*)TheMap.TileData->Pixels)[COLOR_FOG];
- UNROLL32(0);
- dp += da;
- }
-}
-
-/**
-** Fast draw solid unexplored 32x32 tile for 16 bpp video modes.
-**
-** @param data pointer to tile graphic data
-** @param x X position into video memory
-** @param y Y position into video memory
-*/
-global void VideoDraw16Unexplored32Solid(const GraphicData* data, int x, int y)
-{
- const unsigned char* sp;
- const unsigned char* gp;
- VMemType16* dp;
- int da;
-
- sp = data;
- gp = sp + TileSizeY * TileSizeX;
- dp = VideoMemory16 + x + y * VideoWidth;
- da = VideoWidth;
-
- while (sp < gp) {
-#undef UNROLL1
-#define UNROLL1(x) \
- if (COLOR_FOG_P(sp[x])) { \
- dp[x] =
((VMemType16*)TheMap.TileData->Pixels)[COLOR_FOG]; \
- }
-
-#undef UNROLL2
-#define UNROLL2(x) \
- UNROLL1(x + 0); \
- UNROLL1(x + 1);
-
- UNROLL32(0);
- sp += TileSizeX;
- dp += da;
-
- UNROLL32(0);
- sp += TileSizeX;
- dp += da;
- }
-}
-
-// Routines for 24 bit displays .. -------------------------------------------
-
-/**
-** Fast draw solid fog of war 16x16 tile for 24 bpp video modes.
-**
-** @param data pointer to tile graphic data.
-** @param x X position into video memory.
-** @param y Y position into video memory.
-*/
-global void VideoDraw24Fog16Solid(const GraphicData* data, int x, int y)
-{
- const unsigned char* sp;
- const unsigned char* gp;
- VMemType24* dp;
- int da;
-
- sp = data;
- gp = sp + TileSizeY * TileSizeX;
- dp = VideoMemory24 + x + y * VideoWidth;
- da = VideoWidth;
-
- while (sp < gp) {
-#undef UNROLL1
-#define UNROLL1(x) \
- if (COLOR_FOG_P(sp[x])) { \
- dp[x] =
((VMemType24*)TheMap.TileData->Pixels)[COLOR_FOG]; \
- }
-
-#undef UNROLL2
-#define UNROLL2(x) \
- UNROLL1(x + 0);
-
- UNROLL32(0);
-
- sp += TileSizeX;
- dp += da;
-
-#undef UNROLL2
-#define UNROLL2(x) \
- UNROLL1(x + 1);
-
- UNROLL16(0);
-
- sp += TileSizeX;
- dp += da;
- }
-}
-
-/**
-** Fast draw solid 100% fog of war 16x16 tile for 24 bpp video
modes.
-**
-** 100% fog of war -- i.e. raster 10101.
-**
01010 etc...
-**
-** @param data pointer to tile graphic data.
-** @param x X position into video memory
-** @param y Y position into video memory
-*/
-global void VideoDraw24OnlyFog16Solid(const GraphicData* data
__attribute__((unused)),
- int x, int y)
-{
- const VMemType24* gp;
- VMemType24* dp;
- int da;
-
- dp = VideoMemory24 + x + y * VideoWidth;
- gp = dp + VideoWidth * TileSizeX;
- da = VideoWidth;
- while (dp < gp) {
-#undef UNROLL2
-#define UNROLL2(x) \
- dp[x + 0] = ((VMemType24*)TheMap.TileData->Pixels)[COLOR_FOG];
- UNROLL16(0);
- dp += da;
-
-#undef UNROLL2
-#define UNROLL2(x) \
- dp[x + 1] = ((VMemType24*)TheMap.TileData->Pixels)[COLOR_FOG];
- UNROLL16(0);
- dp += da;
- }
-}
-
-/**
-** Fast draw solid unexplored 16x16 tile for 24 bpp video modes.
-**
-** @param data pointer to tile graphic data
-** @param x X position into video memory
-** @param y Y position into video memory
-*/
-global void VideoDraw24Unexplored16Solid(const GraphicData* data, int x, int y)
-{
- const unsigned char* sp;
- const unsigned char* gp;
- VMemType24* dp;
- int da;
-
- sp = data;
- gp = sp + TileSizeY * TileSizeX;
- dp = VideoMemory24 + x + y * VideoWidth;
- da = VideoWidth;
-
- while (sp < gp) {
-#undef UNROLL1
-#define UNROLL1(x) \
- if (COLOR_FOG_P(sp[x])) { \
- dp[x] =
((VMemType24*)TheMap.TileData->Pixels)[COLOR_FOG]; \
- }
-
-#undef UNROLL2
-#define UNROLL2(x) \
- UNROLL1(x + 0); \
- UNROLL1(x + 1);
-
- UNROLL16(0);
- sp += TileSizeX;
- dp += da;
-
- UNROLL16(0);
- sp += TileSizeX;
- dp += da;
- }
-}
-
-/**
-** Fast draw solid fog of war 32x32 tile for 24 bpp video modes.
-**
-** @param data pointer to tile graphic data.
-** @param x X position into video memory.
-** @param y Y position into video memory.
-*/
-global void VideoDraw24Fog32Solid(const GraphicData* data, int x, int y)
-{
- const unsigned char* sp;
- const unsigned char* gp;
- VMemType24* dp;
- int da;
-
- sp = data;
- gp = sp + TileSizeY * TileSizeX;
- dp = VideoMemory24 + x + y * VideoWidth;
- da = VideoWidth;
-
- while (sp < gp) {
-#undef UNROLL1
-#define UNROLL1(x) \
- if (COLOR_FOG_P(sp[x])) { \
- dp[x] =
((VMemType24*)TheMap.TileData->Pixels)[COLOR_FOG]; \
- }
-
-#undef UNROLL2
-#define UNROLL2(x) \
- UNROLL1(x + 0);
-
- UNROLL32(0);
-
- sp += TileSizeX;
- dp += da;
-
-#undef UNROLL2
-#define UNROLL2(x) \
- UNROLL1(x + 1);
-
- UNROLL32(0);
-
- sp += TileSizeX;
- dp += da;
- }
-}
-
-/**
-** Fast draw solid 100% fog of war 32x32 tile for 24 bpp video
modes.
-**
-** 100% fog of war -- i.e. raster 10101.
-**
01010 etc...
-**
-** @param data pointer to tile graphic data.
-** @param x X position into video memory
-** @param y Y position into video memory
-*/
-global void VideoDraw24OnlyFog32Solid(const GraphicData* data
__attribute__((unused)),
- int x, int y)
-{
- const VMemType24* gp;
- VMemType24* dp;
- int da;
-
- dp = VideoMemory24 + x + y * VideoWidth;
- gp = dp + VideoWidth * TileSizeX;
- da = VideoWidth;
- while (dp < gp) {
-#undef UNROLL2
-#define UNROLL2(x) \
- dp[x + 0] = ((VMemType24*)TheMap.TileData->Pixels)[COLOR_FOG];
- UNROLL32(0);
- dp += da;
-
-#undef UNROLL2
-#define UNROLL2(x) \
- dp[x + 1] = ((VMemType24*)TheMap.TileData->Pixels)[COLOR_FOG];
- UNROLL32(0);
- dp += da;
- }
-}
-
-/**
-** Fast draw solid unexplored 32x32 tile for 24 bpp video modes.
-**
-** @param data pointer to tile graphic data
-** @param x X position into video memory
-** @param y Y position into video memory
-*/
-global void VideoDraw24Unexplored32Solid(const GraphicData* data, int x, int y)
-{
- const unsigned char* sp;
- const unsigned char* gp;
- VMemType24* dp;
- int da;
-
- sp = data;
- gp = sp + TileSizeY * TileSizeX;
- dp = VideoMemory24 + x + y * VideoWidth;
- da = VideoWidth;
-
- while (sp < gp) {
-#undef UNROLL1
-#define UNROLL1(x) \
- if (COLOR_FOG_P(sp[x])) { \
- dp[x] =
((VMemType24*)TheMap.TileData->Pixels)[COLOR_FOG]; \
- }
-
-#undef UNROLL2
-#define UNROLL2(x) \
- UNROLL1(x + 0); \
- UNROLL1(x + 1);
-
- UNROLL32(0);
- sp += TileSizeX;
- dp += da;
-
- UNROLL32(0);
- sp += TileSizeX;
- dp += da;
- }
-}
-
-// Routines for 32 bit displays .. -------------------------------------------
-
-/**
-** Fast draw solid fog of war 16x16 tile for 32 bpp video modes.
-**
-** @param data pointer to tile graphic data.
-** @param x X position into video memory.
-** @param y Y position into video memory.
-*/
-global void VideoDraw32Fog16Solid(const GraphicData* data, int x, int y)
-{
- const unsigned char* sp;
- const unsigned char* gp;
- VMemType32* dp;
- int da;
-
- sp = data;
- gp = sp + TileSizeY * TileSizeX;
- dp = VideoMemory32 + x + y * VideoWidth;
- da = VideoWidth;
-
- while (sp < gp) {
-#undef UNROLL1
-#define UNROLL1(x) \
- if (COLOR_FOG_P(sp[x])) { \
- dp[x] =
((VMemType16*)TheMap.TileData->Pixels)[COLOR_FOG]; \
- }
-
-#undef UNROLL2
-#define UNROLL2(x) \
- UNROLL1(x + 0);
-
- UNROLL16(0);
-
- sp += TileSizeX;
- dp += da;
-
-#undef UNROLL2
-#define UNROLL2(x) \
- UNROLL1(x + 1);
-
- UNROLL16(0);
-
- sp += TileSizeX;
- dp += da;
- }
-}
-
-/**
-** Fast draw solid 100% fog of war 16x16 tile for 32 bpp video
modes.
-**
-** 100% fog of war -- i.e. raster 10101.
-**
01010 etc...
-**
-** @param data pointer to tile graphic data.
-** @param x X position into video memory
-** @param y Y position into video memory
-*/
-global void VideoDraw32OnlyFog16Solid(const GraphicData* data
__attribute__((unused)),
- int x, int y)
-{
- const VMemType32* gp;
- VMemType32* dp;
- int da;
-
- dp = VideoMemory32 + x + y * VideoWidth;
- gp = dp + VideoWidth * TileSizeX;
- da = VideoWidth;
- while (dp < gp) {
-#undef UNROLL2
-#define UNROLL2(x) \
- dp[x + 0] = ((VMemType32*)TheMap.TileData->Pixels)[COLOR_FOG];
- UNROLL16(0);
- dp += da;
-
-#undef UNROLL2
-#define UNROLL2(x) \
- dp[x + 1] = ((VMemType32*)TheMap.TileData->Pixels)[COLOR_FOG];
- UNROLL16(0);
- dp += da;
- }
-}
-
-/**
-** Fast draw solid unexplored 16x16 tile for 32 bpp video modes.
-**
-** @param data pointer to tile graphic data
-** @param x X position into video memory
-** @param y Y position into video memory
-*/
-global void VideoDraw32Unexplored16Solid(const GraphicData* data, int x, int y)
-{
- const unsigned char* sp;
- const unsigned char* gp;
- VMemType32* dp;
- int da;
-
- sp = data;
- gp = sp + TileSizeY * TileSizeX;
- dp = VideoMemory32 + x + y * VideoWidth;
- da = VideoWidth;
-
- while (sp < gp) {
-#undef UNROLL1
-#define UNROLL1(x) \
- if (COLOR_FOG_P(sp[x])) { \
- dp[x] =
((VMemType32*)TheMap.TileData->Pixels)[COLOR_FOG]; \
- }
-
-#undef UNROLL2
-#define UNROLL2(x) \
- UNROLL1(x + 0); \
- UNROLL1(x + 1);
-
- UNROLL16(0);
- sp += TileSizeX;
- dp += da;
-
- UNROLL16(0);
- sp += TileSizeX;
- dp += da;
- }
-}
-
-/**
-** Fast draw solid fog of war 32x32 tile for 32 bpp video modes.
-**
-** @param data pointer to tile graphic data.
-** @param x X position into video memory.
-** @param y Y position into video memory.
-*/
-global void VideoDraw32Fog32Solid(const GraphicData* data, int x, int y)
-{
- const unsigned char* sp;
- const unsigned char* gp;
- VMemType32* dp;
- int da;
-
- sp = data;
- gp = sp + TileSizeY * TileSizeX;
- dp = VideoMemory32 + x + y * VideoWidth;
- da = VideoWidth;
-
- while (sp < gp) {
-#undef UNROLL1
-#define UNROLL1(x) \
- if (COLOR_FOG_P(sp[x])) { \
- dp[x] =
((VMemType16*)TheMap.TileData->Pixels)[COLOR_FOG]; \
- }
-
-#undef UNROLL2
-#define UNROLL2(x) \
- UNROLL1(x + 0);
-
- UNROLL32(0);
-
- sp += TileSizeX;
- dp += da;
-
-#undef UNROLL2
-#define UNROLL2(x) \
- UNROLL1(x + 1);
-
- UNROLL32(0);
-
- sp += TileSizeX;
- dp += da;
- }
-}
-
-/**
-** Fast draw solid 100% fog of war 32x32 tile for 32 bpp video
modes.
-**
-** 100% fog of war -- i.e. raster 10101.
-**
01010 etc...
-**
-** @param data pointer to tile graphic data.
-** @param x X position into video memory
-** @param y Y position into video memory
-*/
-global void VideoDraw32OnlyFog32Solid(const GraphicData* data
__attribute__((unused)),
- int x, int y)
-{
- const VMemType32* gp;
- VMemType32* dp;
- int da;
-
- dp = VideoMemory32 + x + y * VideoWidth;
- gp = dp + VideoWidth * TileSizeX;
- da = VideoWidth;
- while (dp < gp) {
-#undef UNROLL2
-#define UNROLL2(x) \
- dp[x + 0] = ((VMemType32*)TheMap.TileData->Pixels)[COLOR_FOG];
- UNROLL32(0);
- dp += da;
-
-#undef UNROLL2
-#define UNROLL2(x) \
- dp[x + 1] = ((VMemType32*)TheMap.TileData->Pixels)[COLOR_FOG];
- UNROLL32(0);
- dp += da;
- }
-}
-
-/**
-** Fast draw solid unexplored 32x32 tile for 32 bpp video modes.
-**
-** @param data pointer to tile graphic data
-** @param x X position into video memory
-** @param y Y position into video memory
-*/
-global void VideoDraw32Unexplored32Solid(const GraphicData* data, int x, int y)
-{
- const unsigned char* sp;
- const unsigned char* gp;
- VMemType32* dp;
- int da;
-
- sp = data;
- gp = sp + TileSizeY * TileSizeX;
- dp = VideoMemory32 + x + y * VideoWidth;
- da = VideoWidth;
-
- while (sp < gp) {
-#undef UNROLL1
-#define UNROLL1(x) \
- if (COLOR_FOG_P(sp[x])) { \
- dp[x] =
((VMemType32*)TheMap.TileData->Pixels)[COLOR_FOG]; \
- }
-
-#undef UNROLL2
-#define UNROLL2(x) \
- UNROLL1(x + 0); \
- UNROLL1(x + 1);
-
- UNROLL32(0);
- sp += TileSizeX;
- dp += da;
-
- UNROLL32(0);
- sp += TileSizeX;
- dp += da;
- }
-}
-#endif
-
-
-#ifdef USE_OPENGL
-
-// ------------------------------------------------------------------
-// Routines for OpenGL .. -------------------------------------------
-// ------------------------------------------------------------------
-
/**
** Fast draw solid unexplored tile.
**
@@ -1718,28 +718,16 @@
if (IsMapFieldVisibleTable(x, y) || ReplayRevealMap) {
if (tile) {
-#ifdef USE_SDL_SURFACE
VideoDrawFog(tile, dx, dy);
-#else
- VideoDrawFog(TheMap.Tiles[tile], dx, dy);
-#endif
// TheMap.Fields[sx].VisibleLastFrame |=
MapFieldPartiallyVisible;
// } else {
// TheMap.Fields[sx].VisibleLastFrame |=
MapFieldCompletelyVisible;
}
} else {
-#ifdef USE_SDL_SURFACE
VideoDrawOnlyFog(dx, dy);
-#else
- VideoDrawOnlyFog(TheMap.Tiles[UNEXPLORED_TILE], dx, dy);
-#endif
}
if (tile2) {
-#ifdef USE_SDL_SURFACE
VideoDrawUnexplored(tile2, dx, dy);
-#else
- VideoDrawUnexplored(TheMap.Tiles[tile2], dx, dy);
-#endif
/*
if (tile2 == tile) { // no same fog
over unexplored
// if (tile != 0xf) {
@@ -1842,11 +830,7 @@
#ifdef USE_OPENGL
MapDrawTile(UNEXPLORED_TILE,
dx, dy);
#else
-#ifdef USE_SDL_SURFACE
VideoFillRectangle(ColorBlack,
dx, dy, TileSizeX, TileSizeY);
-#else
-
VideoDrawTile(TheMap.Tiles[UNEXPLORED_TILE], dx, dy);
-#endif
#endif
}
#endif
@@ -1944,7 +928,6 @@
VideoDrawOnlyFog = VideoDrawOnlyFogAlphaOpenGL;
VideoDrawUnexplored = VideoDrawUnexploredSolidOpenGL;
#else
-#ifdef USE_SDL_SURFACE
//
// Generate Only Fog surface.
//
@@ -1970,76 +953,6 @@
VideoDrawUnexplored = VideoDrawUnexploredSDL;
VideoDrawFog = VideoDrawFogSDL;
VideoDrawOnlyFog = VideoDrawOnlyFogSDL;
-#else
- if (TileSizeX == 16 && TileSizeY == 16) {
- switch (VideoDepth) {
- case 8:
// 8 bpp video depth
- VideoDrawFog = VideoDraw8Fog16Solid;
- VideoDrawOnlyFog = VideoDraw8OnlyFog16Solid;
- VideoDrawUnexplored =
VideoDraw8Unexplored16Solid;
- break;
-
- case 15:
// 15 bpp video depth
- case 16:
// 16 bpp video depth
- VideoDrawFog = VideoDraw16Fog16Solid;
- VideoDrawOnlyFog = VideoDraw16OnlyFog16Solid;
- VideoDrawUnexplored =
VideoDraw16Unexplored16Solid;
- break;
- case 24:
// 24 bpp video depth
- if (VideoBpp == 24) {
- VideoDrawFog = VideoDraw24Fog16Solid;
- VideoDrawOnlyFog =
VideoDraw24OnlyFog16Solid;
- VideoDrawUnexplored =
VideoDraw24Unexplored16Solid;
- break;
- }
- // FALL THROUGH
- case 32:
// 32 bpp video depth
- VideoDrawFog = VideoDraw32Fog16Solid;
- VideoDrawOnlyFog = VideoDraw32OnlyFog16Solid;
- VideoDrawUnexplored =
VideoDraw32Unexplored16Solid;
- break;
-
- default:
- DebugLevel0Fn("Depth unsupported %d\n" _C_
VideoDepth);
- break;
- }
- } else if (TileSizeX == 32 && TileSizeY == 32) {
- switch (VideoDepth) {
- case 8:
// 8 bpp video depth
- VideoDrawFog = VideoDraw8Fog32Solid;
- VideoDrawOnlyFog = VideoDraw8OnlyFog32Solid;
- VideoDrawUnexplored =
VideoDraw8Unexplored32Solid;
- break;
-
- case 15:
// 15 bpp video depth
- case 16:
// 16 bpp video depth
- VideoDrawFog = VideoDraw16Fog32Solid;
- VideoDrawOnlyFog = VideoDraw16OnlyFog32Solid;
- VideoDrawUnexplored =
VideoDraw16Unexplored32Solid;
- break;
- case 24:
// 24 bpp video depth
- if (VideoBpp == 24) {
- VideoDrawFog = VideoDraw24Fog32Solid;
- VideoDrawOnlyFog =
VideoDraw24OnlyFog32Solid;
- VideoDrawUnexplored =
VideoDraw24Unexplored32Solid;
- break;
- }
- // FALL THROUGH
- case 32:
// 32 bpp video depth
- VideoDrawFog = VideoDraw32Fog32Solid;
- VideoDrawOnlyFog = VideoDraw32OnlyFog32Solid;
- VideoDrawUnexplored =
VideoDraw32Unexplored32Solid;
- break;
-
- default:
- DebugLevel0Fn("Depth unsupported %d\n" _C_
VideoDepth);
- break;
- }
- } else {
- printf("Tile size not supported: (%dx%d)\n", TileSizeX,
TileSizeY);
- exit(1);
- }
-#endif
#endif
}
Index: stratagus/src/map/minimap.c
diff -u stratagus/src/map/minimap.c:1.91 stratagus/src/map/minimap.c:1.92
--- stratagus/src/map/minimap.c:1.91 Thu Jan 15 11:56:59 2004
+++ stratagus/src/map/minimap.c Thu Jan 15 13:06:22 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: minimap.c,v 1.91 2004/01/15 00:56:59 wizzard Exp $
+// $Id: minimap.c,v 1.92 2004/01/15 02:06:22 jsalmon3 Exp $
//@{
@@ -52,7 +52,6 @@
-- Variables
----------------------------------------------------------------------------*/
-#ifdef USE_SDL_SURFACE
local SDL_Surface* MinimapSurface; /// generated minimap
local SDL_Surface* MinimapTerrainSurface; /// generated minimap
terrain
local int* Minimap2MapX; /// fast conversion
table
@@ -498,486 +497,5 @@
// Draw cursor as rectangle (Note: unclipped, as it is always visible)
VideoDrawTransRectangle(TheUI.ViewportCursorColor, x, y, w, h, 128);
}
-
-#else // USE_SDL_SURFACE
-
-local Graphic* MinimapTerrainGraphic; /// generated minimap terrain
-local VMemType* MinimapGraphic; /// generated
minimap
-local int* Minimap2MapX; /// fast conversion
table
-local int* Minimap2MapY; /// fast conversion
table
-local int Map2MinimapX[MaxMapWidth]; /// fast conversion table
-local int Map2MinimapY[MaxMapHeight]; /// fast conversion table
-
-// MinimapScale:
-// 32x32 64x64 96x96 128x128 256x256 512x512 ...
-// *4 *2 *4/3 *1 *1/2 *1/4
-local int MinimapScaleX; /// Minimap scale to
fit into window
-local int MinimapScaleY; /// Minimap scale to
fit into window
-global int MinimapX; /// Minimap
drawing position x offset
-global int MinimapY; /// Minimap
drawing position y offset
-
-global int MinimapWithTerrain = 1; /// display minimap with terrain
-global int MinimapFriendly = 1; /// switch
colors of friendly units
-global int MinimapShowSelected = 1; /// highlight selected units
-
-local int OldMinimapCursorX; /// Save MinimapCursorX
-local int OldMinimapCursorY; /// Save MinimapCursorY
-local int OldMinimapCursorW; /// Save MinimapCursorW
-local int OldMinimapCursorH; /// Save MinimapCursorH
-local int OldMinimapCursorSize; /// Saved image
size
-
-local void* OldMinimapCursorImage; /// Saved image behind cursor
-
-/*----------------------------------------------------------------------------
--- Functions
-----------------------------------------------------------------------------*/
-
-/**
-** Update minimap at map position x,y. This is called when the
tile image
-** of a tile changes.
-**
-** @todo FIXME: this is not correct should use SeenTile.
-**
-** @param tx Tile X position, where the map changed.
-** @param ty Tile Y position, where the map changed.
-**
-** FIXME: this can surely be sped up??
-*/
-global void UpdateMinimapXY(int tx, int ty)
-{
- int mx;
- int my;
- int x;
- int y;
- int scalex;
- int scaley;
-
- scalex = MinimapScaleX / MINIMAP_FAC;
- if (scalex == 0) {
- scalex = 1;
- }
- scaley = MinimapScaleY / MINIMAP_FAC;
- if (scaley == 0) {
- scaley = 1;
- }
- //
- // Pixel 7,6 7,14, 15,6 15,14 are taken for the minimap
picture.
- //
- ty *= TheMap.Width;
- for (my = MinimapY; my < TheUI.MinimapH - MinimapY; ++my) {
- y = Minimap2MapY[my];
- if (y < ty) {
- continue;
- }
- if (y > ty) {
- break;
- }
-
- for (mx = MinimapX; mx < TheUI.MinimapW - MinimapX; ++mx) {
- int tile;
-
- x = Minimap2MapX[mx];
- if (x < tx) {
- continue;
- }
- if (x > tx) {
- break;
- }
-
- tile = TheMap.Fields[x + y].Tile;
-
- ((unsigned char*)MinimapTerrainGraphic->Frames)[mx + my
* TheUI.MinimapW] =
- TheMap.Tiles[tile][7 + (mx % scalex) * 8 + (6 +
(my % scaley) * 8) * TileSizeX];
- }
- }
-}
-
-/**
-** Update a mini-map from the tiles of the map.
-**
-** @todo FIXME: this is not correct should use SeenTile.
-**
-** FIXME: this can surely be sped up??
-*/
-global void UpdateMinimapTerrain(void)
-{
- int mx;
- int my;
- int scalex;
- int scaley;
-
- if (!(scalex = (MinimapScaleX / MINIMAP_FAC))) {
- scalex = 1;
- }
- if (!(scaley = (MinimapScaleY / MINIMAP_FAC))) {
- scaley = 1;
- }
-
- //
- // Pixel 7,6 7,14, 15,6 15,14 are taken for the minimap
picture.
- //
- for (my = MinimapY; my < TheUI.MinimapH - MinimapY; ++my) {
- for (mx = MinimapX; mx < TheUI.MinimapW - MinimapX; ++mx) {
- int tile;
-
- tile = TheMap.Fields[Minimap2MapX[mx] +
Minimap2MapY[my]].Tile;
-
- ((unsigned char*)MinimapTerrainGraphic->Frames)[mx + my
* TheUI.MinimapW] =
- TheMap.Tiles[tile][7 + (mx % scalex) * 8 + (6 +
(my % scaley) * 8) * TileSizeX];
- }
- }
-}
-
-/**
-** Create a mini-map from the tiles of the map.
-**
-** @todo Scaling and scrolling the minmap is currently
not supported.
-*/
-global void CreateMinimap(void)
-{
- int n;
- int x;
- int y;
-
- if (TheMap.Width > TheMap.Height) { // Scale to biggest
value.
- n = TheMap.Width;
- } else {
- n = TheMap.Height;
- }
- MinimapScaleX = (TheUI.MinimapW * MINIMAP_FAC + n - 1) / n;
- MinimapScaleY = (TheUI.MinimapH * MINIMAP_FAC + n - 1) / n;
-
- MinimapX = ((TheUI.MinimapW * MINIMAP_FAC) / MinimapScaleX -
TheMap.Width) / 2;
- MinimapY = ((TheUI.MinimapH * MINIMAP_FAC) / MinimapScaleY -
TheMap.Height) / 2;
- MinimapX = (TheUI.MinimapW - (TheMap.Width * MinimapScaleX) /
MINIMAP_FAC) / 2;
- MinimapY = (TheUI.MinimapH - (TheMap.Height * MinimapScaleY) /
MINIMAP_FAC) / 2;
-
- DebugLevel0Fn("MinimapScale %d %d (%d %d), X off %d, Y off %d\n" _C_
- MinimapScaleX / MINIMAP_FAC _C_ MinimapScaleY / MINIMAP_FAC _C_
- MinimapScaleX _C_ MinimapScaleY _C_
- MinimapX _C_ MinimapY);
-
- //
- // Calculate minimap fast lookup tables.
- //
- // FIXME: this needs to be recalculated during map load - the map size
- // might have changed!
- Minimap2MapX = calloc(sizeof(int), TheUI.MinimapW * TheUI.MinimapH);
- Minimap2MapY = calloc(sizeof(int), TheUI.MinimapW * TheUI.MinimapH);
- for (n = MinimapX; n < TheUI.MinimapW - MinimapX; ++n) {
- Minimap2MapX[n] = ((n - MinimapX) * MINIMAP_FAC) /
MinimapScaleX;
- }
- for (n = MinimapY; n < TheUI.MinimapH - MinimapY; ++n) {
- Minimap2MapY[n] = (((n - MinimapY) * MINIMAP_FAC) /
MinimapScaleY) * TheMap.Width;
- }
- for (n = 0; n < TheMap.Width; ++n) {
- Map2MinimapX[n] = (n * MinimapScaleX) / MINIMAP_FAC;
- }
- for (n = 0; n < TheMap.Height; ++n) {
- Map2MinimapY[n] = (n * MinimapScaleY) / MINIMAP_FAC;
- }
-
- MinimapTerrainGraphic = NewGraphic(8, TheUI.MinimapW, TheUI.MinimapH);
-
- memset(MinimapTerrainGraphic->Frames, 0, TheUI.MinimapW *
TheUI.MinimapH);
- MinimapGraphic = calloc(TheUI.MinimapW * TheUI.MinimapH,
sizeof(VMemType));
-
- // FIXME: looks too complicated
- for (y = 0; y < TheUI.MinimapH; ++y) {
- for (x = 0; x < TheUI.MinimapW; ++x) {
- Palette p;
- // this only copies the panel background... honest.
- p = TheMap.TileData->Palette[
- ((unsigned
char*)TheUI.MinimapPanel.Graphic->Frames)[
- x + (TheUI.MinimapPosX -
TheUI.MinimapPanelX) +
- (y + TheUI.MinimapPosY -
TheUI.MinimapPanelY) *
- TheUI.MinimapPanel.Graphic->Width]];
- MinimapGraphic[x + y * TheUI.MinimapW] =
VideoMapRGB(p.r, p.g, p.b);
- }
- }
- if (!TheUI.MinimapTransparent) {
- // make only the inner part which is going to be used black
- for (y = MinimapY; y < TheUI.MinimapH - MinimapY; ++y) {
- for (x = MinimapX; x < TheUI.MinimapW - MinimapX; ++x) {
- MinimapGraphic[x + y * TheUI.MinimapW] =
ColorBlack;
- }
- }
- }
-
- UpdateMinimapTerrain();
-}
-
-/**
-** Destroy mini-map.
-*/
-global void DestroyMinimap(void)
-{
- VideoSafeFree(MinimapTerrainGraphic);
- MinimapTerrainGraphic = NULL;
- if (MinimapGraphic) {
- free(MinimapGraphic);
- MinimapGraphic = NULL;
- }
- free(Minimap2MapX);
- Minimap2MapX = NULL;
- free(Minimap2MapY);
- Minimap2MapY = NULL;
-}
-
-/**
-** Update the minimap
-** @note This one of the hot-points in the program optimize and
optimize!
-*/
-global void UpdateMinimap(void)
-{
- static int red_phase;
- int red_phase_changed;
- int mx;
- int my;
- UnitType* type;
- Unit** table;
- Unit* unit;
- int w;
- int h;
- int h0;
-
- red_phase_changed = red_phase != (int)((FrameCounter /
FRAMES_PER_SECOND) & 1);
- if (red_phase_changed) {
- red_phase = !red_phase;
- }
-
- //
- // Draw the terrain (or make it black again)
- //
- for (my = 0; my < TheUI.MinimapH; ++my) {
- for (mx = 0; mx < TheUI.MinimapW; ++mx) {
- int visiontype; // 0 unexplored, 1 explored, >1 visible.
- if (ReplayRevealMap) {
- visiontype = 2;
- } else {
- visiontype = IsTileVisible(ThisPlayer,
Minimap2MapX[mx], Minimap2MapY[my] / TheMap.Width);
- }
- if (MinimapWithTerrain && (visiontype > 1 ||
(visiontype == 1 && ((mx & 1) == (my & 1))))) {
- Palette p;
- p = TheMap.TileData->Palette[
- ((unsigned
char*)MinimapTerrainGraphic->Frames)[mx + my * TheUI.MinimapW]];
- MinimapGraphic[mx + my * TheUI.MinimapW] =
VideoMapRGB(p.r, p.g, p.b);
- } else if (visiontype > 0) {
- MinimapGraphic[mx + my * TheUI.MinimapW] =
ColorBlack;
- }
- }
- }
-
- //
- // Draw units on map
- // FIXME: I should rewrite this completely
- // FIXME: make a bitmap of the units, and update it with
the moves
- // FIXME: and other changes
- //
-
- for (table = Units; table < Units + NumUnits; ++table) {
- VMemType color;
-
- unit = *table;
-
- // This function is only called from here, but it's better to
have all
- // UnitVisible functions in the same place (unit.c). Hopefully
it will help
- // reduce the confusion around them.
- if (!UnitVisibleOnMinimap(unit)) {
- continue;
- }
-
- type = unit->Type;
- //
- // FIXME: We should force unittypes to have a certain color on
the minimap.
- //
- if (unit->Player->Player == PlayerNumNeutral) {
- color =
VideoMapRGB((*table)->Type->NeutralMinimapColorRGB.D24.a,
- (*table)->Type->NeutralMinimapColorRGB.D24.b,
- (*table)->Type->NeutralMinimapColorRGB.D24.c);
- } else if (unit->Player == ThisPlayer) {
- if (unit->Attacked && unit->Attacked +
ATTACK_BLINK_DURATION > GameCycle &&
- (red_phase || unit->Attacked +
ATTACK_RED_DURATION > GameCycle)) {
- color = ColorRed;
- } else if (MinimapShowSelected && unit->Selected) {
- color = ColorWhite;
- } else {
- color = ColorGreen;
- }
- } else {
- color = unit->Player->Color;
- }
-
- mx = 1 + MinimapX + Map2MinimapX[unit->X];
- my = 1 + MinimapY + Map2MinimapY[unit->Y];
- w = Map2MinimapX[type->TileWidth];
- if (mx + w >= TheUI.MinimapW) { // clip
right side
- w = TheUI.MinimapW - mx;
- }
- h0 = Map2MinimapY[type->TileHeight];
- if (my + h0 >= TheUI.MinimapH) { // clip bottom
side
- h0 = TheUI.MinimapH - my;
- }
- while (w-- >= 0) {
- h = h0;
- while (h-- >= 0) {
- MinimapGraphic[mx + w + (my + h) *
TheUI.MinimapW] = color;
- }
- }
-
- }
-}
-
-/**
-** Draw the mini-map with current viewpoint.
-**
-** @param vx View point X position.
-** @param vy View point Y position.
-*/
-global void DrawMinimap(int vx __attribute__((unused)),
- int vy __attribute__((unused)))
-{
- int i;
- int j;
-
- switch (VideoBpp) {
- case 8: {
- VMemType8* v;
-
- v = VideoMemory8 + TheUI.MinimapPosY * VideoWidth +
TheUI.MinimapPosX;
- for (i = 0; i < TheUI.MinimapH; ++i) {
- for (j = 0; j < TheUI.MinimapW; ++j) {
- v[j] = MinimapGraphic[i *
TheUI.MinimapW + j].D8;
- }
- v += VideoWidth;
- }
- break;
- }
- case 15:
- case 16: {
- VMemType16* v;
-
- v = VideoMemory16 + TheUI.MinimapPosY * VideoWidth +
TheUI.MinimapPosX;
- for (i = 0; i < TheUI.MinimapH; ++i) {
- for (j = 0; j < TheUI.MinimapW; ++j) {
- v[j] = MinimapGraphic[i *
TheUI.MinimapW + j].D16;
- }
- v += VideoWidth;
- }
- break;
- }
- case 24: {
- VMemType24* v;
-
- v = VideoMemory24 + TheUI.MinimapPosY * VideoWidth +
TheUI.MinimapPosX;
- for (i = 0; i < TheUI.MinimapH; ++i) {
- for (j = 0; j < TheUI.MinimapW; ++j) {
- v[j] = MinimapGraphic[i *
TheUI.MinimapW + j].D24;
- }
- v += VideoWidth;
- }
- break;
- }
- case 32: {
- VMemType32* v;
-
- v = VideoMemory32 + TheUI.MinimapPosY * VideoWidth +
TheUI.MinimapPosX;
- for (i = 0; i < TheUI.MinimapH; ++i) {
- for (j = 0; j < TheUI.MinimapW; ++j) {
- v[j] = MinimapGraphic[i *
TheUI.MinimapW + j].D32;
- }
- v += VideoWidth;
- }
- break;
- }
- }
-}
-
-/**
-** Hide minimap cursor.
-*/
-global void HideMinimapCursor(void)
-{
- if (OldMinimapCursorW) {
- LoadCursorRectangle(OldMinimapCursorImage,
- OldMinimapCursorX, OldMinimapCursorY,
- OldMinimapCursorW, OldMinimapCursorH);
- OldMinimapCursorW = 0;
- }
-}
-
-/**
-** Draw minimap cursor.
-**
-** @param vx View point X position.
-** @param vy View point Y position.
-*/
-global void DrawMinimapCursor(int vx, int vy)
-{
- int x;
- int y;
- int w;
- int h;
- int i;
-
- // Determine and save region below minimap cursor
- OldMinimapCursorX = x =
- TheUI.MinimapPosX + MinimapX + (vx * MinimapScaleX) /
MINIMAP_FAC;
- OldMinimapCursorY = y =
- TheUI.MinimapPosY + MinimapY + (vy * MinimapScaleY) /
MINIMAP_FAC;
- OldMinimapCursorW = w =
- (TheUI.SelectedViewport->MapWidth * MinimapScaleX) /
MINIMAP_FAC;
- OldMinimapCursorH = h =
- (TheUI.SelectedViewport->MapHeight * MinimapScaleY) /
MINIMAP_FAC;
- i = (w + 1 + h) * 2 * VideoTypeSize;
- if (OldMinimapCursorSize < i) {
- if (OldMinimapCursorImage) {
- OldMinimapCursorImage = realloc(OldMinimapCursorImage,
i);
- } else {
- OldMinimapCursorImage = malloc(i);
- }
- DebugLevel3("Cursor memory %d\n" _C_ i);
- OldMinimapCursorSize = i;
- }
- SaveCursorRectangle(OldMinimapCursorImage, x, y, w, h);
-
- // Draw cursor as rectangle (Note: unclipped, as it is always visible)
- VideoDraw50TransRectangle(TheUI.ViewportCursorColor, x, y, w, h);
-}
-
-/**
-** Convert minimap cursor X position to tile map coordinate.
-**
-** @param x Screen X pixel coordinate.
-** @return Tile X coordinate.
-*/
-global int ScreenMinimap2MapX(int x)
-{
- int tx;
-
- tx = (((x - TheUI.MinimapPosX - MinimapX) * MINIMAP_FAC) /
MinimapScaleX);
- if (tx < 0) {
- return 0;
- }
- return tx < TheMap.Width ? tx : TheMap.Width - 1;
-}
-
-/**
-** Convert minimap cursor Y position to tile map coordinate.
-**
-** @param y Screen Y pixel coordinate.
-** @return Tile Y coordinate.
-*/
-global int ScreenMinimap2MapY(int y)
-{
- int ty;
-
- ty = (((y - TheUI.MinimapPosY - MinimapY) * MINIMAP_FAC) /
MinimapScaleY);
- if (ty < 0) {
- return 0;
- }
- return ty < TheMap.Height ? ty : TheMap.Height - 1;
-}
-#endif
//@}
Index: stratagus/src/map/tileset.c
diff -u stratagus/src/map/tileset.c:1.63 stratagus/src/map/tileset.c:1.64
--- stratagus/src/map/tileset.c:1.63 Thu Jan 15 10:44:01 2004
+++ stratagus/src/map/tileset.c Thu Jan 15 13:06:22 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: tileset.c,v 1.63 2004/01/14 23:44:01 jsalmon3 Exp $
+// $Id: tileset.c,v 1.64 2004/01/15 02:06:22 jsalmon3 Exp $
//@{
@@ -125,11 +125,7 @@
buf = alloca(strlen(Tilesets[i]->ImageFile) + 9 + 1);
strcat(strcpy(buf, "graphics/"), Tilesets[i]->ImageFile);
ShowLoadProgress("Tileset `%s'", Tilesets[i]->ImageFile);
-#ifdef USE_SDL_SURFACE
TheMap.TileGraphic = LoadGraphic(buf);
-#else
- TheMap.TileData = LoadGraphic(buf);
-#endif
#ifdef USE_OPENGL
MakeTexture(TheMap.TileGraphic, TheMap.TileGraphic->Width,
TheMap.TileGraphic->Height);
#endif
@@ -140,17 +136,10 @@
//
// Calculate number of tiles in graphic tile
//
-#ifdef USE_SDL_SURFACE
tiles_per_row = TheMap.TileGraphic->Width / TileSizeX;
TheMap.TileCount = n =
tiles_per_row * (TheMap.TileGraphic->Height / TileSizeY);
-#else
- tiles_per_row = TheMap.TileData->Width / TileSizeX;
-
- TheMap.TileCount = n =
- tiles_per_row * (TheMap.TileData->Height / TileSizeY);
-#endif
DebugLevel2Fn(" %d Tiles in file %s, %d per row\n" _C_ TheMap.
TileCount _C_ TheMap.Tileset->ImageFile _C_ tiles_per_row);
@@ -164,48 +153,6 @@
// Precalculate the graphic starts of the tiles
//
data = malloc(n * TileSizeX * TileSizeY);
-#ifndef USE_SDL_SURFACE
- TheMap.Tiles = malloc(n * sizeof(*TheMap.Tiles));
-
- for (i = 0; i < n; ++i) {
- TheMap.Tiles[i] = data + i * TileSizeX * TileSizeY;
- }
-
- //
- // Convert the graphic data into faster format
- //
- for (tile = 0; tile < n; ++tile) {
- unsigned char* s;
- unsigned char* d;
-
- s = (char *)TheMap.TileData->Frames +
- (tile % tiles_per_row) * TileSizeX +
- (tile / tiles_per_row) * TileSizeY *
TheMap.TileData->Width;
- d = TheMap.Tiles[tile];
- DebugCheck(d != data + tile * TileSizeX * TileSizeY);
- for (i = 0; i < TileSizeY; ++i) {
- memcpy(d, s, TileSizeX * sizeof(unsigned char));
- d += TileSizeX;
- s += TheMap.TileData->Width;
- }
- }
-#endif
-
-#ifndef USE_OPENGL
-#ifdef USE_SDL_SURFACE
-/*
- free(TheMap.TileGraphic->Frames); // release old memory
- TheMap.TileGraphic->Frames = data;
- TheMap.TileGraphic->Width = TileSizeX;
- TheMap.TileGraphic->Height = TileSizeY * n;
-*/
-#else
- free(TheMap.TileData->Frames); // release old memory
- TheMap.TileData->Frames = data;
- TheMap.TileData->Width = TileSizeX;
- TheMap.TileData->Height = TileSizeY * n;
-#endif
-#endif
//
// Build the TileTypeTable
@@ -745,7 +692,7 @@
char** sp;
CLprintf(file, "\n;;; -----------------------------------------\n");
- CLprintf(file, ";;; MODULE: tileset $Id: tileset.c,v 1.63 2004/01/14
23:44:01 jsalmon3 Exp $\n\n");
+ CLprintf(file, ";;; MODULE: tileset $Id: tileset.c,v 1.64 2004/01/15
02:06:22 jsalmon3 Exp $\n\n");
// Original number to internal tileset name
@@ -805,15 +752,8 @@
//
// Should this be done by the map?
//
-#ifdef USE_SDL_SURFACE
VideoSafeFree(TheMap.TileGraphic);
TheMap.TileGraphic = NULL;
-#else
- VideoSafeFree(TheMap.TileData);
- TheMap.TileData = NULL;
- free(TheMap.Tiles);
- TheMap.Tiles = NULL;
-#endif
//
// Mapping the original tileset numbers in puds to our
internal strings
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Stratagus-CVS] stratagus/src/map map.c map_draw.c map_fog.c mi...,
address@hidden <=