Commit 40b47e49 authored by Gerhard Stein's avatar Gerhard Stein

Some more fixups escpecially the scrolling code is much smaller now

parent ccd8f0dd
......@@ -247,7 +247,7 @@ bool CObject::hitdetectWithTilePropertyRect(const Uint16 Property, int &lx, int
{
for( int j=0 ; j<lh ; j+=res )
{
const char behavior = Tile[mp_Map->getPlaneDataAt(1, lx+i, ly+j)].behaviour;
const signed char behavior = Tile[mp_Map->getPlaneDataAt(1, lx+i, ly+j)].behaviour;
if(behavior == Property || behavior == Property-128 ) // -128 for foreground properties
{
lx = lx+i;
......@@ -268,7 +268,7 @@ bool CObject::hitdetectWithTilePropertyRect(const Uint16 Property, int &lx, int
bool CObject::hitdetectWithTileProperty(const int Property, const int x, const int y)
{
std::vector<CTileProperties> &Tile = g_pBehaviorEngine->getTileProperties(1);
const char behavior = Tile[mp_Map->getPlaneDataAt(1, x, y)].behaviour;
const signed char behavior = Tile[mp_Map->getPlaneDataAt(1, x, y)].behaviour;
if(behavior == Property || behavior == Property-128 ) // +128 for foreground properties
return true;
else
......
......@@ -157,7 +157,7 @@ public:
char keyprocstate;
char wm_lastenterstate;
char pdie, pdieframe, pdietimer;
unsigned char pdie, pdieframe, pdietimer;
int pdietillfly;
signed int pdie_xvect;
bool psliding;
......
......@@ -36,7 +36,7 @@ Uint8* CAudioVorticon::loadSoundStream(Uint32 &buffer_size, Uint8* exedata)
buffer_size = 0;
const std::string gamepath = m_ExeFile.getDataDirectory();
const std::string soundfile = "sounds.ck" + itoa(m_ExeFile.getEpisode());
g_pLogFile->ftextOut("sound_load_all(): trying to open the game audio...<br>");
g_pLogFile->ftextOut("loadSoundStream(): trying to open the game audio...<br>");
std::ifstream file;
if(!OpenGameFileR(file, getResourceFilename(soundfile, gamepath, false, true), std::ios::binary))
......@@ -184,7 +184,7 @@ bool CAudioVorticon::loadSoundData()
const std::string soundfile = "sounds.ck" + itoa(episode);
const std::string DataDirectory = m_ExeFile.getDataDirectory();
g_pLogFile->ftextOut("sound_load_all(): loading all sounds...<br>");
g_pLogFile->ftextOut("loadSoundData(): loading all sounds...<br>");
Uint32 buffer_size;
Uint8 *buffer = loadSoundStream( buffer_size, m_ExeFile.getRawData() );
......
......@@ -15,10 +15,6 @@
#include "common/CTileProperties.h"
// Reference to palette.c
char pal_addcolor(unsigned char r, unsigned char g, unsigned char b);
int pal_getcolor(unsigned char r, unsigned char g, unsigned char b);
class CEGASprit {
public:
CEGASprit(int planesize,
......
......@@ -102,20 +102,6 @@ void CPalette::setupColorPalettes(byte *p_exedata, int m_episode)
}
}
// adds a color onto the end of the palette and returns it's index.
// if the palette is full, returns -1.
char CPalette::addcolor(unsigned char r, unsigned char g, unsigned char b)
{
if (m_numcolors >= 255) return -1;
m_Palette[m_numcolors].r = r;
m_Palette[m_numcolors].g = g;
m_Palette[m_numcolors].b = b;
m_numcolors++;
return (m_numcolors-1);
}
///
// Getters and Setters
///
......
......@@ -40,7 +40,6 @@ public:
void setdark(bool dark);
void setdarkness(Uint8 darkness);
char addcolor(unsigned char r, unsigned char g, unsigned char b);
int getcolor(unsigned char r, unsigned char g, unsigned char b);
bool in_progress(void);
......
......@@ -37,7 +37,7 @@ private:
Uint8 m_Speed;
Uint32 m_Color;
Uint8 m_Alpha;
char m_FadeDir;
fade_dir m_FadeDir;
Uint8 m_Style;
Uint8 m_MaxAlpha;
SmartPointer<SDL_Surface> mpFadeSurface;
......
......@@ -116,9 +116,7 @@ void CGUIComboSelection::setList(const char **strArray, const int numElem)
for( int i=0 ; i<numElem ; i++ )
{
mOptionsList.push_back( strArray[i] );
}
mOLCurrent = mOptionsList.begin();
......
......@@ -110,13 +110,13 @@ bool COGGPlayer::readOGGStream( OggVorbis_File &oggStream, char *buffer, const
return false;
}
bool COGGPlayer::readOGGStreamAndResample( OggVorbis_File &oggStream, char *buffer, const size_t output_size, const size_t input_size, const SDL_AudioSpec &OGGAudioSpec )
bool COGGPlayer::readOGGStreamAndResample( OggVorbis_File &oggStream, Uint8 *buffer, const size_t output_size, const size_t input_size, const SDL_AudioSpec &OGGAudioSpec )
{
char buf[input_size];
Uint8 buf[input_size];
bool eof = readOGGStream( oggStream, buf, input_size, OGGAudioSpec );
bool eof = readOGGStream( oggStream, reinterpret_cast<char*>(buf), input_size, OGGAudioSpec );
resample((Uint8*)buffer, (Uint8*)buf, output_size, input_size, OGGAudioSpec.format, OGGAudioSpec.channels);
resample( buffer, buf, output_size, input_size, OGGAudioSpec.format, OGGAudioSpec.channels);
return eof;
}
......@@ -141,11 +141,11 @@ void COGGPlayer::readBuffer(Uint8* buffer, Uint32 length)
insize++;
insize *= mult;
rewind = readOGGStreamAndResample(m_oggStream, (char*)m_Audio_cvt.buf, m_Audio_cvt.len, insize, m_AudioFileSpec);
rewind = readOGGStreamAndResample(m_oggStream, m_Audio_cvt.buf, m_Audio_cvt.len, insize, m_AudioFileSpec);
}
else
{
rewind = readOGGStream(m_oggStream, (char*)m_Audio_cvt.buf, m_Audio_cvt.len, m_AudioFileSpec);
rewind = readOGGStream(m_oggStream, reinterpret_cast<char*>(m_Audio_cvt.buf), m_Audio_cvt.len, m_AudioFileSpec);
}
// then convert it into SDL Audio buffer
......
......@@ -36,7 +36,7 @@ public:
private:
bool readOGGStream( OggVorbis_File &oggStream, char *buffer, const size_t &size, const SDL_AudioSpec &OGGAudioSpec );
bool readOGGStreamAndResample( OggVorbis_File &oggStream, char *buffer, const size_t output_size, const size_t input_size, const SDL_AudioSpec &OGGAudioSpec );
bool readOGGStreamAndResample( OggVorbis_File &oggStream, Uint8 *buffer, const size_t output_size, const size_t input_size, const SDL_AudioSpec &OGGAudioSpec );
OggVorbis_File m_oggStream;
const std::string m_filename;
......
......@@ -35,7 +35,6 @@ public:
void stopAllSounds();
bool forcedisPlaying(void);
char sound_load_all(const std::string& path);
void callback(void *unused, Uint8 *stream, int len);
void pauseSound(void);
void resumeSounds(void);
......
......@@ -28,7 +28,6 @@ Uint16 getPowerOfTwo(Uint16 value)
// depending on what resolution has been chosen, it is mostly 320x200 or 320x240
COpenGL::COpenGL(const CVidConfig &VidConfig) :
CVideoEngine(VidConfig),
m_opengl_buffer(NULL),
m_texparam(GL_TEXTURE_2D),
m_aspectratio(m_VidConfig.m_DisplayRect.aspectRatio()),
m_GamePOTBaseDim(getPowerOfTwo(m_VidConfig.m_GameRect.w),
......@@ -209,14 +208,9 @@ bool COpenGL::init()
createTexture(m_texture, oglfilter, m_GamePOTVideoDim.w, m_GamePOTVideoDim.h);
if(m_VidConfig.m_ScaleXFilter > 1)
{
m_opengl_buffer = new char[m_GamePOTVideoDim.w*m_GamePOTVideoDim.h*m_VidConfig.m_ScaleXFilter*4];
}
else
if(m_VidConfig.m_ScaleXFilter <= 1)
{ // In that case we can do a texture based rendering
createTexture(m_texFX, oglfilter, m_GamePOTVideoDim.w, m_GamePOTVideoDim.h, true);
m_opengl_buffer = NULL;
}
// If there were any errors
......@@ -363,11 +357,4 @@ void COpenGL::updateScreen()
SDL_GL_SwapBuffers();
}
COpenGL::~COpenGL()
{
if(m_opengl_buffer)
delete[] m_opengl_buffer;
m_opengl_buffer = NULL;
}
#endif // USE_OPENGL
......@@ -34,7 +34,8 @@ struct stDims{
Uint16 getPowerOfTwo(Uint16 value);
class COpenGL : public CVideoEngine {
class COpenGL : public CVideoEngine
{
public:
COpenGL(const CVidConfig &VidConfig);
......@@ -50,11 +51,7 @@ public:
void reloadFX(SDL_Surface* surf);
virtual ~COpenGL();
private:
char* m_opengl_buffer; // Used for internal ScaleX filtering
unsigned int m_texparam;
float m_aspectratio;
......
......@@ -106,88 +106,56 @@ SDL_Surface* CVideoEngine::createSurface( std::string name, bool alpha, int widt
void CVideoEngine::blitScrollSurface() // This is only for tiles
{ // The name should be changed
SDL_Rect srcrect;
SDL_Rect dstrect;
SDL_Rect srcrect, dstrect;
Sint16 sbufferx, sbuffery;
char wraphoz, wrapvrt;
int save_dstx, save_dstw, save_srcx, save_srcw;
const SDL_Rect Gamerect = m_VidConfig.m_GameRect.SDLRect();
dstrect.x = 0; dstrect.y = 0;
srcrect.x = sbufferx = mSbufferx;
srcrect.y = sbuffery = mSbuffery;
const bool wraphoz = (sbufferx > (512-Gamerect.w));
const bool wrapvrt = (sbuffery > (512-Gamerect.h));
dstrect.w = (Gamerect.w>sbufferx) ? Gamerect.w-sbufferx : Gamerect.w ;
dstrect.h = (Gamerect.h>sbuffery) ? Gamerect.h-sbuffery : Gamerect.h ;
if (sbufferx > (Uint16)(512-Gamerect.w))
{ // need to wrap right side
srcrect.w = (512-sbufferx);
wraphoz = 1;
}
else
{ // single blit for whole horizontal copy
srcrect.w = Gamerect.w;
wraphoz = 0;
}
if (sbuffery > (Uint16)(512-Gamerect.h))
{ // need to wrap on bottom
srcrect.h = (512-sbuffery);
wrapvrt = 1;
}
else
{ // single blit for whole bottom copy
srcrect.h = Gamerect.h;
wrapvrt = 0;
}
srcrect.w = wraphoz ? (512-sbufferx) : Gamerect.w;
srcrect.h = wrapvrt ? (512-sbuffery) : Gamerect.h;
SDL_BlitSurface(ScrollSurface, &srcrect, BlitSurface, &dstrect);
if (wraphoz && wrapvrt)
{
// first do same thing we do for wraphoz
save_dstx = dstrect.x;
save_dstw = dstrect.w;
save_srcx = srcrect.x;
save_srcw = srcrect.w;
dstrect.x = srcrect.w;
dstrect.w = Gamerect.w - dstrect.x;
srcrect.x = 0;
srcrect.w = (Gamerect.w - srcrect.w);
SDL_BlitSurface(ScrollSurface, &srcrect, BlitSurface, &dstrect);
const Uint16 saveDstw = dstrect.w;
const Uint16 saveSrcw = srcrect.w;
// now repeat for the bottom
// (lower-right square)
dstrect.y = srcrect.h;
dstrect.h = Gamerect.h - dstrect.y;
srcrect.y = 0;
srcrect.h = (Gamerect.h - srcrect.h);
SDL_BlitSurface(ScrollSurface, &srcrect, BlitSurface, &dstrect);
// (lower-left square)
dstrect.x = save_dstx;
dstrect.w = save_dstw;
srcrect.x = save_srcx;
srcrect.w = save_srcw;
SDL_BlitSurface(ScrollSurface, &srcrect, BlitSurface, &dstrect);
}
else if (wraphoz)
if (wraphoz)
{
dstrect.x = srcrect.w;
dstrect.w = Gamerect.w - dstrect.x;
srcrect.x = 0;
srcrect.w = Gamerect.w - srcrect.w;
SDL_BlitSurface(ScrollSurface, &srcrect, BlitSurface, &dstrect);
if(!wrapvrt)
return;
}
else if (wrapvrt)
if (wrapvrt)
{
dstrect.y = srcrect.h;
dstrect.h = Gamerect.h - dstrect.y;
srcrect.y = 0;
srcrect.h = (Gamerect.h - srcrect.h);
srcrect.h = Gamerect.h - srcrect.h;
SDL_BlitSurface(ScrollSurface, &srcrect, BlitSurface, &dstrect);
if(!wraphoz)
return;
}
srcrect.x = sbufferx;
srcrect.w = saveSrcw;
dstrect.x = 0;
dstrect.w = saveDstw;
SDL_BlitSurface(ScrollSurface, &srcrect, BlitSurface, &dstrect);
}
void CVideoEngine::stop()
......
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