22.Jul.2009

git-svn-id: https://clonekeenplus.svn.sourceforge.net/svnroot/clonekeenplus/cgenius/trunk@95 4df4b0f3-56ce-47cb-b001-ed939b7d65a6
This commit is contained in:
gerstrong
2009-07-22 16:38:10 +00:00
parent b45ce76900
commit 531ce04fa1
53 changed files with 7040 additions and 5553 deletions

View File

@@ -27,6 +27,7 @@
CGame::CGame() { CGame::CGame() {
m_Episode = 0; m_Episode = 0;
memset(m_DataDirectory,0,256);
TileLoader = NULL; TileLoader = NULL;
EGAGraphics = NULL; EGAGraphics = NULL;
@@ -217,13 +218,15 @@ short CGame::runCycle(stCloneKeenPlus *pCKP)
return 0; return 0;
} }
int CGame::loadResources(unsigned short Episode, const std::string& DataDirectory) int CGame::loadResources(unsigned short Episode, char *DataDirectory)
{ {
m_Episode = Episode; m_Episode = Episode;
m_DataDirectory = DataDirectory; memcpy(m_DataDirectory, DataDirectory, 256);
if( m_DataDirectory.size() > 0 && m_DataDirectory[m_DataDirectory.size()-1] != '/' ) int pos = strlen(DataDirectory)-1;
m_DataDirectory += "/"; if(pos == -1) pos =0;
if( ( *(DataDirectory+pos) != '/' ) && strlen(DataDirectory) > 0)
strcat(DataDirectory,"/");
// Decode the entire graphics for the game (EGALATCH, EGASPRIT) // Decode the entire graphics for the game (EGALATCH, EGASPRIT)
EGAGraphics = new CEGAGraphics(Episode, DataDirectory); // Path is relative to the data dir EGAGraphics = new CEGAGraphics(Episode, DataDirectory); // Path is relative to the data dir
@@ -276,6 +279,8 @@ void CGame::preallocateCKP(stCloneKeenPlus *pCKP)
pCKP->GameData = NULL; pCKP->GameData = NULL;
pCKP->GameData = new stGameData[1]; pCKP->GameData = new stGameData[1];
memset(pCKP->GameData, 0, sizeof(stGameData));
framebyframe = 0; framebyframe = 0;
demomode = DEMO_NODEMO; demomode = DEMO_NODEMO;

View File

@@ -8,7 +8,7 @@
#ifndef CGAME_H_ #ifndef CGAME_H_
#define CGAME_H_ #define CGAME_H_
#include <string> #include <string.h>
#include "vorticon/CEGAGraphics.h" #include "vorticon/CEGAGraphics.h"
#include "vorticon/CMessages.h" #include "vorticon/CMessages.h"
@@ -17,14 +17,15 @@ public:
CGame(); CGame();
virtual ~CGame(); virtual ~CGame();
int loadResources(unsigned short Episode, const std::string& DataDirectory); int loadResources(unsigned short Episode, char *DataDirectory);
void freeResources(void); void freeResources(void);
short runCycle(stCloneKeenPlus *pCKP); short runCycle(stCloneKeenPlus *pCKP);
void preallocateCKP(stCloneKeenPlus *pCKP); void preallocateCKP(stCloneKeenPlus *pCKP);
private: private:
static const unsigned short MAX_TEXT_LENGTH = 256;
unsigned short m_Episode; unsigned short m_Episode;
std::string m_DataDirectory; char m_DataDirectory[MAX_TEXT_LENGTH];
int current_demo; int current_demo;
CEGAGraphics *EGAGraphics; CEGAGraphics *EGAGraphics;

View File

@@ -10,14 +10,12 @@
* not platform-specific). * not platform-specific).
*/ */
#include "keen.h"
#include "keenext.h"
#include "CGraphics.h" #include "CGraphics.h"
#include "keen.h"
#include "sdl/CVideoDriver.h" #include "sdl/CVideoDriver.h"
#include "sdl/video/colourtable.h" #include "sdl/video/colourtable.h"
#include "sdl/CVideoDriver.h" #include "sdl/CVideoDriver.h"
#include "CLogFile.h" #include "CLogFile.h"
#include "StringUtils.h"
CGraphics::CGraphics() { CGraphics::CGraphics() {
HQBitmap = NULL; HQBitmap = NULL;
@@ -593,13 +591,13 @@ int c;
} }
// font drawing functions // font drawing functions
void CGraphics::drawFont(const std::string& text, int xoff, int yoff, int highlight) void CGraphics::drawFont(unsigned char *text, int xoff, int yoff, int highlight)
{ {
unsigned int i,x=xoff,y; unsigned int i,x=xoff,y;
int c; int c;
y = yoff; y = yoff;
for(i=0;i<text.size();i++) for(i=0;i<strlen( (char*) text);i++)
{ {
c = text[i]; c = text[i];
if (!c) break; if (!c) break;
@@ -616,14 +614,15 @@ int c;
} }
} }
} }
void CGraphics::sb_font_draw(const std::string& text, int xoff, int yoff) void CGraphics::sb_font_draw(const unsigned char *text, int xoff, int yoff)
{ {
unsigned int i,x,y; unsigned int i,x,y;
x=xoff; x=xoff;
y=yoff; y=yoff;
for(i=0;i<text.size();i++) for(i=0;i<strlen( (char*) text);i++)
{ {
if (!text[i]) break;
if (text[i]!=13) if (text[i]!=13)
{ {
sb_drawCharacter(x, y, text[i]); sb_drawCharacter(x, y, text[i]);
@@ -637,13 +636,13 @@ void CGraphics::sb_font_draw(const std::string& text, int xoff, int yoff)
} }
} }
void CGraphics::sb_mask_font_draw(const std::string& text, int xoff, int yoff, char mask) void CGraphics::sb_mask_font_draw(unsigned char *text, int xoff, int yoff, char mask)
{ {
unsigned int i,x,y; unsigned int i,x,y;
x=xoff; x=xoff;
y=yoff; y=yoff;
for(i=0;i<text.size();i++) for(i=0;i<strlen( (char*) text);i++)
{ {
if (text[i]!=13) if (text[i]!=13)
{ {
@@ -659,14 +658,15 @@ unsigned int i,x,y;
} }
void CGraphics::sb_color_font_draw(const std::string& text, int xoff, int yoff, unsigned int colour, unsigned short bgcolour) void CGraphics::sb_color_font_draw(unsigned char *text, int xoff, int yoff, unsigned int colour, unsigned short bgcolour)
{ {
unsigned int i,x,y; unsigned int i,x,y;
x=xoff; x=xoff;
y=yoff; y=yoff;
for(i=0;i< text.size(); i++) for(i=0;i<strlen( (char*) text);i++)
{ {
if (!text[i]) break;
if (text[i]!=13) if (text[i]!=13)
{ {
sb_drawColorcharacter(x, y, text[i], colour, bgcolour); sb_drawColorcharacter(x, y, text[i], colour, bgcolour);
@@ -680,13 +680,14 @@ unsigned int i,x,y;
} }
} }
void CGraphics::sb_font_draw_inverse(const std::string& text, int xoff, int yoff) void CGraphics::sb_font_draw_inverse(unsigned char *text, int xoff, int yoff)
{ {
unsigned int i,x=xoff,y; unsigned int i,x=xoff,y;
y=yoff; y=yoff;
for(i=0;i< text.size();i++) for(i=0;i<strlen( (char*) text);i++)
{ {
if (!text[i]) break;
if (text[i]!=13) if (text[i]!=13)
{ {
sb_drawCharacterinverse(x, y, text[i]); sb_drawCharacterinverse(x, y, text[i]);
@@ -723,12 +724,18 @@ void CGraphics::renderHQBitmap()
} }
} }
void CGraphics::loadHQGraphics(unsigned char episode, unsigned char level, const std::string& datadir) void CGraphics::loadHQGraphics(unsigned char episode, unsigned char level, char *datadir)
{ {
char buf[256];
char buf2[256];
SDL_Rect screen_rect; SDL_Rect screen_rect;
std::string buf = formatPathString(datadir); memset(buf,0,256);
std::string buf2 = buf + "level" + itoa(level) + "ep" + itoa(episode) + ".bmp"; memset(buf2,0,256);
formatPathString(buf,datadir);
sprintf(buf2,"%slevel%dep%d.bmp",buf,level,episode);
screen_rect.x = 0; screen_rect.x = 0;
screen_rect.y = 0; screen_rect.y = 0;

View File

@@ -11,7 +11,6 @@
#include "CSingleton.h" #include "CSingleton.h"
#define g_pGraphics CGraphics::Get() #define g_pGraphics CGraphics::Get()
#include <string>
#include <SDL.h> #include <SDL.h>
#include "hqp/CHQBitmap.h" #include "hqp/CHQBitmap.h"
@@ -45,18 +44,18 @@ public:
void drawBitmap2FG(int xa, int ya, int b); void drawBitmap2FG(int xa, int ya, int b);
int getBitmapNumberFromName(const char *bmname); int getBitmapNumberFromName(const char *bmname);
void sb_drawCharacterinverse(int x, int y, int f); void sb_drawCharacterinverse(int x, int y, int f);
void drawFont(const std::string& text, int xoff, int yoff, int highlight); void drawFont(unsigned char *text, int xoff, int yoff, int highlight);
void sb_font_draw(const std::string& text, int xoff, int yoff); void sb_font_draw(const unsigned char *text, int xoff, int yoff);
void sb_mask_font_draw(const std::string& text, int xoff, int yoff, char mask); void sb_mask_font_draw(unsigned char *text, int xoff, int yoff, char mask);
void sb_color_font_draw(const std::string& text, int xoff, int yoff, unsigned int colour, unsigned short bgcolour); void sb_color_font_draw(unsigned char *text, int xoff, int yoff, unsigned int colour, unsigned short bgcolour);
void sb_font_draw_inverse(const std::string& text, int xoff, int yoff); void sb_font_draw_inverse(unsigned char *text, int xoff, int yoff);
void drawTile_direct(int x, int y, unsigned int t); void drawTile_direct(int x, int y, unsigned int t);
void setFadeBlack(bool value); void setFadeBlack(bool value);
Uint8 *getScrollbuffer(void); Uint8 *getScrollbuffer(void);
void renderHQBitmap(); void renderHQBitmap();
void loadHQGraphics(unsigned char episode, unsigned char level, const std::string& datadir); void loadHQGraphics(unsigned char episode, unsigned char level, char *datadir);
void unloadHQGraphics(); void unloadHQGraphics();
private: private:

View File

@@ -13,7 +13,6 @@
#include "fileio.h" #include "fileio.h"
#include "keen.h" #include "keen.h"
#include "keenext.h" #include "keenext.h"
#include "StringUtils.h"
#include "CLogFile.h" #include "CLogFile.h"
//#include "vorticon/CEGAGraphics.h" //#include "vorticon/CEGAGraphics.h"
@@ -59,15 +58,19 @@ char CLatch::loadHeader(int episode, const char *path)
FILE *headfile; FILE *headfile;
unsigned long SpriteTableRAMSize; unsigned long SpriteTableRAMSize;
unsigned long BitmapTableRAMSize; unsigned long BitmapTableRAMSize;
std::string buf; char buf[12];
int i,j,k; int i,j,k;
std::string fname; char fname[80];
std::string buffer; char buffer[256];
buffer = formatPathString(path); memset(buffer,0,256);
buffer += "egahead.ck"; memset(fname,0,80);
fname = buffer + itoa(episode); formatPathString(buffer,path);
strcat(buffer,"egahead.ck");
sprintf(fname, "%s%d", buffer,episode);
/*CEGAGraphics *EGAGraphics; /*CEGAGraphics *EGAGraphics;
@@ -77,14 +80,14 @@ char CLatch::loadHeader(int episode, const char *path)
delete EGAGraphics;*/ delete EGAGraphics;*/
headfile = fopen(fname.c_str(), "rb"); headfile = fopen(fname, "rb");
if (!headfile) if (!headfile)
{ {
g_pLogFile->ftextOut("latch_loadheader(): unable to open '%s'.<br>", fname.c_str()); g_pLogFile->ftextOut("latch_loadheader(): unable to open '%s'.<br>", fname);
return 1; return 1;
} }
g_pLogFile->ftextOut("latch_loadheader(): reading main header from '%s'...<br>", fname.c_str()); g_pLogFile->ftextOut("latch_loadheader(): reading main header from '%s'...<br>", fname);
// read the main header data from EGAHEAD // read the main header data from EGAHEAD
LatchHeader.LatchPlaneSize = fgetl(headfile); LatchHeader.LatchPlaneSize = fgetl(headfile);
@@ -132,7 +135,7 @@ char CLatch::loadHeader(int episode, const char *path)
return 1; return 1;
} }
g_pLogFile->ftextOut("latch_loadheader(): Reading sprite table from '%s'...<br>", fname.c_str()); g_pLogFile->ftextOut("latch_loadheader(): Reading sprite table from '%s'...<br>", fname);
fseek(headfile, LatchHeader.OffSpriteTable, SEEK_SET); fseek(headfile, LatchHeader.OffSpriteTable, SEEK_SET);
for(i=0;i<LatchHeader.NumSprites;i++) for(i=0;i<LatchHeader.NumSprites;i++)
@@ -169,7 +172,7 @@ char CLatch::loadHeader(int episode, const char *path)
return 1; return 1;
} }
g_pLogFile->ftextOut("latch_loadheader(): reading bitmap table from '%s'...<br>", fname.c_str()); g_pLogFile->ftextOut("latch_loadheader(): reading bitmap table from '%s'...<br>", fname);
fseek(headfile, LatchHeader.OffBitmapTable, SEEK_SET); fseek(headfile, LatchHeader.OffBitmapTable, SEEK_SET);
@@ -188,7 +191,7 @@ char CLatch::loadHeader(int episode, const char *path)
// print the bitmap info to the console for debug // print the bitmap info to the console for debug
for(j=0;j<8;j++) buf[j] = BitmapTable[i].Name[j]; for(j=0;j<8;j++) buf[j] = BitmapTable[i].Name[j];
buf[j] = 0; buf[j] = 0;
g_pLogFile->ftextOut(" Bitmap '%s': %dx%d at offset %04x. RAMAllocSize=0x%04x<br>", buf.c_str(),BitmapTable[i].Width,BitmapTable[i].Height,BitmapTable[i].Offset,BitmapBufferRAMSize); g_pLogFile->ftextOut(" Bitmap '%s': %dx%d at offset %04x. RAMAllocSize=0x%04x<br>", buf,BitmapTable[i].Width,BitmapTable[i].Height,BitmapTable[i].Offset,BitmapBufferRAMSize);
} }
BitmapBufferRAMSize++; BitmapBufferRAMSize++;
@@ -203,24 +206,26 @@ char CLatch::load(int episode, const char *path)
{ {
FILE *latchfile; FILE *latchfile;
unsigned long plane1, plane2, plane3, plane4; unsigned long plane1, plane2, plane3, plane4;
std::string fname; char fname[80];
int x,y,t,b,c,p; int x,y,t,b,c,p;
char *bmdataptr; char *bmdataptr;
unsigned long RawDataSize; unsigned long RawDataSize;
//unsigned char ch; //unsigned char ch;
std::string buffer; char buffer[256];
buffer = formatPathString(path); formatPathString(buffer,path);
buffer += "egalatch.ck";
fname = buffer + itoa(episode);
g_pLogFile->ftextOut("latch_loadlatch(): Opening file '%s'.<br>", fname.c_str()); strcat(buffer,"egalatch.ck");
latchfile = fopen(fname.c_str(), "rb"); sprintf(fname, "%s%c", buffer,episode + '0');
g_pLogFile->ftextOut("latch_loadlatch(): Opening file '%s'.<br>", fname);
latchfile = fopen(fname, "rb");
if (!latchfile) if (!latchfile)
{ {
g_pLogFile->ftextOut("latch_loadlatch(): Unable to open '%s'!<br>", fname.c_str()); g_pLogFile->ftextOut("latch_loadlatch(): Unable to open '%s'!<br>", fname);
return 1; return 1;
} }
@@ -261,7 +266,7 @@ unsigned long RawDataSize;
plane4 = (LatchHeader.LatchPlaneSize * 3); plane4 = (LatchHeader.LatchPlaneSize * 3);
// ** read the 8x8 tiles ** // ** read the 8x8 tiles **
g_pLogFile->ftextOut("latch_loadlatch(): Decoding 8x8 tiles...<br>", fname.c_str()); g_pLogFile->ftextOut("latch_loadlatch(): Decoding 8x8 tiles...<br>", fname);
// set up the getbit() function // set up the getbit() function
@@ -304,7 +309,7 @@ unsigned long RawDataSize;
delete Planes; delete Planes;
// ** read the 16x16 tiles ** // ** read the 16x16 tiles **
g_pLogFile->ftextOut("latch_loadlatch(): Decoding 16x16 tiles...<br>", fname.c_str()); g_pLogFile->ftextOut("latch_loadlatch(): Decoding 16x16 tiles...<br>", fname);
// set up the getbit() function // set up the getbit() function
Planes = new CPlanes(plane1 + LatchHeader.Off16Tiles, \ Planes = new CPlanes(plane1 + LatchHeader.Off16Tiles, \
@@ -349,7 +354,7 @@ unsigned long RawDataSize;
return 1; return 1;
} }
g_pLogFile->ftextOut("latch_loadlatch(): Decoding bitmaps...<br>", fname.c_str()); g_pLogFile->ftextOut("latch_loadlatch(): Decoding bitmaps...<br>", fname);
// set up the getbit() function // set up the getbit() function
Planes = new CPlanes(plane1 + LatchHeader.OffBitmaps, \ Planes = new CPlanes(plane1 + LatchHeader.OffBitmaps, \
@@ -414,22 +419,24 @@ char CLatch::loadSprites(int episode, const char *path)
{ {
FILE *spritfile; FILE *spritfile;
unsigned long plane1, plane2, plane3, plane4, plane5; unsigned long plane1, plane2, plane3, plane4, plane5;
std::string fname; char fname[80];
int x,y,s,c,p; int x,y,s,c,p;
unsigned long RawDataSize; unsigned long RawDataSize;
std::string buffer; char buffer[256];
CPlanes *Planes; CPlanes *Planes;
buffer = formatPathString(path); formatPathString(buffer,path);
buffer += "egasprit.ck";
fname = buffer + itoa(episode);
g_pLogFile->ftextOut("latch_loadsprites(): Opening file '%s'.<br>", fname.c_str()); strcat(buffer,"egasprit.ck");
spritfile = fopen(fname.c_str(), "rb"); sprintf(fname, "%s%c", buffer,episode + '0');
g_pLogFile->ftextOut("latch_loadsprites(): Opening file '%s'.<br>", fname);
spritfile = fopen(fname, "rb");
if (!spritfile) if (!spritfile)
{ {
g_pLogFile->ftextOut("latch_loadsprites(): Unable to open '%s'!<br>", fname.c_str()); g_pLogFile->ftextOut("latch_loadsprites(): Unable to open '%s'!<br>", fname);
return 1; return 1;
} }
@@ -468,7 +475,7 @@ CPlanes *Planes;
plane5 = (LatchHeader.SpritePlaneSize * 4); plane5 = (LatchHeader.SpritePlaneSize * 4);
// ** read the sprites ** // ** read the sprites **
g_pLogFile->ftextOut("latch_loadsprites(): Decoding sprites...<br>", fname.c_str()); g_pLogFile->ftextOut("latch_loadsprites(): Decoding sprites...<br>", fname);
// set up the getbit() function // set up the getbit() function
Planes = new CPlanes(plane1 + LatchHeader.OffSprites, \ Planes = new CPlanes(plane1 + LatchHeader.OffSprites, \

View File

@@ -1,443 +1,442 @@
/* ESEQ_EP1.C /* ESEQ_EP1.C
Ending sequence for Episode 1. Ending sequence for Episode 1.
*/ */
#include "keen.h" #include "keen.h"
#include "include/game.h" #include "include/game.h"
#include "include/gamedo.h" #include "include/gamedo.h"
#include "include/gamepdo.h" #include "include/gamepdo.h"
#include "sdl/CInput.h" #include "sdl/CInput.h"
#include "sdl/CTimer.h" #include "sdl/CTimer.h"
#include "include/eseq_ep1.h" #include "include/eseq_ep1.h"
#include "include/eseq_ep2.h" #include "include/eseq_ep2.h"
#include "include/menu.h" #include "include/menu.h"
#include "CGraphics.h" #include "CGraphics.h"
#include "StringUtils.h"
#define CMD_MOVE 0
#define CMD_MOVE 0 #define CMD_WAIT 1
#define CMD_WAIT 1 #define CMD_SPAWNSPR 2
#define CMD_SPAWNSPR 2 #define CMD_REMOVESPR 3
#define CMD_REMOVESPR 3 #define CMD_FADEOUT 4
#define CMD_FADEOUT 4 #define CMD_ENDOFQUEUE 5
#define CMD_ENDOFQUEUE 5 #define CMD_ENABLESCROLLING 6
#define CMD_ENABLESCROLLING 6 #define CMD_DISABLESCROLLING 7
#define CMD_DISABLESCROLLING 7
// start x,y map scroll position for eseq1_ShipFlys()
// start x,y map scroll position for eseq1_ShipFlys() #define SHIPFLY_X 32
#define SHIPFLY_X 32 #define SHIPFLY_Y 0
#define SHIPFLY_Y 0
// worldmap scroll position for eseq1_ReturnsToShip()
// worldmap scroll position for eseq1_ReturnsToShip() #define WM_X 40
#define WM_X 40 #define WM_Y 540
#define WM_Y 540
#define LETTER_SHOW_SPD 30
#define LETTER_SHOW_SPD 30 #define RETURNTOSHIP_WAIT_TIME 600
#define RETURNTOSHIP_WAIT_TIME 600
#define SPR_SHIP_RIGHT 115
#define SPR_SHIP_RIGHT 115 #define SPR_SHIP_LEFT 116
#define SPR_SHIP_LEFT 116 #define SPR_EXCLAMATION 117
#define SPR_EXCLAMATION 117 #define SPR_QUESTION 118
#define SPR_QUESTION 118 #define SHIPSPD 4
#define SHIPSPD 4
#define BACKHOME_SHORT_WAIT_TIME 250
#define BACKHOME_SHORT_WAIT_TIME 250
int eseq1_ReturnsToShip(stCloneKeenPlus *pCKP)
int eseq1_ReturnsToShip(stCloneKeenPlus *pCKP) {
{ int i;
int i;
for(i=0;i<MAX_LEVELS;i++)
for(i=0;i<MAX_LEVELS;i++) pCKP->Control.levelcontrol.levels_completed[i] = 0;
pCKP->Control.levelcontrol.levels_completed[i] = 0;
showmapatpos(80, WM_X, WM_Y, 0, pCKP);
showmapatpos(80, WM_X, WM_Y, 0, pCKP);
// draw keen next to his ship
// draw keen next to his ship g_pGraphics->drawSprite(168, 85, PMAPLEFTFRAME, 0);
g_pGraphics->drawSprite(168, 85, PMAPLEFTFRAME, 0); // do not show player when we render the screen
// do not show player when we render the screen numplayers = 1;
numplayers = 1; player[0].x = 0;
player[0].x = 0; player[0].y = 0;
player[0].y = 0; player[0].playframe = BlankSprite;
player[0].playframe = BlankSprite; // all objects -> nonexistant
// all objects -> nonexistant for(i=0;i<MAX_OBJECTS;i++) objects[i].exists = 0;
for(i=0;i<MAX_OBJECTS;i++) objects[i].exists = 0;
fade.mode = FADE_GO;
fade.mode = FADE_GO; fade.dir = FADE_IN;
fade.dir = FADE_IN; fade.curamt = 0;
fade.curamt = 0; fade.fadetimer = 0;
fade.fadetimer = 0; fade.rate = FADE_NORM;
fade.rate = FADE_NORM;
eseq_showmsg(getstring("EP1_ESEQ_PART1"),1,18,37,6,1, pCKP);
eseq_showmsg(getstring("EP1_ESEQ_PART1"),1,18,37,6,1, pCKP);
// fade out
// fade out fade.mode = FADE_GO;
fade.mode = FADE_GO; fade.dir = FADE_OUT;
fade.dir = FADE_OUT; fade.curamt = PAL_FADE_SHADES;
fade.curamt = PAL_FADE_SHADES; fade.fadetimer = 0;
fade.fadetimer = 0; fade.rate = FADE_NORM;
fade.rate = FADE_NORM; do
do {
{ gamedo_fades();
gamedo_fades(); gamedo_AnimatedTiles();
gamedo_AnimatedTiles();
g_pInput->pollEvents();
g_pInput->pollEvents(); g_pTimer->SpeedThrottle();
g_pTimer->SpeedThrottle(); } while(fade.mode != FADE_COMPLETE && !g_pInput->getPressedKey(KQUIT));
} while(fade.mode != FADE_COMPLETE && !g_pInput->getPressedKey(KQUIT));
return 0;
return 0; }
}
void addshipqueue(int cmd, int time, int flag1)
void addshipqueue(int cmd, int time, int flag1) {
{ shipqueue[ShipQueuePtr].cmd = cmd;
shipqueue[ShipQueuePtr].cmd = cmd; shipqueue[ShipQueuePtr].time = time;
shipqueue[ShipQueuePtr].time = time; shipqueue[ShipQueuePtr].flag1 = flag1;
shipqueue[ShipQueuePtr].flag1 = flag1; ShipQueuePtr++;
ShipQueuePtr++; }
}
int eseq1_ShipFlys(stCloneKeenPlus *pCKP)
int eseq1_ShipFlys(stCloneKeenPlus *pCKP) {
{ char enter,lastenterstate;
char enter,lastenterstate; int x, y;
int x, y; int scrollingon;
int scrollingon;
scrollingon = 1;
scrollingon = 1;
#define MARK_SPR_NUM 5
#define MARK_SPR_NUM 5 initgame(pCKP);
initgame(pCKP);
// set up the ship's route
// set up the ship's route ShipQueuePtr = 0;
ShipQueuePtr = 0; addshipqueue(CMD_MOVE, 230, DUP);
addshipqueue(CMD_MOVE, 230, DUP); addshipqueue(CMD_WAIT, 50, 0);
addshipqueue(CMD_WAIT, 50, 0); addshipqueue(CMD_MOVE, 2690, DDOWNRIGHT);
addshipqueue(CMD_MOVE, 2690, DDOWNRIGHT); addshipqueue(CMD_WAIT, 100, 0);
addshipqueue(CMD_WAIT, 100, 0); addshipqueue(CMD_MOVE, 480, DDOWN);
addshipqueue(CMD_MOVE, 480, DDOWN); addshipqueue(CMD_WAIT, 150, 0);
addshipqueue(CMD_WAIT, 150, 0); addshipqueue(CMD_SPAWNSPR, 0, SPR_QUESTION);
addshipqueue(CMD_SPAWNSPR, 0, SPR_QUESTION); addshipqueue(CMD_DISABLESCROLLING, 0, 0);
addshipqueue(CMD_DISABLESCROLLING, 0, 0); addshipqueue(CMD_WAIT, 350, 0);
addshipqueue(CMD_WAIT, 350, 0); addshipqueue(CMD_REMOVESPR, 0, 0);
addshipqueue(CMD_REMOVESPR, 0, 0); addshipqueue(CMD_WAIT, 50, 0);
addshipqueue(CMD_WAIT, 50, 0); addshipqueue(CMD_MOVE, 700, DLEFT);
addshipqueue(CMD_MOVE, 700, DLEFT); addshipqueue(CMD_WAIT, 150, 0);
addshipqueue(CMD_WAIT, 150, 0); addshipqueue(CMD_SPAWNSPR, 0, SPR_EXCLAMATION);
addshipqueue(CMD_SPAWNSPR, 0, SPR_EXCLAMATION); addshipqueue(CMD_WAIT, 500, 0);
addshipqueue(CMD_WAIT, 500, 0); addshipqueue(CMD_REMOVESPR, 0, 0);
addshipqueue(CMD_REMOVESPR, 0, 0); addshipqueue(CMD_WAIT, 50, 0);
addshipqueue(CMD_WAIT, 50, 0); addshipqueue(CMD_MOVE, 700, DRIGHT);
addshipqueue(CMD_MOVE, 700, DRIGHT); addshipqueue(CMD_WAIT, 25, 0);
addshipqueue(CMD_WAIT, 25, 0); addshipqueue(CMD_ENABLESCROLLING, 0, 0);
addshipqueue(CMD_ENABLESCROLLING, 0, 0); addshipqueue(CMD_MOVE, 465, DDOWN);
addshipqueue(CMD_MOVE, 465, DDOWN); addshipqueue(CMD_FADEOUT, 0, 0);
addshipqueue(CMD_FADEOUT, 0, 0); addshipqueue(CMD_MOVE, 100, DDOWN);
addshipqueue(CMD_MOVE, 100, DDOWN); addshipqueue(CMD_ENDOFQUEUE, 0, 0);
addshipqueue(CMD_ENDOFQUEUE, 0, 0);
showmapatpos(81, SHIPFLY_X, SHIPFLY_Y, 0, pCKP);
showmapatpos(81, SHIPFLY_X, SHIPFLY_Y, 0, pCKP);
objects[MARK_SPR_NUM].type = OBJ_YORP; // doesn't matter
objects[MARK_SPR_NUM].type = OBJ_YORP; // doesn't matter objects[MARK_SPR_NUM].exists = 0;
objects[MARK_SPR_NUM].exists = 0; objects[MARK_SPR_NUM].sprite = SPR_QUESTION;
objects[MARK_SPR_NUM].sprite = SPR_QUESTION;
numplayers = 1;
numplayers = 1; // place the player at the center of mars
// place the player at the center of mars if (map_findtile(593, &x, &y))
if (map_findtile(593, &x, &y)) { // found the tile at the center of mars
{ // found the tile at the center of mars player[0].x = ((x<<4)+1)<<CSF;
player[0].x = ((x<<4)+1)<<CSF; player[0].y = ((y<<4)-3)<<CSF;
player[0].y = ((y<<4)-3)<<CSF; }
} else
else {
{ crashflag = 1;
crashflag = 1; why_term_ptr = "eseq1_shipflys(): unable to find center of Mars.";
why_term_ptr = "eseq1_shipflys(): unable to find center of Mars."; return 1;
return 1; }
}
player[0].playframe = SPR_SHIP_RIGHT;
player[0].playframe = SPR_SHIP_RIGHT; // player[0].pbgprioritycorners = 0;
// player[0].pbgprioritycorners = 0;
fade.mode = FADE_GO;
fade.mode = FADE_GO; fade.dir = FADE_IN;
fade.dir = FADE_IN; fade.curamt = 0;
fade.curamt = 0; fade.fadetimer = 0;
fade.fadetimer = 0; fade.rate = FADE_NORM;
fade.rate = FADE_NORM; ShipQueuePtr = 0;
ShipQueuePtr = 0; max_scroll_x = max_scroll_y = 20000;
max_scroll_x = max_scroll_y = 20000; do
do {
{ // keep the question or exclamation mark sprite next to the player
// keep the question or exclamation mark sprite next to the player objects[MARK_SPR_NUM].x = player[0].x + (20<<CSF);
objects[MARK_SPR_NUM].x = player[0].x + (20<<CSF); objects[MARK_SPR_NUM].y = player[0].y - (10<<CSF);
objects[MARK_SPR_NUM].y = player[0].y - (10<<CSF); objects[MARK_SPR_NUM].onscreen = 1;
objects[MARK_SPR_NUM].onscreen = 1; // objects[MARK_SPR_NUM].priorityptsfound = 0;
// objects[MARK_SPR_NUM].priorityptsfound = 0; // objects[MARK_SPR_NUM].priorityptschecked = 4;
// objects[MARK_SPR_NUM].priorityptschecked = 4; objects[MARK_SPR_NUM].scrx = (objects[MARK_SPR_NUM].x>>CSF)-scroll_x;
objects[MARK_SPR_NUM].scrx = (objects[MARK_SPR_NUM].x>>CSF)-scroll_x; objects[MARK_SPR_NUM].scry = (objects[MARK_SPR_NUM].y>>CSF)-scroll_y;
objects[MARK_SPR_NUM].scry = (objects[MARK_SPR_NUM].y>>CSF)-scroll_y;
// execute the current command in the queue
// execute the current command in the queue if (fade.dir != FADE_OUT)
if (fade.dir != FADE_OUT) {
{ switch(shipqueue[ShipQueuePtr].cmd)
switch(shipqueue[ShipQueuePtr].cmd) {
{ case CMD_MOVE:
case CMD_MOVE: switch(shipqueue[ShipQueuePtr].flag1)
switch(shipqueue[ShipQueuePtr].flag1) {
{ case DUP:
case DUP: player[0].y-=SHIPSPD;
player[0].y-=SHIPSPD; player[0].playframe = SPR_SHIP_RIGHT;
player[0].playframe = SPR_SHIP_RIGHT; break;
break; case DDOWN:
case DDOWN: player[0].y+=SHIPSPD/2;
player[0].y+=SHIPSPD/2; player[0].playframe = SPR_SHIP_RIGHT;
player[0].playframe = SPR_SHIP_RIGHT; break;
break; case DLEFT:
case DLEFT: player[0].x-=SHIPSPD;
player[0].x-=SHIPSPD; player[0].playframe = SPR_SHIP_LEFT;
player[0].playframe = SPR_SHIP_LEFT; break;
break; case DRIGHT:
case DRIGHT: player[0].x+=SHIPSPD;
player[0].x+=SHIPSPD; player[0].playframe = SPR_SHIP_RIGHT;
player[0].playframe = SPR_SHIP_RIGHT; break;
break; case DDOWNRIGHT:
case DDOWNRIGHT: player[0].x+=SHIPSPD*2;
player[0].x+=SHIPSPD*2; player[0].y+=SHIPSPD*0.8;
player[0].y+=SHIPSPD*0.8; player[0].playframe = SPR_SHIP_RIGHT;
player[0].playframe = SPR_SHIP_RIGHT; break;
break; }
} break;
break; case CMD_SPAWNSPR:
case CMD_SPAWNSPR: objects[MARK_SPR_NUM].sprite = shipqueue[ShipQueuePtr].flag1;
objects[MARK_SPR_NUM].sprite = shipqueue[ShipQueuePtr].flag1; objects[MARK_SPR_NUM].exists = 1;
objects[MARK_SPR_NUM].exists = 1; break;
break; case CMD_REMOVESPR:
case CMD_REMOVESPR: objects[MARK_SPR_NUM].sprite = shipqueue[ShipQueuePtr].flag1;
objects[MARK_SPR_NUM].sprite = shipqueue[ShipQueuePtr].flag1; objects[MARK_SPR_NUM].exists = 0;
objects[MARK_SPR_NUM].exists = 0; break;
break; case CMD_ENABLESCROLLING:
case CMD_ENABLESCROLLING: scrollingon = 1;
scrollingon = 1; break;
break; case CMD_DISABLESCROLLING:
case CMD_DISABLESCROLLING: scrollingon = 0;
scrollingon = 0; break;
break; case CMD_WAIT:
case CMD_WAIT: break;
break; case CMD_FADEOUT:
case CMD_FADEOUT: if (fade.dir!=FADE_OUT)
if (fade.dir!=FADE_OUT) {
{ fade.dir = FADE_OUT;
fade.dir = FADE_OUT; fade.curamt = PAL_FADE_SHADES;
fade.curamt = PAL_FADE_SHADES; fade.fadetimer = 0;
fade.fadetimer = 0; fade.mode = FADE_GO;
fade.mode = FADE_GO; fade.rate = FADE_NORM;
fade.rate = FADE_NORM; }
} break;
break; default: break;
default: break; }
} // decrease the time remaining
// decrease the time remaining if (shipqueue[ShipQueuePtr].time)
if (shipqueue[ShipQueuePtr].time) {
{ shipqueue[ShipQueuePtr].time--;
shipqueue[ShipQueuePtr].time--; }
} else
else { // no time left on this command, go to next cmd
{ // no time left on this command, go to next cmd ShipQueuePtr++;
ShipQueuePtr++; }
} }
}
if (fade.dir==FADE_OUT && fade.mode==FADE_COMPLETE)
if (fade.dir==FADE_OUT && fade.mode==FADE_COMPLETE) { // we're done
{ // we're done return 0;
return 0; }
}
enter = ( g_pInput->getPressedKey(KENTER) || g_pInput->getPressedKey(KCTRL) || g_pInput->getPressedKey(KALT) );
enter = ( g_pInput->getPressedKey(KENTER) || g_pInput->getPressedKey(KCTRL) || g_pInput->getPressedKey(KALT) ); if (enter)
if (enter) {
{ if (fade.dir!=FADE_OUT)
if (fade.dir!=FADE_OUT) {
{ fade.dir = FADE_OUT;
fade.dir = FADE_OUT; fade.curamt = PAL_FADE_SHADES;
fade.curamt = PAL_FADE_SHADES; fade.fadetimer = 0;
fade.fadetimer = 0; fade.mode = FADE_GO;
fade.mode = FADE_GO; fade.rate = FADE_NORM;
fade.rate = FADE_NORM; }
} }
} lastenterstate = enter;
lastenterstate = enter;
gamedo_fades();
gamedo_fades(); gamedo_AnimatedTiles();
gamedo_AnimatedTiles();
gamedo_frameskipping(pCKP);
gamedo_frameskipping(pCKP); if (scrollingon) gamedo_ScrollTriggers(0);
if (scrollingon) gamedo_ScrollTriggers(0);
g_pInput->pollEvents();
g_pInput->pollEvents(); g_pTimer->SpeedThrottle();
g_pTimer->SpeedThrottle(); } while(!g_pInput->getPressedKey(KQUIT));
} while(!g_pInput->getPressedKey(KQUIT)); return 1;
return 1; }
}
int eseq1_BackAtHome(stCloneKeenPlus *pCKP)
int eseq1_BackAtHome(stCloneKeenPlus *pCKP) {
{ /*int draw;*/
/*int draw;*/ int i;
int i; char *text[10];
std::string text[10]; char strname[40];
std::string strname; char tempbuf[200];
std::string tempbuf; short textline, showtimer;
short textline, showtimer; unsigned short amountshown;
unsigned short amountshown; signed int waittimer;
signed int waittimer; int state;
int state; int enter, lastenterstate;
int enter, lastenterstate; int dlgX, dlgY, dlgW, dlgH;
int dlgX, dlgY, dlgW, dlgH;
#define STATE_TEXTAPPEARING 0
#define STATE_TEXTAPPEARING 0 #define STATE_WAITASEC 1
#define STATE_WAITASEC 1 #define STATE_FADING 2
#define STATE_FADING 2
// get pointers to all the strings we're going to be using
// get pointers to all the strings we're going to be using for(i=0;i<8;i++)
for(i=0;i<8;i++) {
{ sprintf(strname, "EP1_ESEQ_PART2_PAGE%d", i+1);
strname = "EP1_ESEQ_PART2_PAGE" + itoa(i+1); text[i] = getstring(strname);
text[i] = getstring(strname); }
}
textline = 0;
textline = 0; amountshown = 0;
amountshown = 0; showtimer = 0;
showtimer = 0; state = STATE_TEXTAPPEARING;
state = STATE_TEXTAPPEARING; lastenterstate = 1;
lastenterstate = 1; waittimer = 0;
waittimer = 0;
finale_draw("finale.ck1", pCKP->GameData[pCKP->Resources.GameSelected-1].DataDirectory);
finale_draw("finale.ck1", pCKP->GameData[pCKP->Resources.GameSelected-1].DataDirectory); scrollx_buf = scroll_x = 0;
scrollx_buf = scroll_x = 0; scrolly_buf = scroll_y = 0;
scrolly_buf = scroll_y = 0;
numplayers = 1;
numplayers = 1; player[0].x = 16;
player[0].x = 16; player[0].y = 16;
player[0].y = 16; player[0].playframe = BlankSprite;
player[0].playframe = BlankSprite;
dlgX = GetStringAttribute("EP1_ESEQ_PART2_PAGE1", "LEFT");
dlgX = GetStringAttribute("EP1_ESEQ_PART2_PAGE1", "LEFT"); dlgY = GetStringAttribute("EP1_ESEQ_PART2_PAGE1", "TOP");
dlgY = GetStringAttribute("EP1_ESEQ_PART2_PAGE1", "TOP"); dlgW = GetStringAttribute("EP1_ESEQ_PART2_PAGE1", "WIDTH");
dlgW = GetStringAttribute("EP1_ESEQ_PART2_PAGE1", "WIDTH"); dlgH = GetStringAttribute("EP1_ESEQ_PART2_PAGE1", "HEIGHT");
dlgH = GetStringAttribute("EP1_ESEQ_PART2_PAGE1", "HEIGHT");
fade.mode = FADE_GO;
fade.mode = FADE_GO; fade.rate = FADE_NORM;
fade.rate = FADE_NORM; fade.dir = FADE_IN;
fade.dir = FADE_IN; fade.curamt = 0;
fade.curamt = 0; fade.fadetimer = 0;
fade.fadetimer = 0; do
do {
{ enter = ( g_pInput->getPressedKey(KENTER) || g_pInput->getPressedKey(KCTRL) || g_pInput->getPressedKey(KALT) );
enter = ( g_pInput->getPressedKey(KENTER) || g_pInput->getPressedKey(KCTRL) || g_pInput->getPressedKey(KALT) );
sb_dialogbox(dlgX, dlgY, dlgW, dlgH);
sb_dialogbox(dlgX, dlgY, dlgW, dlgH);
// draw the current text line up to the amount currently shown
// draw the current text line up to the amount currently shown strcpy(tempbuf, text[textline]);
tempbuf = text[textline]; tempbuf[amountshown] = 0;
tempbuf.erase(amountshown); g_pGraphics->sb_font_draw( (unsigned char*) tempbuf, (dlgX+1)*8, (dlgY+1)*8);
g_pGraphics->sb_font_draw( tempbuf, (dlgX+1)*8, (dlgY+1)*8);
if (state==STATE_TEXTAPPEARING)
if (state==STATE_TEXTAPPEARING) {
{ if (enter) goto fullshow;
if (enter) goto fullshow; if (showtimer > LETTER_SHOW_SPD)
if (showtimer > LETTER_SHOW_SPD) { // it's time to show a new letter
{ // it's time to show a new letter amountshown++;
amountshown++; if (amountshown > strlen(text[textline]))
if (amountshown > text[textline].size()) { // reached end of line
{ // reached end of line state = STATE_WAITASEC;
state = STATE_WAITASEC; // if (textline==8)
// if (textline==8) // waittimer = -BACKHOME_SHORT_WAIT_TIME*3;
// waittimer = -BACKHOME_SHORT_WAIT_TIME*3; // else
// else waittimer = -BACKHOME_SHORT_WAIT_TIME*2;
waittimer = -BACKHOME_SHORT_WAIT_TIME*2; }
} // if the last letter shown is a dash/cr ('Billy...are you a-'),
// if the last letter shown is a dash/cr ('Billy...are you a-'), // show the rest of the text immediately
// show the rest of the text immediately // (for when the mom shouts "WHAT IS THIS ONE-EYED GREEN THING..."
// (for when the mom shouts "WHAT IS THIS ONE-EYED GREEN THING..." if (text[textline][amountshown]==13 && \
if (text[textline][amountshown]==13 && \ text[textline][amountshown-1]=='-')
text[textline][amountshown-1]=='-') {
{ fullshow: ;
fullshow: ; amountshown = strlen(text[textline]);
amountshown = text[textline].size(); state = STATE_WAITASEC;
state = STATE_WAITASEC; waittimer = -BACKHOME_SHORT_WAIT_TIME*3;
waittimer = -BACKHOME_SHORT_WAIT_TIME*3; }
} showtimer = 0;
showtimer = 0; } else showtimer++;
} else showtimer++;
// user pressed enter
// user pressed enter if (enter)
if (enter) { // show all text immediately
{ // show all text immediately
}
} }
} else if (state==STATE_WAITASEC)
else if (state==STATE_WAITASEC) {
{ if (enter) goto nextline;
if (enter) goto nextline; if (waittimer<BACKHOME_SHORT_WAIT_TIME)
if (waittimer<BACKHOME_SHORT_WAIT_TIME) {
{ waittimer++;
waittimer++; if (waittimer==BACKHOME_SHORT_WAIT_TIME)
if (waittimer==BACKHOME_SHORT_WAIT_TIME) {
{ nextline: ;
nextline: ; textline++;
textline++; state = STATE_TEXTAPPEARING;
state = STATE_TEXTAPPEARING; amountshown = 0;
amountshown = 0; if (textline>7)
if (textline>7) { // end of text
{ // end of text break;
break; }
} }
} }
} }
}
if (fade.dir==FADE_OUT && fade.mode==FADE_COMPLETE)
if (fade.dir==FADE_OUT && fade.mode==FADE_COMPLETE) return 0;
return 0;
gamedo_fades();
gamedo_fades(); gamedo_frameskipping_blitonly();
gamedo_frameskipping_blitonly();
lastenterstate = enter;
lastenterstate = enter;
g_pInput->pollEvents();
g_pInput->pollEvents(); g_pTimer->SpeedThrottle();
g_pTimer->SpeedThrottle(); if (g_pInput->getPressedKey(KQUIT)) return 1;
if (g_pInput->getPressedKey(KQUIT)) return 1; } while(1);
} while(1);
finale_draw("finale.ck1", pCKP->GameData[pCKP->Resources.GameSelected-1].DataDirectory);
finale_draw("finale.ck1", pCKP->GameData[pCKP->Resources.GameSelected-1].DataDirectory); eseq_ToBeContinued(pCKP);
eseq_ToBeContinued(pCKP); return 1;
return 1; }
}
void eseq_ToBeContinued(stCloneKeenPlus *pCKP)
void eseq_ToBeContinued(stCloneKeenPlus *pCKP) {
{ int i;
int i; char *text;
std::string text; int dlgX, dlgY, dlgW, dlgH;
int dlgX, dlgY, dlgW, dlgH;
// remove all objects because eseq_showmsg will call drawobjects
// remove all objects because eseq_showmsg will call drawobjects for(i=0;i<MAX_OBJECTS;i++)
for(i=0;i<MAX_OBJECTS;i++) objects[i].exists = 0;
objects[i].exists = 0;
text = getstring("TO_BE_CONTINUED");
text = getstring("TO_BE_CONTINUED"); dlgX = GetStringAttribute("TO_BE_CONTINUED", "LEFT");
dlgX = GetStringAttribute("TO_BE_CONTINUED", "LEFT"); dlgY = GetStringAttribute("TO_BE_CONTINUED", "TOP");
dlgY = GetStringAttribute("TO_BE_CONTINUED", "TOP"); dlgW = GetStringAttribute("TO_BE_CONTINUED", "WIDTH");
dlgW = GetStringAttribute("TO_BE_CONTINUED", "WIDTH"); dlgH = GetStringAttribute("TO_BE_CONTINUED", "HEIGHT");
dlgH = GetStringAttribute("TO_BE_CONTINUED", "HEIGHT"); eseq_showmsg(text, dlgX, dlgY, dlgW, dlgH, 0, pCKP);
eseq_showmsg(text, dlgX, dlgY, dlgW, dlgH, 0, pCKP);
fade.dir = FADE_OUT;
fade.dir = FADE_OUT; fade.curamt = PAL_FADE_SHADES;
fade.curamt = PAL_FADE_SHADES; fade.fadetimer = 0;
fade.fadetimer = 0; fade.rate = FADE_NORM;
fade.rate = FADE_NORM; fade.mode = FADE_GO;
fade.mode = FADE_GO; do
do {
{ gamedo_fades();
gamedo_fades(); if (g_pInput->getPressedKey(KQUIT)) return;
if (g_pInput->getPressedKey(KQUIT)) return; g_pInput->pollEvents();
g_pInput->pollEvents(); g_pTimer->SpeedThrottle();
g_pTimer->SpeedThrottle(); } while(fade.mode == FADE_GO);
} while(fade.mode == FADE_GO); }
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,12 +1,14 @@
#ifndef __CG_FILEIO2_H__ #ifdef __cplusplus
#define __CG_FILEIO2_H__ extern "C" {
#endif
#include <string> #include <stdio.h>
#include <cstdio>
char loadstrings(const char *fname); char loadstrings(const char *fname);
unsigned int fgeti(FILE *fp); unsigned int fgeti(FILE *fp);
unsigned long fgetl(FILE *fp); unsigned long fgetl(FILE *fp);
std::string formatPathString(const std::string& path); void formatPathString(char *output, const char *path);
#ifdef __cplusplus
}
#endif #endif

View File

@@ -6,31 +6,29 @@
*/ */
#include "CExeFile.h" #include "CExeFile.h"
#include <cstring> #include <string.h>
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include "../StringUtils.h"
using namespace std; using namespace std;
CExeFile::CExeFile(int episode, const std::string& datadirectory) { CExeFile::CExeFile(int episode, char *datadirectory) {
m_episode = episode; m_episode = episode;
m_datadirectory = datadirectory; m_datadirectory = datadirectory;
m_data = NULL; m_data = NULL;
} }
CExeFile::~CExeFile() { CExeFile::~CExeFile() {
if(m_data) delete m_data; if(m_data) delete [] m_data;
} }
bool CExeFile::readData() bool CExeFile::readData()
{ {
char filename[256];
unsigned char *m_data_temp; unsigned char *m_data_temp;
std::string filename = "data/" + m_datadirectory + "keen" + itoa(m_episode) + ".exe"; sprintf(filename, "data/%skeen%d.exe", m_datadirectory, m_episode);
std::ifstream File(filename.c_str(),ios::binary); ifstream File(filename,ios::binary);
if(!File) return false; if(!File) return false;
@@ -49,7 +47,7 @@ bool CExeFile::readData()
{ {
m_datasize = decdata.size(); m_datasize = decdata.size();
m_data = new unsigned char[m_datasize]; m_data = new unsigned char[m_datasize];
memcpy(m_data, &decdata[0], m_datasize); memcpy(m_data, decdata->data(), m_datasize);
} }
else else
{ {
@@ -57,7 +55,7 @@ bool CExeFile::readData()
m_data = new unsigned char[m_datasize]; m_data = new unsigned char[m_datasize];
memcpy(m_data, m_data_temp+512,m_datasize); memcpy(m_data, m_data_temp+512,m_datasize);
} }
delete m_data_temp; delete [] m_data_temp;
return true; return true;
} }

View File

@@ -12,11 +12,11 @@
#define CEXEFILE_H_ #define CEXEFILE_H_
#include <vector> #include <vector>
#include <string> using namespace std;
class CExeFile { class CExeFile {
public: public:
CExeFile(int episode, const std::string& datadirectory); CExeFile(int episode, char *datadirectory);
virtual ~CExeFile(); virtual ~CExeFile();
bool readData(); bool readData();
@@ -27,10 +27,10 @@ private:
int m_datasize; int m_datasize;
int m_episode; int m_episode;
unsigned char *m_data; unsigned char *m_data;
std::string m_datadirectory; char *m_datadirectory;
int get_bit(int *p_bit_count, unsigned char *fin, int *posin); int get_bit(int *p_bit_count, unsigned char *fin, int *posin);
int unlzexe(unsigned char *fin, std::vector<unsigned char> *outbuffer); int unlzexe(unsigned char *fin, vector<unsigned char> *outbuffer);
}; };
#endif /* CEXEFILE_H_ */ #endif /* CEXEFILE_H_ */

View File

@@ -83,7 +83,7 @@ bool CParser::saveParseFile(void) // open, write on the file and close
if((fp=fopen(CONFIGFILENAME,"wt"))) if((fp=fopen(CONFIGFILENAME,"wt")))
{ {
std::list<char*>::iterator i; list<char*>::iterator i;
for(i=m_filebuffer.begin() ; i != m_filebuffer.end() ; ++i ) for(i=m_filebuffer.begin() ; i != m_filebuffer.end() ; ++i )
fprintf(fp,"%s",*i); fprintf(fp,"%s",*i);
@@ -104,7 +104,7 @@ bool CParser::saveParseFile(void) // open, write on the file and close
int CParser::getIntValue(const char *keyword, const char *category) int CParser::getIntValue(const char *keyword, const char *category)
{ {
// The getter will search for category and than for keyword. After that, read the value and return it! // The getter will search for category and than for keyword. After that, read the value and return it!
std::list<char*>::iterator i; list<char*>::iterator i;
char *line; char *line;
@@ -152,7 +152,7 @@ void CParser::saveIntValue(const char *keyword, const char *category,int value)
// 2.- category exists, but keyword not // 2.- category exists, but keyword not
// 3.- category and keyword exist, only the value must be changed // 3.- category and keyword exist, only the value must be changed
std::list<char*>::iterator i; list<char*>::iterator i;
char *line; char *line;

View File

@@ -10,6 +10,7 @@
#include <iostream> #include <iostream>
#include <list> #include <list>
using namespace std;
class CParser { class CParser {
@@ -42,7 +43,7 @@ public:
private: private:
bool m_isOpen; bool m_isOpen;
std::list<char*> m_filebuffer; list<char*> m_filebuffer;
}; };

View File

@@ -10,11 +10,11 @@
#include <string.h> #include <string.h>
#include <fstream> #include <fstream>
CPatcher::CPatcher(int episode, int version,unsigned char *data, const std::string& datadir) { CPatcher::CPatcher(int episode, int version,unsigned char *data, char *datadir) {
m_episode = episode; m_episode = episode;
m_version = version; m_version = version;
m_data = data; m_data = data;
m_datadirectory = datadir; strcpy(m_datadirectory, datadir);
} }
CPatcher::~CPatcher() { CPatcher::~CPatcher() {
@@ -35,7 +35,7 @@ void CPatcher::patchMemory()
// change to the proper directory // change to the proper directory
chdir("data"); chdir("data");
chdir(m_datadirectory.c_str()); chdir(m_datadirectory);
// TODO: Extend this part further with more commands // TODO: Extend this part further with more commands
while(!m_TextList.empty()) while(!m_TextList.empty())
@@ -80,6 +80,7 @@ void CPatcher::patchMemory()
} }
} }
} }
} }
if(!m_TextList.empty()) if(!m_TextList.empty())
@@ -108,7 +109,7 @@ bool CPatcher::loadPatchfile()
{ {
bool ret = false; bool ret = false;
chdir("data"); chdir("data");
chdir(m_datadirectory.c_str()); chdir(m_datadirectory);
// Detect the patchfile // Detect the patchfile
DIR *dir = opendir("."); DIR *dir = opendir(".");
struct dirent *dp; struct dirent *dp;
@@ -120,9 +121,8 @@ bool CPatcher::loadPatchfile()
if(strstr(dp->d_name,".pat")) if(strstr(dp->d_name,".pat"))
{ {
// The file was found! now read it into the memory! // The file was found! now read it into the memory!
char* buf; char* buf;
std::ifstream Patchfile(dp->d_name); ifstream Patchfile(dp->d_name);
while(!Patchfile.eof()) while(!Patchfile.eof())
{ {
@@ -157,12 +157,12 @@ bool CPatcher::loadPatchfile()
return ret; return ret;
} }
void CPatcher::patchMemfromFile(const std::string& patch_file_name, int offset) void CPatcher::patchMemfromFile(const char *patch_file_name, int offset)
{ {
unsigned char *buf_to_patch; unsigned char *buf_to_patch;
unsigned char byte; unsigned char byte;
std::ifstream Patchfile(patch_file_name.c_str(), std::ios::binary); ifstream Patchfile(patch_file_name, ios::binary);
if(!Patchfile) return; if(!Patchfile) return;

View File

@@ -9,15 +9,15 @@
#define CPATCHER_H_ #define CPATCHER_H_
#include <list> #include <list>
#include <string> using namespace std;
class CPatcher { class CPatcher {
public: public:
CPatcher(int episode, int version,unsigned char *data, const std::string& datadir); CPatcher(int episode, int version,unsigned char *data, char *datadir);
virtual ~CPatcher(); virtual ~CPatcher();
void patchMemory(); void patchMemory();
void patchMemfromFile(const std::string& patch_file_name, int offset); void patchMemfromFile(const char *patch_file_name, int offset);
private: private:
@@ -26,9 +26,9 @@ private:
int m_episode; int m_episode;
int m_version; int m_version;
unsigned char *m_data; unsigned char *m_data;
std::string m_datadirectory; char m_datadirectory[256];
std::list<char*> m_TextList; list<char*> m_TextList;
}; };

View File

@@ -12,19 +12,24 @@
#include "../include/fileio.h" #include "../include/fileio.h"
#include "../fileio/CExeFile.h" #include "../fileio/CExeFile.h"
#include "../CLogFile.h" #include "../CLogFile.h"
#include "../StringUtils.h"
int readStoryText(char **ptext, int episode, const std::string& path) int readStoryText(char **ptext, int episode, char *path)
{ {
std::string buf2 = formatPathString(path);
std::string buf = buf2 + "storytxt.ck" + itoa(episode);
FILE *fp; FILE *fp;
if((fp=fopen(buf.c_str(),"rt"))==NULL) char buf[256];
{ char buf2[256];
buf = buf2 + "keen" + itoa(episode) + ".exe";
if((fp=fopen(buf.c_str(),"rb"))!=NULL) memset(buf,0,256*sizeof(char));
formatPathString(buf2,path);
sprintf(buf,"%sstorytxt.ck%d",buf2,episode);
if((fp=fopen(buf,"rt"))==NULL)
{
sprintf(buf,"%skeen%d.exe",buf2,episode);
if((fp=fopen(buf,"rb"))!=NULL)
{ {
unsigned char *filebuf; unsigned char *filebuf;
int startflag=0, endflag=0; // where story begins and ends! int startflag=0, endflag=0; // where story begins and ends!

View File

@@ -1,133 +1,135 @@
/* FINALE.C /* FINALE.C
Code for displaying the FINALE.CK? files. Code for displaying the FINALE.CK? files.
Thanks to Andrew Durdin for FIN2BMP, from which I got Thanks to Andrew Durdin for FIN2BMP, from which I got
the decompression algorithm. the decompression algorithm.
*/ */
#include "keen.h" #include "keen.h"
#include "include/fileio.h" #include "include/fileio.h"
#include "CGraphics.h" #include "CGraphics.h"
int finale_x; int finale_x;
int finale_y; int finale_y;
int finale_count; int finale_count;
int finale_planecol; int finale_planecol;
int finale_plane_length; int finale_plane_length;
int finale_done; int finale_done;
// used internally by finale_draw() // used internally by finale_draw()
void finale_plot(int pix) void finale_plot(int pix)
{ {
int mask; int mask;
mask = 128; mask = 128;
do do
{ {
if (pix & mask) if (pix & mask)
{ {
if (finale_planecol==1) if (finale_planecol==1)
{ {
g_pGraphics->sb_setpixel(finale_x, finale_y, finale_planecol); g_pGraphics->sb_setpixel(finale_x, finale_y, finale_planecol);
} }
else else
{ // merge with previous planes { // merge with previous planes
g_pGraphics->sb_setpixel(finale_x, finale_y, g_pGraphics->sb_getpixel(finale_x, finale_y) | finale_planecol); g_pGraphics->sb_setpixel(finale_x, finale_y, g_pGraphics->sb_getpixel(finale_x, finale_y) | finale_planecol);
} }
} }
else if (finale_planecol==1) else if (finale_planecol==1)
{ {
g_pGraphics->sb_setpixel(finale_x, finale_y, 0); g_pGraphics->sb_setpixel(finale_x, finale_y, 0);
} }
finale_x++; finale_x++;
if (finale_x > 319) if (finale_x > 319)
{ {
finale_x = 0; finale_x = 0;
finale_y++; finale_y++;
} }
finale_count++; finale_count++;
if (finale_count >= finale_plane_length) if (finale_count >= finale_plane_length)
{ {
finale_x = finale_y = 0; finale_x = finale_y = 0;
finale_count = 0; finale_count = 0;
finale_planecol <<= 1; finale_planecol <<= 1;
if (finale_planecol > 8) finale_done = 1; if (finale_planecol > 8) finale_done = 1;
} }
if (mask==1) if (mask==1)
{ {
return; return;
} }
else else
{ {
mask >>= 1; mask >>= 1;
} }
} while(1); } while(1);
} }
// draws a finale.ck? file into the upper-left corner of the scrollbuffer // draws a finale.ck? file into the upper-left corner of the scrollbuffer
void finale_draw(const std::string& filename, const std::string& path) void finale_draw(const char *filename, const char *path)
{ {
FILE *fp; char fname[256];
int cmdbyte; FILE *fp;
int bytecount; int cmdbyte;
int repeatbyte; int bytecount;
int i; int repeatbyte;
int i;
char buffer[256];
std::string buffer = formatPathString(path);
formatPathString(buffer,path);
map_unregister_all_animtiles();
std::string fname = buffer + filename; map_unregister_all_animtiles();
fp = fopen(fname.c_str(), "rb");
if (!fp) sprintf(fname, "%s%s", buffer,filename);
{ fp = fopen(fname, "rb");
crashflag = 1; if (!fp)
why_term_ptr = "finale_draw(): cannot open finake.ck? file."; {
return; crashflag = 1;
} why_term_ptr = "finale_draw(): cannot open finake.ck? file.";
return;
finale_plane_length = fgetl(fp)*2; //length of a plane when decompressed }
finale_planecol = 1;
finale_x = finale_y = 0; finale_plane_length = fgetl(fp)*2; //length of a plane when decompressed
finale_count = 0; finale_planecol = 1;
finale_done = 0; finale_x = finale_y = 0;
finale_count = 0;
/* decompress/draw the image */ finale_done = 0;
do
{ /* decompress/draw the image */
cmdbyte = fgetc(fp); do
if (cmdbyte<0) {
{ // EOF cmdbyte = fgetc(fp);
return; if (cmdbyte<0)
} { // EOF
return;
if (cmdbyte & 0x80) }
{
//N + 1 bytes of data follows if (cmdbyte & 0x80)
bytecount = (cmdbyte & 0x7F) + 1; {
for(i=0;i<bytecount;i++) //N + 1 bytes of data follows
{ bytecount = (cmdbyte & 0x7F) + 1;
finale_plot(fgetc(fp)); for(i=0;i<bytecount;i++)
} {
} finale_plot(fgetc(fp));
else }
{ }
//Repeat N + 3 of following byte else
bytecount = (cmdbyte + 3); {
repeatbyte = fgetc(fp); //Repeat N + 3 of following byte
for(i=0;i<bytecount;i++) bytecount = (cmdbyte + 3);
{ repeatbyte = fgetc(fp);
finale_plot(repeatbyte); for(i=0;i<bytecount;i++)
} {
} finale_plot(repeatbyte);
}
} while(!finale_done); }
fclose(fp); } while(!finale_done);
}
fclose(fp);
}

View File

@@ -1,162 +1,163 @@
/*check if the compiler is of C++*/
#ifndef __CG_FUNCDEFS_H__ #ifdef __cplusplus
#define __CG_FUNCDEFS_H__ extern "C" {
#endif
#include <string>
// gamedo.c
// gamedo.c int gamedo_ScrollTriggers(int theplayer);
int gamedo_ScrollTriggers(int theplayer); void gamedo_AnimatedTiles(void);
void gamedo_AnimatedTiles(void);
void gamedo_render_eraseobjects(void);
void gamedo_render_eraseobjects(void); void gamedo_render_drawdebug(void);
void gamedo_render_drawdebug(void); void gamedo_render_erasedebug(void);
void gamedo_render_erasedebug(void); void gamedo_fades(void);
void gamedo_fades(void);
// gamepdo.c
// gamepdo.c
// gamepdowm.c
// gamepdowm.c //void gamepdo_wm_HandlePlayer(int cp);
//void gamepdo_wm_HandlePlayer(int cp); //void gamepdo_InertiaAndFriction_Y(int cp);
//void gamepdo_InertiaAndFriction_Y(int cp); //void gamepdo_wm_AllowEnterLevel(int cp);
//void gamepdo_wm_AllowEnterLevel(int cp); char wm_issolid(int xb, int yb, int *levels_completed);
char wm_issolid(int xb, int yb, int *levels_completed);
// game.c
// game.c //void SetGameOver(void);
//void SetGameOver(void); void overrun_detect(void);
void overrun_detect(void); void scrolltest(void);
void scrolltest(void); //void gameloop_initialize(void);
//void gameloop_initialize(void); void give_keycard(int doortile, int p);
void give_keycard(int doortile, int p); void take_keycard(int doortile, int p);
void take_keycard(int doortile, int p); //void open_door(int doortile, int doorsprite, int mpx, int mpy, int cp, stCloneKeenPlus *pCKP)
//void open_door(int doortile, int doorsprite, int mpx, int mpy, int cp, stCloneKeenPlus *pCKP) void extralifeat(int p);
void extralifeat(int p); char spawn_object(int x, int y, int otype);
char spawn_object(int x, int y, int otype); void common_enemy_ai(int o);
void common_enemy_ai(int o); char hitdetect(int object1, int object2);
char hitdetect(int object1, int object2); void freezeplayer(int theplayer);
void freezeplayer(int theplayer); void unregister_animtiles(int tile);
void unregister_animtiles(int tile); //void endlevel(int success, stCloneKeenPlus *pCKP)
//void endlevel(int success, stCloneKeenPlus *pCKP) char checkobjsolid(unsigned int x, unsigned int y, unsigned int cp);
char checkobjsolid(unsigned int x, unsigned int y, unsigned int cp); //void initsprites(stCloneKeenPlus *pCKP)
//void initsprites(stCloneKeenPlus *pCKP) void CopyTileToSprite(int t, int s, int ntilestocopy, int transparent);
void CopyTileToSprite(int t, int s, int ntilestocopy, int transparent); void GiveAnkh(int cp);
void GiveAnkh(int cp); // map.c
// map.c void map_scroll_right(void);
void map_scroll_right(void); void map_scroll_left(void);
void map_scroll_left(void); void map_scroll_down(void);
void map_scroll_down(void); void map_scroll_up(void);
void map_scroll_up(void); void map_draw_vstripe(unsigned int x, unsigned int mpx);
void map_draw_vstripe(unsigned int x, unsigned int mpx); void map_draw_hstripe(unsigned int y, unsigned int mpy);
void map_draw_hstripe(unsigned int y, unsigned int mpy); void nosb_map_draw_vstripe(unsigned int x, unsigned int mapx);
void nosb_map_draw_vstripe(unsigned int x, unsigned int mapx); unsigned int getmaptileat(unsigned int x, unsigned int y);
unsigned int getmaptileat(unsigned int x, unsigned int y); unsigned int getlevelat(unsigned int x, unsigned int y);
unsigned int getlevelat(unsigned int x, unsigned int y); void drawmap(void);
void drawmap(void); void map_unregister_all_animtiles(void);
void map_unregister_all_animtiles(void); void map_deanimate(int x, int y);
void map_deanimate(int x, int y); int map_isanimated(int x, int y);
int map_isanimated(int x, int y); void map_animate(int x, int y);
void map_animate(int x, int y); char map_findobject(unsigned int obj, int *xout, int *yout);
char map_findobject(unsigned int obj, int *xout, int *yout); char map_findtile(unsigned int tile, int *xout, int *yout);
char map_findtile(unsigned int tile, int *xout, int *yout); void map_redraw(void);
void map_redraw(void); void map_chgtile(unsigned int x,unsigned int y, int newtile);
void map_chgtile(unsigned int x,unsigned int y, int newtile); // dos\snddrv.c
// dos\snddrv.c void SoundDrv_Stop(void);
void SoundDrv_Stop(void); void sound_do(void);
void sound_do(void); void sound_play_stereo(int snd, char mode, short balance);
void sound_play_stereo(int snd, char mode, short balance); void sound_play_stereo_from_coord(int snd, char mode, unsigned int xcoordinate);
void sound_play_stereo_from_coord(int snd, char mode, unsigned int xcoordinate); void sound_play(int snd, char mode);
void sound_play(int snd, char mode); char sound_is_playing(int snd);
char sound_is_playing(int snd); void sound_stop(int snd);
void sound_stop(int snd); void sound_stop_all(void);
void sound_stop_all(void); void sound_pause(void);
void sound_pause(void); void sound_resume(void);
void sound_resume(void); char sound_extraction_of_exe_files(char *inputpath, int episode);
char sound_extraction_of_exe_files(char *inputpath, int episode);
// graphics.c
// graphics.c void DrawBitmap(int xa, int ya, int b);
void DrawBitmap(int xa, int ya, int b); void freemem(void);
void freemem(void); void Graphics_Stop(void);
void Graphics_Stop(void); void /*inline*/ sb_setpixel(int x, int y, unsigned char c);
void /*inline*/ sb_setpixel(int x, int y, unsigned char c); unsigned char sb_getpixel(int x, int y);
unsigned char sb_getpixel(int x, int y); void drawtile(int x, int y, unsigned int t);
void drawtile(int x, int y, unsigned int t); void drawtile_direct(int x, int y, unsigned int t);
void drawtile_direct(int x, int y, unsigned int t); void drawtilewithmask(int x, int y, unsigned int til, unsigned int tmask);
void drawtilewithmask(int x, int y, unsigned int til, unsigned int tmask); void drawprioritytile(int x, int y, unsigned int til);
void drawprioritytile(int x, int y, unsigned int til); void drawsprite_direct(int x, int y, unsigned int t);
void drawsprite_direct(int x, int y, unsigned int t); void drawsprite(int x, int y, unsigned int s, int objectnum);
void drawsprite(int x, int y, unsigned int s, int objectnum); void erasesprite(int x, int y, unsigned int s, int objectnum);
void erasesprite(int x, int y, unsigned int s, int objectnum); void drawcharacter(int x, int y, int f);
void drawcharacter(int x, int y, int f); void sb_drawcharacter(int x, int y, int f);
void sb_drawcharacter(int x, int y, int f); void sb_drawcharacterwithmask(int x, int y, int f, char mask);
void sb_drawcharacterwithmask(int x, int y, int f, char mask); void sb_drawcolorcharacter(int x, int y, int f, unsigned short colour, unsigned short bgcolour);
void sb_drawcolorcharacter(int x, int y, int f, unsigned short colour, unsigned short bgcolour); void sb_drawcharacterinverse(int x, int y, int f);
void sb_drawcharacterinverse(int x, int y, int f); void save_area(int x1, int y1, int x2, int y2);
void save_area(int x1, int y1, int x2, int y2); void restore_area(int x1, int y1, int x2, int y2);
void restore_area(int x1, int y1, int x2, int y2); void setvideomode(unsigned char mode);
void setvideomode(unsigned char mode); void addpal(int c, int r, int g, int b);
void addpal(int c, int r, int g, int b); void pal_init(int dark);
void pal_init(int dark); void pal_fade(int fadeamt);
void pal_fade(int fadeamt); void pal_apply(void);
void pal_apply(void); void font_draw(unsigned char *text, int xoff, int yoff, int highlight);
void font_draw(unsigned char *text, int xoff, int yoff, int highlight); void sb_font_draw(const unsigned char *text, int xoff, int yoff);
void sb_font_draw(const unsigned char *text, int xoff, int yoff); void sb_mask_font_draw(unsigned char *text, int xoff, int yoff, char mask);
void sb_mask_font_draw(unsigned char *text, int xoff, int yoff, char mask); void sb_color_font_draw(unsigned char *text, int xoff, int yoff, unsigned int colour, unsigned short bgcolour);
void sb_color_font_draw(unsigned char *text, int xoff, int yoff, unsigned int colour, unsigned short bgcolour); void sb_font_draw_inverse(unsigned char *text, int xoff, int yoff);
void sb_font_draw_inverse(unsigned char *text, int xoff, int yoff); // viddrv.c
// viddrv.c // fileio.c
// fileio.c //void addmaptile(unsigned int t, stCloneKeenPlus *pCKP);
//void addmaptile(unsigned int t, stCloneKeenPlus *pCKP); //void addenemytile(unsigned int t, stCloneKeenPlus *pCKP);
//void addenemytile(unsigned int t, stCloneKeenPlus *pCKP); //unsigned int fgeti(FILE *fp);
//unsigned int fgeti(FILE *fp); //unsigned long fgetl(FILE *fp);
//unsigned long fgetl(FILE *fp); //unsigned int loadmap(char *filename, char *path, int lvlnum, int isworldmap);
//unsigned int loadmap(char *filename, char *path, int lvlnum, int isworldmap); #include "fileio.h"
#include "fileio.h"
bool loadtileattributes(int episode, int version, unsigned char *filebuf);
bool loadtileattributes(int episode, int version, unsigned char *filebuf); int freestrings(void);
int freestrings(void); char* getstring(const char *name);
std::string getstring(const std::string& name); int GetStringAttribute(const char *stringName, const char *attrName);
int GetStringAttribute(const std::string& stringName, const char *attrName);
// keydrv.c
// keydrv.c char KeyDrv_Start(void);
char KeyDrv_Start(void); void KeyDrv_Stop(void);
void KeyDrv_Stop(void);
// misc.c
// misc.c void banner(void);
void banner(void); void dialogbox(int x1, int y1, int w, int h);
void dialogbox(int x1, int y1, int w, int h); void sb_dialogbox(int x1, int y1, int w, int h);
void sb_dialogbox(int x1, int y1, int w, int h); void statusbox(void);
void statusbox(void);
int savegameiswm(char *fname);
int savegameiswm(char *fname); void usage(void);
void usage(void); void radar(void);
void radar(void); void SetAllCanSupportPlayer(int o, int state);
void SetAllCanSupportPlayer(int o, int state); void AllPlayersInvisible(void);
void AllPlayersInvisible(void);
// menu.c
// menu.c int GetBitmapNumberFromName(const char *bmname);
int GetBitmapNumberFromName(const char *bmname);
// eseq_ep1.c
// eseq_ep1.c void addshipqueue(int cmd, int time, int flag1);
void addshipqueue(int cmd, int time, int flag1);
// latch.c
// latch.c //char latch_loadgraphics(int episode, char *path);
//char latch_loadgraphics(int episode, char *path);
// sglre.c
// sglre.c void sgrle_reset(void);
void sgrle_reset(void); void sgrle_compress(FILE *fp, unsigned char *ptr, unsigned long nbytes);
void sgrle_compress(FILE *fp, unsigned char *ptr, unsigned long nbytes); void sgrle_decompress(FILE *fp, unsigned char *ptr, unsigned long nbytes);
void sgrle_decompress(FILE *fp, unsigned char *ptr, unsigned long nbytes); unsigned char sgrle_get_next_byte(FILE *fp);
unsigned char sgrle_get_next_byte(FILE *fp);
// lz.c
// lz.c char lz_decompress(FILE *lzfile, unsigned char *outbuffer);
char lz_decompress(FILE *lzfile, unsigned char *outbuffer);
// finale.c
// finale.c void finale_draw(const char *filename, const char *path);
void finale_draw(const std::string& filename, const std::string& path);
// scalerx.c
// scalerx.c //void scale2x(void* void_dst, unsigned dst_slice, const void* void_src, unsigned src_slice, unsigned pixel, unsigned width, unsigned height);
//void scale2x(void* void_dst, unsigned dst_slice, const void* void_src, unsigned src_slice, unsigned pixel, unsigned width, unsigned height);
/*check if the compiler is of C++*/
#endif #ifdef __cplusplus
}
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -22,9 +22,9 @@ CHQBitmap::~CHQBitmap() {
if(m_blackscreen){ SDL_FreeSurface(m_blackscreen); m_blackscreen = NULL;} if(m_blackscreen){ SDL_FreeSurface(m_blackscreen); m_blackscreen = NULL;}
} }
bool CHQBitmap::loadImage(const std::string& pFilename, int wsize, int hsize) bool CHQBitmap::loadImage(const char *pFilename, int wsize, int hsize)
{ {
SDL_Surface *BitmapSurface = SDL_LoadBMP(pFilename.c_str()); SDL_Surface *BitmapSurface = SDL_LoadBMP(pFilename);
m_active = false; m_active = false;

View File

@@ -9,7 +9,6 @@
#define CHQBITMAP_H_ #define CHQBITMAP_H_
#include <SDL.h> #include <SDL.h>
#include <string>
class CHQBitmap { class CHQBitmap {
public: public:
@@ -18,7 +17,7 @@ public:
void setScrollposition(unsigned int xpos, unsigned int ypos); void setScrollposition(unsigned int xpos, unsigned int ypos);
void updateHQBitmap(SDL_Surface *m_surface, SDL_Rect *p_srcrect, SDL_Rect *p_dstrect); void updateHQBitmap(SDL_Surface *m_surface, SDL_Rect *p_srcrect, SDL_Rect *p_dstrect);
bool loadImage(const std::string& pFilename, int wsize, int hsize); bool loadImage(const char *pFilename, int wsize, int hsize);
void setAlphaBlend(Uint8 alpha); void setAlphaBlend(Uint8 alpha);
void offsetAlphaBlend(Uint8 alpha); void offsetAlphaBlend(Uint8 alpha);

View File

@@ -12,6 +12,7 @@
CMusic::CMusic() { CMusic::CMusic() {
playmode = PLAY_MODE_STOP; playmode = PLAY_MODE_STOP;
music_buffer = NULL;
} }
CMusic::~CMusic() { CMusic::~CMusic() {
@@ -20,6 +21,8 @@ CMusic::~CMusic() {
int CMusic::load(SDL_AudioSpec AudioSpec, char *musicfile) int CMusic::load(SDL_AudioSpec AudioSpec, char *musicfile)
{ {
FILE *fp;
if(AudioSpec.format != 0) if(AudioSpec.format != 0)
{ {
@@ -33,10 +36,10 @@ int CMusic::load(SDL_AudioSpec AudioSpec, char *musicfile)
pOggAudio.sound_len=0; pOggAudio.sound_len=0;
pOggAudio.sound_pos=0; pOggAudio.sound_pos=0;
FILE *fp;
if((fp = fopen(musicfile,"rb")) == NULL) if((fp = fopen(musicfile,"rb")) == NULL)
{ {
g_pLogFile->textOut(PURPLE,"Music Driver(): \"%s\". File does not exist!<br>", musicfile); g_pLogFile->textOut(PURPLE,"Music Driver(): \"%s\". File does not exist!<br>", musicfile);
return -1; return -1;
} }
@@ -101,7 +104,8 @@ void CMusic::unload(void)
void CMusic::play(void) void CMusic::play(void)
{ {
playmode = PLAY_MODE_PLAY; if(music_buffer)
playmode = PLAY_MODE_PLAY;
} }
void CMusic::stop(void) void CMusic::stop(void)

View File

@@ -11,17 +11,17 @@
#include "../include/vorbis/oggsupport.h" #include "../include/vorbis/oggsupport.h"
#include "../CLogFile.h" #include "../CLogFile.h"
short HQSndDrv_Load(SDL_AudioSpec *AudioSpec, stHQSound *psound, const std::string& soundfile) short HQSndDrv_Load(SDL_AudioSpec *AudioSpec, stHQSound *psound, const char *soundfile)
{ {
SDL_AudioSpec AudioFileSpec; SDL_AudioSpec AudioFileSpec;
SDL_AudioCVT Audio_cvt; SDL_AudioCVT Audio_cvt;
psound->sound_buffer = NULL; psound->sound_buffer = NULL;
std::string buf; char buf[80];
FILE *fp; FILE *fp;
buf = "data/hqp/snd/" + soundfile + ".OGG"; // Start with OGG sprintf(buf,"data/hqp/snd/%s.OGG",soundfile); // Start with OGG
if((fp = fopen(buf.c_str(),"rb")) != NULL) if((fp = fopen(buf,"rb")) != NULL)
{ {
#ifdef BUILD_WITH_OGG #ifdef BUILD_WITH_OGG
if(openOGGSound(fp, &AudioFileSpec, AudioSpec->format, psound) != 0) if(openOGGSound(fp, &AudioFileSpec, AudioSpec->format, psound) != 0)
@@ -29,37 +29,38 @@ short HQSndDrv_Load(SDL_AudioSpec *AudioSpec, stHQSound *psound, const std::stri
g_pLogFile->textOut(PURPLE,"OGG file could not be opened: \"%s\". The file was detected, but appears to be damaged. Trying to load the classical sound<br>", soundfile); g_pLogFile->textOut(PURPLE,"OGG file could not be opened: \"%s\". The file was detected, but appears to be damaged. Trying to load the classical sound<br>", soundfile);
return 1; return 1;
} }
psound->enabled = true;
#endif #endif
#ifndef BUILD_WITH_OGG #ifndef BUILD_WITH_OGG
g_pLogFile->textOut(PURPLE,"Sorry, OGG-Support is disabled!<br>"); g_pLogFile->textOut(PURPLE,"Sorry, OGG-Support is disabled!<br>");
buf = "data/hqp/snd/"+ soundfile + ".WAV"; sprintf(buf,"data/hqp/snd/%s.WAV",soundfile);
// Check, if it is a wav file or go back to classic sounds // Check, if it is a wav file or go back to classic sounds
if (SDL_LoadWAV (buf.c_str(), &AudioFileSpec, &(psound->sound_buffer), &(psound->sound_len)) == NULL) if (SDL_LoadWAV (buf, &AudioFileSpec, &(psound->sound_buffer), &(psound->sound_len)) == NULL)
{ {
g_pLogFile->textOut(PURPLE,"Wave file could not be opened: \"%s\". Trying to load the classical sound<br>", buf.c_str()); g_pLogFile->textOut(PURPLE,"Wave file could not be opened: \"%s\". Trying to load the classical sound<br>", buf);
return 1; return 1;
} }
#endif #endif
psound->enabled = true;
} }
else else
{ {
buf = "data/hqp/snd/" + soundfile + ".WAV"; sprintf(buf,"data/hqp/snd/%s.WAV",soundfile);
// Check, if it is a wav file or go back to classic sounds // Check, if it is a wav file or go back to classic sounds
if (SDL_LoadWAV (buf.c_str(), &AudioFileSpec, &(psound->sound_buffer), &(psound->sound_len)) == NULL) if (SDL_LoadWAV (buf, &AudioFileSpec, &(psound->sound_buffer), &(psound->sound_len)) == NULL)
{ {
g_pLogFile->textOut(PURPLE,"Wave file could not be opened: \"%s\". Trying to load the classical sounds<br>", buf.c_str()); g_pLogFile->textOut(PURPLE,"Wave file could not be opened: \"%s\". Trying to load the classical sounds<br>", buf);
return 1; return 1;
} }
} }
psound->sound_pos = 0; psound->sound_pos = 0;
g_pLogFile->textOut(PURPLE,"File \"%s\" opened successfully!<br>", buf.c_str()); g_pLogFile->textOut(PURPLE,"File \"%s\" opened successfully!<br>", buf);
int ret; int ret;
/* Build AudioCVT (This is needed for the conversion from one format to the one used in the game)*/ /* Build AudioCVT (This is needed for the conversion from one format to the one used in the game)*/

View File

@@ -5,21 +5,15 @@
* Author: gerstrong * Author: gerstrong
*/ */
#ifndef __CG_HQ_SOUND_H__
#define __CG_HQ_SOUND_H__
#include <SDL.h> #include <SDL.h>
#include <string>
struct stHQSound typedef struct stHQSound
{ {
Uint8 *sound_buffer; Uint8 *sound_buffer;
Uint32 sound_len; Uint32 sound_len;
int sound_pos; int sound_pos;
bool enabled; bool enabled;
}; } stHQSound;
short HQSndDrv_Load(SDL_AudioSpec *AudioSpec, stHQSound *psound, const std::string& soundfile); short HQSndDrv_Load(SDL_AudioSpec *AudioSpec, stHQSound *psound, const char *soundfile);
void HQSndDrv_Unload(stHQSound *psound); void HQSndDrv_Unload(stHQSound *psound);
#endif

View File

@@ -1,12 +1,8 @@
#ifndef __CG_DECLARATIONS_H__
#define __CG_DECLARATIONS_H__
#include <string>
#include <SDL.h>
#define MAX_COMMANDS 8 #define MAX_COMMANDS 8
#define MAX_SOUND_LENGTH 1024 #define MAX_SOUND_LENGTH 1024
#define MAX_SOUNDS 50 #define MAX_SOUNDS 50
#define MAX_STRING_LENGTH 256
#define MAX_NUMBER_OF_FILES 100 #define MAX_NUMBER_OF_FILES 100
@@ -72,11 +68,10 @@ typedef struct stControl
typedef struct stGameData typedef struct stGameData
{ {
std::string DataDirectory; char DataDirectory[MAX_STRING_LENGTH];
short Episode; short Episode;
std::string Name; char Name[MAX_STRING_LENGTH];
std::string FileList[MAX_NUMBER_OF_FILES]; char FileList[MAX_NUMBER_OF_FILES][MAX_STRING_LENGTH];
stGameData() : Episode(0) {}
} stGameData; } stGameData;
@@ -111,5 +106,3 @@ typedef struct stNewPlayer
{ {
stCommand Command; stCommand Command;
} stNewPlayer; } stNewPlayer;
#endif

View File

@@ -5,17 +5,10 @@
* Author: gerstrong * Author: gerstrong
*/ */
#ifndef __CG_ESEQ_EP2_H__
#define __CG_ESEQ_EP2_H__
#include <string>
struct stCloneKeenPlus;
int eseq2_LimpsHome(stCloneKeenPlus *pCKP); int eseq2_LimpsHome(stCloneKeenPlus *pCKP);
int eseq2_TantalusRay(stCloneKeenPlus *pCKP); int eseq2_TantalusRay(stCloneKeenPlus *pCKP);
void eseq2_vibrate(stCloneKeenPlus *pCKP); void eseq2_vibrate(stCloneKeenPlus *pCKP);
int eseq2_HeadsForEarth(stCloneKeenPlus *pCKP); int eseq2_HeadsForEarth(stCloneKeenPlus *pCKP);
int eseq2_SnowedOutside(stCloneKeenPlus *pCKP); int eseq2_SnowedOutside(stCloneKeenPlus *pCKP);
void eseq_showmsg(const std::string& text, int boxleft, int boxtop, int boxwidth, int boxheight, char autodismiss, stCloneKeenPlus *pCKP); void eseq_showmsg(char *text, int boxleft, int boxtop, int boxwidth, int boxheight, char autodismiss, stCloneKeenPlus *pCKP);
#endif

View File

@@ -5,17 +5,10 @@
* Author: gerstrong * Author: gerstrong
*/ */
#ifndef __CG_FILEIO_H__ unsigned int loadmap(char filename[MAX_STRING_LENGTH], char *path, int lvlnum, int isworldmap, stCloneKeenPlus *pCKP);
#define __CG_FILEIO_H__
#include <string>
unsigned int loadmap(const std::string& filename, const std::string& path, int lvlnum, int isworldmap, stCloneKeenPlus *pCKP);
void addmaptile(unsigned int t); void addmaptile(unsigned int t);
void addenemytile(unsigned int t, stCloneKeenPlus *pCKP); void addenemytile(unsigned int t, stCloneKeenPlus *pCKP);
short checkConsistencyofGameData(stGameData *p_GameData); short checkConsistencyofGameData(stGameData *p_GameData);
std::string formatPathString(const std::string& path); void formatPathString(char *output, const char *path);
bool renameFilenamesLowerCase(const char *dir_name); bool renameFilenamesLowerCase(const char *dir_name);
void assignChangeTileAttribute(stTile *tile, int episode); void assignChangeTileAttribute(stTile *tile, int episode);
#endif

View File

@@ -5,11 +5,4 @@
* Author: gerstrong * Author: gerstrong
*/ */
#ifndef __CG_STORY_H__ int readStoryText(char **ptext, int episode, char *path);
#define __CG_STORY_H__
#include <string>
int readStoryText(char **ptext, int episode, const std::string& path);
#endif

1728
src/keen.h

File diff suppressed because it is too large Load Diff

View File

@@ -24,7 +24,7 @@
CloneKeen 2003-2005 Caitlin Shaw CloneKeen 2003-2005 Caitlin Shaw
CloneKeenPlus 2008-2009 Gerstrong CloneKeenPlus 2008-2009 Gerstrong
Commander Genius 2009 Tulip, Pickle and DaVince Commander Genius 2009 Tulip, Pickle, DaVince and Albert
*/ */
#include "keen.h" #include "keen.h"
@@ -572,7 +572,6 @@ demoHeaderCorrupt: ;
short readCommandLine(int argc, char *argv[], stCloneKeenPlus *pCKP) short readCommandLine(int argc, char *argv[], stCloneKeenPlus *pCKP)
{ {
int i; int i;
static const int MAX_STRING_LENGTH = 256;
char tempbuf[MAX_STRING_LENGTH]; char tempbuf[MAX_STRING_LENGTH];

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -5,7 +5,6 @@
* Author: gerstrong * Author: gerstrong
*/ */
#include "COpenGL.h" #include "COpenGL.h"
#include "CVideoDriver.h"
#include "../CLogFile.h" #include "../CLogFile.h"
#define GAME_STD_WIDTH 320 #define GAME_STD_WIDTH 320
@@ -116,7 +115,7 @@ void COpenGL::render(void)
//Clear the screen //Clear the screen
glClear(GL_COLOR_BUFFER_BIT); // Clear The Screen glClear(GL_COLOR_BUFFER_BIT); // Clear The Screen
LockSurface(m_blitsurface); SDL_LockSurface(m_blitsurface);
if(m_ScaleX == 2) //Scale 2x if(m_ScaleX == 2) //Scale 2x
{ {
@@ -158,7 +157,7 @@ void COpenGL::render(void)
glVertex3f (0.0, 1.0, 0.0); glVertex3f (0.0, 1.0, 0.0);
glEnd(); glEnd();
UnlockSurface(m_blitsurface); SDL_UnlockSurface(m_blitsurface);
// Reset (Position?) // Reset (Position?)
glLoadIdentity(); glLoadIdentity();

View File

@@ -480,7 +480,7 @@ char tempbuf[80];
#else #else
sprintf(tempbuf, "FPS: %03d", fps); sprintf(tempbuf, "FPS: %03d", fps);
#endif #endif
g_pGraphics->drawFont( tempbuf, 320-3-(strlen( (char *) tempbuf)<<3), 3, 1); g_pGraphics->drawFont( (unsigned char *) tempbuf, 320-3-(strlen( (char *) tempbuf)<<3), 3, 1);
} }
update_screen(); update_screen();
@@ -499,11 +499,11 @@ void CVideoDriver::update_screen(void)
mp_OpenGL->render(); mp_OpenGL->render();
LockSurface(FGLayerSurface); SDL_LockSurface(FGLayerSurface);
// Flush the layers // Flush the layers
memset(FGLayerSurface->pixels,SDL_MapRGB(FGLayerSurface->format, 0, 0, 0), memset(FGLayerSurface->pixels,SDL_MapRGB(FGLayerSurface->format, 0, 0, 0),
GAME_STD_WIDTH*GAME_STD_HEIGHT*FGLayerSurface->format->BytesPerPixel); GAME_STD_WIDTH*GAME_STD_HEIGHT*FGLayerSurface->format->BytesPerPixel);
UnlockSurface(FGLayerSurface); SDL_UnlockSurface(FGLayerSurface);
} }
else // No OpenGL but Software Rendering 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 // another offscreen buffer, and must now stretchblit it to the screen
if (Zoom == 1 && m_Resolution.width != 320 ) if (Zoom == 1 && m_Resolution.width != 320 )
{ {
LockSurface(BlitSurface); SDL_LockSurface(BlitSurface);
LockSurface(screen); SDL_LockSurface(screen);
if(Filtermode == 0) 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>"); g_pLogFile->textOut(PURPLE,"Try to use a higher zoom factor. Switching to no-filter<br>");
Filtermode = 0; Filtermode = 0;
} }
UnlockSurface(screen); SDL_UnlockSurface(screen);
UnlockSurface(BlitSurface); SDL_UnlockSurface(BlitSurface);
} }
if (Zoom == 2) if (Zoom == 2)
{ {
LockSurface(BlitSurface); SDL_LockSurface(BlitSurface);
LockSurface(screen); SDL_LockSurface(screen);
if(Filtermode == 0) if(Filtermode == 0)
{ {
@@ -551,13 +551,13 @@ void CVideoDriver::update_screen(void)
Filtermode = 0; Filtermode = 0;
} }
UnlockSurface(screen); SDL_UnlockSurface(screen);
UnlockSurface(BlitSurface); SDL_UnlockSurface(BlitSurface);
} }
else if (Zoom == 3) else if (Zoom == 3)
{ {
LockSurface(BlitSurface); SDL_LockSurface(BlitSurface);
LockSurface(screen); SDL_LockSurface(screen);
if(Filtermode == 0) 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>"); g_pLogFile->textOut(PURPLE,"Try to use a higher zoom factor. Switching to no-filter<br>");
Filtermode = 0; Filtermode = 0;
} }
UnlockSurface(screen); SDL_UnlockSurface(screen);
UnlockSurface(BlitSurface); SDL_UnlockSurface(BlitSurface);
} }
else if (Zoom == 4) else if (Zoom == 4)
{ {
LockSurface(BlitSurface); SDL_LockSurface(BlitSurface);
LockSurface(screen); SDL_LockSurface(screen);
if(Filtermode == 0) 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>"); g_pLogFile->textOut(PURPLE,"Try to use a higher zoom factor. Switching to no-filter<br>");
Filtermode = 0; Filtermode = 0;
} }
UnlockSurface(screen); SDL_UnlockSurface(screen);
UnlockSurface(BlitSurface); SDL_UnlockSurface(BlitSurface);
} }
SDL_Flip(screen); SDL_Flip(screen);
//SDL_UpdateRect(screen, screenrect.x, screenrect.y, screenrect.w, screenrect.h); //SDL_UpdateRect(screen, screenrect.x, screenrect.y, screenrect.w, screenrect.h);
LockSurface(FGLayerSurface); SDL_LockSurface(FGLayerSurface);
// Flush the layers // Flush the layers
memset(FGLayerSurface->pixels,SDL_MapRGB(FGLayerSurface->format, 0, 0, 0), memset(FGLayerSurface->pixels,SDL_MapRGB(FGLayerSurface->format, 0, 0, 0),
GAME_STD_WIDTH*GAME_STD_HEIGHT*FGLayerSurface->format->BytesPerPixel); GAME_STD_WIDTH*GAME_STD_HEIGHT*FGLayerSurface->format->BytesPerPixel);
UnlockSurface(FGLayerSurface); SDL_UnlockSurface(FGLayerSurface);
#ifdef USE_OPENGL #ifdef USE_OPENGL
} }
#endif #endif
@@ -765,7 +765,7 @@ int y;
y = CONSOLE_MESSAGE_Y; y = CONSOLE_MESSAGE_Y;
for(i=0;i<NumConsoleMessages;i++) for(i=0;i<NumConsoleMessages;i++)
{ {
g_pGraphics->drawFont( cmsg[i].msg, CONSOLE_MESSAGE_X, y, 1); g_pGraphics->drawFont( (unsigned char *) cmsg[i].msg, CONSOLE_MESSAGE_X, y, 1);
y += CONSOLE_MESSAGE_SPACING; y += CONSOLE_MESSAGE_SPACING;
} }
} }

View File

@@ -21,17 +21,7 @@ struct st_resolution
#include <SDL.h> #include <SDL.h>
#include <iostream> #include <iostream>
#include <list> #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> class CVideoDriver : public CSingleton<CVideoDriver>
{ {
@@ -109,8 +99,8 @@ private:
st_resolution m_Resolution; st_resolution m_Resolution;
std::list<st_resolution> m_Resolutionlist; list<st_resolution> m_Resolutionlist;
std::list<st_resolution> :: iterator m_Resolution_pos; list<st_resolution> :: iterator m_Resolution_pos;
unsigned int Mode; unsigned int Mode;
bool Fullscreen; bool Fullscreen;

View File

@@ -12,7 +12,6 @@
#include "../../hqp/CMusic.h" #include "../../hqp/CMusic.h"
#include "../../vorticon/sounds.h" #include "../../vorticon/sounds.h"
#include "../../fileio/CExeFile.h" #include "../../fileio/CExeFile.h"
#include "../../StringUtils.h"
#define SAFE_DELETE_ARRAY(x) if(x) delete[] x; x=NULL #define SAFE_DELETE_ARRAY(x) if(x) delete[] x; x=NULL
@@ -45,7 +44,7 @@ CSound::~CSound() {
bool CSound::init(void) bool CSound::init(void)
{ {
char name[256]; char name[MAX_STRING_LENGTH];
SDL_AudioSpec *desired, *obtained; SDL_AudioSpec *desired, *obtained;
desired = &AudioSpec; desired = &AudioSpec;
@@ -298,14 +297,14 @@ playsound: ;
m_soundchannel[chnl].setupSound((unsigned short)snd, 0, true, WAVE_IN, 0, (mode==PLAY_FORCE) ? true : false ); m_soundchannel[chnl].setupSound((unsigned short)snd, 0, true, WAVE_IN, 0, (mode==PLAY_FORCE) ? true : false );
} }
char CSound::loadSoundData(unsigned short Episode, const std::string& DataDirectory) char CSound::loadSoundData(unsigned short Episode, char *DataDirectory)
{ {
if(!m_active) return false; if(!m_active) return false;
std::string path; char *path;
int ok; int ok;
std::string soundfile; char soundfile[80];
std::string buf; char buf[256];
if(m_soundslot) delete[] m_soundslot; if(m_soundslot) delete[] m_soundslot;
m_soundslot = new CSoundSlot[MAX_SOUNDS]; m_soundslot = new CSoundSlot[MAX_SOUNDS];
@@ -319,16 +318,21 @@ char CSound::loadSoundData(unsigned short Episode, const std::string& DataDirect
g_pLogFile->ftextOut("sound_load_all(): loading all sounds...<br>"); g_pLogFile->ftextOut("sound_load_all(): loading all sounds...<br>");
soundfile = formatPathString(path) + "sounds.ck" + itoa(Episode); char buffer[256];
formatPathString(buffer,path);
sprintf(soundfile, "%ssounds.ck%d", buffer,Episode);
FILE *p_file; FILE *p_file;
if( ( p_file = fopen(soundfile.c_str(),"rb") ) == NULL ) if( ( p_file = fopen(soundfile,"rb") ) == NULL )
{ {
formatPathString(buffer,path);
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()); sprintf(buf,"keen%d.exe",Episode);
extractOfExeFile(formatPathString(path), 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);
} }
else else
fclose(p_file); fclose(p_file);
@@ -372,7 +376,7 @@ char CSound::loadSoundData(unsigned short Episode, const std::string& DataDirect
if (Episode == 2) if (Episode == 2)
{ {
ok |= m_soundslot[33].loadSound(soundfile, "EARTHPOW", SOUND_EARTHPOW); ok |= m_soundslot[SOUND_KEEN_BLOK].loadSound(soundfile, "EARTHPOW", SOUND_EARTHPOW);
} }
else if (Episode == 3) else if (Episode == 3)
{ {
@@ -405,16 +409,18 @@ char CSound::loadSoundData(unsigned short Episode, const std::string& DataDirect
the sound data. the sound data.
*/ */
char CSound::extractOfExeFile(const std::string& inputpath, int episode) char CSound::extractOfExeFile(char *inputpath, int episode)
{ {
std::string outputfname; const char *outputfname;
int bit_count; int bit_count;
int pos, sounds_start, sounds_end, ret = 0; int pos, sounds_start, sounds_end, ret = 0;
std::string buffer; char buffer[MAX_STRING_LENGTH];
std::string inputfname; char inputfname[MAX_STRING_LENGTH];
pos = 0; pos = 0;
bit_count = 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 // Set Offsets. Episode 1 already provides this
if (episode == 2) if (episode == 2)
@@ -431,7 +437,7 @@ char CSound::extractOfExeFile(const std::string& inputpath, int episode)
} }
else else
{ {
g_pLogFile->ftextOut("Error: Unknown keen executable name: %s<br>", inputfname.c_str()); g_pLogFile->ftextOut("Error: Unknown keen executable name: %s<br>", inputfname);
return 1; return 1;
} }
@@ -440,7 +446,7 @@ char CSound::extractOfExeFile(const std::string& inputpath, int episode)
else else
{ {
FILE *fout; FILE *fout;
if(!(fout = fopen(outputfname.c_str(),"wb"))) ret = 1; if(!(fout = fopen(outputfname,"wb"))) ret = 1;
else else
{ {
fwrite( ExeFile->getData()+sounds_start, 1, (sounds_end-sounds_start), fout); fwrite( ExeFile->getData()+sounds_start, 1, (sounds_end-sounds_start), fout);

View File

@@ -11,12 +11,10 @@
#include "../../CSingleton.h" #include "../../CSingleton.h"
#define g_pSound CSound::Get() #define g_pSound CSound::Get()
#include <string>
#include <SDL.h> #include <SDL.h>
#include "CSoundChannel.h" #include "CSoundChannel.h"
#include "CSoundSlot.h" #include "CSoundSlot.h"
class CSound : public CSingleton<CSound> class CSound : public CSingleton<CSound>
{ {
public: public:
@@ -25,11 +23,11 @@ public:
bool init(void); bool init(void);
void stop(void); void stop(void);
char loadSoundData(unsigned short Episode, const std::string& DataDirectory); char loadSoundData(unsigned short Episode, char *DataDirectory);
void stopAllSounds(void); void stopAllSounds(void);
bool forcedisPlaying(void); bool forcedisPlaying(void);
char sound_load_all(const std::string& path); char sound_load_all(const char *path);
void transform_into_logaritmic_sound(int *pcmstream, int len); void transform_into_logaritmic_sound(int *pcmstream, int len);
void callback(void *unused, Uint8 *stream, int len); void callback(void *unused, Uint8 *stream, int len);
void pauseSound(void); void pauseSound(void);
@@ -46,7 +44,7 @@ public:
void setSoundmode(int freq, bool stereo); void setSoundmode(int freq, bool stereo);
char extractOfExeFile(const std::string& inputpath, int episode); // This is a special funktion. It doesn't belong here! char extractOfExeFile(char *inputpath, int episode); // This is a special funktion. It doesn't belong here!
private: private:
CSoundChannel *m_soundchannel; CSoundChannel *m_soundchannel;

View File

@@ -34,7 +34,7 @@ CSoundSlot::~CSoundSlot() {
// loads sound searchname from file fname, into sounds[] entry loadnum // loads sound searchname from file fname, into sounds[] entry loadnum
// return value is nonzero on failure // return value is nonzero on failure
bool CSoundSlot::loadSound(const std::string& fname, const std::string& searchname, unsigned int loadnum) bool CSoundSlot::loadSound(const char *fname, const char *searchname, unsigned int loadnum)
{ {
// Unload the sound if any was previously loaded // Unload the sound if any was previously loaded
if(m_sounddata){ delete[] m_sounddata; m_sounddata = NULL; } if(m_sounddata){ delete[] m_sounddata; m_sounddata = NULL; }
@@ -57,10 +57,10 @@ bool CSoundSlot::loadSound(const std::string& fname, const std::string& searchna
for(i=0;i<12;i++) for(i=0;i<12;i++)
name[i] = 0; name[i] = 0;
fp = fopen(fname.c_str(), "rb"); fp = fopen(fname, "rb");
if (!fp) if (!fp)
{ {
g_pLogFile->ftextOut("loadSound : Sounds file '%s' unopenable attempting load of '%s'<br>", fname.c_str(), searchname.c_str()); g_pLogFile->ftextOut("loadSound : Sounds file '%s' unopenable attempting load of '%s'<br>", fname, searchname);
return false; return false;
} }
@@ -75,12 +75,12 @@ bool CSoundSlot::loadSound(const std::string& fname, const std::string& searchna
priority = fgetc(fp); priority = fgetc(fp);
garbage = fgetc(fp); garbage = fgetc(fp);
for(i=0;i<12;i++) name[i] = fgetc(fp); for(i=0;i<12;i++) name[i] = fgetc(fp);
if (name == searchname) goto sound_found; if (!strcmp(name, searchname)) goto sound_found;
curheader += 0x10; curheader += 0x10;
} }
// sound could not be found // sound could not be found
g_pLogFile->ftextOut("loadSound : sound %s could not be found in %s.<br>", searchname.c_str(), fname.c_str()); g_pLogFile->ftextOut("loadSound : sound %s could not be found in %s.<br>", searchname, fname);
fclose(fp); fclose(fp);
return false; return false;
@@ -115,7 +115,7 @@ bool CSoundSlot::loadSound(const std::string& fname, const std::string& searchna
memcpy(m_sounddata, tempstack, m_soundlength*sizeof(unsigned int)); memcpy(m_sounddata, tempstack, m_soundlength*sizeof(unsigned int));
g_pLogFile->ftextOut("loadSound : loaded sound %s of %d bytes.<br>", searchname.c_str(), m_soundlength); g_pLogFile->ftextOut("loadSound : loaded sound %s of %d bytes.<br>", searchname, m_soundlength);
m_hqsound.enabled = false; m_hqsound.enabled = false;
fclose(fp); fclose(fp);

View File

@@ -15,7 +15,7 @@ public:
CSoundSlot(); CSoundSlot();
virtual ~CSoundSlot(); virtual ~CSoundSlot();
bool loadSound(const std::string& fname, const std::string& searchname, unsigned int loadnum); bool loadSound(const char *fname, const char *searchname, unsigned int loadnum);
void setpAudioSpec(SDL_AudioSpec *pAudioSpec){ m_pAudioSpec = pAudioSpec; } void setpAudioSpec(SDL_AudioSpec *pAudioSpec){ m_pAudioSpec = pAudioSpec; }

View File

@@ -64,11 +64,14 @@ short openOGGSound(FILE *fp, SDL_AudioSpec *pspec, Uint16 format, stHQSound *pso
psound->sound_len = buffer.size(); psound->sound_len = buffer.size();
psound->sound_buffer = new Uint8[psound->sound_len]; //psound->sound_buffer = new Uint8[psound->sound_len];
for(Uint32 i=0; i<psound->sound_len ; i++ ) psound->sound_buffer = (Uint8*) malloc(psound->sound_len);
/*for(Uint32 i=0; i<psound->sound_len ; i++ )
{ {
memcpy( &(psound->sound_buffer[i]), &(buffer[i]), 1); memcpy( &(psound->sound_buffer[i]), &(buffer[i]), 1);
} }*/
memcpy( psound->sound_buffer, buffer.data(), psound->sound_len );
buffer.clear();
return 0; return 0;
} }

View File

@@ -128,7 +128,7 @@ void CCredits::Render(stCloneKeenPlus *pCKP)
for(int j=0 ; j<51 ; j++) for(int j=0 ; j<51 ; j++)
if(scrolly+(j<<3) > -8 && scrolly+(j<<3) < 200) if(scrolly+(j<<3) > -8 && scrolly+(j<<3) < 200)
g_pGraphics->sb_font_draw_inverse( scrolltext[j], mid[j], scrolly+(j<<3)); g_pGraphics->sb_font_draw_inverse( (unsigned char*) scrolltext[j], mid[j], scrolly+(j<<3));
if( g_pInput->getPressedAnyCommand() ) if( g_pInput->getPressedAnyCommand() )
{ {

View File

@@ -77,9 +77,10 @@ void CDialog::addSeparator(void)
addOptionText(""); addOptionText("");
} }
void CDialog::addOptionText(const std::string& text) void CDialog::addOptionText(const char *text)
{ {
std::string buf; char buf[TEXT_LENGTH];
memset(buf,0,TEXT_LENGTH);
// This algorithm is similar to one pointer session and // This algorithm is similar to one pointer session and
// list implementation. TextList is the head. // list implementation. TextList is the head.
if(OptionTextList == NULL) if(OptionTextList == NULL)
@@ -87,21 +88,22 @@ void CDialog::addOptionText(const std::string& text)
OptionTextList = new stTextList; OptionTextList = new stTextList;
OptionTextList->nextElement = NULL; OptionTextList->nextElement = NULL;
OptionTextList->text = ""; memset(OptionTextList->text,0,TEXT_LENGTH);
buf = text; strcpy(buf,text);
size_t length = buf.length(); unsigned int length;
length = strlen(buf);
// before the text is copied, check if that string is too long. // before the text is copied, check if that string is too long.
if(length > w-4) if(length > w-4)
{ {
OptionTextList->text = text.substr(0, w-7); copy(text,text+w-7,OptionTextList->text);
OptionTextList->text += "..."; strcat(OptionTextList->text,"...");
} }
else else
{ {
OptionTextList->text = text; strcpy(OptionTextList->text,text);
} }
number_of_options = 1; number_of_options = 1;
@@ -122,41 +124,41 @@ void CDialog::addOptionText(const std::string& text)
curTextList = (stTextList*) curTextList->nextElement; curTextList = (stTextList*) curTextList->nextElement;
curTextList->text = ""; memset(curTextList->text,0, TEXT_LENGTH);
number_of_options++; number_of_options++;
buf = text; strcpy(buf,text);
size_t length = buf.length(); unsigned int length;
length = strlen(buf);
// before the text is copied, check if that string is too long. // before the text is copied, check if that string is too long.
if(length > w-4) if(length > w-4)
{ {
curTextList->text = text.substr(0, w-7); copy(text,text+w-7,curTextList->text);
curTextList->text += "..."; strcat(curTextList->text,"...");
} }
else else
{ {
curTextList->text = text; strcpy(curTextList->text,text);
} }
curTextList->nextElement = NULL; curTextList->nextElement = NULL;
} }
} }
void CDialog::setOptionText(unsigned int pos, const std::string& text) void CDialog::setOptionText(unsigned int pos, const char *text)
{ {
unsigned int i; unsigned int i;
stTextList *curTextList = OptionTextList; stTextList *curTextList;
for(i=0 ; i<pos ; i++) { curTextList = OptionTextList;
if(!curTextList)
// TODO: print error for(i=0 ; i<pos ; i++)
return; curTextList = (stTextList*) curTextList->nextElement;
curTextList = curTextList->nextElement;
} memset(curTextList->text,0,TEXT_LENGTH);
strcpy(curTextList->text,text);
curTextList->text = text;
} }
void CDialog::setDimensions(int rectx, int recty, int rectw, int recth) void CDialog::setDimensions(int rectx, int recty, int rectw, int recth)
@@ -195,7 +197,7 @@ void CDialog::renderDialog()
while(curTextList != NULL) while(curTextList != NULL)
{ {
g_pGraphics->sb_font_draw(curTextList->text, (x+3)<<3, (y+i+1)<<3); g_pGraphics->sb_font_draw((unsigned char*)(curTextList->text), (x+3)<<3, (y+i+1)<<3);
curTextList = (stTextList*) curTextList->nextElement; curTextList = (stTextList*) curTextList->nextElement;
i++; i++;
if(i >= h-2) if(i >= h-2)
@@ -285,7 +287,7 @@ void CDialog::renderOpenDialogAnimation(int x,int y, int w, int h)
isanimated = false; isanimated = false;
} }
std::string CDialog::getOptionString(unsigned int pos) char *CDialog::getOptionString(unsigned int pos)
{ {
unsigned int i; unsigned int i;
stTextList *curTextList; stTextList *curTextList;
@@ -325,7 +327,7 @@ bool CDialog::setNextSelection()
int i=0; int i=0;
if(selection+1 < number_of_options) if(selection+1 < number_of_options)
{ {
while(getOptionString(selection+i+1) == "") while(strcmp(getOptionString(selection+i+1),"") == 0)
i++; i++;
selection += i; selection += i;
@@ -341,7 +343,7 @@ bool CDialog::setPrevSelection()
int i=0; int i=0;
if(selection-1 > 0) if(selection-1 > 0)
{ {
while(getOptionString(selection-i-1) == "") while(strcmp(getOptionString(selection-i-1),"") == 0)
i++; i++;
selection -= i; selection -= i;

View File

@@ -8,13 +8,13 @@
#ifndef CDIALOG_H_ #ifndef CDIALOG_H_
#define CDIALOG_H_ #define CDIALOG_H_
#include <string> #define TEXT_LENGTH 256
struct stTextList typedef struct stTextList
{ {
std::string text; char text[TEXT_LENGTH];
stTextList *nextElement; void *nextElement;
}; }stTextList;
class CDialog { class CDialog {
public: public:
@@ -25,8 +25,8 @@ public:
void drawDialogbox(int x1, int y1, int w, int h); void drawDialogbox(int x1, int y1, int w, int h);
void setDimensions(int rectx, int recty, int rectw, int recth); void setDimensions(int rectx, int recty, int rectw, int recth);
void addOptionText(const std::string& text); void addOptionText(const char *text);
void setOptionText(unsigned int pos, const std::string& text); void setOptionText(unsigned int pos, const char *text);
void addSeparator(void); void addSeparator(void);
bool setSelection(int value); bool setSelection(int value);
@@ -34,7 +34,7 @@ public:
bool setPrevSelection(); bool setPrevSelection();
int getSelection(void); int getSelection(void);
std::string getOptionString(unsigned int pos); char *getOptionString(unsigned int pos);
void renderOpenDialogAnimation(int x,int y, int w, int h); void renderOpenDialogAnimation(int x,int y, int w, int h);
void animateDialogBox(bool value); void animateDialogBox(bool value);

View File

@@ -12,14 +12,11 @@
#endif #endif
#include <fstream> #include <fstream>
#include <vector> #include <vector>
#include "../StringUtils.h"
using namespace std; using namespace std;
CEGAGraphics::CEGAGraphics(short episode, const std::string& path) { CEGAGraphics::CEGAGraphics(short episode, const char *path) {
m_episode = episode; m_episode = episode;
m_path = path; strcpy(m_path, path);
// EGAHEAD Structure // EGAHEAD Structure
LatchPlaneSize = 0; LatchPlaneSize = 0;
@@ -54,15 +51,15 @@ CEGAGraphics::~CEGAGraphics() {
bool CEGAGraphics::loadData() bool CEGAGraphics::loadData()
{ {
std::string buf; char buf[256];
vector<char> databuf; vector<char> databuf;
chdir("data"); // TODO: You must be able to use another directory chdir("data"); // TODO: You must be able to use another directory
if(m_path == "") if(m_path[0] == 0)
buf = "egahead.ck" + itoa(m_episode); sprintf(buf,"egahead.ck%hd",m_episode);
else else
buf = m_path + "/egahead.ck" + itoa(m_episode); sprintf(buf,"%s/egahead.ck%hd",m_path,m_episode);
std::ifstream HeadFile(buf.c_str(),ios::binary); ifstream HeadFile(buf,ios::binary);
if(!HeadFile) if(!HeadFile)
return false; return false;
@@ -75,8 +72,10 @@ bool CEGAGraphics::loadData()
} }
HeadFile.close(); HeadFile.close();
char *data = new char[databuf.size()]; char *data;
memcpy(data, &databuf[0], databuf.size()); data = new char[databuf.size()];
memcpy(data, databuf.data(), databuf.size());
// Now copy the data to the EGAHEAD Structure // Now copy the data to the EGAHEAD Structure
memcpy(&LatchPlaneSize,data,4); memcpy(&LatchPlaneSize,data,4);
@@ -109,10 +108,10 @@ bool CEGAGraphics::loadData()
m_Latch->loadHead(data); m_Latch->loadHead(data);
if(m_path == "") if(m_path[0] == 0)
buf = "egalatch.ck" + itoa(m_episode); sprintf(buf,"egalatch.ck%hd",m_episode);
else else
buf = m_path + "/egalatch.ck" + itoa(m_episode); sprintf(buf,"%s/egalatch.ck%hd",m_path,m_episode);
m_Latch->loadData(buf,(compressed>>1)); // The second bit tells, if latch is compressed. m_Latch->loadData(buf,(compressed>>1)); // The second bit tells, if latch is compressed.
@@ -122,14 +121,16 @@ bool CEGAGraphics::loadData()
SpriteLocation); SpriteLocation);
m_Sprit->loadHead(data); m_Sprit->loadHead(data);
if(m_path == "") if(m_path[0] == 0)
buf = "egasprit.ck" + itoa(m_episode); sprintf(buf,"egasprit.ck%hd",m_episode);
else else
buf = m_path + "/egasprit.ck" + itoa(m_episode); sprintf(buf,"%s/egasprit.ck%hd",m_path,m_episode);
m_Sprit->loadData(buf,(compressed>>1)); m_Sprit->loadData(buf,(compressed>>1));
chdir("../"); chdir("../");
delete [] data;
return true; return true;
} }

View File

@@ -14,13 +14,12 @@
#ifndef CEGAGRAPHICS_H_ #ifndef CEGAGRAPHICS_H_
#define CEGAGRAPHICS_H_ #define CEGAGRAPHICS_H_
#include <string>
#include "CEGALatch.h" #include "CEGALatch.h"
#include "CEGASprit.h" #include "CEGASprit.h"
class CEGAGraphics { class CEGAGraphics {
public: public:
CEGAGraphics(short episode, const std::string& path); CEGAGraphics(short episode, const char *path);
virtual ~CEGAGraphics(); virtual ~CEGAGraphics();
bool loadData(); bool loadData();
@@ -29,7 +28,7 @@ public:
private: private:
short m_episode; short m_episode;
std::string m_path; char m_path[256];
// Part of the EGAHEAD Data Structure // Part of the EGAHEAD Data Structure
// Section 1: // Section 1:

View File

@@ -65,11 +65,12 @@ bool CEGALatch::loadHead( char *data )
return true; return true;
} }
bool CEGALatch::loadData(const std::string& filename, bool compresseddata) bool CEGALatch::loadData(const char *filename, bool compresseddata)
{ {
FILE* latchfile;
char *RawData; char *RawData;
FILE* latchfile = fopen(filename.c_str(),"rb"); latchfile = fopen(filename,"rb");
if(!latchfile) if(!latchfile)
return false; return false;

View File

@@ -8,8 +8,7 @@
#ifndef CEGALATCH_H_ #ifndef CEGALATCH_H_
#define CEGALATCH_H_ #define CEGALATCH_H_
#include <SDL.h> #include <SDL/SDL.h>
#include <string>
class CEGALatch { class CEGALatch {
public: public:
@@ -26,7 +25,7 @@ public:
virtual ~CEGALatch(); virtual ~CEGALatch();
bool loadHead(char *data ); bool loadHead(char *data );
bool loadData(const std::string& filename, bool compresseddata); bool loadData(const char *filename, bool compresseddata);
char *RawData; char *RawData;

View File

@@ -71,11 +71,12 @@ bool CEGASprit::loadHead(char *data)
return true; return true;
} }
bool CEGASprit::loadData(const std::string& filename, bool compresseddata) bool CEGASprit::loadData(const char *filename, bool compresseddata)
{ {
FILE* latchfile;
char *RawData; char *RawData;
FILE* latchfile = fopen(filename.c_str(),"rb"); latchfile = fopen(filename,"rb");
if(!latchfile) if(!latchfile)
return false; return false;

View File

@@ -8,8 +8,6 @@
#ifndef CEGASPRIT_H_ #ifndef CEGASPRIT_H_
#define CEGASPRIT_H_ #define CEGASPRIT_H_
#include <string>
class CEGASprit { class CEGASprit {
public: public:
CEGASprit(int planesize, CEGASprit(int planesize,
@@ -19,7 +17,7 @@ public:
virtual ~CEGASprit(); virtual ~CEGASprit();
bool loadHead(char *data); bool loadHead(char *data);
bool loadData(const std::string& filename, bool compresseddata); bool loadData(const char *filename, bool compresseddata);
private: private:
int m_numsprites; int m_numsprites;

View File

@@ -9,7 +9,9 @@
#include <fstream> #include <fstream>
#include <string> #include <string>
#include <cstring> using namespace std;
#include <string.h>
#include "../keen.h" #include "../keen.h"
#include "../include/menu.h" #include "../include/menu.h"
@@ -18,14 +20,10 @@
#include "../sdl/CInput.h" #include "../sdl/CInput.h"
#include "../sdl/CTimer.h" #include "../sdl/CTimer.h"
#include "../CGraphics.h" #include "../CGraphics.h"
#include "../StringUtils.h"
#define HIGHSCORETABLE_X 1344 #define HIGHSCORETABLE_X 1344
#define HIGHSCORETABLE_Y 32 #define HIGHSCORETABLE_Y 32
using namespace std;
CHighScores::CHighScores(stCloneKeenPlus *poutsideCKP) { CHighScores::CHighScores(stCloneKeenPlus *poutsideCKP) {
// Set default Scores // Set default Scores
strcpy(Name[0],"Gerstrong"); strcpy(Name[0],"Gerstrong");
@@ -126,8 +124,8 @@ char CHighScores::showHighScore(void)
for( i=0 ; i<7 ; i++ ) for( i=0 ; i<7 ; i++ )
{ {
g_pGraphics->sb_color_font_draw(Name[i],40,64+(i<<4),4,7); g_pGraphics->sb_color_font_draw((unsigned char*) Name[i],40,64+(i<<4),4,7);
g_pGraphics->sb_color_font_draw(Score[i],200-(strlen(Score[i])<<3),64+(i<<4),4,7); g_pGraphics->sb_color_font_draw((unsigned char*) Score[i],200-(strlen(Score[i])<<3),64+(i<<4),4,7);
if(Extra[i][0] == true) if(Extra[i][0] == true)
g_pGraphics->drawTile(32,90+(i<<4),ItemTiles[0]); g_pGraphics->drawTile(32,90+(i<<4),ItemTiles[0]);
if(Extra[i][1] == true) if(Extra[i][1] == true)
@@ -142,19 +140,19 @@ char CHighScores::showHighScore(void)
{ {
for( i=0 ; i<7 ; i++ ) for( i=0 ; i<7 ; i++ )
{ {
std::string buf; char buf[2];
g_pGraphics->sb_color_font_draw(Name[i],40,64+(i<<4),4,7); g_pGraphics->sb_color_font_draw((unsigned char*) Name[i],40,64+(i<<4),4,7);
g_pGraphics->sb_color_font_draw(Score[i],200-(strlen(Score[i])<<3),64+(i<<4),4,7); g_pGraphics->sb_color_font_draw((unsigned char*) Score[i],200-(strlen(Score[i])<<3),64+(i<<4),4,7);
buf = itoa(Cities[i]); sprintf(buf,"%d",Cities[i]);
g_pGraphics->sb_color_font_draw(buf,250,64+(i<<4),4,7); g_pGraphics->sb_color_font_draw((unsigned char*) buf,250,64+(i<<4),4,7);
} }
} }
else else
{ {
for( i=0 ; i<7 ; i++ ) for( i=0 ; i<7 ; i++ )
{ {
g_pGraphics->sb_color_font_draw(Name[i],40,64+(i<<4),4,7); g_pGraphics->sb_color_font_draw((unsigned char*) Name[i],40,64+(i<<4),4,7);
g_pGraphics->sb_color_font_draw(Score[i],200-(strlen(Score[i])<<3),64+(i<<4),4,7); g_pGraphics->sb_color_font_draw((unsigned char*) Score[i],200-(strlen(Score[i])<<3),64+(i<<4),4,7);
} }
} }
@@ -247,19 +245,19 @@ char CHighScores::writeHighScore(int points, bool *extras, int cities)
{ {
for( i=0 ; i<7 ; i++ ) for( i=0 ; i<7 ; i++ )
{ {
std::string buf; char buf[2];
g_pGraphics->sb_color_font_draw(Name[i],40,64+(i<<4),4,7); g_pGraphics->sb_color_font_draw((unsigned char*) Name[i],40,64+(i<<4),4,7);
g_pGraphics->sb_color_font_draw(Score[i],200-(strlen(Score[i])<<3),64+(i<<4),4,7); g_pGraphics->sb_color_font_draw((unsigned char*) Score[i],200-(strlen(Score[i])<<3),64+(i<<4),4,7);
buf = itoa(Cities[i]); sprintf(buf,"%d",Cities[i]);
g_pGraphics->sb_color_font_draw(buf,250,64+(i<<4),4,7); g_pGraphics->sb_color_font_draw((unsigned char*) buf,250,64+(i<<4),4,7);
} }
} }
else else
{ {
for( i=0 ; i<7 ; i++ ) for( i=0 ; i<7 ; i++ )
{ {
g_pGraphics->sb_color_font_draw(Name[i],40,64+(i<<4),4,7); g_pGraphics->sb_color_font_draw((unsigned char*) Name[i],40,64+(i<<4),4,7);
g_pGraphics->sb_color_font_draw(Score[i],200-(strlen(Score[i])<<3),64+(i<<4),4,7); g_pGraphics->sb_color_font_draw((unsigned char*) Score[i],200-(strlen(Score[i])<<3),64+(i<<4),4,7);
} }
} }
@@ -313,7 +311,7 @@ char CHighScores::writeHighScore(int points, bool *extras, int cities)
if(g_pInput->getPressedKey(KBCKSPCE) && (WrittenName.length() > 0)) if(g_pInput->getPressedKey(KBCKSPCE) && (WrittenName.length() > 0))
{ {
memset(buf,0,256); memset(buf,0,256);
g_pGraphics->sb_color_font_draw(" ",40,64+(place<<4),4,7); g_pGraphics->sb_color_font_draw((unsigned char*) " ",40,64+(place<<4),4,7);
WrittenName.erase(WrittenName.length()-1); WrittenName.erase(WrittenName.length()-1);
WrittenName.copy(buf,WrittenName.length(),0); WrittenName.copy(buf,WrittenName.length(),0);
memset(Name[place],0,16); memset(Name[place],0,16);
@@ -331,10 +329,10 @@ char CHighScores::writeHighScore(int points, bool *extras, int cities)
for( i=0 ; i<7 ; i++ ) for( i=0 ; i<7 ; i++ )
{ {
if(i != place) if(i != place)
g_pGraphics->sb_color_font_draw(Name[i],40,64+(i<<4),4,7); g_pGraphics->sb_color_font_draw((unsigned char*) Name[i],40,64+(i<<4),4,7);
else else
g_pGraphics->sb_color_font_draw(buf,40,64+(i<<4),4,7); g_pGraphics->sb_color_font_draw((unsigned char*) buf,40,64+(i<<4),4,7);
g_pGraphics->sb_color_font_draw(Score[i],200-(strlen(Score[i])<<3),64+(i<<4),4,7); g_pGraphics->sb_color_font_draw((unsigned char*) Score[i],200-(strlen(Score[i])<<3),64+(i<<4),4,7);
if(pCKP->Control.levelcontrol.episode == 1) if(pCKP->Control.levelcontrol.episode == 1)
{ {
@@ -366,7 +364,9 @@ char CHighScores::writeHighScore(int points, bool *extras, int cities)
char CHighScores::loadHighScoreTable(void) char CHighScores::loadHighScoreTable(void)
{ {
string sBuf; string sBuf;
std::string chBuf = itoa(Episode); char chBuf[256];
sprintf(chBuf,"%d",Episode);
sBuf.append("data/"); sBuf.append("data/");
sBuf.append(DataDirectory); sBuf.append(DataDirectory);

View File

@@ -8,8 +8,6 @@
#ifndef CHIGHSCORES_H_ #ifndef CHIGHSCORES_H_
#define CHIGHSCORES_H_ #define CHIGHSCORES_H_
#include <string>
class CHighScores { class CHighScores {
public: public:
CHighScores(stCloneKeenPlus *poutsideCKP); CHighScores(stCloneKeenPlus *poutsideCKP);
@@ -27,7 +25,7 @@ private:
int ItemTiles[4]; int ItemTiles[4];
char Episode; char Episode;
std::string DataDirectory; char *DataDirectory;
stCloneKeenPlus *pCKP; stCloneKeenPlus *pCKP;

View File

@@ -55,7 +55,7 @@ bool CMessages::readData(char *buf, int episode, int version)
// Now read the stuff and store it to a list // Now read the stuff and store it to a list
for(int pos=offset_start ; pos<offset_end ; pos++) for(int pos=offset_start ; pos<offset_end ; pos++)
{ {
std::string Text; string Text;
while(buf[pos] != 0) while(buf[pos] != 0)
{ {
@@ -68,7 +68,7 @@ bool CMessages::readData(char *buf, int episode, int version)
StringList.push_back(Text); StringList.push_back(Text);
} }
std::list<std::string> :: iterator i; list<string> :: iterator i;
#include <iostream> #include <iostream>
for(i=StringList.begin() ; i!=StringList.end() ; i++) for(i=StringList.begin() ; i!=StringList.end() ; i++)

View File

@@ -12,6 +12,8 @@
#include <string> #include <string>
#include <iostream> #include <iostream>
using namespace std;
// TODO: Make the strings a class, but it must read from the exe-files basing on uncompressed buffer // TODO: Make the strings a class, but it must read from the exe-files basing on uncompressed buffer
class CMessages { class CMessages {
@@ -23,8 +25,8 @@ public:
char *getString(const char *IDtext); char *getString(const char *IDtext);
private: private:
std::list<std::string> StringList; list<string> StringList;
std::list<std::string> StringIDList; list<string> StringIDList;
}; };
#endif /* CMESSAGES_H_ */ #endif /* CMESSAGES_H_ */