Main Changes:

- Added automatic frameskip support
- Improved Timers speed

git-svn-id: https://clonekeenplus.svn.sourceforge.net/svnroot/clonekeenplus/cgenius/trunk@6 4df4b0f3-56ce-47cb-b001-ed939b7d65a6
This commit is contained in:
gerstrong
2009-06-07 11:44:08 +00:00
parent 563103b890
commit 8352242dc6
17 changed files with 194 additions and 57 deletions

Binary file not shown.

View File

@@ -18,11 +18,12 @@ src/gamedo.d src/gamedo.o: ../src/gamedo.cpp ../src/keen.h \
../src/include/gamepdo.h ../src/include/misc.h \
../src/sdl/CVideoDriver.h ../src/sdl/../CSingleton.h \
../src/sdl/COpenGL.h /usr/include/SDL/SDL_opengl.h \
../src/sdl/../scale2x/scalebit.h ../src/sdl/sound/CSound.h \
../src/sdl/../scale2x/scalebit.h ../src/sdl/CTimer.h \
../src/sdl/CInput.h ../src/sdl/sound/CSound.h \
../src/sdl/sound/../../CSingleton.h ../src/sdl/sound/CSoundChannel.h \
../src/sdl/sound/CSoundSlot.h ../src/sdl/sound/../../hqp/hq_sound.h \
../src/CGraphics.h ../src/CSingleton.h ../src/hqp/CHQBitmap.h \
../src/sdl/CInput.h ../src/vorticon/CPlayer.h ../src/include/enemyai.h
../src/vorticon/CPlayer.h ../src/include/enemyai.h
../src/keen.h:
@@ -110,6 +111,10 @@ src/gamedo.d src/gamedo.o: ../src/gamedo.cpp ../src/keen.h \
../src/sdl/../scale2x/scalebit.h:
../src/sdl/CTimer.h:
../src/sdl/CInput.h:
../src/sdl/sound/CSound.h:
../src/sdl/sound/../../CSingleton.h:
@@ -126,8 +131,6 @@ src/gamedo.d src/gamedo.o: ../src/gamedo.cpp ../src/keen.h \
../src/hqp/CHQBitmap.h:
../src/sdl/CInput.h:
../src/vorticon/CPlayer.h:
../src/include/enemyai.h:

View File

@@ -16,7 +16,9 @@ src/sdl/CTimer.d src/sdl/CTimer.o: ../src/sdl/CTimer.cpp \
/usr/include/SDL/SDL_loadso.h /usr/include/SDL/SDL_timer.h \
/usr/include/SDL/SDL_version.h ../src/sdl/../include/declarations.h \
../src/sdl/../keenext.h ../src/sdl/../keenext.h ../src/sdl/CTimer.h \
../src/sdl/../CSingleton.h
../src/sdl/../CSingleton.h ../src/sdl/CVideoDriver.h \
../src/sdl/COpenGL.h /usr/include/SDL/SDL_opengl.h \
../src/sdl/../scale2x/scalebit.h
../src/sdl/../keen.h:
@@ -91,3 +93,11 @@ src/sdl/CTimer.d src/sdl/CTimer.o: ../src/sdl/CTimer.cpp \
../src/sdl/CTimer.h:
../src/sdl/../CSingleton.h:
../src/sdl/CVideoDriver.h:
../src/sdl/COpenGL.h:
/usr/include/SDL/SDL_opengl.h:
../src/sdl/../scale2x/scalebit.h:

View File

@@ -6,20 +6,17 @@
CPP_SRCS += \
../src/hqp/CHQBitmap.cpp \
../src/hqp/CMusic.cpp \
../src/hqp/hq_sound.cpp \
../src/hqp/musicdrv.cpp
../src/hqp/hq_sound.cpp
OBJS += \
./src/hqp/CHQBitmap.o \
./src/hqp/CMusic.o \
./src/hqp/hq_sound.o \
./src/hqp/musicdrv.o
./src/hqp/hq_sound.o
CPP_DEPS += \
./src/hqp/CHQBitmap.d \
./src/hqp/CMusic.d \
./src/hqp/hq_sound.d \
./src/hqp/musicdrv.d
./src/hqp/hq_sound.d
# Each subdirectory must supply rules for building sources it contributes

View File

@@ -5,18 +5,21 @@
# Add inputs and outputs from these tool invocations to the build variables
CPP_SRCS += \
../src/sdl/CInput.cpp \
../src/sdl/COpenGL.cpp \
../src/sdl/CTimer.cpp \
../src/sdl/CVideoDriver.cpp \
../src/sdl/joydrv.cpp
OBJS += \
./src/sdl/CInput.o \
./src/sdl/COpenGL.o \
./src/sdl/CTimer.o \
./src/sdl/CVideoDriver.o \
./src/sdl/joydrv.o
CPP_DEPS += \
./src/sdl/CInput.d \
./src/sdl/COpenGL.d \
./src/sdl/CTimer.d \
./src/sdl/CVideoDriver.d \
./src/sdl/joydrv.d

View File

@@ -6,20 +6,17 @@
CPP_SRCS += \
../src/hqp/CHQBitmap.cpp \
../src/hqp/CMusic.cpp \
../src/hqp/hq_sound.cpp \
../src/hqp/musicdrv.cpp
../src/hqp/hq_sound.cpp
OBJS += \
./src/hqp/CHQBitmap.o \
./src/hqp/CMusic.o \
./src/hqp/hq_sound.o \
./src/hqp/musicdrv.o
./src/hqp/hq_sound.o
CPP_DEPS += \
./src/hqp/CHQBitmap.d \
./src/hqp/CMusic.d \
./src/hqp/hq_sound.d \
./src/hqp/musicdrv.d
./src/hqp/hq_sound.d
# Each subdirectory must supply rules for building sources it contributes

View File

@@ -5,18 +5,21 @@
# Add inputs and outputs from these tool invocations to the build variables
CPP_SRCS += \
../src/sdl/CInput.cpp \
../src/sdl/COpenGL.cpp \
../src/sdl/CTimer.cpp \
../src/sdl/CVideoDriver.cpp \
../src/sdl/joydrv.cpp
OBJS += \
./src/sdl/CInput.o \
./src/sdl/COpenGL.o \
./src/sdl/CTimer.o \
./src/sdl/CVideoDriver.o \
./src/sdl/joydrv.o
CPP_DEPS += \
./src/sdl/CInput.d \
./src/sdl/COpenGL.d \
./src/sdl/CTimer.d \
./src/sdl/CVideoDriver.d \
./src/sdl/joydrv.d

View File

@@ -1,8 +1,13 @@
Commander Genius v0.2.9.0a Beta (CloneKeenPlus):
------------------------------------------------
Commander Genius v0.2.9.1 Beta (CloneKeenPlus):
-----------------------------------------------
07-06-2009
- Improved the timer
- Improved blit-speed at resolution of 320x200
- Added automatic-frameskip
05-06-2009
- Fixed OpenGL slowdowns and bugs
- Fixed some OpenGL slowdowns and bugs
04-06-2009
- Fixed a crash when loading game with Fullscreen settings

View File

@@ -6,9 +6,10 @@
* *
* (c)2008-2009 Gerstrong *
* (c)2003-2005 Caitlin Shaw *
* (c)2009 Pickle *
* Released under GNU/GPL *
* *
* Beta v0.2.9.0 *
* Beta v0.2.9.1 *
* *
*************************************
Welcome to CloneKeenPlus (Commander Genius)!
@@ -82,8 +83,11 @@ Setting up the data of the game:
You only have to modify the "games.cfg".
* Only Linux/Unix Users: If you have many data files which upper-case,
use the "./data/renlower.sh" shell script to rename them.
* Go into the "Release" folder and start the interpreter.
* If you want better sounds and music, please download the high quality pack.
* Go into the Release folder and start the interpreter. If you have downloaded
the binary version of Commander Genius (for Windows, Linux32/64), then you
will find the executable in the root directory of the extracted game.
Under Linux it is called "CommanderGenius", under Windows "CGenius.exe".
* If you want better sounds and music, please download the high quality pack (HQP).
Extract its contents to the "data" directory together with your game data.
Howto use CloneKeenPlus (If you didn't compile it):
@@ -143,6 +147,27 @@ allowed save at the map).
Wait a while at the tile screen and the game will cycle through several
demos, an added feature not found on the original game.
- FAQ -
Q: When I change to opengl-mode, the screen gets white and I can't do anything! I have to kill the program.
What can I do to restore the normal mode?
A: You can delete "cgenius.cfg" or change it the way you need it! Just put "opengl = 0" and it should normal
with your previous settings. I'm going to fix that soon! The white screen means, that your graphic card
doesn't support NPOT Textures, which is required. A video card with OpenGL 2.0 or later support should not
have that problem anymore.
Q: Why not to use POT-Textures?
A: Because it requires more memory to write, and the game would get slower than with software rendering.
I'm working on a new method to get it working with POT Textures and faster, but for now I cannot
support it.
Q: Commander Genius is slow? Please help!
A: You can increase the frameskip under settings->video or you can enable automatic frameskip, what is very
recommended for any system. OpenGL may also help, but you must have a gfx-card that support NPOT-Textures.
(OpenGL 2.0 or later). Try to lower the resolution, a lower filter, or decrease some stuff in the sound section.
Stereo sound requires additional calculations than mono sound. There are many things you can do, to speed up
the program.
- BUG! -
So you really found one or more bugs? Please report me those per e-mail (gerstrong@gmail.com)

View File

@@ -8,7 +8,7 @@
#ifndef CLOGFILE_H_
#define CLOGFILE_H_
#define REVISION "CloneKeenPlus Beta v0.2.9.0 (Commander Genius)"
#define REVISION "CloneKeenPlus Beta v0.2.9.1 (Commander Genius)"
#include <stdio.h>
#include "CSingleton.h"

View File

@@ -11,9 +11,10 @@
#include "include/gamepdo.h"
#include "include/misc.h"
#include "sdl/CVideoDriver.h"
#include "sdl/CTimer.h"
#include "sdl/CInput.h"
#include "sdl/sound/CSound.h"
#include "CGraphics.h"
#include "sdl/CInput.h"
#include "vorticon/CPlayer.h"
#include "keenext.h"

View File

@@ -488,6 +488,7 @@ short saveDriverConfiguration(stCloneKeenPlus *pCKP)
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("channels","Audio",(g_pSound->getAudioSpec()).channels);
Parser.saveIntValue("format","Audio",(g_pSound->getAudioSpec()).format);
@@ -528,6 +529,7 @@ short loadDriverConfiguration(stCloneKeenPlus *pCKP)
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"));

View File

