diff --git a/Debug/CommanderGenius b/Debug/CommanderGenius index bf206ca01..76db8f6e1 100755 Binary files a/Debug/CommanderGenius and b/Debug/CommanderGenius differ diff --git a/Debug/src/gamedo.d b/Debug/src/gamedo.d index f30b8f8a8..bddfd3084 100644 --- a/Debug/src/gamedo.d +++ b/Debug/src/gamedo.d @@ -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: diff --git a/Debug/src/sdl/CTimer.d b/Debug/src/sdl/CTimer.d index 72a7d45b4..1a40331a8 100644 --- a/Debug/src/sdl/CTimer.d +++ b/Debug/src/sdl/CTimer.d @@ -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: diff --git a/Linux32/src/hqp/subdir.mk b/Linux32/src/hqp/subdir.mk index df3069b81..70ba00e4a 100644 --- a/Linux32/src/hqp/subdir.mk +++ b/Linux32/src/hqp/subdir.mk @@ -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 diff --git a/Linux32/src/sdl/subdir.mk b/Linux32/src/sdl/subdir.mk index f8b1235e6..bb5d677b4 100644 --- a/Linux32/src/sdl/subdir.mk +++ b/Linux32/src/sdl/subdir.mk @@ -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 diff --git a/Linux64/src/hqp/subdir.mk b/Linux64/src/hqp/subdir.mk index 46430c647..cb05aff8c 100644 --- a/Linux64/src/hqp/subdir.mk +++ b/Linux64/src/hqp/subdir.mk @@ -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 diff --git a/Linux64/src/sdl/subdir.mk b/Linux64/src/sdl/subdir.mk index 7cd0d07d4..43a2fb4ba 100644 --- a/Linux64/src/sdl/subdir.mk +++ b/Linux64/src/sdl/subdir.mk @@ -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 diff --git a/changelog.txt b/changelog.txt index 7b709396f..350518a62 100644 --- a/changelog.txt +++ b/changelog.txt @@ -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 diff --git a/readme.txt b/readme.txt index ea0f31366..6305bbe66 100644 --- a/readme.txt +++ b/readme.txt @@ -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) diff --git a/src/CLogFile.h b/src/CLogFile.h index ae733eb16..13de5505c 100644 --- a/src/CLogFile.h +++ b/src/CLogFile.h @@ -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 #include "CSingleton.h" diff --git a/src/gamedo.cpp b/src/gamedo.cpp index e3c8ebd56..440cdcecd 100644 --- a/src/gamedo.cpp +++ b/src/gamedo.cpp @@ -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" diff --git a/src/main.cpp b/src/main.cpp index d0894c718..6265840ea 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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")); diff --git a/src/menu.cpp b/src/menu.cpp index dcfb233fb..683ef9fdc 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -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(); diff --git a/src/sdl/CTimer.cpp b/src/sdl/CTimer.cpp index 26fac9fdc..338f1274e 100644 --- a/src/sdl/CTimer.cpp +++ b/src/sdl/CTimer.cpp @@ -8,24 +8,9 @@ #include "../keen.h" #include "../keenext.h" -#include #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(). */ } - diff --git a/src/sdl/CTimer.h b/src/sdl/CTimer.h index 9d6f30356..5bffda09c 100644 --- a/src/sdl/CTimer.h +++ b/src/sdl/CTimer.h @@ -12,8 +12,25 @@ #include "../CSingleton.h" #define g_pTimer CTimer::Get() +#include + 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 { 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_ */ diff --git a/src/sdl/CVideoDriver.cpp b/src/sdl/CVideoDriver.cpp index 762cbb033..ffbc2ac4e 100644 --- a/src/sdl/CVideoDriver.cpp +++ b/src/sdl/CVideoDriver.cpp @@ -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
"); 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(); diff --git a/src/sdl/CVideoDriver.h b/src/sdl/CVideoDriver.h index 29e2ebe9d..783d58e92 100644 --- a/src/sdl/CVideoDriver.h +++ b/src/sdl/CVideoDriver.h @@ -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;