Commit 6555177e authored by Gerhard Stein's avatar Gerhard Stein

masked tiles are now loaded with the Galaxy engine

parent c1f2b19f
......@@ -46,22 +46,18 @@ class CObject {
public:
CObject(CMap *pmap=NULL);
object_t m_type; // yorp, vorticon, etc.
unsigned int m_index; // Like an ID for some objects that need this implementation
object_t m_type; // yorp, vorticon, etc.
unsigned int m_index; // Like an ID for some objects that need this implementation
bool exists;
bool onscreen; // true=(scrx,scry) position is visible onscreen
bool onscreen; // true=(scrx,scry) position is visible onscreen
bool hasbeenonscreen;
unsigned int sprite; // which sprite should this object be drawn with
int scrx, scry; // x,y pixel position on screen
int scrx, scry; // x,y pixel position on screen
// Bouncing Boxes
Uint32 bboxX1, bboxX2;
Uint32 bboxY1, bboxY2;
// if type is OBJ_PLAYER, this contains the player number that this object
// is associated with
int AssociatedWithPlayer;
// if zero, priority tiles will not be honored and object will always
// appear in front of the background
bool honorPriority;
......@@ -86,11 +82,6 @@ public:
unsigned char touchPlayer; // 1=hit detection with player
unsigned char touchedBy; // which player was hit
// Y position on this object the hit was detected
// this is used for the yorps' bonk-on-the-head thing.
// objects arm_typee scanned bottom to top, and first pixel
// touching player is what goes in here.
unsigned char hity;
bool needinit; // 1=new object--requires initilization
bool dead;
......@@ -168,8 +159,6 @@ public:
unsigned int getYDownPos();
unsigned int getYMidPos();
unsigned int x, y; // x,y location in map coords, CSFed
void processFalling();
void draw();
......@@ -181,6 +170,7 @@ private:
CMap *mp_Map;
Uint16 m_blinktime;
unsigned int x, y; // x,y location in map coords, CSFed
static int m_number_of_objects;
};
......
......@@ -137,8 +137,10 @@ bool CEGAGraphicsGalaxy::loadData()
if(!readfonts()) return false;
if(!readBitmaps()) return false;
if(!readMaskedBitmaps()) return false;
g_pGfxEngine->createEmptyTilemap(4);
if(!readTilemaps()) return false;
//k456_export_masked_tiles();
if(!readMaskedTilemaps()) return false;
//k456_export_8_tiles();
//k456_export_8_masked_tiles();
//k456_export_sprites();
......@@ -275,6 +277,64 @@ void CEGAGraphicsGalaxy::extractTile(SDL_Surface *sfc, std::vector<unsigned char
}
}
/**
* \brief This function extracts a tile from the galaxy graphics map, and converts it properly to a
* SDL Surface
*/
void CEGAGraphicsGalaxy::extractMaskedTile(SDL_Surface *sfc, std::vector<unsigned char> &data,
Uint16 size, Uint16 columns, size_t tile)
{
if(!data.empty())
{
// Decode the image data
for(size_t p = 0; p < 4; p++)
{
// Decode the lines of the bitmap data
Uint8 *pointer = &(data[0]) + (p+1) * (size/8) * size;
for(size_t y = 0; y < size; y++)
{
Uint8 *pixel = (Uint8*)sfc->pixels +
size*(tile%columns) +
size*size*columns*(tile/columns) +
(size*columns*y);
for(size_t x = 0; x < (size/8); x++)
{
Uint8 bit,b;
for(b=0 ; b<8 ; b++)
{
bit = getBit(*pointer, 7-b);
*pixel |= (bit<<p);
pixel++;
}
pointer++;
}
}
}
// now apply the mask!
Uint8 *pointer = &(data[0]);
for(size_t y = 0; y < size; y++)
{
Uint8 *pixel = (Uint8*)sfc->pixels +
size*(tile%columns) +
size*size*columns*(tile/columns) +
(size*columns*y);
for(size_t x = 0; x < (size/8); x++)
{
Uint8 bit,b;
for(b=0 ; b<8 ; b++)
{
bit = getBit(*pointer, 7-b);
if(bit == 1)
*pixel = 16;
pixel++;
}
pointer++;
}
}
}
}
/**
* \brief prepares to load the data. Does a bit of extraction
* \return returns true, if loading was successful
......@@ -569,7 +629,6 @@ bool CEGAGraphicsGalaxy::readTilemaps()
{
int ep = m_episode - 4;
g_pGfxEngine->createEmptyTilemap(4);
CTilemap &Tilemap = g_pGfxEngine->getTileMap(0);
Tilemap.CreateSurface( g_pGfxEngine->Palette.m_Palette, SDL_SWSURFACE,
EpisodeInfo[ep].Num16Tiles, 4, 18 );
......@@ -587,6 +646,27 @@ bool CEGAGraphicsGalaxy::readTilemaps()
return true;
}
bool CEGAGraphicsGalaxy::readMaskedTilemaps()
{
int ep = m_episode - 4;
CTilemap &Tilemap = g_pGfxEngine->getTileMap(1);
Tilemap.CreateSurface( g_pGfxEngine->Palette.m_Palette, SDL_SWSURFACE,
EpisodeInfo[ep].Num16MaskedTiles, 4, 18 );
SDL_Surface *sfc = Tilemap.getSDLSurface();
SDL_FillRect(sfc,NULL, 0);
if(SDL_MUSTLOCK(sfc)) SDL_LockSurface(sfc);
for(size_t i = 0; i < EpisodeInfo[ep].Num16MaskedTiles; i++)
{
extractMaskedTile(sfc, m_egagraph.at(EpisodeInfo[ep].Index16MaskedTiles + i).data, 16, 18, i);
}
SDL_UnlockSurface(sfc);
return true;
}
//
//void k456_export_masked_tiles()
//{
......
......@@ -33,6 +33,8 @@ public:
bool masked=false);
void extractTile(SDL_Surface *sfc, std::vector<unsigned char> &data,
Uint16 size, Uint16 columns, size_t tile);
void extractMaskedTile(SDL_Surface *sfc, std::vector<unsigned char> &data,
Uint16 size, Uint16 columns, size_t tile);
bool begin();
Uint8 getBit(unsigned char data, Uint8 leftshift);
......@@ -40,6 +42,7 @@ public:
bool readBitmaps();
bool readMaskedBitmaps();
bool readTilemaps();
bool readMaskedTilemaps();
virtual ~CEGAGraphicsGalaxy();
......
......@@ -102,7 +102,7 @@ void CPlayGameGalaxy::processRendering()
{
g_pGfxEngine->getTileMap(0).drawTile(g_pVideoDriver->getBlitSurface(),
16*x, 16*y, m_Map.at(m_posx+x,m_posy+y,0) );
//g_pGfxEngine->getTileMap(0).drawTile(g_pVideoDriver->getBlitSurface(),
//g_pGfxEngine->getTileMap(1).drawTile(g_pVideoDriver->getBlitSurface(),
//16*x, 16*y, m_Map.at(m_posx+x,m_posy+y,0) );
}
}
......
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