Commit cce939d6 authored by Gerhard Stein's avatar Gerhard Stein

Restored other small vorticon animation functions

parent 21c71938
......@@ -22,10 +22,9 @@ m_width(0), m_height(0),
m_worldmap(false),
m_animation_enabled(true),
m_Tilemaps(g_pGfxEngine->getTileMaps()),
m_animtiletimer(0)
m_animtiletimer(0),
m_Background(false)
{
//memset( m_AnimTileInUse, 0, sizeof(m_AnimTileInUse));
//memset( m_animtiles, 0, sizeof(m_animtiles));
resetScrolls();
memset(m_objectlayer, 0, sizeof(m_objectlayer));
}
......@@ -48,6 +47,7 @@ bool CMap::createEmptyDataPlane(size_t plane, size_t blocksize)
if(!blocksize) return false;
m_Plane[plane].createDataMap(blocksize, m_width, m_height);
m_Background = (m_Plane[0].getMapDataPtr() != NULL);
return true;
}
......@@ -311,14 +311,20 @@ void CMap::scrollUp(void)
// in stripes as it scrolls around.
void CMap::redrawAt(int mx, int my)
{
/*for(size_t tilemap=0 ; tilemap<2 ; tilemap++)
if( m_Background )
{
if(m_Plane[tilemap].getMapDataPtr() == NULL)
continue;
int c = m_Plane[tilemap].getMapDataAt(mx, my);
m_Tilemaps.at(tilemap).drawTile(mp_scrollsurface, (mx<<4)&511, (my<<4)&511, c);
size_t bg = m_Plane[0].getMapDataAt(mx, my);
size_t fg = m_Plane[1].getMapDataAt(mx, my);
m_Tilemaps.at(0).drawTile(mp_scrollsurface, (mx<<4)&511, (my<<4)&511, bg);
m_Tilemaps.at(1).drawTile(mp_scrollsurface, (mx<<4)&511, (my<<4)&511, fg);
registerAnimation( (mx<<4)&511, (my<<4)&511, bg, fg );
}*/
}
else
{
size_t fg = m_Plane[1].getMapDataAt(mx, my);
m_Tilemaps.at(1).drawTile(mp_scrollsurface, (mx<<4)&511, (my<<4)&511, fg);
registerAnimation( (mx<<4)&511, (my<<4)&511, 0, fg );
}
}
// draws all the map area. This is used for the title screen, when game starts and other passive scenes.
......@@ -335,6 +341,8 @@ void CMap::drawAll()
if(num_h_tiles+m_mapy >= m_height)
num_h_tiles = m_height-m_mapy;
if( m_Background )
{
for(Uint32 y=0;y<num_h_tiles;y++)
{
for(Uint32 x=0;x<num_v_tiles;x++)
......@@ -348,6 +356,20 @@ void CMap::drawAll()
registerAnimation( ((x<<4)+m_mapxstripepos)&511,((y<<4)+m_mapystripepos)&511, bg, fg );
}
}
}
else
{
for(Uint32 y=0;y<num_h_tiles;y++)
{
for(Uint32 x=0;x<num_v_tiles;x++)
{
Uint32 fg = m_Plane[1].getMapDataAt(x+m_mapx, y+m_mapy);
m_Tilemaps.at(1).drawTile(mp_scrollsurface, ((x<<4)+m_mapxstripepos)&511,((y<<4)+m_mapystripepos)&511, fg);
registerAnimation( ((x<<4)+m_mapxstripepos)&511,((y<<4)+m_mapystripepos)&511, 0, fg );
}
}
}
}
// draw a horizontal stripe, for vertical scrolling
......@@ -359,6 +381,8 @@ void CMap::drawHstripe(unsigned int y, unsigned int mpy)
if( num_v_tiles+m_mapx >= m_width )
num_v_tiles = m_width-m_mapx;
if( m_Background )
{
for(Uint32 x=0;x<num_v_tiles;x++)
{
Uint32 bg = m_Plane[0].getMapDataAt(x+m_mapx, mpy);
......@@ -369,6 +393,16 @@ void CMap::drawHstripe(unsigned int y, unsigned int mpy)
m_Tilemaps.at(1).drawTile(mp_scrollsurface, ((x<<4)+m_mapxstripepos)&511, y, fg);
registerAnimation( ((x<<4)+m_mapxstripepos)&511, y, bg, fg );
}
}
else
{
for(Uint32 x=0;x<num_v_tiles;x++)
{
Uint32 fg = m_Plane[1].getMapDataAt(x+m_mapx, mpy);
m_Tilemaps.at(1).drawTile(mp_scrollsurface, ((x<<4)+m_mapxstripepos)&511, y, fg);
registerAnimation( ((x<<4)+m_mapxstripepos)&511, y, 0, fg );
}
}
}
// draws a vertical stripe from map position mapx to scrollbuffer position x
......@@ -381,6 +415,8 @@ void CMap::drawVstripe(unsigned int x, unsigned int mpx)
if( num_h_tiles+m_mapy >= m_height )
num_h_tiles = m_height-m_mapy;
if( m_Background )
{
for(Uint32 y=0;y<num_h_tiles;y++)
{
Uint32 bg = m_Plane[0].getMapDataAt(mpx, y+m_mapy);
......@@ -391,6 +427,17 @@ void CMap::drawVstripe(unsigned int x, unsigned int mpx)
m_Tilemaps.at(1).drawTile(mp_scrollsurface, x, ((y<<4)+m_mapystripepos)&511, fg);
registerAnimation( x, ((y<<4)+m_mapystripepos)&511, bg, fg );
}
}
else
{
for(Uint32 y=0;y<num_h_tiles;y++)
{
Uint32 fg = m_Plane[1].getMapDataAt(mpx, y+m_mapy);
m_Tilemaps.at(1).drawTile(mp_scrollsurface, x, ((y<<4)+m_mapystripepos)&511, fg);
registerAnimation( x, ((y<<4)+m_mapystripepos)&511, 0, fg );
}
}
}
/////////////////////////
......@@ -400,12 +447,34 @@ void CMap::drawVstripe(unsigned int x, unsigned int mpx)
// unregisters them from animtiles
void CMap::deAnimate(int x, int y)
{
const int px = ((m_mapxstripepos+((x-m_mapx)<<4))&511);
const int py = ((m_mapystripepos+((y-m_mapy)<<4))&511);
m_AnimationSlots.remove_if(usedCoord(px, py));
}
// Draw an animated tile. If it's not animated draw it anyway
void CMap::drawAnimatedTile(SDL_Surface *dst, Uint16 mx, Uint16 my, Uint16 tile)
{
CTileProperties &TileProperty = g_pBehaviorEngine->getTileProperties(1).at(tile);
if(TileProperty.animationtime)
{ // animate animated tile
std::list<stAnimationSlot>::iterator slot = m_AnimationSlots.begin();
for( ; slot != m_AnimationSlots.end() ; slot++ )
{
if( (slot->x == mx+m_scrollx_buf) &&
(slot->y == my+m_scrolly_buf) )
{
m_Tilemaps.at(0).drawTile( dst, mx, my,
slot->fgtile );
}
}
}
else
{ // Unanimated tile
m_Tilemaps.at(1).drawTile( dst, mx, my, tile );
}
}
......@@ -416,9 +485,10 @@ void CMap::animateAllTiles()
// Go throught the list and just draw all the tiles that need to be animated
std::list<stAnimationSlot>::iterator slot = m_AnimationSlots.begin();
for( ; slot != m_AnimationSlots.end() ; slot++ )
if(m_Background)
{
// Get the right property of the tile
for( ; slot != m_AnimationSlots.end() ; slot++ )
{ // Get the right property of the tile
CTileProperties &TilePropertiesBG =
g_pBehaviorEngine->getTileProperties(0).at(slot->bgtile);
CTileProperties &TilePropertiesFG =
......@@ -438,6 +508,23 @@ void CMap::animateAllTiles()
if( (m_animtiletimer % TilePropertiesFG.animationtime) == 0)
slot->fgtile += TilePropertiesFG.nextTile;
}
}
else
{
for( ; slot != m_AnimationSlots.end() ; slot++ )
{ // Get the right property of the tile
CTileProperties &TilePropertiesFG =
g_pBehaviorEngine->getTileProperties(1).at(slot->fgtile);
m_Tilemaps.at(1).drawTile( mp_scrollsurface, slot->x, slot->y, slot->fgtile);
// get the next tile which will be drawn in the next animation cycle
if(TilePropertiesFG.animationtime)
if( (m_animtiletimer % TilePropertiesFG.animationtime) == 0)
slot->fgtile += TilePropertiesFG.nextTile;
}
}
}
// unregisters all animated tiles with baseframe tile
......@@ -465,19 +552,21 @@ public:
private : size_t m_x,m_y;
};
// register the tiles which has to be animated
void CMap::registerAnimation(Uint32 x, Uint32 y, size_t bg, size_t fg)
{
// first check if some of the Animation slots are out of place and remove them
m_AnimationSlots.remove_if(usedCoord(x, y));
CTileProperties &TilePropertyBG =
g_pBehaviorEngine->getTileProperties(0).at(bg);
CTileProperties &TilePropertyFG =
g_pBehaviorEngine->getTileProperties(1).at(fg);
// we just drew an animated tile which we will now register
if( TilePropertyBG.animationtime )
if( m_Background )
{
CTileProperties &TilePropertyBG =
g_pBehaviorEngine->getTileProperties(0).at(bg);
if( TilePropertyBG.animationtime && m_Background )
{
stAnimationSlot NewAnimationSlot;
NewAnimationSlot.x = x;
......@@ -486,6 +575,7 @@ void CMap::registerAnimation(Uint32 x, Uint32 y, size_t bg, size_t fg)
NewAnimationSlot.fgtile = fg;
m_AnimationSlots.push_back(NewAnimationSlot);
}
}
if( TilePropertyFG.animationtime )
{
......@@ -498,12 +588,6 @@ void CMap::registerAnimation(Uint32 x, Uint32 y, size_t bg, size_t fg)
}
}
void CMap::cleanupAll()
{
//memset( m_AnimTileInUse, 0, sizeof(m_AnimTileInUse));
//memset( m_animtiles, 0, sizeof(m_animtiles));
}
CMap::~CMap() {
}
......
......@@ -19,17 +19,6 @@
// animation rate of animated tiles
#define ANIM_TILE_TIME 256
#define MAX_ANIMTILES 400
// for each entry in the animtileinuse array that is nonzero, that
// location on the display is an animated tile which is currently registered
// in animtiles[]. Used in map_draw_hstripe and map_draw_vstripe.
// When drawing a new stripe over one that previously contained an animated
// tile, this lets it know it needs to unregister the animated tile that
// used to be there. the nonzero value corresponds to the associated entry
// in animtiles[]. the x,y pixel position is the index in here * 16.
#define ATILEINUSE_SIZEX 33
#define ATILEINUSE_SIZEY 33
class CMap {
public:
......@@ -75,7 +64,6 @@ public:
word *getForegroundData();
word *getBackgroundData();
void cleanupAll();
virtual ~CMap();
......@@ -110,18 +98,6 @@ private:
SDL_Surface *mp_scrollsurface;
std::vector<CTilemap> &m_Tilemaps;
// (map) stripe attribute structures, for animated tiles
// slot 0 is not used. data starts at slot 1. see description
// of AnimTileInUse in map structure to see why.
/*struct {
bool slotinuse; // if false, this entry should not be drawn
int x; // x pixel position in scrollbuf[] where tile is
int y; // y pixel position in scrollbuf[]
int tile; // tile which has to be drawn
} m_animtiles[2][MAX_ANIMTILES+1];
unsigned int m_AnimTileInUse[2][ATILEINUSE_SIZEX][ATILEINUSE_SIZEY];*/
class usedCoord;
struct stAnimationSlot{
size_t x, y;
......@@ -133,6 +109,7 @@ private:
Uint8 m_animtiletimer;
CPlane m_Plane[2];
bool m_Background; // This variable holds, whether we have a background to draw or not.
};
#endif /* CMAP_H_ */
......@@ -81,7 +81,6 @@ void CPlayGameGalaxy::processInput()
m_Level++;
else
m_Level = 0;
m_Map.cleanupAll();
loadLevel();
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment