reverted all src changes from rev95 commit (because all old work was just removed)
git-svn-id: https://clonekeenplus.svn.sourceforge.net/svnroot/clonekeenplus/cgenius/trunk@107 4df4b0f3-56ce-47cb-b001-ed939b7d65a6
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
* Author: gerstrong
|
||||
*/
|
||||
#include "COpenGL.h"
|
||||
#include "CVideoDriver.h"
|
||||
#include "../CLogFile.h"
|
||||
|
||||
#define GAME_STD_WIDTH 320
|
||||
@@ -115,7 +116,7 @@ void COpenGL::render(void)
|
||||
//Clear the screen
|
||||
glClear(GL_COLOR_BUFFER_BIT); // Clear The Screen
|
||||
|
||||
SDL_LockSurface(m_blitsurface);
|
||||
LockSurface(m_blitsurface);
|
||||
|
||||
if(m_ScaleX == 2) //Scale 2x
|
||||
{
|
||||
@@ -157,7 +158,7 @@ void COpenGL::render(void)
|
||||
glVertex3f (0.0, 1.0, 0.0);
|
||||
glEnd();
|
||||
|
||||
SDL_UnlockSurface(m_blitsurface);
|
||||
UnlockSurface(m_blitsurface);
|
||||
|
||||
// Reset (Position?)
|
||||
glLoadIdentity();
|
||||
|
||||
@@ -480,7 +480,7 @@ char tempbuf[80];
|
||||
#else
|
||||
sprintf(tempbuf, "FPS: %03d", fps);
|
||||
#endif
|
||||
g_pGraphics->drawFont( (unsigned char *) tempbuf, 320-3-(strlen( (char *) tempbuf)<<3), 3, 1);
|
||||
g_pGraphics->drawFont( tempbuf, 320-3-(strlen( (char *) tempbuf)<<3), 3, 1);
|
||||
}
|
||||
|
||||
update_screen();
|
||||
@@ -499,11 +499,11 @@ void CVideoDriver::update_screen(void)
|
||||
|
||||
mp_OpenGL->render();
|
||||
|
||||
SDL_LockSurface(FGLayerSurface);
|
||||
LockSurface(FGLayerSurface);
|
||||
// Flush the layers
|
||||
memset(FGLayerSurface->pixels,SDL_MapRGB(FGLayerSurface->format, 0, 0, 0),
|
||||
GAME_STD_WIDTH*GAME_STD_HEIGHT*FGLayerSurface->format->BytesPerPixel);
|
||||
SDL_UnlockSurface(FGLayerSurface);
|
||||
UnlockSurface(FGLayerSurface);
|
||||
}
|
||||
else // No OpenGL but Software Rendering
|
||||
{
|
||||
@@ -514,8 +514,8 @@ void CVideoDriver::update_screen(void)
|
||||
// another offscreen buffer, and must now stretchblit it to the screen
|
||||
if (Zoom == 1 && m_Resolution.width != 320 )
|
||||
{
|
||||
SDL_LockSurface(BlitSurface);
|
||||
SDL_LockSurface(screen);
|
||||
LockSurface(BlitSurface);
|
||||
LockSurface(screen);
|
||||
|
||||
if(Filtermode == 0)
|
||||
{
|
||||
@@ -527,13 +527,13 @@ void CVideoDriver::update_screen(void)
|
||||
g_pLogFile->textOut(PURPLE,"Try to use a higher zoom factor. Switching to no-filter<br>");
|
||||
Filtermode = 0;
|
||||
}
|
||||
SDL_UnlockSurface(screen);
|
||||
SDL_UnlockSurface(BlitSurface);
|
||||
UnlockSurface(screen);
|
||||
UnlockSurface(BlitSurface);
|
||||
}
|
||||
if (Zoom == 2)
|
||||
{
|
||||
SDL_LockSurface(BlitSurface);
|
||||
SDL_LockSurface(screen);
|
||||
LockSurface(BlitSurface);
|
||||
LockSurface(screen);
|
||||
|
||||
if(Filtermode == 0)
|
||||
{
|
||||
@@ -551,13 +551,13 @@ void CVideoDriver::update_screen(void)
|
||||
Filtermode = 0;
|
||||
}
|
||||
|
||||
SDL_UnlockSurface(screen);
|
||||
SDL_UnlockSurface(BlitSurface);
|
||||
UnlockSurface(screen);
|
||||
UnlockSurface(BlitSurface);
|
||||
}
|
||||
else if (Zoom == 3)
|
||||
{
|
||||
SDL_LockSurface(BlitSurface);
|
||||
SDL_LockSurface(screen);
|
||||
LockSurface(BlitSurface);
|
||||
LockSurface(screen);
|
||||
|
||||
if(Filtermode == 0)
|
||||
{
|
||||
@@ -579,13 +579,13 @@ void CVideoDriver::update_screen(void)
|
||||
g_pLogFile->textOut(PURPLE,"Try to use a higher zoom factor. Switching to no-filter<br>");
|
||||
Filtermode = 0;
|
||||
}
|
||||
SDL_UnlockSurface(screen);
|
||||
SDL_UnlockSurface(BlitSurface);
|
||||
UnlockSurface(screen);
|
||||
UnlockSurface(BlitSurface);
|
||||
}
|
||||
else if (Zoom == 4)
|
||||
{
|
||||
SDL_LockSurface(BlitSurface);
|
||||
SDL_LockSurface(screen);
|
||||
LockSurface(BlitSurface);
|
||||
LockSurface(screen);
|
||||
|
||||
if(Filtermode == 0)
|
||||
{
|
||||
@@ -612,18 +612,18 @@ void CVideoDriver::update_screen(void)
|
||||
g_pLogFile->textOut(PURPLE,"Try to use a higher zoom factor. Switching to no-filter<br>");
|
||||
Filtermode = 0;
|
||||
}
|
||||
SDL_UnlockSurface(screen);
|
||||
SDL_UnlockSurface(BlitSurface);
|
||||
UnlockSurface(screen);
|
||||
UnlockSurface(BlitSurface);
|
||||
}
|
||||
|
||||
SDL_Flip(screen);
|
||||
//SDL_UpdateRect(screen, screenrect.x, screenrect.y, screenrect.w, screenrect.h);
|
||||
|
||||
SDL_LockSurface(FGLayerSurface);
|
||||
LockSurface(FGLayerSurface);
|
||||
// Flush the layers
|
||||
memset(FGLayerSurface->pixels,SDL_MapRGB(FGLayerSurface->format, 0, 0, 0),
|
||||
GAME_STD_WIDTH*GAME_STD_HEIGHT*FGLayerSurface->format->BytesPerPixel);
|
||||
SDL_UnlockSurface(FGLayerSurface);
|
||||
UnlockSurface(FGLayerSurface);
|
||||
#ifdef USE_OPENGL
|
||||
}
|
||||
#endif
|
||||
@@ -765,7 +765,7 @@ int y;
|
||||
y = CONSOLE_MESSAGE_Y;
|
||||
for(i=0;i<NumConsoleMessages;i++)
|
||||
{
|
||||
g_pGraphics->drawFont( (unsigned char *) cmsg[i].msg, CONSOLE_MESSAGE_X, y, 1);
|
||||
g_pGraphics->drawFont( cmsg[i].msg, CONSOLE_MESSAGE_X, y, 1);
|
||||
y += CONSOLE_MESSAGE_SPACING;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,17 @@ struct st_resolution
|
||||
#include <SDL.h>
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
using namespace std;
|
||||
|
||||
inline bool LockSurface(SDL_Surface * bmp) {
|
||||
if (SDL_MUSTLOCK(bmp))
|
||||
return SDL_LockSurface(bmp) != -1;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline void UnlockSurface(SDL_Surface * bmp) {
|
||||
if (SDL_MUSTLOCK(bmp))
|
||||
SDL_UnlockSurface(bmp);
|
||||
}
|
||||
|
||||
class CVideoDriver : public CSingleton<CVideoDriver>
|
||||
{
|
||||
@@ -99,8 +109,8 @@ private:
|
||||
|
||||
st_resolution m_Resolution;
|
||||
|
||||
list<st_resolution> m_Resolutionlist;
|
||||
list<st_resolution> :: iterator m_Resolution_pos;
|
||||
std::list<st_resolution> m_Resolutionlist;
|
||||
std::list<st_resolution> :: iterator m_Resolution_pos;
|
||||
|
||||
unsigned int Mode;
|
||||
bool Fullscreen;
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "../../hqp/CMusic.h"
|
||||
#include "../../vorticon/sounds.h"
|
||||
#include "../../fileio/CExeFile.h"
|
||||
#include "../../StringUtils.h"
|
||||
|
||||
#define SAFE_DELETE_ARRAY(x) if(x) delete[] x; x=NULL
|
||||
|
||||
@@ -44,7 +45,7 @@ CSound::~CSound() {
|
||||
|
||||
bool CSound::init(void)
|
||||
{
|
||||
char name[MAX_STRING_LENGTH];
|
||||
char name[256];
|
||||
SDL_AudioSpec *desired, *obtained;
|
||||
|
||||
desired = &AudioSpec;
|
||||
@@ -297,14 +298,14 @@ playsound: ;
|
||||
m_soundchannel[chnl].setupSound((unsigned short)snd, 0, true, WAVE_IN, 0, (mode==PLAY_FORCE) ? true : false );
|
||||
}
|
||||
|
||||
bool CSound::loadSoundData(unsigned short Episode, char *DataDirectory)
|
||||
bool CSound::loadSoundData(unsigned short Episode, const std::string& DataDirectory)
|
||||
{
|
||||
if(!m_active) return false;
|
||||
|
||||
char *path;
|
||||
std::string path;
|
||||
bool ok = true;
|
||||
char soundfile[80];
|
||||
char buf[256];
|
||||
std::string soundfile;
|
||||
std::string buf;
|
||||
|
||||
if(m_soundslot) delete[] m_soundslot;
|
||||
m_soundslot = new CSoundSlot[MAX_SOUNDS];
|
||||
@@ -318,21 +319,16 @@ bool CSound::loadSoundData(unsigned short Episode, char *DataDirectory)
|
||||
|
||||
g_pLogFile->ftextOut("sound_load_all(): loading all sounds...<br>");
|
||||
|
||||
char buffer[256];
|
||||
|
||||
formatPathString(buffer,path);
|
||||
|
||||
sprintf(soundfile, "%ssounds.ck%d", buffer,Episode);
|
||||
soundfile = formatPathString(path) + "sounds.ck" + itoa(Episode);
|
||||
|
||||
FILE *p_file;
|
||||
|
||||
if( ( p_file = fopen(soundfile,"rb") ) == NULL )
|
||||
if( ( p_file = fopen(soundfile.c_str(),"rb") ) == NULL )
|
||||
{
|
||||
formatPathString(buffer,path);
|
||||
|
||||
sprintf(buf,"keen%d.exe",Episode);
|
||||
g_pLogFile->ftextOut("sound_load_all(): \"%s\" was not found in the data directory. Looking for \"%s\" in \"%s\" and trying to extract this file<br>", soundfile, buf, buffer);
|
||||
extractOfExeFile(buffer, Episode);
|
||||
|
||||
buf = "keen" + itoa(Episode) + ".exe";
|
||||
g_pLogFile->ftextOut("sound_load_all(): \"%s\" was not found in the data directory. Looking for \"%s\" in \"%s\" and trying to extract this file<br>", soundfile.c_str(), buf.c_str(), formatPathString(path).c_str());
|
||||
extractOfExeFile(formatPathString(path), Episode);
|
||||
}
|
||||
else
|
||||
fclose(p_file);
|
||||
@@ -409,18 +405,16 @@ bool CSound::loadSoundData(unsigned short Episode, char *DataDirectory)
|
||||
the sound data.
|
||||
*/
|
||||
|
||||
char CSound::extractOfExeFile(char *inputpath, int episode)
|
||||
char CSound::extractOfExeFile(const std::string& inputpath, int episode)
|
||||
{
|
||||
const char *outputfname;
|
||||
std::string outputfname;
|
||||
int bit_count;
|
||||
int pos, sounds_start, sounds_end, ret = 0;
|
||||
char buffer[MAX_STRING_LENGTH];
|
||||
char inputfname[MAX_STRING_LENGTH];
|
||||
std::string buffer;
|
||||
std::string inputfname;
|
||||
|
||||
pos = 0;
|
||||
bit_count = 0;
|
||||
memset(buffer,0, MAX_STRING_LENGTH*sizeof(char));
|
||||
memset(inputfname,0, MAX_STRING_LENGTH*sizeof(char));
|
||||
|
||||
// Set Offsets. Episode 1 already provides this
|
||||
if (episode == 2)
|
||||
@@ -437,7 +431,7 @@ char CSound::extractOfExeFile(char *inputpath, int episode)
|
||||
}
|
||||
else
|
||||
{
|
||||
g_pLogFile->ftextOut("Error: Unknown keen executable name: %s<br>", inputfname);
|
||||
g_pLogFile->ftextOut("Error: Unknown keen executable name: %s<br>", inputfname.c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -446,7 +440,7 @@ char CSound::extractOfExeFile(char *inputpath, int episode)
|
||||
else
|
||||
{
|
||||
FILE *fout;
|
||||
if(!(fout = fopen(outputfname,"wb"))) ret = 1;
|
||||
if(!(fout = fopen(outputfname.c_str(),"wb"))) ret = 1;
|
||||
else
|
||||
{
|
||||
fwrite( ExeFile->getData()+sounds_start, 1, (sounds_end-sounds_start), fout);
|
||||
|
||||
@@ -11,10 +11,12 @@
|
||||
#include "../../CSingleton.h"
|
||||
#define g_pSound CSound::Get()
|
||||
|
||||
#include <string>
|
||||
#include <SDL.h>
|
||||
#include "CSoundChannel.h"
|
||||
#include "CSoundSlot.h"
|
||||
|
||||
|
||||
class CSound : public CSingleton<CSound>
|
||||
{
|
||||
public:
|
||||
@@ -23,11 +25,11 @@ public:
|
||||
|
||||
bool init(void);
|
||||
void stop(void);
|
||||
bool loadSoundData(unsigned short Episode, char *DataDirectory);
|
||||
bool loadSoundData(unsigned short Episode, const std::string& DataDirectory);
|
||||
void stopAllSounds(void);
|
||||
|
||||
bool forcedisPlaying(void);
|
||||
char sound_load_all(const char *path);
|
||||
char sound_load_all(const std::string& path);
|
||||
void transform_into_logaritmic_sound(int *pcmstream, int len);
|
||||
void callback(void *unused, Uint8 *stream, int len);
|
||||
void pauseSound(void);
|
||||
@@ -44,7 +46,7 @@ public:
|
||||
|
||||
void setSoundmode(int freq, bool stereo);
|
||||
|
||||
char extractOfExeFile(char *inputpath, int episode); // This is a special funktion. It doesn't belong here!
|
||||
char extractOfExeFile(const std::string& inputpath, int episode); // This is a special funktion. It doesn't belong here!
|
||||
|
||||
private:
|
||||
CSoundChannel *m_soundchannel;
|
||||
|
||||
@@ -34,7 +34,7 @@ CSoundSlot::~CSoundSlot() {
|
||||
|
||||
// loads sound searchname from file fname, into sounds[] entry loadnum
|
||||
// return value is false on failure
|
||||
bool CSoundSlot::loadSound(const char *fname, const char *searchname, unsigned int loadnum)
|
||||
bool CSoundSlot::loadSound(const std::string& fname, const std::string& searchname, unsigned int loadnum)
|
||||
{
|
||||
// Unload the sound if any was previously loaded
|
||||
if(m_sounddata){ delete[] m_sounddata; m_sounddata = NULL; }
|
||||
@@ -57,10 +57,10 @@ bool CSoundSlot::loadSound(const char *fname, const char *searchname, unsigned i
|
||||
for(i=0;i<12;i++)
|
||||
name[i] = 0;
|
||||
|
||||
fp = fopen(fname, "rb");
|
||||
fp = fopen(fname.c_str(), "rb");
|
||||
if (!fp)
|
||||
{
|
||||
g_pLogFile->ftextOut("loadSound : Sounds file '%s' unopenable attempting load of '%s'<br>", fname, searchname);
|
||||
g_pLogFile->ftextOut("loadSound : Sounds file '%s' unopenable attempting load of '%s'<br>", fname.c_str(), searchname.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -75,12 +75,12 @@ bool CSoundSlot::loadSound(const char *fname, const char *searchname, unsigned i
|
||||
priority = fgetc(fp);
|
||||
garbage = fgetc(fp);
|
||||
for(i=0;i<12;i++) name[i] = fgetc(fp);
|
||||
if (!strcmp(name, searchname)) goto sound_found;
|
||||
if (name == searchname) goto sound_found;
|
||||
|
||||
curheader += 0x10;
|
||||
}
|
||||
// sound could not be found
|
||||
g_pLogFile->ftextOut("loadSound : sound %s could not be found in %s.<br>", searchname, fname);
|
||||
g_pLogFile->ftextOut("loadSound : sound %s could not be found in %s.<br>", searchname.c_str(), fname.c_str());
|
||||
fclose(fp);
|
||||
return false;
|
||||
|
||||
@@ -115,7 +115,7 @@ bool CSoundSlot::loadSound(const char *fname, const char *searchname, unsigned i
|
||||
|
||||
memcpy(m_sounddata, tempstack, m_soundlength*sizeof(unsigned int));
|
||||
|
||||
g_pLogFile->ftextOut("loadSound : loaded sound %s of %d bytes.<br>", searchname, m_soundlength);
|
||||
g_pLogFile->ftextOut("loadSound : loaded sound %s of %d bytes.<br>", searchname.c_str(), m_soundlength);
|
||||
m_hqsound.enabled = false;
|
||||
|
||||
fclose(fp);
|
||||
|
||||
@@ -15,7 +15,7 @@ public:
|
||||
CSoundSlot();
|
||||
virtual ~CSoundSlot();
|
||||
|
||||
bool loadSound(const char *fname, const char *searchname, unsigned int loadnum);
|
||||
bool loadSound(const std::string& fname, const std::string& searchname, unsigned int loadnum);
|
||||
|
||||
void setpAudioSpec(SDL_AudioSpec *pAudioSpec){ m_pAudioSpec = pAudioSpec; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user