@@ -643,6 +643,7 @@ short GraphicsDlg(stCloneKeenPlus *pCKP)
bool fsmode;
char buf[256];
short retval = 0;
unsigned char autoframeskip = 0;
showmapatpos(90, MAINMENU_X, MENUS_Y, 0, pCKP);
@@ -718,6 +719,24 @@ short GraphicsDlg(stCloneKeenPlus *pCKP)
else
DisplayMenu->addOptionText("Software Rendering");
autoframeskip = g_pVideoDriver->getTargetFPS();
switch(autoframeskip)
{
case 60:
DisplayMenu->addOptionText("Auto-Frameskip : 60 fps"); break;
case 50:
DisplayMenu->addOptionText("Auto-Frameskip : 50 fps"); break;
case 40:
DisplayMenu->addOptionText("Auto-Frameskip : 40 fps"); break;
case 30:
DisplayMenu->addOptionText("Auto-Frameskip : 30 fps"); break;
case 20:
DisplayMenu->addOptionText("Auto-Frameskip : 20 fps"); break;
default:
DisplayMenu->addOptionText("Auto-Frameskip disabled"); break;
};
DisplayMenu->addSeparator();
DisplayMenu->addOptionText("Save and return");
DisplayMenu->addOptionText("Cancel");
@@ -843,7 +862,32 @@ short GraphicsDlg(stCloneKeenPlus *pCKP)
else
DisplayMenu->setOptionText(5,"Software Rendering");
}
else if(selection == 7)
else if(selection == 6)
{
if(autoframeskip < 60 && autoframeskip >= 0)
autoframeskip += 10;
else
autoframeskip = 0;
switch(autoframeskip)
{
case 60:
DisplayMenu->setOptionText(6,"Auto-Frameskip : 60 fps"); break;
case 50:
DisplayMenu->setOptionText(6,"Auto-Frameskip : 50 fps"); break;
case 40:
DisplayMenu->setOptionText(6,"Auto-Frameskip : 40 fps"); break;
case 30:
DisplayMenu->setOptionText(6,"Auto-Frameskip : 30 fps"); break;
case 20:
DisplayMenu->setOptionText(6,"Auto-Frameskip : 20 fps"); break;
case 10:
DisplayMenu->setOptionText(6,"Auto-Frameskip : 10 fps"); break;
default:
DisplayMenu->setOptionText(6,"Auto-Frameskip disabled"); break;
};
}
else if(selection == 8)
{
g_pVideoDriver->stop();
@@ -858,6 +902,7 @@ short GraphicsDlg(stCloneKeenPlus *pCKP)
g_pVideoDriver->setZoom(zoom);
g_pVideoDriver->setFilter(filter);
g_pVideoDriver->setFrameskip(frameskip);
g_pVideoDriver->setTargetFPS(autoframeskip);
saveDriverConfiguration(pCKP);
g_pGraphics->allocScrollBufmem();

View File

@@ -8,24 +8,9 @@
#include "../keen.h"
#include "../keenext.h"
#include <SDL.h>
#include "CTimer.h"
typedef char int8;
typedef short int16;
typedef long int32;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned long uint32;
#ifdef __GNUC__
typedef unsigned long long uint64;
typedef long long int64;
#define INLINE inline
#define GINLINE inline
#endif
#include "CVideoDriver.h"
Uint32 FPSCallback(Uint32 interval, void* param);
@@ -38,6 +23,34 @@ Uint32 FPSCallback(Uint32 interval, void* param)
{
fps = (curfps << 1);
curfps = 0;
unsigned char targetfps;
targetfps = g_pVideoDriver->getTargetFPS();
if(targetfps > 0)
{
if(fps > targetfps + 10)
{
uint8 fsk;
fsk = g_pVideoDriver->getFrameskip();
if(fsk < 20)
fsk++;
g_pVideoDriver->setFrameskip(fsk);
}
else if( fps < targetfps - 10)
{
uint8 fsk;
fsk = g_pVideoDriver->getFrameskip();
if(fsk > 0)
fsk--;
g_pVideoDriver->setFrameskip(fsk);
}
}
return interval;
}
@@ -45,6 +58,9 @@ CTimer::CTimer() {
RefreshThrottleFPS();
if(SDL_Init(SDL_INIT_TIMER) == 0)
ckp_timer_id = SDL_AddTimer(1000, FPSCallback, NULL);
ltime = 0;
m_frameskip = 0;
}
CTimer::~CTimer() {
@@ -53,22 +69,23 @@ CTimer::~CTimer() {
void CTimer::SpeedThrottle(void)
{
static uint64 ttime,ltime=0;
//regulateFrameskip();
waiter:
ttime=SDL_GetTicks();
ttime*=10000;
//ttime*=10000;
ttime<<=14;
if( (ttime-ltime) < (tfreq/desiredfps) )
{
int64 delay;
delay=(tfreq/desiredfps)-(ttime-ltime);
if(delay>0)
SDL_Delay(delay/10000);
goto waiter;
delay=(tfreq/desiredfps)-(ttime-ltime);
if(delay>0)
//SDL_Delay(delay/10000);
SDL_Delay(delay>>14);
goto waiter;
}
if( (ttime-ltime) >= (tfreq*4/desiredfps))
if( (ttime-ltime) >= ((tfreq<<2)/desiredfps) )
ltime=ttime;
else
ltime+=tfreq/desiredfps;
@@ -77,8 +94,8 @@ void CTimer::RefreshThrottleFPS(void)
{
// desiredfps=FCEUI_GetDesiredFPS()>>8;
// desiredfps = 23000000;
desiredfps = 21800000;
//desiredfps = 21800000;
desiredfps = 13600000;
tfreq=10000000;
tfreq<<=16; /* Adjustment for fps returned from FCEUI_GetDesiredFPS(). */
}

View File

@@ -12,8 +12,25 @@
#include "../CSingleton.h"
#define g_pTimer CTimer::Get()
#include <SDL.h>
void initTimer(void);
typedef char int8;
typedef short int16;
typedef long int32;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned long uint32;
#ifdef __GNUC__
typedef unsigned long long uint64;
typedef long long int64;
#define INLINE inline
#define GINLINE inline
#endif
class CTimer : public CSingleton<CTimer>
{
public:
@@ -23,7 +40,18 @@ public:
void SpeedThrottle(void);
void RefreshThrottleFPS(void);
uint8 getFrameskip(void){ return m_frameskip; }
void setFrameskip(uint8 frameskip){ m_frameskip = frameskip; }
private:
uint64 ttime;
uint64 ltime;
int64 delay;
uint64 m_timepoint;
uint64 m_elaptime;
uint8 m_frameskip;
};
#endif /* CTIMER_H_ */

View File

@@ -55,6 +55,7 @@ CVideoDriver::CVideoDriver() {
Filtermode=1;
Zoom=2;
FrameSkip=2;
m_targetfps = 0; // Disable automatic frameskipping by default
m_opengl = false;
m_opengl_filter = GL_NEAREST;
mp_OpenGL = NULL;
@@ -220,7 +221,7 @@ bool CVideoDriver::createSurfaces(void)
//Set surface alpha
SDL_SetAlpha( FGLayerSurface, SDL_SRCALPHA, 225 );
if(Width == 320)
if(Width == 320 && !m_opengl)
{
g_pLogFile->textOut("Blitsurface = Screen<br>");
BlitSurface = screen;
@@ -244,10 +245,6 @@ bool CVideoDriver::createSurfaces(void)
dstrect.w = GAME_STD_WIDTH;
dstrect.h = GAME_STD_HEIGHT;
// TODO: If OpenGL used, do we still need this?
if(m_opengl) // If OpenGL could be set, initialize the matrices
{
mp_OpenGL = new COpenGL();

View File

@@ -66,6 +66,9 @@ public:
void enableOpenGL(bool value) { m_opengl = value; }
void setOGLFilter(unsigned char value) { m_opengl_filter = (value==1) ? GL_LINEAR : GL_NEAREST ; }
void setTargetFPS(unsigned char targetfps){ if( targetfps >= 0 && targetfps <= 60 ) m_targetfps = targetfps; }
unsigned char getTargetFPS(void){ return m_targetfps; }
void showFPS(bool value);
private:
@@ -79,6 +82,7 @@ private:
short Filtermode;
unsigned short Zoom;
unsigned short FrameSkip;
unsigned char m_targetfps; // Used for automatic frame skipping
bool showfps;
bool m_opengl;
int m_opengl_filter;