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:
@@ -27,6 +27,7 @@
|
||||
|
||||
CGame::CGame() {
|
||||
m_Episode = 0;
|
||||
memset(m_DataDirectory,0,256);
|
||||
|
||||
TileLoader = NULL;
|
||||
EGAGraphics = NULL;
|
||||
@@ -217,13 +218,15 @@ short CGame::runCycle(stCloneKeenPlus *pCKP)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CGame::loadResources(unsigned short Episode, const std::string& DataDirectory)
|
||||
int CGame::loadResources(unsigned short Episode, char *DataDirectory)
|
||||
{
|
||||
m_Episode = Episode;
|
||||
m_DataDirectory = DataDirectory;
|
||||
memcpy(m_DataDirectory, DataDirectory, 256);
|
||||
|
||||
if( m_DataDirectory.size() > 0 && m_DataDirectory[m_DataDirectory.size()-1] != '/' )
|
||||
m_DataDirectory += "/";
|
||||
int pos = strlen(DataDirectory)-1;
|
||||
if(pos == -1) pos =0;
|
||||
if( ( *(DataDirectory+pos) != '/' ) && strlen(DataDirectory) > 0)
|
||||
strcat(DataDirectory,"/");
|
||||
|
||||
// Decode the entire graphics for the game (EGALATCH, EGASPRIT)
|
||||
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 = new stGameData[1];
|
||||
|
||||
memset(pCKP->GameData, 0, sizeof(stGameData));
|
||||
|
||||
framebyframe = 0;
|
||||
|
||||
demomode = DEMO_NODEMO;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#ifndef CGAME_H_
|
||||
#define CGAME_H_
|
||||
|
||||
#include <string>
|
||||
#include <string.h>
|
||||
#include "vorticon/CEGAGraphics.h"
|
||||
#include "vorticon/CMessages.h"
|
||||
|
||||
@@ -17,14 +17,15 @@ public:
|
||||
CGame();
|
||||
virtual ~CGame();
|
||||
|
||||
int loadResources(unsigned short Episode, const std::string& DataDirectory);
|
||||
int loadResources(unsigned short Episode, char *DataDirectory);
|
||||
void freeResources(void);
|
||||
short runCycle(stCloneKeenPlus *pCKP);
|
||||
void preallocateCKP(stCloneKeenPlus *pCKP);
|
||||
|
||||
private:
|
||||
static const unsigned short MAX_TEXT_LENGTH = 256;
|
||||
unsigned short m_Episode;
|
||||
std::string m_DataDirectory;
|
||||
char m_DataDirectory[MAX_TEXT_LENGTH];
|
||||
int current_demo;
|
||||
|
||||
CEGAGraphics *EGAGraphics;
|
||||
|
||||
@@ -10,14 +10,12 @@
|
||||
* not platform-specific).
|
||||
*/
|
||||
|
||||
#include "keen.h"
|
||||
#include "keenext.h"
|
||||
#include "CGraphics.h"
|
||||
#include "keen.h"
|
||||
#include "sdl/CVideoDriver.h"
|
||||
#include "sdl/video/colourtable.h"
|
||||
#include "sdl/CVideoDriver.h"
|
||||
#include "CLogFile.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
CGraphics::CGraphics() {
|
||||
HQBitmap = NULL;
|
||||
@@ -593,13 +591,13 @@ int c;
|
||||
}
|
||||
|
||||
// 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;
|
||||
int c;
|
||||
|
||||
y = yoff;
|
||||
for(i=0;i<text.size();i++)
|
||||
for(i=0;i<strlen( (char*) text);i++)
|
||||
{
|
||||
c = text[i];
|
||||
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;
|
||||
|
||||
x=xoff;
|
||||
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)
|
||||
{
|
||||
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;
|
||||
|
||||
x=xoff;
|
||||
y=yoff;
|
||||
for(i=0;i<text.size();i++)
|
||||
for(i=0;i<strlen( (char*) text);i++)
|
||||
{
|
||||
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;
|
||||
|
||||
x=xoff;
|
||||
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)
|
||||
{
|
||||
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;
|
||||
|
||||
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)
|
||||
{
|
||||
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;
|
||||
|
||||
std::string buf = formatPathString(datadir);
|
||||
std::string buf2 = buf + "level" + itoa(level) + "ep" + itoa(episode) + ".bmp";
|
||||
memset(buf,0,256);
|
||||
memset(buf2,0,256);
|
||||
|
||||
formatPathString(buf,datadir);
|
||||
|
||||
sprintf(buf2,"%slevel%dep%d.bmp",buf,level,episode);
|
||||
|
||||
screen_rect.x = 0;
|
||||
screen_rect.y = 0;
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#include "CSingleton.h"
|
||||
#define g_pGraphics CGraphics::Get()
|
||||
|
||||
#include <string>
|
||||
#include <SDL.h>
|
||||
#include "hqp/CHQBitmap.h"
|
||||
|
||||
@@ -45,18 +44,18 @@ public:
|
||||
void drawBitmap2FG(int xa, int ya, int b);
|
||||
int getBitmapNumberFromName(const char *bmname);
|
||||
void sb_drawCharacterinverse(int x, int y, int f);
|
||||
void drawFont(const std::string& text, int xoff, int yoff, int highlight);
|
||||
void sb_font_draw(const std::string& text, int xoff, int yoff);
|
||||
void sb_mask_font_draw(const std::string& 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_font_draw_inverse(const std::string& text, int xoff, int yoff);
|
||||
void drawFont(unsigned char *text, int xoff, int yoff, int highlight);
|
||||
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_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 drawTile_direct(int x, int y, unsigned int t);
|
||||
void setFadeBlack(bool value);
|
||||
|
||||
Uint8 *getScrollbuffer(void);
|
||||
|
||||
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();
|
||||
|
||||
private:
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include "fileio.h"
|
||||
#include "keen.h"
|
||||
#include "keenext.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
#include "CLogFile.h"
|
||||
//#include "vorticon/CEGAGraphics.h"
|
||||
@@ -59,15 +58,19 @@ char CLatch::loadHeader(int episode, const char *path)
|
||||
FILE *headfile;
|
||||
unsigned long SpriteTableRAMSize;
|
||||
unsigned long BitmapTableRAMSize;
|
||||
std::string buf;
|
||||
char buf[12];
|
||||
int i,j,k;
|
||||
std::string fname;
|
||||
std::string buffer;
|
||||
char fname[80];
|
||||
char buffer[256];
|
||||
|
||||
buffer = formatPathString(path);
|
||||
buffer += "egahead.ck";
|
||||
memset(buffer,0,256);
|
||||
memset(fname,0,80);
|
||||
|
||||
fname = buffer + itoa(episode);
|
||||
formatPathString(buffer,path);
|
||||
|
||||
strcat(buffer,"egahead.ck");
|
||||
|
||||
sprintf(fname, "%s%d", buffer,episode);
|
||||
|
||||
/*CEGAGraphics *EGAGraphics;
|
||||
|
||||
@@ -77,14 +80,14 @@ char CLatch::loadHeader(int episode, const char *path)
|
||||
|
||||
delete EGAGraphics;*/
|
||||
|
||||
headfile = fopen(fname.c_str(), "rb");
|
||||
headfile = fopen(fname, "rb");
|
||||
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;
|
||||
}
|
||||
|
||||
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
|
||||
LatchHeader.LatchPlaneSize = fgetl(headfile);
|
||||
@@ -132,7 +135,7 @@ char CLatch::loadHeader(int episode, const char *path)
|
||||
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);
|
||||
for(i=0;i<LatchHeader.NumSprites;i++)
|
||||
@@ -169,7 +172,7 @@ char CLatch::loadHeader(int episode, const char *path)
|
||||
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);
|
||||
|
||||
@@ -188,7 +191,7 @@ char CLatch::loadHeader(int episode, const char *path)
|
||||
// print the bitmap info to the console for debug
|
||||
for(j=0;j<8;j++) buf[j] = BitmapTable[i].Name[j];
|
||||
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++;
|
||||
|
||||
@@ -203,24 +206,26 @@ char CLatch::load(int episode, const char *path)
|
||||
{
|
||||
FILE *latchfile;
|
||||
unsigned long plane1, plane2, plane3, plane4;
|
||||
std::string fname;
|
||||
char fname[80];
|
||||
int x,y,t,b,c,p;
|
||||
char *bmdataptr;
|
||||
unsigned long RawDataSize;
|
||||
//unsigned char ch;
|
||||
|
||||
std::string buffer;
|
||||
char buffer[256];
|
||||
|
||||
buffer = formatPathString(path);
|
||||
buffer += "egalatch.ck";
|
||||
fname = buffer + itoa(episode);
|
||||
formatPathString(buffer,path);
|
||||
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -261,7 +266,7 @@ unsigned long RawDataSize;
|
||||
plane4 = (LatchHeader.LatchPlaneSize * 3);
|
||||
|
||||
// ** 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
|
||||
|
||||
@@ -304,7 +309,7 @@ unsigned long RawDataSize;
|
||||
delete Planes;
|
||||
|
||||
// ** 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
|
||||
Planes = new CPlanes(plane1 + LatchHeader.Off16Tiles, \
|
||||
@@ -349,7 +354,7 @@ unsigned long RawDataSize;
|
||||
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
|
||||
Planes = new CPlanes(plane1 + LatchHeader.OffBitmaps, \
|
||||
@@ -414,22 +419,24 @@ char CLatch::loadSprites(int episode, const char *path)
|
||||
{
|
||||
FILE *spritfile;
|
||||
unsigned long plane1, plane2, plane3, plane4, plane5;
|
||||
std::string fname;
|
||||
char fname[80];
|
||||
int x,y,s,c,p;
|
||||
unsigned long RawDataSize;
|
||||
std::string buffer;
|
||||
char buffer[256];
|
||||
CPlanes *Planes;
|
||||
|
||||
buffer = formatPathString(path);
|
||||
buffer += "egasprit.ck";
|
||||
fname = buffer + itoa(episode);
|
||||
formatPathString(buffer,path);
|
||||
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -468,7 +475,7 @@ CPlanes *Planes;
|
||||
plane5 = (LatchHeader.SpritePlaneSize * 4);
|
||||
|
||||
// ** 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
|
||||
Planes = new CPlanes(plane1 + LatchHeader.OffSprites, \
|
||||
|
||||
885
src/eseq_ep1.cpp
885
src/eseq_ep1.cpp
@@ -1,443 +1,442 @@
|
||||
/* ESEQ_EP1.C
|
||||
Ending sequence for Episode 1.
|
||||
*/
|
||||
|
||||
#include "keen.h"
|
||||
#include "include/game.h"
|
||||
#include "include/gamedo.h"
|
||||
#include "include/gamepdo.h"
|
||||
#include "sdl/CInput.h"
|
||||
#include "sdl/CTimer.h"
|
||||
#include "include/eseq_ep1.h"
|
||||
#include "include/eseq_ep2.h"
|
||||
#include "include/menu.h"
|
||||
#include "CGraphics.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
#define CMD_MOVE 0
|
||||
#define CMD_WAIT 1
|
||||
#define CMD_SPAWNSPR 2
|
||||
#define CMD_REMOVESPR 3
|
||||
#define CMD_FADEOUT 4
|
||||
#define CMD_ENDOFQUEUE 5
|
||||
#define CMD_ENABLESCROLLING 6
|
||||
#define CMD_DISABLESCROLLING 7
|
||||
|
||||
|
||||
// start x,y map scroll position for eseq1_ShipFlys()
|
||||
#define SHIPFLY_X 32
|
||||
#define SHIPFLY_Y 0
|
||||
|
||||
// worldmap scroll position for eseq1_ReturnsToShip()
|
||||
#define WM_X 40
|
||||
#define WM_Y 540
|
||||
|
||||
#define LETTER_SHOW_SPD 30
|
||||
#define RETURNTOSHIP_WAIT_TIME 600
|
||||
|
||||
#define SPR_SHIP_RIGHT 115
|
||||
#define SPR_SHIP_LEFT 116
|
||||
#define SPR_EXCLAMATION 117
|
||||
#define SPR_QUESTION 118
|
||||
#define SHIPSPD 4
|
||||
|
||||
#define BACKHOME_SHORT_WAIT_TIME 250
|
||||
|
||||
int eseq1_ReturnsToShip(stCloneKeenPlus *pCKP)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i=0;i<MAX_LEVELS;i++)
|
||||
pCKP->Control.levelcontrol.levels_completed[i] = 0;
|
||||
|
||||
showmapatpos(80, WM_X, WM_Y, 0, pCKP);
|
||||
|
||||
// draw keen next to his ship
|
||||
g_pGraphics->drawSprite(168, 85, PMAPLEFTFRAME, 0);
|
||||
// do not show player when we render the screen
|
||||
numplayers = 1;
|
||||
player[0].x = 0;
|
||||
player[0].y = 0;
|
||||
player[0].playframe = BlankSprite;
|
||||
// all objects -> nonexistant
|
||||
for(i=0;i<MAX_OBJECTS;i++) objects[i].exists = 0;
|
||||
|
||||
fade.mode = FADE_GO;
|
||||
fade.dir = FADE_IN;
|
||||
fade.curamt = 0;
|
||||
fade.fadetimer = 0;
|
||||
fade.rate = FADE_NORM;
|
||||
|
||||
eseq_showmsg(getstring("EP1_ESEQ_PART1"),1,18,37,6,1, pCKP);
|
||||
|
||||
// fade out
|
||||
fade.mode = FADE_GO;
|
||||
fade.dir = FADE_OUT;
|
||||
fade.curamt = PAL_FADE_SHADES;
|
||||
fade.fadetimer = 0;
|
||||
fade.rate = FADE_NORM;
|
||||
do
|
||||
{
|
||||
gamedo_fades();
|
||||
gamedo_AnimatedTiles();
|
||||
|
||||
g_pInput->pollEvents();
|
||||
g_pTimer->SpeedThrottle();
|
||||
} while(fade.mode != FADE_COMPLETE && !g_pInput->getPressedKey(KQUIT));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void addshipqueue(int cmd, int time, int flag1)
|
||||
{
|
||||
shipqueue[ShipQueuePtr].cmd = cmd;
|
||||
shipqueue[ShipQueuePtr].time = time;
|
||||
shipqueue[ShipQueuePtr].flag1 = flag1;
|
||||
ShipQueuePtr++;
|
||||
}
|
||||
|
||||
int eseq1_ShipFlys(stCloneKeenPlus *pCKP)
|
||||
{
|
||||
char enter,lastenterstate;
|
||||
int x, y;
|
||||
int scrollingon;
|
||||
|
||||
scrollingon = 1;
|
||||
|
||||
#define MARK_SPR_NUM 5
|
||||
initgame(pCKP);
|
||||
|
||||
// set up the ship's route
|
||||
ShipQueuePtr = 0;
|
||||
addshipqueue(CMD_MOVE, 230, DUP);
|
||||
addshipqueue(CMD_WAIT, 50, 0);
|
||||
addshipqueue(CMD_MOVE, 2690, DDOWNRIGHT);
|
||||
addshipqueue(CMD_WAIT, 100, 0);
|
||||
addshipqueue(CMD_MOVE, 480, DDOWN);
|
||||
addshipqueue(CMD_WAIT, 150, 0);
|
||||
addshipqueue(CMD_SPAWNSPR, 0, SPR_QUESTION);
|
||||
addshipqueue(CMD_DISABLESCROLLING, 0, 0);
|
||||
addshipqueue(CMD_WAIT, 350, 0);
|
||||
addshipqueue(CMD_REMOVESPR, 0, 0);
|
||||
addshipqueue(CMD_WAIT, 50, 0);
|
||||
addshipqueue(CMD_MOVE, 700, DLEFT);
|
||||
addshipqueue(CMD_WAIT, 150, 0);
|
||||
addshipqueue(CMD_SPAWNSPR, 0, SPR_EXCLAMATION);
|
||||
addshipqueue(CMD_WAIT, 500, 0);
|
||||
addshipqueue(CMD_REMOVESPR, 0, 0);
|
||||
addshipqueue(CMD_WAIT, 50, 0);
|
||||
addshipqueue(CMD_MOVE, 700, DRIGHT);
|
||||
addshipqueue(CMD_WAIT, 25, 0);
|
||||
addshipqueue(CMD_ENABLESCROLLING, 0, 0);
|
||||
addshipqueue(CMD_MOVE, 465, DDOWN);
|
||||
addshipqueue(CMD_FADEOUT, 0, 0);
|
||||
addshipqueue(CMD_MOVE, 100, DDOWN);
|
||||
addshipqueue(CMD_ENDOFQUEUE, 0, 0);
|
||||
|
||||
showmapatpos(81, SHIPFLY_X, SHIPFLY_Y, 0, pCKP);
|
||||
|
||||
objects[MARK_SPR_NUM].type = OBJ_YORP; // doesn't matter
|
||||
objects[MARK_SPR_NUM].exists = 0;
|
||||
objects[MARK_SPR_NUM].sprite = SPR_QUESTION;
|
||||
|
||||
numplayers = 1;
|
||||
// place the player at the center of mars
|
||||
if (map_findtile(593, &x, &y))
|
||||
{ // found the tile at the center of mars
|
||||
player[0].x = ((x<<4)+1)<<CSF;
|
||||
player[0].y = ((y<<4)-3)<<CSF;
|
||||
}
|
||||
else
|
||||
{
|
||||
crashflag = 1;
|
||||
why_term_ptr = "eseq1_shipflys(): unable to find center of Mars.";
|
||||
return 1;
|
||||
}
|
||||
|
||||
player[0].playframe = SPR_SHIP_RIGHT;
|
||||
// player[0].pbgprioritycorners = 0;
|
||||
|
||||
fade.mode = FADE_GO;
|
||||
fade.dir = FADE_IN;
|
||||
fade.curamt = 0;
|
||||
fade.fadetimer = 0;
|
||||
fade.rate = FADE_NORM;
|
||||
ShipQueuePtr = 0;
|
||||
max_scroll_x = max_scroll_y = 20000;
|
||||
do
|
||||
{
|
||||
// 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].y = player[0].y - (10<<CSF);
|
||||
objects[MARK_SPR_NUM].onscreen = 1;
|
||||
// objects[MARK_SPR_NUM].priorityptsfound = 0;
|
||||
// objects[MARK_SPR_NUM].priorityptschecked = 4;
|
||||
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;
|
||||
|
||||
// execute the current command in the queue
|
||||
if (fade.dir != FADE_OUT)
|
||||
{
|
||||
switch(shipqueue[ShipQueuePtr].cmd)
|
||||
{
|
||||
case CMD_MOVE:
|
||||
switch(shipqueue[ShipQueuePtr].flag1)
|
||||
{
|
||||
case DUP:
|
||||
player[0].y-=SHIPSPD;
|
||||
player[0].playframe = SPR_SHIP_RIGHT;
|
||||
break;
|
||||
case DDOWN:
|
||||
player[0].y+=SHIPSPD/2;
|
||||
player[0].playframe = SPR_SHIP_RIGHT;
|
||||
break;
|
||||
case DLEFT:
|
||||
player[0].x-=SHIPSPD;
|
||||
player[0].playframe = SPR_SHIP_LEFT;
|
||||
break;
|
||||
case DRIGHT:
|
||||
player[0].x+=SHIPSPD;
|
||||
player[0].playframe = SPR_SHIP_RIGHT;
|
||||
break;
|
||||
case DDOWNRIGHT:
|
||||
player[0].x+=SHIPSPD*2;
|
||||
player[0].y+=SHIPSPD*0.8;
|
||||
player[0].playframe = SPR_SHIP_RIGHT;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case CMD_SPAWNSPR:
|
||||
objects[MARK_SPR_NUM].sprite = shipqueue[ShipQueuePtr].flag1;
|
||||
objects[MARK_SPR_NUM].exists = 1;
|
||||
break;
|
||||
case CMD_REMOVESPR:
|
||||
objects[MARK_SPR_NUM].sprite = shipqueue[ShipQueuePtr].flag1;
|
||||
objects[MARK_SPR_NUM].exists = 0;
|
||||
break;
|
||||
case CMD_ENABLESCROLLING:
|
||||
scrollingon = 1;
|
||||
break;
|
||||
case CMD_DISABLESCROLLING:
|
||||
scrollingon = 0;
|
||||
break;
|
||||
case CMD_WAIT:
|
||||
break;
|
||||
case CMD_FADEOUT:
|
||||
if (fade.dir!=FADE_OUT)
|
||||
{
|
||||
fade.dir = FADE_OUT;
|
||||
fade.curamt = PAL_FADE_SHADES;
|
||||
fade.fadetimer = 0;
|
||||
fade.mode = FADE_GO;
|
||||
fade.rate = FADE_NORM;
|
||||
}
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
// decrease the time remaining
|
||||
if (shipqueue[ShipQueuePtr].time)
|
||||
{
|
||||
shipqueue[ShipQueuePtr].time--;
|
||||
}
|
||||
else
|
||||
{ // no time left on this command, go to next cmd
|
||||
ShipQueuePtr++;
|
||||
}
|
||||
}
|
||||
|
||||
if (fade.dir==FADE_OUT && fade.mode==FADE_COMPLETE)
|
||||
{ // we're done
|
||||
return 0;
|
||||
}
|
||||
|
||||
enter = ( g_pInput->getPressedKey(KENTER) || g_pInput->getPressedKey(KCTRL) || g_pInput->getPressedKey(KALT) );
|
||||
if (enter)
|
||||
{
|
||||
if (fade.dir!=FADE_OUT)
|
||||
{
|
||||
fade.dir = FADE_OUT;
|
||||
fade.curamt = PAL_FADE_SHADES;
|
||||
fade.fadetimer = 0;
|
||||
fade.mode = FADE_GO;
|
||||
fade.rate = FADE_NORM;
|
||||
}
|
||||
}
|
||||
lastenterstate = enter;
|
||||
|
||||
gamedo_fades();
|
||||
gamedo_AnimatedTiles();
|
||||
|
||||
gamedo_frameskipping(pCKP);
|
||||
if (scrollingon) gamedo_ScrollTriggers(0);
|
||||
|
||||
g_pInput->pollEvents();
|
||||
g_pTimer->SpeedThrottle();
|
||||
} while(!g_pInput->getPressedKey(KQUIT));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int eseq1_BackAtHome(stCloneKeenPlus *pCKP)
|
||||
{
|
||||
/*int draw;*/
|
||||
int i;
|
||||
std::string text[10];
|
||||
std::string strname;
|
||||
std::string tempbuf;
|
||||
short textline, showtimer;
|
||||
unsigned short amountshown;
|
||||
signed int waittimer;
|
||||
int state;
|
||||
int enter, lastenterstate;
|
||||
int dlgX, dlgY, dlgW, dlgH;
|
||||
|
||||
#define STATE_TEXTAPPEARING 0
|
||||
#define STATE_WAITASEC 1
|
||||
#define STATE_FADING 2
|
||||
|
||||
// get pointers to all the strings we're going to be using
|
||||
for(i=0;i<8;i++)
|
||||
{
|
||||
strname = "EP1_ESEQ_PART2_PAGE" + itoa(i+1);
|
||||
text[i] = getstring(strname);
|
||||
}
|
||||
|
||||
textline = 0;
|
||||
amountshown = 0;
|
||||
showtimer = 0;
|
||||
state = STATE_TEXTAPPEARING;
|
||||
lastenterstate = 1;
|
||||
waittimer = 0;
|
||||
|
||||
finale_draw("finale.ck1", pCKP->GameData[pCKP->Resources.GameSelected-1].DataDirectory);
|
||||
scrollx_buf = scroll_x = 0;
|
||||
scrolly_buf = scroll_y = 0;
|
||||
|
||||
numplayers = 1;
|
||||
player[0].x = 16;
|
||||
player[0].y = 16;
|
||||
player[0].playframe = BlankSprite;
|
||||
|
||||
dlgX = GetStringAttribute("EP1_ESEQ_PART2_PAGE1", "LEFT");
|
||||
dlgY = GetStringAttribute("EP1_ESEQ_PART2_PAGE1", "TOP");
|
||||
dlgW = GetStringAttribute("EP1_ESEQ_PART2_PAGE1", "WIDTH");
|
||||
dlgH = GetStringAttribute("EP1_ESEQ_PART2_PAGE1", "HEIGHT");
|
||||
|
||||
fade.mode = FADE_GO;
|
||||
fade.rate = FADE_NORM;
|
||||
fade.dir = FADE_IN;
|
||||
fade.curamt = 0;
|
||||
fade.fadetimer = 0;
|
||||
do
|
||||
{
|
||||
enter = ( g_pInput->getPressedKey(KENTER) || g_pInput->getPressedKey(KCTRL) || g_pInput->getPressedKey(KALT) );
|
||||
|
||||
sb_dialogbox(dlgX, dlgY, dlgW, dlgH);
|
||||
|
||||
// draw the current text line up to the amount currently shown
|
||||
tempbuf = text[textline];
|
||||
tempbuf.erase(amountshown);
|
||||
g_pGraphics->sb_font_draw( tempbuf, (dlgX+1)*8, (dlgY+1)*8);
|
||||
|
||||
if (state==STATE_TEXTAPPEARING)
|
||||
{
|
||||
if (enter) goto fullshow;
|
||||
if (showtimer > LETTER_SHOW_SPD)
|
||||
{ // it's time to show a new letter
|
||||
amountshown++;
|
||||
if (amountshown > text[textline].size())
|
||||
{ // reached end of line
|
||||
state = STATE_WAITASEC;
|
||||
// if (textline==8)
|
||||
// waittimer = -BACKHOME_SHORT_WAIT_TIME*3;
|
||||
// else
|
||||
waittimer = -BACKHOME_SHORT_WAIT_TIME*2;
|
||||
}
|
||||
// if the last letter shown is a dash/cr ('Billy...are you a-'),
|
||||
// show the rest of the text immediately
|
||||
// (for when the mom shouts "WHAT IS THIS ONE-EYED GREEN THING..."
|
||||
if (text[textline][amountshown]==13 && \
|
||||
text[textline][amountshown-1]=='-')
|
||||
{
|
||||
fullshow: ;
|
||||
amountshown = text[textline].size();
|
||||
state = STATE_WAITASEC;
|
||||
waittimer = -BACKHOME_SHORT_WAIT_TIME*3;
|
||||
}
|
||||
showtimer = 0;
|
||||
} else showtimer++;
|
||||
|
||||
// user pressed enter
|
||||
if (enter)
|
||||
{ // show all text immediately
|
||||
|
||||
}
|
||||
}
|
||||
else if (state==STATE_WAITASEC)
|
||||
{
|
||||
if (enter) goto nextline;
|
||||
if (waittimer<BACKHOME_SHORT_WAIT_TIME)
|
||||
{
|
||||
waittimer++;
|
||||
if (waittimer==BACKHOME_SHORT_WAIT_TIME)
|
||||
{
|
||||
nextline: ;
|
||||
textline++;
|
||||
state = STATE_TEXTAPPEARING;
|
||||
amountshown = 0;
|
||||
if (textline>7)
|
||||
{ // end of text
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (fade.dir==FADE_OUT && fade.mode==FADE_COMPLETE)
|
||||
return 0;
|
||||
|
||||
gamedo_fades();
|
||||
gamedo_frameskipping_blitonly();
|
||||
|
||||
lastenterstate = enter;
|
||||
|
||||
g_pInput->pollEvents();
|
||||
g_pTimer->SpeedThrottle();
|
||||
if (g_pInput->getPressedKey(KQUIT)) return 1;
|
||||
} while(1);
|
||||
|
||||
finale_draw("finale.ck1", pCKP->GameData[pCKP->Resources.GameSelected-1].DataDirectory);
|
||||
eseq_ToBeContinued(pCKP);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void eseq_ToBeContinued(stCloneKeenPlus *pCKP)
|
||||
{
|
||||
int i;
|
||||
std::string text;
|
||||
int dlgX, dlgY, dlgW, dlgH;
|
||||
|
||||
// remove all objects because eseq_showmsg will call drawobjects
|
||||
for(i=0;i<MAX_OBJECTS;i++)
|
||||
objects[i].exists = 0;
|
||||
|
||||
text = getstring("TO_BE_CONTINUED");
|
||||
dlgX = GetStringAttribute("TO_BE_CONTINUED", "LEFT");
|
||||
dlgY = GetStringAttribute("TO_BE_CONTINUED", "TOP");
|
||||
dlgW = GetStringAttribute("TO_BE_CONTINUED", "WIDTH");
|
||||
dlgH = GetStringAttribute("TO_BE_CONTINUED", "HEIGHT");
|
||||
eseq_showmsg(text, dlgX, dlgY, dlgW, dlgH, 0, pCKP);
|
||||
|
||||
fade.dir = FADE_OUT;
|
||||
fade.curamt = PAL_FADE_SHADES;
|
||||
fade.fadetimer = 0;
|
||||
fade.rate = FADE_NORM;
|
||||
fade.mode = FADE_GO;
|
||||
do
|
||||
{
|
||||
gamedo_fades();
|
||||
if (g_pInput->getPressedKey(KQUIT)) return;
|
||||
g_pInput->pollEvents();
|
||||
g_pTimer->SpeedThrottle();
|
||||
} while(fade.mode == FADE_GO);
|
||||
}
|
||||
/* ESEQ_EP1.C
|
||||
Ending sequence for Episode 1.
|
||||
*/
|
||||
|
||||
#include "keen.h"
|
||||
#include "include/game.h"
|
||||
#include "include/gamedo.h"
|
||||
#include "include/gamepdo.h"
|
||||
#include "sdl/CInput.h"
|
||||
#include "sdl/CTimer.h"
|
||||
#include "include/eseq_ep1.h"
|
||||
#include "include/eseq_ep2.h"
|
||||
#include "include/menu.h"
|
||||
#include "CGraphics.h"
|
||||
|
||||
#define CMD_MOVE 0
|
||||
#define CMD_WAIT 1
|
||||
#define CMD_SPAWNSPR 2
|
||||
#define CMD_REMOVESPR 3
|
||||
#define CMD_FADEOUT 4
|
||||
#define CMD_ENDOFQUEUE 5
|
||||
#define CMD_ENABLESCROLLING 6
|
||||
#define CMD_DISABLESCROLLING 7
|
||||
|
||||
|
||||
// start x,y map scroll position for eseq1_ShipFlys()
|
||||
#define SHIPFLY_X 32
|
||||
#define SHIPFLY_Y 0
|
||||
|
||||
// worldmap scroll position for eseq1_ReturnsToShip()
|
||||
#define WM_X 40
|
||||
#define WM_Y 540
|
||||
|
||||
#define LETTER_SHOW_SPD 30
|
||||
#define RETURNTOSHIP_WAIT_TIME 600
|
||||
|
||||
#define SPR_SHIP_RIGHT 115
|
||||
#define SPR_SHIP_LEFT 116
|
||||
#define SPR_EXCLAMATION 117
|
||||
#define SPR_QUESTION 118
|
||||
#define SHIPSPD 4
|
||||
|
||||
#define BACKHOME_SHORT_WAIT_TIME 250
|
||||
|
||||
int eseq1_ReturnsToShip(stCloneKeenPlus *pCKP)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i=0;i<MAX_LEVELS;i++)
|
||||
pCKP->Control.levelcontrol.levels_completed[i] = 0;
|
||||
|
||||
showmapatpos(80, WM_X, WM_Y, 0, pCKP);
|
||||
|
||||
// draw keen next to his ship
|
||||
g_pGraphics->drawSprite(168, 85, PMAPLEFTFRAME, 0);
|
||||
// do not show player when we render the screen
|
||||
numplayers = 1;
|
||||
player[0].x = 0;
|
||||
player[0].y = 0;
|
||||
player[0].playframe = BlankSprite;
|
||||
// all objects -> nonexistant
|
||||
for(i=0;i<MAX_OBJECTS;i++) objects[i].exists = 0;
|
||||
|
||||
fade.mode = FADE_GO;
|
||||
fade.dir = FADE_IN;
|
||||
fade.curamt = 0;
|
||||
fade.fadetimer = 0;
|
||||
fade.rate = FADE_NORM;
|
||||
|
||||
eseq_showmsg(getstring("EP1_ESEQ_PART1"),1,18,37,6,1, pCKP);
|
||||
|
||||
// fade out
|
||||
fade.mode = FADE_GO;
|
||||
fade.dir = FADE_OUT;
|
||||
fade.curamt = PAL_FADE_SHADES;
|
||||
fade.fadetimer = 0;
|
||||
fade.rate = FADE_NORM;
|
||||
do
|
||||
{
|
||||
gamedo_fades();
|
||||
gamedo_AnimatedTiles();
|
||||
|
||||
g_pInput->pollEvents();
|
||||
g_pTimer->SpeedThrottle();
|
||||
} while(fade.mode != FADE_COMPLETE && !g_pInput->getPressedKey(KQUIT));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void addshipqueue(int cmd, int time, int flag1)
|
||||
{
|
||||
shipqueue[ShipQueuePtr].cmd = cmd;
|
||||
shipqueue[ShipQueuePtr].time = time;
|
||||
shipqueue[ShipQueuePtr].flag1 = flag1;
|
||||
ShipQueuePtr++;
|
||||
}
|
||||
|
||||
int eseq1_ShipFlys(stCloneKeenPlus *pCKP)
|
||||
{
|
||||
char enter,lastenterstate;
|
||||
int x, y;
|
||||
int scrollingon;
|
||||
|
||||
scrollingon = 1;
|
||||
|
||||
#define MARK_SPR_NUM 5
|
||||
initgame(pCKP);
|
||||
|
||||
// set up the ship's route
|
||||
ShipQueuePtr = 0;
|
||||
addshipqueue(CMD_MOVE, 230, DUP);
|
||||
addshipqueue(CMD_WAIT, 50, 0);
|
||||
addshipqueue(CMD_MOVE, 2690, DDOWNRIGHT);
|
||||
addshipqueue(CMD_WAIT, 100, 0);
|
||||
addshipqueue(CMD_MOVE, 480, DDOWN);
|
||||
addshipqueue(CMD_WAIT, 150, 0);
|
||||
addshipqueue(CMD_SPAWNSPR, 0, SPR_QUESTION);
|
||||
addshipqueue(CMD_DISABLESCROLLING, 0, 0);
|
||||
addshipqueue(CMD_WAIT, 350, 0);
|
||||
addshipqueue(CMD_REMOVESPR, 0, 0);
|
||||
addshipqueue(CMD_WAIT, 50, 0);
|
||||
addshipqueue(CMD_MOVE, 700, DLEFT);
|
||||
addshipqueue(CMD_WAIT, 150, 0);
|
||||
addshipqueue(CMD_SPAWNSPR, 0, SPR_EXCLAMATION);
|
||||
addshipqueue(CMD_WAIT, 500, 0);
|
||||
addshipqueue(CMD_REMOVESPR, 0, 0);
|
||||
addshipqueue(CMD_WAIT, 50, 0);
|
||||
addshipqueue(CMD_MOVE, 700, DRIGHT);
|
||||
addshipqueue(CMD_WAIT, 25, 0);
|
||||
addshipqueue(CMD_ENABLESCROLLING, 0, 0);
|
||||
addshipqueue(CMD_MOVE, 465, DDOWN);
|
||||
addshipqueue(CMD_FADEOUT, 0, 0);
|
||||
addshipqueue(CMD_MOVE, 100, DDOWN);
|
||||
addshipqueue(CMD_ENDOFQUEUE, 0, 0);
|
||||
|
||||
showmapatpos(81, SHIPFLY_X, SHIPFLY_Y, 0, pCKP);
|
||||
|
||||
objects[MARK_SPR_NUM].type = OBJ_YORP; // doesn't matter
|
||||
objects[MARK_SPR_NUM].exists = 0;
|
||||
objects[MARK_SPR_NUM].sprite = SPR_QUESTION;
|
||||
|
||||
numplayers = 1;
|
||||
// place the player at the center of mars
|
||||
if (map_findtile(593, &x, &y))
|
||||
{ // found the tile at the center of mars
|
||||
player[0].x = ((x<<4)+1)<<CSF;
|
||||
player[0].y = ((y<<4)-3)<<CSF;
|
||||
}
|
||||
else
|
||||
{
|
||||
crashflag = 1;
|
||||
why_term_ptr = "eseq1_shipflys(): unable to find center of Mars.";
|
||||
return 1;
|
||||
}
|
||||
|
||||
player[0].playframe = SPR_SHIP_RIGHT;
|
||||
// player[0].pbgprioritycorners = 0;
|
||||
|
||||
fade.mode = FADE_GO;
|
||||
fade.dir = FADE_IN;
|
||||
fade.curamt = 0;
|
||||
fade.fadetimer = 0;
|
||||
fade.rate = FADE_NORM;
|
||||
ShipQueuePtr = 0;
|
||||
max_scroll_x = max_scroll_y = 20000;
|
||||
do
|
||||
{
|
||||
// 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].y = player[0].y - (10<<CSF);
|
||||
objects[MARK_SPR_NUM].onscreen = 1;
|
||||
// objects[MARK_SPR_NUM].priorityptsfound = 0;
|
||||
// objects[MARK_SPR_NUM].priorityptschecked = 4;
|
||||
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;
|
||||
|
||||
// execute the current command in the queue
|
||||
if (fade.dir != FADE_OUT)
|
||||
{
|
||||
switch(shipqueue[ShipQueuePtr].cmd)
|
||||
{
|
||||
case CMD_MOVE:
|
||||
switch(shipqueue[ShipQueuePtr].flag1)
|
||||
{
|
||||
case DUP:
|
||||
player[0].y-=SHIPSPD;
|
||||
player[0].playframe = SPR_SHIP_RIGHT;
|
||||
break;
|
||||
case DDOWN:
|
||||
player[0].y+=SHIPSPD/2;
|
||||
player[0].playframe = SPR_SHIP_RIGHT;
|
||||
break;
|
||||
case DLEFT:
|
||||
player[0].x-=SHIPSPD;
|
||||
player[0].playframe = SPR_SHIP_LEFT;
|
||||
break;
|
||||
case DRIGHT:
|
||||
player[0].x+=SHIPSPD;
|
||||
player[0].playframe = SPR_SHIP_RIGHT;
|
||||
break;
|
||||
case DDOWNRIGHT:
|
||||
player[0].x+=SHIPSPD*2;
|
||||
player[0].y+=SHIPSPD*0.8;
|
||||
player[0].playframe = SPR_SHIP_RIGHT;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case CMD_SPAWNSPR:
|
||||
objects[MARK_SPR_NUM].sprite = shipqueue[ShipQueuePtr].flag1;
|
||||
objects[MARK_SPR_NUM].exists = 1;
|
||||
break;
|
||||
case CMD_REMOVESPR:
|
||||
objects[MARK_SPR_NUM].sprite = shipqueue[ShipQueuePtr].flag1;
|
||||
objects[MARK_SPR_NUM].exists = 0;
|
||||
break;
|
||||
case CMD_ENABLESCROLLING:
|
||||
scrollingon = 1;
|
||||
break;
|
||||
case CMD_DISABLESCROLLING:
|
||||
scrollingon = 0;
|
||||
break;
|
||||
case CMD_WAIT:
|
||||
break;
|
||||
case CMD_FADEOUT:
|
||||
if (fade.dir!=FADE_OUT)
|
||||
{
|
||||
fade.dir = FADE_OUT;
|
||||
fade.curamt = PAL_FADE_SHADES;
|
||||
fade.fadetimer = 0;
|
||||
fade.mode = FADE_GO;
|
||||
fade.rate = FADE_NORM;
|
||||
}
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
// decrease the time remaining
|
||||
if (shipqueue[ShipQueuePtr].time)
|
||||
{
|
||||
shipqueue[ShipQueuePtr].time--;
|
||||
}
|
||||
else
|
||||
{ // no time left on this command, go to next cmd
|
||||
ShipQueuePtr++;
|
||||
}
|
||||
}
|
||||
|
||||
if (fade.dir==FADE_OUT && fade.mode==FADE_COMPLETE)
|
||||
{ // we're done
|
||||
return 0;
|
||||
}
|
||||
|
||||
enter = ( g_pInput->getPressedKey(KENTER) || g_pInput->getPressedKey(KCTRL) || g_pInput->getPressedKey(KALT) );
|
||||
if (enter)
|
||||
{
|
||||
if (fade.dir!=FADE_OUT)
|
||||
{
|
||||
fade.dir = FADE_OUT;
|
||||
fade.curamt = PAL_FADE_SHADES;
|
||||
fade.fadetimer = 0;
|
||||
fade.mode = FADE_GO;
|
||||
fade.rate = FADE_NORM;
|
||||
}
|
||||
}
|
||||
lastenterstate = enter;
|
||||
|
||||
gamedo_fades();
|
||||
gamedo_AnimatedTiles();
|
||||
|
||||
gamedo_frameskipping(pCKP);
|
||||
if (scrollingon) gamedo_ScrollTriggers(0);
|
||||
|
||||
g_pInput->pollEvents();
|
||||
g_pTimer->SpeedThrottle();
|
||||
} while(!g_pInput->getPressedKey(KQUIT));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int eseq1_BackAtHome(stCloneKeenPlus *pCKP)
|
||||
{
|
||||
/*int draw;*/
|
||||
int i;
|
||||
char *text[10];
|
||||
char strname[40];
|
||||
char tempbuf[200];
|
||||
short textline, showtimer;
|
||||
unsigned short amountshown;
|
||||
signed int waittimer;
|
||||
int state;
|
||||
int enter, lastenterstate;
|
||||
int dlgX, dlgY, dlgW, dlgH;
|
||||
|
||||
#define STATE_TEXTAPPEARING 0
|
||||
#define STATE_WAITASEC 1
|
||||
#define STATE_FADING 2
|
||||
|
||||
// get pointers to all the strings we're going to be using
|
||||
for(i=0;i<8;i++)
|
||||
{
|
||||
sprintf(strname, "EP1_ESEQ_PART2_PAGE%d", i+1);
|
||||
text[i] = getstring(strname);
|
||||
}
|
||||
|
||||
textline = 0;
|
||||
amountshown = 0;
|
||||
showtimer = 0;
|
||||
state = STATE_TEXTAPPEARING;
|
||||
lastenterstate = 1;
|
||||
waittimer = 0;
|
||||
|
||||
finale_draw("finale.ck1", pCKP->GameData[pCKP->Resources.GameSelected-1].DataDirectory);
|
||||
scrollx_buf = scroll_x = 0;
|
||||
scrolly_buf = scroll_y = 0;
|
||||
|
||||
numplayers = 1;
|
||||
player[0].x = 16;
|
||||
player[0].y = 16;
|
||||
player[0].playframe = BlankSprite;
|
||||
|
||||
dlgX = GetStringAttribute("EP1_ESEQ_PART2_PAGE1", "LEFT");
|
||||
dlgY = GetStringAttribute("EP1_ESEQ_PART2_PAGE1", "TOP");
|
||||
dlgW = GetStringAttribute("EP1_ESEQ_PART2_PAGE1", "WIDTH");
|
||||
dlgH = GetStringAttribute("EP1_ESEQ_PART2_PAGE1", "HEIGHT");
|
||||
|
||||
fade.mode = FADE_GO;
|
||||
fade.rate = FADE_NORM;
|
||||
fade.dir = FADE_IN;
|
||||
fade.curamt = 0;
|
||||
fade.fadetimer = 0;
|
||||
do
|
||||
{
|
||||
enter = ( g_pInput->getPressedKey(KENTER) || g_pInput->getPressedKey(KCTRL) || g_pInput->getPressedKey(KALT) );
|
||||
|
||||
sb_dialogbox(dlgX, dlgY, dlgW, dlgH);
|
||||
|
||||
// draw the current text line up to the amount currently shown
|
||||
strcpy(tempbuf, text[textline]);
|
||||
tempbuf[amountshown] = 0;
|
||||
g_pGraphics->sb_font_draw( (unsigned char*) tempbuf, (dlgX+1)*8, (dlgY+1)*8);
|
||||
|
||||
if (state==STATE_TEXTAPPEARING)
|
||||
{
|
||||
if (enter) goto fullshow;
|
||||
if (showtimer > LETTER_SHOW_SPD)
|
||||
{ // it's time to show a new letter
|
||||
amountshown++;
|
||||
if (amountshown > strlen(text[textline]))
|
||||
{ // reached end of line
|
||||
state = STATE_WAITASEC;
|
||||
// if (textline==8)
|
||||
// waittimer = -BACKHOME_SHORT_WAIT_TIME*3;
|
||||
// else
|
||||
waittimer = -BACKHOME_SHORT_WAIT_TIME*2;
|
||||
}
|
||||
// if the last letter shown is a dash/cr ('Billy...are you a-'),
|
||||
// show the rest of the text immediately
|
||||
// (for when the mom shouts "WHAT IS THIS ONE-EYED GREEN THING..."
|
||||
if (text[textline][amountshown]==13 && \
|
||||
text[textline][amountshown-1]=='-')
|
||||
{
|
||||
fullshow: ;
|
||||
amountshown = strlen(text[textline]);
|
||||
state = STATE_WAITASEC;
|
||||
waittimer = -BACKHOME_SHORT_WAIT_TIME*3;
|
||||
}
|
||||
showtimer = 0;
|
||||
} else showtimer++;
|
||||
|
||||
// user pressed enter
|
||||
if (enter)
|
||||
{ // show all text immediately
|
||||
|
||||
}
|
||||
}
|
||||
else if (state==STATE_WAITASEC)
|
||||
{
|
||||
if (enter) goto nextline;
|
||||
if (waittimer<BACKHOME_SHORT_WAIT_TIME)
|
||||
{
|
||||
waittimer++;
|
||||
if (waittimer==BACKHOME_SHORT_WAIT_TIME)
|
||||
{
|
||||
nextline: ;
|
||||
textline++;
|
||||
state = STATE_TEXTAPPEARING;
|
||||
amountshown = 0;
|
||||
if (textline>7)
|
||||
{ // end of text
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (fade.dir==FADE_OUT && fade.mode==FADE_COMPLETE)
|
||||
return 0;
|
||||
|
||||
gamedo_fades();
|
||||
gamedo_frameskipping_blitonly();
|
||||
|
||||
lastenterstate = enter;
|
||||
|
||||
g_pInput->pollEvents();
|
||||
g_pTimer->SpeedThrottle();
|
||||
if (g_pInput->getPressedKey(KQUIT)) return 1;
|
||||
} while(1);
|
||||
|
||||
finale_draw("finale.ck1", pCKP->GameData[pCKP->Resources.GameSelected-1].DataDirectory);
|
||||
eseq_ToBeContinued(pCKP);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void eseq_ToBeContinued(stCloneKeenPlus *pCKP)
|
||||
{
|
||||
int i;
|
||||
char *text;
|
||||
int dlgX, dlgY, dlgW, dlgH;
|
||||
|
||||
// remove all objects because eseq_showmsg will call drawobjects
|
||||
for(i=0;i<MAX_OBJECTS;i++)
|
||||
objects[i].exists = 0;
|
||||
|
||||
text = getstring("TO_BE_CONTINUED");
|
||||
dlgX = GetStringAttribute("TO_BE_CONTINUED", "LEFT");
|
||||
dlgY = GetStringAttribute("TO_BE_CONTINUED", "TOP");
|
||||
dlgW = GetStringAttribute("TO_BE_CONTINUED", "WIDTH");
|
||||
dlgH = GetStringAttribute("TO_BE_CONTINUED", "HEIGHT");
|
||||
eseq_showmsg(text, dlgX, dlgY, dlgW, dlgH, 0, pCKP);
|
||||
|
||||
fade.dir = FADE_OUT;
|
||||
fade.curamt = PAL_FADE_SHADES;
|
||||
fade.fadetimer = 0;
|
||||
fade.rate = FADE_NORM;
|
||||
fade.mode = FADE_GO;
|
||||
do
|
||||
{
|
||||
gamedo_fades();
|
||||
if (g_pInput->getPressedKey(KQUIT)) return;
|
||||
g_pInput->pollEvents();
|
||||
g_pTimer->SpeedThrottle();
|
||||
} while(fade.mode == FADE_GO);
|
||||
}
|
||||
|
||||
1430
src/eseq_ep2.cpp
1430
src/eseq_ep2.cpp
File diff suppressed because it is too large
Load Diff
1583
src/fileio.cpp
1583
src/fileio.cpp
File diff suppressed because it is too large
Load Diff
12
src/fileio.h
12
src/fileio.h
@@ -1,12 +1,14 @@
|
||||
#ifndef __CG_FILEIO2_H__
|
||||
#define __CG_FILEIO2_H__
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
#include <cstdio>
|
||||
#include <stdio.h>
|
||||
|
||||
char loadstrings(const char *fname);
|
||||
unsigned int fgeti(FILE *fp);
|
||||
unsigned long fgetl(FILE *fp);
|
||||
std::string formatPathString(const std::string& path);
|
||||
void formatPathString(char *output, const char *path);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -6,31 +6,29 @@
|
||||
*/
|
||||
|
||||
#include "CExeFile.h"
|
||||
#include <cstring>
|
||||
#include <string.h>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include "../StringUtils.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
CExeFile::CExeFile(int episode, const std::string& datadirectory) {
|
||||
CExeFile::CExeFile(int episode, char *datadirectory) {
|
||||
m_episode = episode;
|
||||
m_datadirectory = datadirectory;
|
||||
m_data = NULL;
|
||||
}
|
||||
|
||||
CExeFile::~CExeFile() {
|
||||
if(m_data) delete m_data;
|
||||
if(m_data) delete [] m_data;
|
||||
}
|
||||
|
||||
bool CExeFile::readData()
|
||||
{
|
||||
char filename[256];
|
||||
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;
|
||||
|
||||
@@ -49,7 +47,7 @@ bool CExeFile::readData()
|
||||
{
|
||||
m_datasize = decdata.size();
|
||||
m_data = new unsigned char[m_datasize];
|
||||
memcpy(m_data, &decdata[0], m_datasize);
|
||||
memcpy(m_data, decdata->data(), m_datasize);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -57,7 +55,7 @@ bool CExeFile::readData()
|
||||
m_data = new unsigned char[m_datasize];
|
||||
memcpy(m_data, m_data_temp+512,m_datasize);
|
||||
}
|
||||
delete m_data_temp;
|
||||
delete [] m_data_temp;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -12,11 +12,11 @@
|
||||
#define CEXEFILE_H_
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
class CExeFile {
|
||||
public:
|
||||
CExeFile(int episode, const std::string& datadirectory);
|
||||
CExeFile(int episode, char *datadirectory);
|
||||
virtual ~CExeFile();
|
||||
|
||||
bool readData();
|
||||
@@ -27,10 +27,10 @@ private:
|
||||
int m_datasize;
|
||||
int m_episode;
|
||||
unsigned char *m_data;
|
||||
std::string m_datadirectory;
|
||||
char *m_datadirectory;
|
||||
|
||||
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_ */
|
||||
|
||||
@@ -83,7 +83,7 @@ bool CParser::saveParseFile(void) // open, write on the file and close
|
||||
|
||||
if((fp=fopen(CONFIGFILENAME,"wt")))
|
||||
{
|
||||
std::list<char*>::iterator i;
|
||||
list<char*>::iterator i;
|
||||
|
||||
for(i=m_filebuffer.begin() ; i != m_filebuffer.end() ; ++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)
|
||||
{
|
||||
// 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;
|
||||
|
||||
@@ -152,7 +152,7 @@ void CParser::saveIntValue(const char *keyword, const char *category,int value)
|
||||
// 2.- category exists, but keyword not
|
||||
// 3.- category and keyword exist, only the value must be changed
|
||||
|
||||
std::list<char*>::iterator i;
|
||||
list<char*>::iterator i;
|
||||
|
||||
|
||||
char *line;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
using namespace std;
|
||||
|
||||
|
||||
class CParser {
|
||||
@@ -42,7 +43,7 @@ public:
|
||||
private:
|
||||
bool m_isOpen;
|
||||
|
||||
std::list<char*> m_filebuffer;
|
||||
list<char*> m_filebuffer;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
#include <string.h>
|
||||
#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_version = version;
|
||||
m_data = data;
|
||||
m_datadirectory = datadir;
|
||||
strcpy(m_datadirectory, datadir);
|
||||
}
|
||||
|
||||
CPatcher::~CPatcher() {
|
||||
@@ -35,7 +35,7 @@ void CPatcher::patchMemory()
|
||||
|
||||
// change to the proper directory
|
||||
chdir("data");
|
||||
chdir(m_datadirectory.c_str());
|
||||
chdir(m_datadirectory);
|
||||
|
||||
// TODO: Extend this part further with more commands
|
||||
while(!m_TextList.empty())
|
||||
@@ -80,6 +80,7 @@ void CPatcher::patchMemory()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(!m_TextList.empty())
|
||||
@@ -108,7 +109,7 @@ bool CPatcher::loadPatchfile()
|
||||
{
|
||||
bool ret = false;
|
||||
chdir("data");
|
||||
chdir(m_datadirectory.c_str());
|
||||
chdir(m_datadirectory);
|
||||
// Detect the patchfile
|
||||
DIR *dir = opendir(".");
|
||||
struct dirent *dp;
|
||||
@@ -120,9 +121,8 @@ bool CPatcher::loadPatchfile()
|
||||
if(strstr(dp->d_name,".pat"))
|
||||
{
|
||||
// The file was found! now read it into the memory!
|
||||
|
||||
char* buf;
|
||||
std::ifstream Patchfile(dp->d_name);
|
||||
ifstream Patchfile(dp->d_name);
|
||||
|
||||
while(!Patchfile.eof())
|
||||
{
|
||||
@@ -157,12 +157,12 @@ bool CPatcher::loadPatchfile()
|
||||
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 byte;
|
||||
|
||||
std::ifstream Patchfile(patch_file_name.c_str(), std::ios::binary);
|
||||
ifstream Patchfile(patch_file_name, ios::binary);
|
||||
|
||||
if(!Patchfile) return;
|
||||
|
||||
|
||||
@@ -9,15 +9,15 @@
|
||||
#define CPATCHER_H_
|
||||
|
||||
#include <list>
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
class CPatcher {
|
||||
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();
|
||||
|
||||
void patchMemory();
|
||||
void patchMemfromFile(const std::string& patch_file_name, int offset);
|
||||
void patchMemfromFile(const char *patch_file_name, int offset);
|
||||
|
||||
private:
|
||||
|
||||
@@ -26,9 +26,9 @@ private:
|
||||
int m_episode;
|
||||
int m_version;
|
||||
unsigned char *m_data;
|
||||
std::string m_datadirectory;
|
||||
|
||||
std::list<char*> m_TextList;
|
||||
char m_datadirectory[256];
|
||||
|
||||
list<char*> m_TextList;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -12,19 +12,24 @@
|
||||
#include "../include/fileio.h"
|
||||
#include "../fileio/CExeFile.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;
|
||||
if((fp=fopen(buf.c_str(),"rt"))==NULL)
|
||||
{
|
||||
buf = buf2 + "keen" + itoa(episode) + ".exe";
|
||||
char buf[256];
|
||||
char buf2[256];
|
||||
|
||||
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;
|
||||
int startflag=0, endflag=0; // where story begins and ends!
|
||||
|
||||
268
src/finale.cpp
268
src/finale.cpp
@@ -1,133 +1,135 @@
|
||||
/* FINALE.C
|
||||
Code for displaying the FINALE.CK? files.
|
||||
Thanks to Andrew Durdin for FIN2BMP, from which I got
|
||||
the decompression algorithm.
|
||||
*/
|
||||
|
||||
#include "keen.h"
|
||||
#include "include/fileio.h"
|
||||
#include "CGraphics.h"
|
||||
|
||||
int finale_x;
|
||||
int finale_y;
|
||||
int finale_count;
|
||||
int finale_planecol;
|
||||
int finale_plane_length;
|
||||
int finale_done;
|
||||
|
||||
// used internally by finale_draw()
|
||||
void finale_plot(int pix)
|
||||
{
|
||||
int mask;
|
||||
|
||||
mask = 128;
|
||||
do
|
||||
{
|
||||
if (pix & mask)
|
||||
{
|
||||
if (finale_planecol==1)
|
||||
{
|
||||
g_pGraphics->sb_setpixel(finale_x, finale_y, finale_planecol);
|
||||
}
|
||||
else
|
||||
{ // merge with previous planes
|
||||
g_pGraphics->sb_setpixel(finale_x, finale_y, g_pGraphics->sb_getpixel(finale_x, finale_y) | finale_planecol);
|
||||
}
|
||||
}
|
||||
else if (finale_planecol==1)
|
||||
{
|
||||
g_pGraphics->sb_setpixel(finale_x, finale_y, 0);
|
||||
}
|
||||
|
||||
finale_x++;
|
||||
if (finale_x > 319)
|
||||
{
|
||||
finale_x = 0;
|
||||
finale_y++;
|
||||
}
|
||||
|
||||
finale_count++;
|
||||
if (finale_count >= finale_plane_length)
|
||||
{
|
||||
finale_x = finale_y = 0;
|
||||
finale_count = 0;
|
||||
finale_planecol <<= 1;
|
||||
if (finale_planecol > 8) finale_done = 1;
|
||||
}
|
||||
|
||||
if (mask==1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
mask >>= 1;
|
||||
}
|
||||
|
||||
} while(1);
|
||||
|
||||
}
|
||||
|
||||
// draws a finale.ck? file into the upper-left corner of the scrollbuffer
|
||||
void finale_draw(const std::string& filename, const std::string& path)
|
||||
{
|
||||
FILE *fp;
|
||||
int cmdbyte;
|
||||
int bytecount;
|
||||
int repeatbyte;
|
||||
int i;
|
||||
|
||||
|
||||
std::string buffer = formatPathString(path);
|
||||
|
||||
|
||||
map_unregister_all_animtiles();
|
||||
|
||||
std::string fname = buffer + filename;
|
||||
fp = fopen(fname.c_str(), "rb");
|
||||
if (!fp)
|
||||
{
|
||||
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_count = 0;
|
||||
finale_done = 0;
|
||||
|
||||
/* decompress/draw the image */
|
||||
do
|
||||
{
|
||||
cmdbyte = fgetc(fp);
|
||||
if (cmdbyte<0)
|
||||
{ // EOF
|
||||
return;
|
||||
}
|
||||
|
||||
if (cmdbyte & 0x80)
|
||||
{
|
||||
//N + 1 bytes of data follows
|
||||
bytecount = (cmdbyte & 0x7F) + 1;
|
||||
for(i=0;i<bytecount;i++)
|
||||
{
|
||||
finale_plot(fgetc(fp));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Repeat N + 3 of following byte
|
||||
bytecount = (cmdbyte + 3);
|
||||
repeatbyte = fgetc(fp);
|
||||
for(i=0;i<bytecount;i++)
|
||||
{
|
||||
finale_plot(repeatbyte);
|
||||
}
|
||||
}
|
||||
|
||||
} while(!finale_done);
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
/* FINALE.C
|
||||
Code for displaying the FINALE.CK? files.
|
||||
Thanks to Andrew Durdin for FIN2BMP, from which I got
|
||||
the decompression algorithm.
|
||||
*/
|
||||
|
||||
#include "keen.h"
|
||||
#include "include/fileio.h"
|
||||
#include "CGraphics.h"
|
||||
|
||||
int finale_x;
|
||||
int finale_y;
|
||||
int finale_count;
|
||||
int finale_planecol;
|
||||
int finale_plane_length;
|
||||
int finale_done;
|
||||
|
||||
// used internally by finale_draw()
|
||||
void finale_plot(int pix)
|
||||
{
|
||||
int mask;
|
||||
|
||||
mask = 128;
|
||||
do
|
||||
{
|
||||
if (pix & mask)
|
||||
{
|
||||
if (finale_planecol==1)
|
||||
{
|
||||
g_pGraphics->sb_setpixel(finale_x, finale_y, finale_planecol);
|
||||
}
|
||||
else
|
||||
{ // merge with previous planes
|
||||
g_pGraphics->sb_setpixel(finale_x, finale_y, g_pGraphics->sb_getpixel(finale_x, finale_y) | finale_planecol);
|
||||
}
|
||||
}
|
||||
else if (finale_planecol==1)
|
||||
{
|
||||
g_pGraphics->sb_setpixel(finale_x, finale_y, 0);
|
||||
}
|
||||
|
||||
finale_x++;
|
||||
if (finale_x > 319)
|
||||
{
|
||||
finale_x = 0;
|
||||
finale_y++;
|
||||
}
|
||||
|
||||
finale_count++;
|
||||
if (finale_count >= finale_plane_length)
|
||||
{
|
||||
finale_x = finale_y = 0;
|
||||
finale_count = 0;
|
||||
finale_planecol <<= 1;
|
||||
if (finale_planecol > 8) finale_done = 1;
|
||||
}
|
||||
|
||||
if (mask==1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
mask >>= 1;
|
||||
}
|
||||
|
||||
} while(1);
|
||||
|
||||
}
|
||||
|
||||
// draws a finale.ck? file into the upper-left corner of the scrollbuffer
|
||||
void finale_draw(const char *filename, const char *path)
|
||||
{
|
||||
char fname[256];
|
||||
FILE *fp;
|
||||
int cmdbyte;
|
||||
int bytecount;
|
||||
int repeatbyte;
|
||||
int i;
|
||||
char buffer[256];
|
||||
|
||||
|
||||
formatPathString(buffer,path);
|
||||
|
||||
|
||||
map_unregister_all_animtiles();
|
||||
|
||||
sprintf(fname, "%s%s", buffer,filename);
|
||||
fp = fopen(fname, "rb");
|
||||
if (!fp)
|
||||
{
|
||||
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_count = 0;
|
||||
finale_done = 0;
|
||||
|
||||
/* decompress/draw the image */
|
||||
do
|
||||
{
|
||||
cmdbyte = fgetc(fp);
|
||||
if (cmdbyte<0)
|
||||
{ // EOF
|
||||
return;
|
||||
}
|
||||
|
||||
if (cmdbyte & 0x80)
|
||||
{
|
||||
//N + 1 bytes of data follows
|
||||
bytecount = (cmdbyte & 0x7F) + 1;
|
||||
for(i=0;i<bytecount;i++)
|
||||
{
|
||||
finale_plot(fgetc(fp));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Repeat N + 3 of following byte
|
||||
bytecount = (cmdbyte + 3);
|
||||
repeatbyte = fgetc(fp);
|
||||
for(i=0;i<bytecount;i++)
|
||||
{
|
||||
finale_plot(repeatbyte);
|
||||
}
|
||||
}
|
||||
|
||||
} while(!finale_done);
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
325
src/funcdefs.h
325
src/funcdefs.h
@@ -1,162 +1,163 @@
|
||||
|
||||
#ifndef __CG_FUNCDEFS_H__
|
||||
#define __CG_FUNCDEFS_H__
|
||||
|
||||
#include <string>
|
||||
|
||||
// gamedo.c
|
||||
int gamedo_ScrollTriggers(int theplayer);
|
||||
void gamedo_AnimatedTiles(void);
|
||||
|
||||
void gamedo_render_eraseobjects(void);
|
||||
void gamedo_render_drawdebug(void);
|
||||
void gamedo_render_erasedebug(void);
|
||||
void gamedo_fades(void);
|
||||
|
||||
// gamepdo.c
|
||||
|
||||
|
||||
// gamepdowm.c
|
||||
//void gamepdo_wm_HandlePlayer(int cp);
|
||||
//void gamepdo_InertiaAndFriction_Y(int cp);
|
||||
//void gamepdo_wm_AllowEnterLevel(int cp);
|
||||
char wm_issolid(int xb, int yb, int *levels_completed);
|
||||
|
||||
// game.c
|
||||
//void SetGameOver(void);
|
||||
void overrun_detect(void);
|
||||
void scrolltest(void);
|
||||
//void gameloop_initialize(void);
|
||||
void give_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 extralifeat(int p);
|
||||
char spawn_object(int x, int y, int otype);
|
||||
void common_enemy_ai(int o);
|
||||
char hitdetect(int object1, int object2);
|
||||
void freezeplayer(int theplayer);
|
||||
void unregister_animtiles(int tile);
|
||||
//void endlevel(int success, stCloneKeenPlus *pCKP)
|
||||
char checkobjsolid(unsigned int x, unsigned int y, unsigned int cp);
|
||||
//void initsprites(stCloneKeenPlus *pCKP)
|
||||
void CopyTileToSprite(int t, int s, int ntilestocopy, int transparent);
|
||||
void GiveAnkh(int cp);
|
||||
// map.c
|
||||
void map_scroll_right(void);
|
||||
void map_scroll_left(void);
|
||||
void map_scroll_down(void);
|
||||
void map_scroll_up(void);
|
||||
void map_draw_vstripe(unsigned int x, unsigned int mpx);
|
||||
void map_draw_hstripe(unsigned int y, unsigned int mpy);
|
||||
void nosb_map_draw_vstripe(unsigned int x, unsigned int mapx);
|
||||
unsigned int getmaptileat(unsigned int x, unsigned int y);
|
||||
unsigned int getlevelat(unsigned int x, unsigned int y);
|
||||
void drawmap(void);
|
||||
void map_unregister_all_animtiles(void);
|
||||
void map_deanimate(int x, int y);
|
||||
int map_isanimated(int x, int y);
|
||||
void map_animate(int x, int y);
|
||||
char map_findobject(unsigned int obj, int *xout, int *yout);
|
||||
char map_findtile(unsigned int tile, int *xout, int *yout);
|
||||
void map_redraw(void);
|
||||
void map_chgtile(unsigned int x,unsigned int y, int newtile);
|
||||
// dos\snddrv.c
|
||||
void SoundDrv_Stop(void);
|
||||
void sound_do(void);
|
||||
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(int snd, char mode);
|
||||
char sound_is_playing(int snd);
|
||||
void sound_stop(int snd);
|
||||
void sound_stop_all(void);
|
||||
void sound_pause(void);
|
||||
void sound_resume(void);
|
||||
char sound_extraction_of_exe_files(char *inputpath, int episode);
|
||||
|
||||
// graphics.c
|
||||
void DrawBitmap(int xa, int ya, int b);
|
||||
void freemem(void);
|
||||
void Graphics_Stop(void);
|
||||
void /*inline*/ sb_setpixel(int x, int y, unsigned char c);
|
||||
unsigned char sb_getpixel(int x, int y);
|
||||
void drawtile(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 drawprioritytile(int x, int y, unsigned int til);
|
||||
void drawsprite_direct(int x, int y, unsigned int t);
|
||||
void drawsprite(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 sb_drawcharacter(int x, int y, int f);
|
||||
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_drawcharacterinverse(int x, int y, int f);
|
||||
void save_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 addpal(int c, int r, int g, int b);
|
||||
void pal_init(int dark);
|
||||
void pal_fade(int fadeamt);
|
||||
void pal_apply(void);
|
||||
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_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_font_draw_inverse(unsigned char *text, int xoff, int yoff);
|
||||
// viddrv.c
|
||||
// fileio.c
|
||||
//void addmaptile(unsigned int t, stCloneKeenPlus *pCKP);
|
||||
//void addenemytile(unsigned int t, stCloneKeenPlus *pCKP);
|
||||
//unsigned int fgeti(FILE *fp);
|
||||
//unsigned long fgetl(FILE *fp);
|
||||
//unsigned int loadmap(char *filename, char *path, int lvlnum, int isworldmap);
|
||||
#include "fileio.h"
|
||||
|
||||
bool loadtileattributes(int episode, int version, unsigned char *filebuf);
|
||||
int freestrings(void);
|
||||
std::string getstring(const std::string& name);
|
||||
int GetStringAttribute(const std::string& stringName, const char *attrName);
|
||||
|
||||
// keydrv.c
|
||||
char KeyDrv_Start(void);
|
||||
void KeyDrv_Stop(void);
|
||||
|
||||
// misc.c
|
||||
void banner(void);
|
||||
void dialogbox(int x1, int y1, int w, int h);
|
||||
void sb_dialogbox(int x1, int y1, int w, int h);
|
||||
void statusbox(void);
|
||||
|
||||
int savegameiswm(char *fname);
|
||||
void usage(void);
|
||||
void radar(void);
|
||||
void SetAllCanSupportPlayer(int o, int state);
|
||||
void AllPlayersInvisible(void);
|
||||
|
||||
// menu.c
|
||||
int GetBitmapNumberFromName(const char *bmname);
|
||||
|
||||
|
||||
// eseq_ep1.c
|
||||
void addshipqueue(int cmd, int time, int flag1);
|
||||
|
||||
// latch.c
|
||||
//char latch_loadgraphics(int episode, char *path);
|
||||
|
||||
// sglre.c
|
||||
void sgrle_reset(void);
|
||||
void sgrle_compress(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);
|
||||
|
||||
// lz.c
|
||||
char lz_decompress(FILE *lzfile, unsigned char *outbuffer);
|
||||
|
||||
// finale.c
|
||||
void finale_draw(const std::string& filename, const std::string& path);
|
||||
|
||||
// scalerx.c
|
||||
//void scale2x(void* void_dst, unsigned dst_slice, const void* void_src, unsigned src_slice, unsigned pixel, unsigned width, unsigned height);
|
||||
|
||||
#endif
|
||||
|
||||
/*check if the compiler is of C++*/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// gamedo.c
|
||||
int gamedo_ScrollTriggers(int theplayer);
|
||||
void gamedo_AnimatedTiles(void);
|
||||
|
||||
void gamedo_render_eraseobjects(void);
|
||||
void gamedo_render_drawdebug(void);
|
||||
void gamedo_render_erasedebug(void);
|
||||
void gamedo_fades(void);
|
||||
|
||||
// gamepdo.c
|
||||
|
||||
|
||||
// gamepdowm.c
|
||||
//void gamepdo_wm_HandlePlayer(int cp);
|
||||
//void gamepdo_InertiaAndFriction_Y(int cp);
|
||||
//void gamepdo_wm_AllowEnterLevel(int cp);
|
||||
char wm_issolid(int xb, int yb, int *levels_completed);
|
||||
|
||||
// game.c
|
||||
//void SetGameOver(void);
|
||||
void overrun_detect(void);
|
||||
void scrolltest(void);
|
||||
//void gameloop_initialize(void);
|
||||
void give_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 extralifeat(int p);
|
||||
char spawn_object(int x, int y, int otype);
|
||||
void common_enemy_ai(int o);
|
||||
char hitdetect(int object1, int object2);
|
||||
void freezeplayer(int theplayer);
|
||||
void unregister_animtiles(int tile);
|
||||
//void endlevel(int success, stCloneKeenPlus *pCKP)
|
||||
char checkobjsolid(unsigned int x, unsigned int y, unsigned int cp);
|
||||
//void initsprites(stCloneKeenPlus *pCKP)
|
||||
void CopyTileToSprite(int t, int s, int ntilestocopy, int transparent);
|
||||
void GiveAnkh(int cp);
|
||||
// map.c
|
||||
void map_scroll_right(void);
|
||||
void map_scroll_left(void);
|
||||
void map_scroll_down(void);
|
||||
void map_scroll_up(void);
|
||||
void map_draw_vstripe(unsigned int x, unsigned int mpx);
|
||||
void map_draw_hstripe(unsigned int y, unsigned int mpy);
|
||||
void nosb_map_draw_vstripe(unsigned int x, unsigned int mapx);
|
||||
unsigned int getmaptileat(unsigned int x, unsigned int y);
|
||||
unsigned int getlevelat(unsigned int x, unsigned int y);
|
||||
void drawmap(void);
|
||||
void map_unregister_all_animtiles(void);
|
||||
void map_deanimate(int x, int y);
|
||||
int map_isanimated(int x, int y);
|
||||
void map_animate(int x, int y);
|
||||
char map_findobject(unsigned int obj, int *xout, int *yout);
|
||||
char map_findtile(unsigned int tile, int *xout, int *yout);
|
||||
void map_redraw(void);
|
||||
void map_chgtile(unsigned int x,unsigned int y, int newtile);
|
||||
// dos\snddrv.c
|
||||
void SoundDrv_Stop(void);
|
||||
void sound_do(void);
|
||||
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(int snd, char mode);
|
||||
char sound_is_playing(int snd);
|
||||
void sound_stop(int snd);
|
||||
void sound_stop_all(void);
|
||||
void sound_pause(void);
|
||||
void sound_resume(void);
|
||||
char sound_extraction_of_exe_files(char *inputpath, int episode);
|
||||
|
||||
// graphics.c
|
||||
void DrawBitmap(int xa, int ya, int b);
|
||||
void freemem(void);
|
||||
void Graphics_Stop(void);
|
||||
void /*inline*/ sb_setpixel(int x, int y, unsigned char c);
|
||||
unsigned char sb_getpixel(int x, int y);
|
||||
void drawtile(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 drawprioritytile(int x, int y, unsigned int til);
|
||||
void drawsprite_direct(int x, int y, unsigned int t);
|
||||
void drawsprite(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 sb_drawcharacter(int x, int y, int f);
|
||||
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_drawcharacterinverse(int x, int y, int f);
|
||||
void save_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 addpal(int c, int r, int g, int b);
|
||||
void pal_init(int dark);
|
||||
void pal_fade(int fadeamt);
|
||||
void pal_apply(void);
|
||||
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_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_font_draw_inverse(unsigned char *text, int xoff, int yoff);
|
||||
// viddrv.c
|
||||
// fileio.c
|
||||
//void addmaptile(unsigned int t, stCloneKeenPlus *pCKP);
|
||||
//void addenemytile(unsigned int t, stCloneKeenPlus *pCKP);
|
||||
//unsigned int fgeti(FILE *fp);
|
||||
//unsigned long fgetl(FILE *fp);
|
||||
//unsigned int loadmap(char *filename, char *path, int lvlnum, int isworldmap);
|
||||
#include "fileio.h"
|
||||
|
||||
bool loadtileattributes(int episode, int version, unsigned char *filebuf);
|
||||
int freestrings(void);
|
||||
char* getstring(const char *name);
|
||||
int GetStringAttribute(const char *stringName, const char *attrName);
|
||||
|
||||
// keydrv.c
|
||||
char KeyDrv_Start(void);
|
||||
void KeyDrv_Stop(void);
|
||||
|
||||
// misc.c
|
||||
void banner(void);
|
||||
void dialogbox(int x1, int y1, int w, int h);
|
||||
void sb_dialogbox(int x1, int y1, int w, int h);
|
||||
void statusbox(void);
|
||||
|
||||
int savegameiswm(char *fname);
|
||||
void usage(void);
|
||||
void radar(void);
|
||||
void SetAllCanSupportPlayer(int o, int state);
|
||||
void AllPlayersInvisible(void);
|
||||
|
||||
// menu.c
|
||||
int GetBitmapNumberFromName(const char *bmname);
|
||||
|
||||
|
||||
// eseq_ep1.c
|
||||
void addshipqueue(int cmd, int time, int flag1);
|
||||
|
||||
// latch.c
|
||||
//char latch_loadgraphics(int episode, char *path);
|
||||
|
||||
// sglre.c
|
||||
void sgrle_reset(void);
|
||||
void sgrle_compress(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);
|
||||
|
||||
// lz.c
|
||||
char lz_decompress(FILE *lzfile, unsigned char *outbuffer);
|
||||
|
||||
// finale.c
|
||||
void finale_draw(const char *filename, const char *path);
|
||||
|
||||
// scalerx.c
|
||||
//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++*/
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
1497
src/gamedo.cpp
1497
src/gamedo.cpp
File diff suppressed because it is too large
Load Diff
@@ -22,9 +22,9 @@ CHQBitmap::~CHQBitmap() {
|
||||
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;
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#define CHQBITMAP_H_
|
||||
|
||||
#include <SDL.h>
|
||||
#include <string>
|
||||
|
||||
class CHQBitmap {
|
||||
public:
|
||||
@@ -18,7 +17,7 @@ public:
|
||||
|
||||
void setScrollposition(unsigned int xpos, unsigned int ypos);
|
||||
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 offsetAlphaBlend(Uint8 alpha);
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
CMusic::CMusic() {
|
||||
playmode = PLAY_MODE_STOP;
|
||||
music_buffer = NULL;
|
||||
}
|
||||
|
||||
CMusic::~CMusic() {
|
||||
@@ -20,6 +21,8 @@ CMusic::~CMusic() {
|
||||
|
||||
int CMusic::load(SDL_AudioSpec AudioSpec, char *musicfile)
|
||||
{
|
||||
FILE *fp;
|
||||
|
||||
if(AudioSpec.format != 0)
|
||||
{
|
||||
|
||||
@@ -33,10 +36,10 @@ int CMusic::load(SDL_AudioSpec AudioSpec, char *musicfile)
|
||||
pOggAudio.sound_len=0;
|
||||
pOggAudio.sound_pos=0;
|
||||
|
||||
FILE *fp;
|
||||
if((fp = fopen(musicfile,"rb")) == NULL)
|
||||
{
|
||||
g_pLogFile->textOut(PURPLE,"Music Driver(): \"%s\". File does not exist!<br>", musicfile);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -101,7 +104,8 @@ void CMusic::unload(void)
|
||||
|
||||
void CMusic::play(void)
|
||||
{
|
||||
playmode = PLAY_MODE_PLAY;
|
||||
if(music_buffer)
|
||||
playmode = PLAY_MODE_PLAY;
|
||||
}
|
||||
|
||||
void CMusic::stop(void)
|
||||
|
||||
@@ -11,17 +11,17 @@
|
||||
#include "../include/vorbis/oggsupport.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_AudioCVT Audio_cvt;
|
||||
|
||||
psound->sound_buffer = NULL;
|
||||
std::string buf;
|
||||
char buf[80];
|
||||
FILE *fp;
|
||||
|
||||
buf = "data/hqp/snd/" + soundfile + ".OGG"; // Start with OGG
|
||||
if((fp = fopen(buf.c_str(),"rb")) != NULL)
|
||||
sprintf(buf,"data/hqp/snd/%s.OGG",soundfile); // Start with OGG
|
||||
if((fp = fopen(buf,"rb")) != NULL)
|
||||
{
|
||||
#ifdef BUILD_WITH_OGG
|
||||
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);
|
||||
return 1;
|
||||
}
|
||||
psound->enabled = true;
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef BUILD_WITH_OGG
|
||||
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
|
||||
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;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
psound->enabled = true;
|
||||
}
|
||||
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
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
/* Build AudioCVT (This is needed for the conversion from one format to the one used in the game)*/
|
||||
|
||||
@@ -5,21 +5,15 @@
|
||||
* Author: gerstrong
|
||||
*/
|
||||
|
||||
#ifndef __CG_HQ_SOUND_H__
|
||||
#define __CG_HQ_SOUND_H__
|
||||
|
||||
#include <SDL.h>
|
||||
#include <string>
|
||||
|
||||
struct stHQSound
|
||||
typedef struct stHQSound
|
||||
{
|
||||
Uint8 *sound_buffer;
|
||||
Uint32 sound_len;
|
||||
int sound_pos;
|
||||
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);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
#ifndef __CG_DECLARATIONS_H__
|
||||
#define __CG_DECLARATIONS_H__
|
||||
|
||||
#include <string>
|
||||
#include <SDL.h>
|
||||
|
||||
#define MAX_COMMANDS 8
|
||||
#define MAX_SOUND_LENGTH 1024
|
||||
#define MAX_SOUNDS 50
|
||||
#define MAX_STRING_LENGTH 256
|
||||
|
||||
|
||||
#define MAX_NUMBER_OF_FILES 100
|
||||
@@ -72,11 +68,10 @@ typedef struct stControl
|
||||
|
||||
typedef struct stGameData
|
||||
{
|
||||
std::string DataDirectory;
|
||||
short Episode;
|
||||
std::string Name;
|
||||
std::string FileList[MAX_NUMBER_OF_FILES];
|
||||
stGameData() : Episode(0) {}
|
||||
char DataDirectory[MAX_STRING_LENGTH];
|
||||
short Episode;
|
||||
char Name[MAX_STRING_LENGTH];
|
||||
char FileList[MAX_NUMBER_OF_FILES][MAX_STRING_LENGTH];
|
||||
} stGameData;
|
||||
|
||||
|
||||
@@ -111,5 +106,3 @@ typedef struct stNewPlayer
|
||||
{
|
||||
stCommand Command;
|
||||
} stNewPlayer;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -5,17 +5,10 @@
|
||||
* Author: gerstrong
|
||||
*/
|
||||
|
||||
#ifndef __CG_ESEQ_EP2_H__
|
||||
#define __CG_ESEQ_EP2_H__
|
||||
|
||||
#include <string>
|
||||
struct stCloneKeenPlus;
|
||||
|
||||
int eseq2_LimpsHome(stCloneKeenPlus *pCKP);
|
||||
int eseq2_TantalusRay(stCloneKeenPlus *pCKP);
|
||||
void eseq2_vibrate(stCloneKeenPlus *pCKP);
|
||||
int eseq2_HeadsForEarth(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
|
||||
|
||||
@@ -5,17 +5,10 @@
|
||||
* Author: gerstrong
|
||||
*/
|
||||
|
||||
#ifndef __CG_FILEIO_H__
|
||||
#define __CG_FILEIO_H__
|
||||
|
||||
#include <string>
|
||||
|
||||
unsigned int loadmap(const std::string& filename, const std::string& path, int lvlnum, int isworldmap, stCloneKeenPlus *pCKP);
|
||||
unsigned int loadmap(char filename[MAX_STRING_LENGTH], char *path, int lvlnum, int isworldmap, stCloneKeenPlus *pCKP);
|
||||
void addmaptile(unsigned int t);
|
||||
void addenemytile(unsigned int t, stCloneKeenPlus *pCKP);
|
||||
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);
|
||||
void assignChangeTileAttribute(stTile *tile, int episode);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -5,11 +5,4 @@
|
||||
* Author: gerstrong
|
||||
*/
|
||||
|
||||
#ifndef __CG_STORY_H__
|
||||
#define __CG_STORY_H__
|
||||
|
||||
#include <string>
|
||||
|
||||
int readStoryText(char **ptext, int episode, const std::string& path);
|
||||
|
||||
#endif
|
||||
int readStoryText(char **ptext, int episode, char *path);
|
||||
|
||||
1728
src/keen.h
1728
src/keen.h
File diff suppressed because it is too large
Load Diff
@@ -24,7 +24,7 @@
|
||||
|
||||
CloneKeen 2003-2005 Caitlin Shaw
|
||||
CloneKeenPlus 2008-2009 Gerstrong
|
||||
Commander Genius 2009 Tulip, Pickle and DaVince
|
||||
Commander Genius 2009 Tulip, Pickle, DaVince and Albert
|
||||
*/
|
||||
|
||||
#include "keen.h"
|
||||
@@ -572,7 +572,6 @@ demoHeaderCorrupt: ;
|
||||
short readCommandLine(int argc, char *argv[], stCloneKeenPlus *pCKP)
|
||||
{
|
||||
int i;
|
||||
static const int MAX_STRING_LENGTH = 256;
|
||||
char tempbuf[MAX_STRING_LENGTH];
|
||||
|
||||
|
||||
|
||||
1451
src/menu.cpp
1451
src/menu.cpp
File diff suppressed because it is too large
Load Diff
2739
src/misc.cpp
2739
src/misc.cpp
File diff suppressed because it is too large
Load Diff
@@ -5,7 +5,6 @@
|
||||
* Author: gerstrong
|
||||
*/
|
||||
#include "COpenGL.h"
|
||||
#include "CVideoDriver.h"
|
||||
#include "../CLogFile.h"
|
||||
|
||||
#define GAME_STD_WIDTH 320
|
||||
@@ -116,7 +115,7 @@ void COpenGL::render(void)
|
||||
//Clear the screen
|
||||
glClear(GL_COLOR_BUFFER_BIT); // Clear The Screen
|
||||
|
||||
LockSurface(m_blitsurface);
|
||||
SDL_LockSurface(m_blitsurface);
|
||||
|
||||
if(m_ScaleX == 2) //Scale 2x
|
||||
{
|
||||
@@ -158,7 +157,7 @@ void COpenGL::render(void)
|
||||
glVertex3f (0.0, 1.0, 0.0);
|
||||
glEnd();
|
||||
|
||||
UnlockSurface(m_blitsurface);
|
||||
SDL_UnlockSurface(m_blitsurface);
|
||||
|
||||
// Reset (Position?)
|
||||
glLoadIdentity();
|
||||
|
||||
@@ -480,7 +480,7 @@ char tempbuf[80];
|
||||
#else
|
||||
sprintf(tempbuf, "FPS: %03d", fps);
|
||||
#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();
|
||||
@@ -499,11 +499,11 @@ void CVideoDriver::update_screen(void)
|
||||
|
||||
mp_OpenGL->render();
|
||||
|
||||
LockSurface(FGLayerSurface);
|
||||
SDL_LockSurface(FGLayerSurface);
|
||||
// Flush the layers
|
||||
memset(FGLayerSurface->pixels,SDL_MapRGB(FGLayerSurface->format, 0, 0, 0),
|
||||
GAME_STD_WIDTH*GAME_STD_HEIGHT*FGLayerSurface->format->BytesPerPixel);
|
||||
UnlockSurface(FGLayerSurface);
|
||||
SDL_UnlockSurface(FGLayerSurface);
|
||||
}
|
||||
else // No OpenGL but Software Rendering
|
||||
{
|
||||
@@ -514,8 +514,8 @@ void CVideoDriver::update_screen(void)
|
||||
// another offscreen buffer, and must now stretchblit it to the screen
|
||||
if (Zoom == 1 && m_Resolution.width != 320 )
|
||||
{
|
||||
LockSurface(BlitSurface);
|
||||
LockSurface(screen);
|
||||
SDL_LockSurface(BlitSurface);
|
||||
SDL_LockSurface(screen);
|
||||
|
||||
if(Filtermode == 0)
|
||||
{
|
||||
@@ -527,13 +527,13 @@ void CVideoDriver::update_screen(void)
|
||||
g_pLogFile->textOut(PURPLE,"Try to use a higher zoom factor. Switching to no-filter<br>");
|
||||
Filtermode = 0;
|
||||
}
|
||||
UnlockSurface(screen);
|
||||
UnlockSurface(BlitSurface);
|
||||
SDL_UnlockSurface(screen);
|
||||
SDL_UnlockSurface(BlitSurface);
|
||||
}
|
||||
if (Zoom == 2)
|
||||
{
|
||||
LockSurface(BlitSurface);
|
||||
LockSurface(screen);
|
||||
SDL_LockSurface(BlitSurface);
|
||||
SDL_LockSurface(screen);
|
||||
|
||||
if(Filtermode == 0)
|
||||
{
|
||||
@@ -551,13 +551,13 @@ void CVideoDriver::update_screen(void)
|
||||
Filtermode = 0;
|
||||
}
|
||||
|
||||
UnlockSurface(screen);
|
||||
UnlockSurface(BlitSurface);
|
||||
SDL_UnlockSurface(screen);
|
||||
SDL_UnlockSurface(BlitSurface);
|
||||
}
|
||||
else if (Zoom == 3)
|
||||
{
|
||||
LockSurface(BlitSurface);
|
||||
LockSurface(screen);
|
||||
SDL_LockSurface(BlitSurface);
|
||||
SDL_LockSurface(screen);
|
||||
|
||||
if(Filtermode == 0)
|
||||
{
|
||||
@@ -579,13 +579,13 @@ void CVideoDriver::update_screen(void)
|
||||
g_pLogFile->textOut(PURPLE,"Try to use a higher zoom factor. Switching to no-filter<br>");
|
||||
Filtermode = 0;
|
||||
}
|
||||
UnlockSurface(screen);
|
||||
UnlockSurface(BlitSurface);
|
||||
SDL_UnlockSurface(screen);
|
||||
SDL_UnlockSurface(BlitSurface);
|
||||
}
|
||||
else if (Zoom == 4)
|
||||
{
|
||||
LockSurface(BlitSurface);
|
||||
LockSurface(screen);
|
||||
SDL_LockSurface(BlitSurface);
|
||||
SDL_LockSurface(screen);
|
||||
|
||||
if(Filtermode == 0)
|
||||
{
|
||||
@@ -612,18 +612,18 @@ void CVideoDriver::update_screen(void)
|
||||
g_pLogFile->textOut(PURPLE,"Try to use a higher zoom factor. Switching to no-filter<br>");
|
||||
Filtermode = 0;
|
||||
}
|
||||
UnlockSurface(screen);
|
||||
UnlockSurface(BlitSurface);
|
||||
SDL_UnlockSurface(screen);
|
||||
SDL_UnlockSurface(BlitSurface);
|
||||
}
|
||||
|
||||
SDL_Flip(screen);
|
||||
//SDL_UpdateRect(screen, screenrect.x, screenrect.y, screenrect.w, screenrect.h);
|
||||
|
||||
LockSurface(FGLayerSurface);
|
||||
SDL_LockSurface(FGLayerSurface);
|
||||
// Flush the layers
|
||||
memset(FGLayerSurface->pixels,SDL_MapRGB(FGLayerSurface->format, 0, 0, 0),
|
||||
GAME_STD_WIDTH*GAME_STD_HEIGHT*FGLayerSurface->format->BytesPerPixel);
|
||||
UnlockSurface(FGLayerSurface);
|
||||
SDL_UnlockSurface(FGLayerSurface);
|
||||
#ifdef USE_OPENGL
|
||||
}
|
||||
#endif
|
||||
@@ -765,7 +765,7 @@ int y;
|
||||
y = CONSOLE_MESSAGE_Y;
|
||||
for(i=0;i<NumConsoleMessages;i++)
|
||||
{
|
||||
g_pGraphics->drawFont( 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,17 +21,7 @@ struct st_resolution
|
||||
#include <SDL.h>
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
||||
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);
|
||||
}
|
||||
using namespace std;
|
||||
|
||||
class CVideoDriver : public CSingleton<CVideoDriver>
|
||||
{
|
||||
@@ -109,8 +99,8 @@ private:
|
||||
|
||||
st_resolution m_Resolution;
|
||||
|
||||
std::list<st_resolution> m_Resolutionlist;
|
||||
std::list<st_resolution> :: iterator m_Resolution_pos;
|
||||
list<st_resolution> m_Resolutionlist;
|
||||
list<st_resolution> :: iterator m_Resolution_pos;
|
||||
|
||||
unsigned int Mode;
|
||||
bool Fullscreen;
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#include "../../hqp/CMusic.h"
|
||||
#include "../../vorticon/sounds.h"
|
||||
#include "../../fileio/CExeFile.h"
|
||||
#include "../../StringUtils.h"
|
||||
|
||||
#define SAFE_DELETE_ARRAY(x) if(x) delete[] x; x=NULL
|
||||
|
||||
@@ -45,7 +44,7 @@ CSound::~CSound() {
|
||||
|
||||
bool CSound::init(void)
|
||||
{
|
||||
char name[256];
|
||||
char name[MAX_STRING_LENGTH];
|
||||
SDL_AudioSpec *desired, *obtained;
|
||||
|
||||
desired = &AudioSpec;
|
||||
@@ -298,14 +297,14 @@ playsound: ;
|
||||
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;
|
||||
|
||||
std::string path;
|
||||
char *path;
|
||||
int ok;
|
||||
std::string soundfile;
|
||||
std::string buf;
|
||||
char soundfile[80];
|
||||
char buf[256];
|
||||
|
||||
if(m_soundslot) delete[] m_soundslot;
|
||||
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>");
|
||||
|
||||
soundfile = formatPathString(path) + "sounds.ck" + itoa(Episode);
|
||||
char buffer[256];
|
||||
|
||||
formatPathString(buffer,path);
|
||||
|
||||
sprintf(soundfile, "%ssounds.ck%d", buffer,Episode);
|
||||
|
||||
FILE *p_file;
|
||||
|
||||
if( ( p_file = fopen(soundfile.c_str(),"rb") ) == NULL )
|
||||
if( ( p_file = fopen(soundfile,"rb") ) == NULL )
|
||||
{
|
||||
|
||||
buf = "keen" + itoa(Episode) + ".exe";
|
||||
g_pLogFile->ftextOut("sound_load_all(): \"%s\" was not found in the data directory. Looking for \"%s\" in \"%s\" and trying to extract this file<br>", soundfile.c_str(), buf.c_str(), formatPathString(path).c_str());
|
||||
extractOfExeFile(formatPathString(path), Episode);
|
||||
formatPathString(buffer,path);
|
||||
|
||||
sprintf(buf,"keen%d.exe",Episode);
|
||||
g_pLogFile->ftextOut("sound_load_all(): \"%s\" was not found in the data directory. Looking for \"%s\" in \"%s\" and trying to extract this file<br>", soundfile, buf, buffer);
|
||||
extractOfExeFile(buffer, Episode);
|
||||
}
|
||||
else
|
||||
fclose(p_file);
|
||||
@@ -372,7 +376,7 @@ char CSound::loadSoundData(unsigned short Episode, const std::string& DataDirect
|
||||
|
||||
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)
|
||||
{
|
||||
@@ -405,16 +409,18 @@ char CSound::loadSoundData(unsigned short Episode, const std::string& DataDirect
|
||||
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 pos, sounds_start, sounds_end, ret = 0;
|
||||
std::string buffer;
|
||||
std::string inputfname;
|
||||
char buffer[MAX_STRING_LENGTH];
|
||||
char inputfname[MAX_STRING_LENGTH];
|
||||
|
||||
pos = 0;
|
||||
bit_count = 0;
|
||||
memset(buffer,0, MAX_STRING_LENGTH*sizeof(char));
|
||||
memset(inputfname,0, MAX_STRING_LENGTH*sizeof(char));
|
||||
|
||||
// Set Offsets. Episode 1 already provides this
|
||||
if (episode == 2)
|
||||
@@ -431,7 +437,7 @@ char CSound::extractOfExeFile(const std::string& inputpath, int episode)
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -440,7 +446,7 @@ char CSound::extractOfExeFile(const std::string& inputpath, int episode)
|
||||
else
|
||||
{
|
||||
FILE *fout;
|
||||
if(!(fout = fopen(outputfname.c_str(),"wb"))) ret = 1;
|
||||
if(!(fout = fopen(outputfname,"wb"))) ret = 1;
|
||||
else
|
||||
{
|
||||
fwrite( ExeFile->getData()+sounds_start, 1, (sounds_end-sounds_start), fout);
|
||||
|
||||
@@ -11,12 +11,10 @@
|
||||
#include "../../CSingleton.h"
|
||||
#define g_pSound CSound::Get()
|
||||
|
||||
#include <string>
|
||||
#include <SDL.h>
|
||||
#include "CSoundChannel.h"
|
||||
#include "CSoundSlot.h"
|
||||
|
||||
|
||||
class CSound : public CSingleton<CSound>
|
||||
{
|
||||
public:
|
||||
@@ -25,11 +23,11 @@ public:
|
||||
|
||||
bool init(void);
|
||||
void stop(void);
|
||||
char loadSoundData(unsigned short Episode, const std::string& DataDirectory);
|
||||
char loadSoundData(unsigned short Episode, char *DataDirectory);
|
||||
void stopAllSounds(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 callback(void *unused, Uint8 *stream, int len);
|
||||
void pauseSound(void);
|
||||
@@ -46,7 +44,7 @@ public:
|
||||
|
||||
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:
|
||||
CSoundChannel *m_soundchannel;
|
||||
|
||||
@@ -34,7 +34,7 @@ CSoundSlot::~CSoundSlot() {
|
||||
|
||||
// loads sound searchname from file fname, into sounds[] entry loadnum
|
||||
// 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
|
||||
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++)
|
||||
name[i] = 0;
|
||||
|
||||
fp = fopen(fname.c_str(), "rb");
|
||||
fp = fopen(fname, "rb");
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -75,12 +75,12 @@ bool CSoundSlot::loadSound(const std::string& fname, const std::string& searchna
|
||||
priority = fgetc(fp);
|
||||
garbage = 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;
|
||||
}
|
||||
// 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);
|
||||
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));
|
||||
|
||||
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;
|
||||
|
||||
fclose(fp);
|
||||
|
||||
@@ -15,7 +15,7 @@ public:
|
||||
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; }
|
||||
|
||||
|
||||
@@ -64,11 +64,14 @@ short openOGGSound(FILE *fp, SDL_AudioSpec *pspec, Uint16 format, stHQSound *pso
|
||||
|
||||
psound->sound_len = buffer.size();
|
||||
|
||||
psound->sound_buffer = new Uint8[psound->sound_len];
|
||||
for(Uint32 i=0; i<psound->sound_len ; i++ )
|
||||
//psound->sound_buffer = new Uint8[psound->sound_len];
|
||||
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, buffer.data(), psound->sound_len );
|
||||
buffer.clear();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ void CCredits::Render(stCloneKeenPlus *pCKP)
|
||||
|
||||
for(int j=0 ; j<51 ; j++)
|
||||
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() )
|
||||
{
|
||||
|
||||
@@ -77,9 +77,10 @@ void CDialog::addSeparator(void)
|
||||
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
|
||||
// list implementation. TextList is the head.
|
||||
if(OptionTextList == NULL)
|
||||
@@ -87,21 +88,22 @@ void CDialog::addOptionText(const std::string& text)
|
||||
OptionTextList = new stTextList;
|
||||
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.
|
||||
if(length > w-4)
|
||||
{
|
||||
OptionTextList->text = text.substr(0, w-7);
|
||||
OptionTextList->text += "...";
|
||||
copy(text,text+w-7,OptionTextList->text);
|
||||
strcat(OptionTextList->text,"...");
|
||||
}
|
||||
else
|
||||
{
|
||||
OptionTextList->text = text;
|
||||
strcpy(OptionTextList->text,text);
|
||||
}
|
||||
|
||||
number_of_options = 1;
|
||||
@@ -122,41 +124,41 @@ void CDialog::addOptionText(const std::string& text)
|
||||
|
||||
curTextList = (stTextList*) curTextList->nextElement;
|
||||
|
||||
curTextList->text = "";
|
||||
memset(curTextList->text,0, TEXT_LENGTH);
|
||||
|
||||
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.
|
||||
if(length > w-4)
|
||||
{
|
||||
curTextList->text = text.substr(0, w-7);
|
||||
curTextList->text += "...";
|
||||
copy(text,text+w-7,curTextList->text);
|
||||
strcat(curTextList->text,"...");
|
||||
}
|
||||
else
|
||||
{
|
||||
curTextList->text = text;
|
||||
strcpy(curTextList->text,text);
|
||||
}
|
||||
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;
|
||||
stTextList *curTextList = OptionTextList;
|
||||
stTextList *curTextList;
|
||||
|
||||
for(i=0 ; i<pos ; i++) {
|
||||
if(!curTextList)
|
||||
// TODO: print error
|
||||
return;
|
||||
curTextList = curTextList->nextElement;
|
||||
}
|
||||
|
||||
curTextList->text = text;
|
||||
curTextList = OptionTextList;
|
||||
|
||||
for(i=0 ; i<pos ; i++)
|
||||
curTextList = (stTextList*) curTextList->nextElement;
|
||||
|
||||
memset(curTextList->text,0,TEXT_LENGTH);
|
||||
strcpy(curTextList->text,text);
|
||||
}
|
||||
|
||||
void CDialog::setDimensions(int rectx, int recty, int rectw, int recth)
|
||||
@@ -195,7 +197,7 @@ void CDialog::renderDialog()
|
||||
|
||||
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;
|
||||
i++;
|
||||
if(i >= h-2)
|
||||
@@ -285,7 +287,7 @@ void CDialog::renderOpenDialogAnimation(int x,int y, int w, int h)
|
||||
isanimated = false;
|
||||
}
|
||||
|
||||
std::string CDialog::getOptionString(unsigned int pos)
|
||||
char *CDialog::getOptionString(unsigned int pos)
|
||||
{
|
||||
unsigned int i;
|
||||
stTextList *curTextList;
|
||||
@@ -325,7 +327,7 @@ bool CDialog::setNextSelection()
|
||||
int i=0;
|
||||
if(selection+1 < number_of_options)
|
||||
{
|
||||
while(getOptionString(selection+i+1) == "")
|
||||
while(strcmp(getOptionString(selection+i+1),"") == 0)
|
||||
i++;
|
||||
|
||||
selection += i;
|
||||
@@ -341,7 +343,7 @@ bool CDialog::setPrevSelection()
|
||||
int i=0;
|
||||
if(selection-1 > 0)
|
||||
{
|
||||
while(getOptionString(selection-i-1) == "")
|
||||
while(strcmp(getOptionString(selection-i-1),"") == 0)
|
||||
i++;
|
||||
|
||||
selection -= i;
|
||||
|
||||
@@ -8,13 +8,13 @@
|
||||
#ifndef CDIALOG_H_
|
||||
#define CDIALOG_H_
|
||||
|
||||
#include <string>
|
||||
#define TEXT_LENGTH 256
|
||||
|
||||
struct stTextList
|
||||
typedef struct stTextList
|
||||
{
|
||||
std::string text;
|
||||
stTextList *nextElement;
|
||||
};
|
||||
char text[TEXT_LENGTH];
|
||||
void *nextElement;
|
||||
}stTextList;
|
||||
|
||||
class CDialog {
|
||||
public:
|
||||
@@ -25,8 +25,8 @@ public:
|
||||
void drawDialogbox(int x1, int y1, int w, int h);
|
||||
void setDimensions(int rectx, int recty, int rectw, int recth);
|
||||
|
||||
void addOptionText(const std::string& text);
|
||||
void setOptionText(unsigned int pos, const std::string& text);
|
||||
void addOptionText(const char *text);
|
||||
void setOptionText(unsigned int pos, const char *text);
|
||||
void addSeparator(void);
|
||||
|
||||
bool setSelection(int value);
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
bool setPrevSelection();
|
||||
|
||||
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 animateDialogBox(bool value);
|
||||
|
||||
@@ -12,14 +12,11 @@
|
||||
#endif
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
#include "../StringUtils.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
CEGAGraphics::CEGAGraphics(short episode, const std::string& path) {
|
||||
CEGAGraphics::CEGAGraphics(short episode, const char *path) {
|
||||
m_episode = episode;
|
||||
m_path = path;
|
||||
strcpy(m_path, path);
|
||||
|
||||
// EGAHEAD Structure
|
||||
LatchPlaneSize = 0;
|
||||
@@ -54,15 +51,15 @@ CEGAGraphics::~CEGAGraphics() {
|
||||
|
||||
bool CEGAGraphics::loadData()
|
||||
{
|
||||
std::string buf;
|
||||
char buf[256];
|
||||
vector<char> databuf;
|
||||
|
||||
chdir("data"); // TODO: You must be able to use another directory
|
||||
if(m_path == "")
|
||||
buf = "egahead.ck" + itoa(m_episode);
|
||||
if(m_path[0] == 0)
|
||||
sprintf(buf,"egahead.ck%hd",m_episode);
|
||||
else
|
||||
buf = m_path + "/egahead.ck" + itoa(m_episode);
|
||||
std::ifstream HeadFile(buf.c_str(),ios::binary);
|
||||
sprintf(buf,"%s/egahead.ck%hd",m_path,m_episode);
|
||||
ifstream HeadFile(buf,ios::binary);
|
||||
|
||||
if(!HeadFile)
|
||||
return false;
|
||||
@@ -75,8 +72,10 @@ bool CEGAGraphics::loadData()
|
||||
}
|
||||
HeadFile.close();
|
||||
|
||||
char *data = new char[databuf.size()];
|
||||
memcpy(data, &databuf[0], databuf.size());
|
||||
char *data;
|
||||
data = new char[databuf.size()];
|
||||
|
||||
memcpy(data, databuf.data(), databuf.size());
|
||||
|
||||
// Now copy the data to the EGAHEAD Structure
|
||||
memcpy(&LatchPlaneSize,data,4);
|
||||
@@ -109,10 +108,10 @@ bool CEGAGraphics::loadData()
|
||||
|
||||
m_Latch->loadHead(data);
|
||||
|
||||
if(m_path == "")
|
||||
buf = "egalatch.ck" + itoa(m_episode);
|
||||
if(m_path[0] == 0)
|
||||
sprintf(buf,"egalatch.ck%hd",m_episode);
|
||||
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.
|
||||
|
||||
|
||||
@@ -122,14 +121,16 @@ bool CEGAGraphics::loadData()
|
||||
SpriteLocation);
|
||||
m_Sprit->loadHead(data);
|
||||
|
||||
if(m_path == "")
|
||||
buf = "egasprit.ck" + itoa(m_episode);
|
||||
if(m_path[0] == 0)
|
||||
sprintf(buf,"egasprit.ck%hd",m_episode);
|
||||
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));
|
||||
|
||||
chdir("../");
|
||||
|
||||
delete [] data;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,13 +14,12 @@
|
||||
#ifndef CEGAGRAPHICS_H_
|
||||
#define CEGAGRAPHICS_H_
|
||||
|
||||
#include <string>
|
||||
#include "CEGALatch.h"
|
||||
#include "CEGASprit.h"
|
||||
|
||||
class CEGAGraphics {
|
||||
public:
|
||||
CEGAGraphics(short episode, const std::string& path);
|
||||
CEGAGraphics(short episode, const char *path);
|
||||
virtual ~CEGAGraphics();
|
||||
|
||||
bool loadData();
|
||||
@@ -29,7 +28,7 @@ public:
|
||||
|
||||
private:
|
||||
short m_episode;
|
||||
std::string m_path;
|
||||
char m_path[256];
|
||||
|
||||
// Part of the EGAHEAD Data Structure
|
||||
// Section 1:
|
||||
|
||||
@@ -65,11 +65,12 @@ bool CEGALatch::loadHead( char *data )
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CEGALatch::loadData(const std::string& filename, bool compresseddata)
|
||||
bool CEGALatch::loadData(const char *filename, bool compresseddata)
|
||||
{
|
||||
FILE* latchfile;
|
||||
char *RawData;
|
||||
|
||||
FILE* latchfile = fopen(filename.c_str(),"rb");
|
||||
latchfile = fopen(filename,"rb");
|
||||
|
||||
if(!latchfile)
|
||||
return false;
|
||||
|
||||
@@ -8,8 +8,7 @@
|
||||
#ifndef CEGALATCH_H_
|
||||
#define CEGALATCH_H_
|
||||
|
||||
#include <SDL.h>
|
||||
#include <string>
|
||||
#include <SDL/SDL.h>
|
||||
|
||||
class CEGALatch {
|
||||
public:
|
||||
@@ -26,7 +25,7 @@ public:
|
||||
virtual ~CEGALatch();
|
||||
|
||||
bool loadHead(char *data );
|
||||
bool loadData(const std::string& filename, bool compresseddata);
|
||||
bool loadData(const char *filename, bool compresseddata);
|
||||
|
||||
char *RawData;
|
||||
|
||||
|
||||
@@ -71,11 +71,12 @@ bool CEGASprit::loadHead(char *data)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CEGASprit::loadData(const std::string& filename, bool compresseddata)
|
||||
bool CEGASprit::loadData(const char *filename, bool compresseddata)
|
||||
{
|
||||
FILE* latchfile;
|
||||
char *RawData;
|
||||
|
||||
FILE* latchfile = fopen(filename.c_str(),"rb");
|
||||
latchfile = fopen(filename,"rb");
|
||||
|
||||
if(!latchfile)
|
||||
return false;
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
#ifndef CEGASPRIT_H_
|
||||
#define CEGASPRIT_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
class CEGASprit {
|
||||
public:
|
||||
CEGASprit(int planesize,
|
||||
@@ -19,7 +17,7 @@ public:
|
||||
virtual ~CEGASprit();
|
||||
|
||||
bool loadHead(char *data);
|
||||
bool loadData(const std::string& filename, bool compresseddata);
|
||||
bool loadData(const char *filename, bool compresseddata);
|
||||
|
||||
private:
|
||||
int m_numsprites;
|
||||
|
||||
@@ -9,7 +9,9 @@
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "../keen.h"
|
||||
#include "../include/menu.h"
|
||||
@@ -18,14 +20,10 @@
|
||||
#include "../sdl/CInput.h"
|
||||
#include "../sdl/CTimer.h"
|
||||
#include "../CGraphics.h"
|
||||
#include "../StringUtils.h"
|
||||
|
||||
#define HIGHSCORETABLE_X 1344
|
||||
#define HIGHSCORETABLE_Y 32
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
CHighScores::CHighScores(stCloneKeenPlus *poutsideCKP) {
|
||||
// Set default Scores
|
||||
strcpy(Name[0],"Gerstrong");
|
||||
@@ -126,8 +124,8 @@ char CHighScores::showHighScore(void)
|
||||
|
||||
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(Score[i],200-(strlen(Score[i])<<3),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((unsigned char*) Score[i],200-(strlen(Score[i])<<3),64+(i<<4),4,7);
|
||||
if(Extra[i][0] == true)
|
||||
g_pGraphics->drawTile(32,90+(i<<4),ItemTiles[0]);
|
||||
if(Extra[i][1] == true)
|
||||
@@ -142,19 +140,19 @@ char CHighScores::showHighScore(void)
|
||||
{
|
||||
for( i=0 ; i<7 ; i++ )
|
||||
{
|
||||
std::string buf;
|
||||
g_pGraphics->sb_color_font_draw(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);
|
||||
buf = itoa(Cities[i]);
|
||||
g_pGraphics->sb_color_font_draw(buf,250,64+(i<<4),4,7);
|
||||
char buf[2];
|
||||
g_pGraphics->sb_color_font_draw((unsigned char*) Name[i],40,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);
|
||||
sprintf(buf,"%d",Cities[i]);
|
||||
g_pGraphics->sb_color_font_draw((unsigned char*) buf,250,64+(i<<4),4,7);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
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(Score[i],200-(strlen(Score[i])<<3),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((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++ )
|
||||
{
|
||||
std::string buf;
|
||||
g_pGraphics->sb_color_font_draw(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);
|
||||
buf = itoa(Cities[i]);
|
||||
g_pGraphics->sb_color_font_draw(buf,250,64+(i<<4),4,7);
|
||||
char buf[2];
|
||||
g_pGraphics->sb_color_font_draw((unsigned char*) Name[i],40,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);
|
||||
sprintf(buf,"%d",Cities[i]);
|
||||
g_pGraphics->sb_color_font_draw((unsigned char*) buf,250,64+(i<<4),4,7);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
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(Score[i],200-(strlen(Score[i])<<3),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((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))
|
||||
{
|
||||
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.copy(buf,WrittenName.length(),0);
|
||||
memset(Name[place],0,16);
|
||||
@@ -331,10 +329,10 @@ char CHighScores::writeHighScore(int points, bool *extras, int cities)
|
||||
for( i=0 ; i<7 ; i++ )
|
||||
{
|
||||
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
|
||||
g_pGraphics->sb_color_font_draw(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*) buf,40,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)
|
||||
{
|
||||
@@ -366,7 +364,9 @@ char CHighScores::writeHighScore(int points, bool *extras, int cities)
|
||||
char CHighScores::loadHighScoreTable(void)
|
||||
{
|
||||
string sBuf;
|
||||
std::string chBuf = itoa(Episode);
|
||||
char chBuf[256];
|
||||
|
||||
sprintf(chBuf,"%d",Episode);
|
||||
|
||||
sBuf.append("data/");
|
||||
sBuf.append(DataDirectory);
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
#ifndef CHIGHSCORES_H_
|
||||
#define CHIGHSCORES_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
class CHighScores {
|
||||
public:
|
||||
CHighScores(stCloneKeenPlus *poutsideCKP);
|
||||
@@ -27,7 +25,7 @@ private:
|
||||
int ItemTiles[4];
|
||||
|
||||
char Episode;
|
||||
std::string DataDirectory;
|
||||
char *DataDirectory;
|
||||
|
||||
stCloneKeenPlus *pCKP;
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ bool CMessages::readData(char *buf, int episode, int version)
|
||||
// Now read the stuff and store it to a list
|
||||
for(int pos=offset_start ; pos<offset_end ; pos++)
|
||||
{
|
||||
std::string Text;
|
||||
string Text;
|
||||
|
||||
while(buf[pos] != 0)
|
||||
{
|
||||
@@ -68,7 +68,7 @@ bool CMessages::readData(char *buf, int episode, int version)
|
||||
StringList.push_back(Text);
|
||||
}
|
||||
|
||||
std::list<std::string> :: iterator i;
|
||||
list<string> :: iterator i;
|
||||
|
||||
#include <iostream>
|
||||
for(i=StringList.begin() ; i!=StringList.end() ; i++)
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
// TODO: Make the strings a class, but it must read from the exe-files basing on uncompressed buffer
|
||||
|
||||
class CMessages {
|
||||
@@ -23,8 +25,8 @@ public:
|
||||
char *getString(const char *IDtext);
|
||||
|
||||
private:
|
||||
std::list<std::string> StringList;
|
||||
std::list<std::string> StringIDList;
|
||||
list<string> StringList;
|
||||
list<string> StringIDList;
|
||||
};
|
||||
|
||||
#endif /* CMESSAGES_H_ */
|
||||
|
||||
Reference in New Issue
Block a user