added engine states, separate fullscreen smush playback depend on engine mode
This commit is contained in:
parent
4b07d850fc
commit
098f0b2b2c
6 changed files with 73 additions and 42 deletions
94
engine.cpp
94
engine.cpp
|
@ -84,61 +84,75 @@ void Engine::mainLoop() {
|
||||||
// Run asynchronous tasks
|
// Run asynchronous tasks
|
||||||
lua_runtasks();
|
lua_runtasks();
|
||||||
|
|
||||||
if (SCREENBLOCKS_GLOBAL == 1)
|
if (_mode == ENGINE_MODE_SMUSH) {
|
||||||
screenBlocksReset();
|
if (g_smush->isPlaying()) {
|
||||||
|
movieTime_ = g_smush->getMovieTime();
|
||||||
|
if (g_smush->isUpdateNeeded()) {
|
||||||
|
g_driver->prepareSmushFrame(g_smush->getWidth(), g_smush->getHeight(), g_smush->getDstPtr());
|
||||||
|
g_smush->clearUpdateNeeded();
|
||||||
|
}
|
||||||
|
g_driver->drawSmushFrame(g_smush->getX(), g_smush->getY());
|
||||||
|
}
|
||||||
|
// Draw text
|
||||||
|
for (text_list_type::iterator i = textObjects_.begin(); i != textObjects_.end(); i++) {
|
||||||
|
(*i)->draw();
|
||||||
|
}
|
||||||
|
g_driver->flipBuffer();
|
||||||
|
} else if (_mode == ENGINE_MODE_NORMAL) {
|
||||||
|
if (SCREENBLOCKS_GLOBAL == 1)
|
||||||
|
screenBlocksReset();
|
||||||
|
|
||||||
// Update actor costumes
|
// Update actor costumes
|
||||||
for (actor_list_type::iterator i = actors_.begin(); i != actors_.end(); i++) {
|
for (actor_list_type::iterator i = actors_.begin(); i != actors_.end(); i++) {
|
||||||
Actor *a = *i;
|
Actor *a = *i;
|
||||||
assert(currScene_);
|
assert(currScene_);
|
||||||
if (a->inSet(currScene_->name()) && a->visible())
|
if (a->inSet(currScene_->name()) && a->visible())
|
||||||
a->update();
|
a->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
g_driver->clearScreen();
|
g_driver->clearScreen();
|
||||||
|
|
||||||
if (SCREENBLOCKS_GLOBAL == 1)
|
if (SCREENBLOCKS_GLOBAL == 1)
|
||||||
screenBlocksBlitDirtyBlocks();
|
screenBlocksBlitDirtyBlocks();
|
||||||
|
|
||||||
if (!g_smush->isPlaying() || (g_smush->isPlaying() && !g_smush->isFullSize())) {
|
|
||||||
Bitmap::prepareDraw();
|
Bitmap::prepareDraw();
|
||||||
if (currScene_ != NULL)
|
if (currScene_ != NULL)
|
||||||
currScene_->drawBackground();
|
currScene_->drawBackground();
|
||||||
}
|
|
||||||
|
|
||||||
if (g_smush->isPlaying()) {
|
if (g_smush->isPlaying()) {
|
||||||
movieTime_ = g_smush->getMovieTime();
|
movieTime_ = g_smush->getMovieTime();
|
||||||
if (g_smush->isUpdateNeeded()) {
|
if (g_smush->isUpdateNeeded()) {
|
||||||
g_driver->prepareSmushFrame(g_smush->getWidth(), g_smush->getHeight(), g_smush->getDstPtr());
|
g_driver->prepareSmushFrame(g_smush->getWidth(), g_smush->getHeight(), g_smush->getDstPtr());
|
||||||
g_smush->clearUpdateNeeded();
|
g_smush->clearUpdateNeeded();
|
||||||
|
}
|
||||||
|
g_driver->drawSmushFrame(g_smush->getX(), g_smush->getY());
|
||||||
}
|
}
|
||||||
g_driver->drawSmushFrame(g_smush->getX(), g_smush->getY());
|
|
||||||
}
|
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
if (currScene_ != NULL)
|
if (currScene_ != NULL)
|
||||||
currScene_->setupCamera();
|
currScene_->setupCamera();
|
||||||
|
|
||||||
// Draw actors
|
// Draw actors
|
||||||
if (!g_smush->isPlaying() || (g_smush->isPlaying() && !g_smush->isFullSize())) {
|
if (!g_smush->isPlaying()) {
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
for (actor_list_type::iterator i = actors_.begin(); i != actors_.end(); i++) {
|
for (actor_list_type::iterator i = actors_.begin(); i != actors_.end(); i++) {
|
||||||
Actor *a = *i;
|
Actor *a = *i;
|
||||||
if (a->inSet(currScene_->name()) && a->visible())
|
if (a->inSet(currScene_->name()) && a->visible())
|
||||||
a->draw();
|
a->draw();
|
||||||
|
}
|
||||||
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
//screenBlocksDrawDebug();
|
||||||
}
|
}
|
||||||
glDisable(GL_TEXTURE_2D);
|
|
||||||
//screenBlocksDrawDebug();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw text
|
// Draw text
|
||||||
for (text_list_type::iterator i = textObjects_.begin(); i != textObjects_.end(); i++) {
|
for (text_list_type::iterator i = textObjects_.begin(); i != textObjects_.end(); i++) {
|
||||||
(*i)->draw();
|
(*i)->draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
g_driver->flipBuffer();
|
g_driver->flipBuffer();
|
||||||
|
}
|
||||||
|
|
||||||
// don't kill CPU
|
// don't kill CPU
|
||||||
SDL_Delay(1);
|
SDL_Delay(1);
|
||||||
|
|
9
engine.h
9
engine.h
|
@ -26,6 +26,12 @@
|
||||||
|
|
||||||
class Actor;
|
class Actor;
|
||||||
|
|
||||||
|
#define ENGINE_MODE_IDLE 0
|
||||||
|
#define ENGINE_MODE_PAUSE 1
|
||||||
|
#define ENGINE_MODE_NORMAL 2
|
||||||
|
#define ENGINE_MODE_SMUSH 3
|
||||||
|
#define ENGINE_MODE_DRAW 4
|
||||||
|
|
||||||
// Fake SDLK_* values for joystick and mouse events
|
// Fake SDLK_* values for joystick and mouse events
|
||||||
enum {
|
enum {
|
||||||
SDLK_JOY1_B1 = SDLK_LAST,
|
SDLK_JOY1_B1 = SDLK_LAST,
|
||||||
|
@ -86,6 +92,8 @@ public:
|
||||||
return instance_;
|
return instance_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setMode(int mode) { _mode = mode; }
|
||||||
|
|
||||||
void mainLoop();
|
void mainLoop();
|
||||||
unsigned frameStart() const { return frameStart_; }
|
unsigned frameStart() const { return frameStart_; }
|
||||||
unsigned frameTime() const { return frameTime_; }
|
unsigned frameTime() const { return frameTime_; }
|
||||||
|
@ -137,6 +145,7 @@ private:
|
||||||
~Engine() { }
|
~Engine() { }
|
||||||
|
|
||||||
Scene *currScene_;
|
Scene *currScene_;
|
||||||
|
int _mode;
|
||||||
|
|
||||||
unsigned frameStart_, frameTime_, movieTime_;
|
unsigned frameStart_, frameTime_, movieTime_;
|
||||||
|
|
||||||
|
|
2
lua.cpp
2
lua.cpp
|
@ -1028,6 +1028,7 @@ static void GetTextObjectDimensions() {
|
||||||
|
|
||||||
static void StartFullscreenMovie() {
|
static void StartFullscreenMovie() {
|
||||||
bool mode = getbool(2);
|
bool mode = getbool(2);
|
||||||
|
Engine::instance()->setMode(ENGINE_MODE_SMUSH);
|
||||||
pushbool(g_smush->play(luaL_check_string(1), 0, 0));
|
pushbool(g_smush->play(luaL_check_string(1), 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1035,6 +1036,7 @@ static void StartMovie() {
|
||||||
bool mode = getbool(2);
|
bool mode = getbool(2);
|
||||||
int x = lua_getparam(3);
|
int x = lua_getparam(3);
|
||||||
int y = lua_getparam(4);
|
int y = lua_getparam(4);
|
||||||
|
Engine::instance()->setMode(ENGINE_MODE_NORMAL);
|
||||||
pushbool(g_smush->play(luaL_check_string(1), x, y));
|
pushbool(g_smush->play(luaL_check_string(1), x, y));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
1
main.cpp
1
main.cpp
|
@ -121,6 +121,7 @@ int main(int argc, char *argv[]) {
|
||||||
lua_call("BOOT");
|
lua_call("BOOT");
|
||||||
lua_endblock();
|
lua_endblock();
|
||||||
|
|
||||||
|
Engine::instance()->setMode(ENGINE_MODE_NORMAL);
|
||||||
Engine::instance()->mainLoop();
|
Engine::instance()->mainLoop();
|
||||||
|
|
||||||
delete g_smush;
|
delete g_smush;
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "mixer/mixer.h"
|
#include "mixer/mixer.h"
|
||||||
#include "driver_gl.h"
|
#include "driver_gl.h"
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
|
#include "engine.h"
|
||||||
|
|
||||||
Smush *g_smush;
|
Smush *g_smush;
|
||||||
|
|
||||||
|
@ -217,6 +218,11 @@ bool Smush::setupAnim(const char *file, int x, int y) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Smush::stop() {
|
||||||
|
deinit();
|
||||||
|
Engine::instance()->setMode(ENGINE_MODE_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
bool Smush::play(const char *filename, int x, int y) {
|
bool Smush::play(const char *filename, int x, int y) {
|
||||||
deinit();
|
deinit();
|
||||||
|
|
||||||
|
|
3
smush.h
3
smush.h
|
@ -74,7 +74,7 @@ public:
|
||||||
~Smush();
|
~Smush();
|
||||||
|
|
||||||
bool play(const char *filename, int x, int y);
|
bool play(const char *filename, int x, int y);
|
||||||
void stop() { deinit(); }
|
void stop();
|
||||||
void pause(bool pause) { _videoPause = pause; }
|
void pause(bool pause) { _videoPause = pause; }
|
||||||
bool isPlaying() { return !_videoFinished; }
|
bool isPlaying() { return !_videoFinished; }
|
||||||
bool isUpdateNeeded() { return _updateNeeded; }
|
bool isUpdateNeeded() { return _updateNeeded; }
|
||||||
|
@ -84,7 +84,6 @@ public:
|
||||||
int getWidth() {return _width; }
|
int getWidth() {return _width; }
|
||||||
int getHeight() { return _height; }
|
int getHeight() { return _height; }
|
||||||
void clearUpdateNeeded() { _updateNeeded = false; }
|
void clearUpdateNeeded() { _updateNeeded = false; }
|
||||||
bool isFullSize() { return ( _width == 640 && _height == 480); }
|
|
||||||
int32 getMovieTime() { return _movieTime; }
|
int32 getMovieTime() { return _movieTime; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue