PRIVATE: some more functions implemented
This commit is contained in:
parent
cae1b214a8
commit
ccef0fb704
4 changed files with 112 additions and 44 deletions
|
@ -33,7 +33,6 @@ void saveSetting(char *name)
|
|||
Common::String s(name);
|
||||
settingcode.setVal(s, psetting);
|
||||
debug("setting %s %x, %x, %x", name, psetting, psetting->prog, psetting->stack);
|
||||
|
||||
}
|
||||
|
||||
void loadSetting(Common::String *name)
|
||||
|
@ -104,17 +103,11 @@ int funcpush() //(char *name, int nargs)
|
|||
debug("executing %s with %d params", s.str, n.val);
|
||||
for (int i = 0; i < n.val; i++) {
|
||||
arg = pop();
|
||||
//if (arg.sym != NULL)
|
||||
// debug("arg name", arg->sym->name.c_str());
|
||||
debug("%d", arg.val);
|
||||
//debug("%d", arg.val);
|
||||
args.insert(args.begin(), arg) ;
|
||||
}
|
||||
|
||||
execFunction(s.str, args);
|
||||
//pc++;
|
||||
//d.sym = (Symbol *)(*pc++);
|
||||
//printf("var pushing %s", d.sym->name);
|
||||
//push(d);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -237,14 +230,6 @@ int ne()
|
|||
return 0;
|
||||
}
|
||||
|
||||
int print() /* pop top value from stack, print it */
|
||||
{
|
||||
Datum d;
|
||||
d = pop();
|
||||
//printf("\t%d\n", d.val);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Inst *code(Inst f) /* install one instruction or operand */
|
||||
{
|
||||
Inst *oprogp = progp;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "common/str.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/system.h"
|
||||
|
||||
#include "grammar.h"
|
||||
#include "private.h"
|
||||
|
@ -35,6 +36,30 @@ void Sound(ArgArray args) {
|
|||
}
|
||||
}
|
||||
|
||||
void Bitmap(ArgArray args) {
|
||||
assert(args.size() == 1 || args.size() == 3);
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
|
||||
char *f = args[0].str;
|
||||
if (args.size() == 3) {
|
||||
x = args[1].val;
|
||||
y = args[2].val;
|
||||
}
|
||||
|
||||
debug("Bitmap(%s, %d, %d)", f, x, y);
|
||||
Common::String *s = new Common::String(args[0].str);
|
||||
_private->loadImage(*s, x, y);
|
||||
}
|
||||
|
||||
void Timer(ArgArray args) {
|
||||
debug("Timer(%d, %s, %s)", args[0].val, args[1].str, args[2].str);
|
||||
g_system->delayMillis(1000 * args[0].val);
|
||||
Common::String *s = new Common::String(args[1].str);
|
||||
_nextSetting = s;
|
||||
}
|
||||
|
||||
|
||||
void execFunction(char *name, ArgArray args) {
|
||||
if (strcmp(name, "ChgMode") == 0) {
|
||||
|
@ -50,7 +75,15 @@ void execFunction(char *name, ArgArray args) {
|
|||
else if (strcmp(name, "Sound") == 0) {
|
||||
Sound(args);
|
||||
}
|
||||
|
||||
else if (strcmp(name, "Bitmap") == 0) {
|
||||
Bitmap(args);
|
||||
}
|
||||
else if (strcmp(name, "Timer") == 0) {
|
||||
Timer(args);
|
||||
}
|
||||
else if (strcmp(name, "Exit") == 0) {
|
||||
;
|
||||
}
|
||||
else
|
||||
assert(0);
|
||||
|
||||
|
|
|
@ -11,9 +11,12 @@
|
|||
#include "common/file.h"
|
||||
#include "common/fs.h"
|
||||
#include "common/system.h"
|
||||
#include "common/str.h"
|
||||
|
||||
#include "engines/util.h"
|
||||
|
||||
#include "image/bmp.h"
|
||||
|
||||
#include "private/private.h"
|
||||
#include "private/grammar.tab.h"
|
||||
#include "private/grammar.h"
|
||||
|
@ -28,13 +31,21 @@ PrivateEngine *_private = NULL;
|
|||
|
||||
extern int parse(char*);
|
||||
|
||||
Common::String &lowercase(Common::String &val) {
|
||||
Common::String::iterator i;
|
||||
for (i = val.begin(); i != val.end(); i++)
|
||||
*i = tolower(*i);
|
||||
return val;
|
||||
}
|
||||
Common::String convertPath(Common::String name) {
|
||||
Common::String path(name);
|
||||
Common::String s1("\\");
|
||||
Common::String s2("/");
|
||||
|
||||
Common::replace(path, s1, s2);
|
||||
s1 = Common::String("\"");
|
||||
s2 = Common::String("");
|
||||
|
||||
Common::replace(path, s1, s2);
|
||||
Common::replace(path, s1, s2);
|
||||
|
||||
path.toLowercase();
|
||||
return path;
|
||||
}
|
||||
|
||||
PrivateEngine::PrivateEngine(OSystem *syst)
|
||||
: Engine(syst) {
|
||||
|
@ -87,6 +98,8 @@ Common::Error PrivateEngine::run() {
|
|||
_screenW = 640;
|
||||
_screenH = 480;
|
||||
initGraphics(_screenW, _screenH);
|
||||
_image = new Image::BitmapDecoder();
|
||||
_compositeSurface = nullptr;
|
||||
|
||||
// You could use backend transactions directly as an alternative,
|
||||
// but it isn't recommended, until you want to handle the error values
|
||||
|
@ -121,7 +134,7 @@ Common::Error PrivateEngine::run() {
|
|||
|
||||
// Simple main event loop
|
||||
Common::Event evt;
|
||||
_videoDecoder = new Video::SmackerDecoder();
|
||||
_videoDecoder = nullptr; //new Video::SmackerDecoder();
|
||||
|
||||
_nextSetting = new Common::String("kGoIntro");
|
||||
|
||||
|
@ -140,6 +153,9 @@ Common::Error PrivateEngine::run() {
|
|||
}
|
||||
}
|
||||
|
||||
if (_compositeSurface)
|
||||
drawScreen();
|
||||
|
||||
if (_nextSetting != NULL) {
|
||||
debug("Executing %s", _nextSetting->c_str());
|
||||
loadSetting(_nextSetting);
|
||||
|
@ -181,20 +197,9 @@ void PrivateEngine::syncGameStream(Common::Serializer &s) {
|
|||
void PrivateEngine::playSound(const Common::String &name) {
|
||||
debugC(1, kPrivateDebugExample, "%s : %s", __FUNCTION__, name.c_str());
|
||||
|
||||
Common::String path(name);
|
||||
Common::String s1("\\");
|
||||
Common::String s2("/");
|
||||
|
||||
Common::replace(path, s1, s2);
|
||||
s1 = Common::String("\"");
|
||||
s2 = Common::String("");
|
||||
|
||||
Common::replace(path, s1, s2);
|
||||
Common::replace(path, s1, s2);
|
||||
|
||||
lowercase(path);
|
||||
|
||||
Common::File *file = new Common::File();
|
||||
Common::String path = convertPath(name);
|
||||
|
||||
if (!file->open(path))
|
||||
error("unable to find sound file %s", path.c_str());
|
||||
|
||||
|
@ -222,25 +227,58 @@ void PrivateEngine::stopSound() {
|
|||
_mixer->stopHandle(_soundHandle);
|
||||
}
|
||||
|
||||
void PrivateEngine::loadImage(const Common::String &name, int x, int y) {
|
||||
debugC(1, kPrivateDebugExample, "%s : %s", __FUNCTION__, name.c_str());
|
||||
Common::File file;
|
||||
Common::String path = convertPath(name);
|
||||
if (!file.open(path))
|
||||
error("unable to load image %s", path.c_str());
|
||||
|
||||
_image->loadStream(file);
|
||||
Graphics::Surface *surf;
|
||||
if (!_compositeSurface)
|
||||
_compositeSurface = new Graphics::Surface();
|
||||
_compositeSurface->create(_screenW, _screenH, _image->getSurface()->format );
|
||||
|
||||
_compositeSurface->copyRectToSurface(*_image->getSurface(), x, y,
|
||||
Common::Rect(0, 0, _image->getSurface()->w, _image->getSurface()->h));
|
||||
|
||||
//delete _compositeSurface;
|
||||
/*if (_compositeSurface) {
|
||||
delete _compositeSurface;
|
||||
_compositeSurface = nullptr;
|
||||
}*/
|
||||
drawScreen();
|
||||
}
|
||||
|
||||
|
||||
void PrivateEngine::drawScreen() {
|
||||
if (_videoDecoder && _videoDecoder->needsUpdate()) {
|
||||
if (_videoDecoder ? _videoDecoder->needsUpdate() : false || _compositeSurface) {
|
||||
Graphics::Surface *screen = g_system->lockScreen();
|
||||
screen->fillRect(Common::Rect(0, 0, g_system->getWidth(), g_system->getHeight()), 0);
|
||||
//screen->fillRect(Common::Rect(0, 0, g_system->getWidth(), g_system->getHeight()), 0);
|
||||
|
||||
const Graphics::Surface *surface;
|
||||
surface = _videoDecoder->decodeNextFrame();
|
||||
/*if (_videoDecoder)
|
||||
surface = _videoDecoder->decodeNextFrame();
|
||||
else*/ if (_compositeSurface)
|
||||
surface = _compositeSurface;
|
||||
else
|
||||
assert(0);
|
||||
// surface = _image->getSurface();
|
||||
|
||||
int w = surface->w; //CLIP<int>(surface->w, 0, _screenW);
|
||||
int h = surface->h; //CLIP<int>(surface->h, 0, _screenH);
|
||||
|
||||
//int x = (_screenW - w) / 2;
|
||||
//int y = (_screenH - h) / 2;
|
||||
//debug("%d %d %d %d", w, h, x, y);
|
||||
//debug("%d %d", w, h);
|
||||
|
||||
screen->copyRectToSurface(*surface, 0, 0, Common::Rect(0, 0, w, h));
|
||||
|
||||
g_system->unlockScreen();
|
||||
g_system->getPaletteManager()->setPalette(_videoDecoder->getPalette(), 0, 256);
|
||||
if (_image->getPalette() != nullptr)
|
||||
g_system->getPaletteManager()->setPalette(_image->getPalette(), 0, 256);
|
||||
//g_system->getPaletteManager()->setPalette(_videoDecoder->getPalette(), 0, 256);
|
||||
g_system->updateScreen();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,14 @@
|
|||
#include "video/smk_decoder.h"
|
||||
#include "graphics/palette.h"
|
||||
|
||||
namespace Image {
|
||||
class ImageDecoder;
|
||||
}
|
||||
|
||||
namespace Graphics {
|
||||
struct Surface;
|
||||
}
|
||||
|
||||
namespace Private {
|
||||
|
||||
class Console;
|
||||
|
@ -32,6 +40,9 @@ class PrivateEngine : public Engine {
|
|||
private:
|
||||
// We need random numbers
|
||||
Common::RandomSource *_rnd;
|
||||
Image::ImageDecoder *_image;
|
||||
Graphics::Surface *_compositeSurface;
|
||||
|
||||
int _screenW, _screenH;
|
||||
|
||||
public:
|
||||
|
@ -52,8 +63,9 @@ public:
|
|||
|
||||
void playSound(const Common::String &name);
|
||||
void playVideo(const Common::String &name);
|
||||
|
||||
void stopSound();
|
||||
|
||||
void loadImage(const Common::String &name, int x, int y);
|
||||
void drawScreen();
|
||||
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue