git-svn-id: https://clonekeenplus.svn.sourceforge.net/svnroot/clonekeenplus/cgenius/trunk@30 4df4b0f3-56ce-47cb-b001-ed939b7d65a6
This commit is contained in:
168
src/sdl/CSettings.cpp
Normal file
168
src/sdl/CSettings.cpp
Normal file
@@ -0,0 +1,168 @@
|
||||
/*
|
||||
* CSettings.cpp
|
||||
*
|
||||
* Created on: 08.06.2009
|
||||
* Author: gerstrong
|
||||
*/
|
||||
|
||||
#include "../fileio/CParser.h"
|
||||
#include "../CLogFile.h"
|
||||
#include "CSettings.h"
|
||||
#include "CVideoDriver.h"
|
||||
#include "sound/CSound.h"
|
||||
|
||||
CSettings::CSettings() {
|
||||
// TODO Auto-generated constructor stub
|
||||
|
||||
}
|
||||
|
||||
CSettings::~CSettings() {
|
||||
// TODO Auto-generated destructor stub
|
||||
}
|
||||
|
||||
|
||||
short CSettings::saveDrvCfg(void)
|
||||
{
|
||||
short retval = 0;
|
||||
|
||||
CParser Parser;
|
||||
|
||||
Parser.saveIntValue("bpp","Video",g_pVideoDriver->getDepth());
|
||||
Parser.saveIntValue("frameskip","Video",g_pVideoDriver->getFrameskip());
|
||||
|
||||
if(g_pVideoDriver->getFullscreen())
|
||||
Parser.saveIntValue("fullscreen","Video",1);
|
||||
else
|
||||
Parser.saveIntValue("fullscreen","Video",0);
|
||||
|
||||
if(g_pVideoDriver->isOpenGL())
|
||||
Parser.saveIntValue("OpenGL","Video",1);
|
||||
else
|
||||
Parser.saveIntValue("OpenGL","Video",0);
|
||||
|
||||
|
||||
Parser.saveIntValue("width","Video",g_pVideoDriver->getWidth());
|
||||
Parser.saveIntValue("height","Video",g_pVideoDriver->getHeight());
|
||||
Parser.saveIntValue("scale","Video",g_pVideoDriver->getZoomValue());
|
||||
Parser.saveIntValue("OGLfilter","Video",g_pVideoDriver->getOGLFilter());
|
||||
Parser.saveIntValue("filter","Video",g_pVideoDriver->getFiltermode());
|
||||
Parser.saveIntValue("autoframeskip","Video",g_pVideoDriver->getTargetFPS());
|
||||
Parser.saveIntValue("aspect","Video",g_pVideoDriver->getAspectCorrection() ? 1 : 0);
|
||||
|
||||
Parser.saveIntValue("channels","Audio",(g_pSound->getAudioSpec()).channels);
|
||||
Parser.saveIntValue("format","Audio",(g_pSound->getAudioSpec()).format);
|
||||
Parser.saveIntValue("rate","Audio",(g_pSound->getAudioSpec()).freq);
|
||||
Parser.saveIntValue("mixerch","Audio",(g_pSound->getMixingchannels()));
|
||||
|
||||
Parser.saveParseFile();
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
short CSettings::loadDrvCfg(void)
|
||||
{
|
||||
short retval = 0;
|
||||
CParser Parser;
|
||||
|
||||
if(!Parser.loadParseFile())
|
||||
{
|
||||
retval = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
int width, height, depth;
|
||||
|
||||
depth = Parser.getIntValue("bpp","Video");
|
||||
width = Parser.getIntValue("width","Video");
|
||||
height = Parser.getIntValue("height","Video");
|
||||
|
||||
if(depth*width*height < 0)
|
||||
g_pLogFile->ftextOut(RED,"Error reading the configuration file. It appears to be damaged!");
|
||||
|
||||
g_pVideoDriver->setMode(width, height, depth);
|
||||
|
||||
g_pVideoDriver->setFrameskip(Parser.getIntValue("frameskip","Video"));
|
||||
|
||||
if((Parser.getIntValue("fullscreen","Video")) == 1)
|
||||
g_pVideoDriver->isFullscreen(true);
|
||||
|
||||
g_pVideoDriver->setOGLFilter(Parser.getIntValue("OGLfilter","Video"));
|
||||
g_pVideoDriver->setZoom(Parser.getIntValue("scale","Video"));
|
||||
g_pVideoDriver->setTargetFPS(Parser.getIntValue("autoframeskip","Video"));
|
||||
|
||||
g_pVideoDriver->setFilter(Parser.getIntValue("filter","Video"));
|
||||
|
||||
if(Parser.getIntValue("OpenGL","Video") == 1)
|
||||
g_pVideoDriver->enableOpenGL(true);
|
||||
else
|
||||
g_pVideoDriver->enableOpenGL(false);
|
||||
|
||||
if(Parser.getIntValue("channels","Audio") == 2)
|
||||
g_pSound->setSoundmode(Parser.getIntValue("rate","Audio"), true);
|
||||
else
|
||||
g_pSound->setSoundmode(Parser.getIntValue("rate","Audio"), false);
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
void CSettings::setOption(stOption *options, int opt, const char *name, char value)
|
||||
{
|
||||
if (name != NULL)
|
||||
options[opt].name = (char*) name;
|
||||
|
||||
options[opt].value = value;
|
||||
}
|
||||
|
||||
void CSettings::loadDefaultGameCfg(stOption *Option)
|
||||
{
|
||||
setOption(Option,OPT_FULLYAUTOMATIC, "autogun", 0);
|
||||
setOption(Option,OPT_SUPERPOGO, "superpogo", 0);
|
||||
setOption(Option,OPT_ALLOWPKING, "pking", 1);
|
||||
setOption(Option,OPT_CHEATS, "allcheats", 0);
|
||||
setOption(Option,OPT_TWOBUTTON, "two-button-firing", 0);
|
||||
setOption(Option,OPT_KEYCARDSTACK, "keycard-stacking", 0);
|
||||
setOption(Option,OPT_ANALOGJOYSTICK, "analog-joystick", 1);
|
||||
}
|
||||
|
||||
short CSettings::loadGameCfg(stOption *Option)
|
||||
{
|
||||
short retval = 0;
|
||||
int i;
|
||||
CParser Parser;
|
||||
|
||||
if(!Parser.loadParseFile())
|
||||
return 1;
|
||||
|
||||
for (i = 0; i < NUM_OPTIONS; i++)
|
||||
{
|
||||
Option[i].value = Parser.getIntValue(Option[i].name,"Game");
|
||||
if(Option[i].value == -1)
|
||||
{
|
||||
loadDefaultGameCfg(Option);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return retval;
|
||||
|
||||
g_pLogFile->ftextOut("<br>Your personal settings were loaded successfully...<br>");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CSettings::saveGameCfg(stOption *Option)
|
||||
{
|
||||
int i;
|
||||
CParser Parser;
|
||||
|
||||
if(Parser.loadParseFile())
|
||||
{
|
||||
for (i = 0; i < NUM_OPTIONS; i++)
|
||||
Parser.saveIntValue(Option[i].name,"Game",Option[i].value);
|
||||
|
||||
Parser.saveParseFile();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
40
src/sdl/CSettings.h
Normal file
40
src/sdl/CSettings.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* CSettings.h
|
||||
*
|
||||
* Created on: 08.06.2009
|
||||
* Author: gerstrong
|
||||
*/
|
||||
|
||||
#ifndef CSETTINGS_H_
|
||||
#define CSETTINGS_H_
|
||||
|
||||
#define OPT_FULLYAUTOMATIC 0
|
||||
#define OPT_SUPERPOGO 1
|
||||
#define OPT_ALLOWPKING 2
|
||||
#define OPT_CHEATS 3
|
||||
#define OPT_TWOBUTTON 4
|
||||
#define OPT_KEYCARDSTACK 5
|
||||
#define OPT_ANALOGJOYSTICK 6
|
||||
#define OPT_MEAN 7
|
||||
|
||||
#define NUM_OPTIONS 8
|
||||
|
||||
typedef struct stOption
|
||||
{
|
||||
char *name;
|
||||
char value;
|
||||
} stOption;
|
||||
|
||||
class CSettings {
|
||||
public:
|
||||
CSettings();
|
||||
virtual ~CSettings();
|
||||
short saveDrvCfg(void);
|
||||
short loadDrvCfg(void);
|
||||
short loadGameCfg(stOption *Option);
|
||||
void saveGameCfg(stOption *Option);
|
||||
void loadDefaultGameCfg(stOption *Option);
|
||||
void setOption(stOption *options, int opt, const char *name, char value);
|
||||
};
|
||||
|
||||
#endif /* CSETTINGS_H_ */
|
||||
32
src/sdl/gp2x.h
Executable file
32
src/sdl/gp2x.h
Executable file
@@ -0,0 +1,32 @@
|
||||
#ifndef _GP2X_H_
|
||||
#define _GP2X_H_
|
||||
|
||||
#define GP2X_BUTTON_UP 0
|
||||
#define GP2X_BUTTON_DOWN 4
|
||||
#define GP2X_BUTTON_LEFT 2
|
||||
#define GP2X_BUTTON_RIGHT 6
|
||||
#define GP2X_BUTTON_UPLEFT 1
|
||||
#define GP2X_BUTTON_UPRIGHT 7
|
||||
#define GP2X_BUTTON_DOWNLEFT 3
|
||||
#define GP2X_BUTTON_DOWNRIGHT 5
|
||||
|
||||
#define GP2X_BUTTON_A 12
|
||||
#define GP2X_BUTTON_B 13
|
||||
#define GP2X_BUTTON_X 14
|
||||
#define GP2X_BUTTON_Y 15
|
||||
#define GP2X_BUTTON_L 10
|
||||
#define GP2X_BUTTON_R 11
|
||||
#define GP2X_BUTTON_CLICK 18
|
||||
#define GP2X_BUTTON_START 8
|
||||
#define GP2X_BUTTON_SELECT 9
|
||||
#define GP2X_BUTTON_VOLUP 16
|
||||
#define GP2X_BUTTON_VOLDOWN 17
|
||||
|
||||
#define VOLUME_MIN 0
|
||||
#define VOLUME_MAX 100
|
||||
#define VOLUME_CHANGE_RATE 2
|
||||
#define VOLUME_NOCHG 0
|
||||
#define VOLUME_DOWN 1
|
||||
#define VOLUME_UP 2
|
||||
|
||||
#endif
|
||||
161
src/vorticon/CCredits.cpp
Normal file
161
src/vorticon/CCredits.cpp
Normal file
@@ -0,0 +1,161 @@
|
||||
/*
|
||||
* CCredits.cpp
|
||||
*
|
||||
* Created on: 20.06.2009
|
||||
* Author: gerstrong
|
||||
*/
|
||||
|
||||
#include "../keen.h"
|
||||
#include "CCredits.h"
|
||||
#include "../sdl/CTimer.h"
|
||||
#include "../sdl/CInput.h"
|
||||
#include "../CGraphics.h"
|
||||
#include "../include/menu.h"
|
||||
#include "../include/gamedo.h"
|
||||
|
||||
CCredits::CCredits() {
|
||||
// TODO Auto-generated constructor stub
|
||||
|
||||
}
|
||||
|
||||
CCredits::~CCredits() {
|
||||
// TODO Auto-generated destructor stub
|
||||
}
|
||||
|
||||
void CCredits::Render(stCloneKeenPlus *pCKP)
|
||||
{
|
||||
// TODO: Now that the new intro function works, the old one must become
|
||||
// a credits class
|
||||
|
||||
int mid[7];
|
||||
char scrolltext[7][80];
|
||||
unsigned char pagenumber = 0;
|
||||
int timer = 8;
|
||||
int scrolly = 0;
|
||||
bool cancel = false;
|
||||
|
||||
fade.mode = FADE_GO;
|
||||
fade.rate = FADE_NORM;
|
||||
fade.dir = FADE_IN;
|
||||
fade.curamt = 0;
|
||||
fade.fadetimer = 0;
|
||||
|
||||
showmapatpos(90, 104<<4, 32, 0, pCKP);
|
||||
|
||||
memset(scrolltext,0,7*80);
|
||||
|
||||
do
|
||||
{
|
||||
// do fades
|
||||
gamedo_fades();
|
||||
|
||||
// blit the scrollbuffer to the display
|
||||
gamedo_frameskipping_blitonly();
|
||||
|
||||
gamedo_AnimatedTiles();
|
||||
|
||||
if(fade.mode != FADE_COMPLETE)
|
||||
continue;
|
||||
|
||||
if(timer<15) timer++;
|
||||
else
|
||||
{
|
||||
timer=0;
|
||||
if(scrolly>-7*8) scrolly--;
|
||||
else
|
||||
{
|
||||
scrolly = 200;
|
||||
memset(scrolltext,0,7*80);
|
||||
|
||||
switch(pagenumber)
|
||||
{
|
||||
case 0:
|
||||
strcpy(scrolltext[0],"Commander Genius");
|
||||
strcpy(scrolltext[1],"Interpreter of");
|
||||
strcpy(scrolltext[2],"Commander Keen 1-3");
|
||||
strcpy(scrolltext[3],"Credits");
|
||||
break;
|
||||
case 1:
|
||||
strcpy(scrolltext[0],"based on the engine of");
|
||||
strcpy(scrolltext[1],"CloneKeen by Shaw");
|
||||
strcpy(scrolltext[2],"and");
|
||||
strcpy(scrolltext[3],"CloneKeenPlus by Gerstrong");
|
||||
break;
|
||||
|
||||
case 2:
|
||||
strcpy(scrolltext[0],"Developers");
|
||||
strcpy(scrolltext[1],"of");
|
||||
strcpy(scrolltext[2],"Commander Genius");
|
||||
strcpy(scrolltext[3],"");
|
||||
strcpy(scrolltext[4],"Aka CloneKeenPlus");
|
||||
break;
|
||||
|
||||
case 3:
|
||||
strcpy(scrolltext[0],"Main Developer:");
|
||||
strcpy(scrolltext[1]," Gerstrong");
|
||||
strcpy(scrolltext[2],"Handheld Devices (Wiz):");
|
||||
strcpy(scrolltext[3]," Pickle");
|
||||
strcpy(scrolltext[4],"Resources:");
|
||||
strcpy(scrolltext[5]," Tulip");
|
||||
break;
|
||||
|
||||
case 4:
|
||||
strcpy(scrolltext[0],"Thanks to ID Software");
|
||||
strcpy(scrolltext[1],"for the wonderful");
|
||||
strcpy(scrolltext[2],"\"Commander Keen\" series.");
|
||||
strcpy(scrolltext[3],"");
|
||||
strcpy(scrolltext[4],"\"As a child, I spent way too");
|
||||
strcpy(scrolltext[5],"much time playing these games.");
|
||||
break;
|
||||
|
||||
|
||||
case 5:
|
||||
strcpy(scrolltext[0],"And now I have spent way");
|
||||
strcpy(scrolltext[1],"too much time programming");
|
||||
strcpy(scrolltext[2],"this game.");
|
||||
strcpy(scrolltext[3],"");
|
||||
strcpy(scrolltext[4],"...");
|
||||
strcpy(scrolltext[5],"Hmmm... Does history repeat itself?");
|
||||
strcpy(scrolltext[6],":)");
|
||||
break;
|
||||
|
||||
case 6:
|
||||
strcpy(scrolltext[0],"This is my tribute to");
|
||||
strcpy(scrolltext[1],"the \"Keen legacy\".");
|
||||
strcpy(scrolltext[2],"");
|
||||
strcpy(scrolltext[3],"Enjoy the Game.\"");
|
||||
strcpy(scrolltext[4],"");
|
||||
strcpy(scrolltext[5]," -Katy");
|
||||
break;
|
||||
|
||||
default: cancel = true; break;
|
||||
}
|
||||
|
||||
for(int j=0 ; j<7 ; j++)
|
||||
mid[j] = (320-(strlen(scrolltext[j])<<3))>>1;
|
||||
pagenumber++;
|
||||
}
|
||||
}
|
||||
|
||||
for(int j=0 ; j<7 ; j++)
|
||||
g_pGraphics->sb_font_draw_inverse( (unsigned char*) scrolltext[j], mid[j], scrolly+(j<<3));
|
||||
|
||||
if( g_pInput->getPressedAnyCommand() )
|
||||
{
|
||||
cancel = true;
|
||||
fade.dir = FADE_OUT;
|
||||
fade.curamt = PAL_FADE_SHADES;
|
||||
fade.fadetimer = 0;
|
||||
fade.rate = FADE_NORM;
|
||||
fade.mode = FADE_GO;
|
||||
}
|
||||
|
||||
if(g_pInput->getExitEvent()) cancel=true;
|
||||
|
||||
g_pInput->pollEvents();
|
||||
g_pTimer->SpeedThrottle();
|
||||
|
||||
} while(!(cancel && fade.mode == FADE_COMPLETE));
|
||||
|
||||
|
||||
}
|
||||
19
src/vorticon/CCredits.h
Normal file
19
src/vorticon/CCredits.h
Normal file
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* CCredits.h
|
||||
*
|
||||
* Created on: 20.06.2009
|
||||
* Author: gerstrong
|
||||
*/
|
||||
|
||||
#ifndef CCREDITS_H_
|
||||
#define CCREDITS_H_
|
||||
|
||||
class CCredits {
|
||||
public:
|
||||
CCredits();
|
||||
virtual ~CCredits();
|
||||
|
||||
void Render(stCloneKeenPlus *pCKP);
|
||||
};
|
||||
|
||||
#endif /* CCREDITS_H_ */
|
||||
108
src/vorticon/CIntro.cpp
Normal file
108
src/vorticon/CIntro.cpp
Normal file
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* CIntro.cpp
|
||||
*
|
||||
* Created on: 19.06.2009
|
||||
* Author: gerstrong
|
||||
*/
|
||||
|
||||
#include "../keen.h"
|
||||
#include "CIntro.h"
|
||||
#include "../sdl/CTimer.h"
|
||||
#include "../sdl/CInput.h"
|
||||
#include "../CGraphics.h"
|
||||
#include "../include/menu.h"
|
||||
#include "../include/gamedo.h"
|
||||
|
||||
CIntro::CIntro() {
|
||||
// TODO Auto-generated constructor stub
|
||||
|
||||
}
|
||||
|
||||
CIntro::~CIntro() {
|
||||
// TODO Auto-generated destructor stub
|
||||
}
|
||||
|
||||
void CIntro::Render(stCloneKeenPlus *pCKP)
|
||||
{
|
||||
// TODO: Now that the new intro function works, the old one must become
|
||||
// a credits class
|
||||
|
||||
int bmnum[7];
|
||||
int mid[7];
|
||||
int timer = 0;
|
||||
int introtime = 5000; // Total time to elapse until Main menu opens
|
||||
int scrolly = 200;
|
||||
bool cancel=false;
|
||||
|
||||
fade.mode = FADE_GO;
|
||||
fade.rate = FADE_NORM;
|
||||
fade.dir = FADE_IN;
|
||||
fade.curamt = 0;
|
||||
fade.fadetimer = 0;
|
||||
|
||||
showmapatpos(90, 104<<4, 32, 0, pCKP);
|
||||
|
||||
// Load the Title Bitmap
|
||||
bmnum[0] = g_pGraphics->getBitmapNumberFromName("AN");
|
||||
bmnum[1] = g_pGraphics->getBitmapNumberFromName("APOGEE");
|
||||
bmnum[2] = g_pGraphics->getBitmapNumberFromName("PRESENT");
|
||||
bmnum[3] = g_pGraphics->getBitmapNumberFromName("OFAN");
|
||||
bmnum[4] = g_pGraphics->getBitmapNumberFromName("IDSOFT");
|
||||
bmnum[5] = g_pGraphics->getBitmapNumberFromName("SOFTWARE");
|
||||
bmnum[6] = g_pGraphics->getBitmapNumberFromName("PRODUCT");
|
||||
|
||||
for(int j=0 ; j<7 ; j++)
|
||||
mid[j] = (320/2)-(bitmaps[bmnum[j]].xsize/2);
|
||||
|
||||
do
|
||||
{
|
||||
// do fades
|
||||
gamedo_fades();
|
||||
|
||||
|
||||
// blit the scrollbuffer to the display
|
||||
gamedo_frameskipping_blitonly();
|
||||
|
||||
g_pGraphics->drawBitmap(mid[0], scrolly, bmnum[0]);
|
||||
g_pGraphics->drawBitmap(mid[1], scrolly+9, bmnum[1]);
|
||||
g_pGraphics->drawBitmap(mid[2], scrolly+43, bmnum[2]);
|
||||
g_pGraphics->drawBitmap(mid[3], scrolly+56, bmnum[3]);
|
||||
g_pGraphics->drawBitmap(mid[4], scrolly+77, bmnum[4]);
|
||||
g_pGraphics->drawBitmap(mid[5], scrolly+87, bmnum[5]);
|
||||
g_pGraphics->drawBitmap(mid[6], scrolly+120, bmnum[6]);
|
||||
|
||||
gamedo_AnimatedTiles();
|
||||
|
||||
if(fade.mode != FADE_COMPLETE)
|
||||
continue;
|
||||
|
||||
if(timer<7) timer++;
|
||||
else
|
||||
{
|
||||
timer=0;
|
||||
if(scrolly>35) scrolly--;
|
||||
}
|
||||
|
||||
if( g_pInput->getPressedAnyCommand() )
|
||||
{
|
||||
cancel = true;
|
||||
fade.dir = FADE_OUT;
|
||||
fade.curamt = PAL_FADE_SHADES;
|
||||
fade.fadetimer = 0;
|
||||
fade.rate = FADE_NORM;
|
||||
fade.mode = FADE_GO;
|
||||
}
|
||||
|
||||
if(g_pInput->getExitEvent()) cancel=true;
|
||||
|
||||
g_pInput->pollEvents();
|
||||
g_pTimer->SpeedThrottle();
|
||||
|
||||
|
||||
if( introtime <= 0 ) break;
|
||||
introtime--;
|
||||
|
||||
} while(!(cancel && fade.mode == FADE_COMPLETE));
|
||||
|
||||
|
||||
}
|
||||
20
src/vorticon/CIntro.h
Normal file
20
src/vorticon/CIntro.h
Normal file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* CIntro.h
|
||||
*
|
||||
* Created on: 19.06.2009
|
||||
* Author: gerstrong
|
||||
*/
|
||||
|
||||
#ifndef CINTRO_H_
|
||||
#define CINTRO_H_
|
||||
|
||||
|
||||
class CIntro {
|
||||
public:
|
||||
CIntro();
|
||||
virtual ~CIntro();
|
||||
|
||||
void Render(stCloneKeenPlus *pCKP);
|
||||
};
|
||||
|
||||
#endif /* CINTRO_H_ */
|
||||
Reference in New Issue
Block a user