Commit 38bdbc93 authored by Gerhard Stein's avatar Gerhard Stein

Added the other tilemaps to the memory and made the load of galaxy tile masks possible

parent 6555177e
......@@ -87,13 +87,22 @@ Uint16 CMap::at(Uint16 x, Uint16 y, Uint16 t)
Uint16 CMap::getObjectat(Uint16 x, Uint16 y)
{ return m_objectlayer[x][y]; }
/**
* \brief Gets the pointer to the plane data of the map
* \param PlaneNum number of the requested Plane
*/
word *CMap::getData(Uint8 PlaneNum)
{
return m_Plane[PlaneNum].getMapDataPtr();
}
word *CMap::getForegroundData()
{ //return mp_foreground_data;
return m_Plane[1].getMapDataPtr();
{
return m_Plane[0].getMapDataPtr();
}
word *CMap::getBackgroundData()
{ //return mp_foreground_data;
{
return m_Plane[0].getMapDataPtr();
}
......
......@@ -69,6 +69,7 @@ public:
unsigned int getlevelat(unsigned int x, unsigned int y) {
return m_objectlayer[x>>4][y>>4]; }
word *getData(Uint8 PlaneNum);
word *getForegroundData();
word *getBackgroundData();
......
......@@ -67,6 +67,8 @@ void CMapLoaderGalaxy::unpackPlaneData(std::ifstream &MapFile,
longword offset, longword length,
word magic_word)
{
size_t initial_pos = MapFile.tellg();
std::vector<word> Plane;
MapFile.seekg(offset);
......@@ -86,10 +88,11 @@ void CMapLoaderGalaxy::unpackPlaneData(std::ifstream &MapFile,
// Now use the RLE Decompression
CRLE RLE;
size_t derlesize = (RLE_Plane[0]<<8)+RLE_Plane[1]; // Bytes already swapped
RLE.expand(Plane, RLE_Plane, magic_word);
//RLE.expand(Plane, RLE_Plane, magic_word);
RLE.expandSwapped(Plane, RLE_Plane, magic_word);
RLE_Plane.clear();
word *ptr = Map.getBackgroundData();
word *ptr = Map.getData(PlaneNumber);
for(size_t y=0; y<Map.m_height ; y++)
{
for(size_t x=0; x<Map.m_width ; x++)
......@@ -113,6 +116,8 @@ void CMapLoaderGalaxy::unpackPlaneData(std::ifstream &MapFile,
{
g_pLogFile->textOut( "\nERROR Plane Uncompress Carmack Size Failed: Actual " + itoa(RLE_Plane.size()) + " bytes Expected " + itoa(decarmacksize) + " bytes<br>");
}
MapFile.seekg(initial_pos);
}
......@@ -130,7 +135,7 @@ bool CMapLoaderGalaxy::loadMap(CMap &Map, Uint8 level)
magic_word = READWORD(Maphead);
// Get location of the level data from MAPHEAD Located in the EXE-File.
Maphead += (level-1)*sizeof(longword);
Maphead += level*sizeof(longword);
level_offset = READLONGWORD(Maphead);
// Open the Gamemaps file
......@@ -200,6 +205,20 @@ bool CMapLoaderGalaxy::loadMap(CMap &Map, Uint8 level)
Map.createEmptyDataPlanes(Width*Height);
unpackPlaneData(MapFile, Map, 0, Plane_Offset[0], Plane_Length[0], magic_word);
unpackPlaneData(MapFile, Map, 1, Plane_Offset[1], Plane_Length[1], magic_word);
unpackPlaneData(MapFile, Map, 2, Plane_Offset[2], Plane_Length[2], magic_word);
FILE *fp = fopen("bumpplane1.bin","wb");
fwrite(Map.getData(0), 2, 8052/2, fp);
fclose(fp);
fp = fopen("bumpplane2.bin","wb");
fwrite(Map.getData(1), 2, 8052/2, fp);
fclose(fp);
fp = fopen("bumpplane3.bin","wb");
fwrite(Map.getData(2), 2, 8052/2, fp);
fclose(fp);
}
MapFile.close();
return true;
......
......@@ -36,7 +36,7 @@ bool CPlayGameGalaxy::init()
m_Map.setTileMap(g_pGfxEngine->getTileMap(0));
m_Map.setScrollSurface(g_pVideoDriver->getScrollSurface());
MapLoader.loadMap(m_Map, 1); // Map Level?
MapLoader.loadMap(m_Map, 0); // Map Level?
m_Map.gotoPos(0, 0); // Coordinates of star sky
//m_Map.drawAll();
......@@ -102,8 +102,8 @@ 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(1).drawTile(g_pVideoDriver->getBlitSurface(),
//16*x, 16*y, m_Map.at(m_posx+x,m_posy+y,0) );
g_pGfxEngine->getTileMap(1).drawTile(g_pVideoDriver->getBlitSurface(),
16*x, 16*y, m_Map.at(m_posx+x,m_posy+y,0) );
}
}
......
......@@ -89,7 +89,6 @@ void CRLE::expand( std::vector<word>& dst, std::vector<byte>& src, word key )
finsize = (high_byte<<8) | low_byte;
finsize /= 2;
//for(size_t i=WORDSIZE; i<src.size(); i+=inc )
for(size_t i=WORDSIZE ; dst.size() < finsize ; i+=inc)
{
// Read datum (word)
......
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