From 053a44eeae4d9fa73f586bd3ca6d170788002d06 Mon Sep 17 00:00:00 2001 From: gerstrong Date: Sat, 20 Jun 2009 18:08:58 +0000 Subject: [PATCH] update 20.06.2009 git-svn-id: https://clonekeenplus.svn.sourceforge.net/svnroot/clonekeenplus/cgenius/trunk@27 4df4b0f3-56ce-47cb-b001-ed939b7d65a6 --- Debug/src/sdl/subdir.mk | 3 + Debug/src/vorticon/subdir.mk | 6 + Linux32/src/ai/subdir.mk | 2 +- Linux32/src/fileio/subdir.mk | 2 +- Linux32/src/hqp/subdir.mk | 2 +- Linux32/src/scale2x/subdir.mk | 2 +- Linux32/src/sdl/sound/subdir.mk | 2 +- Linux32/src/sdl/subdir.mk | 5 +- Linux32/src/sdl/video/subdir.mk | 2 +- Linux32/src/subdir.mk | 2 +- Linux32/src/vorbis/subdir.mk | 2 +- Linux32/src/vorticon/subdir.mk | 8 +- Linux64/src/ai/subdir.mk | 2 +- Linux64/src/fileio/subdir.mk | 2 +- Linux64/src/hqp/subdir.mk | 2 +- Linux64/src/scale2x/subdir.mk | 2 +- Linux64/src/sdl/sound/subdir.mk | 2 +- Linux64/src/sdl/subdir.mk | 5 +- Linux64/src/sdl/video/subdir.mk | 2 +- Linux64/src/subdir.mk | 2 +- Linux64/src/vorbis/subdir.mk | 2 +- Linux64/src/vorticon/subdir.mk | 8 +- Windows/src/ai/subdir.mk | 2 +- Windows/src/fileio/subdir.mk | 2 +- Windows/src/hqp/subdir.mk | 2 +- Windows/src/scale2x/subdir.mk | 2 +- Windows/src/sdl/sound/subdir.mk | 2 +- Windows/src/sdl/subdir.mk | 5 +- Windows/src/sdl/video/subdir.mk | 2 +- Windows/src/subdir.mk | 2 +- Windows/src/vorbis/subdir.mk | 2 +- Windows/src/vorticon/subdir.mk | 8 +- src/CGame.cpp | 229 +++++++++- src/CGame.h | 4 +- src/CGraphics.cpp | 2 + src/CLatch.cpp | 12 +- src/CLogFile.h | 2 +- src/eseq_ep1.cpp | 2 +- src/eseq_ep2.cpp | 2 +- src/game.cpp | 4 +- src/gamedo.cpp | 177 +++----- src/gamepdo.cpp | 6 +- src/include/declarations.h | 18 - src/include/gamedo.h | 2 +- src/include/main.h | 3 - src/include/menu.h | 1 - src/keen.h | 10 +- src/keenext.h | 3 +- src/main.cpp | 429 ++----------------- src/menu.cpp | 721 ++++++++------------------------ src/sdl/CInput.cpp | 261 +++++++----- src/sdl/CInput.h | 15 +- src/sdl/COpenGL.cpp | 7 +- src/sdl/COpenGL.h | 2 +- src/sdl/CTimer.cpp | 2 +- src/sdl/CVideoDriver.cpp | 112 +++-- src/sdl/CVideoDriver.h | 7 +- src/sdl/sound/CSound.cpp | 7 +- 58 files changed, 838 insertions(+), 1298 deletions(-) diff --git a/Debug/src/sdl/subdir.mk b/Debug/src/sdl/subdir.mk index d340cecc8..8b3c974ff 100644 --- a/Debug/src/sdl/subdir.mk +++ b/Debug/src/sdl/subdir.mk @@ -6,6 +6,7 @@ CPP_SRCS += \ ../src/sdl/CInput.cpp \ ../src/sdl/COpenGL.cpp \ +../src/sdl/CSettings.cpp \ ../src/sdl/CTimer.cpp \ ../src/sdl/CVideoDriver.cpp \ ../src/sdl/joydrv.cpp @@ -13,6 +14,7 @@ CPP_SRCS += \ OBJS += \ ./src/sdl/CInput.o \ ./src/sdl/COpenGL.o \ +./src/sdl/CSettings.o \ ./src/sdl/CTimer.o \ ./src/sdl/CVideoDriver.o \ ./src/sdl/joydrv.o @@ -20,6 +22,7 @@ OBJS += \ CPP_DEPS += \ ./src/sdl/CInput.d \ ./src/sdl/COpenGL.d \ +./src/sdl/CSettings.d \ ./src/sdl/CTimer.d \ ./src/sdl/CVideoDriver.d \ ./src/sdl/joydrv.d diff --git a/Debug/src/vorticon/subdir.mk b/Debug/src/vorticon/subdir.mk index d09a1d383..f8e77cbbf 100644 --- a/Debug/src/vorticon/subdir.mk +++ b/Debug/src/vorticon/subdir.mk @@ -4,20 +4,26 @@ # Add inputs and outputs from these tool invocations to the build variables CPP_SRCS += \ +../src/vorticon/CCredits.cpp \ ../src/vorticon/CDialog.cpp \ ../src/vorticon/CHighScores.cpp \ +../src/vorticon/CIntro.cpp \ ../src/vorticon/CObject.cpp \ ../src/vorticon/CPlayer.cpp OBJS += \ +./src/vorticon/CCredits.o \ ./src/vorticon/CDialog.o \ ./src/vorticon/CHighScores.o \ +./src/vorticon/CIntro.o \ ./src/vorticon/CObject.o \ ./src/vorticon/CPlayer.o CPP_DEPS += \ +./src/vorticon/CCredits.d \ ./src/vorticon/CDialog.d \ ./src/vorticon/CHighScores.d \ +./src/vorticon/CIntro.d \ ./src/vorticon/CObject.d \ ./src/vorticon/CPlayer.d diff --git a/Linux32/src/ai/subdir.mk b/Linux32/src/ai/subdir.mk index 37d365b0f..74cc684a1 100644 --- a/Linux32/src/ai/subdir.mk +++ b/Linux32/src/ai/subdir.mk @@ -95,7 +95,7 @@ CPP_DEPS += \ src/ai/%.o: ../src/ai/%.cpp @echo 'Building file: $<' @echo 'Invoking: GCC C++ Compiler' - g++ -DBUILD_SDL -D__i386__ -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O3 -Wall -c -fmessage-length=0 -m32 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" + g++ -DBUILD_SDL -DUSE_OPENGL -D__i386__ -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O3 -Wall -c -fmessage-length=0 -m32 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" @echo 'Finished building: $<' @echo ' ' diff --git a/Linux32/src/fileio/subdir.mk b/Linux32/src/fileio/subdir.mk index acf6eb2a4..aad1c288d 100644 --- a/Linux32/src/fileio/subdir.mk +++ b/Linux32/src/fileio/subdir.mk @@ -26,7 +26,7 @@ CPP_DEPS += \ src/fileio/%.o: ../src/fileio/%.cpp @echo 'Building file: $<' @echo 'Invoking: GCC C++ Compiler' - g++ -DBUILD_SDL -D__i386__ -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O3 -Wall -c -fmessage-length=0 -m32 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" + g++ -DBUILD_SDL -DUSE_OPENGL -D__i386__ -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O3 -Wall -c -fmessage-length=0 -m32 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" @echo 'Finished building: $<' @echo ' ' diff --git a/Linux32/src/hqp/subdir.mk b/Linux32/src/hqp/subdir.mk index 70ba00e4a..4f78054f2 100644 --- a/Linux32/src/hqp/subdir.mk +++ b/Linux32/src/hqp/subdir.mk @@ -23,7 +23,7 @@ CPP_DEPS += \ src/hqp/%.o: ../src/hqp/%.cpp @echo 'Building file: $<' @echo 'Invoking: GCC C++ Compiler' - g++ -DBUILD_SDL -D__i386__ -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O3 -Wall -c -fmessage-length=0 -m32 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" + g++ -DBUILD_SDL -DUSE_OPENGL -D__i386__ -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O3 -Wall -c -fmessage-length=0 -m32 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" @echo 'Finished building: $<' @echo ' ' diff --git a/Linux32/src/scale2x/subdir.mk b/Linux32/src/scale2x/subdir.mk index 4ae53e06a..397e8dd55 100644 --- a/Linux32/src/scale2x/subdir.mk +++ b/Linux32/src/scale2x/subdir.mk @@ -29,7 +29,7 @@ CPP_DEPS += \ src/scale2x/%.o: ../src/scale2x/%.cpp @echo 'Building file: $<' @echo 'Invoking: GCC C++ Compiler' - g++ -DBUILD_SDL -D__i386__ -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O3 -Wall -c -fmessage-length=0 -m32 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" + g++ -DBUILD_SDL -DUSE_OPENGL -D__i386__ -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O3 -Wall -c -fmessage-length=0 -m32 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" @echo 'Finished building: $<' @echo ' ' diff --git a/Linux32/src/sdl/sound/subdir.mk b/Linux32/src/sdl/sound/subdir.mk index e3a9811e4..0e143a1d0 100644 --- a/Linux32/src/sdl/sound/subdir.mk +++ b/Linux32/src/sdl/sound/subdir.mk @@ -23,7 +23,7 @@ CPP_DEPS += \ src/sdl/sound/%.o: ../src/sdl/sound/%.cpp @echo 'Building file: $<' @echo 'Invoking: GCC C++ Compiler' - g++ -DBUILD_SDL -D__i386__ -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O3 -Wall -c -fmessage-length=0 -m32 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" + g++ -DBUILD_SDL -DUSE_OPENGL -D__i386__ -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O3 -Wall -c -fmessage-length=0 -m32 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" @echo 'Finished building: $<' @echo ' ' diff --git a/Linux32/src/sdl/subdir.mk b/Linux32/src/sdl/subdir.mk index bb5d677b4..0d62afb29 100644 --- a/Linux32/src/sdl/subdir.mk +++ b/Linux32/src/sdl/subdir.mk @@ -6,6 +6,7 @@ CPP_SRCS += \ ../src/sdl/CInput.cpp \ ../src/sdl/COpenGL.cpp \ +../src/sdl/CSettings.cpp \ ../src/sdl/CTimer.cpp \ ../src/sdl/CVideoDriver.cpp \ ../src/sdl/joydrv.cpp @@ -13,6 +14,7 @@ CPP_SRCS += \ OBJS += \ ./src/sdl/CInput.o \ ./src/sdl/COpenGL.o \ +./src/sdl/CSettings.o \ ./src/sdl/CTimer.o \ ./src/sdl/CVideoDriver.o \ ./src/sdl/joydrv.o @@ -20,6 +22,7 @@ OBJS += \ CPP_DEPS += \ ./src/sdl/CInput.d \ ./src/sdl/COpenGL.d \ +./src/sdl/CSettings.d \ ./src/sdl/CTimer.d \ ./src/sdl/CVideoDriver.d \ ./src/sdl/joydrv.d @@ -29,7 +32,7 @@ CPP_DEPS += \ src/sdl/%.o: ../src/sdl/%.cpp @echo 'Building file: $<' @echo 'Invoking: GCC C++ Compiler' - g++ -DBUILD_SDL -D__i386__ -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O3 -Wall -c -fmessage-length=0 -m32 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" + g++ -DBUILD_SDL -DUSE_OPENGL -D__i386__ -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O3 -Wall -c -fmessage-length=0 -m32 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" @echo 'Finished building: $<' @echo ' ' diff --git a/Linux32/src/sdl/video/subdir.mk b/Linux32/src/sdl/video/subdir.mk index c492ee662..4eea1daa3 100644 --- a/Linux32/src/sdl/video/subdir.mk +++ b/Linux32/src/sdl/video/subdir.mk @@ -17,7 +17,7 @@ CPP_DEPS += \ src/sdl/video/%.o: ../src/sdl/video/%.cpp @echo 'Building file: $<' @echo 'Invoking: GCC C++ Compiler' - g++ -DBUILD_SDL -D__i386__ -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O3 -Wall -c -fmessage-length=0 -m32 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" + g++ -DBUILD_SDL -DUSE_OPENGL -D__i386__ -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O3 -Wall -c -fmessage-length=0 -m32 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" @echo 'Finished building: $<' @echo ' ' diff --git a/Linux32/src/subdir.mk b/Linux32/src/subdir.mk index 4847eb190..f0641fb63 100644 --- a/Linux32/src/subdir.mk +++ b/Linux32/src/subdir.mk @@ -74,7 +74,7 @@ CPP_DEPS += \ src/%.o: ../src/%.cpp @echo 'Building file: $<' @echo 'Invoking: GCC C++ Compiler' - g++ -DBUILD_SDL -D__i386__ -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O3 -Wall -c -fmessage-length=0 -m32 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" + g++ -DBUILD_SDL -DUSE_OPENGL -D__i386__ -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O3 -Wall -c -fmessage-length=0 -m32 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" @echo 'Finished building: $<' @echo ' ' diff --git a/Linux32/src/vorbis/subdir.mk b/Linux32/src/vorbis/subdir.mk index 94d6e5717..5acfd8eb7 100644 --- a/Linux32/src/vorbis/subdir.mk +++ b/Linux32/src/vorbis/subdir.mk @@ -17,7 +17,7 @@ CPP_DEPS += \ src/vorbis/%.o: ../src/vorbis/%.cpp @echo 'Building file: $<' @echo 'Invoking: GCC C++ Compiler' - g++ -DBUILD_SDL -D__i386__ -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O3 -Wall -c -fmessage-length=0 -m32 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" + g++ -DBUILD_SDL -DUSE_OPENGL -D__i386__ -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O3 -Wall -c -fmessage-length=0 -m32 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" @echo 'Finished building: $<' @echo ' ' diff --git a/Linux32/src/vorticon/subdir.mk b/Linux32/src/vorticon/subdir.mk index ca7f2b518..036ab6a2b 100644 --- a/Linux32/src/vorticon/subdir.mk +++ b/Linux32/src/vorticon/subdir.mk @@ -4,20 +4,26 @@ # Add inputs and outputs from these tool invocations to the build variables CPP_SRCS += \ +../src/vorticon/CCredits.cpp \ ../src/vorticon/CDialog.cpp \ ../src/vorticon/CHighScores.cpp \ +../src/vorticon/CIntro.cpp \ ../src/vorticon/CObject.cpp \ ../src/vorticon/CPlayer.cpp OBJS += \ +./src/vorticon/CCredits.o \ ./src/vorticon/CDialog.o \ ./src/vorticon/CHighScores.o \ +./src/vorticon/CIntro.o \ ./src/vorticon/CObject.o \ ./src/vorticon/CPlayer.o CPP_DEPS += \ +./src/vorticon/CCredits.d \ ./src/vorticon/CDialog.d \ ./src/vorticon/CHighScores.d \ +./src/vorticon/CIntro.d \ ./src/vorticon/CObject.d \ ./src/vorticon/CPlayer.d @@ -26,7 +32,7 @@ CPP_DEPS += \ src/vorticon/%.o: ../src/vorticon/%.cpp @echo 'Building file: $<' @echo 'Invoking: GCC C++ Compiler' - g++ -DBUILD_SDL -D__i386__ -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O3 -Wall -c -fmessage-length=0 -m32 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" + g++ -DBUILD_SDL -DUSE_OPENGL -D__i386__ -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O3 -Wall -c -fmessage-length=0 -m32 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" @echo 'Finished building: $<' @echo ' ' diff --git a/Linux64/src/ai/subdir.mk b/Linux64/src/ai/subdir.mk index 3a68c626d..77b0ba948 100644 --- a/Linux64/src/ai/subdir.mk +++ b/Linux64/src/ai/subdir.mk @@ -95,7 +95,7 @@ CPP_DEPS += \ src/ai/%.o: ../src/ai/%.cpp @echo 'Building file: $<' @echo 'Invoking: GCC C++ Compiler' - g++ -DBUILD_SDL -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" + g++ -DBUILD_SDL -DUSE_OPENGL -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" @echo 'Finished building: $<' @echo ' ' diff --git a/Linux64/src/fileio/subdir.mk b/Linux64/src/fileio/subdir.mk index d1c65773d..525b094f4 100644 --- a/Linux64/src/fileio/subdir.mk +++ b/Linux64/src/fileio/subdir.mk @@ -26,7 +26,7 @@ CPP_DEPS += \ src/fileio/%.o: ../src/fileio/%.cpp @echo 'Building file: $<' @echo 'Invoking: GCC C++ Compiler' - g++ -DBUILD_SDL -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" + g++ -DBUILD_SDL -DUSE_OPENGL -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" @echo 'Finished building: $<' @echo ' ' diff --git a/Linux64/src/hqp/subdir.mk b/Linux64/src/hqp/subdir.mk index cb05aff8c..039cb6e8b 100644 --- a/Linux64/src/hqp/subdir.mk +++ b/Linux64/src/hqp/subdir.mk @@ -23,7 +23,7 @@ CPP_DEPS += \ src/hqp/%.o: ../src/hqp/%.cpp @echo 'Building file: $<' @echo 'Invoking: GCC C++ Compiler' - g++ -DBUILD_SDL -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" + g++ -DBUILD_SDL -DUSE_OPENGL -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" @echo 'Finished building: $<' @echo ' ' diff --git a/Linux64/src/scale2x/subdir.mk b/Linux64/src/scale2x/subdir.mk index e1375fac0..fad097db5 100644 --- a/Linux64/src/scale2x/subdir.mk +++ b/Linux64/src/scale2x/subdir.mk @@ -29,7 +29,7 @@ CPP_DEPS += \ src/scale2x/%.o: ../src/scale2x/%.cpp @echo 'Building file: $<' @echo 'Invoking: GCC C++ Compiler' - g++ -DBUILD_SDL -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" + g++ -DBUILD_SDL -DUSE_OPENGL -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" @echo 'Finished building: $<' @echo ' ' diff --git a/Linux64/src/sdl/sound/subdir.mk b/Linux64/src/sdl/sound/subdir.mk index e7f48ab32..ca48b37a2 100644 --- a/Linux64/src/sdl/sound/subdir.mk +++ b/Linux64/src/sdl/sound/subdir.mk @@ -23,7 +23,7 @@ CPP_DEPS += \ src/sdl/sound/%.o: ../src/sdl/sound/%.cpp @echo 'Building file: $<' @echo 'Invoking: GCC C++ Compiler' - g++ -DBUILD_SDL -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" + g++ -DBUILD_SDL -DUSE_OPENGL -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" @echo 'Finished building: $<' @echo ' ' diff --git a/Linux64/src/sdl/subdir.mk b/Linux64/src/sdl/subdir.mk index 43a2fb4ba..afc5eb458 100644 --- a/Linux64/src/sdl/subdir.mk +++ b/Linux64/src/sdl/subdir.mk @@ -6,6 +6,7 @@ CPP_SRCS += \ ../src/sdl/CInput.cpp \ ../src/sdl/COpenGL.cpp \ +../src/sdl/CSettings.cpp \ ../src/sdl/CTimer.cpp \ ../src/sdl/CVideoDriver.cpp \ ../src/sdl/joydrv.cpp @@ -13,6 +14,7 @@ CPP_SRCS += \ OBJS += \ ./src/sdl/CInput.o \ ./src/sdl/COpenGL.o \ +./src/sdl/CSettings.o \ ./src/sdl/CTimer.o \ ./src/sdl/CVideoDriver.o \ ./src/sdl/joydrv.o @@ -20,6 +22,7 @@ OBJS += \ CPP_DEPS += \ ./src/sdl/CInput.d \ ./src/sdl/COpenGL.d \ +./src/sdl/CSettings.d \ ./src/sdl/CTimer.d \ ./src/sdl/CVideoDriver.d \ ./src/sdl/joydrv.d @@ -29,7 +32,7 @@ CPP_DEPS += \ src/sdl/%.o: ../src/sdl/%.cpp @echo 'Building file: $<' @echo 'Invoking: GCC C++ Compiler' - g++ -DBUILD_SDL -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" + g++ -DBUILD_SDL -DUSE_OPENGL -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" @echo 'Finished building: $<' @echo ' ' diff --git a/Linux64/src/sdl/video/subdir.mk b/Linux64/src/sdl/video/subdir.mk index f71f1e753..2daaa8283 100644 --- a/Linux64/src/sdl/video/subdir.mk +++ b/Linux64/src/sdl/video/subdir.mk @@ -17,7 +17,7 @@ CPP_DEPS += \ src/sdl/video/%.o: ../src/sdl/video/%.cpp @echo 'Building file: $<' @echo 'Invoking: GCC C++ Compiler' - g++ -DBUILD_SDL -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" + g++ -DBUILD_SDL -DUSE_OPENGL -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" @echo 'Finished building: $<' @echo ' ' diff --git a/Linux64/src/subdir.mk b/Linux64/src/subdir.mk index 8048b8da1..589304beb 100644 --- a/Linux64/src/subdir.mk +++ b/Linux64/src/subdir.mk @@ -74,7 +74,7 @@ CPP_DEPS += \ src/%.o: ../src/%.cpp @echo 'Building file: $<' @echo 'Invoking: GCC C++ Compiler' - g++ -DBUILD_SDL -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" + g++ -DBUILD_SDL -DUSE_OPENGL -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" @echo 'Finished building: $<' @echo ' ' diff --git a/Linux64/src/vorbis/subdir.mk b/Linux64/src/vorbis/subdir.mk index 302b3dec0..78dafb3de 100644 --- a/Linux64/src/vorbis/subdir.mk +++ b/Linux64/src/vorbis/subdir.mk @@ -17,7 +17,7 @@ CPP_DEPS += \ src/vorbis/%.o: ../src/vorbis/%.cpp @echo 'Building file: $<' @echo 'Invoking: GCC C++ Compiler' - g++ -DBUILD_SDL -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" + g++ -DBUILD_SDL -DUSE_OPENGL -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" @echo 'Finished building: $<' @echo ' ' diff --git a/Linux64/src/vorticon/subdir.mk b/Linux64/src/vorticon/subdir.mk index a59b43ce3..00fd9660e 100644 --- a/Linux64/src/vorticon/subdir.mk +++ b/Linux64/src/vorticon/subdir.mk @@ -4,20 +4,26 @@ # Add inputs and outputs from these tool invocations to the build variables CPP_SRCS += \ +../src/vorticon/CCredits.cpp \ ../src/vorticon/CDialog.cpp \ ../src/vorticon/CHighScores.cpp \ +../src/vorticon/CIntro.cpp \ ../src/vorticon/CObject.cpp \ ../src/vorticon/CPlayer.cpp OBJS += \ +./src/vorticon/CCredits.o \ ./src/vorticon/CDialog.o \ ./src/vorticon/CHighScores.o \ +./src/vorticon/CIntro.o \ ./src/vorticon/CObject.o \ ./src/vorticon/CPlayer.o CPP_DEPS += \ +./src/vorticon/CCredits.d \ ./src/vorticon/CDialog.d \ ./src/vorticon/CHighScores.d \ +./src/vorticon/CIntro.d \ ./src/vorticon/CObject.d \ ./src/vorticon/CPlayer.d @@ -26,7 +32,7 @@ CPP_DEPS += \ src/vorticon/%.o: ../src/vorticon/%.cpp @echo 'Building file: $<' @echo 'Invoking: GCC C++ Compiler' - g++ -DBUILD_SDL -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" + g++ -DBUILD_SDL -DUSE_OPENGL -DBUILD_WITH_OGG -DTARGET_LNX -I/usr/include/SDL -I/usr/include/vorbis -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" @echo 'Finished building: $<' @echo ' ' diff --git a/Windows/src/ai/subdir.mk b/Windows/src/ai/subdir.mk index 52f9c9cf9..495ae45d3 100644 --- a/Windows/src/ai/subdir.mk +++ b/Windows/src/ai/subdir.mk @@ -95,7 +95,7 @@ CPP_DEPS += \ src/ai/%.o: ../src/ai/%.cpp @echo 'Building file: $<' @echo 'Invoking: GCC C++ Compiler' - i586-mingw32msvc-g++ -DBUILD_SDL -DBUILD_WITH_OGG -DTARGET_WIN32 -I/usr/i586-mingw32msvc/include/SDL -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" + i586-mingw32msvc-g++ -DBUILD_SDL -DUSE_OPENGL -DBUILD_WITH_OGG -DTARGET_WIN32 -I/usr/i586-mingw32msvc/include/SDL -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" @echo 'Finished building: $<' @echo ' ' diff --git a/Windows/src/fileio/subdir.mk b/Windows/src/fileio/subdir.mk index c768e32fc..b06c7c9f7 100644 --- a/Windows/src/fileio/subdir.mk +++ b/Windows/src/fileio/subdir.mk @@ -26,7 +26,7 @@ CPP_DEPS += \ src/fileio/%.o: ../src/fileio/%.cpp @echo 'Building file: $<' @echo 'Invoking: GCC C++ Compiler' - i586-mingw32msvc-g++ -DBUILD_SDL -DBUILD_WITH_OGG -DTARGET_WIN32 -I/usr/i586-mingw32msvc/include/SDL -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" + i586-mingw32msvc-g++ -DBUILD_SDL -DUSE_OPENGL -DBUILD_WITH_OGG -DTARGET_WIN32 -I/usr/i586-mingw32msvc/include/SDL -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" @echo 'Finished building: $<' @echo ' ' diff --git a/Windows/src/hqp/subdir.mk b/Windows/src/hqp/subdir.mk index 51a245cab..a0a273f06 100644 --- a/Windows/src/hqp/subdir.mk +++ b/Windows/src/hqp/subdir.mk @@ -23,7 +23,7 @@ CPP_DEPS += \ src/hqp/%.o: ../src/hqp/%.cpp @echo 'Building file: $<' @echo 'Invoking: GCC C++ Compiler' - i586-mingw32msvc-g++ -DBUILD_SDL -DBUILD_WITH_OGG -DTARGET_WIN32 -I/usr/i586-mingw32msvc/include/SDL -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" + i586-mingw32msvc-g++ -DBUILD_SDL -DUSE_OPENGL -DBUILD_WITH_OGG -DTARGET_WIN32 -I/usr/i586-mingw32msvc/include/SDL -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" @echo 'Finished building: $<' @echo ' ' diff --git a/Windows/src/scale2x/subdir.mk b/Windows/src/scale2x/subdir.mk index 559660451..ef6e5bca6 100644 --- a/Windows/src/scale2x/subdir.mk +++ b/Windows/src/scale2x/subdir.mk @@ -29,7 +29,7 @@ CPP_DEPS += \ src/scale2x/%.o: ../src/scale2x/%.cpp @echo 'Building file: $<' @echo 'Invoking: GCC C++ Compiler' - i586-mingw32msvc-g++ -DBUILD_SDL -DBUILD_WITH_OGG -DTARGET_WIN32 -I/usr/i586-mingw32msvc/include/SDL -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" + i586-mingw32msvc-g++ -DBUILD_SDL -DUSE_OPENGL -DBUILD_WITH_OGG -DTARGET_WIN32 -I/usr/i586-mingw32msvc/include/SDL -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" @echo 'Finished building: $<' @echo ' ' diff --git a/Windows/src/sdl/sound/subdir.mk b/Windows/src/sdl/sound/subdir.mk index 83159e2b4..bec54b8ee 100644 --- a/Windows/src/sdl/sound/subdir.mk +++ b/Windows/src/sdl/sound/subdir.mk @@ -23,7 +23,7 @@ CPP_DEPS += \ src/sdl/sound/%.o: ../src/sdl/sound/%.cpp @echo 'Building file: $<' @echo 'Invoking: GCC C++ Compiler' - i586-mingw32msvc-g++ -DBUILD_SDL -DBUILD_WITH_OGG -DTARGET_WIN32 -I/usr/i586-mingw32msvc/include/SDL -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" + i586-mingw32msvc-g++ -DBUILD_SDL -DUSE_OPENGL -DBUILD_WITH_OGG -DTARGET_WIN32 -I/usr/i586-mingw32msvc/include/SDL -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" @echo 'Finished building: $<' @echo ' ' diff --git a/Windows/src/sdl/subdir.mk b/Windows/src/sdl/subdir.mk index 68229e717..5e0334f66 100644 --- a/Windows/src/sdl/subdir.mk +++ b/Windows/src/sdl/subdir.mk @@ -6,6 +6,7 @@ CPP_SRCS += \ ../src/sdl/CInput.cpp \ ../src/sdl/COpenGL.cpp \ +../src/sdl/CSettings.cpp \ ../src/sdl/CTimer.cpp \ ../src/sdl/CVideoDriver.cpp \ ../src/sdl/joydrv.cpp @@ -13,6 +14,7 @@ CPP_SRCS += \ OBJS += \ ./src/sdl/CInput.o \ ./src/sdl/COpenGL.o \ +./src/sdl/CSettings.o \ ./src/sdl/CTimer.o \ ./src/sdl/CVideoDriver.o \ ./src/sdl/joydrv.o @@ -20,6 +22,7 @@ OBJS += \ CPP_DEPS += \ ./src/sdl/CInput.d \ ./src/sdl/COpenGL.d \ +./src/sdl/CSettings.d \ ./src/sdl/CTimer.d \ ./src/sdl/CVideoDriver.d \ ./src/sdl/joydrv.d @@ -29,7 +32,7 @@ CPP_DEPS += \ src/sdl/%.o: ../src/sdl/%.cpp @echo 'Building file: $<' @echo 'Invoking: GCC C++ Compiler' - i586-mingw32msvc-g++ -DBUILD_SDL -DBUILD_WITH_OGG -DTARGET_WIN32 -I/usr/i586-mingw32msvc/include/SDL -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" + i586-mingw32msvc-g++ -DBUILD_SDL -DUSE_OPENGL -DBUILD_WITH_OGG -DTARGET_WIN32 -I/usr/i586-mingw32msvc/include/SDL -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" @echo 'Finished building: $<' @echo ' ' diff --git a/Windows/src/sdl/video/subdir.mk b/Windows/src/sdl/video/subdir.mk index 7dedd0bf2..bb881a516 100644 --- a/Windows/src/sdl/video/subdir.mk +++ b/Windows/src/sdl/video/subdir.mk @@ -17,7 +17,7 @@ CPP_DEPS += \ src/sdl/video/%.o: ../src/sdl/video/%.cpp @echo 'Building file: $<' @echo 'Invoking: GCC C++ Compiler' - i586-mingw32msvc-g++ -DBUILD_SDL -DBUILD_WITH_OGG -DTARGET_WIN32 -I/usr/i586-mingw32msvc/include/SDL -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" + i586-mingw32msvc-g++ -DBUILD_SDL -DUSE_OPENGL -DBUILD_WITH_OGG -DTARGET_WIN32 -I/usr/i586-mingw32msvc/include/SDL -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" @echo 'Finished building: $<' @echo ' ' diff --git a/Windows/src/subdir.mk b/Windows/src/subdir.mk index 54b59655f..b4030bd28 100644 --- a/Windows/src/subdir.mk +++ b/Windows/src/subdir.mk @@ -74,7 +74,7 @@ CPP_DEPS += \ src/%.o: ../src/%.cpp @echo 'Building file: $<' @echo 'Invoking: GCC C++ Compiler' - i586-mingw32msvc-g++ -DBUILD_SDL -DBUILD_WITH_OGG -DTARGET_WIN32 -I/usr/i586-mingw32msvc/include/SDL -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" + i586-mingw32msvc-g++ -DBUILD_SDL -DUSE_OPENGL -DBUILD_WITH_OGG -DTARGET_WIN32 -I/usr/i586-mingw32msvc/include/SDL -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" @echo 'Finished building: $<' @echo ' ' diff --git a/Windows/src/vorbis/subdir.mk b/Windows/src/vorbis/subdir.mk index b520a1000..68f1684ee 100644 --- a/Windows/src/vorbis/subdir.mk +++ b/Windows/src/vorbis/subdir.mk @@ -17,7 +17,7 @@ CPP_DEPS += \ src/vorbis/%.o: ../src/vorbis/%.cpp @echo 'Building file: $<' @echo 'Invoking: GCC C++ Compiler' - i586-mingw32msvc-g++ -DBUILD_SDL -DBUILD_WITH_OGG -DTARGET_WIN32 -I/usr/i586-mingw32msvc/include/SDL -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" + i586-mingw32msvc-g++ -DBUILD_SDL -DUSE_OPENGL -DBUILD_WITH_OGG -DTARGET_WIN32 -I/usr/i586-mingw32msvc/include/SDL -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" @echo 'Finished building: $<' @echo ' ' diff --git a/Windows/src/vorticon/subdir.mk b/Windows/src/vorticon/subdir.mk index 404ff5817..a87f8e7fd 100644 --- a/Windows/src/vorticon/subdir.mk +++ b/Windows/src/vorticon/subdir.mk @@ -4,20 +4,26 @@ # Add inputs and outputs from these tool invocations to the build variables CPP_SRCS += \ +../src/vorticon/CCredits.cpp \ ../src/vorticon/CDialog.cpp \ ../src/vorticon/CHighScores.cpp \ +../src/vorticon/CIntro.cpp \ ../src/vorticon/CObject.cpp \ ../src/vorticon/CPlayer.cpp OBJS += \ +./src/vorticon/CCredits.o \ ./src/vorticon/CDialog.o \ ./src/vorticon/CHighScores.o \ +./src/vorticon/CIntro.o \ ./src/vorticon/CObject.o \ ./src/vorticon/CPlayer.o CPP_DEPS += \ +./src/vorticon/CCredits.d \ ./src/vorticon/CDialog.d \ ./src/vorticon/CHighScores.d \ +./src/vorticon/CIntro.d \ ./src/vorticon/CObject.d \ ./src/vorticon/CPlayer.d @@ -26,7 +32,7 @@ CPP_DEPS += \ src/vorticon/%.o: ../src/vorticon/%.cpp @echo 'Building file: $<' @echo 'Invoking: GCC C++ Compiler' - i586-mingw32msvc-g++ -DBUILD_SDL -DBUILD_WITH_OGG -DTARGET_WIN32 -I/usr/i586-mingw32msvc/include/SDL -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" + i586-mingw32msvc-g++ -DBUILD_SDL -DUSE_OPENGL -DBUILD_WITH_OGG -DTARGET_WIN32 -I/usr/i586-mingw32msvc/include/SDL -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" @echo 'Finished building: $<' @echo ' ' diff --git a/src/CGame.cpp b/src/CGame.cpp index 290ef31ce..da0b303fc 100644 --- a/src/CGame.cpp +++ b/src/CGame.cpp @@ -7,10 +7,20 @@ #include -#include "CGame.h" -#include "fileio.h" #include "keen.h" +#include "CGame.h" +#include "include/game.h" +#include "include/misc.h" +#include "include/main.h" +#include "include/menu.h" +#include "include/fileio/story.h" +#include "vorticon/CHighScores.h" +#include "vorticon/CIntro.h" +#include "vorticon/CCredits.h" +#include "CLogFile.h" +#include "fileio.h" #include "sdl/sound/CSound.h" +#include "sdl/CVideoDriver.h" CGame::CGame() { m_Episode = 0; @@ -22,9 +32,189 @@ CGame::~CGame() { if(Latch){ delete Latch; Latch = NULL;} } -void CGame::runCycle(void) +short CGame::runCycle(stCloneKeenPlus *pCKP) { - // TODO: Code here!! + int opt = MAINMNU_1PLAYER; + int retval; + int eseq = 0; + int defaultopt = 0; + + initgamefirsttime(pCKP, Latch->getLatchHeader()->NumSprites); + initgame(pCKP); + + g_pLogFile->ftextOut("Game starting...
"); + + if (eseq) + { + endsequence(pCKP); + closeCKP(pCKP); + } + + if(!pCKP->Control.skipstarting) + { + CIntro Intro; + Intro.Render(pCKP); + //if (intro(pCKP)){ pCKP->shutdown=SHUTDOWN_EXIT; return 0; } + pCKP->Control.skipstarting=0; + } + + do + { + if (QuitState==QUIT_TO_TITLE) QuitState = NO_QUIT; + + if(pCKP->Control.storyboard == 1) // Show the story of the game + { + char *text; + int textsize; + + textsize = readStoryText(&text, + pCKP->GameData[pCKP->Resources.GameSelected-1].Episode, + pCKP->GameData[pCKP->Resources.GameSelected-1].DataDirectory); // Read text from + // and store it at the text pointer + + if(textsize > 0) + { + showPage(text,pCKP,textsize); + free(text); + } + else if(textsize == 0) + { + g_pLogFile->ftextOut("readStoryText(): Error reading story text. Are you sure that there is any story text?"); + } + else if(textsize == 0) + { + g_pLogFile->ftextOut("readStoryText(): Error reading story text. The version appears to be incompatible"); + } + pCKP->Control.storyboard = 0; + } + + if(pCKP->Control.levelcontrol.command != LVLC_START_LEVEL) + { + g_pLogFile->ftextOut("calling mainmenu()
"); + + opt = mainmenu(pCKP, defaultopt); // Read option from the main menu + // of the game. + + pCKP->Control.skipstarting=0; + + g_pLogFile->ftextOut("gcl: opt = %d
", opt); + } + + defaultopt = 0; + IntroCanceled = 0; + switch(opt) + { + case MAINMNU_1PLAYER: + numplayers = 1; + defaultopt = 0; + current_demo = 1; + initgamefirsttime(pCKP, Latch->getLatchHeader()->NumSprites); + loadinggame = 0; + playgame_levelmanager(pCKP); + break; + case MAINMNU_2PLAYER: + defaultopt = 0; + current_demo = 1; + numplayers = 2; + initgamefirsttime(pCKP, Latch->getLatchHeader()->NumSprites); + loadinggame = 0; + playgame_levelmanager(pCKP); + break; + case MAINMNU_LOADGAME: + if (loadslot) + { + loadinggame = 1; + defaultopt = 0; + current_demo = 1; + numplayers = 1; // here was 2. Why was that? I don't understand + initgamefirsttime(pCKP, Latch->getLatchHeader()->NumSprites); + playgame_levelmanager(pCKP); + } + break; + + case MAINMNU_STORY: + pCKP->Control.storyboard=1; + break; + + case MAINMNU_HIGHSCORES: + CHighScores *pHighscores; + pHighscores = new CHighScores(pCKP); + if(pHighscores->showHighScore()) + { + g_pLogFile->ftextOut("Error processing Highscore!!
"); + } + delete pHighscores; + break; + + case MAINMNU_NEW_GAME: + if(loadStartMenu(pCKP) == 1) + { + pCKP->shutdown = SHUTDOWN_EXIT; + break; + } + //loadResourcesforGame(pCKP); + loadResources(pCKP->Control.levelcontrol.episode, pCKP->GameData[pCKP->Resources.GameSelected-1].DataDirectory); + + + pCKP->shutdown = SHUTDOWN_RESTART; + break; + + case MAINMNU_ABOUT: + CCredits *pCredit; + pCredit = new CCredits; + pCredit->Render(pCKP); + delete pCredit; + pCredit = NULL; + break; + + case MAINMNU_TIMEOUT: + case MAINMNU_DEMO: + retval = play_demo(current_demo, pCKP, Latch->getLatchHeader()->NumSprites); + + if (retval==DEMO_RESULT_FILE_BAD) + { + // we tried to play a demo that did not exist--assume we + // reached the last demo and go back to the intro + //intro(pCKP); + CIntro *pIntro; + pIntro = new CIntro(); + delete pIntro; + pIntro = NULL; + current_demo = 0; + } + else if (retval==DEMO_RESULT_CANCELED) + { // user hit a key to cancel demo + IntroCanceled = 1; // pop up menu + } + + if (IntroCanceled) + { // user canceled out of demo (or intro if at end of demos) + // if user selected "demo" have it selected when he comes back + if (opt==MAINMNU_DEMO) + { + defaultopt = MAINMNU_DEMO; + } + } + + current_demo++; + break; + case RESTART_GAME: + g_pLogFile->ftextOut("********************
"); + g_pLogFile->ftextOut(" Restarting game...
"); + g_pLogFile->ftextOut("********************
\n"); + cleanup(pCKP); + pCKP->shutdown = SHUTDOWN_RESTART; + return 0; + break; + case BACK2MAINMENU: + + default: break; + } + g_pLogFile->ftextOut("bottom of game control loop opt=%d crashflag=%d
", opt, crashflag); + if(pCKP->shutdown == SHUTDOWN_EXIT) break; + } while(opt != MAINMNU_QUIT && opt != MAINMNU_NEW_GAME && !crashflag); + + return 0; } int CGame::loadResources(unsigned short Episode, char *DataDirectory) @@ -44,5 +234,36 @@ int CGame::loadResources(unsigned short Episode, char *DataDirectory) return 0; } +void CGame::preallocateCKP(stCloneKeenPlus *pCKP) +{ + // This function prepares the CKP Structure so that the it is allocated in the memory. + pCKP->numGames = 0; + pCKP->Resources.GameSelected = 0; + + TileProperty = NULL; + + pCKP->GameData = NULL; + pCKP->GameData = new stGameData[1]; + + memset(pCKP->GameData, 0, sizeof(stGameData)); + + framebyframe = 0; + + demomode = DEMO_NODEMO; + current_demo = 1; + + memset(&pCKP->Control, 0, sizeof(stControl)); + + pCKP->Joystick = NULL; + + acceleratemode = 0; + g_pVideoDriver->showFPS(false); + + player[0].x = player[0].y = 0; +} + + + + CLatch *CGame::getLatch(void) { return Latch; } diff --git a/src/CGame.h b/src/CGame.h index f8759017f..60469eebc 100644 --- a/src/CGame.h +++ b/src/CGame.h @@ -16,14 +16,16 @@ public: CGame(); virtual ~CGame(); - void runCycle(void); int loadResources(unsigned short Episode, char *DataDirectory); + short runCycle(stCloneKeenPlus *pCKP); + void preallocateCKP(stCloneKeenPlus *pCKP); CLatch *getLatch(void); private: static const unsigned short MAX_TEXT_LENGTH = 256; unsigned short m_Episode; char m_DataDirectory[MAX_TEXT_LENGTH]; + int current_demo; CLatch *Latch; }; diff --git a/src/CGraphics.cpp b/src/CGraphics.cpp index e9b2e7e2e..5315d9b36 100644 --- a/src/CGraphics.cpp +++ b/src/CGraphics.cpp @@ -531,6 +531,8 @@ unsigned char *bmdataptr; int CGraphics::getBitmapNumberFromName(const char *bmname) { + + // TODO: Implement Code for Introduction Screen int i; for(i=0;iftextOut("latch_loadlatch(): Reading %d bytes...
", RawDataSize); - fread(RawData, RawDataSize, 1, latchfile); + if(!fread(RawData, 1, RawDataSize, latchfile)) + { + g_pLogFile->ftextOut(RED,"latch_loadlatch(): Error reading the file...
"); + return 1; + } } fclose(latchfile); @@ -480,7 +484,11 @@ char buffer[256]; else { g_pLogFile->ftextOut("latch_loadsprites(): Reading %d bytes...
", RawDataSize); - fread(RawData, RawDataSize, 1, spritfile); + if(!fread(RawData, 1, RawDataSize, spritfile)) + { + g_pLogFile->ftextOut(RED,"latch_loadsprites(): Error reading the file...
"); + return 1; + } } fclose(spritfile); diff --git a/src/CLogFile.h b/src/CLogFile.h index c6146b0bf..a663e7587 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.2 (Commander Genius)" +#define REVISION "CloneKeenPlus Beta v0.2.9.5 (Commander Genius)" #include #include "CSingleton.h" diff --git a/src/eseq_ep1.cpp b/src/eseq_ep1.cpp index 5f31058aa..9648ca69b 100644 --- a/src/eseq_ep1.cpp +++ b/src/eseq_ep1.cpp @@ -396,7 +396,7 @@ int dlgX, dlgY, dlgW, dlgH; return 0; gamedo_fades(); - gamedo_frameskipping_blitonly(pCKP); + gamedo_frameskipping_blitonly(); lastenterstate = enter; diff --git a/src/eseq_ep2.cpp b/src/eseq_ep2.cpp index 2adc988db..56bbd0e0b 100644 --- a/src/eseq_ep2.cpp +++ b/src/eseq_ep2.cpp @@ -383,7 +383,7 @@ int cancel, lastcancelstate; sb_dialogbox(boxleft,boxtop,boxwidth,boxheight); g_pGraphics->sb_font_draw( (unsigned char*)tempbuf, (boxleft+1)*8, (boxtop+1+textline)*8); - gamedo_frameskipping_blitonly(pCKP); + gamedo_frameskipping_blitonly(); gamedo_render_eraseobjects(); if (showtimer > LETTER_SHOW_SPD) diff --git a/src/game.cpp b/src/game.cpp index e89eee18e..d15abc15c 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -267,14 +267,12 @@ void gameloop(stCloneKeenPlus *pCKP) // if (numplayers>1) net_senddata(); #endif - if (g_pInput->getPressedKey(KQUIT)) + if (g_pInput->getPressedKey(KQUIT)) { VerifyQuit(pCKP); } - if (QuitState != NO_QUIT) return; - // limit frame rate if (!acceleratemode) { diff --git a/src/gamedo.cpp b/src/gamedo.cpp index 440cdcecd..6e020aa99 100644 --- a/src/gamedo.cpp +++ b/src/gamedo.cpp @@ -43,7 +43,6 @@ void gamedo_getInput(stCloneKeenPlus *pCKP) int i; int byt; unsigned int msb, lsb; -int p/*, keysdirty*/; if (demomode==DEMO_PLAYBACK) { @@ -56,17 +55,19 @@ int p/*, keysdirty*/; demo_RLERunLen = (msb<<8) | lsb; byt = demo_data[demo_data_index++]; // get keys down - player[0].keytable[KLEFT] = 0; - player[0].keytable[KRIGHT] = 0; - player[0].keytable[KCTRL] = 0; - player[0].keytable[KALT] = 0; + player[0].playcontrol[PA_X] = 0; + player[0].playcontrol[PA_POGO] = 0; + player[0].playcontrol[PA_JUMP] = 0; + player[0].playcontrol[PA_FIRE] = 0; + player[0].playcontrol[PA_STATUS] = 0; - - if (byt & 1) player[0].keytable[KLEFT] = 1; - if (byt & 2) player[0].keytable[KRIGHT] = 1; - if (byt & 4) player[0].keytable[KCTRL] = 1; - if (byt & 8) player[0].keytable[KALT] = 1; - if (byt & 16) + if (byt & 1) player[0].playcontrol[PA_X] -= 100; + if (byt & 2) player[0].playcontrol[PA_X] += 100; + if (byt & 4) player[0].playcontrol[PA_POGO] = 1; + if (byt & 8) player[0].playcontrol[PA_JUMP] = 1; + if (byt & 16)player[0].playcontrol[PA_FIRE] = 1; + if (byt & 32)player[0].playcontrol[PA_STATUS] = 1; + if (byt & 64) { // demo STOP command if (fade.mode!=FADE_GO) endlevel(1, pCKP); } @@ -93,94 +94,49 @@ int p/*, keysdirty*/; return; } - if (is_server) return; - - p = primaryplayer; - //player[p].keytable[KQUIT] = immediate_keytable[KQUIT]; - - memcpy(player[p].lastplaycontrol,player[p].playcontrol,PA_MAX_ACTIONS); - - // Entry for the primary player - for(i=0 ; igetHoldedCommand(p, IC_LEFT)) + player[p].playcontrol[PA_X] -= 100; + if(g_pInput->getHoldedCommand(p, IC_RIGHT)) + player[p].playcontrol[PA_X] += 100; + + if(g_pInput->getHoldedCommand(p, IC_UP)) + player[p].playcontrol[PA_Y] -= 100; + if(g_pInput->getHoldedCommand(p, IC_DOWN)) + player[p].playcontrol[PA_Y] += 100; + + if(g_pInput->getHoldedCommand(p, IC_JUMP)) + player[p].playcontrol[PA_JUMP] = 1; + if(g_pInput->getHoldedCommand(p, IC_POGO)) + player[p].playcontrol[PA_POGO] = 1; + if(g_pInput->getHoldedCommand(p, IC_FIRE)) + player[p].playcontrol[PA_FIRE] = 1; + if(g_pInput->getHoldedCommand(p, IC_STATUS)) + player[p].playcontrol[PA_STATUS] = 1; + + if (demomode==DEMO_RECORD) + { + if(i) player[p].playcontrol[PA_X] += 100; + fputc(i, demofile); + if(i) player[p].playcontrol[PA_X] -= 100; + fputc(i, demofile); + if(i) player[p].playcontrol[PA_POGO] = 1; + fputc(i, demofile); + if(i) player[p].playcontrol[PA_JUMP] = 1; + fputc(i, demofile); + if(i) player[p].playcontrol[PA_FIRE] = 1; + fputc(i, demofile); + if(i) player[p].playcontrol[PA_STATUS] = 1; + fputc(i, demofile); + } } - - if(g_pInput->getHoldedCommand(IC_LEFT)) - player[p].playcontrol[PA_X] -= 100; - if(g_pInput->getHoldedCommand(IC_RIGHT)) - player[p].playcontrol[PA_X] += 100; - - if(g_pInput->getHoldedCommand(IC_UP)) - player[p].playcontrol[PA_Y] -= 100; - if(g_pInput->getHoldedCommand(IC_DOWN)) - player[p].playcontrol[PA_Y] += 100; - - if(g_pInput->getHoldedCommand(IC_JUMP)) - player[p].playcontrol[PA_JUMP] = 1; - if(g_pInput->getHoldedCommand(IC_POGO)) - player[p].playcontrol[PA_POGO] = 1; - if(g_pInput->getHoldedCommand(IC_FIRE)) - player[p].playcontrol[PA_FIRE] = 1; - if(g_pInput->getHoldedCommand(IC_STATUS)) - player[p].playcontrol[PA_STATUS] = 1; - - - #ifdef NETWORK_PLAY -// if (numplayers>1) - if (is_client) - { - if (player[p].keytable[KLEFT] != oldleftkey) keysdirty = 1; - else if (player[p].keytable[KRIGHT] != oldrightkey) keysdirty = 1; - else if (player[p].keytable[KUP] != oldupkey) keysdirty = 1; - else if (player[p].keytable[KDOWN] != olddownkey) keysdirty = 1; - else if (player[p].keytable[KCTRL] != oldctrlkey) keysdirty = 1; - else if (player[p].keytable[KALT] != oldaltkey) keysdirty = 1; - else keysdirty = 0; - if (keysdirty) - { - net_sendkeys(); - oldleftkey = player[p].keytable[KLEFT]; - oldrightkey = player[p].keytable[KRIGHT]; - oldupkey = player[p].keytable[KUP]; - olddownkey = player[p].keytable[KDOWN]; - oldctrlkey = player[p].keytable[KCTRL]; - oldaltkey = player[p].keytable[KALT]; - } - } - #endif - - if (numplayers>1 && localmp) - { - /* player[1].keytable[KQUIT] = 0; - player[1].keytable[KLEFT] = immediate_keytable[KLEFT2]; - player[1].keytable[KRIGHT] = immediate_keytable[KRIGHT2]; - player[1].keytable[KUP] = immediate_keytable[KUP2]; - player[1].keytable[KDOWN] = immediate_keytable[KDOWN2]; - player[1].keytable[KCTRL] = immediate_keytable[KCTRL2]; - player[1].keytable[KALT] = immediate_keytable[KALT2]; - player[1].keytable[KENTER] = 0; - player[1].keytable[KSPACE] = 0; - - player[2].keytable[KQUIT] = 0; - player[2].keytable[KLEFT] = immediate_keytable[KLEFT3]; - player[2].keytable[KRIGHT] = immediate_keytable[KRIGHT3]; - player[2].keytable[KUP] = immediate_keytable[KUP3]; - player[2].keytable[KDOWN] = immediate_keytable[KDOWN3]; - player[2].keytable[KCTRL] = immediate_keytable[KCTRL3]; - player[2].keytable[KALT] = immediate_keytable[KALT3]; - player[2].keytable[KENTER] = 0; - player[2].keytable[KSPACE] = 0;*/ - } - - if (demomode==DEMO_RECORD) - { - /*fputc(player[0].keytable[KLEFT], demofile); - fputc(player[0].keytable[KRIGHT], demofile); - fputc(player[0].keytable[KCTRL], demofile); - fputc(player[0].keytable[KALT], demofile); - fputc(immediate_keytable[KF1], demofile);*/ - } } // handles scrolling, for player cp @@ -553,7 +509,6 @@ void gamedo_RenderScreen(stCloneKeenPlus *pCKP) g_pGraphics->renderHQBitmap(); gamedo_render_drawobjects(pCKP); - //gamedo_render_drawdebug(); if(pCKP != NULL) { @@ -572,30 +527,6 @@ void gamedo_RenderScreen(stCloneKeenPlus *pCKP) gamedo_render_erasedebug(); gamedo_render_eraseobjects(); - /*if (framebyframe) - { - while(!immediate_keytable[KF8] && !immediate_keytable[KQUIT]) - { - if (immediate_keytable[KF7]) - { - while(immediate_keytable[KF7] && !immediate_keytable[KQUIT]) - { - poll_events(pCKP); - } - framebyframe = 0; - #ifdef BUILD_SDL - NumConsoleMessages = 0; - #endif - return; - } - poll_events(pCKP); - } - while(immediate_keytable[KF8] && !immediate_keytable[KQUIT]) - { - poll_events(pCKP); - } - }*/ - curfps++; } @@ -799,7 +730,7 @@ void gamedo_frameskipping(stCloneKeenPlus *pCKP) // same as above but only does a sb_blit, not the full RenderScreen. // used for intros etc. -void gamedo_frameskipping_blitonly(stCloneKeenPlus *pCKP) +void gamedo_frameskipping_blitonly(void) { if (framebyframe) { diff --git a/src/gamepdo.cpp b/src/gamepdo.cpp index 5f92ea983..1fd7bce1c 100644 --- a/src/gamepdo.cpp +++ b/src/gamepdo.cpp @@ -74,12 +74,10 @@ char doFall; } gamepdo_JumpAndPogo(cp, pCKP); - //gamepdo_Jump(cp, pCKP); // decide if player should fall doFall = 1; if (player[cp].inhibitfall) doFall = 0; - //else if (pCKP->Option[OPT_CHEATS].value) doFall = 0; if (doFall) { @@ -290,7 +288,7 @@ void gamepdo_ProcessInput(unsigned int cp, stCloneKeenPlus *pCKP) gamedo_render_drawobjects(pCKP); gamedo_AnimatedTiles(); PauseDialog->renderDialog(); - gamedo_frameskipping_blitonly(pCKP); + gamedo_frameskipping_blitonly(); } while(!g_pInput->getPressedAnyKey()); delete PauseDialog; @@ -672,7 +670,7 @@ void gamepdo_InertiaAndFriction_X(unsigned int cp, stCloneKeenPlus *pCKP) { if(player[cp].ppogostick) { - player[cp].pinertia_x += player[cp].pboost_x/PJUMPINERTIA; + player[cp].pinertia_x += 3*player[cp].pboost_x/(PJUMPINERTIA*2); } else { diff --git a/src/include/declarations.h b/src/include/declarations.h index c7530c8b6..ae20f355b 100644 --- a/src/include/declarations.h +++ b/src/include/declarations.h @@ -5,26 +5,8 @@ #define MAX_STRING_LENGTH 256 -#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 NUM_OPTIONS 7 - -#define OPT_MEAN 7 // This isn't part of the options menu anymore - #define MAX_NUMBER_OF_FILES 100 -typedef struct stOption -{ - char *name; - char value; -} stOption; - typedef struct stDisplay { unsigned int Width; diff --git a/src/include/gamedo.h b/src/include/gamedo.h index ecce51869..e494ac250 100644 --- a/src/include/gamedo.h +++ b/src/include/gamedo.h @@ -2,6 +2,6 @@ void gamedo_RenderScreen(stCloneKeenPlus *pCKP); void gamedo_frameskipping(stCloneKeenPlus *pCKP); void gamedo_HandleFKeys(stCloneKeenPlus *pCKP); -void gamedo_frameskipping_blitonly(stCloneKeenPlus *pCKP); +void gamedo_frameskipping_blitonly(void); void gamedo_getInput(stCloneKeenPlus *pCKP); void gamedo_render_drawobjects(stCloneKeenPlus *pCKP); diff --git a/src/include/main.h b/src/include/main.h index dca3d276e..da65cfa4a 100644 --- a/src/include/main.h +++ b/src/include/main.h @@ -5,9 +5,6 @@ * Author: gerstrong */ -short loadDriverConfiguration(stCloneKeenPlus *pCKP); -short saveDriverConfiguration(stCloneKeenPlus *pCKP); -void startTheWholeGame(stCloneKeenPlus *pCKP); short readCommandLine(int argc, char *argv[], stCloneKeenPlus *pCKP); void preallocateCKP(stCloneKeenPlus *pCKP); short loadGamesConfig(stOption *Option); diff --git a/src/include/menu.h b/src/include/menu.h index 478725efb..313bb6b1f 100644 --- a/src/include/menu.h +++ b/src/include/menu.h @@ -19,7 +19,6 @@ int mainmenu(stCloneKeenPlus *pCKP,int defaultopt); char configmenu(stCloneKeenPlus *pCKP); short loadStartMenu(stCloneKeenPlus *pCKP); void keensleft(stCloneKeenPlus *pCKP); -int intro(stCloneKeenPlus *pCKP); void showmapatpos(int level, int xoff, int yoff, int wm, stCloneKeenPlus *pCKP); short loadResourcesforStartMenu(stCloneKeenPlus *pCKP, CGame *Game); int getDifficulty(stCloneKeenPlus *pCKP); diff --git a/src/keen.h b/src/keen.h index 8601e7f4e..054bb14d2 100644 --- a/src/keen.h +++ b/src/keen.h @@ -773,10 +773,11 @@ typedef struct stShipQueue #define MAINMNU_OPTIONS 5 #define MAINMNU_DEMO 6 #define MAINMNU_NEW_GAME 7 - #define MAINMNU_QUIT 8 - #define MAINMNU_TIMEOUT 10 // going to demo due to timeout - #define RESTART_GAME 11 - #define BACK2MAINMENU 12 + #define MAINMNU_ABOUT 8 + #define MAINMNU_QUIT 9 + #define MAINMNU_TIMEOUT 11 // going to demo due to timeout + #define RESTART_GAME 12 + #define BACK2MAINMENU 13 #define MAINMENU_NUM_OPTIONS MAINMNU_QUIT @@ -848,6 +849,7 @@ typedef struct stShipQueue #include #include "include/declarations.h" #include "keenext.h" +#include "sdl/CSettings.h" typedef struct stCloneKeenPlus { diff --git a/src/keenext.h b/src/keenext.h index 2e1002586..f64ba9631 100644 --- a/src/keenext.h +++ b/src/keenext.h @@ -1,9 +1,10 @@ +#include "sdl/CSettings.h" + extern char PlatExtending; extern stFade fade; extern stMap map; extern unsigned int AnimTileInUse[ATILEINUSE_SIZEX][ATILEINUSE_SIZEY]; extern stTile tiles[MAX_TILES+1]; -extern char localmp; extern unsigned char tiledata[MAX_TILES+1][16][16]; extern stSprite sprites[MAX_SPRITES+1]; extern stBitmap bitmaps[MAX_BITMAPS+1]; diff --git a/src/main.cpp b/src/main.cpp index 6265840ea..acbdb9a9b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -49,14 +49,13 @@ #include "CLogFile.h" #include "CGame.h" #include "CGraphics.h" - +#include "sdl/CSettings.h" int IntroCanceled; int NessieObjectHandle; int DemoObjectHandle; int BlankSprite; int DemoSprite; -int current_demo; int framebyframe; int fps=0, curfps=0; @@ -113,62 +112,10 @@ char frameskiptimer=0; int thisplayer; unsigned int primaryplayer; unsigned int numplayers; -char is_client; -char is_server; -char localmp; int crashflag,crashflag2,crashflag3; const char *why_term_ptr = "No reason given."; -void setoption(stOption *options, int opt, const char *name, char value) -{ - if (name != NULL) - options[opt].name = (char*) name; - - options[opt].value = value; -} - -short loadGamesConfig(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) - { - createDefaultSettings(Option); - break; - } - } - - return retval; - - g_pLogFile->ftextOut("
Your personal settings were loaded successfully...
"); - return 0; -} - -void SaveConfig(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; -} - int main(int argc, char *argv[]) { @@ -179,14 +126,19 @@ int main(int argc, char *argv[]) banner(); // Intro on the text-console. - preallocateCKP(&CKP); + CGame* Game; + Game = new CGame(); - if(loadDriverConfiguration(&CKP) != 0) // Always return 0 if no ERROR + Game->preallocateCKP(&CKP); + + CSettings *Settings; + Settings = new CSettings; + + if(Settings->loadDrvCfg() != 0) // Always return 0 if no ERROR { g_pLogFile->textOut(RED,"First time message: CKP didn't find the driver config file. However, it is going to generate one basing on default configurations.
"); - saveDriverConfiguration(&CKP); + Settings->saveDrvCfg(); } - // TODO: Implement Driver Configuration as class if(readCommandLine(argc, argv, &CKP) != 0) { @@ -200,15 +152,13 @@ int main(int argc, char *argv[]) return 1; } - createDefaultSettings(CKP.Option); - if(loadGamesConfig(CKP.Option) != 0) + Settings->loadDefaultGameCfg(CKP.Option); + if(Settings->loadGameCfg(CKP.Option) != 0) { g_pLogFile->textOut(PURPLE,"There are no settings! CKP is going to use the default options. You can change them later in the game.
"); - SaveConfig(CKP.Option); + Settings->saveGameCfg(CKP.Option); } - - CGame* Game; - Game = new CGame(); + delete Settings; Settings = NULL; if(loadResourcesforStartMenu(&CKP, Game) != 0) { @@ -240,7 +190,7 @@ int main(int argc, char *argv[]) while( CKP.shutdown == SHUTDOWN_RESTART || CKP.shutdown == SHUTDOWN_BOOTUP ) { CKP.shutdown = SHUTDOWN_NONE; // Game is runnning - runGameCycle(&CKP, Game); + Game->runCycle(&CKP); } } @@ -253,204 +203,21 @@ int main(int argc, char *argv[]) return 0; } -short runGameCycle(stCloneKeenPlus *pCKP, CGame *Game) -{ - int opt = MAINMNU_1PLAYER; - int retval; - int eseq = 0; - int defaultopt = 0; - - initgamefirsttime(pCKP, Game->getLatch()->getLatchHeader()->NumSprites); - initgame(pCKP); - - g_pLogFile->ftextOut("Game starting...
"); - - if (eseq) - { - endsequence(pCKP); - closeCKP(pCKP); - } - - if(!pCKP->Control.skipstarting) - { - if (intro(pCKP)){ pCKP->shutdown=SHUTDOWN_EXIT; return 0; } - pCKP->Control.skipstarting=0; - } - - do - { - if (QuitState==QUIT_TO_TITLE) QuitState = NO_QUIT; - - if(pCKP->Control.storyboard == 1) // Show the story of the game - { - char *text; - int textsize; - - textsize = readStoryText(&text, - pCKP->GameData[pCKP->Resources.GameSelected-1].Episode, - pCKP->GameData[pCKP->Resources.GameSelected-1].DataDirectory); // Read text from - // and store it at the text pointer - - if(textsize > 0) - { - showPage(text,pCKP,textsize); - free(text); - } - else if(textsize == 0) - { - g_pLogFile->ftextOut("readStoryText(): Error reading story text. Are you sure that there is any story text?"); - } - else if(textsize == 0) - { - g_pLogFile->ftextOut("readStoryText(): Error reading story text. The version appears to be incompatible"); - } - pCKP->Control.storyboard = 0; - } - - if(pCKP->Control.levelcontrol.command != LVLC_START_LEVEL) - { - g_pLogFile->ftextOut("calling mainmenu()
"); - - opt = mainmenu(pCKP, defaultopt); // Read option from the main menu - // of the game. - - pCKP->Control.skipstarting=0; - - g_pLogFile->ftextOut("gcl: opt = %d
", opt); - } - - defaultopt = 0; - IntroCanceled = 0; - switch(opt) - { - case MAINMNU_1PLAYER: - numplayers = 1; - defaultopt = 0; - current_demo = 1; - initgamefirsttime(pCKP, Game->getLatch()->getLatchHeader()->NumSprites); - loadinggame = 0; - playgame_levelmanager(pCKP); - break; - case MAINMNU_2PLAYER: - defaultopt = 0; - current_demo = 1; - numplayers = 2; - initgamefirsttime(pCKP, Game->getLatch()->getLatchHeader()->NumSprites); - loadinggame = 0; - playgame_levelmanager(pCKP); - break; - case MAINMNU_LOADGAME: - if (loadslot) - { - loadinggame = 1; - defaultopt = 0; - current_demo = 1; - numplayers = 1; // here was 2. Why was that? I don't understand - initgamefirsttime(pCKP, Game->getLatch()->getLatchHeader()->NumSprites); - playgame_levelmanager(pCKP); - } - break; - - case MAINMNU_STORY: - pCKP->Control.storyboard=1; - break; - - case MAINMNU_HIGHSCORES: - CHighScores *pHighscores; - pHighscores = new CHighScores(pCKP); - if(pHighscores->showHighScore()) - { - g_pLogFile->ftextOut("Error processing Highscore!!
"); - } - delete pHighscores; - break; - - case MAINMNU_NEW_GAME: - if(loadStartMenu(pCKP) == 1) - { - pCKP->shutdown = SHUTDOWN_EXIT; - break; - } - //loadResourcesforGame(pCKP); - Game->loadResources(pCKP->Control.levelcontrol.episode, pCKP->GameData[pCKP->Resources.GameSelected-1].DataDirectory); - - - pCKP->shutdown = SHUTDOWN_RESTART; - break; - - case MAINMNU_TIMEOUT: - case MAINMNU_DEMO: - retval = play_demo(current_demo, pCKP, Game->getLatch()->getLatchHeader()->NumSprites); - - if (retval==DEMO_RESULT_FILE_BAD) - { - // we tried to play a demo that did not exist--assume we - // reached the last demo and go back to the intro - intro(pCKP); - current_demo = 0; - } - else if (retval==DEMO_RESULT_CANCELED) - { // user hit a key to cancel demo - IntroCanceled = 1; // pop up menu - } - - if (IntroCanceled) - { // user canceled out of demo (or intro if at end of demos) - // if user selected "demo" have it selected when he comes back - if (opt==MAINMNU_DEMO) - { - defaultopt = MAINMNU_DEMO; - } - } - - current_demo++; - break; - case RESTART_GAME: - g_pLogFile->ftextOut("********************
"); - g_pLogFile->ftextOut(" Restarting game...
"); - g_pLogFile->ftextOut("********************
\n"); - cleanup(pCKP); - pCKP->shutdown = SHUTDOWN_RESTART; - return 0; - break; - case BACK2MAINMENU: - - default: break; - } - g_pLogFile->ftextOut("bottom of game control loop opt=%d crashflag=%d
", opt, crashflag); - if(pCKP->shutdown == SHUTDOWN_EXIT) break; - } while(opt != MAINMNU_QUIT && opt != MAINMNU_NEW_GAME && !crashflag); - - return 0; -} - void cleanupResources(stCloneKeenPlus *pCKP) { cleanup(pCKP); return; } -void createDefaultSettings(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 loadCKPDrivers(stCloneKeenPlus *pCKP) { g_pGraphics->allocScrollBufmem(); // initialize/activate all drivers g_pLogFile->ftextOut("Starting graphics driver...
"); + if (!g_pVideoDriver->start()) - { return abortCKP(pCKP); - } g_pLogFile->ftextOut("Starting sound driver...
"); @@ -463,90 +230,6 @@ short loadCKPDrivers(stCloneKeenPlus *pCKP) return 0; } -short saveDriverConfiguration(stCloneKeenPlus *pCKP) -{ - 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("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 loadDriverConfiguration(stCloneKeenPlus *pCKP) -{ - 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; -} - short abortCKP(stCloneKeenPlus *pCKP) { g_pLogFile->ftextOut("Fatal error, cleaning up.
"); @@ -559,20 +242,26 @@ short closeCKP(stCloneKeenPlus *pCKP) { int count; int i; - banner(); - SaveConfig(pCKP->Option); - g_pLogFile->ftextOut("
Thanks for playing!

"); - cleanup(pCKP); - if (crashflag) - { - if (crashflag != QUIT_NONFATAL) g_pLogFile->ftextOut("\a"); - g_pLogFile->ftextOut("abnormal program termination, error code %d/%d/%d
explanation: %s
", crashflag,crashflag2,crashflag3, why_term_ptr); + CSettings Settings; - g_pLogFile->ftextOut("numplayers: %d
", numplayers); - for(count=0,i=0;iftextOut("# of player instances with isPlaying set: %d
", count); - } - return 0; + banner(); + + Settings.saveGameCfg(pCKP->Option); + + g_pLogFile->ftextOut("
Thanks for playing!

"); + cleanup(pCKP); + if (crashflag) + { + if (crashflag != QUIT_NONFATAL) g_pLogFile->ftextOut("\a"); + g_pLogFile->ftextOut("abnormal program termination, error code %d/%d/%d
explanation: %s
", crashflag,crashflag2,crashflag3, why_term_ptr); + + g_pLogFile->ftextOut("numplayers: %d
", numplayers); + + for(count=0,i=0;iftextOut("# of player instances with isPlaying set: %d
", count); + } + return 0; } void playgame_levelmanager(stCloneKeenPlus *pCKP) @@ -756,6 +445,12 @@ void playgame_levelmanager(stCloneKeenPlus *pCKP) } g_pGraphics->unloadHQGraphics(); + for(unsigned int i=0;icommand==LVLC_CHANGE_LEVEL && !crashflag); g_pGraphics->unloadHQGraphics(); @@ -959,16 +654,6 @@ short readCommandLine(int argc, char *argv[], stCloneKeenPlus *pCKP) { g_pVideoDriver->showFPS(true); } - else if (strcmp(tempbuf, "-host")==0) // start network server - { - is_server = 1; - localmp = 0; - } - else if (strcmp(tempbuf, "-join")==0) // connect to a server - { - is_client = 1; - localmp = 0; - } else if (strncmp(tempbuf, "-level",strlen("-level"))==0) // select the game { int g; @@ -988,35 +673,3 @@ short readCommandLine(int argc, char *argv[], stCloneKeenPlus *pCKP) } return 0; } -void preallocateCKP(stCloneKeenPlus *pCKP) -{ - // This function prepares the CKP Structure so that the it is allocated in the memory. - pCKP->numGames = 0; - pCKP->Resources.GameSelected = 0; - - TileProperty = NULL; - - pCKP->GameData = NULL; - pCKP->GameData = new stGameData[1]; - - memset(pCKP->GameData, 0, sizeof(stGameData)); - - framebyframe = 0; - - demomode = DEMO_NODEMO; - current_demo = 1; - - memset(&pCKP->Control, 0, sizeof(stControl)); - - pCKP->Joystick = NULL; - - acceleratemode = 0; - is_client = 0; - is_server = 0; - localmp = 1; - g_pVideoDriver->showFPS(false); - - player[0].x = player[0].y = 0; -} - - diff --git a/src/menu.cpp b/src/menu.cpp index 1e4bff09d..05cf8cba2 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -1,4 +1,4 @@ -/* MENU.C + /* MENU.C The main menu, intro, and other such stuff. */ @@ -22,6 +22,7 @@ #include "sdl/CInput.h" #include "vorticon/CDialog.h" #include "CLogFile.h" +#include "sdl/CSettings.h" #include #include #include @@ -43,7 +44,6 @@ g_pLogFile->ftextOut("showmapatpos(%d, %d, %d, %d);
",level,xoff,yoff,wm); memset(levelname,0,MAX_STRING_LENGTH*sizeof(char)); sprintf(levelname, "level%02d.ck%d", level, pCKP->Control.levelcontrol.episode); - short numsel; if(pCKP->Resources.GameSelected == 0 ) // First time startup. No game has been chosen numsel = 0; @@ -182,13 +182,13 @@ short loadStartMenu(stCloneKeenPlus *pCKP) gamedo_AnimatedTiles(); // Check the Input - if(g_pInput->getPressedCommand(IC_DOWN)) + if(g_pInput->getPressedCommand(0, IC_DOWN)) GamesMenu->setNextSelection(); - if(g_pInput->getPressedCommand(IC_UP)) + if(g_pInput->getPressedCommand(0, IC_UP)) GamesMenu->setPrevSelection(); - if(g_pInput->getPressedCommand(IC_STATUS)) + if(g_pInput->getPressedCommand(0, IC_STATUS)) { fade.dir = FADE_OUT; fade.curamt = PAL_FADE_SHADES; @@ -204,7 +204,7 @@ short loadStartMenu(stCloneKeenPlus *pCKP) GamesMenu->renderDialog(); // blit the scrollbuffer to the display - gamedo_frameskipping_blitonly(pCKP); + gamedo_frameskipping_blitonly(); } while(!g_pInput->getExitEvent()); delete GamesMenu; @@ -230,7 +230,7 @@ int mainmenu(stCloneKeenPlus *pCKP,int defaultopt) // Prepare the Games Menu MainMenu = new CDialog(); - MainMenu->setDimensions(11,9,18,11); + MainMenu->setDimensions(11,8,18,12); // Load the Title Bitmap bmnum = g_pGraphics->getBitmapNumberFromName("TITLE"); @@ -243,6 +243,7 @@ int mainmenu(stCloneKeenPlus *pCKP,int defaultopt) MainMenu->addOptionText("Options"); MainMenu->addOptionText("Demo"); MainMenu->addOptionText("Change Game"); + MainMenu->addOptionText("About CG"); MainMenu->addOptionText("Quit"); x = (320/2)-(bitmaps[bmnum].xsize/2); @@ -282,7 +283,7 @@ int mainmenu(stCloneKeenPlus *pCKP,int defaultopt) MainMenu->renderDialog(); // blit the scrollbuffer to the display - gamedo_frameskipping_blitonly(pCKP); + gamedo_frameskipping_blitonly(); if(g_pInput->getExitEvent()) return MAINMNU_QUIT; @@ -414,7 +415,7 @@ int getDifficulty(stCloneKeenPlus *pCKP) DifficultyMenu->renderDialog(); // blit the scrollbuffer to the display - gamedo_frameskipping_blitonly(pCKP); + gamedo_frameskipping_blitonly(); g_pInput->pollEvents(); g_pTimer->SpeedThrottle(); @@ -509,7 +510,10 @@ int AudioDlg(stCloneKeenPlus *pCKP) { g_pSound->destroy(); g_pSound->setSoundmode(rate, mode ? true : false); - saveDriverConfiguration(pCKP); + CSettings *Settings; + Settings = new CSettings(); + Settings->saveDrvCfg(); + delete Settings; Settings = NULL; g_pSound->init(); ok = g_pSound->loadSoundData(pCKP->Control.levelcontrol.episode, pCKP->GameData[pCKP->Resources.GameSelected-1].DataDirectory); @@ -524,7 +528,7 @@ int AudioDlg(stCloneKeenPlus *pCKP) AudioMenu->renderDialog(); // blit the scrollbuffer to the display - gamedo_frameskipping_blitonly(pCKP); + gamedo_frameskipping_blitonly(); g_pInput->pollEvents(); g_pTimer->SpeedThrottle(); @@ -608,7 +612,8 @@ void OptionsDlg(stCloneKeenPlus *pCKP) } else { - SaveConfig(pCKP->Option); + CSettings Settings; + Settings.saveGameCfg(pCKP->Option); break; } } @@ -616,7 +621,7 @@ void OptionsDlg(stCloneKeenPlus *pCKP) OptionsMenu->renderDialog(); // blit the scrollbuffer to the display - gamedo_frameskipping_blitonly(pCKP); + gamedo_frameskipping_blitonly(); g_pInput->pollEvents(); g_pTimer->SpeedThrottle(); @@ -644,6 +649,7 @@ short GraphicsDlg(stCloneKeenPlus *pCKP) char buf[256]; short retval = 0; unsigned char autoframeskip = 0; + bool aspect; showmapatpos(90, MAINMENU_X, MENUS_Y, 0, pCKP); @@ -654,7 +660,7 @@ short GraphicsDlg(stCloneKeenPlus *pCKP) // Prepare the Games Menu DisplayMenu = new CDialog(); - DisplayMenu->setDimensions(4,4,32,11); + DisplayMenu->setDimensions(4,3,32,13); width = g_pVideoDriver->getWidth(); height = g_pVideoDriver->getHeight(); @@ -720,27 +726,24 @@ short GraphicsDlg(stCloneKeenPlus *pCKP) 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; - }; + if(autoframeskip) + sprintf(buf,"Auto-Frameskip : %d fps",autoframeskip); + else + sprintf(buf,"Auto-Frameskip disabled"); + + DisplayMenu->addOptionText(buf); + + aspect = g_pVideoDriver->getAspectCorrection(); + + if(aspect) + DisplayMenu->addOptionText("Aspect Ratio Enabled"); + else + DisplayMenu->addOptionText("Aspect Ratio Disabled"); DisplayMenu->addSeparator(); DisplayMenu->addOptionText("Save and return"); DisplayMenu->addOptionText("Cancel"); - DisplayMenu->animateDialogBox(true); do @@ -764,29 +767,34 @@ short GraphicsDlg(stCloneKeenPlus *pCKP) if(selection == 0) { // Now the part of the resolution list - if(width == 1024) - { - width = 320; - height = 240; - } - else if(width == 320) + switch(width) { + case 320: width = 640; height = 480; - } - else if(width == 640) - { + break; + case 640: width = 800; height = 600; - } - else if(width == 800) - { + break; + case 800: width = 1024; height = 768; + break; + case 1024: + width = 1280; + height = 1024; + break; + case 1280: + width = 1680; + height = 1050; + break; + default: + width = 320; + height = 240; + break; } - // TODO: Replace this by the available modes list! - sprintf(buf,"Resolution: %dx%dx%d",width,height,depth); DisplayMenu->setOptionText(selection,buf); } @@ -864,30 +872,30 @@ short GraphicsDlg(stCloneKeenPlus *pCKP) } else if(selection == 6) { - if(autoframeskip < 60 && autoframeskip >= 0) - autoframeskip += 10; - else - autoframeskip = 0; - - switch(autoframeskip) + if(autoframeskip < 70 && autoframeskip >= 0) { - 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; - }; + autoframeskip += 10; + sprintf(buf,"Auto-Frameskip : %d fps", autoframeskip); + } + else + { + autoframeskip = 0; + sprintf(buf,"Auto-Frameskip disabled"); + } + + DisplayMenu->setOptionText(6, buf); } - else if(selection == 8) + else if(selection == 7) + { + aspect = !aspect; + + if(aspect) + DisplayMenu->setOptionText(7,"Aspect Ratio Enabled"); + else + DisplayMenu->setOptionText(7,"Aspect Ratio Disabled"); + + } + else if(selection == 9) { g_pVideoDriver->stop(); @@ -903,11 +911,15 @@ short GraphicsDlg(stCloneKeenPlus *pCKP) g_pVideoDriver->setFilter(filter); g_pVideoDriver->setFrameskip(frameskip); g_pVideoDriver->setTargetFPS(autoframeskip); - saveDriverConfiguration(pCKP); - g_pGraphics->allocScrollBufmem(); + g_pVideoDriver->setAspectCorrection(aspect); + + CSettings *Settings; + Settings = new CSettings(); + Settings->saveDrvCfg(); + delete Settings; Settings = NULL; // initialize/activate all drivers - g_pLogFile->ftextOut("Starting graphics driver...
"); + g_pLogFile->ftextOut("Restarting graphics driver... (Menu)
"); if (g_pVideoDriver->start()) retval = 1; @@ -928,7 +940,7 @@ short GraphicsDlg(stCloneKeenPlus *pCKP) DisplayMenu->renderDialog(); // blit the scrollbuffer to the display - gamedo_frameskipping_blitonly(pCKP); + gamedo_frameskipping_blitonly(); g_pInput->pollEvents(); g_pTimer->SpeedThrottle(); @@ -947,10 +959,8 @@ void showPage(char *text, stCloneKeenPlus *pCKP, int textsize) unsigned int i, j, k; int exit=0; int textpos; - //char lastupstate, lastdnstate; - int enter; + bool enter; unsigned int dlgX,dlgY,dlgW,dlgH; - //unsigned char lastkeytable[KEYTABLE_SIZE+1]; unsigned int scroll, maxscroll; char buffer[200][40]; @@ -1059,20 +1069,20 @@ void showPage(char *text, stCloneKeenPlus *pCKP, int textsize) g_pGraphics->sb_font_draw((unsigned char*) coverline, (dlgX+1)<<3, (dlgY+dlgH-1)<<3); // If user presses up or down - if (g_pInput->getHoldedCommand(IC_DOWN)) + if (g_pInput->getHoldedCommand(0,IC_DOWN) || g_pInput->getHoldedCommand(1,IC_DOWN)) { if(scroll < (totnumline-dlgH)<<3) scroll++; SDL_Delay(2); } - else if (g_pInput->getHoldedCommand(IC_UP)) + else if (g_pInput->getHoldedCommand(0,IC_UP) || g_pInput->getHoldedCommand(1,IC_UP)) { if(scroll > 0) scroll--; SDL_Delay(2); } - enter = (g_pInput->getPressedCommand(IC_STATUS));//||g_pInput->getPressedCommand(KCTRL)||g_pInput->getPressedCommand(KALT)); + enter = (g_pInput->getPressedCommand(0,IC_STATUS) || g_pInput->getPressedCommand(1,IC_STATUS)); if (enter) { exit=1; @@ -1152,7 +1162,7 @@ char configmenu(stCloneKeenPlus *pCKP) OptionsMenu->renderDialog(); // blit the scrollbuffer to the display - gamedo_frameskipping_blitonly(pCKP); + gamedo_frameskipping_blitonly(); g_pInput->pollEvents(); g_pTimer->SpeedThrottle(); @@ -1207,31 +1217,56 @@ char controlsmenu(stCloneKeenPlus *pCKP) // Prepare the Games Menu ControlsMenu = new CDialog(); - ControlsMenu->setDimensions(1,1,38,24); + ControlsMenu->setDimensions(1,3,38,20); - g_pInput->getEventName(IC_LEFT,buf2); - sprintf(buf,"Left: %s",buf2); + g_pInput->getEventName(IC_LEFT, 0, buf2); + sprintf(buf,"P1 Left: %s",buf2); ControlsMenu->addOptionText(buf); - g_pInput->getEventName(IC_UP,buf2); - sprintf(buf,"Up: %s",buf2); + g_pInput->getEventName(IC_UP, 0, buf2); + sprintf(buf,"P1 Up: %s",buf2); ControlsMenu->addOptionText(buf); - g_pInput->getEventName(IC_RIGHT,buf2); - sprintf(buf,"Right: %s",buf2); + g_pInput->getEventName(IC_RIGHT, 0, buf2); + sprintf(buf,"P1 Right: %s",buf2); ControlsMenu->addOptionText(buf); - g_pInput->getEventName(IC_DOWN,buf2); - sprintf(buf,"Down: %s",buf2); + g_pInput->getEventName(IC_DOWN, 0, buf2); + sprintf(buf,"P1 Down: %s",buf2); ControlsMenu->addOptionText(buf); - g_pInput->getEventName(IC_JUMP,buf2); - sprintf(buf,"Jump: %s",buf2); + g_pInput->getEventName(IC_JUMP, 0, buf2); + sprintf(buf,"P1 Jump: %s",buf2); ControlsMenu->addOptionText(buf); - g_pInput->getEventName(IC_POGO,buf2); - sprintf(buf,"Pogo: %s",buf2); + g_pInput->getEventName(IC_POGO, 0, buf2); + sprintf(buf,"P1 Pogo: %s",buf2); ControlsMenu->addOptionText(buf); - g_pInput->getEventName(IC_FIRE,buf2); - sprintf(buf,"Fire: %s",buf2); + g_pInput->getEventName(IC_FIRE, 0, buf2); + sprintf(buf,"P1 Fire: %s",buf2); ControlsMenu->addOptionText(buf); - g_pInput->getEventName(IC_STATUS,buf2); - sprintf(buf,"Status: %s",buf2); + g_pInput->getEventName(IC_STATUS, 0, buf2); + sprintf(buf,"P1 Status: %s",buf2); + ControlsMenu->addOptionText(buf); + + g_pInput->getEventName(IC_LEFT, 1, buf2); + sprintf(buf,"P2 Left: %s",buf2); + ControlsMenu->addOptionText(buf); + g_pInput->getEventName(IC_UP, 1, buf2); + sprintf(buf,"P2 Up: %s",buf2); + ControlsMenu->addOptionText(buf); + g_pInput->getEventName(IC_RIGHT, 1, buf2); + sprintf(buf,"P2 Right: %s",buf2); + ControlsMenu->addOptionText(buf); + g_pInput->getEventName(IC_DOWN, 1, buf2); + sprintf(buf,"P2 Down: %s",buf2); + ControlsMenu->addOptionText(buf); + g_pInput->getEventName(IC_JUMP, 1, buf2); + sprintf(buf,"P2 Jump: %s",buf2); + ControlsMenu->addOptionText(buf); + g_pInput->getEventName(IC_POGO, 1, buf2); + sprintf(buf,"P2 Pogo: %s",buf2); + ControlsMenu->addOptionText(buf); + g_pInput->getEventName(IC_FIRE, 1, buf2); + sprintf(buf,"P2 Fire: %s",buf2); + ControlsMenu->addOptionText(buf); + g_pInput->getEventName(IC_STATUS, 1, buf2); + sprintf(buf,"P2 Status: %s",buf2); ControlsMenu->addOptionText(buf); ControlsMenu->addSeparator(); ControlsMenu->addOptionText("Return"); @@ -1266,27 +1301,61 @@ char controlsmenu(stCloneKeenPlus *pCKP) switch(selection) { - case 0: sprintf(buf,"Left: "); break; - case 1: sprintf(buf,"Up: "); break; - case 2: sprintf(buf,"Right: "); break; - case 3: sprintf(buf,"Down: "); break; - case 4: sprintf(buf,"Jump: "); break; - case 5: sprintf(buf,"Pogo: "); break; - case 6: sprintf(buf,"Fire: "); break; - case 7: sprintf(buf,"Status: "); break; + case 0: sprintf(buf,"P1 Left: "); break; + case 1: sprintf(buf,"P1 Up: "); break; + case 2: sprintf(buf,"P1 Right: "); break; + case 3: sprintf(buf,"P1 Down: "); break; + case 4: sprintf(buf,"P1 Jump: "); break; + case 5: sprintf(buf,"P1 Pogo: "); break; + case 6: sprintf(buf,"P1 Fire: "); break; + case 7: sprintf(buf,"P1 Status: "); break; } strcpy(buf2,buf); strcat(buf2,"*Waiting for Input*"); ControlsMenu->setOptionText(selection,buf2); - while(!g_pInput->readNewEvent(item)) + while(!g_pInput->readNewEvent(0,item)) { ControlsMenu->renderDialog(); - gamedo_frameskipping_blitonly(pCKP); + gamedo_frameskipping_blitonly(); } - g_pInput->getEventName(item,buf2); + g_pInput->getEventName(item, 0, buf2); + strcat(buf,buf2); + ControlsMenu->setOptionText(selection,buf); + } + else if(selection >= MAX_COMMANDS && selection < MAX_COMMANDS*2) + { + int item=0; + if(selection < (4 + MAX_COMMANDS)) + item = selection + 4 - MAX_COMMANDS; + else + item = selection - 4 - MAX_COMMANDS; + + switch(selection) + { + case 0+ MAX_COMMANDS: sprintf(buf,"P2 Left: "); break; + case 1+ MAX_COMMANDS: sprintf(buf,"P2 Up: "); break; + case 2+ MAX_COMMANDS: sprintf(buf,"P2 Right: "); break; + case 3+ MAX_COMMANDS: sprintf(buf,"P2 Down: "); break; + case 4+ MAX_COMMANDS: sprintf(buf,"P2 Jump: "); break; + case 5+ MAX_COMMANDS: sprintf(buf,"P2 Pogo: "); break; + case 6+ MAX_COMMANDS: sprintf(buf,"P2 Fire: "); break; + case 7+ MAX_COMMANDS: sprintf(buf,"P2 Status: "); break; + } + + strcpy(buf2,buf); + strcat(buf2,"*Waiting for Input*"); + ControlsMenu->setOptionText(selection,buf2); + + while(!g_pInput->readNewEvent(1,item)) + { + ControlsMenu->renderDialog(); + gamedo_frameskipping_blitonly(); + } + + g_pInput->getEventName(item, 1, buf2); strcat(buf,buf2); ControlsMenu->setOptionText(selection,buf); } @@ -1300,7 +1369,7 @@ char controlsmenu(stCloneKeenPlus *pCKP) ControlsMenu->renderDialog(); // blit the scrollbuffer to the display - gamedo_frameskipping_blitonly(pCKP); + gamedo_frameskipping_blitonly(); g_pInput->pollEvents(); g_pTimer->SpeedThrottle(); @@ -1311,446 +1380,6 @@ char controlsmenu(stCloneKeenPlus *pCKP) return 0; } -int intro(stCloneKeenPlus *pCKP) -{ -int x,y; -unsigned int i; -int yb; - -int curPage, changedPage; -int textVisible; -char stStringName[40]; -char *stStringData; -char stTextLine1[80]; -char stTextLine2[80]; -char stTextLine3[80]; -char SlowPrintBuffer[80]; -int x1,x2,x3,x4,x5; -int y1,y2,y3,y4,y5; -char *copyPtr, copyIndex; - -int ontime, offtime, textTimer; -int y1adj, y2adj, y3adj; -int lastpage; -int SlowPrint, SlowPrintTimer, SlowPrintIndex; -int SlowPrintSpeed; -char keypressed; -char lastkeypressed; -char *SlowPrintPtr; - -const char *ScrollText1 = "Presenting"; -const char *ScrollTextErase = " "; -const char *ScrollText2 = "CloneKeenPlus"; -const char *ScrollText4 = "by Caitlin Shaw"; -const char *ScrollText5 = "and Gerstrong"; -char ScrollText3[20]; -char ScrollTextTimer; -int STimer; -char SState; -char ShowPressF10; -#define PRESSF10_X (160 - (PRESSF10_WIDTH/2)) -#define PRESSF10_Y 3 -//#define PRESSF10_X (315 - PRESSF10_WIDTH) -//#define PRESSF10_Y (195 - PRESSF10_HEIGHT) - - if (!g_pVideoDriver->getFullscreen()) - ShowPressF10 = 0; // 0 = mask hide all - else - ShowPressF10 = 15; // 15 = mask show all - - // display the starry background and initiate a fade-in - showmapatpos(90, 104<<4, 32, 0, pCKP); - fade.mode = FADE_GO; - fade.rate = FADE_NORM; - fade.dir = FADE_IN; - fade.curamt = 0; - fade.fadetimer = 0; - - player[0].hideplayer = 1; - - #define SCROLL_STOP_Y 75 - #define F10_STOP_Y 210 - - /* move "Presenting" up the screen */ - g_pGraphics->setFadeBlack(1); - sprintf(ScrollText3, "Episode %d", pCKP->Control.levelcontrol.episode); - x1 = (320/2) - ((strlen(ScrollText1)*8)/2); - y1 = 235; - x2 = (320/2) - ((strlen(ScrollText2)*8)/2); - y2 = SCROLL_STOP_Y+16; - x3 = (320/2) - ((strlen(ScrollText3)*8)/2); - y3 = y2+24; - x4 = (320/2) - ((strlen(ScrollText4)*8)/2); - y4 = y3+16; - x5 = (320/2) - ((strlen(ScrollText5)*8)/2); - y5 = y4+16; - SState = 0; - STimer = 0; - ScrollTextTimer = 0; - - lastkeypressed = 1; - do - { - // do fades - gamedo_fades(); - gamedo_AnimatedTiles(); - - if (fade.dir != FADE_OUT) - { - // if user pressed a key cancel the intro - keypressed = 0; - for(i=0;igetPressedKey(i)) - { - keypressed = i; - break; - } - } - if (keypressed && !lastkeypressed) - { - fade.dir = FADE_OUT; - fade.curamt = PAL_FADE_SHADES; - fade.fadetimer = 0; - fade.rate = FADE_NORM; - fade.mode = FADE_GO; - IntroCanceled = 1; - } - if (keypressed) lastkeypressed = 1; else lastkeypressed = 0; - - } // end if(fade.dir!=FADE_OUT) - - g_pGraphics->sb_font_draw_inverse( (unsigned char*) ScrollText1, x1, y1); - - if (SState >= 1) - { - g_pGraphics->sb_font_draw_inverse( (unsigned char*) ScrollText2, x2, y2); - if (SState==1) - { - if (STimer > 200) - { - SState = 2; - STimer = 0; - } - else STimer++; - } - } - - if (SState >= 2) - { - g_pGraphics->sb_font_draw_inverse( (unsigned char*) ScrollText3, x3, y3); - if (SState==2) - { - if (STimer > 200) - { - SState = 3; - STimer = 0; - } - else STimer++; - } - } - - if (SState >= 3) - { - g_pGraphics->sb_font_draw_inverse( (unsigned char*) ScrollText4, x4, y4); - if (SState==3) - { - if (STimer > 200) - { - SState = 4; - STimer = 0; - } - else STimer++; - } - } - - if (SState >= 4) - { - g_pGraphics->sb_font_draw_inverse( (unsigned char*) ScrollText5, x5, y5); - if (STimer > 1000) - { - g_pGraphics->setFadeBlack(0); - break; - } - else STimer++; - } - - // if Press F10 message is still visible, display it - if (ShowPressF10) - { - if (y1 <= F10_STOP_Y) ShowPressF10 = 0; - if (g_pVideoDriver->getFullscreen()) ShowPressF10 = 0; - - i = 0; - for(y=0;ygetScrollbuffer()[yb+((PRESSF10_X+x+scrollx_buf)&511)] = (pressf10_image[i++] & ShowPressF10); - } - } - } - - // blit the scrollbuffer to the display - gamedo_frameskipping_blitonly(pCKP); - - if (SState==0) - { - g_pGraphics->sb_font_draw_inverse( (unsigned char*) ScrollTextErase, x1, y1); - - if (y1 > SCROLL_STOP_Y) - { - if (ScrollTextTimer > 10) - { - y1--; - ScrollTextTimer = 0; - } - else ScrollTextTimer++; - } - else - { - if (STimer > 200) - { - SState = 1; - STimer = 0; - } - else STimer++; - } - } - - // when fade is complete we're done! - if (fade.dir==FADE_OUT && fade.mode==FADE_COMPLETE) - { - g_pGraphics->setFadeBlack(0); - return 0; - } - - g_pInput->pollEvents(); - g_pTimer->SpeedThrottle(); - /*if (immediate_keytable[KQUIT] || crashflag) - { - fade_black = 0; - return 1; - }*/ - } while(!g_pInput->getExitEvent()); - - if(g_pInput->getExitEvent()) - return 1; - - g_pGraphics->sb_font_draw_inverse( (unsigned char*) ScrollTextErase, x1, y1); - g_pGraphics->sb_font_draw_inverse( (unsigned char*) ScrollTextErase, x2, y2); - g_pGraphics->sb_font_draw_inverse( (unsigned char*) ScrollTextErase, x3, y3); - g_pGraphics->sb_font_draw_inverse( (unsigned char*) ScrollTextErase, x4, y4); - g_pGraphics->sb_font_draw_inverse( (unsigned char*) ScrollTextErase, x5, y5); - - /* the appearing/disapearing text */ - curPage = 1; - changedPage = 1; - do - { - // do fades - gamedo_fades(); - gamedo_AnimatedTiles(); - - // need to load a new page from the strings file? - if (changedPage) - { - // load the data for the new page - sprintf(stStringName, "Tribute_Page_%d", curPage); - stStringData = getstring(stStringName); - ontime = GetStringAttribute(stStringName, "ONTIME"); - offtime = GetStringAttribute(stStringName, "OFFTIME"); - y1adj = GetStringAttribute(stStringName, "Y1ADJ"); - y2adj = GetStringAttribute(stStringName, "Y2ADJ"); - y3adj = GetStringAttribute(stStringName, "Y3ADJ"); - lastpage = GetStringAttribute(stStringName, "LASTPAGE"); - SlowPrint = GetStringAttribute(stStringName, "SLOWPRINT"); - - // if no SLOWPRINT attribute disable slowprinting - if (SlowPrint==-1) - { - SlowPrint = 0; - } - else - { - SlowPrintSpeed = GetStringAttribute(stStringName, "SLOWPRINTSPD"); - } - - // for y adjustments that weren't specified use 0 - if (y1adj==-1) y1adj = 0; - if (y2adj==-1) y2adj = 0; - if (y3adj==-1) y3adj = 0; - - stTextLine1[0] = stTextLine2[0] = stTextLine3[0] = 0; - - // we have the text as three CR-terminated lines, now split it - // up into the 3 buffers - copyIndex = 0; - copyPtr = stTextLine1; - for(i=0;iControl.levelcontrol.episode + '0'; - } - else - { - SlowPrintBuffer[i] = SlowPrintPtr[i]; - } - } - - // clear out the text line - for(i=0;i SlowPrintSpeed) - { // time to print the next character of the line we're slowprinting - if (SlowPrintBuffer[SlowPrintIndex]) - { - SlowPrintPtr[SlowPrintIndex] = SlowPrintBuffer[SlowPrintIndex]; - SlowPrintIndex++; - } - else - { // reached the NULL (slowprint complete) - SlowPrint = 0; - } - - SlowPrintTimer = 0; - } - else SlowPrintTimer++; - } - - if (fade.dir != FADE_OUT) - { - if (!textTimer) - { // time to either invisibilize the text, or go to the next page - if (textVisible) - { - // erase the text - for(i=0;igetPressedKey(i)) - { - keypressed = 1; - break; - } - } - if (keypressed && !lastkeypressed) - { - fade.dir = FADE_OUT; - fade.curamt = PAL_FADE_SHADES; - fade.fadetimer = 0; - fade.rate = FADE_NORM; - fade.mode = FADE_GO; - IntroCanceled = 1; - } - lastkeypressed = keypressed; - - - } // end if(fade.dir!=FADE_OUT) - - // draw/erase all three lines of text - g_pGraphics->sb_font_draw_inverse( (unsigned char*) stTextLine1, x1, y1); - g_pGraphics->sb_font_draw_inverse( (unsigned char*) stTextLine2, x2, y2); - g_pGraphics->sb_font_draw_inverse( (unsigned char*) stTextLine3, x3, y3); - - // blit the scrollbuffer to the display - gamedo_frameskipping_blitonly(pCKP); - - // when fade is complete we're done! - if (fade.dir==FADE_OUT && fade.mode==FADE_COMPLETE) - { - return 0; - } - - g_pInput->pollEvents(); - g_pTimer->SpeedThrottle(); - } while(!g_pInput->getPressedCommand(KQUIT) && !crashflag); - return 1; -} - void keensleft(stCloneKeenPlus *pCKP) { int enter, lastenterstate; diff --git a/src/sdl/CInput.cpp b/src/sdl/CInput.cpp index b538305f9..a8cb88b3c 100644 --- a/src/sdl/CInput.cpp +++ b/src/sdl/CInput.cpp @@ -10,6 +10,7 @@ #include "CInput.h" #include "../CLogFile.h" +#include "CVideoDriver.h" #ifdef WIZ #include "gp2x.h" @@ -26,42 +27,54 @@ CInput::CInput() { for(i=0 ; igetFullscreen(); + value = !value; + g_pLogFile->textOut(GREEN,"Fullscreen mode triggered by user!
"); + g_pVideoDriver->isFullscreen(value); + + // initialize/activate all drivers + g_pLogFile->ftextOut("Restarting graphics driver...
"); + if (!g_pVideoDriver->applyMode()) + { + value = !value; + g_pLogFile->ftextOut(PURPLE, "Couldn't change the resolution, Rolling back...
"); + if(g_pVideoDriver->applyMode()) g_pVideoDriver->initOpenGL(); + } + else + g_pVideoDriver->initOpenGL(); + + + if(value) g_pVideoDriver->AddConsoleMsg("Fullscreen enabled"); + else g_pVideoDriver->AddConsoleMsg("Fullscreen disabled"); + } + + // Check, if LALT+Q or LALT+F4 was pressed + if(getHoldedKey(KLALT) && (getPressedKey(KF4) || getPressedKey(KQ)) ) + { + g_pLogFile->textOut("User exit request!"); + m_exit = true; + } + + #ifdef WIZ - WIZ_AdjustVolume( volume_direction ); + WIZ_AdjustVolume( volume_direction ); #endif } void CInput::processJoystickAxis(void) { - unsigned int i; - for(i=0 ; i 3200 && InputCommand[i].joyvalue > 0) || - (Event.jaxis.value < -3200 && InputCommand[i].joyvalue < 0)) - InputCommand[i].active = true; - else - InputCommand[i].active = false; + // Axis are configured for this commmand + if(Event.jaxis.axis == InputCommand[j][i].joyaxis && Event.jaxis.which == InputCommand[j][i].which ) + { + // Deadzone + if((Event.jaxis.value > 3200 && InputCommand[0][i].joyvalue > 0) || + (Event.jaxis.value < -3200 && InputCommand[0][i].joyvalue < 0)) + InputCommand[j][i].active = true; + else + InputCommand[j][i].active = false; + } } } } @@ -220,14 +269,17 @@ void CInput::processJoystickButton(int value) #ifdef WIZ WIZ_EmuKeyboard( Event.jbutton.button, value ); #else - unsigned int i; - for(i=0 ; igetTargetFPS(); - if(targetfps > 0) + if(targetfps > 0 && fps > 0) { if(fps > targetfps + 10) { diff --git a/src/sdl/CVideoDriver.cpp b/src/sdl/CVideoDriver.cpp index 9e2bf6af7..ec048cc74 100644 --- a/src/sdl/CVideoDriver.cpp +++ b/src/sdl/CVideoDriver.cpp @@ -47,6 +47,17 @@ CVideoDriver::CVideoDriver() { // Default values showfps=true; +#ifdef WIZ + Width=320; + Height=240; + Depth=16; + Mode=0; + Fullscreen=true; + Filtermode=0; + Zoom=1; + FrameSkip=0; + m_targetfps = 30; // Enable automatic frameskipping by default at 30 +#else Width=640; Height=480; Depth=0; @@ -56,11 +67,13 @@ CVideoDriver::CVideoDriver() { Zoom=2; FrameSkip=2; m_targetfps = 0; // Disable automatic frameskipping by default +#endif m_opengl = false; #ifdef USE_OPENGL m_opengl_filter = GL_NEAREST; mp_OpenGL = NULL; #endif + m_aspect_correction = true; screenrect.x=0; screenrect.y=0; @@ -79,9 +92,9 @@ CVideoDriver::~CVideoDriver() { void CVideoDriver::stop(void) { - if(screen) { SDL_FreeSurface(screen); g_pLogFile->textOut("freed screen
"); } - if(ScrollSurface && (ScrollSurface->map != NULL)) { SDL_FreeSurface(ScrollSurface); g_pLogFile->textOut("freed scrollsurface
"); } - if(blitsurface_alloc) { blitsurface_alloc = 0; SDL_FreeSurface(BlitSurface); g_pLogFile->textOut("freed blitsurface
"); } + if(screen) { SDL_FreeSurface(screen); g_pLogFile->textOut("freed screen
"); screen = NULL; } + if(ScrollSurface && (ScrollSurface->map != NULL)) { SDL_FreeSurface(ScrollSurface); g_pLogFile->textOut("freed scrollsurface
"); ScrollSurface = NULL; } + if(blitsurface_alloc) { blitsurface_alloc = 0; SDL_FreeSurface(BlitSurface); g_pLogFile->textOut("freed blitsurface
"); BlitSurface=NULL; } #ifdef USE_OPENGL if(mp_OpenGL) { delete mp_OpenGL; mp_OpenGL = NULL; } #endif @@ -91,32 +104,53 @@ void CVideoDriver::stop(void) bool CVideoDriver::start(void) { + bool retval = false; + if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_AUDIO) < 0) { g_pLogFile->textOut(RED,"Could not initialize SDL: %s
", SDL_GetError()); return false; } - if (is_server) - { - SDL_WM_SetCaption("CloneKeenPlus [host]", NULL); - } - else if (is_client) - { - SDL_WM_SetCaption("CloneKeenPlus [multiplayer]", NULL); - } else - { - SDL_WM_SetCaption("CloneKeenPlus", NULL); - } + g_pLogFile->textOut(GREEN,"SDL was successfully initialized!
"); + SDL_WM_SetCaption("Commander Genius (CKP)", NULL); // When the program is through executing, call SDL_Quit atexit(SDL_Quit); if(!applyMode()) + { + g_pLogFile->textOut(RED,"VideoDriver: Error applying mode! Your Videocard doesn't seem to work on CKP
"); + g_pLogFile->textOut(RED,"Check, if you have the most recent drivers installed!
"); return false; + } - return createSurfaces(); + retval = createSurfaces(); + initOpenGL(); + + return retval; } + +bool CVideoDriver::initOpenGL() +{ +#ifdef USE_OPENGL + if(m_opengl) // If OpenGL could be set, initialize the matrices + { + mp_OpenGL = new COpenGL(); + if(!(mp_OpenGL->initGL(Width, Height, Depth, m_opengl_filter, Filtermode+1, m_aspect_correction))) + { + delete mp_OpenGL; + mp_OpenGL = NULL; + m_opengl = false; + } + else + mp_OpenGL->setSurface(BlitSurface); + } +#endif + + return m_opengl; +} + bool CVideoDriver::applyMode(void) { // Check if some zoom/filter modes are illogical @@ -256,21 +290,6 @@ bool CVideoDriver::createSurfaces(void) dstrect.w = GAME_STD_WIDTH; dstrect.h = GAME_STD_HEIGHT; -#ifdef USE_OPENGL - if(m_opengl) // If OpenGL could be set, initialize the matrices - { - mp_OpenGL = new COpenGL(); - if(!(mp_OpenGL->initGL(Width, Height, Depth, m_opengl_filter, Filtermode+1))) - { - delete mp_OpenGL; - mp_OpenGL = NULL; - m_opengl = false; - } - else - mp_OpenGL->setSurface(BlitSurface); - } -#endif - return true; } @@ -635,37 +654,8 @@ void CVideoDriver::showFPS(bool value){ showfps = value; } void CVideoDriver::isFullscreen(bool value) { - //SDL_Rect** Modes; - //int i; - - //if(value == false) - //{ - Fullscreen = value; - return; - //} - - /*Modes = SDL_ListModes(NULL, SDL_FULLSCREEN); - - // Check if there are any modes available - if (Modes == (SDL_Rect**)0) { - g_pLogFile->textOut(PURPLE,"No modes for Fullscreen available!
"); - } - - // Print valid modes - for (i=0; Modes[i]; ++i) - { - if(Modes[i]->w == Width) - { - if(Modes[i]->h == Height) - { - Fullscreen = value; - return; - } - } - } - g_pLogFile->textOut(PURPLE,"This mode doesn't exist for Fullscreen!
"); - - Fullscreen = value;*/ + Fullscreen = value; + return; } unsigned short CVideoDriver::getFrameskip(void) diff --git a/src/sdl/CVideoDriver.h b/src/sdl/CVideoDriver.h index 5b9f35b01..0d98a5a95 100644 --- a/src/sdl/CVideoDriver.h +++ b/src/sdl/CVideoDriver.h @@ -71,16 +71,20 @@ public: void setZoom(short vale); #ifdef USE_OPENGL void enableOpenGL(bool value) { m_opengl = value; } + bool initOpenGL(); void setOGLFilter(unsigned char value) { m_opengl_filter = (value==1) ? GL_LINEAR : GL_NEAREST ; } #else void enableOpenGL(bool value) { m_opengl = false; } void setOGLFilter(unsigned char value) { m_opengl_filter = 0; } #endif - void setTargetFPS(unsigned int targetfps){ if( targetfps >= 0 && targetfps <= 60 ) m_targetfps = targetfps; } + void setTargetFPS(unsigned int targetfps){ if( targetfps >= 0 && targetfps <= 70 ) m_targetfps = targetfps; } unsigned char getTargetFPS(void){ return m_targetfps; } void showFPS(bool value); + void setAspectCorrection(bool value) { m_aspect_correction = value; } + bool getAspectCorrection(void) { return m_aspect_correction; } + private: #ifdef USE_OPENGL COpenGL *mp_OpenGL; @@ -98,6 +102,7 @@ private: bool showfps; bool m_opengl; int m_opengl_filter; + bool m_aspect_correction; SDL_Rect screenrect; SDL_Rect blitrect; diff --git a/src/sdl/sound/CSound.cpp b/src/sdl/sound/CSound.cpp index e0a9a264e..5ab61c2d9 100644 --- a/src/sdl/sound/CSound.cpp +++ b/src/sdl/sound/CSound.cpp @@ -502,7 +502,12 @@ char CSound::extractOfExeFile(char *inputpath, int episode) if (get_bit(&bit_count, &fin)) { unsigned char tmp[2]; - fread(tmp, 1, 2, fin); + if(fread(tmp, 1, 2, fin)) + { + g_pLogFile->ftextOut(RED,"Read-Error!"); + return 1; + } + repeat = (tmp[1] & 0x07); offset = ((tmp[1] & ~0x07) << 5) | tmp[0] | 0xE000;