Commit dd2fc837 authored by Gerhard Stein's avatar Gerhard Stein

HUD update to make it faster. Bitmap and Sprite mapping improved and Music in Keen 5. Yay!

parent 8ce8812d
......@@ -18,6 +18,7 @@ CHUD::CHUD(unsigned long &score, signed char &lives,
m_score(score),
m_lives(lives),
m_charges(charges),
mpHUDBox(NULL),
mpCamlead(camlead)
{
m_Rect.x = 4;
......@@ -31,9 +32,9 @@ mpCamlead(camlead)
CreateBackground();
else
{
CSprite &HUDBox = g_pGfxEngine->getSprite(129);
m_Rect.h = HUDBox.getHeight()+2;
m_Rect.w = HUDBox.getWidth()+2;
mpHUDBox = g_pGfxEngine->getSprite("HUDBACKGROUND");
m_Rect.h = mpHUDBox->getHeight()+2;
m_Rect.w = mpHUDBox->getWidth()+2;
mpHUDBlit = CG_CreateRGBSurface( m_Rect );
mpHUDBlit = SDL_DisplayFormatAlpha( mpHUDBlit.get() );
}
......@@ -158,8 +159,7 @@ void CHUD::renderGalaxy()
// Draw the HUD with all the digits
SDL_Surface* blitsfc = mpHUDBlit.get();
CSprite &HUDBox = g_pGfxEngine->getSprite(129);
HUDBox._drawSprite( blitsfc, m_Rect.x, m_Rect.y );
mpHUDBox->_drawSprite( blitsfc, m_Rect.x, m_Rect.y );
g_pGfxEngine->drawDigits(getRightAlignedString(itoa(score),9), m_Rect.x+8, m_Rect.y+4, blitsfc );
g_pGfxEngine->drawDigits(getRightAlignedString(itoa(charges),2), m_Rect.x+64, m_Rect.y+20, blitsfc );
g_pGfxEngine->drawDigits(getRightAlignedString(itoa(lives),2), m_Rect.x+24, m_Rect.y+20, blitsfc );
......
......@@ -14,6 +14,7 @@
#include "Playerdefines.h"
#include "engine/spritedefines.h"
#include "SmartPointer.h"
#include "graphics/CSprite.h"
#ifndef CHUD_H_
#define CHUD_H_
......@@ -39,6 +40,7 @@ private:
unsigned long &m_score;
signed char &m_lives;
unsigned int &m_charges;
CSprite *mpHUDBox;
SmartPointer <SDL_Surface> mpBackground;
SmartPointer <SDL_Surface> mpHUDBlit;
......
......@@ -18,6 +18,7 @@
#include "common/direction.h"
#include "SmartPointer.h"
#include "CVec.h"
#include "graphics/CBitmap.h"
#include <vector>
class CGalaxySpriteObject;
......@@ -77,13 +78,13 @@ struct EventSendDialog : CEvent
struct EventSendBitmapDialogMsg : EventSendDialog
{
const uint16_t BitmapID;
const CBitmap &BitmapRef;
const direction_t Direction;
EventSendBitmapDialogMsg(const uint16_t &lBitmapID,
EventSendBitmapDialogMsg(const CBitmap &lBitmapRef,
const std::string& lMsg,
const direction_t& lDirection = LEFT) :
EventSendDialog(lMsg),
BitmapID(lBitmapID),
BitmapRef(lBitmapRef),
Direction(lDirection)
{}
};
......
......@@ -719,6 +719,8 @@ bool CEGAGraphicsGalaxy::readSprites( size_t NumSprites, size_t IndexSprite )
// Create all the sprites
g_pGfxEngine->createEmptySprites(NumSprites);
int ep = m_episode - 4;
// ARM processor requires all ints and structs to be 4-byte aligned, so we're just using memcpy()
SpriteHeadStruct SprHead[NumSprites];
memcpy( SprHead, &(m_egagraph.at(2).data.at(0)), NumSprites*sizeof(SpriteHeadStruct) );
......@@ -795,6 +797,7 @@ bool CEGAGraphicsGalaxy::readSprites( size_t NumSprites, size_t IndexSprite )
}
SDL_UnlockSurface(sfc);
Sprite.setName(m_SpriteNameMap[ep][i]);
}
return true;
}
......
......@@ -60,6 +60,7 @@ private:
std::vector<ChunkStruct> m_egagraph;
std::string m_BitmapNameMap[4][1000];
std::string m_SpriteNameMap[4][1000];
CExeFile &m_Exefile;
};
......
......@@ -62,10 +62,7 @@ bool CLevelPlay::loadLevel(const Uint16 level)
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
if(g_pBehaviorEngine->getEpisode() == 4 )
EventContainer.add( new EventSendBitmapDialogMsg(106, loading_text, LEFT) );
else
EventContainer.add( new EventSendBitmapDialogMsg(1, loading_text, LEFT) );
EventContainer.add( new EventSendBitmapDialogMsg(*g_pGfxEngine->getBitmap("KEENTHUMBSUP"), loading_text, LEFT) );
mMap.drawAll();
return true;
......
......@@ -236,7 +236,7 @@ void CPlayGameGalaxy::process()
if( EventSendBitmapDialogMsg *ev = eventContainer.occurredEvent<EventSendBitmapDialogMsg>() )
{
CMessageBoxBitmapGalaxy *pMsgBox = new CMessageBoxBitmapGalaxy( ev->Msg, ev->BitmapID, ev->Direction );
CMessageBoxBitmapGalaxy *pMsgBox = new CMessageBoxBitmapGalaxy( ev->Msg, ev->BitmapRef, ev->Direction );
pMsgBox->init();
mMessageBoxes.push_back( pMsgBox );
......@@ -247,7 +247,7 @@ void CPlayGameGalaxy::process()
std::vector< SmartPointer<EventSendBitmapDialogMsg> >::iterator it = ev->msgs.begin();
for( ; it != ev->msgs.end() ; it++ )
{
CMessageBoxBitmapGalaxy *pMsgBox = new CMessageBoxBitmapGalaxy( (*it)->Msg, (*it)->BitmapID, (*it)->Direction );
CMessageBoxBitmapGalaxy *pMsgBox = new CMessageBoxBitmapGalaxy( (*it)->Msg, (*it)->BitmapRef, (*it)->Direction );
pMsgBox->init();
mMessageBoxes.push_back( pMsgBox );
......
......@@ -32,10 +32,7 @@ void CWorldMap::init()
const std::string loading_text = g_pBehaviorEngine->getString("WORLDMAP_LOAD_TEXT");
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
if(g_pBehaviorEngine->getEpisode() == 4 )
EventContainer.add( new EventSendBitmapDialogMsg(106, loading_text, LEFT) );
else
EventContainer.add( new EventSendBitmapDialogMsg(1, loading_text, LEFT) );
EventContainer.add( new EventSendBitmapDialogMsg(*g_pGfxEngine->getBitmap("KEENTHUMBSUP"), loading_text, LEFT) );
mMap.drawAll();
}
......
......@@ -20,6 +20,7 @@ void CEGAGraphicsGalaxy::createBitmapsIDs()
m_BitmapNameMap[0][97] = "KEENSWATCH";
m_BitmapNameMap[0][103] = "TITLE";
m_BitmapNameMap[0][106] = "KEENTHUMBSUP";
m_SpriteNameMap[0][129] = "HUDBACKGROUND";
// Menu Labels
m_BitmapNameMap[0][82] = "MAINMENULABEL";
......@@ -40,6 +41,8 @@ void CEGAGraphicsGalaxy::createBitmapsIDs()
// Keen 5 Bitmap IDs
m_BitmapNameMap[1][82] = "TITLE";
m_BitmapNameMap[1][76] = "KEENSWATCH";
m_BitmapNameMap[1][85] = "KEENTHUMBSUP";
m_SpriteNameMap[1][133] = "HUDBACKGROUND";
// Menu Labels
m_BitmapNameMap[1][61] = "MAINMENULABEL";
......
......@@ -72,7 +72,7 @@ void CPlayerWM::process()
{
finishLevel(ev->levelObject);
const std::string loading_text = g_pBehaviorEngine->getString("WORLDMAP_LOAD_TEXT");
EventContainer.add( new EventSendBitmapDialogMsg(106, loading_text, LEFT) );
EventContainer.add( new EventSendBitmapDialogMsg(*g_pGfxEngine->getBitmap("KEENTHUMBSUP"), loading_text, LEFT) );
}
EventContainer.pop_Event();
}
......@@ -180,7 +180,7 @@ void CPlayerWM::processMoving()
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
g_pSound->playSound( SOUND_CANT_SWIM, PLAY_PAUSEALL );
EventContainer.add( new EventSendBitmapDialogMsg(105,
EventContainer.add( new EventSendBitmapDialogMsg(g_pGfxEngine->getBitmap(105),
g_pBehaviorEngine->getString("CANT_SWIM_TEXT"), LEFT) );
m_cantswim = true;
......
......@@ -141,12 +141,12 @@ void CCouncilMember::getTouchedBy(CSpriteObject &theObject)
std::vector< SmartPointer<EventSendBitmapDialogMsg> > msgs;
msgs.push_back( new EventSendBitmapDialogMsg(104, elder_text[0], LEFT) );
msgs.push_back( new EventSendBitmapDialogMsg(106, elder_text[1], RIGHT) );
msgs.push_back( new EventSendBitmapDialogMsg(g_pGfxEngine->getBitmap(104), elder_text[0], LEFT) );
msgs.push_back( new EventSendBitmapDialogMsg(*g_pGfxEngine->getBitmap("KEENTHUMBSUP"), elder_text[1], RIGHT) );
if(rescuedelders == 7)
msgs.push_back( new EventSendBitmapDialogMsg(106, g_pBehaviorEngine->getString(answermap[8]), RIGHT) );
msgs.push_back( new EventSendBitmapDialogMsg(*g_pGfxEngine->getBitmap("KEENTHUMBSUP"), g_pBehaviorEngine->getString(answermap[8]), RIGHT) );
EventContainer.add( new EventSendBitmapDialogMessages(msgs) );
......
......@@ -36,7 +36,7 @@ void CDiveSuit::getTouchedBy(CSpriteObject &theObject)
g_pSound->playSound( SOUND_GET_WETSUIT, PLAY_PAUSEALL );
taken = swimsuit = true;
EventContainer.add( new EventSendBitmapDialogMsg(106,
EventContainer.add( new EventSendBitmapDialogMsg(*g_pGfxEngine->getBitmap("KEENTHUMBSUP"),
g_pBehaviorEngine->getString("SWIM_SUIT_TEXT"), LEFT) );
EventContainer.add( new EventExitLevel(mp_Map->getLevel(), true) );
......
......@@ -77,9 +77,9 @@ void CLindsey::getTouchedBy(CSpriteObject &theObject)
std::vector< SmartPointer<EventSendBitmapDialogMsg> > msgs;
msgs.push_back( new EventSendBitmapDialogMsg(108, lindsey_text[0], LEFT) );
msgs.push_back( new EventSendBitmapDialogMsg(108, lindsey_text[1], LEFT) );
msgs.push_back( new EventSendBitmapDialogMsg(106, lindsey_text[2], RIGHT) );
msgs.push_back( new EventSendBitmapDialogMsg(g_pGfxEngine->getBitmap(108), lindsey_text[0], LEFT) );
msgs.push_back( new EventSendBitmapDialogMsg(g_pGfxEngine->getBitmap(108), lindsey_text[1], LEFT) );
msgs.push_back( new EventSendBitmapDialogMsg(*g_pGfxEngine->getBitmap("KEENTHUMBSUP"), lindsey_text[2], RIGHT) );
EventContainer.add( new EventSendBitmapDialogMessages(msgs) );
......
......@@ -12,10 +12,10 @@
const int FONT_ID = 0;
CMessageBoxBitmapGalaxy::CMessageBoxBitmapGalaxy( const std::string& Text,
const Uint16 BitmapId,
const CBitmap &BitmapRef,
const direction_t alignment ) :
CMessageBoxGalaxy(Text),
mBitmap(g_pGfxEngine->getBitmap(BitmapId)),
mBitmap(BitmapRef),
mAlignment(alignment)
{
......
......@@ -21,14 +21,14 @@ public:
* \param Text Message to be shown
* \param BitmapId Bitmap that will be shown to the left side in the box
*/
CMessageBoxBitmapGalaxy( const std::string& Text, const Uint16 BitmapId,
CMessageBoxBitmapGalaxy( const std::string& Text, const CBitmap &BitmapRef,
const direction_t alignment = LEFT );
virtual ~CMessageBoxBitmapGalaxy() {};
virtual void init();
private:
CBitmap &mBitmap;
const CBitmap &mBitmap;
const direction_t mAlignment;
};
......
......@@ -71,15 +71,6 @@ bool CBitmap::loadHQBitmap( const std::string& filename )
return false;
}
///
// Getters and Setters
///
void CBitmap::setName(const std::string &name)
{
mName = name;
}
/**
* \brief The function that blits the sprite to dst
......@@ -94,7 +85,7 @@ void CBitmap::draw(Uint16 x, Uint16 y)
///
// Drawing Routines
///
void CBitmap::_draw(SDL_Surface *dst, Uint16 x, Uint16 y)
void CBitmap::_draw(SDL_Surface *dst, Uint16 x, Uint16 y) const
{
SDL_Rect dst_rect;
dst_rect.x = x; dst_rect.y = y;
......
......@@ -32,15 +32,14 @@ public:
return mpBitmapSurface.get();
}
void setName(const std::string &name);
Uint16 getWidth() { return mpBitmapSurface->w; }
Uint16 getHeight() { return mpBitmapSurface->h; }
Uint16 getWidth() const { return mpBitmapSurface->w; }
Uint16 getHeight() const { return mpBitmapSurface->h; }
std::string getName() const { return mName; }
void setName(std::string &name) { mName = name; }
void setName(const std::string &name) { mName = name; }
void draw(Uint16 x, Uint16 y);
void _draw(SDL_Surface *dst, Uint16 x, Uint16 y);
void _draw(SDL_Surface *dst, Uint16 x, Uint16 y) const;
private:
std::string mName;
......
......@@ -6,6 +6,7 @@
*/
#include "CGfxEngine.h"
#include "CLogFile.h"
#include "sdl/input/CInput.h"
......@@ -194,13 +195,35 @@ void CGfxEngine::drawDialogBox(SDL_Surface *DialogSurface, int x1, int y1, int w
CBitmap *CGfxEngine::getBitmap(const std::string &name) const
{
std::string s_name;
for(Uint8 i=0 ; i<Bitmap.size() ; i++)
for(unsigned int i=0 ; i<Bitmap.size() ; i++)
{
s_name = Bitmap[i].getName();
if(s_name == name)
return const_cast<CBitmap*>(&Bitmap[i]);
}
std::string error = "Ooops! Wrong TextID ";
error += "name";
error += "used!";
g_pLogFile->textOut(error);
return NULL;
}
CSprite *CGfxEngine::getSprite(const std::string &name) const
{
std::string s_name;
for(unsigned int i=0 ; i<Sprite.size() ; i++)
{
s_name = Sprite[i].getName();
if(s_name == name)
return const_cast<CSprite*>(&Sprite[i]);
}
return NULL;
}
......
......@@ -63,6 +63,8 @@ public:
CBitmap &getMaskedBitmap(Uint16 slot) { return maskedBitmap.at(slot); }
CBitmap *getBitmap(const std::string &name) const;
CSprite *getSprite(const std::string &name) const;
CEffects *Effect() { return mpEffects.get(); }
bool applyingEffects() { return !mpEffects.empty(); }
......
......@@ -47,6 +47,9 @@ public:
void setWidth(Uint8 w) { m_xsize=w; };
void setHeight(Uint8 h) { m_ysize=h; };
std::string getName() const { return mName; }
void setName(const std::string &name) { mName = name; }
// bounding box for hit detection
Sint32 m_bboxX1, m_bboxY1;
Sint32 m_bboxX2, m_bboxY2;
......@@ -55,6 +58,7 @@ private:
SmartPointer<SDL_Surface> mpSurface;
SmartPointer<SDL_Surface> mpMasksurface;
std::string mName;
Uint8 m_xsize, m_ysize;
Sint16 m_xoffset, m_yoffset;
Uint8 m_alpha;
......
......@@ -19,8 +19,8 @@
const Uint32 GalaxySongAssignments[] =
{
0x02F206,
0x030679,
0x03103D,
0x03067A,
0x03103E,
};
CIMFPlayer::CIMFPlayer( const SDL_AudioSpec& AudioSpec, COPLEmulator& opl_emulator ) :
......
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